Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec/ac3enc_template: Avoid always-true check
Date: Sun, 19 May 2024 11:48:25 +0200
Message-ID: <AS8P250MB07442093D608E217E9E51EC98FE82@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB07440CB25403CF0260C2F5758FEE2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

Andreas Rheinhardt:
> This might also help Coverity with issue #1596532.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/ac3enc_template.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
> index 49fc6d7f37..049666fdca 100644
> --- a/libavcodec/ac3enc_template.c
> +++ b/libavcodec/ac3enc_template.c
> @@ -31,6 +31,7 @@
>  #include <stdint.h>
>  
>  #include "libavutil/attributes.h"
> +#include "libavutil/avassert.h"
>  #include "libavutil/mem_internal.h"
>  
>  #include "audiodsp.h"
> @@ -50,14 +51,15 @@
>   */
>  static void apply_mdct(AC3EncodeContext *s, uint8_t * const *samples)
>  {
> -    int blk, ch;
> +    av_assert1(s->num_blocks > 0);
>  
> -    for (ch = 0; ch < s->channels; ch++) {
> +    for (int ch = 0; ch < s->channels; ch++) {
>          const SampleType *input_samples0 = (const SampleType*)s->planar_samples[ch];
>          /* Reorder channels from native order to AC-3 order. */
>          const SampleType *input_samples1 = (const SampleType*)samples[s->channel_map[ch]];
> +        int blk = 0;
>  
> -        for (blk = 0; blk < s->num_blocks; blk++) {
> +        do {
>              AC3Block *block = &s->blocks[blk];
>              SampleType *windowed_samples = s->RENAME(windowed_samples);
>  
> @@ -71,7 +73,8 @@ static void apply_mdct(AC3EncodeContext *s, uint8_t * const *samples)
>                       windowed_samples, sizeof(*windowed_samples));
>              input_samples0  = input_samples1;
>              input_samples1 += AC3_BLOCK_SIZE;
> -        }
> +        } while (++blk < s->num_blocks);
> +
>          /* Store last 256 samples of current frame */
>          memcpy(s->planar_samples[ch], input_samples0,
>                 AC3_BLOCK_SIZE * sizeof(*input_samples0));

 Will apply this patchset tomorrow unless there are objections.

- Andreas

_______________________________________________
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".

      parent reply	other threads:[~2024-05-19  9:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-17 17:57 Andreas Rheinhardt
2024-05-17 17:59 ` [FFmpeg-devel] [PATCH 2/2] avcodec/ac3enc: Move transient PutBitContext to stack Andreas Rheinhardt
2024-05-19  9:48 ` Andreas Rheinhardt [this message]

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=AS8P250MB07442093D608E217E9E51EC98FE82@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --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