]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/takdec.c
arm: Remove a leftover define for the pld instruction
[ffmpeg] / libavcodec / takdec.c
index 87fcf832baa378df599e6889a5a4b46579207f4e..0d2dcbbdb29cbeda72a318c5fbe800c8fb23f324 100644 (file)
@@ -25,6 +25,7 @@
  * @author Paul B Mahol
  */
 
+#include "libavutil/internal.h"
 #include "libavutil/samplefmt.h"
 #include "tak.h"
 #include "avcodec.h"
@@ -44,7 +45,6 @@ typedef struct MCDParam {
 
 typedef struct TAKDecContext {
     AVCodecContext *avctx;                          // parent AVCodecContext
-    AVFrame         frame;                          // AVFrame for decoded output
     DSPContext      dsp;
     TAKStreamInfo   ti;
     GetBitContext   gb;                             // bitstream reader initialized to start at the current frame
@@ -175,8 +175,6 @@ static av_cold int tak_decode_init(AVCodecContext *avctx)
     ff_dsputil_init(&s->dsp, avctx);
 
     s->avctx = avctx;
-    avcodec_get_frame_defaults(&s->frame);
-    avctx->coded_frame = &s->frame;
 
     set_sample_rate_params(avctx);
 
@@ -420,11 +418,13 @@ static void decode_filter_coeffs(TAKDecContext *s, int filter_order, int size,
 static int decode_subframe(TAKDecContext *s, int32_t *decoded,
                            int subframe_size, int prev_subframe_size)
 {
-    LOCAL_ALIGNED_16(int16_t, filter, [MAX_PREDICTORS]) = { 0, };
+    LOCAL_ALIGNED_16(int16_t, filter, [MAX_PREDICTORS]);
     GetBitContext *gb = &s->gb;
     int i, ret;
     int dshift, size, filter_quant, filter_order;
 
+    memset(filter, 0, MAX_PREDICTORS * sizeof(*filter));
+
     if (!get_bits1(gb))
         return decode_residues(s, decoded, subframe_size);
 
@@ -599,10 +599,12 @@ static int decorrelate(TAKDecContext *s, int c1, int c2, int length)
     case 6:
         FFSWAP(int32_t*, p1, p2);
     case 7: {
-        LOCAL_ALIGNED_16(int16_t, filter, [MAX_PREDICTORS]) = { 0 };
+        LOCAL_ALIGNED_16(int16_t, filter, [MAX_PREDICTORS]);
         int length2, order_half, filter_order, dval1, dval2;
         int av_uninit(code_size);
 
+        memset(filter, 0, MAX_PREDICTORS * sizeof(*filter));
+
         if (length < 256)
             return AVERROR_INVALIDDATA;
 
@@ -670,6 +672,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame_ptr, AVPacket *pkt)
 {
     TAKDecContext *s  = avctx->priv_data;
+    AVFrame *frame    = data;
     GetBitContext *gb = &s->gb;
     int chan, i, ret, hsize;
 
@@ -682,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;
     }
 
@@ -690,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;
         }
     }
 
@@ -736,8 +740,8 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
     s->nb_samples = s->ti.last_frame_samples ? s->ti.last_frame_samples
                                              : s->ti.frame_samples;
 
-    s->frame.nb_samples = s->nb_samples;
-    if ((ret = ff_get_buffer(avctx, &s->frame)) < 0)
+    frame->nb_samples = s->nb_samples;
+    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
         return ret;
 
     if (avctx->bits_per_coded_sample <= 16) {
@@ -754,7 +758,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
             return ret;
     } else {
         for (chan = 0; chan < avctx->channels; chan++)
-            s->decoded[chan] = (int32_t *)s->frame.extended_data[chan];
+            s->decoded[chan] = (int32_t *)frame->extended_data[chan];
     }
 
     if (s->nb_samples < 16) {
@@ -864,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;
         }
     }
 
@@ -872,7 +877,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
     switch (avctx->sample_fmt) {
     case AV_SAMPLE_FMT_U8P:
         for (chan = 0; chan < avctx->channels; chan++) {
-            uint8_t *samples = (uint8_t *)s->frame.extended_data[chan];
+            uint8_t *samples = (uint8_t *)frame->extended_data[chan];
             int32_t *decoded = s->decoded[chan];
             for (i = 0; i < s->nb_samples; i++)
                 samples[i] = decoded[i] + 0x80;
@@ -880,7 +885,7 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
         break;
     case AV_SAMPLE_FMT_S16P:
         for (chan = 0; chan < avctx->channels; chan++) {
-            int16_t *samples = (int16_t *)s->frame.extended_data[chan];
+            int16_t *samples = (int16_t *)frame->extended_data[chan];
             int32_t *decoded = s->decoded[chan];
             for (i = 0; i < s->nb_samples; i++)
                 samples[i] = decoded[i];
@@ -888,15 +893,14 @@ static int tak_decode_frame(AVCodecContext *avctx, void *data,
         break;
     case AV_SAMPLE_FMT_S32P:
         for (chan = 0; chan < avctx->channels; chan++) {
-            int32_t *samples = (int32_t *)s->frame.extended_data[chan];
+            int32_t *samples = (int32_t *)frame->extended_data[chan];
             for (i = 0; i < s->nb_samples; i++)
                 samples[i] <<= 8;
         }
         break;
     }
 
-    *got_frame_ptr   = 1;
-    *(AVFrame *)data = s->frame;
+    *got_frame_ptr = 1;
 
     return pkt->size;
 }
@@ -913,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),
@@ -921,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,