diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-09-06 12:17:45 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-12-02 17:40:40 -0500 |
commit | 0eea212943544d40f99b05571aa7159d78667154 (patch) | |
tree | 1e6b0271a633bf8a3f92c78bdfbaca275498ee26 /libavcodec/imc.c | |
parent | 560f773c7ddd17f66e2621222980c1359a9027be (diff) | |
download | ffmpeg-0eea212943544d40f99b05571aa7159d78667154.tar.gz |
Add avcodec_decode_audio4().
Deprecate avcodec_decode_audio3().
Implement audio support in avcodec_default_get_buffer().
Implement the new audio decoder API in all audio decoders.
Diffstat (limited to 'libavcodec/imc.c')
-rw-r--r-- | libavcodec/imc.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 1f1db6c121..b55eee9b70 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -51,6 +51,8 @@ #define COEFFS 256 typedef struct { + AVFrame frame; + float old_floor[BANDS]; float flcoeffs1[BANDS]; float flcoeffs2[BANDS]; @@ -168,6 +170,10 @@ static av_cold int imc_decode_init(AVCodecContext * avctx) dsputil_init(&q->dsp, avctx); avctx->sample_fmt = AV_SAMPLE_FMT_FLT; avctx->channel_layout = AV_CH_LAYOUT_MONO; + + avcodec_get_frame_defaults(&q->frame); + avctx->coded_frame = &q->frame; + return 0; } @@ -649,9 +655,8 @@ static int imc_get_coeffs (IMCContext* q) { return 0; } -static int imc_decode_frame(AVCodecContext * avctx, - void *data, int *data_size, - AVPacket *avpkt) +static int imc_decode_frame(AVCodecContext * avctx, void *data, + int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; @@ -659,7 +664,7 @@ static int imc_decode_frame(AVCodecContext * avctx, IMCContext *q = avctx->priv_data; int stream_format_code; - int imc_hdr, i, j, out_size, ret; + int imc_hdr, i, j, ret; int flag; int bits, summer; int counter, bitscount; @@ -670,15 +675,16 @@ static int imc_decode_frame(AVCodecContext * avctx, return AVERROR_INVALIDDATA; } - out_size = COEFFS * av_get_bytes_per_sample(avctx->sample_fmt); - if (*data_size < out_size) { - av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); - return AVERROR(EINVAL); + /* get output buffer */ + q->frame.nb_samples = COEFFS; + if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return ret; } + q->out_samples = (float *)q->frame.data[0]; q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2); - q->out_samples = data; init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); /* Check the frame header */ @@ -823,7 +829,8 @@ static int imc_decode_frame(AVCodecContext * avctx, imc_imdct256(q); - *data_size = out_size; + *got_frame_ptr = 1; + *(AVFrame *)data = q->frame; return IMC_BLOCK_SIZE; } @@ -834,6 +841,7 @@ static av_cold int imc_decode_close(AVCodecContext * avctx) IMCContext *q = avctx->priv_data; ff_fft_end(&q->fft); + return 0; } @@ -846,5 +854,6 @@ AVCodec ff_imc_decoder = { .init = imc_decode_init, .close = imc_decode_close, .decode = imc_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"), }; |