Browse code

Merge commit '72025ac36c740f031d7e413041fdfe97087c83c4'

* commit '72025ac36c740f031d7e413041fdfe97087c83c4':
lavc: add libdcadec decoder

Conflicts:
Changelog
configure
libavcodec/Makefile
libavcodec/allcodecs.c
libavcodec/libdcadec.c

See: 519868de7d9c99876efcaf57d6a9683c22732cde
Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2015/03/29 19:47:10
Showing 3 changed files
... ...
@@ -6,7 +6,7 @@ version <next>:
6 6
 - TDSC decoder
7 7
 - DTS lossless extension (XLL) decoding (not lossless, disabled by default)
8 8
 - showwavespic filter
9
-- libdcadec wrapper
9
+- DTS decoding through libdcadec
10 10
 - Drop support for nvenc API before 5.0
11 11
 - nvenc H265 encoder
12 12
 - Detelecine filter
... ...
@@ -736,7 +736,7 @@ OBJS-$(CONFIG_ELBG_FILTER)             += elbg.o
736 736
 # external codec libraries
737 737
 OBJS-$(CONFIG_LIBAACPLUS_ENCODER)         += libaacplus.o
738 738
 OBJS-$(CONFIG_LIBCELT_DECODER)            += libcelt_dec.o
739
-OBJS-$(CONFIG_LIBDCADEC_DECODER)          += libdcadec.o
739
+OBJS-$(CONFIG_LIBDCADEC_DECODER)          += libdcadec.o dca.o
740 740
 OBJS-$(CONFIG_LIBFAAC_ENCODER)            += libfaac.o
741 741
 OBJS-$(CONFIG_LIBFDK_AAC_DECODER)         += libfdk-aacdec.o
742 742
 OBJS-$(CONFIG_LIBFDK_AAC_ENCODER)         += libfdk-aacenc.o
... ...
@@ -25,6 +25,7 @@
25 25
 #include "libavutil/channel_layout.h"
26 26
 #include "libavutil/common.h"
27 27
 #include "libavutil/opt.h"
28
+
28 29
 #include "avcodec.h"
29 30
 #include "dca.h"
30 31
 #include "dca_syncwords.h"
... ...
@@ -48,6 +49,10 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data,
48 48
     int input_size = avpkt->size;
49 49
 
50 50
     /* convert bytestream syntax to RAW BE format if required */
51
+    if (input_size < 8) {
52
+        av_log(avctx, AV_LOG_ERROR, "Input size too small\n");
53
+        return AVERROR_INVALIDDATA;
54
+    }
51 55
     mrk = AV_RB32(input);
52 56
     if (mrk != DCA_SYNCWORD_CORE_BE && mrk != DCA_SYNCWORD_SUBSTREAM) {
53 57
         s->buffer = av_fast_realloc(s->buffer, &s->buffer_size, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
... ...
@@ -75,11 +80,16 @@ static int dcadec_decode_frame(AVCodecContext *avctx, void *data,
75 75
     avctx->channel_layout = channel_mask;
76 76
     avctx->sample_rate    = sample_rate;
77 77
 
78
-    av_assert0(bits_per_sample >= 16 && bits_per_sample <= 24);
78
+    av_assert0(bits_per_sample >= 16);
79 79
     if (bits_per_sample == 16)
80 80
         avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
81
-    else
81
+    else if (bits_per_sample <= 24)
82 82
         avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
83
+    else {
84
+        av_log(avctx, AV_LOG_ERROR, "Unsupported number of bits per sample: %d\n",
85
+               bits_per_sample);
86
+        return AVERROR(ENOSYS);
87
+    }
83 88
 
84 89
     avctx->bits_per_raw_sample = bits_per_sample;
85 90