This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 68e18d3a1cf7c8c83360260d7025de4a03d8a3b7
Author:     Jun Zhao <[email protected]>
AuthorDate: Mon Mar 9 08:40:53 2026 +0800
Commit:     toots <[email protected]>
CommitDate: Wed Mar 18 02:08:09 2026 +0000

    doc/examples/encode_audio: fix hardcoded stereo sample stride
    
    The sample generation loop hardcodes a stride of 2 (stereo) with
    samples[2*j], but the channel count is dynamically selected by
    select_channel_layout() which picks the layout with the highest
    channel count. If the encoder supports more than 2 channels,
    samples will be written at wrong offsets.
    
    Use c->ch_layout.nb_channels as the stride instead.
    
    Signed-off-by: Jun Zhao <[email protected]>
---
 doc/examples/encode_audio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/doc/examples/encode_audio.c b/doc/examples/encode_audio.c
index bb16683d94..8be9e8a82a 100644
--- a/doc/examples/encode_audio.c
+++ b/doc/examples/encode_audio.c
@@ -218,10 +218,10 @@ int main(int argc, char **argv)
         samples = (uint16_t*)frame->data[0];
 
         for (j = 0; j < c->frame_size; j++) {
-            samples[2*j] = (int)(sin(t) * 10000);
+            samples[c->ch_layout.nb_channels*j] = (int)(sin(t) * 10000);
 
             for (k = 1; k < c->ch_layout.nb_channels; k++)
-                samples[2*j + k] = samples[2*j];
+                samples[c->ch_layout.nb_channels*j + k] = 
samples[c->ch_layout.nb_channels*j];
             t += tincr;
         }
         encode(c, frame, pkt, f);

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

Reply via email to