avcodec/libmp3lame: rescale packet duration when calculating discarded samples

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer
2026-02-13 13:01:54 -03:00
parent e3061be971
commit 5863cab885

View File

@@ -285,7 +285,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts,
&avpkt->duration);
discard_padding = avctx->frame_size - avpkt->duration;
discard_padding = avctx->frame_size - ff_samples_from_time_base(avctx, avpkt->duration);
// Check if subtraction resulted in an overflow
if ((discard_padding < avctx->frame_size) != (avpkt->duration > 0)) {
av_log(avctx, AV_LOG_ERROR, "discard padding overflow\n");