X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmpc8.c;h=b97f3ed62c5d09b2cb1111c0193bac634d8433cb;hb=3ab770001817e0f52114a9876819f07fcd8ed93a;hp=b38664215b4b0c2f60abe52b8730ee0ae3f40c18;hpb=9bd854b1ff342f82efa6d2ad4e8fefddce5fa731;p=ffmpeg diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c index b38664215b4..b97f3ed62c5 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"), };