Commit 5f60735450 for ffmpeg

commit 5f60735450503a0fd623eecbb2e26f57d4cc574e
Author: Michael Niedermayer <michael@niedermayer.cc>
Date:   Wed Dec 2 19:23:06 2026 +0000

    avcodec/opus/enc: keep encoder priming when a packet also has end padding

    ff_af_queue_remove() already writes both skip counts from the exact sample counts. Creating new packet side data with only the end padding overwrites the start skip on a short encode.

    Assisted-by: Fairy

diff --git a/libavcodec/opus/enc.c b/libavcodec/opus/enc.c
index a82929069c..80d0fe8af2 100644
--- a/libavcodec/opus/enc.c
+++ b/libavcodec/opus/enc.c
@@ -558,7 +558,7 @@ static int opus_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                              const AVFrame *frame, int *got_packet_ptr)
 {
     OpusEncContext *s = avctx->priv_data;
-    int ret, frame_size, discard_padding, alloc_size = 0;
+    int ret, frame_size, alloc_size = 0;

     if (frame) { /* Add new frame to queue */
         if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
@@ -608,19 +608,11 @@ static int opus_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
     /* Update the psychoacoustic system */
     ff_opus_psy_postencode_update(&s->psyctx, s->frame);

-    /* Remove samples from queue and skip if needed */
+    /* The queue supplies both encoder priming and end padding. */
     ret = ff_af_queue_remove(&s->afq, s->packet.frames*frame_size, avpkt);
     if (ret < 0)
         return ret;

-    discard_padding = s->packet.frames*frame_size - ff_samples_from_time_base(avctx, avpkt->duration);
-    if (discard_padding > 0) {
-        uint8_t *side = av_packet_new_side_data(avpkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
-        if (!side)
-            return AVERROR(ENOMEM);
-        AV_WL32(&side[4], discard_padding);
-    }
-
     *got_packet_ptr = 1;

     return 0;