[FFmpeg-devel] [PATCH 2/2] libavcodec/ac3_parser: add avpriv function to parse EC3SpecificBox (dec3)

Nachiket Tarate nachiket.tarate at outlook.com
Sun Oct 4 01:09:02 EEST 2020


________________________________
From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> on behalf of James Almer <jamrial at gmail.com>
Sent: Sunday, October 4, 2020 3:07 AM
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/3/2020 6:12 PM, Nachiket Tarate wrote:
> So you want me to change ff_ac3_sample_rate_tab to avpriv_ac3_sample_rate_tab and get channel count using av_get_channel_layout_nb_channels(). Is my understanding correct ?

Yes.

Also please, don't top post in this list. Write below the paragraph
you're replying to.

Okay, Thanks !

I will resubmit this patch.

Meanwhile, will you please review my first patch:

[PATCH 1/2] libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header ?


> ________________________________
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> on behalf of James Almer <jamrial at gmail.com>
> Sent: Saturday, October 3, 2020 11:04 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/3/2020 2:30 PM, Nachiket Tarate wrote:
>> 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 ?
>
> You can use av_get_channel_layout_nb_channels() to get channel count
> from the output of avpriv_ac3_channel_layout_tab[]. Same as
> mov_read_dec3() in libavformat/mov.c does.
>
>>
>> ________________________________
>> 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".
>> _______________________________________________
>> 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".
>>
>
> _______________________________________________
> 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".
> _______________________________________________
> 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".
>

_______________________________________________
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