aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-10-30 18:56:45 -0300
committerJames Almer <jamrial@gmail.com>2017-10-30 18:56:45 -0300
commitb9d3def9b2cb77eb83542086aa3ac883b4d7efa4 (patch)
treea35626011027d7ec2a3165dcc09ff912ed9c1821
parentff173ce8f1a8d043ce87c02a017ec55bb51b2297 (diff)
parentb5f19f7478492307e4b4763aeac3180faf50e17f (diff)
downloadffmpeg-b9d3def9b2cb77eb83542086aa3ac883b4d7efa4.tar.gz
Merge commit 'b5f19f7478492307e4b4763aeac3180faf50e17f'
* commit 'b5f19f7478492307e4b4763aeac3180faf50e17f': aac: Split function to parse ADTS header data into public and private part Merged-by: James Almer <jamrial@gmail.com>
-rwxr-xr-xconfigure8
-rw-r--r--doc/developer.texi2
-rw-r--r--libavcodec/Makefile13
-rw-r--r--libavcodec/aac_adtstoasc_bsf.c13
-rw-r--r--libavcodec/aac_parser.c10
-rw-r--r--libavcodec/aacdec.c2
-rw-r--r--libavcodec/aacdec_fixed.c2
-rw-r--r--libavcodec/aacdec_template.c2
-rw-r--r--libavcodec/adts_header.c (renamed from libavcodec/aacadtsdec.c)7
-rw-r--r--libavcodec/adts_header.h (renamed from libavcodec/aacadtsdec.h)12
-rw-r--r--libavcodec/adts_parser.c44
-rw-r--r--libavcodec/adts_parser.h37
-rw-r--r--libavformat/spdifdec.c24
-rw-r--r--libavformat/spdifenc.c17
14 files changed, 141 insertions, 52 deletions
diff --git a/configure b/configure
index 3380c87432..0414347e3b 100755
--- a/configure
+++ b/configure
@@ -2135,6 +2135,7 @@ HAVE_LIST="
CONFIG_EXTRA="
aandcttables
ac3dsp
+ adts_header
audio_frame_queue
audiodsp
blockdsp
@@ -2421,7 +2422,7 @@ vc1dsp_select="h264chroma qpeldsp startcode"
rdft_select="fft"
# decoders / encoders
-aac_decoder_select="mdct15 mdct sinewin"
+aac_decoder_select="adts_header mdct15 mdct sinewin"
aac_fixed_decoder_select="mdct sinewin"
aac_encoder_select="audio_frame_queue iirfilter lpc mdct sinewin"
aac_latm_decoder_select="aac_decoder aac_latm_parser"
@@ -2873,6 +2874,7 @@ vp9_v4l2m2m_decoder_deps="v4l2_m2m vp9_v4l2_m2m"
wmv3_crystalhd_decoder_select="crystalhd"
# parsers
+aac_parser_select="adts_header"
h264_parser_select="golomb h264dsp h264parse"
hevc_parser_select="hevcparse"
mpegaudio_parser_select="mpegaudioheader"
@@ -2881,6 +2883,7 @@ mpeg4video_parser_select="h263dsp mpegvideo qpeldsp"
vc1_parser_select="vc1dsp"
# bitstream_filters
+aac_adtstoasc_bsf_select="adts_header"
h264_metadata_bsf_select="cbs_h264"
h264_redundant_pps_bsf_select="cbs_h264"
hevc_metadata_bsf_select="cbs_h265"
@@ -3047,7 +3050,8 @@ sap_demuxer_select="sdp_demuxer"
sap_muxer_select="rtp_muxer rtp_protocol rtpenc_chain"
sdp_demuxer_select="rtpdec"
smoothstreaming_muxer_select="ismv_muxer"
-spdif_muxer_select="aac_parser"
+spdif_demuxer_select="adts_header"
+spdif_muxer_select="adts_header"
spx_muxer_select="ogg_muxer"
swf_demuxer_suggest="zlib"
tak_demuxer_select="tak_parser"
diff --git a/doc/developer.texi b/doc/developer.texi
index 98540c8f99..a7b4f1d737 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -184,7 +184,7 @@ e.g. @samp{ff_w64_demuxer}.
@item
For variables and functions visible outside of file scope, used internally
across multiple libraries, use @code{avpriv_} as prefix, for example,
-@samp{avpriv_aac_parse_header}.
+@samp{avpriv_report_missing_feature}.
@item
Each library has its own prefix for public symbols, in addition to the
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e4e7a4adbf..3a33361f33 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -2,6 +2,7 @@ NAME = avcodec
DESC = FFmpeg codec library
HEADERS = ac3_parser.h \
+ adts_parser.h \
avcodec.h \
avdct.h \
avfft.h \
@@ -20,6 +21,7 @@ HEADERS = ac3_parser.h \
xvmc.h \
OBJS = ac3_parser.o \
+ adts_parser.o \
allcodecs.o \
avdct.o \
avpacket.o \
@@ -52,6 +54,7 @@ OBJS = ac3_parser.o \
# subsystems
OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o
OBJS-$(CONFIG_AC3DSP) += ac3dsp.o ac3.o ac3tab.o
+OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o
OBJS-$(CONFIG_AUDIO_FRAME_QUEUE) += audio_frame_queue.o
OBJS-$(CONFIG_AUDIODSP) += audiodsp.o
OBJS-$(CONFIG_BLOCKDSP) += blockdsp.o
@@ -148,10 +151,10 @@ OBJS-$(CONFIG_ZERO12V_DECODER) += 012v.o
OBJS-$(CONFIG_A64MULTI_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps_float.o \
- aacadtsdec.o mpeg4audio.o kbdwin.o \
+ mpeg4audio.o kbdwin.o \
sbrdsp.o aacpsdsp_float.o cbrt_data.o
OBJS-$(CONFIG_AAC_FIXED_DECODER) += aacdec_fixed.o aactab.o aacsbr_fixed.o aacps_fixed.o \
- aacadtsdec.o mpeg4audio.o kbdwin.o \
+ mpeg4audio.o kbdwin.o \
sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \
aacpsy.o aactab.o \
@@ -880,7 +883,6 @@ OBJS-$(CONFIG_MXF_MUXER) += dnxhddata.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
OBJS-$(CONFIG_NUT_DEMUXER) += mpegaudiodata.o mpeg4audio.o
OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o
-OBJS-$(CONFIG_SPDIF_DEMUXER) += aacadtsdec.o mpeg4audio.o
OBJS-$(CONFIG_SPDIF_MUXER) += dca.o
OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o
@@ -957,7 +959,7 @@ OBJS-$(CONFIG_LIBZVBI_TELETEXT_DECODER) += libzvbi-teletextdec.o ass.o
# parsers
OBJS-$(CONFIG_AAC_LATM_PARSER) += latm_parser.o
OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \
- aacadtsdec.o mpeg4audio.o
+ mpeg4audio.o
OBJS-$(CONFIG_AC3_PARSER) += ac3tab.o aac_ac3_parser.o
OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o
OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o
@@ -1003,8 +1005,7 @@ OBJS-$(CONFIG_VP9_PARSER) += vp9_parser.o
OBJS-$(CONFIG_XMA_PARSER) += xma_parser.o
# bitstream filters
-OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o aacadtsdec.o \
- mpeg4audio.o
+OBJS-$(CONFIG_AAC_ADTSTOASC_BSF) += aac_adtstoasc_bsf.o mpeg4audio.o
OBJS-$(CONFIG_CHOMP_BSF) += chomp_bsf.o
OBJS-$(CONFIG_DUMP_EXTRADATA_BSF) += dump_extradata_bsf.o
OBJS-$(CONFIG_DCA_CORE_BSF) += dca_core_bsf.o
diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c
index d92779ed23..49f1f095e6 100644
--- a/libavcodec/aac_adtstoasc_bsf.c
+++ b/libavcodec/aac_adtstoasc_bsf.c
@@ -19,8 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "adts_header.h"
+#include "adts_parser.h"
#include "avcodec.h"
-#include "aacadtsdec.h"
#include "bsf.h"
#include "put_bits.h"
#include "get_bits.h"
@@ -52,12 +53,12 @@ static int aac_adtstoasc_filter(AVBSFContext *bsfc, AVPacket *out)
if (bsfc->par_in->extradata && in->size >= 2 && (AV_RB16(in->data) >> 4) != 0xfff)
goto finish;
- if (in->size < AAC_ADTS_HEADER_SIZE)
+ if (in->size < AV_AAC_ADTS_HEADER_SIZE)
goto packet_too_small;
- init_get_bits(&gb, in->data, AAC_ADTS_HEADER_SIZE * 8);
+ init_get_bits(&gb, in->data, AV_AAC_ADTS_HEADER_SIZE * 8);
- if (avpriv_aac_parse_header(&gb, &hdr) < 0) {
+ if (ff_adts_header_parse(&gb, &hdr) < 0) {
av_log(bsfc, AV_LOG_ERROR, "Error parsing ADTS frame header!\n");
ret = AVERROR_INVALIDDATA;
goto fail;
@@ -70,10 +71,10 @@ static int aac_adtstoasc_filter(AVBSFContext *bsfc, AVPacket *out)
goto fail;
}
- in->size -= AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent;
+ in->size -= AV_AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent;
if (in->size <= 0)
goto packet_too_small;
- in->data += AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent;
+ in->data += AV_AAC_ADTS_HEADER_SIZE + 2 * !hdr.crc_absent;
if (!ctx->first_frame_done) {
int pce_size = 0;
diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c
index 0b868edcb2..b8692625f3 100644
--- a/libavcodec/aac_parser.c
+++ b/libavcodec/aac_parser.c
@@ -22,7 +22,8 @@
#include "parser.h"
#include "aac_ac3_parser.h"
-#include "aacadtsdec.h"
+#include "adts_header.h"
+#include "adts_parser.h"
#include "get_bits.h"
#include "mpeg4audio.h"
@@ -38,9 +39,10 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info,
} tmp;
tmp.u64 = av_be2ne64(state);
- init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8);
+ init_get_bits(&bits, tmp.u8 + 8 - AV_AAC_ADTS_HEADER_SIZE,
+ AV_AAC_ADTS_HEADER_SIZE * 8);
- if ((size = avpriv_aac_parse_header(&bits, &hdr)) < 0)
+ if ((size = ff_adts_header_parse(&bits, &hdr)) < 0)
return 0;
*need_next_header = 0;
*new_frame_start = 1;
@@ -54,7 +56,7 @@ static int aac_sync(uint64_t state, AACAC3ParseContext *hdr_info,
static av_cold int aac_parse_init(AVCodecParserContext *s1)
{
AACAC3ParseContext *s = s1->priv_data;
- s->header_size = AAC_ADTS_HEADER_SIZE;
+ s->header_size = AV_AAC_ADTS_HEADER_SIZE;
s->sync = aac_sync;
return 0;
}
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index fe50871476..44352764a7 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -50,11 +50,11 @@
#include "aac.h"
#include "aactab.h"
#include "aacdectab.h"
+#include "adts_header.h"
#include "cbrt_data.h"
#include "sbr.h"
#include "aacsbr.h"
#include "mpeg4audio.h"
-#include "aacadtsdec.h"
#include "profiles.h"
#include "libavutil/intfloat.h"
diff --git a/libavcodec/aacdec_fixed.c b/libavcodec/aacdec_fixed.c
index d802f3834f..ffd577c789 100644
--- a/libavcodec/aacdec_fixed.c
+++ b/libavcodec/aacdec_fixed.c
@@ -75,11 +75,11 @@
#include "aac.h"
#include "aactab.h"
#include "aacdectab.h"
+#include "adts_header.h"
#include "cbrt_data.h"
#include "sbr.h"
#include "aacsbr.h"
#include "mpeg4audio.h"
-#include "aacadtsdec.h"
#include "profiles.h"
#include "libavutil/intfloat.h"
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 082cc908d2..6c6cdd84af 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -2955,7 +2955,7 @@ static int parse_adts_frame_header(AACContext *ac, GetBitContext *gb)
uint8_t layout_map[MAX_ELEM_ID*4][3];
int layout_map_tags, ret;
- size = avpriv_aac_parse_header(gb, &hdr_info);
+ size = ff_adts_header_parse(gb, &hdr_info);
if (size > 0) {
if (!ac->warned_num_aac_frames && hdr_info.num_aac_frames != 1) {
// This is 2 for "VLB " audio in NSV files.
diff --git a/libavcodec/aacadtsdec.c b/libavcodec/adts_header.c
index d0814ac27e..0889820f8a 100644
--- a/libavcodec/aacadtsdec.c
+++ b/libavcodec/adts_header.c
@@ -22,11 +22,12 @@
*/
#include "aac_ac3_parser.h"
-#include "aacadtsdec.h"
+#include "adts_header.h"
+#include "adts_parser.h"
#include "get_bits.h"
#include "mpeg4audio.h"
-int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
+int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
{
int size, rdb, ch, sr;
int aot, crc_abs;
@@ -51,7 +52,7 @@ int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
skip_bits1(gbc); /* copyright_identification_bit */
skip_bits1(gbc); /* copyright_identification_start */
size = get_bits(gbc, 13); /* aac_frame_length */
- if (size < AAC_ADTS_HEADER_SIZE)
+ if (size < AV_AAC_ADTS_HEADER_SIZE)
return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
skip_bits(gbc, 11); /* adts_buffer_fullness */
diff --git a/libavcodec/aacadtsdec.h b/libavcodec/adts_header.h
index d0584ef36a..f615f6a9f9 100644
--- a/libavcodec/aacadtsdec.h
+++ b/libavcodec/adts_header.h
@@ -20,14 +20,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_AACADTSDEC_H
-#define AVCODEC_AACADTSDEC_H
+#ifndef AVCODEC_ADTS_HEADER_H
+#define AVCODEC_ADTS_HEADER_H
-#include <stdint.h>
#include "get_bits.h"
-#define AAC_ADTS_HEADER_SIZE 7
-
typedef struct AACADTSHeaderInfo {
uint32_t sample_rate;
uint32_t samples;
@@ -40,7 +37,6 @@ typedef struct AACADTSHeaderInfo {
} AACADTSHeaderInfo;
/**
- * Parse AAC frame header.
* Parse the ADTS frame header to the end of the variable header, which is
* the first 54 bits.
* @param[in] gbc BitContext containing the first 54 bits of the frame.
@@ -49,6 +45,6 @@ typedef struct AACADTSHeaderInfo {
* -2 if the version element is invalid, -3 if the sample rate
* element is invalid, or -4 if the bit rate element is invalid.
*/
-int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr);
+int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr);
-#endif /* AVCODEC_AACADTSDEC_H */
+#endif /* AVCODEC_ADTS_HEADER_H */
diff --git a/libavcodec/adts_parser.c b/libavcodec/adts_parser.c
new file mode 100644
index 0000000000..5c9f8ff6f2
--- /dev/null
+++ b/libavcodec/adts_parser.c
@@ -0,0 +1,44 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "adts_header.h"
+#include "adts_parser.h"
+
+int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t *frames)
+{
+#if CONFIG_ADTS_HEADER
+ GetBitContext gb;
+ AACADTSHeaderInfo hdr;
+ int err = init_get_bits8(&gb, buf, AV_AAC_ADTS_HEADER_SIZE);
+ if (err < 0)
+ return err;
+ err = ff_adts_header_parse(&gb, &hdr);
+ if (err < 0)
+ return err;
+ *samples = hdr.samples;
+ *frames = hdr.num_aac_frames;
+ return 0;
+#else
+ return AVERROR(ENOSYS);
+#endif
+}
diff --git a/libavcodec/adts_parser.h b/libavcodec/adts_parser.h
new file mode 100644
index 0000000000..f85becd131
--- /dev/null
+++ b/libavcodec/adts_parser.h
@@ -0,0 +1,37 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_ADTS_PARSER_H
+#define AVCODEC_ADTS_PARSER_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+#define AV_AAC_ADTS_HEADER_SIZE 7
+
+/**
+ * Extract the number of samples and frames from AAC data.
+ * @param[in] buf pointer to AAC data buffer
+ * @param[out] samples Pointer to where number of samples is written
+ * @param[out] frames Pointer to where number of frames is written
+ * @return Returns 0 on success, error code on failure.
+ */
+int av_adts_header_parse(const uint8_t *buf, uint32_t *samples,
+ uint8_t *frames);
+
+#endif /* AVCODEC_ADTS_PARSER_H */
diff --git a/libavformat/spdifdec.c b/libavformat/spdifdec.c
index f7288376f6..21bfce4226 100644
--- a/libavformat/spdifdec.c
+++ b/libavformat/spdifdec.c
@@ -25,18 +25,22 @@
* @author Anssi Hannula
*/
+#include "libavutil/bswap.h"
+
+#include "libavcodec/ac3.h"
+#include "libavcodec/adts_parser.h"
+
#include "avformat.h"
#include "spdif.h"
-#include "libavcodec/ac3.h"
-#include "libavcodec/aacadtsdec.h"
static int spdif_get_offset_and_codec(AVFormatContext *s,
enum IEC61937DataType data_type,
const char *buf, int *offset,
enum AVCodecID *codec)
{
- AACADTSHeaderInfo aac_hdr;
- GetBitContext gbc;
+ uint32_t samples;
+ uint8_t frames;
+ int ret;
switch (data_type & 0xff) {
case IEC61937_AC3:
@@ -56,13 +60,13 @@ static int spdif_get_offset_and_codec(AVFormatContext *s,
*codec = AV_CODEC_ID_MP3;
break;
case IEC61937_MPEG2_AAC:
- init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8);
- if (avpriv_aac_parse_header(&gbc, &aac_hdr) < 0) {
+ ret = av_adts_header_parse(buf, &samples, &frames);
+ if (ret < 0) {
if (s) /* be silent during a probe */
av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n");
- return AVERROR_INVALIDDATA;
+ return ret;
}
- *offset = aac_hdr.samples << 2;
+ *offset = samples << 2;
*codec = AV_CODEC_ID_AAC;
break;
case IEC61937_MPEG2_LAYER1_LSF:
@@ -100,7 +104,7 @@ static int spdif_get_offset_and_codec(AVFormatContext *s,
}
/* Largest offset between bursts we currently handle, i.e. AAC with
- aac_hdr.samples = 4096 */
+ samples = 4096 */
#define SPDIF_MAX_OFFSET 16384
static int spdif_probe(AVProbeData *p)
@@ -132,7 +136,7 @@ int ff_spdif_probe(const uint8_t *p_buf, int buf_size, enum AVCodecID *codec)
} else
consecutive_codes = 0;
- if (buf + 4 + AAC_ADTS_HEADER_SIZE > p_buf + buf_size)
+ if (buf + 4 + AV_AAC_ADTS_HEADER_SIZE > p_buf + buf_size)
break;
/* continue probing to find more sync codes */
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index b47ec123e8..3a50aebbef 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -50,9 +50,9 @@
#include "avio_internal.h"
#include "spdif.h"
#include "libavcodec/ac3.h"
+#include "libavcodec/adts_parser.h"
#include "libavcodec/dca.h"
#include "libavcodec/dca_syncwords.h"
-#include "libavcodec/aacadtsdec.h"
#include "libavutil/opt.h"
typedef struct IEC61937Context {
@@ -349,19 +349,18 @@ static int spdif_header_mpeg(AVFormatContext *s, AVPacket *pkt)
static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
{
IEC61937Context *ctx = s->priv_data;
- AACADTSHeaderInfo hdr;
- GetBitContext gbc;
+ uint32_t samples;
+ uint8_t frames;
int ret;
- init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8);
- ret = avpriv_aac_parse_header(&gbc, &hdr);
+ ret = av_adts_header_parse(pkt->data, &samples, &frames);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n");
- return AVERROR_INVALIDDATA;
+ return ret;
}
- ctx->pkt_offset = hdr.samples << 2;
- switch (hdr.num_aac_frames) {
+ ctx->pkt_offset = samples << 2;
+ switch (frames) {
case 1:
ctx->data_type = IEC61937_MPEG2_AAC;
break;
@@ -373,7 +372,7 @@ static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
break;
default:
av_log(s, AV_LOG_ERROR,
- "%"PRIu32" samples in AAC frame not supported\n", hdr.samples);
+ "%"PRIu32" samples in AAC frame not supported\n", samples);
return AVERROR(EINVAL);
}
//TODO Data type dependent info (LC profile/SBR)