Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andrew Sayers <ffmpeg-devel@pileofstuff.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 2/4] avcodec/aac_ac3_parser: Untangle AAC and AC3 parsing error codes
Date: Sat, 11 May 2024 14:44:11 +0100
Message-ID: <Zj92K0DmSw2witEL@andrews-2024-laptop.sayers> (raw)
In-Reply-To: <GV1P250MB0737E625947ADBC97011909E8FE72@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>

On Fri, May 10, 2024 at 06:56:25PM +0200, Andreas Rheinhardt wrote:
> Also remove the (unused) AAC_AC3_PARSE_ERROR_CHANNEL_CFG while at it;
> furthermore, fix the documentation of ff_ac3_parse_header()
> and (ff|avpriv)_adts_header_parse().
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/aac_ac3_parser.h      | 10 ----------
>  libavcodec/ac3_parser.c          | 14 +++++++-------
>  libavcodec/ac3_parser_internal.h | 13 ++++++++++---
>  libavcodec/ac3dec.c              | 18 ++++++++----------
>  libavcodec/adts_header.c         |  7 +++----
>  libavcodec/adts_header.h         | 16 ++++++++++------
>  libavcodec/eac3dec.c             |  6 +++---
>  7 files changed, 41 insertions(+), 43 deletions(-)
> 
> diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h
> index bc16181a19..e3259d1841 100644
> --- a/libavcodec/aac_ac3_parser.h
> +++ b/libavcodec/aac_ac3_parser.h
> @@ -28,16 +28,6 @@
>  #include "avcodec.h"
>  #include "parser.h"
>  
> -typedef enum {
> -    AAC_AC3_PARSE_ERROR_SYNC        = -0x1030c0a,
> -    AAC_AC3_PARSE_ERROR_BSID        = -0x2030c0a,
> -    AAC_AC3_PARSE_ERROR_SAMPLE_RATE = -0x3030c0a,
> -    AAC_AC3_PARSE_ERROR_FRAME_SIZE  = -0x4030c0a,
> -    AAC_AC3_PARSE_ERROR_FRAME_TYPE  = -0x5030c0a,
> -    AAC_AC3_PARSE_ERROR_CRC         = -0x6030c0a,
> -    AAC_AC3_PARSE_ERROR_CHANNEL_CFG = -0x7030c0a,
> -} AACAC3ParseError;
> -
>  typedef struct AACAC3ParseContext {
>      ParseContext pc;
>      int header_size;
> diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
> index 4e0ba73481..69989690dd 100644
> --- a/libavcodec/ac3_parser.c
> +++ b/libavcodec/ac3_parser.c
> @@ -81,12 +81,12 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
>  
>      hdr->sync_word = get_bits(gbc, 16);
>      if(hdr->sync_word != 0x0B77)
> -        return AAC_AC3_PARSE_ERROR_SYNC;
> +        return AC3_PARSE_ERROR_SYNC;
>  
>      /* read ahead to bsid to distinguish between AC-3 and E-AC-3 */
>      hdr->bitstream_id = show_bits_long(gbc, 29) & 0x1F;
>      if(hdr->bitstream_id > 16)
> -        return AAC_AC3_PARSE_ERROR_BSID;
> +        return AC3_PARSE_ERROR_BSID;
>  
>      hdr->num_blocks = 6;
>      hdr->ac3_bit_rate_code = -1;
> @@ -103,11 +103,11 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
>          hdr->crc1 = get_bits(gbc, 16);
>          hdr->sr_code = get_bits(gbc, 2);
>          if(hdr->sr_code == 3)
> -            return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
> +            return AC3_PARSE_ERROR_SAMPLE_RATE;
>  
>          frame_size_code = get_bits(gbc, 6);
>          if(frame_size_code > 37)
> -            return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
> +            return AC3_PARSE_ERROR_FRAME_SIZE;
>  
>          hdr->ac3_bit_rate_code = (frame_size_code >> 1);
>  
> @@ -138,19 +138,19 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
>          hdr->crc1 = 0;
>          hdr->frame_type = get_bits(gbc, 2);
>          if(hdr->frame_type == EAC3_FRAME_TYPE_RESERVED)
> -            return AAC_AC3_PARSE_ERROR_FRAME_TYPE;
> +            return AC3_PARSE_ERROR_FRAME_TYPE;
>  
>          hdr->substreamid = get_bits(gbc, 3);
>  
>          hdr->frame_size = (get_bits(gbc, 11) + 1) << 1;
>          if(hdr->frame_size < AC3_HEADER_SIZE)
> -            return AAC_AC3_PARSE_ERROR_FRAME_SIZE;
> +            return AC3_PARSE_ERROR_FRAME_SIZE;
>  
>          hdr->sr_code = get_bits(gbc, 2);
>          if (hdr->sr_code == 3) {
>              int sr_code2 = get_bits(gbc, 2);
>              if(sr_code2 == 3)
> -                return AAC_AC3_PARSE_ERROR_SAMPLE_RATE;
> +                return AC3_PARSE_ERROR_SAMPLE_RATE;
>              hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2;
>              hdr->sr_shift = 1;
>          } else {
> diff --git a/libavcodec/ac3_parser_internal.h b/libavcodec/ac3_parser_internal.h
> index 2ac0e67ec2..2c4eb546e5 100644
> --- a/libavcodec/ac3_parser_internal.h
> +++ b/libavcodec/ac3_parser_internal.h
> @@ -64,15 +64,22 @@ typedef struct AC3HeaderInfo {
>      /** @} */
>  } AC3HeaderInfo;
>  
> +typedef enum {
> +    AC3_PARSE_ERROR_SYNC        = -0x1030c0a,
> +    AC3_PARSE_ERROR_BSID        = -0x2030c0a,
> +    AC3_PARSE_ERROR_SAMPLE_RATE = -0x3030c0a,
> +    AC3_PARSE_ERROR_FRAME_SIZE  = -0x4030c0a,
> +    AC3_PARSE_ERROR_FRAME_TYPE  = -0x5030c0a,
> +    AC3_PARSE_ERROR_CRC         = -0x6030c0a,
> +} AC3ParseError;
> +
>  /**
>   * 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.
> + * @return Returns 0 on success and AC3_PARSE_ERROR_* values otherwise.

"@return Returns" is redundant - can this (and similar below) just be
"@return 0 on success ..."?
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-05-11 13:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-10 16:54 [FFmpeg-devel] [PATCH 1/4] avcodec/adts_parser: Don't presume buffer to be padded Andreas Rheinhardt
2024-05-10 16:56 ` [FFmpeg-devel] [PATCH 2/4] avcodec/aac_ac3_parser: Untangle AAC and AC3 parsing error codes Andreas Rheinhardt
2024-05-11 13:44   ` Andrew Sayers [this message]
2024-05-10 16:56 ` [FFmpeg-devel] [PATCH 3/4] avcodec/adts_header: Add ff_adts_header_parse_buf() Andreas Rheinhardt
2024-05-10 17:02   ` James Almer
2024-05-10 17:03     ` Andreas Rheinhardt
2024-05-10 16:56 ` [FFmpeg-devel] [PATCH 4/4] avcodec/aac_ac3_parser: Use ff_adts_header_parse_buf() Andreas Rheinhardt
2024-05-18 16:59 ` [FFmpeg-devel] [PATCH 1/4] avcodec/adts_parser: Don't presume buffer to be padded Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zj92K0DmSw2witEL@andrews-2024-laptop.sayers \
    --to=ffmpeg-devel@pileofstuff.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git