PR #25091 opened by romainhedouin
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25091
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25091.patch

The value is the same for every row. No change in behaviour.
Although not measurable, this technically improves performance.

Found during a code review sweep of ffmpeg using an LLM.

# Summary of changes

Briefly describe what this PR does and why.

<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).

Attached filenames must match the sample's filename:

```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->



>From 24e42e21be669672a3d1fd9d0b4fc1c545087fb2 Mon Sep 17 00:00:00 2001
From: romainhedouin <[email protected]>
Date: Thu, 15 Oct 2026 13:02:30 +0200
Subject: [PATCH] ffplay: compute 1/sqrt(nb_freq) once outside the row loop

The value is the same for every row. No change in behaviour.

Found during a code review sweep of ffmpeg using an LLM.
---
 fftools/ffplay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index a280ed3abe..3054820dc3 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2005,10 +2005,10 @@ static void video_audio_display(VideoState *s)
             /* Least efficient way to do this, we should of course
              * directly access it but it is more than fast enough. */
             if (!SDL_LockTexture(s->vis_texture, &rect, (void **)&pixels, 
&pitch)) {
+                double w = 1 / sqrt(nb_freq);
                 pitch >>= 2;
                 pixels += pitch * s->height;
                 for (y = 0; y < s->height; y++) {
-                    double w = 1 / sqrt(nb_freq);
                     int a = sqrt(w * sqrt(data[0][y].re * data[0][y].re + 
data[0][y].im * data[0][y].im));
                     int b = (nb_display_channels == 2 ) ? sqrt(w * 
hypot(data[1][y].re, data[1][y].im))
                                                         : a;
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to