]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpc8.c
vda: cosmetic.
[ffmpeg] / libavcodec / mpc8.c
index 2f6bde3231f74aa8686dce14097bfc16a97b6293..a4750ad9619ff4293a7208ff4709a926ade813be 100644 (file)
@@ -230,12 +230,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;
@@ -243,14 +246,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;
@@ -403,14 +407,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;
 }
@@ -422,5 +428,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"),
 };