diff mbox series

[FFmpeg-devel] avcodec/aacenc: don't redundantly re-compute max sfb

Message ID 20240428093711.3126293-1-yotam.ofek@gmail.com
State Accepted
Commit a9a69a5a312f889d95c60de52485ee8e96e20e47
Headers show
Series [FFmpeg-devel] avcodec/aacenc: don't redundantly re-compute max sfb | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Yotam Ofek April 28, 2024, 9:37 a.m. UTC
Remove an unneeded inner loop in adjust_frame_information that
had no effect, the loop body can be run only once and will compute
the same max sfb.
---
 libavcodec/aacenc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Lynne April 28, 2024, 12:02 p.m. UTC | #1
Apr 28, 2024, 11:37 by yotam.ofek@gmail.com:

> Remove an unneeded inner loop in adjust_frame_information that
> had no effect, the loop body can be run only once and will compute
> the same max sfb.
> ---
>  libavcodec/aacenc.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
> index 7feb723289..163598e938 100644
> --- a/libavcodec/aacenc.c
> +++ b/libavcodec/aacenc.c
> @@ -538,11 +538,9 @@ static void adjust_frame_information(ChannelElement *cpe, int chans)
>  maxsfb = 0;
>  cpe->ch[ch].pulse.num_pulse = 0;
>  for (w = 0; w < ics->num_windows; w += ics->group_len[w]) {
> -            for (w2 =  0; w2 < ics->group_len[w]; w2++) {
> -                for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w*16+cmaxsfb-1]; cmaxsfb--)
> -                    ;
> -                maxsfb = FFMAX(maxsfb, cmaxsfb);
> -            }
> +            for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w*16+cmaxsfb-1]; cmaxsfb--)
> +                ;
> +            maxsfb = FFMAX(maxsfb, cmaxsfb);
>  }
>  ics->max_sfb = maxsfb; 
>

Thanks, pushed
diff mbox series

Patch

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 7feb723289..163598e938 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -538,11 +538,9 @@  static void adjust_frame_information(ChannelElement *cpe, int chans)
         maxsfb = 0;
         cpe->ch[ch].pulse.num_pulse = 0;
         for (w = 0; w < ics->num_windows; w += ics->group_len[w]) {
-            for (w2 =  0; w2 < ics->group_len[w]; w2++) {
-                for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w*16+cmaxsfb-1]; cmaxsfb--)
-                    ;
-                maxsfb = FFMAX(maxsfb, cmaxsfb);
-            }
+            for (cmaxsfb = ics->num_swb; cmaxsfb > 0 && cpe->ch[ch].zeroes[w*16+cmaxsfb-1]; cmaxsfb--)
+                ;
+            maxsfb = FFMAX(maxsfb, cmaxsfb);
         }
         ics->max_sfb = maxsfb;