1 Index: libavcodec/h264.c
2 ===================================================================
3 --- libavcodec/h264.c (revision 14820)
4 +++ libavcodec/h264.c (working copy)
6 * stream. Need to discard one frame. Prevents overrun of the
7 * short_ref and long_ref buffers.
9 - av_log(h->s.avctx, AV_LOG_ERROR,
10 + av_log(h->s.avctx, AV_LOG_DEBUG,
11 "number of reference frames exceeds max (probably "
12 "corrupt input), discarding one\n");
16 if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
17 if (avctx->skip_frame >= AVDISCARD_NONREF || s->hurry_up) return 0;
18 - av_log(avctx, AV_LOG_ERROR, "no frame!\n");
19 + av_log(avctx, AV_LOG_DEBUG, "no frame!\n");
23 Index: libavcodec/mpegvideo.c
24 ===================================================================
25 --- libavcodec/mpegvideo.c (revision 14820)
26 +++ libavcodec/mpegvideo.c (working copy)
29 for(i=0; i<MAX_PICTURE_COUNT; i++){
30 if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) return i; //FIXME
31 + /* XXX there seems to be a leak caused by h264 in mpeg transport
32 + * streams: Over-the-air streams have a lot of errors. A picture
33 + * may be marked as referenced but the actual references get lost
34 + * so it never gets released. We take care of that here by purging
35 + * pictures that are impossibly old.
37 + if (s->coded_picture_number - s->picture[i].coded_picture_number >
38 + 32*MAX_PICTURE_COUNT)
39 + s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]);
41 for(i=0; i<MAX_PICTURE_COUNT; i++){
42 if(s->picture[i].data[0]==NULL) return i;
46 av_log(s->avctx, AV_LOG_FATAL, "Internal error, picture buffer overflow\n");
47 - /* We could return -1, but the codec would crash trying to draw into a
48 - * non-existing frame anyway. This is safer than waiting for a random crash.
49 - * Also the return of this is never useful, an encoder must only allocate
50 - * as much as allowed in the specification. This has no relationship to how
51 - * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large
52 - * enough for such valid streams).
53 - * Plus, a decoder has to check stream validity and remove frames if too
54 - * many reference frames are around. Waiting for "OOM" is not correct at
55 - * all. Similarly, missing reference frames have to be replaced by
56 - * interpolated/MC frames, anything else is a bug in the codec ...
60 + /* assume that we don't have a picture because of the leak described above.
61 + * just release the oldest we have & reuse its slot. */
63 + for(i=0; i<MAX_PICTURE_COUNT; i++){
64 + if (s->picture[i].coded_picture_number < s->picture[oldest].coded_picture_number)
67 + s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[oldest]);
71 static void update_noise_reduction(MpegEncContext *s){