avcodec/h264: Keep a reference to the last picture for EC

This and the next commit improve error concealment for
green-block-artifacts-from-canon-100-hs.MOV

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-01-11 16:40:27 +01:00
parent cba199b595
commit 855463c007
4 changed files with 17 additions and 1 deletions

View File

@ -1838,6 +1838,8 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
* packets do not get used. */
h->data_partitioning = 0;
ff_h264_unref_picture(h, &h->last_pic_for_ec);
/* end of stream, output what is still in the buffers */
if (buf_size == 0) {
out:
@ -1930,6 +1932,8 @@ static int h264_decode_frame(AVCodecContext *avctx, void *data,
assert(pict->buf[0] || !*got_frame);
ff_h264_unref_picture(h, &h->last_pic_for_ec);
return get_consumed_bytes(buf_index, buf_size);
}
@ -1954,6 +1958,7 @@ static av_cold int h264_decode_end(AVCodecContext *avctx)
ff_h264_free_context(h);
ff_h264_unref_picture(h, &h->cur_pic);
ff_h264_unref_picture(h, &h->last_pic_for_ec);
return 0;
}

View File

@ -352,6 +352,7 @@ typedef struct H264Context {
H264Picture *DPB;
H264Picture *cur_pic_ptr;
H264Picture cur_pic;
H264Picture last_pic_for_ec;
int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264
int chroma_qp[2]; // QPc

View File

@ -493,6 +493,10 @@ void ff_h264_remove_all_refs(H264Context *h)
}
assert(h->long_ref_count == 0);
ff_h264_unref_picture(h, &h->last_pic_for_ec);
if (h->short_ref_count)
ff_h264_ref_picture(h, &h->last_pic_for_ec, h->short_ref[0]);
for (i = 0; i < h->short_ref_count; i++) {
unreference_pic(h, h->short_ref[i], 0);
h->short_ref[i] = NULL;

View File

@ -542,6 +542,7 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
memset(&h->mb_padding, 0, sizeof(h->mb_padding));
memset(&h->cur_pic, 0, sizeof(h->cur_pic));
memset(&h->last_pic_for_ec, 0, sizeof(h->last_pic_for_ec));
h->avctx = dst;
h->DPB = NULL;
@ -1959,7 +1960,12 @@ int ff_h264_decode_slice_header(H264Context *h, H264Context *h0)
(h->ref_list[j][i].reference & 3);
}
if (h->ref_count[0]) ff_h264_set_erpic(&h->er.last_pic, &h->ref_list[0][0]);
if (h->ref_count[0]) {
ff_h264_set_erpic(&h->er.last_pic, &h->ref_list[0][0]);
} else if (h->last_pic_for_ec.f.buf[0]) {
ff_h264_set_erpic(&h->er.last_pic, &h->last_pic_for_ec);
}
if (h->ref_count[1]) ff_h264_set_erpic(&h->er.next_pic, &h->ref_list[1][0]);
h->er.ref_count = h->ref_count[0];