OSDN Git Service

x264 bump from r1698 to r1703
[handbrake-jp/handbrake-jp-git.git] / contrib / ffmpeg / A01-mpegleak.patch
1 Index: libavcodec/mpegvideo.c
2 ===================================================================
3 --- ffmpeg.orig/libavcodec/mpegvideo.c  (revision 22823)
4 +++ ffmpeg/libavcodec/mpegvideo.c       (working copy)
5 @@ -867,19 +867,18 @@
6      }
7  
8      av_log(s->avctx, AV_LOG_FATAL, "Internal error, picture buffer overflow\n");
9 -    /* We could return -1, but the codec would crash trying to draw into a
10 -     * non-existing frame anyway. This is safer than waiting for a random crash.
11 -     * Also the return of this is never useful, an encoder must only allocate
12 -     * as much as allowed in the specification. This has no relationship to how
13 -     * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large
14 -     * enough for such valid streams).
15 -     * Plus, a decoder has to check stream validity and remove frames if too
16 -     * many reference frames are around. Waiting for "OOM" is not correct at
17 -     * all. Similarly, missing reference frames have to be replaced by
18 -     * interpolated/MC frames, anything else is a bug in the codec ...
19 -     */
20 -    abort();
21 -    return -1;
22 +    /* XXX there seems to be a leak caused by h264 in mpeg transport
23 +     * streams: Over-the-air streams have a lot of errors. A picture
24 +     * may be marked as referenced but the actual references get lost
25 +     * so it never gets released. We take care of that here by releasing
26 +     * the oldest we have & reusing its slot. */
27 +    int oldest=0;
28 +    for(i=0; i<MAX_PICTURE_COUNT; i++){
29 +        if (s->picture[i].coded_picture_number < s->picture[oldest].coded_picture_number)
30 +            oldest = i;
31 +    }
32 +    s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[oldest]);
33 +    return oldest;
34  }
35  
36  static void update_noise_reduction(MpegEncContext *s){
37 Index: libavcodec/h264.c
38 ===================================================================
39 --- ffmpeg.orig/libavcodec/h264.c       (revision 22823)
40 +++ ffmpeg/libavcodec/h264.c    (working copy)
41 @@ -2772,7 +2772,7 @@
42  
43      if(!(s->flags2 & CODEC_FLAG2_CHUNKS) && !s->current_picture_ptr){
44          if (avctx->skip_frame >= AVDISCARD_NONREF || s->hurry_up) return 0;
45 -        av_log(avctx, AV_LOG_ERROR, "no frame!\n");
46 +        av_log(avctx, AV_LOG_DEBUG, "no frame!\n");
47          return -1;
48      }
49  
50 Index: libavcodec/h264_refs.c
51 ===================================================================
52 --- ffmpeg.orig/libavcodec/h264_refs.c  (revision 22823)
53 +++ ffmpeg/libavcodec/h264_refs.c       (working copy)
54 @@ -608,7 +608,7 @@
55           * stream. Need to discard one frame. Prevents overrun of the
56           * short_ref and long_ref buffers.
57           */
58 -        av_log(h->s.avctx, AV_LOG_ERROR,
59 +        av_log(h->s.avctx, AV_LOG_DEBUG,
60                 "number of reference frames exceeds max (probably "
61                 "corrupt input), discarding one\n");
62