]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/apedec.c
binkaudio: simplify frame_len_bits and frame_len calculation
[ffmpeg] / libavcodec / apedec.c
index c27d0863efbfc8a9425507aea5ba04ee5b8fd3f1..05498777b479a43acf87fd7466a6ca9c8128872a 100644 (file)
 #include "dsputil.h"
 #include "get_bits.h"
 #include "bytestream.h"
+#include "libavutil/audioconvert.h"
 
 /**
- * @file libavcodec/apedec.c
+ * @file
  * Monkey's Audio lossless audio decoder
  */
 
@@ -198,8 +199,8 @@ static av_cold int ape_decode_init(AVCodecContext * avctx)
     }
 
     dsputil_init(&s->dsp, avctx);
-    avctx->sample_fmt = SAMPLE_FMT_S16;
-    avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+    avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
     return 0;
 }
 
@@ -211,6 +212,7 @@ static av_cold int ape_decode_close(AVCodecContext * avctx)
     for (i = 0; i < APE_FILTER_LEVELS; i++)
         av_freep(&s->filterbuf[i]);
 
+    av_freep(&s->data);
     return 0;
 }
 
@@ -876,9 +878,15 @@ static int ape_decode_frame(AVCodecContext * avctx,
     return bytes_used;
 }
 
-AVCodec ape_decoder = {
+static void ape_flush(AVCodecContext *avctx)
+{
+    APEContext *s = avctx->priv_data;
+    s->samples= 0;
+}
+
+AVCodec ff_ape_decoder = {
     "ape",
-    CODEC_TYPE_AUDIO,
+    AVMEDIA_TYPE_AUDIO,
     CODEC_ID_APE,
     sizeof(APEContext),
     ape_decode_init,
@@ -886,5 +894,6 @@ AVCodec ape_decoder = {
     ape_decode_close,
     ape_decode_frame,
     .capabilities = CODEC_CAP_SUBFRAMES,
+    .flush = ape_flush,
     .long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"),
 };