Commit 0ffc8415 authored by Ronald S. Bultje's avatar Ronald S. Bultje

h264: fix loopfilter with threading at slice boundaries.

parent 89a20987
......@@ -2557,7 +2557,7 @@ static int fill_filter_caches(H264Context *h, int mb_type){
return 0;
}
static void loop_filter(H264Context *h){
static void loop_filter(H264Context *h, int start_x, int end_x){
MpegEncContext * const s = &h->s;
uint8_t *dest_y, *dest_cb, *dest_cr;
int linesize, uvlinesize, mb_x, mb_y;
......@@ -2566,7 +2566,7 @@ static void loop_filter(H264Context *h){
const int pixel_shift = h->pixel_shift;
if(h->deblocking_filter) {
for(mb_x= 0; mb_x<s->mb_width; mb_x++){
for(mb_x= start_x; mb_x<end_x; mb_x++){
for(mb_y=end_mb_y - FRAME_MBAFF; mb_y<= end_mb_y; mb_y++){
int mb_xy, mb_type;
mb_xy = h->mb_xy = mb_x + mb_y*s->mb_stride;
......@@ -2632,6 +2632,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
H264Context *h = *(void**)arg;
MpegEncContext * const s = &h->s;
const int part_mask= s->partitioned_frame ? (AC_END|AC_ERROR) : 0x7F;
int lf_x_start = s->mb_x;
s->mb_skip_run= -1;
......@@ -2670,6 +2671,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
if((s->workaround_bugs & FF_BUG_TRUNCATED) && h->cabac.bytestream > h->cabac.bytestream_end + 2){
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
if (s->mb_x >= lf_x_start) loop_filter(h, lf_x_start, s->mb_x + 1);
return 0;
}
if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) {
......@@ -2679,8 +2681,8 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
}
if( ++s->mb_x >= s->mb_width ) {
s->mb_x = 0;
loop_filter(h);
loop_filter(h, lf_x_start, s->mb_x);
s->mb_x = lf_x_start = 0;
ff_draw_horiz_band(s, 16*s->mb_y, 16);
++s->mb_y;
if(FIELD_OR_MBAFF_PICTURE) {
......@@ -2693,6 +2695,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
if( eos || s->mb_y >= s->mb_height ) {
tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
if (s->mb_x > lf_x_start) loop_filter(h, lf_x_start, s->mb_x);
return 0;
}
}
......@@ -2714,13 +2717,12 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
if(ret<0){
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
return -1;
}
if(++s->mb_x >= s->mb_width){
s->mb_x=0;
loop_filter(h);
loop_filter(h, lf_x_start, s->mb_x);
s->mb_x = lf_x_start = 0;
ff_draw_horiz_band(s, 16*s->mb_y, 16);
++s->mb_y;
if(FIELD_OR_MBAFF_PICTURE) {
......@@ -2747,6 +2749,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg){
tprintf(s->avctx, "slice end %d %d\n", get_bits_count(&s->gb), s->gb.size_in_bits);
if(get_bits_count(&s->gb) == s->gb.size_in_bits ){
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, (AC_END|DC_END|MV_END)&part_mask);
if (s->mb_x > lf_x_start) loop_filter(h, lf_x_start, s->mb_x);
return 0;
}else{
......
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