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

bps was looked up again for every channel. No change in output.
This technically improves performance a tiny little bit.

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 b41ad3aff46935bf2ea5d1ead80ab79389f5962a Mon Sep 17 00:00:00 2001
From: romainhedouin <[email protected]>
Date: Thu, 15 Oct 2026 13:02:31 +0200
Subject: [PATCH] avcodec/opus/enc: get the sample size once in
 spawn_empty_frame

It was looked up again for every channel. No change in output.

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

diff --git a/libavcodec/opus/enc.c b/libavcodec/opus/enc.c
index c451a5b552..a82929069c 100644
--- a/libavcodec/opus/enc.c
+++ b/libavcodec/opus/enc.c
@@ -547,8 +547,8 @@ static AVFrame *spawn_empty_frame(OpusEncContext *s)
         av_frame_free(&f);
         return NULL;
     }
+    size_t bps = av_get_bytes_per_sample(f->format);
     for (int i = 0; i < s->channels; i++) {
-        size_t bps = av_get_bytes_per_sample(f->format);
         memset(f->extended_data[i], 0, bps*f->nb_samples);
     }
     return f;
-- 
2.52.0

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

Reply via email to