@@ -66,6 +66,7 @@ int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr)
hdr->sample_rate = avpriv_mpeg4audio_sample_rates[sr];
hdr->samples = (rdb + 1) * 1024;
hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples;
+ hdr->frame_length = size;
return size;
}
@@ -34,6 +34,7 @@ typedef struct AACADTSHeaderInfo {
uint8_t sampling_index;
uint8_t chan_config;
uint8_t num_aac_frames;
+ uint32_t frame_length;
} AACADTSHeaderInfo;
/**
@@ -21,7 +21,6 @@
#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)
@@ -42,3 +41,31 @@ int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t *frames)
return AVERROR(ENOSYS);
#endif
}
+
+int avpriv_adts_header_parse (AACADTSHeaderInfo **phdr, const uint8_t *buf, size_t size)
+{
+#if CONFIG_ADTS_HEADER
+ int ret = 0;
+ GetBitContext gb;
+
+ if (size < AV_AAC_ADTS_HEADER_SIZE)
+ return AVERROR_INVALIDDATA;
+
+ if (!*phdr)
+ *phdr = av_mallocz(sizeof(AACADTSHeaderInfo));
+ if (!*phdr)
+ return AVERROR(ENOMEM);
+
+ ret = init_get_bits8(&gb, buf, AV_AAC_ADTS_HEADER_SIZE);
+ if (ret < 0)
+ return ret;
+
+ ret = ff_adts_header_parse(&gb, *phdr);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+#else
+ return AVERROR(ENOSYS);
+#endif
+}
@@ -22,6 +22,8 @@
#include <stddef.h>
#include <stdint.h>
+#include "adts_header.h"
+
#define AV_AAC_ADTS_HEADER_SIZE 7
/**
@@ -34,4 +36,6 @@
int av_adts_header_parse(const uint8_t *buf, uint32_t *samples,
uint8_t *frames);
+int avpriv_adts_header_parse (AACADTSHeaderInfo **phdr, const uint8_t *buf, size_t size);
+
#endif /* AVCODEC_ADTS_PARSER_H */
These will be used by HLS demuxer in case of SAMPLE-AES encryption. Signed-off-by: Nachiket Tarate <nachiket.tarate@outlook.com> --- libavcodec/adts_header.c | 1 + libavcodec/adts_header.h | 1 + libavcodec/adts_parser.c | 29 ++++++++++++++++++++++++++++- libavcodec/adts_parser.h | 4 ++++ 4 files changed, 34 insertions(+), 1 deletion(-)