diff --git a/libavcodec/bmv.c b/libavcodec/bmv.c index 715e6a3b62..c480815333 100644 --- a/libavcodec/bmv.c +++ b/libavcodec/bmv.c @@ -302,32 +302,23 @@ static av_cold int decode_end(AVCodecContext *avctx) return 0; } -typedef struct BMVAudioDecContext { - AVFrame frame; -} BMVAudioDecContext; - static const int bmv_aud_mults[16] = { 16512, 8256, 4128, 2064, 1032, 516, 258, 192, 129, 88, 64, 56, 48, 40, 36, 32 }; static av_cold int bmv_aud_decode_init(AVCodecContext *avctx) { - BMVAudioDecContext *c = avctx->priv_data; - avctx->channels = 2; avctx->channel_layout = AV_CH_LAYOUT_STEREO; avctx->sample_fmt = AV_SAMPLE_FMT_S16; - avcodec_get_frame_defaults(&c->frame); - avctx->coded_frame = &c->frame; - return 0; } static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { - BMVAudioDecContext *c = avctx->priv_data; + AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int blocks = 0, total_blocks, i; @@ -343,12 +334,12 @@ static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data, } /* get output buffer */ - c->frame.nb_samples = total_blocks * 32; - if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) { + frame->nb_samples = total_blocks * 32; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - output_samples = (int16_t *)c->frame.data[0]; + output_samples = (int16_t *)frame->data[0]; for (blocks = 0; blocks < total_blocks; blocks++) { uint8_t code = *buf++; @@ -361,8 +352,7 @@ static int bmv_aud_decode_frame(AVCodecContext *avctx, void *data, } } - *got_frame_ptr = 1; - *(AVFrame *)data = c->frame; + *got_frame_ptr = 1; return buf_size; } @@ -383,7 +373,6 @@ AVCodec ff_bmv_audio_decoder = { .name = "bmv_audio", .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_BMV_AUDIO, - .priv_data_size = sizeof(BMVAudioDecContext), .init = bmv_aud_decode_init, .decode = bmv_aud_decode_frame, .capabilities = CODEC_CAP_DR1, diff --git a/libavcodec/cngdec.c b/libavcodec/cngdec.c index d2b1257af9..edfdd3e44c 100644 --- a/libavcodec/cngdec.c +++ b/libavcodec/cngdec.c @@ -28,7 +28,6 @@ #include "libavutil/lfg.h" typedef struct CNGContext { - AVFrame avframe; float *refl_coef, *target_refl_coef; float *lpc_coef; int order; @@ -58,8 +57,6 @@ static av_cold int cng_decode_init(AVCodecContext *avctx) avctx->channels = 1; avctx->sample_rate = 8000; - avcodec_get_frame_defaults(&p->avframe); - avctx->coded_frame = &p->avframe; p->order = 12; avctx->frame_size = 640; p->refl_coef = av_mallocz(p->order * sizeof(*p->refl_coef)); @@ -105,7 +102,7 @@ static void cng_decode_flush(AVCodecContext *avctx) static int cng_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { - + AVFrame *frame = data; CNGContext *p = avctx->priv_data; int buf_size = avpkt->size; int ret, i; @@ -144,19 +141,18 @@ static int cng_decode_frame(AVCodecContext *avctx, void *data, ff_celp_lp_synthesis_filterf(p->filter_out + p->order, p->lpc_coef, p->excitation, avctx->frame_size, p->order); - p->avframe.nb_samples = avctx->frame_size; - if ((ret = ff_get_buffer(avctx, &p->avframe)) < 0) { + frame->nb_samples = avctx->frame_size; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - buf_out = (int16_t *)p->avframe.data[0]; + buf_out = (int16_t *)frame->data[0]; for (i = 0; i < avctx->frame_size; i++) buf_out[i] = p->filter_out[i + p->order]; memcpy(p->filter_out, p->filter_out + avctx->frame_size, p->order * sizeof(*p->filter_out)); - *got_frame_ptr = 1; - *(AVFrame *)data = p->avframe; + *got_frame_ptr = 1; return buf_size; } diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 4117cee1f9..54b576f89f 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -123,7 +123,6 @@ typedef struct cook { AVCodecContext* avctx; DSPContext dsp; - AVFrame frame; GetBitContext gb; /* stream data */ int num_vectors; @@ -956,6 +955,7 @@ static int decode_subpacket(COOKContext *q, COOKSubpacket *p, static int cook_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { + AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; COOKContext *q = avctx->priv_data; @@ -969,12 +969,12 @@ 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 = ff_get_buffer(avctx, &q->frame)) < 0) { + frame->nb_samples = q->samples_per_channel; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - samples = (float **)q->frame.extended_data; + samples = (float **)frame->extended_data; } /* estimate subpacket sizes */ @@ -1015,8 +1015,7 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data, return avctx->block_align; } - *got_frame_ptr = 1; - *(AVFrame *) data = q->frame; + *got_frame_ptr = 1; return avctx->block_align; } @@ -1269,9 +1268,6 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) else avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; - avcodec_get_frame_defaults(&q->frame); - avctx->coded_frame = &q->frame; - #ifdef DEBUG dump_cook_context(q); #endif diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index ff6375dd79..e2f37328aa 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -349,7 +349,6 @@ static av_always_inline int get_bitalloc(GetBitContext *gb, BitAlloc *ba, typedef struct { AVCodecContext *avctx; - AVFrame frame; /* Frame header */ int frame_type; ///< type of the current frame int samples_deficit; ///< deficit sample count @@ -2067,6 +2066,7 @@ static void dca_exss_parse_header(DCAContext *s) static int dca_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { + AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int channel_mask; @@ -2354,17 +2354,17 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, } /* get output buffer */ - s->frame.nb_samples = 256 * (s->sample_blocks / 8); - if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) { + frame->nb_samples = 256 * (s->sample_blocks / 8); + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - samples_flt = (float **) s->frame.extended_data; + samples_flt = (float **)frame->extended_data; /* allocate buffer for extra channels if downmixing */ if (avctx->channels < full_channels) { ret = av_samples_get_buffer_size(NULL, full_channels - channels, - s->frame.nb_samples, + frame->nb_samples, avctx->sample_fmt, 0); if (ret < 0) return ret; @@ -2377,7 +2377,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, ret = av_samples_fill_arrays((uint8_t **)s->extra_channels, NULL, s->extra_channels_buffer, full_channels - channels, - s->frame.nb_samples, avctx->sample_fmt, 0); + frame->nb_samples, avctx->sample_fmt, 0); if (ret < 0) return ret; } @@ -2456,8 +2456,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, for (i = 0; i < 2 * s->lfe * 4; i++) s->lfe_data[i] = s->lfe_data[i + lfe_samples]; - *got_frame_ptr = 1; - *(AVFrame *) data = s->frame; + *got_frame_ptr = 1; return buf_size; } @@ -2491,9 +2490,6 @@ static av_cold int dca_decode_init(AVCodecContext *avctx) avctx->channels = avctx->request_channels; } - avcodec_get_frame_defaults(&s->frame); - avctx->coded_frame = &s->frame; - return 0; } diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index ea6fabd47b..bae338d8f9 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -230,7 +230,6 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } typedef struct PCMDecode { - AVFrame frame; short table[256]; } PCMDecode; @@ -262,9 +261,6 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx) if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) avctx->bits_per_raw_sample = av_get_bits_per_sample(avctx->codec_id); - avcodec_get_frame_defaults(&s->frame); - avctx->coded_frame = &s->frame; - return 0; } @@ -289,7 +285,7 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx) n /= avctx->channels; \ for (c = 0; c < avctx->channels; c++) { \ int i; \ - dst = s->frame.extended_data[c]; \ + dst = frame->extended_data[c]; \ for (i = n; i > 0; i--) { \ uint ## size ## _t v = bytestream_get_ ## endian(&src); \ AV_WN ## size ## A(dst, (v - offset) << shift); \ @@ -303,6 +299,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, const uint8_t *src = avpkt->data; int buf_size = avpkt->size; PCMDecode *s = avctx->priv_data; + AVFrame *frame = data; int sample_size, c, n, ret, samples_per_block; uint8_t *samples; int32_t *dst_int32_t; @@ -358,12 +355,12 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, n = buf_size / sample_size; /* get output buffer */ - s->frame.nb_samples = n * samples_per_block / avctx->channels; - if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) { + frame->nb_samples = n * samples_per_block / avctx->channels; + if ((ret = ff_get_buffer(avctx, frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - samples = s->frame.data[0]; + samples = frame->data[0]; switch (avctx->codec_id) { case AV_CODEC_ID_PCM_U32LE: @@ -410,7 +407,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, n /= avctx->channels; for (c = 0; c < avctx->channels; c++) { int i; - samples = s->frame.extended_data[c]; + samples = frame->extended_data[c]; for (i = n; i > 0; i--) *samples++ = *src++ + 128; } @@ -466,7 +463,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, #endif /* HAVE_BIGENDIAN */ n /= avctx->channels; for (c = 0; c < avctx->channels; c++) { - samples = s->frame.extended_data[c]; + samples = frame->extended_data[c]; bytestream_get_buffer(&src, samples, n * sample_size); } break; @@ -488,7 +485,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, case AV_CODEC_ID_PCM_DVD: { const uint8_t *src8; - dst_int32_t = (int32_t *)s->frame.data[0]; + dst_int32_t = (int32_t *)frame->data[0]; n /= avctx->channels; switch (avctx->bits_per_coded_sample) { case 20: @@ -521,7 +518,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, int i; n /= avctx->channels; for (c = 0; c < avctx->channels; c++) { - dst_int32_t = (int32_t *)s->frame.extended_data[c]; + dst_int32_t = (int32_t *)frame->extended_data[c]; for (i = 0; i < n; i++) { // extract low 20 bits and expand to 32 bits *dst_int32_t++ = (src[2] << 28) | @@ -544,8 +541,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void *data, return -1; } - *got_frame_ptr = 1; - *(AVFrame *)data = s->frame; + *got_frame_ptr = 1; return buf_size; }