summaryrefslogtreecommitdiff
path: root/libavcodec/8svx.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/8svx.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/8svx.c')
-rw-r--r--libavcodec/8svx.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/libavcodec/8svx.c b/libavcodec/8svx.c
index 3e3eae6c87..4f11b8bec4 100644
--- a/libavcodec/8svx.c
+++ b/libavcodec/8svx.c
@@ -32,6 +32,7 @@
/** decoder context */
typedef struct EightSvxContext {
+ AVFrame frame;
uint8_t fib_acc[2];
const int8_t *table;
@@ -83,13 +84,13 @@ static void raw_decode(uint8_t *dst, const int8_t *src, int src_size,
}
/** decode a frame */
-static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
- AVPacket *avpkt)
+static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
{
EightSvxContext *esc = avctx->priv_data;
int buf_size;
- uint8_t *out_data = data;
- int out_data_size;
+ uint8_t *out_data;
+ int ret;
int is_compr = (avctx->codec_id != CODEC_ID_PCM_S8_PLANAR);
/* for the first packet, copy data to buffer */
@@ -134,15 +135,18 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_si
/* decode next piece of data from the buffer */
buf_size = FFMIN(MAX_FRAME_SIZE, esc->data_size - esc->data_idx);
if (buf_size <= 0) {
- *data_size = 0;
+ *got_frame_ptr = 0;
return avpkt->size;
}
- out_data_size = buf_size * (is_compr + 1) * avctx->channels;
- if (*data_size < out_data_size) {
- av_log(avctx, AV_LOG_ERROR, "Provided buffer with size %d is too small.\n",
- *data_size);
- return AVERROR(EINVAL);
+
+ /* get output buffer */
+ esc->frame.nb_samples = buf_size * (is_compr + 1);
+ if ((ret = avctx->get_buffer(avctx, &esc->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
}
+ out_data = esc->frame.data[0];
+
if (is_compr) {
delta_decode(out_data, &esc->data[0][esc->data_idx], buf_size,
&esc->fib_acc[0], esc->table, avctx->channels);
@@ -158,7 +162,9 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_si
}
}
esc->data_idx += buf_size;
- *data_size = out_data_size;
+
+ *got_frame_ptr = 1;
+ *(AVFrame *)data = esc->frame;
return avpkt->size;
}
@@ -186,6 +192,10 @@ static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
return -1;
}
avctx->sample_fmt = AV_SAMPLE_FMT_U8;
+
+ avcodec_get_frame_defaults(&esc->frame);
+ avctx->coded_frame = &esc->frame;
+
return 0;
}
@@ -207,7 +217,7 @@ AVCodec ff_eightsvx_fib_decoder = {
.init = eightsvx_decode_init,
.close = eightsvx_decode_close,
.decode = eightsvx_decode_frame,
- .capabilities = CODEC_CAP_DELAY,
+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("8SVX fibonacci"),
};
@@ -219,7 +229,7 @@ AVCodec ff_eightsvx_exp_decoder = {
.init = eightsvx_decode_init,
.close = eightsvx_decode_close,
.decode = eightsvx_decode_frame,
- .capabilities = CODEC_CAP_DELAY,
+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"),
};
@@ -231,6 +241,6 @@ AVCodec ff_pcm_s8_planar_decoder = {
.init = eightsvx_decode_init,
.close = eightsvx_decode_close,
.decode = eightsvx_decode_frame,
- .capabilities = CODEC_CAP_DELAY,
+ .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),
};