Mercurial > libavcodec.hg
comparison h264.c @ 12530:63edd10ad4bc libavcodec tip
Try to fix crashes introduced by r25218
r25218 made assumptions about the existence of past reference frames that
weren't necessarily true.
author | darkshikari |
---|---|
date | Tue, 28 Sep 2010 09:06:22 +0000 |
parents | 7c0dbd8eb53a |
children |
comparison
equal
deleted
inserted
replaced
12529:9a3f2beae2a9 | 12530:63edd10ad4bc |
---|---|
1896 h->mb_field_decoding_flag= s->picture_structure != PICT_FRAME; | 1896 h->mb_field_decoding_flag= s->picture_structure != PICT_FRAME; |
1897 | 1897 |
1898 if(h0->current_slice == 0){ | 1898 if(h0->current_slice == 0){ |
1899 while(h->frame_num != h->prev_frame_num && | 1899 while(h->frame_num != h->prev_frame_num && |
1900 h->frame_num != (h->prev_frame_num+1)%(1<<h->sps.log2_max_frame_num)){ | 1900 h->frame_num != (h->prev_frame_num+1)%(1<<h->sps.log2_max_frame_num)){ |
1901 Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL; | |
1901 av_log(h->s.avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n", h->frame_num, h->prev_frame_num); | 1902 av_log(h->s.avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n", h->frame_num, h->prev_frame_num); |
1902 if (ff_h264_frame_start(h) < 0) | 1903 if (ff_h264_frame_start(h) < 0) |
1903 return -1; | 1904 return -1; |
1904 h->prev_frame_num++; | 1905 h->prev_frame_num++; |
1905 h->prev_frame_num %= 1<<h->sps.log2_max_frame_num; | 1906 h->prev_frame_num %= 1<<h->sps.log2_max_frame_num; |
1910 * FIXME: avoiding a memcpy would be nice, but ref handling makes many assumptions | 1911 * FIXME: avoiding a memcpy would be nice, but ref handling makes many assumptions |
1911 * about there being no actual duplicates. | 1912 * about there being no actual duplicates. |
1912 * FIXME: this doesn't copy padding for out-of-frame motion vectors. Given we're | 1913 * 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 * concealing a lost frame, this probably isn't noticable by comparison, but it should |
1914 * be fixed. */ | 1915 * be fixed. */ |
1915 av_image_copy(h->short_ref[0]->data, h->short_ref[0]->linesize, | 1916 if (h->short_ref_count) { |
1916 (const uint8_t**)h->short_ref[1]->data, h->short_ref[1]->linesize, | 1917 if (prev) { |
1917 PIX_FMT_YUV420P, s->mb_width*16, s->mb_height*16); | 1918 av_image_copy(h->short_ref[0]->data, h->short_ref[0]->linesize, |
1918 h->short_ref[0]->frame_num = h->prev_frame_num; | 1919 (const uint8_t**)prev->data, prev->linesize, |
1919 h->short_ref[0]->poc = h->short_ref[1]->poc+2; | 1920 PIX_FMT_YUV420P, s->mb_width*16, s->mb_height*16); |
1921 h->short_ref[0]->poc = prev->poc+2; | |
1922 } | |
1923 h->short_ref[0]->frame_num = h->prev_frame_num; | |
1924 } | |
1920 } | 1925 } |
1921 | 1926 |
1922 /* See if we have a decoded first field looking for a pair... */ | 1927 /* See if we have a decoded first field looking for a pair... */ |
1923 if (s0->first_field) { | 1928 if (s0->first_field) { |
1924 assert(s0->current_picture_ptr); | 1929 assert(s0->current_picture_ptr); |