[FFmpeg-devel] [PATCH 3/4] avcodec/adts_header: Add ff_adts_header_parse_buf()

James Almer jamrial at gmail.com
Fri May 10 20:02:14 EEST 2024


On 5/10/2024 1:56 PM, Andreas Rheinhardt wrote:
> Most users of ff_adts_header_parse() don't already have
> an opened GetBitContext for the header, so add a convenience
> function for them.
> Also use a forward declaration of GetBitContext in adts_header.h
> as this avoids (implicit) inclusion of get_bits.h in some of
> the users that now no longer use a GetBitContext of their own.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>   libavcodec/aac_parser.c        | 16 +++++-----------
>   libavcodec/adts_header.c       | 10 ++++++++++
>   libavcodec/adts_header.h       | 14 ++++++++++++--
>   libavcodec/adts_parser.c       | 18 ++++--------------
>   libavcodec/bsf/aac_adtstoasc.c |  6 ++----
>   libavcodec/ftr_parser.c        |  7 ++-----
>   6 files changed, 35 insertions(+), 36 deletions(-)

> diff --git a/libavcodec/adts_header.h b/libavcodec/adts_header.h
> index d89d487025..4f62edcbac 100644
> --- a/libavcodec/adts_header.h
> +++ b/libavcodec/adts_header.h
> @@ -23,7 +23,8 @@
>   #ifndef AVCODEC_ADTS_HEADER_H
>   #define AVCODEC_ADTS_HEADER_H
>   
> -#include "get_bits.h"
> +#include "adts_parser.h"
> +#include "defs.h"
>   
>   typedef enum {
>       AAC_PARSE_ERROR_SYNC        = -0x1030c0a,
> @@ -43,6 +44,8 @@ typedef struct AACADTSHeaderInfo {
>       uint32_t frame_length;
>   } AACADTSHeaderInfo;
>   
> +struct GetBitContext;
> +
>   /**
>    * Parse the ADTS frame header to the end of the variable header, which is
>    * the first 54 bits.
> @@ -51,7 +54,14 @@ typedef struct AACADTSHeaderInfo {
>    * @return Returns the size in bytes of the header parsed on success
>    * and AAC_PARSE_ERROR_* values otherwise.
>    */
> -int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr);
> +int ff_adts_header_parse(struct GetBitContext *gbc, AACADTSHeaderInfo *hdr);
> +
> +/**
> + * Wrapper around ff_adts_header_parse() for users that already have
> + * a proper GetBitContext.

That have or don't have?

> + */
> +int ff_adts_header_parse_buf(const uint8_t buf[AV_AAC_ADTS_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE],
> +                             AACADTSHeaderInfo *hdr);
>   
>   /**
>    * Parse the ADTS frame header contained in the buffer, which is


More information about the ffmpeg-devel mailing list