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

Git pushed a commit to branch master
in repository ffmpeg.

commit b192eb5b71448d87aeee71cd31f1364c40d7fb5c
Author:     James Almer <[email protected]>
AuthorDate: Tue Jun 30 13:12:04 2026 -0300
Commit:     James Almer <[email protected]>
CommitDate: Thu Jul 2 17:53:20 2026 -0300

    avcodec/audio_frame_queue: take into account padding in input frames
    
    If the declared duration is less than the amount of samples in the frame, 
then
    only consider the former as valid.
    
    Signed-off-by: James Almer <[email protected]>
---
 libavcodec/audio_frame_queue.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavcodec/audio_frame_queue.c b/libavcodec/audio_frame_queue.c
index 1ca5f70304..1db4a35673 100644
--- a/libavcodec/audio_frame_queue.c
+++ b/libavcodec/audio_frame_queue.c
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/attributes.h"
+#include "libavutil/intreadwrite.h"
 #include "libavutil/mem.h"
 #include "audio_frame_queue.h"
 #include "encode.h"
@@ -44,13 +45,23 @@ av_cold void ff_af_queue_close(AudioFrameQueue *afq)
 int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
 {
     AudioFrame *new = av_fast_realloc(afq->frames, &afq->frame_alloc, 
sizeof(*afq->frames)*(afq->frame_count+1));
+    const AVFrameSideData *sd;
+    int nb_samples = f->nb_samples;
+
     if(!new)
         return AVERROR(ENOMEM);
     afq->frames = new;
     new += afq->frame_count;
 
+    sd = av_frame_side_data_get(f->side_data, f->nb_side_data, 
AV_FRAME_DATA_SKIP_SAMPLES);
+    if (sd && sd->size >= 10) {
+        int discard_padding = AV_RL32(sd->data + 4);
+        if (discard_padding > 0 && discard_padding < nb_samples)
+            nb_samples -= discard_padding;
+    }
+
     /* get frame parameters */
-    new->duration = f->nb_samples;
+    new->duration = nb_samples;
     new->duration += afq->remaining_delay;
     if (f->pts != AV_NOPTS_VALUE) {
         new->pts = av_rescale_q(f->pts,
@@ -65,7 +76,7 @@ int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
     afq->remaining_delay = 0;
 
     /* add frame sample count */
-    afq->remaining_samples += f->nb_samples;
+    afq->remaining_samples += nb_samples;
 
     afq->frame_count++;
 

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

Reply via email to