Commit 594d4d5d authored by Anton Khirnov's avatar Anton Khirnov
Browse files

lavc: add a wrapper for AVCodecContext.get_buffer().

It will be useful in the upcoming transition to refcounted AVFrames.
parent cb45553f
......@@ -29,6 +29,7 @@
#include "bytestream.h"
#include "dsputil.h"
#include "get_bits.h"
#include "internal.h"
//#undef NDEBUG
//#include <assert.h>
......@@ -833,7 +834,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
avctx->release_buffer(avctx, p);
p->reference = 1;
if (avctx->get_buffer(avctx, p) < 0) {
if (ff_get_buffer(avctx, p) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
......@@ -849,7 +850,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
} else if (frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")) {
if (!f->last_picture.data[0]) {
f->last_picture.reference = 1;
if (avctx->get_buffer(avctx, &f->last_picture) < 0) {
if (ff_get_buffer(avctx, &f->last_picture) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
......
......@@ -38,6 +38,7 @@
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "internal.h"
static const enum AVPixelFormat pixfmt_rgb24[] = {
......@@ -83,7 +84,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
c->pic.reference = 0;
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
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;
}
......
......@@ -29,6 +29,7 @@
*/
#include "avcodec.h"
#include "internal.h"
#include "libavutil/common.h"
/** decoder context */
......@@ -136,7 +137,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;
}
......
......@@ -181,7 +181,7 @@ static int frame_configure_elements(AVCodecContext *avctx)
/* get output buffer */
ac->frame.nb_samples = 2048;
if ((ret = avctx->get_buffer(avctx, &ac->frame)) < 0) {
if ((ret = ff_get_buffer(avctx, &ac->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
......
......@@ -1371,7 +1371,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
/* get output buffer */
avctx->channels = s->out_channels;
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;
}
......
......@@ -23,6 +23,7 @@
#include "bytestream.h"
#include "adpcm.h"
#include "adpcm_data.h"
#include "internal.h"
/**
* @file
......@@ -611,7 +612,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;
}
......
......@@ -23,6 +23,7 @@
#include "avcodec.h"
#include "adx.h"
#include "get_bits.h"
#include "internal.h"
/**
* @file
......@@ -142,7 +143,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;
}
......
......@@ -49,6 +49,7 @@
#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
#include "internal.h"
#include "unary.h"
#include "mathops.h"
......@@ -317,7 +318,7 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
if (!alac->nb_samples) {
/* get output buffer */
alac->frame.nb_samples = output_samples;
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;
}
......
......@@ -36,6 +36,7 @@
#include "bytestream.h"
#include "bgmc.h"
#include "dsputil.h"
#include "internal.h"
#include "libavutil/samplefmt.h"
#include "libavutil/crc.h"
......@@ -1461,7 +1462,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;
}
......
......@@ -53,6 +53,7 @@
#include "acelp_pitch_delay.h"
#include "lsp.h"
#include "amr.h"
#include "internal.h"
#include "amrnbdata.h"
......@@ -947,7 +948,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;
}
......
......@@ -35,6 +35,7 @@
#include "acelp_filters.h"
#include "acelp_vectors.h"
#include "acelp_pitch_delay.h"
#include "internal.h"
#define AMR_USE_16BIT_TABLES
#include "amr.h"
......@@ -1093,7 +1094,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;
}
......
......@@ -28,6 +28,7 @@
#include "libavutil/lfg.h"
#include "avcodec.h"
#include "cga_data.h"
#include "internal.h"
#define ATTR_BOLD 0x01 /**< Bold/Bright-foreground (mode 1) */
#define ATTR_FAINT 0x02 /**< Faint (mode 2) */
......@@ -222,7 +223,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;
......
......@@ -26,6 +26,7 @@
#include "avcodec.h"
#include "dsputil.h"
#include "bytestream.h"
#include "internal.h"
/**
* @file
......@@ -909,7 +910,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;
}
......
......@@ -30,6 +30,7 @@
#include "avcodec.h"
#include "put_bits.h"
#include "dsputil.h"
#include "internal.h"
#include "mathops.h"
#include "mpeg12data.h"
......@@ -194,7 +195,7 @@ static int decode_frame(AVCodecContext *avctx,
avctx->release_buffer(avctx, p);
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
if(ff_get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
......
......@@ -36,6 +36,7 @@
#include "get_bits.h"
#include "dsputil.h"
#include "fft.h"
#include "internal.h"
#include "sinewin.h"
#include "atrac.h"
......@@ -286,7 +287,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;
}
......
......@@ -42,6 +42,7 @@
#include "fft.h"
#include "fmtconvert.h"
#include "get_bits.h"
#include "internal.h"
#include "atrac.h"
#include "atrac3data.h"
......@@ -811,7 +812,7 @@ static int atrac3_decode_frame(AVCodecContext *avctx, void *data,
/* get output buffer */
q->frame.nb_samples = SAMPLES_PER_FRAME;
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;
}
......
......@@ -24,6 +24,7 @@
*/
#include "avcodec.h"
#include "internal.h"
#include "libavutil/internal.h"
typedef struct AuraDecodeContext {
......@@ -72,7 +73,7 @@ static int aura_decode_frame(AVCodecContext *avctx,
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
s->frame.reference = 0;
if(avctx->get_buffer(avctx, &s->frame) < 0) {
if(ff_get_buffer(avctx, &s->frame) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
......
......@@ -29,6 +29,7 @@
#include "libavutil/common.h"
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
typedef struct BFIContext {
AVCodecContext *avctx;
......@@ -61,7 +62,7 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data,
bfi->frame.reference = 1;
if (avctx->get_buffer(avctx, &bfi->frame) < 0) {
if (ff_get_buffer(avctx, &bfi->frame) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
......
......@@ -25,6 +25,7 @@
#include "dsputil.h"
#include "binkdata.h"
#include "binkdsp.h"
#include "internal.h"
#include "mathops.h"
#define BITSTREAM_READER_LE
......@@ -1171,7 +1172,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
if(c->pic.data[0])
avctx->release_buffer(avctx, &c->pic);
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;
}
......
......@@ -36,6 +36,7 @@
#include "dct.h"
#include "rdft.h"
#include "fmtconvert.h"
#include "internal.h"
#include "libavutil/intfloat.h"
extern const uint16_t ff_wma_critical_freqs[25];
......@@ -321,7 +322,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
/* get output buffer */
s->frame.nb_samples = 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;
}
......
......@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "bytestream.h"
#include "bmp.h"
#include "internal.h"
#include "msrledec.h"
static av_cold int bmp_decode_init(AVCodecContext *avctx){
......@@ -205,7 +206,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
avctx->release_buffer(avctx, p);
p->reference = 0;
if(avctx->get_buffer(avctx, p) < 0){
if(ff_get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
......
......@@ -22,6 +22,7 @@
#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
enum BMVFlags{
BMV_NOP = 0,
......@@ -242,7 +243,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
avctx->release_buffer(avctx, &c->pic);
c->pic.reference = 3;
if ((ret = avctx->get_buffer(avctx, &c->pic)) < 0) {
if ((ret = ff_get_buffer(avctx, &c->pic)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
......@@ -335,7 +336,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;
}
......
......@@ -29,6 +29,7 @@
#include "get_bits.h"
#include "golomb.h"
#include "cavs.h"
#include "internal.h"
static const uint8_t mv_scan[4] = {
MV_FWD_X0,MV_FWD_X1,
......@@ -950,7 +951,7 @@ static int decode_pic(AVSContext *h) {
if(h->picture.f.data[0])
s->avctx->release_buffer(s->avctx, &h->picture.f);
s->avctx->get_buffer(s->avctx, &h->picture.f);
ff_get_buffer(s->avctx, &h->picture.f);
ff_cavs_init_pic(h);
h->picture.poc = get_bits(&s->gb,8)*2;
......
......@@ -21,6 +21,7 @@
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
/**
* @file
......@@ -333,7 +334,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;
......
......@@ -23,6 +23,7 @@
#include "libavutil/imgutils.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#define BIT_PLANAR 0x00
#define BYTE_PLANAR 0x20
......@@ -262,7 +263,7 @@ static int cdxl_decode_frame(AVCodecContext *avctx, void *data,
avctx->release_buffer(avctx, p);
p->reference = 0;
if ((ret = avctx->get_buffer(avctx, p)) < 0) {
if ((ret = ff_get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
......
......@@ -70,7 +70,7 @@ static int decode_frame(AVCodecContext *avctx,
}
p->reference = 0;
if (avctx->get_buffer(avctx, p) < 0) {
if (ff_get_buffer(avctx, p) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
......
......@@ -24,6 +24,7 @@
#include "dsputil.h"
#include "get_bits.h"
#include "avcodec.h"
#include "internal.h"
typedef struct CLLCContext {
DSPContext dsp;
......@@ -333,7 +334,7 @@ static int cllc_decode_frame(AVCodecContext *avctx, void *data,
avctx->pix_fmt = AV_PIX_FMT_RGB24;
avctx->bits_per_raw_sample = 8;
ret = avctx->get_buffer(avctx, pic);
ret = ff_get_buffer(avctx, pic);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n");
return ret;
......@@ -348,7 +349,7 @@ static int cllc_decode_frame(AVCodecContext *avctx, void *data,
avctx->pix_fmt = AV_PIX_FMT_ARGB;
avctx->bits_per_raw_sample = 8;
ret = avctx->get_buffer(avctx, pic);
ret = ff_get_buffer(avctx, pic);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n");
return ret;
......
......@@ -24,6 +24,7 @@
#include "libavutil/common.h"
#include "avcodec.h"
#include "celp_filters.h"
#include "internal.h"
#include "libavutil/lfg.h"
typedef struct CNGContext {
......@@ -144,7 +145,7 @@ static int cng_decode_frame(AVCodecContext *avctx, void *data,
p->excitation, avctx->frame_size, p->order);
p->avframe.nb_samples = avctx->frame_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;
}
......
......@@ -49,6 +49,7 @@
#include "dsputil.h"
#include "bytestream.h"
#include "fft.h"
#include "internal.h"
#include "sinewin.h"
#include "cookdata.h"
......@@ -957,7 +958,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;
}
......
......@@ -22,6 +22,7 @@
#include <stdlib.h>
#include "avcodec.h"
#include "internal.h"
#include "libavutil/common.h"
#if CONFIG_ZLIB
......@@ -153,7 +154,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
c->pic.reference = 1;
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
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;
}
......
......@@ -34,6 +34,7 @@
#include "avcodec.h"
#include "dsputil.h"
#include "internal.h"
#include "libavutil/internal.h"
......@@ -105,7 +106,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx,
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID;
s->frame.reference = 0;
if (avctx->get_buffer(avctx, &s->frame) < 0) {
if (ff_get_buffer(avctx, &s->frame) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
......
......@@ -45,6 +45,7 @@
#include "synth_filter.h"
#include "dcadsp.h"
#include "fmtconvert.h"
#include "internal.h"
#if ARCH_ARM
# include "arm/dca.h"
......@@ -1835,7 +1836,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;
}
......
......@@ -22,6 +22,7 @@
#include "avcodec.h"
#include "bytestream.h"
#include "internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/mem.h"
......@@ -321,7 +322,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;
}
......
......@@ -30,6 +30,7 @@
#include "get_bits.h"
#include "dnxhddata.h"
#include "dsputil.h"
#include "internal.h"
typedef struct DNXHDContext {
AVCodecContext *avctx;
......@@ -357,7 +358,7 @@ static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
if (first_field) {
if (ctx->picture.data[0])
avctx->release_buffer(avctx, &ctx->picture);
if (avctx->get_buffer(avctx, &ctx->picture) < 0) {
if (ff_get_buffer(avctx, &ctx->picture) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
......
......@@ -40,6 +40,7 @@
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "bytestream.h"