From: Michael Niedermayer Date: Wed, 19 Sep 2012 13:30:24 +0000 (+0200) Subject: Merge remote-tracking branch 'qatar/master' X-Git-Tag: n1.1-dev~160 X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/8846115b1a5c29892fdf2c74747f71d37e16e864 Merge remote-tracking branch 'qatar/master' * qatar/master: rv34: use ff_MPV_common_frame_size_change() mpegvideo: add reinit function for frame parameter changes Merged-by: Michael Niedermayer --- 8846115b1a5c29892fdf2c74747f71d37e16e864 diff --cc libavcodec/mpegvideo.c index 23a5797,e2e5276..c603eeb --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@@ -1144,23 -1256,23 +1225,37 @@@ static int find_unused_picture(MpegEncC } } - return AVERROR_INVALIDDATA; + av_log(s->avctx, AV_LOG_FATAL, + "Internal error, picture buffer overflow\n"); + /* We could return -1, but the codec would crash trying to draw into a + * non-existing frame anyway. This is safer than waiting for a random crash. + * Also the return of this is never useful, an encoder must only allocate + * as much as allowed in the specification. This has no relationship to how + * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large + * enough for such valid streams). + * Plus, a decoder has to check stream validity and remove frames if too + * many reference frames are around. Waiting for "OOM" is not correct at + * all. Similarly, missing reference frames have to be replaced by + * interpolated/MC frames, anything else is a bug in the codec ... + */ + abort(); + return -1; } + int ff_find_unused_picture(MpegEncContext *s, int shared) + { + int ret = find_unused_picture(s, shared); + + if (ret >= 0 && ret < s->picture_range_end) { + if (s->picture[ret].needs_realloc) { + s->picture[ret].needs_realloc = 0; + free_picture(s, &s->picture[ret]); + avcodec_get_frame_defaults(&s->picture[ret].f); + } + } + return ret; + } + static void update_noise_reduction(MpegEncContext *s) { int intra, i;