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

Git pushed a commit to branch master
in repository ffmpeg.

commit 355d05a78442c42112186e389efddf811be02262
Author:     James Almer <[email protected]>
AuthorDate: Thu May 7 15:06:35 2026 -0300
Commit:     James Almer <[email protected]>
CommitDate: Sat May 16 13:55:22 2026 -0300

    avcodec/encode: report that the padded samples must be discarded
    
    For encoders where we pad the last frame, actually tag the silent samples as
    discardable.
    
    Signed-off-by: James Almer <[email protected]>
---
 libavcodec/encode.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 160aaa739e..de79340cff 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -155,6 +155,8 @@ static int encode_make_refcounted(AVCodecContext *avctx, 
AVPacket *avpkt)
  */
 static int pad_last_frame(AVCodecContext *s, AVFrame *frame, const AVFrame 
*src, int out_samples)
 {
+    AVFrameSideData *sd;
+    int discard_padding;
     int ret;
 
     frame->format         = src->format;
@@ -179,6 +181,17 @@ static int pad_last_frame(AVCodecContext *s, AVFrame 
*frame, const AVFrame *src,
                                       s->ch_layout.nb_channels, 
s->sample_fmt)) < 0)
         goto fail;
 
+    discard_padding = frame->nb_samples - src->nb_samples;
+    av_assert1(discard_padding > 0);
+    sd = av_frame_new_side_data(frame, AV_FRAME_DATA_SKIP_SAMPLES, 10);
+    if (!sd) {
+        ret = AVERROR(ENOMEM);
+        goto fail;
+    }
+    AV_WL32A(sd->data, 0);
+    AV_WL32A(sd->data + 4, discard_padding);
+    AV_WL16A(sd->data + 8, 0);
+
     return 0;
 
 fail:

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

Reply via email to