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/wmadec.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/wmadec.c')
-rw-r--r-- | libavcodec/wmadec.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index 1e3b7e32a5..5600f9ba90 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -124,6 +124,10 @@ static int wma_decode_init(AVCodecContext * avctx) } avctx->sample_fmt = AV_SAMPLE_FMT_S16; + + avcodec_get_frame_defaults(&s->frame); + avctx->coded_frame = &s->frame; + return 0; } @@ -797,14 +801,13 @@ static int wma_decode_frame(WMACodecContext *s, int16_t *samples) return 0; } -static int wma_decode_superframe(AVCodecContext *avctx, - void *data, int *data_size, - AVPacket *avpkt) +static int wma_decode_superframe(AVCodecContext *avctx, void *data, + int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; WMACodecContext *s = avctx->priv_data; - int nb_frames, bit_offset, i, pos, len, out_size; + int nb_frames, bit_offset, i, pos, len, ret; uint8_t *q; int16_t *samples; @@ -818,8 +821,6 @@ static int wma_decode_superframe(AVCodecContext *avctx, return 0; buf_size = s->block_align; - samples = data; - init_get_bits(&s->gb, buf, buf_size*8); if (s->use_bit_reservoir) { @@ -830,12 +831,13 @@ static int wma_decode_superframe(AVCodecContext *avctx, nb_frames = 1; } - out_size = nb_frames * s->frame_len * s->nb_channels * - av_get_bytes_per_sample(avctx->sample_fmt); - if (*data_size < out_size) { - av_log(s->avctx, AV_LOG_ERROR, "Insufficient output space\n"); - goto fail; + /* get output buffer */ + s->frame.nb_samples = nb_frames * s->frame_len; + if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return ret; } + samples = (int16_t *)s->frame.data[0]; if (s->use_bit_reservoir) { bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3); @@ -903,7 +905,9 @@ static int wma_decode_superframe(AVCodecContext *avctx, //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d outbytes:%d eaten:%d\n", s->frame_len_bits, s->block_len_bits, s->frame_len, s->block_len, (int8_t *)samples - (int8_t *)data, s->block_align); - *data_size = out_size; + *got_frame_ptr = 1; + *(AVFrame *)data = s->frame; + return s->block_align; fail: /* when error, we reset the bit reservoir */ @@ -928,6 +932,7 @@ AVCodec ff_wmav1_decoder = { .close = ff_wma_end, .decode = wma_decode_superframe, .flush = flush, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), }; @@ -940,5 +945,6 @@ AVCodec ff_wmav2_decoder = { .close = ff_wma_end, .decode = wma_decode_superframe, .flush = flush, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), }; |