aboutsummaryrefslogtreecommitdiff
path: root/libavcodec/mpc8.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/mpc8.c')
-rw-r--r--libavcodec/mpc8.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c
index b38664215b..b97f3ed62c 100644
--- a/libavcodec/mpc8.c
+++ b/libavcodec/mpc8.c
@@ -228,12 +228,15 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
&mpc8_q8_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC);
}
vlc_initialized = 1;
+
+ avcodec_get_frame_defaults(&c->frame);
+ avctx->coded_frame = &c->frame;
+
return 0;
}
-static int mpc8_decode_frame(AVCodecContext * avctx,
- void *data, int *data_size,
- AVPacket *avpkt)
+static int mpc8_decode_frame(AVCodecContext * avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
@@ -241,14 +244,15 @@ static int mpc8_decode_frame(AVCodecContext * avctx,
GetBitContext gb2, *gb = &gb2;
int i, j, k, ch, cnt, res, t;
Band *bands = c->bands;
- int off, out_size;
+ int off;
int maxband, keyframe;
int last[2];
- out_size = MPC_FRAME_SIZE * 2 * avctx->channels;
- if (*data_size < out_size) {
- av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
- return AVERROR(EINVAL);
+ /* get output buffer */
+ c->frame.nb_samples = MPC_FRAME_SIZE;
+ if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return res;
}
keyframe = c->cur_frame == 0;
@@ -401,14 +405,16 @@ static int mpc8_decode_frame(AVCodecContext * avctx,
}
}
- ff_mpc_dequantize_and_synth(c, maxband, data, avctx->channels);
+ ff_mpc_dequantize_and_synth(c, maxband, c->frame.data[0], avctx->channels);
c->cur_frame++;
c->last_bits_used = get_bits_count(gb);
if(c->cur_frame >= c->frames)
c->cur_frame = 0;
- *data_size = out_size;
+
+ *got_frame_ptr = 1;
+ *(AVFrame *)data = c->frame;
return c->cur_frame ? c->last_bits_used >> 3 : buf_size;
}
@@ -420,5 +426,6 @@ AVCodec ff_mpc8_decoder = {
.priv_data_size = sizeof(MPCContext),
.init = mpc8_decode_init,
.decode = mpc8_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Musepack SV8"),
};