diff options
author | Jason Garrett-Glaser <darkshikari@gmail.com> | 2010-09-27 04:43:41 +0000 |
---|---|---|
committer | Jason Garrett-Glaser <darkshikari@gmail.com> | 2010-09-27 04:43:41 +0000 |
commit | e2983d6eac7b0bb563886c6f97c4ce0385b2018d (patch) | |
tree | 1bac5dfb3c47f6b8b3ddd4e258d1d7278e5854dc /libavcodec/h264.c | |
parent | b1a05b820e6ee4d4209bc356348451bb4ad5870a (diff) | |
download | ffmpeg-e2983d6eac7b0bb563886c6f97c4ce0385b2018d.tar.gz |
Improve error concealment of lost frames
If a frame is lost, replace it with data from the previous valid frame.
Originally committed as revision 25218 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h264.c')
-rw-r--r-- | libavcodec/h264.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c index 49bbe302e8..0b0d96b08d 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -25,6 +25,7 @@ * @author Michael Niedermayer <michaelni@gmx.at> */ +#include "libavcore/imgutils.h" #include "internal.h" #include "dsputil.h" #include "avcodec.h" @@ -1905,6 +1906,17 @@ static int decode_slice_header(H264Context *h, H264Context *h0){ s->current_picture_ptr->frame_num= h->prev_frame_num; ff_generate_sliding_window_mmcos(h); ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); + /* Error concealment: if a ref is missing, copy the previous ref in its place. + * FIXME: avoiding a memcpy would be nice, but ref handling makes many assumptions + * about there being no actual duplicates. + * FIXME: this doesn't copy padding for out-of-frame motion vectors. Given we're + * concealing a lost frame, this probably isn't noticable by comparison, but it should + * be fixed. */ + av_image_copy(h->short_ref[0]->data, h->short_ref[0]->linesize, + (const uint8_t**)h->short_ref[1]->data, h->short_ref[1]->linesize, + PIX_FMT_YUV420P, s->mb_width*16, s->mb_height*16); + h->short_ref[0]->frame_num = h->prev_frame_num; + h->short_ref[0]->poc = h->short_ref[1]->poc+2; } /* See if we have a decoded first field looking for a pair... */ |