Commit 4e987f82 authored by Ronald S. Bultje's avatar Ronald S. Bultje
Browse files

h264: correct border check.

When backing up the top-left border, check that the top-left
(rather than left) MB indeed does belong to our slice. If it
doesn't, backing up has no positive effect but may accidentally
interfere with other threads writing in the same space.

Fixes occasional one-off effects when enabling slice-MT.
parent 0ffc8415
...@@ -1034,7 +1034,7 @@ static inline void xchg_mb_border(H264Context *h, uint8_t *src_y, ...@@ -1034,7 +1034,7 @@ static inline void xchg_mb_border(H264Context *h, uint8_t *src_y,
int linesize, int uvlinesize, int linesize, int uvlinesize,
int xchg, int simple, int pixel_shift){ int xchg, int simple, int pixel_shift){
MpegEncContext * const s = &h->s; MpegEncContext * const s = &h->s;
int deblock_left; int deblock_topleft;
int deblock_top; int deblock_top;
int top_idx = 1; int top_idx = 1;
uint8_t *top_border_m1; uint8_t *top_border_m1;
...@@ -1050,11 +1050,11 @@ static inline void xchg_mb_border(H264Context *h, uint8_t *src_y, ...@@ -1050,11 +1050,11 @@ static inline void xchg_mb_border(H264Context *h, uint8_t *src_y,
} }
if(h->deblocking_filter == 2) { if(h->deblocking_filter == 2) {
deblock_left = h->left_type[0]; deblock_topleft = h->slice_table[h->mb_xy - 1 - s->mb_stride] == h->slice_num;
deblock_top = h->top_type; deblock_top = h->top_type;
} else { } else {
deblock_left = (s->mb_x > 0); deblock_topleft = (s->mb_x > 0);
deblock_top = (s->mb_y > !!MB_FIELD); deblock_top = (s->mb_y > !!MB_FIELD);
} }
src_y -= linesize + 1 + pixel_shift; src_y -= linesize + 1 + pixel_shift;
...@@ -1077,7 +1077,7 @@ if (xchg) AV_SWAP64(b,a);\ ...@@ -1077,7 +1077,7 @@ if (xchg) AV_SWAP64(b,a);\
else AV_COPY64(b,a); else AV_COPY64(b,a);
if(deblock_top){ if(deblock_top){
if(deblock_left){ if(deblock_topleft){
XCHG(top_border_m1 + (8 << pixel_shift), src_y - (7 << pixel_shift), 1); XCHG(top_border_m1 + (8 << pixel_shift), src_y - (7 << pixel_shift), 1);
} }
XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg); XCHG(top_border + (0 << pixel_shift), src_y + (1 << pixel_shift), xchg);
...@@ -1088,7 +1088,7 @@ else AV_COPY64(b,a); ...@@ -1088,7 +1088,7 @@ else AV_COPY64(b,a);
} }
if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){
if(deblock_top){ if(deblock_top){
if(deblock_left){ if(deblock_topleft){
XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1); XCHG(top_border_m1 + (16 << pixel_shift), src_cb - (7 << pixel_shift), 1);
XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1); XCHG(top_border_m1 + (24 << pixel_shift), src_cr - (7 << pixel_shift), 1);
} }
...@@ -2611,7 +2611,7 @@ static void loop_filter(H264Context *h, int start_x, int end_x){ ...@@ -2611,7 +2611,7 @@ static void loop_filter(H264Context *h, int start_x, int end_x){
} }
} }
h->slice_type= old_slice_type; h->slice_type= old_slice_type;
s->mb_x= 0; s->mb_x= end_x;
s->mb_y= end_mb_y - FRAME_MBAFF; s->mb_y= end_mb_y - FRAME_MBAFF;
h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale); h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale);
h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale); h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment