Mercurial > libavcodec.hg
comparison h264.c @ 12525:7c0dbd8eb53a libavcodec
Improve error concealment of lost frames
If a frame is lost, replace it with data from the previous valid frame.
author | darkshikari |
---|---|
date | Mon, 27 Sep 2010 04:43:41 +0000 |
parents | 58a960d6e34c |
children | 63edd10ad4bc |
comparison
equal
deleted
inserted
replaced
12524:98606b84a7a4 | 12525:7c0dbd8eb53a |
---|---|
23 * @file | 23 * @file |
24 * H.264 / AVC / MPEG4 part10 codec. | 24 * H.264 / AVC / MPEG4 part10 codec. |
25 * @author Michael Niedermayer <michaelni@gmx.at> | 25 * @author Michael Niedermayer <michaelni@gmx.at> |
26 */ | 26 */ |
27 | 27 |
28 #include "libavcore/imgutils.h" | |
28 #include "internal.h" | 29 #include "internal.h" |
29 #include "dsputil.h" | 30 #include "dsputil.h" |
30 #include "avcodec.h" | 31 #include "avcodec.h" |
31 #include "mpegvideo.h" | 32 #include "mpegvideo.h" |
32 #include "h264.h" | 33 #include "h264.h" |
1903 h->prev_frame_num++; | 1904 h->prev_frame_num++; |
1904 h->prev_frame_num %= 1<<h->sps.log2_max_frame_num; | 1905 h->prev_frame_num %= 1<<h->sps.log2_max_frame_num; |
1905 s->current_picture_ptr->frame_num= h->prev_frame_num; | 1906 s->current_picture_ptr->frame_num= h->prev_frame_num; |
1906 ff_generate_sliding_window_mmcos(h); | 1907 ff_generate_sliding_window_mmcos(h); |
1907 ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); | 1908 ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); |
1909 /* Error concealment: if a ref is missing, copy the previous ref in its place. | |
1910 * FIXME: avoiding a memcpy would be nice, but ref handling makes many assumptions | |
1911 * about there being no actual duplicates. | |
1912 * FIXME: this doesn't copy padding for out-of-frame motion vectors. Given we're | |
1913 * concealing a lost frame, this probably isn't noticable by comparison, but it should | |
1914 * be fixed. */ | |
1915 av_image_copy(h->short_ref[0]->data, h->short_ref[0]->linesize, | |
1916 (const uint8_t**)h->short_ref[1]->data, h->short_ref[1]->linesize, | |
1917 PIX_FMT_YUV420P, s->mb_width*16, s->mb_height*16); | |
1918 h->short_ref[0]->frame_num = h->prev_frame_num; | |
1919 h->short_ref[0]->poc = h->short_ref[1]->poc+2; | |
1908 } | 1920 } |
1909 | 1921 |
1910 /* See if we have a decoded first field looking for a pair... */ | 1922 /* See if we have a decoded first field looking for a pair... */ |
1911 if (s0->first_field) { | 1923 if (s0->first_field) { |
1912 assert(s0->current_picture_ptr); | 1924 assert(s0->current_picture_ptr); |