summaryrefslogtreecommitdiff
path: root/libavcodec/atrac3.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-09-06 12:17:45 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-12-02 17:40:40 -0500
commit0eea212943544d40f99b05571aa7159d78667154 (patch)
tree1e6b0271a633bf8a3f92c78bdfbaca275498ee26 /libavcodec/atrac3.c
parent560f773c7ddd17f66e2621222980c1359a9027be (diff)
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/atrac3.c')
-rw-r--r--libavcodec/atrac3.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c
index 3a48a5a647..bdd03402da 100644
--- a/libavcodec/atrac3.c
+++ b/libavcodec/atrac3.c
@@ -86,6 +86,7 @@ typedef struct {
} channel_unit;
typedef struct {
+ AVFrame frame;
GetBitContext gb;
//@{
/** stream data */
@@ -823,16 +824,16 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf,
* @param avctx pointer to the AVCodecContext
*/
-static int atrac3_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- AVPacket *avpkt) {
+static int atrac3_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
+{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ATRAC3Context *q = avctx->priv_data;
- int result = 0, out_size;
+ int result;
const uint8_t* databuf;
- float *samples_flt = data;
- int16_t *samples_s16 = data;
+ float *samples_flt;
+ int16_t *samples_s16;
if (buf_size < avctx->block_align) {
av_log(avctx, AV_LOG_ERROR,
@@ -840,12 +841,14 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
return AVERROR_INVALIDDATA;
}
- out_size = SAMPLES_PER_FRAME * q->channels *
- 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 = SAMPLES_PER_FRAME;
+ if ((result = avctx->get_buffer(avctx, &q->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return result;
}
+ samples_flt = (float *)q->frame.data[0];
+ samples_s16 = (int16_t *)q->frame.data[0];
/* Check if we need to descramble and what buffer to pass on. */
if (q->scrambled_stream) {
@@ -875,7 +878,9 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
(const float **)q->outSamples,
SAMPLES_PER_FRAME, q->channels);
}
- *data_size = out_size;
+
+ *got_frame_ptr = 1;
+ *(AVFrame *)data = q->frame;
return avctx->block_align;
}
@@ -1047,6 +1052,9 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
}
}
+ avcodec_get_frame_defaults(&q->frame);
+ avctx->coded_frame = &q->frame;
+
return 0;
}
@@ -1060,6 +1068,6 @@ AVCodec ff_atrac3_decoder =
.init = atrac3_decode_init,
.close = atrac3_decode_close,
.decode = atrac3_decode_frame,
- .capabilities = CODEC_CAP_SUBFRAMES,
+ .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"),
};