]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/takdec.c
mxf: Support AAC
[ffmpeg] / libavcodec / takdec.c
index 48a424ebb7c52a49f09a5b8d40330e8a168eb090..b0e84ea3c09a5d79d7ba043deab69d11de90a6b0 100644 (file)
@@ -28,8 +28,8 @@
 #include "libavutil/internal.h"
 #include "libavutil/samplefmt.h"
 #include "tak.h"
+#include "audiodsp.h"
 #include "avcodec.h"
-#include "dsputil.h"
 #include "internal.h"
 #include "unary.h"
 
@@ -45,7 +45,7 @@ typedef struct MCDParam {
 
 typedef struct TAKDecContext {
     AVCodecContext *avctx;                          // parent AVCodecContext
-    DSPContext      dsp;
+    AudioDSPContext adsp;
     TAKStreamInfo   ti;
     GetBitContext   gb;                             // bitstream reader initialized to start at the current frame
 
@@ -172,7 +172,7 @@ static av_cold int tak_decode_init(AVCodecContext *avctx)
 {
     TAKDecContext *s = avctx->priv_data;
 
-    ff_dsputil_init(&s->dsp, avctx);
+    ff_audiodsp_init(&s->adsp);
 
     s->avctx = avctx;
 
@@ -484,8 +484,8 @@ static int decode_subframe(TAKDecContext *s, int32_t *decoded,
     for (i = 0; i < subframe_size - filter_order; i++) {
         int v = 1 << (filter_quant - 1);
 
-        v += s->dsp.scalarproduct_int16(&s->residues[i], filter,
-                                        FFALIGN(filter_order, 16));
+        v += s->adsp.scalarproduct_int16(&s->residues[i], filter,
+                                         FFALIGN(filter_order, 16));
 
         v = (av_clip(v >> filter_quant, -8192, 8191) << dshift) - *decoded;
         *decoded++ = v;
@@ -654,8 +654,8 @@ static int decorrelate(TAKDecContext *s, int c1, int c2, int length)
         for (i = 0; i < length2; i++) {
             int v = 1 << 9;
 
-            v += s->dsp.scalarproduct_int16(&s->residues[i], filter,
-                                            FFALIGN(filter_order, 16));
+            v += s->adsp.scalarproduct_int16(&s->residues[i], filter,
+                                             FFALIGN(filter_order, 16));
 
             p1[i] = (av_clip(v >> 10, -8192, 8191) << dshift) - p1[i];
         }
@@ -685,7 +685,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
         return ret;
 
     if (s->ti.flags & TAK_FRAME_FLAG_HAS_METADATA) {
-        av_log_missing_feature(avctx, "frame metadata", 1);
+        avpriv_request_sample(avctx, "Frame metadata");
         return AVERROR_PATCHWELCOME;
     }
 
@@ -693,7 +693,8 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
     if (avctx->err_recognition & AV_EF_CRCCHECK) {
         if (ff_tak_check_crc(pkt->data, hsize)) {
             av_log(avctx, AV_LOG_ERROR, "CRC error\n");
-            return AVERROR_INVALIDDATA;
+            if (avctx->err_recognition & AV_EF_EXPLODE)
+                return AVERROR_INVALIDDATA;
         }
     }
 
@@ -740,7 +741,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
                                              : s->ti.frame_samples;
 
     frame->nb_samples = s->nb_samples;
-    if ((ret = ff_get_buffer(avctx, frame)) < 0)
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
     if (avctx->bits_per_coded_sample <= 16) {
@@ -867,7 +868,8 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
         if (ff_tak_check_crc(pkt->data + hsize,
                              get_bits_count(gb) / 8 - hsize)) {
             av_log(avctx, AV_LOG_ERROR, "CRC error\n");
-            return AVERROR_INVALIDDATA;
+            if (avctx->err_recognition & AV_EF_EXPLODE)
+                return AVERROR_INVALIDDATA;
         }
     }
 
@@ -915,6 +917,7 @@ static av_cold int tak_decode_close(AVCodecContext *avctx)
 
 AVCodec ff_tak_decoder = {
     .name             = "tak",
+    .long_name        = NULL_IF_CONFIG_SMALL("TAK (Tom's lossless Audio Kompressor)"),
     .type             = AVMEDIA_TYPE_AUDIO,
     .id               = AV_CODEC_ID_TAK,
     .priv_data_size   = sizeof(TAKDecContext),
@@ -923,7 +926,6 @@ AVCodec ff_tak_decoder = {
     .close            = tak_decode_close,
     .decode           = tak_decode_frame,
     .capabilities     = CODEC_CAP_DR1,
-    .long_name        = NULL_IF_CONFIG_SMALL("TAK (Tom's lossless Audio Kompressor)"),
     .sample_fmts      = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
                                                         AV_SAMPLE_FMT_S16P,
                                                         AV_SAMPLE_FMT_S32P,