Make the current semi-public avpriv_ac3_parse_header() private to lavc.
---
libavcodec/Makefile | 6 ++--
libavcodec/ac3_parser.c | 35 ++++++++++++++++++++--
libavcodec/ac3_parser.h | 13 +++-----
libavcodec/{ac3_parser.h => ac3_parser_internal.h} | 12 ++++----
libavcodec/ac3dec.c | 4 +--
libavcodec/eac3dec.c | 1 -
libavformat/ac3dec.c | 19 +++++++-----
7 files changed, 59 insertions(+), 31 deletions(-)
copy libavcodec/{ac3_parser.h => ac3_parser_internal.h} (83%)
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3a55a28..a78d5be 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1,7 +1,8 @@
NAME = avcodec
DESC = Libav codec library
-HEADERS = avcodec.h \
+HEADERS = ac3_parser.h \
+ avcodec.h \
avfft.h \
d3d11va.h \
dirac.h \
@@ -14,7 +15,8 @@ HEADERS = avcodec.h
\
version.h \
vorbis_parser.h \
-OBJS = allcodecs.o \
+OBJS = ac3_parser.o \
+ allcodecs.o \
avpacket.o \
avpicture.o \
bitstream.o \
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 9704848..53189e0 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -20,15 +20,19 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "config.h"
+
#include "libavutil/channel_layout.h"
#include "parser.h"
#include "ac3_parser.h"
+#include "ac3_parser_internal.h"
#include "aac_ac3_parser.h"
#include "get_bits.h"
#define AC3_HEADER_SIZE 7
+#if CONFIG_AC3_PARSER
static const uint8_t eac3_blocks[4] = {
1, 2, 3, 6
@@ -47,7 +51,7 @@ static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
static const uint8_t surround_levels[4] = { 4, 6, 7, 6 };
-int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
+int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
{
int frame_size_code;
@@ -144,6 +148,24 @@ int avpriv_ac3_parse_header(GetBitContext *gbc,
AC3HeaderInfo *hdr)
return 0;
}
+int av_ac3_parse_header(const uint8_t *buf, size_t size,
+ uint8_t *bitstream_id, uint16_t *frame_size)
+{
+ GetBitContext gb;
+ AC3HeaderInfo hdr;
+ int err;
+
+ init_get_bits8(&gb, buf, size);
+ err = ff_ac3_parse_header(&gb, &hdr);
+ if (err < 0)
+ return AVERROR_INVALIDDATA;
+
+ *bitstream_id = hdr.bitstream_id;
+ *frame_size = hdr.frame_size;
+
+ return 0;
+}
+
static int ac3_sync(uint64_t state, AACAC3ParseContext *hdr_info,
int *need_next_header, int *new_frame_start)
{
@@ -156,7 +178,7 @@ static int ac3_sync(uint64_t state, AACAC3ParseContext
*hdr_info,
GetBitContext gbc;
init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54);
- err = avpriv_ac3_parse_header(&gbc, &hdr);
+ err = ff_ac3_parse_header(&gbc, &hdr);
if(err < 0)
return 0;
@@ -195,3 +217,12 @@ AVCodecParser ff_ac3_parser = {
.parser_parse = ff_aac_ac3_parse,
.parser_close = ff_parse_close,
};
+
+#else
+
+int av_ac3_parse_header(const uint8_t *buf, size_t size,
+ uint8_t *bitstream_id, uint16_t *frame_size)
+{
+ return AVERROR(ENOSYS);
+}
+#endif
diff --git a/libavcodec/ac3_parser.h b/libavcodec/ac3_parser.h
index 9322550..ff2290c 100644
--- a/libavcodec/ac3_parser.h
+++ b/libavcodec/ac3_parser.h
@@ -27,15 +27,10 @@
#include "get_bits.h"
/**
- * Parse AC-3 frame header.
- * Parse the header up to the lfeon element, which is the first 52 or 54 bits
- * depending on the audio coding mode.
- * @param[in] gbc BitContext containing the first 54 bits of the frame.
- * @param[out] hdr Pointer to struct where header info is written.
- * @return Returns 0 on success, -1 if there is a sync word mismatch,
- * -2 if the bsid (version) element is invalid, -3 if the fscod (sample rate)
- * element is invalid, or -4 if the frmsizecod (bit rate) element is invalid.
+ * Extract the bitstream id and the frame size from AC3 data.
*/
-int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
+int av_ac3_parse_header(const uint8_t *buf, size_t size,
+ uint8_t *bitstream_id, uint16_t *frame_size);
+
#endif /* AVCODEC_AC3_PARSER_H */
diff --git a/libavcodec/ac3_parser.h b/libavcodec/ac3_parser_internal.h
similarity index 83%
copy from libavcodec/ac3_parser.h
copy to libavcodec/ac3_parser_internal.h
index 9322550..5e305e8 100644
--- a/libavcodec/ac3_parser.h
+++ b/libavcodec/ac3_parser_internal.h
@@ -1,7 +1,5 @@
/*
- * AC-3 parser prototypes
- * Copyright (c) 2003 Fabrice Bellard
- * Copyright (c) 2003 Michael Niedermayer
+ * AC-3 parser internal code
*
* This file is part of Libav.
*
@@ -20,8 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef AVCODEC_AC3_PARSER_H
-#define AVCODEC_AC3_PARSER_H
+#ifndef AVCODEC_AC3_PARSER_INTERNAL_H
+#define AVCODEC_AC3_PARSER_INTERNAL_H
#include "ac3.h"
#include "get_bits.h"
@@ -36,6 +34,6 @@
* -2 if the bsid (version) element is invalid, -3 if the fscod (sample rate)
* element is invalid, or -4 if the frmsizecod (bit rate) element is invalid.
*/
-int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
+int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
-#endif /* AVCODEC_AC3_PARSER_H */
+#endif /* AVCODEC_AC3_PARSER_INTERNAL_H */
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index ad50552..4be0f1f 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -36,7 +36,7 @@
#include "bswapdsp.h"
#include "internal.h"
#include "aac_ac3_parser.h"
-#include "ac3_parser.h"
+#include "ac3_parser_internal.h"
#include "ac3dec.h"
#include "ac3dec_data.h"
#include "kbdwin.h"
@@ -270,7 +270,7 @@ static int parse_frame_header(AC3DecodeContext *s)
AC3HeaderInfo hdr;
int err;
- err = avpriv_ac3_parse_header(&s->gbc, &hdr);
+ err = ff_ac3_parse_header(&s->gbc, &hdr);
if (err)
return err;
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index fe52d27..89db7d3 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -48,7 +48,6 @@
#include "internal.h"
#include "aac_ac3_parser.h"
#include "ac3.h"
-#include "ac3_parser.h"
#include "ac3dec.h"
#include "ac3dec_data.h"
#include "eac3_data.h"
diff --git a/libavformat/ac3dec.c b/libavformat/ac3dec.c
index 4ceffa5..7a86805 100644
--- a/libavformat/ac3dec.c
+++ b/libavformat/ac3dec.c
@@ -28,8 +28,6 @@ static int ac3_eac3_probe(AVProbeData *p, enum AVCodecID
expected_codec_id)
{
int max_frames, first_frames = 0, frames;
uint8_t *buf, *buf2, *end;
- AC3HeaderInfo hdr;
- GetBitContext gbc;
enum AVCodecID codec_id = AV_CODEC_ID_AC3;
max_frames = 0;
@@ -40,15 +38,20 @@ static int ac3_eac3_probe(AVProbeData *p, enum AVCodecID
expected_codec_id)
buf2 = buf;
for(frames = 0; buf2 < end; frames++) {
- init_get_bits(&gbc, buf2, 54);
- if(avpriv_ac3_parse_header(&gbc, &hdr) < 0)
+ uint8_t bitstream_id;
+ uint16_t frame_size;
+ int ret;
+
+ ret = av_ac3_parse_header(buf2, end - buf2, &bitstream_id,
+ &frame_size);
+ if (ret < 0)
break;
- if(buf2 + hdr.frame_size > end ||
- av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2,
hdr.frame_size - 2))
+ if (buf2 + frame_size > end ||
+ av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2,
frame_size - 2))
break;
- if (hdr.bitstream_id > 10)
+ if (bitstream_id > 10)
codec_id = AV_CODEC_ID_EAC3;
- buf2 += hdr.frame_size;
+ buf2 += frame_size;
}
max_frames = FFMAX(max_frames, frames);
if(buf == p->buf)
--
2.0.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel