diff options
| author | Luca Barbato <[email protected]> | 2014-08-08 18:07:43 +0200 | 
|---|---|---|
| committer | Luca Barbato <[email protected]> | 2014-08-09 04:01:15 +0200 | 
| commit | 0ab76ddf313eeab70d06619ae0376fd7dd40761b (patch) | |
| tree | 5b9cc612dea64c831a020c831ddd998c709cb796 | |
| parent | 042c25f54bd25b52d2936b822be026450971a82d (diff) | |
avcodec: Introduce ff_get_buffer
Validate the image size there as is done in the other release
branches.
Bug-Id: CVE-2011-3935
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
70 files changed, 149 insertions, 81 deletions
@@ -1584,7 +1584,7 @@ static int input_reget_buffer(AVCodecContext *codec, AVFrame *pic)      if (pic->data[0] == NULL) {          pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; -        return codec->get_buffer(codec, pic); +        return input_get_buffer(codec, pic);      }      if ((codec->width != ref->video->w) || (codec->height != ref->video->h) || diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c index 4f11b8bec4..1057a72db9 100644 --- a/libavcodec/8svx.c +++ b/libavcodec/8svx.c @@ -29,6 +29,7 @@   */  #include "avcodec.h" +#include "internal.h"  /** decoder context */  typedef struct EightSvxContext { @@ -141,7 +142,7 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      esc->frame.nb_samples = buf_size * (is_compr + 1); -    if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &esc->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 83dd06bfc0..9c4489434a 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -2246,7 +2246,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,      if (samples) {          /* get output buffer */          ac->frame.nb_samples = samples; -        if ((err = avctx->get_buffer(avctx, &ac->frame)) < 0) { +        if ((err = ff_get_buffer(avctx, &ac->frame)) < 0) {              av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");              return err;          } diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 039062b3d6..a3c581909b 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1411,7 +1411,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,      /* get output buffer */      s->frame.nb_samples = s->num_blocks * 256; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 5f7f140a9d..fe4949d7af 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -18,6 +18,7 @@   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA   */  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "put_bits.h"  #include "bytestream.h" @@ -547,7 +548,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      c->frame.nb_samples = nb_samples; -    if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c index 3f7f5f4ca1..de2d718b1c 100644 --- a/libavcodec/adxdec.c +++ b/libavcodec/adxdec.c @@ -21,6 +21,7 @@  #include "libavutil/intreadwrite.h"  #include "avcodec.h" +#include "internal.h"  #include "adx.h"  #include "get_bits.h" @@ -140,7 +141,7 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      c->frame.nb_samples = num_blocks * BLOCK_SAMPLES; -    if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 23b8951169..c162e2f60e 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -47,6 +47,7 @@  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "bytestream.h"  #include "unary.h" @@ -402,7 +403,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,          return AVERROR_INVALIDDATA;      }      alac->frame.nb_samples = outputsamples; -    if ((ret = avctx->get_buffer(avctx, &alac->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &alac->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c index 7daa545765..c49552de59 100644 --- a/libavcodec/alsdec.c +++ b/libavcodec/alsdec.c @@ -30,6 +30,7 @@  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "unary.h"  #include "mpeg4audio.h" @@ -1484,7 +1485,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,      /* get output buffer */      ctx->frame.nb_samples = ctx->cur_frame_length; -    if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &ctx->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c index a7d0b4e337..d294fe967f 100644 --- a/libavcodec/amrnbdec.c +++ b/libavcodec/amrnbdec.c @@ -44,6 +44,7 @@  #include <math.h>  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "libavutil/common.h"  #include "celp_math.h" @@ -944,7 +945,7 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      p->avframe.nb_samples = AMR_BLOCK_SIZE; -    if ((ret = avctx->get_buffer(avctx, &p->avframe)) < 0) { +    if ((ret = ff_get_buffer(avctx, &p->avframe)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c index b9ae9ece66..893cd355e5 100644 --- a/libavcodec/amrwbdec.c +++ b/libavcodec/amrwbdec.c @@ -27,6 +27,7 @@  #include "libavutil/lfg.h"  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "lsp.h"  #include "celp_math.h" @@ -1087,7 +1088,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      ctx->avframe.nb_samples = 4 * AMRWB_SFR_SIZE_16k; -    if ((ret = avctx->get_buffer(avctx, &ctx->avframe)) < 0) { +    if ((ret = ff_get_buffer(avctx, &ctx->avframe)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/ansi.c b/libavcodec/ansi.c index 32c7ce4ecd..3721bca1e8 100644 --- a/libavcodec/ansi.c +++ b/libavcodec/ansi.c @@ -26,6 +26,7 @@  #include "libavutil/lfg.h"  #include "avcodec.h" +#include "internal.h"  #include "cga_data.h"  #define ATTR_BOLD         0x01  /**< Bold/Bright-foreground (mode 1) */ @@ -221,7 +222,7 @@ static int execute_code(AVCodecContext * avctx, int c)              if (s->frame.data[0])                  avctx->release_buffer(avctx, &s->frame);              avcodec_set_dimensions(avctx, width, height); -            ret = avctx->get_buffer(avctx, &s->frame); +            ret = ff_get_buffer(avctx, &s->frame);              if (ret < 0) {                  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");                  return ret; diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 745b14c1be..a9c3be492f 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -22,6 +22,7 @@  #define BITSTREAM_READER_LE  #include "avcodec.h" +#include "internal.h"  #include "dsputil.h"  #include "get_bits.h"  #include "bytestream.h" @@ -887,7 +888,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = blockstodecode; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c index 9ead80d5c8..128a66d0e7 100644 --- a/libavcodec/atrac1.c +++ b/libavcodec/atrac1.c @@ -33,6 +33,7 @@  #include <stdio.h>  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "dsputil.h"  #include "fft.h" @@ -291,7 +292,7 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      q->frame.nb_samples = AT1_SU_SAMPLES; -    if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &q->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index e31dd1dcd5..5bfd038abd 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -37,6 +37,7 @@  #include <stdio.h>  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "dsputil.h"  #include "bytestream.h" @@ -852,7 +853,7 @@ static int atrac3_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      q->frame.nb_samples = SAMPLES_PER_FRAME; -    if ((result = avctx->get_buffer(avctx, &q->frame)) < 0) { +    if ((result = ff_get_buffer(avctx, &q->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return result;      } diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index d73ffcdabc..dc1028fbad 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -29,6 +29,7 @@   */  #include "avcodec.h" +#include "internal.h"  #define BITSTREAM_READER_LE  #include "get_bits.h"  #include "dsputil.h" @@ -340,7 +341,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = s->block_size / avctx->channels; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/bmv.c b/libavcodec/bmv.c index 920e75255f..c0fe9b87d8 100644 --- a/libavcodec/bmv.c +++ b/libavcodec/bmv.c @@ -20,6 +20,7 @@   */  #include "avcodec.h" +#include "internal.h"  #include "bytestream.h"  enum BMVFlags{ @@ -265,7 +266,7 @@ static av_cold int decode_init(AVCodecContext *avctx)      avctx->pix_fmt = PIX_FMT_PAL8;      c->pic.reference = 1; -    if (avctx->get_buffer(avctx, &c->pic) < 0) { +    if (ff_get_buffer(avctx, &c->pic) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return -1;      } @@ -330,7 +331,7 @@ static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      c->frame.nb_samples = total_blocks * 32; -    if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/cdgraphics.c b/libavcodec/cdgraphics.c index 9ab00b4fac..f642287782 100644 --- a/libavcodec/cdgraphics.c +++ b/libavcodec/cdgraphics.c @@ -20,6 +20,7 @@   */  #include "avcodec.h" +#include "internal.h"  #include "bytestream.h"  /** @@ -331,7 +332,7 @@ static int cdg_decode_frame(AVCodecContext *avctx,              }              cdg_init_frame(&new_frame); -            ret = avctx->get_buffer(avctx, &new_frame); +            ret = ff_get_buffer(avctx, &new_frame);              if (ret) {                  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");                  return ret; diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 74378521b3..df4fee5967 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -44,6 +44,7 @@  #include "libavutil/lfg.h"  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "dsputil.h"  #include "bytestream.h" @@ -991,7 +992,7 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      if (q->discarded_packets >= 2) {          q->frame.nb_samples = q->samples_per_channel; -        if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { +        if ((ret = ff_get_buffer(avctx, &q->frame)) < 0) {              av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");              return ret;          } diff --git a/libavcodec/dca.c b/libavcodec/dca.c index 4d71812d88..72b7bbf7f1 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -32,6 +32,7 @@  #include "libavutil/mathematics.h"  #include "libavutil/audioconvert.h"  #include "avcodec.h" +#include "internal.h"  #include "dsputil.h"  #include "fft.h"  #include "get_bits.h" @@ -1902,7 +1903,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = 256 * (s->sample_blocks / 8); -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/dfa.c b/libavcodec/dfa.c index 0ae89a8985..d9ff44545e 100644 --- a/libavcodec/dfa.c +++ b/libavcodec/dfa.c @@ -21,6 +21,7 @@   */  #include "avcodec.h" +#include "internal.h"  #include "bytestream.h"  #include "libavutil/imgutils.h" @@ -325,7 +326,7 @@ static int dfa_decode_frame(AVCodecContext *avctx,      if (s->pic.data[0])          avctx->release_buffer(avctx, &s->pic); -    if ((ret = avctx->get_buffer(avctx, &s->pic))) { +    if ((ret = ff_get_buffer(avctx, &s->pic))) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c index 7f5dbfe3b9..f4aaa95c0a 100644 --- a/libavcodec/dpcm.c +++ b/libavcodec/dpcm.c @@ -39,6 +39,7 @@  #include "libavutil/intreadwrite.h"  #include "avcodec.h" +#include "internal.h"  #include "bytestream.h"  typedef struct DPCMContext { @@ -213,7 +214,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = out / s->channels; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/dsicinav.c b/libavcodec/dsicinav.c index 1a3366814b..99eea8ab33 100644 --- a/libavcodec/dsicinav.c +++ b/libavcodec/dsicinav.c @@ -25,6 +25,7 @@   */  #include "avcodec.h" +#include "internal.h"  #include "bytestream.h"  #include "mathops.h" @@ -362,7 +363,7 @@ static int cinaudio_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      cin->frame.nb_samples = avpkt->size - cin->initial_decode_frame; -    if ((ret = avctx->get_buffer(avctx, &cin->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &cin->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/dxtory.c b/libavcodec/dxtory.c index 5f67fbdbef..f8ebb43b63 100644 --- a/libavcodec/dxtory.c +++ b/libavcodec/dxtory.c @@ -21,6 +21,7 @@   */  #include "avcodec.h" +#include "internal.h"  #include "libavutil/intreadwrite.h"  static av_cold int decode_init(AVCodecContext *avctx) @@ -51,7 +52,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,      }      pic->reference = 0; -    if ((ret = avctx->get_buffer(avctx, pic)) < 0) +    if ((ret = ff_get_buffer(avctx, pic)) < 0)          return ret;      pic->pict_type = AV_PICTURE_TYPE_I; diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c index 440a55d3e9..f20dc3d9b7 100644 --- a/libavcodec/flacdec.c +++ b/libavcodec/flacdec.c @@ -599,7 +599,7 @@ static int flac_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = s->blocksize; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/g722dec.c b/libavcodec/g722dec.c index 72bb0ef3c7..9e0a2870b2 100644 --- a/libavcodec/g722dec.c +++ b/libavcodec/g722dec.c @@ -35,6 +35,7 @@   */  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "g722.h"  #include "libavutil/opt.h" @@ -96,7 +97,7 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      c->frame.nb_samples = avpkt->size * 2; -    if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/g726.c b/libavcodec/g726.c index 85711f854c..81aa7d0927 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -448,7 +448,7 @@ static int g726_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      c->frame.nb_samples = out_samples; -    if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/gsmdec.c b/libavcodec/gsmdec.c index 97b6fe8492..6fdf9fbf61 100644 --- a/libavcodec/gsmdec.c +++ b/libavcodec/gsmdec.c @@ -25,6 +25,7 @@   */  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "msgsmdec.h" @@ -72,7 +73,7 @@ static int gsm_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = avctx->frame_size; -    if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return res;      } diff --git a/libavcodec/iff.c b/libavcodec/iff.c index b931e40213..4565724a8a 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -28,6 +28,7 @@  #include "libavutil/imgutils.h"  #include "bytestream.h"  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  typedef struct { @@ -260,7 +261,7 @@ static int decode_frame_ilbm(AVCodecContext *avctx,              av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");              return res;          } -    } else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) { +    } else if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return res;      } else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != PIX_FMT_GRAY8) { @@ -317,7 +318,7 @@ static int decode_frame_byterun1(AVCodecContext *avctx,              av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");              return res;          } -    } else if ((res = avctx->get_buffer(avctx, &s->frame)) < 0) { +    } else if ((res = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return res;      } else if (avctx->bits_per_coded_sample <= 8 && avctx->pix_fmt != PIX_FMT_GRAY8) { diff --git a/libavcodec/imc.c b/libavcodec/imc.c index bee38b07f8..44bef9a13a 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -36,6 +36,7 @@  #include <stdio.h>  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "dsputil.h"  #include "fft.h" @@ -680,7 +681,7 @@ static int imc_decode_frame(AVCodecContext * avctx, void *data,      /* get output buffer */      q->frame.nb_samples = COEFFS; -    if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &q->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c index 9e90fb1c5a..c0957f0e3c 100644 --- a/libavcodec/indeo3.c +++ b/libavcodec/indeo3.c @@ -32,6 +32,7 @@  #include "libavutil/imgutils.h"  #include "libavutil/intreadwrite.h"  #include "avcodec.h" +#include "internal.h"  #include "dsputil.h"  #include "bytestream.h"  #include "get_bits.h" @@ -1095,7 +1096,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,          avctx->release_buffer(avctx, &ctx->frame);      ctx->frame.reference = 0; -    if ((res = avctx->get_buffer(avctx, &ctx->frame)) < 0) { +    if ((res = ff_get_buffer(avctx, &ctx->frame)) < 0) {          av_log(ctx->avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return res;      } diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 441430e41c..66940a8da5 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -126,4 +126,7 @@ int avpriv_unlock_avformat(void);   */  int ff_alloc_packet(AVPacket *avpkt, int size); + +int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame); +  #endif /* AVCODEC_INTERNAL_H */ diff --git a/libavcodec/ivi_common.c b/libavcodec/ivi_common.c index 84695a058b..25390018ad 100644 --- a/libavcodec/ivi_common.c +++ b/libavcodec/ivi_common.c @@ -28,6 +28,7 @@  #define BITSTREAM_READER_LE  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "ivi_common.h"  #include "libavutil/common.h" @@ -940,7 +941,7 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, int *data_size,      ctx->frame.reference = 0;      avcodec_set_dimensions(avctx, ctx->planes[0].width, ctx->planes[0].height); -    if ((result = avctx->get_buffer(avctx, &ctx->frame)) < 0) { +    if ((result = ff_get_buffer(avctx, &ctx->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return result;      } diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index 42bbcae530..21f30803da 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -27,6 +27,7 @@  #include "libavutil/intreadwrite.h"  #include "libavutil/imgutils.h"  #include "avcodec.h" +#include "internal.h"  typedef struct {      AVCodecContext *avctx; @@ -70,7 +71,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac      maxcnt = w * h;      c->cur.reference = 3; -    if ((res = avctx->get_buffer(avctx, &c->cur)) < 0) +    if ((res = ff_get_buffer(avctx, &c->cur)) < 0)          return res;      out  = (uint16_t *) c->cur.data[0];      if (c->prev.data[0]) { diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c index 1fa04cf9d9..1098bce631 100644 --- a/libavcodec/libgsm.c +++ b/libavcodec/libgsm.c @@ -188,7 +188,7 @@ static int libgsm_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = avctx->frame_size; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c index ded92179d3..8265848155 100644 --- a/libavcodec/libopencore-amr.c +++ b/libavcodec/libopencore-amr.c @@ -143,7 +143,7 @@ static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = 160; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } @@ -295,7 +295,7 @@ static int amr_wb_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = 320; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/libspeexdec.c b/libavcodec/libspeexdec.c index eba2f16949..0ce09f4be7 100644 --- a/libavcodec/libspeexdec.c +++ b/libavcodec/libspeexdec.c @@ -108,7 +108,7 @@ static int libspeex_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = s->frame_size; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/mace.c b/libavcodec/mace.c index d02b1dc095..2d2f3767a1 100644 --- a/libavcodec/mace.c +++ b/libavcodec/mace.c @@ -25,6 +25,7 @@   */  #include "avcodec.h" +#include "internal.h"  /*   * Adapted to libavcodec by Francois Revol <[email protected]> @@ -253,7 +254,7 @@ static int mace_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      ctx->frame.nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels; -    if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &ctx->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index e74b20269a..6f6701fa10 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -27,6 +27,7 @@  #include <stdint.h>  #include "avcodec.h" +#include "internal.h"  #include "dsputil.h"  #include "libavutil/intreadwrite.h"  #include "get_bits.h" @@ -932,7 +933,7 @@ static int output_data(MLPDecodeContext *m, unsigned int substr,      /* get output buffer */      m->frame.nb_samples = s->blockpos; -    if ((ret = avctx->get_buffer(avctx, &m->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &m->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c index b678afd1a2..443c78b40f 100644 --- a/libavcodec/mpc7.c +++ b/libavcodec/mpc7.c @@ -27,6 +27,7 @@  #include "libavutil/lfg.h"  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "dsputil.h"  #include "mpegaudiodsp.h" @@ -218,7 +219,7 @@ static int mpc7_decode_frame(AVCodecContext * avctx, void *data,      /* get output buffer */      c->frame.nb_samples = buf[1] ? c->lastframelen : MPC_FRAME_SIZE; -    if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index f5eb4d6651..5dadbefafb 100644 --- a/libavcodec/mpc8.c +++ b/libavcodec/mpc8.c @@ -27,6 +27,7 @@  #include "libavutil/lfg.h"  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "dsputil.h"  #include "mpegaudiodsp.h" @@ -250,7 +251,7 @@ static int mpc8_decode_frame(AVCodecContext * avctx, void *data,      /* get output buffer */      c->frame.nb_samples = MPC_FRAME_SIZE; -    if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) { +    if ((res = ff_get_buffer(avctx, &c->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return res;      } diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c index e2216f3fdb..ee67f12464 100644 --- a/libavcodec/mpegaudiodec.c +++ b/libavcodec/mpegaudiodec.c @@ -26,6 +26,7 @@  #include "libavutil/audioconvert.h"  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "mathops.h"  #include "mpegaudiodsp.h" @@ -1604,7 +1605,7 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples,      /* get output buffer */      if (!samples) {          s->frame.nb_samples = s->avctx->frame_size; -        if ((ret = s->avctx->get_buffer(s->avctx, &s->frame)) < 0) { +        if ((ret = ff_get_buffer(s->avctx, &s->frame)) < 0) {              av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");              return ret;          } @@ -1910,7 +1911,7 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame->nb_samples = MPA_FRAME_SIZE; -    if ((ret = avctx->get_buffer(avctx, s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/mxpegdec.c b/libavcodec/mxpegdec.c index 6f0d0457f7..fff5c7eef9 100644 --- a/libavcodec/mxpegdec.c +++ b/libavcodec/mxpegdec.c @@ -249,7 +249,7 @@ static int mxpeg_decode_frame(AVCodecContext *avctx,                      /* use stored SOF data to allocate current picture */                      if (jpg->picture_ptr->data[0])                          avctx->release_buffer(avctx, jpg->picture_ptr); -                    if (avctx->get_buffer(avctx, jpg->picture_ptr) < 0) { +                    if (ff_get_buffer(avctx, jpg->picture_ptr) < 0) {                          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");                          return AVERROR(ENOMEM);                      } @@ -268,7 +268,7 @@ static int mxpeg_decode_frame(AVCodecContext *avctx,                      /* allocate dummy reference picture if needed */                      if (!reference_ptr->data[0] && -                        avctx->get_buffer(avctx, reference_ptr) < 0) { +                        ff_get_buffer(avctx, reference_ptr) < 0) {                          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");                          return AVERROR(ENOMEM);                      } diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c index 69c1b86f5e..1bc2b5422d 100644 --- a/libavcodec/nellymoserdec.c +++ b/libavcodec/nellymoserdec.c @@ -36,6 +36,7 @@  #include "libavutil/random_seed.h"  #include "libavutil/audioconvert.h"  #include "avcodec.h" +#include "internal.h"  #include "dsputil.h"  #include "fft.h"  #include "fmtconvert.h" @@ -179,7 +180,7 @@ static int decode_tag(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = NELLY_SAMPLES * blocks; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/pcm-mpeg.c b/libavcodec/pcm-mpeg.c index f010b970bf..0d0eba189b 100644 --- a/libavcodec/pcm-mpeg.c +++ b/libavcodec/pcm-mpeg.c @@ -26,6 +26,7 @@  #include "libavutil/audioconvert.h"  #include "avcodec.h" +#include "internal.h"  #include "bytestream.h"  /* @@ -161,7 +162,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = samples; -    if ((retval = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((retval = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return retval;      } diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index cd44d77000..23a03c45ad 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -302,7 +302,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = n * samples_per_block / avctx->channels; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index 65c6e2fbe3..345456ce6e 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -573,7 +573,7 @@ static int submit_packet(PerThreadContext *p, AVPacket *avpkt)                  pthread_cond_wait(&p->progress_cond, &p->progress_mutex);              if (p->state == STATE_GET_BUFFER) { -                p->result = p->avctx->get_buffer(p->avctx, p->requested_frame); +                p->result = p-ff_get_buffer(p->avctx, p->requested_frame);                  p->state  = STATE_SETTING_UP;                  pthread_cond_signal(&p->progress_cond);              } @@ -919,7 +919,7 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)      if (!(avctx->active_thread_type&FF_THREAD_FRAME)) {          f->thread_opaque = NULL; -        return avctx->get_buffer(avctx, f); +        return ff_get_buffer(avctx, f);      }      if (p->state != STATE_SETTING_UP && @@ -941,7 +941,7 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)      if (avctx->thread_safe_callbacks ||          avctx->get_buffer == avcodec_default_get_buffer) { -        err = avctx->get_buffer(avctx, f); +        err = ff_get_buffer(avctx, f);      } else {          p->requested_frame = f;          p->state = STATE_GET_BUFFER; diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c index a3af2378f3..3d7420b9f2 100644 --- a/libavcodec/qcelpdec.c +++ b/libavcodec/qcelpdec.c @@ -697,7 +697,7 @@ static int qcelp_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      q->avframe.nb_samples = 160; -    if ((ret = avctx->get_buffer(avctx, &q->avframe)) < 0) { +    if ((ret = ff_get_buffer(avctx, &q->avframe)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c index 6b11b46d98..936c911d1a 100644 --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@ -37,6 +37,7 @@  #define BITSTREAM_READER_LE  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "dsputil.h"  #include "rdft.h" @@ -2003,7 +2004,7 @@ static int qdm2_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = 16 * s->frame_size; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/ra144dec.c b/libavcodec/ra144dec.c index dd8838c417..86c7eedd9c 100644 --- a/libavcodec/ra144dec.c +++ b/libavcodec/ra144dec.c @@ -24,6 +24,7 @@  #include "libavutil/intmath.h"  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "ra144.h" @@ -77,7 +78,7 @@ static int ra144_decode_frame(AVCodecContext * avctx, void *data,      /* get output buffer */      ractx->frame.nb_samples = NBLOCKS * BLOCKSIZE; -    if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &ractx->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c index 4cb2493fc9..0d10545faa 100644 --- a/libavcodec/ra288.c +++ b/libavcodec/ra288.c @@ -20,6 +20,7 @@   */  #include "avcodec.h" +#include "internal.h"  #define BITSTREAM_READER_LE  #include "get_bits.h"  #include "ra288.h" @@ -188,7 +189,7 @@ static int ra288_decode_frame(AVCodecContext * avctx, void *data,      /* get output buffer */      ractx->frame.nb_samples = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME; -    if ((ret = avctx->get_buffer(avctx, &ractx->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &ractx->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c index 2a62d5509d..58dd255a55 100644 --- a/libavcodec/roqvideoenc.c +++ b/libavcodec/roqvideoenc.c @@ -1031,8 +1031,8 @@ static int roq_encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_s      if (enc->first_frame) {          /* Alloc memory for the reconstruction data (we must know the stride           for that) */ -        if (avctx->get_buffer(avctx, enc->current_frame) || -            avctx->get_buffer(avctx, enc->last_frame)) { +        if (ff_get_buffer(avctx, enc->current_frame) || +            ff_get_buffer(avctx, enc->last_frame)) {              av_log(avctx, AV_LOG_ERROR, "  RoQ: get_buffer() failed\n");              return -1;          } diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c index 34018aeb46..f18059da51 100644 --- a/libavcodec/s302m.c +++ b/libavcodec/s302m.c @@ -22,6 +22,7 @@  #include "libavutil/intreadwrite.h"  #include "avcodec.h" +#include "internal.h"  #define AES3_HEADER_LEN 4 @@ -94,7 +95,7 @@ static int s302m_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      block_size = (avctx->bits_per_coded_sample + 4) / 4;      s->frame.nb_samples = 2 * (buf_size / block_size) / avctx->channels; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index f96a003e75..2a127c50b9 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -28,6 +28,7 @@  #include <limits.h>  #include "avcodec.h" +#include "internal.h"  #include "bytestream.h"  #include "get_bits.h"  #include "golomb.h" @@ -598,7 +599,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data,              if (s->cur_chan == s->channels) {                  /* get output buffer */                  s->frame.nb_samples = s->blocksize; -                if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +                if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {                      av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");                      return ret;                  } diff --git a/libavcodec/sipr.c b/libavcodec/sipr.c index 818524ca62..b862e7d3be 100644 --- a/libavcodec/sipr.c +++ b/libavcodec/sipr.c @@ -27,6 +27,7 @@  #include "libavutil/mathematics.h"  #include "avcodec.h" +#include "internal.h"  #define BITSTREAM_READER_LE  #include "get_bits.h"  #include "dsputil.h" @@ -541,7 +542,7 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      ctx->frame.nb_samples = mode_par->frames_per_packet * subframe_size *                              mode_par->subframe_count; -    if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &ctx->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c index e07fc3749d..bce23f4e0a 100644 --- a/libavcodec/smacker.c +++ b/libavcodec/smacker.c @@ -32,6 +32,7 @@  #include <stdlib.h>  #include "avcodec.h" +#include "internal.h"  #include "libavutil/audioconvert.h"  #include "mathops.h" @@ -636,7 +637,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = unp_size / (avctx->channels * (bits + 1)); -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index ef136b94f0..82b828b6dd 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -512,8 +512,8 @@ static int svq1_encode_frame(AVCodecContext *avctx, unsigned char *buf,      }      if(!s->current_picture.data[0]){ -        avctx->get_buffer(avctx, &s->current_picture); -        avctx->get_buffer(avctx, &s->last_picture); +        ff_get_buffer(avctx, &s->current_picture); +        ff_get_buffer(avctx, &s->last_picture);          s->scratchbuf = av_malloc(s->current_picture.linesize[0] * 16 * 2);      } diff --git a/libavcodec/thread.h b/libavcodec/thread.h index 7f018fc441..782c03cbcf 100644 --- a/libavcodec/thread.h +++ b/libavcodec/thread.h @@ -89,7 +89,7 @@ void ff_thread_await_progress(AVFrame *f, int progress, int field);  /**   * Wrapper around get_buffer() for frame-multithreaded codecs. - * Call this function instead of avctx->get_buffer(f). + * Call this function instead of ff_get_buffer(f).   * Cannot be called after the codec has called ff_thread_finish_setup().   *   * @param avctx The current context. diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index 5ef0a01427..4b69b90ddb 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -21,6 +21,7 @@  #include "libavutil/intreadwrite.h"  #include "avcodec.h" +#include "internal.h"  #include "dsputil.h"  #include "get_bits.h" @@ -325,7 +326,7 @@ static int truespeech_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      c->frame.nb_samples = iterations * 240; -    if ((ret = avctx->get_buffer(avctx, &c->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 1743f7d0ac..9ea7d030cd 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -31,6 +31,7 @@  //#define DEBUG  #include <limits.h>  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "libavutil/crc.h" @@ -343,7 +344,7 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = framelen; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/twinvq.c b/libavcodec/twinvq.c index c58a9bc75d..061ff7636b 100644 --- a/libavcodec/twinvq.c +++ b/libavcodec/twinvq.c @@ -20,6 +20,7 @@   */  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "dsputil.h"  #include "fft.h" @@ -840,7 +841,7 @@ static int twin_decode_frame(AVCodecContext * avctx, void *data,      /* get output buffer */      if (tctx->discarded_packets >= 2) {          tctx->frame.nb_samples = mtab->size; -        if ((ret = avctx->get_buffer(avctx, &tctx->frame)) < 0) { +        if ((ret = ff_get_buffer(avctx, &tctx->frame)) < 0) {              av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");              return ret;          } diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 7902e987ca..e657a2cece 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -552,7 +552,7 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){      if(pic->data[0] == NULL) {          /* We will copy from buffer, so must be readable */          pic->buffer_hints |= FF_BUFFER_HINTS_READABLE; -        return s->get_buffer(s, pic); +        return ff_get_buffer(s, pic);      }      /* If internal buffer type return the same buffer */ @@ -571,7 +571,7 @@ int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic){          pic->data[i] = pic->base[i] = NULL;      pic->opaque = NULL;      /* Allocate new frame */ -    if (s->get_buffer(s, pic)) +    if (ff_get_buffer(s, pic))          return -1;      /* Copy image data from old buffer to new buffer */      av_picture_copy((AVPicture*)pic, (AVPicture*)&temp_pic, s->pix_fmt, s->width, @@ -1815,7 +1815,7 @@ unsigned int avpriv_toupper4(unsigned int x)  int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)  {      f->owner = avctx; -    return avctx->get_buffer(avctx, f); +    return ff_get_buffer(avctx, f);  }  void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f) @@ -1863,3 +1863,16 @@ int avcodec_is_open(AVCodecContext *s)  {      return !!s->internal;  } + +int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame) +{ +    switch (avctx->codec_type) { +        case AVMEDIA_TYPE_VIDEO: +            if (av_image_check_size(avctx->width, avctx->height, 0, avctx)) { +                av_log(avctx, AV_LOG_ERROR, "Invalid dimensions %dx%d\n", +                       avctx->width, avctx->height); +                return AVERROR_INVALIDDATA; +            } +    } +    return avctx->get_buffer(avctx, frame); +} diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c index 4659971335..bdd9ca056e 100644 --- a/libavcodec/vmdav.c +++ b/libavcodec/vmdav.c @@ -45,6 +45,7 @@  #include "libavutil/intreadwrite.h"  #include "avcodec.h" +#include "internal.h"  #include "bytestream.h"  #define VMD_HEADER_SIZE 0x330 @@ -396,7 +397,7 @@ static int vmdvideo_decode_frame(AVCodecContext *avctx,          return buf_size;      s->frame.reference = 1; -    if (avctx->get_buffer(avctx, &s->frame)) { +    if (ff_get_buffer(avctx, &s->frame)) {          av_log(s->avctx, AV_LOG_ERROR, "VMD Video: get_buffer() failed\n");          return -1;      } @@ -569,7 +570,7 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = ((silent_chunks + audio_chunks) * avctx->block_align) / avctx->channels; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index 5a0a4a4a9b..a22b541b11 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -27,6 +27,7 @@  #define BITSTREAM_READER_LE  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "dsputil.h"  #include "fft.h" @@ -1668,7 +1669,7 @@ static int vorbis_decode_frame(AVCodecContext *avccontext, void *data,      /* get output buffer */      vc->frame.nb_samples = len; -    if ((ret = avccontext->get_buffer(avccontext, &vc->frame)) < 0) { +    if ((ret = ff_get_buffer(avccontext, &vc->frame)) < 0) {          av_log(avccontext, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 31377e75c6..73986f89f4 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -23,6 +23,7 @@  #include "libavutil/audioconvert.h"  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "unary.h" @@ -1207,7 +1208,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = s->samples; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index c88a035336..a0eb5c3b63 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -34,6 +34,7 @@   */  #include "avcodec.h" +#include "internal.h"  #include "wma.h"  #undef NDEBUG @@ -842,7 +843,7 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = nb_frames * s->frame_len; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 902c4e32bd..93bccb0e37 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -1384,7 +1384,7 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr)      /* get output buffer */      s->frame.nb_samples = s->samples_per_frame; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          s->packet_loss = 1;          return 0; diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 41a9ea3bb8..444a7274cc 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -29,6 +29,7 @@  #include <math.h>  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  #include "put_bits.h"  #include "wmavoice_data.h" @@ -1814,7 +1815,7 @@ static int synth_superframe(AVCodecContext *ctx, int *got_frame_ptr)      /* get output buffer */      s->frame.nb_samples = 480; -    if ((res = ctx->get_buffer(ctx, &s->frame)) < 0) { +    if ((res = ff_get_buffer(ctx, &s->frame)) < 0) {          av_log(ctx, AV_LOG_ERROR, "get_buffer() failed\n");          return res;      } diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c index 15eb6f895a..685c8ecfd9 100644 --- a/libavcodec/ws-snd1.c +++ b/libavcodec/ws-snd1.c @@ -22,6 +22,7 @@  #include <stdint.h>  #include "libavutil/intreadwrite.h"  #include "avcodec.h" +#include "internal.h"  /**   * @file @@ -89,7 +90,7 @@ static int ws_snd_decode_frame(AVCodecContext *avctx, void *data,      /* get output buffer */      s->frame.nb_samples = out_size; -    if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { +    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/xan.c b/libavcodec/xan.c index d0def65f20..fd7de1c9d7 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -34,6 +34,7 @@  #include "libavutil/intreadwrite.h"  #include "avcodec.h" +#include "internal.h"  #include "bytestream.h"  #define BITSTREAM_READER_LE  #include "get_bits.h" @@ -560,7 +561,7 @@ static int xan_decode_frame(AVCodecContext *avctx,          return AVERROR_INVALIDDATA;      } -    if ((ret = avctx->get_buffer(avctx, &s->current_frame))) { +    if ((ret = ff_get_buffer(avctx, &s->current_frame))) {          av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;      } diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 3c2d8b8957..e1d9753cb1 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -26,6 +26,7 @@  #include "libavutil/imgutils.h"  #include "avcodec.h" +#include "internal.h"  #include "get_bits.h"  typedef struct YopDecContext { @@ -198,7 +199,7 @@ static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,      if (s->frame.data[0])          avctx->release_buffer(avctx, &s->frame); -    ret = avctx->get_buffer(avctx, &s->frame); +    ret = ff_get_buffer(avctx, &s->frame);      if (ret < 0) {          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");          return ret;  | 
