[FFmpeg-devel] [PATCH 2/2] libavcodec/ac3_parser: add avpriv function to parse EC3SpecificBox (dec3)
Nachiket Tarate
nachiket.tarate at outlook.com
Sat Oct 3 20:30:34 EEST 2020
Actually names of 2 tables ff_ac3_sample_rate_tab and ff_ac3_channels_tab need to be changed in order to access them from libavformat.
There would be changes in multiple files in which these tables have been used currently. Is that fine ?
________________________________
From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> on behalf of James Almer <jamrial at gmail.com>
Sent: Friday, October 2, 2020 7:48 PM
To: ffmpeg-devel at ffmpeg.org <ffmpeg-devel at ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 2/2] libavcodec/ac3_parser: add avpriv function to parse EC3SpecificBox (dec3)
On 10/2/2020 10:10 AM, Nachiket Tarate wrote:
> This will be used by HLS demuxer for SAMPLE-AES decryption.
>
> Signed-off-by: Nachiket Tarate <nachiket.tarate at outlook.com>
> ---
> libavcodec/ac3_parser.c | 47 ++++++++++++++++++++++++++++++++
> libavcodec/ac3_parser_internal.h | 4 +++
> 2 files changed, 51 insertions(+)
>
> diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
> index ba171653ef..a8fdde0ff9 100644
> --- a/libavcodec/ac3_parser.c
> +++ b/libavcodec/ac3_parser.c
> @@ -2,6 +2,7 @@
> * AC-3 parser
> * Copyright (c) 2003 Fabrice Bellard
> * Copyright (c) 2003 Michael Niedermayer
> + * Copyright (c) 2020 Nachiket Tarate
> *
> * This file is part of FFmpeg.
> *
> @@ -172,6 +173,47 @@ int avpriv_ac3_parse_header(AC3HeaderInfo **phdr, const uint8_t *buf,
> return get_bits_count(&gb);
> }
>
> +/*
> + * Parse 'dec3' EC3SpecificBox
> + */
> +int avpriv_eac3_parse_dec3(AC3HeaderInfo **phdr, const uint8_t *buf, size_t size)
> +{
> + GetBitContext gb;
> + AC3HeaderInfo *hdr;
> + int err;
> +
> + int data_rate, fscod, acmod, lfeon;
> +
> + if (!*phdr)
> + *phdr = av_mallocz(sizeof(AC3HeaderInfo));
> + if (!*phdr)
> + return AVERROR(ENOMEM);
> + hdr = *phdr;
> +
> + err = init_get_bits8(&gb, buf, size);
> + if (err < 0)
> + return AVERROR_INVALIDDATA;
> +
> + data_rate = get_bits(&gb, 13);
> + skip_bits(&gb, 3);
> + fscod = get_bits(&gb, 2);
> + skip_bits(&gb, 10);
> + acmod = get_bits(&gb, 3);
> + lfeon = get_bits(&gb, 1);
> +
> + hdr->sample_rate = ff_ac3_sample_rate_tab[fscod];
Why not instead just make this array avpriv_? Everything else can be
done within libavformat. See mov_read_dec3() in mov.c
> +
> + hdr->channels = ff_ac3_channels_tab[acmod] + lfeon;
> +
> + hdr->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
> + if (lfeon)
> + hdr->channel_layout |= AV_CH_LOW_FREQUENCY;
> +
> + hdr->bit_rate = data_rate*1000;
> +
> + return 0;
> +}
> +
> int av_ac3_parse_header(const uint8_t *buf, size_t size,
> uint8_t *bitstream_id, uint16_t *frame_size)
> {
> @@ -256,6 +298,11 @@ int avpriv_ac3_parse_header(AC3HeaderInfo **phdr, const uint8_t *buf,
> return AVERROR(ENOSYS);
> }
>
> +int avpriv_eac3_parse_dec3(AC3HeaderInfo **phdr, const uint8_t *buf, size_t size)
> +{
> + return AVERROR(ENOSYS);
> +}
> +
> int av_ac3_parse_header(const uint8_t *buf, size_t size,
> uint8_t *bitstream_id, uint16_t *frame_size)
> {
> diff --git a/libavcodec/ac3_parser_internal.h b/libavcodec/ac3_parser_internal.h
> index 3648802a73..0388a5bb5e 100644
> --- a/libavcodec/ac3_parser_internal.h
> +++ b/libavcodec/ac3_parser_internal.h
> @@ -38,5 +38,9 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr);
>
> int avpriv_ac3_parse_header(AC3HeaderInfo **hdr, const uint8_t *buf,
> size_t size);
> +/*
> + * Parse 'dec3' EC3SpecificBox
> + */
> +int avpriv_eac3_parse_dec3(AC3HeaderInfo **phdr, const uint8_t *buf, size_t size);
>
> #endif /* AVCODEC_AC3_PARSER_INTERNAL_H */
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list