adxdec: get rid of an avpriv function
authorAnton Khirnov <anton@khirnov.net>
Thu, 3 Jul 2014 19:01:59 +0000 (19:01 +0000)
committerAnton Khirnov <anton@khirnov.net>
Wed, 9 Jul 2014 13:37:18 +0000 (13:37 +0000)
The only thing the demuxer needs is the sample rate to set the timebase,
which can be simply read with AV_RB32.

libavcodec/Makefile
libavcodec/adx.c
libavcodec/adx.h
libavcodec/adxdec.c
libavformat/adxdec.c

index 56aac3892f8930e96bccf990b79602490d451d1b..7fa15d55f3cbb2641ff1656172d73c773d3020f4 100644 (file)
@@ -556,7 +556,6 @@ OBJS-$(CONFIG_VC1_VDPAU_HWACCEL)          += vdpau_vc1.o
 
 # libavformat dependencies
 OBJS-$(CONFIG_ADTS_MUXER)              += mpeg4audio.o
-OBJS-$(CONFIG_ADX_DEMUXER)             += adx.o
 OBJS-$(CONFIG_CAF_DEMUXER)             += mpeg4audio.o mpegaudiodata.o  \
                                           ac3tab.o
 OBJS-$(CONFIG_FLAC_DEMUXER)            += flac.o flacdata.o             \
index a9cf4ffd097a0149fc676640621c6ec44dc4f086..4d412d56d3d130ccc8389672bc5252b725cfab17 100644 (file)
@@ -35,8 +35,8 @@ void ff_adx_calculate_coeffs(int cutoff, int sample_rate, int bits, int *coeff)
     coeff[1] = lrintf(-(c * c) * (1 << bits));
 }
 
-int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
-                             int bufsize, int *header_size, int *coeff)
+int ff_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
+                         int bufsize, int *header_size, int *coeff)
 {
     int offset, cutoff;
 
@@ -80,3 +80,11 @@ int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
     *header_size = offset;
     return 0;
 }
+
+#if LIBAVCODEC_VERSION_MAJOR < 56
+int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
+                             int bufsize, int *header_size, int *coeff)
+{
+    return ff_adx_decode_header(avctx, buf, bufsize, header_size, coeff);
+}
+#endif
index ff4c2d6f35fcbda6596d07bd20b957396427797b..9328111012916c779415e309a955da12b113f872 100644 (file)
@@ -74,7 +74,12 @@ void ff_adx_calculate_coeffs(int cutoff, int sample_rate, int bits, int *coeff);
  * @param[out] coeff        2 LPC coefficients, can be NULL
  * @return data offset or negative error code if header is invalid
  */
+int ff_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
+                         int bufsize, int *header_size, int *coeff);
+
+#if LIBAVCODEC_VERSION_MAJOR < 56
 int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
                              int bufsize, int *header_size, int *coeff);
+#endif
 
 #endif /* AVCODEC_ADX_H */
index 17d5becc2b2b0efad195d644f2dff13e99dc0be6..14fddf5520b2aa7763b6261bd0adf9f9a4fdb901 100644 (file)
@@ -40,9 +40,9 @@ static av_cold int adx_decode_init(AVCodecContext *avctx)
     int ret, header_size;
 
     if (avctx->extradata_size >= 24) {
-        if ((ret = avpriv_adx_decode_header(avctx, avctx->extradata,
-                                            avctx->extradata_size, &header_size,
-                                            c->coeff)) < 0) {
+        if ((ret = ff_adx_decode_header(avctx, avctx->extradata,
+                                        avctx->extradata_size, &header_size,
+                                        c->coeff)) < 0) {
             av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n");
             return AVERROR_INVALIDDATA;
         }
@@ -110,8 +110,8 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data,
 
     if (!c->header_parsed && buf_size >= 2 && AV_RB16(buf) == 0x8000) {
         int header_size;
-        if ((ret = avpriv_adx_decode_header(avctx, buf, buf_size, &header_size,
-                                            c->coeff)) < 0) {
+        if ((ret = ff_adx_decode_header(avctx, buf, buf_size, &header_size,
+                                        c->coeff)) < 0) {
             av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n");
             return AVERROR_INVALIDDATA;
         }
index 49e19307d5024db27bc767b41af2471aec007146..fc83ff263b5077d8c592c391d324d71040a1bc3f 100644 (file)
@@ -24,7 +24,6 @@
  */
 
 #include "libavutil/intreadwrite.h"
-#include "libavcodec/adx.h"
 #include "avformat.h"
 #include "internal.h"
 
@@ -66,7 +65,6 @@ static int adx_read_header(AVFormatContext *s)
 {
     ADXDemuxerContext *c = s->priv_data;
     AVCodecContext *avctx;
-    int ret;
 
     AVStream *st = avformat_new_stream(s, NULL);
     if (!st)
@@ -87,11 +85,11 @@ static int adx_read_header(AVFormatContext *s)
     }
     avctx->extradata_size = c->header_size;
 
-    ret = avpriv_adx_decode_header(avctx, avctx->extradata,
-                                   avctx->extradata_size, &c->header_size,
-                                   NULL);
-    if (ret)
-        return ret;
+    if (avctx->extradata_size < 12) {
+        av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n");
+        return AVERROR_INVALIDDATA;
+    }
+    avctx->sample_rate = AV_RB32(avctx->extradata + 8);
 
     st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
     st->codec->codec_id    = s->iformat->raw_codec_id;