avcodec/libvorbisenc: export padding samples if needed

Based on code from libopus encoder wrapper.

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2026-02-06 15:34:49 -03:00
parent 23dce39d5a
commit a7522f3fef
+12
View File
@@ -417,7 +417,19 @@ static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
duration = av_vorbis_parse_frame(s->vp, avpkt->data, avpkt->size);
if (duration > 0) {
int discard_padding;
ff_af_queue_remove(&s->afq, duration, &avpkt->pts, &avpkt->duration);
discard_padding = ff_samples_to_time_base(avctx, duration) - avpkt->duration;
if (discard_padding > 0) {
uint8_t *side_data = av_packet_new_side_data(avpkt,
AV_PKT_DATA_SKIP_SAMPLES,
10);
if (!side_data)
return AVERROR(ENOMEM);
AV_WL32(side_data + 4, discard_padding);
}
}
*got_packet_ptr = 1;