OSDN Git Service

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