diff mbox series

[FFmpeg-devel,2/3] libavcodec/vorbisenc: Add missing initial_padding

Message ID 20210707154134.59769-2-gsun@roblox.com
State Accepted
Commit 24b3178efdfd61c7002d016b0e8db59fd5ff1491
Headers show
Series [FFmpeg-devel,1/3] avformat/oggparsevorbis: Update end_trimming for the last packet | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate fail Make fate failed
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate warning Make fate failed

Commit Message

Guangyu Sun July 7, 2021, 3:41 p.m. UTC
Vorbis has priming samples at the beginning. If the initial_padding is not
set in the encoder, the total sample count will be one frame fewer than it
should be. The result is that we get a truncated version of encoding.

initial_padding should be set to the frame_size used in
vorbis_encode_frame().

Signed-off-by: Guangyu Sun <gsun@roblox.com>
---
 libavcodec/vorbisenc.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index 332c09f9a1..72c6ba1130 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -1287,6 +1287,7 @@  static av_cold int vorbis_encode_init(AVCodecContext *avctx)
     avctx->extradata_size = ret;
 
     avctx->frame_size = 64;
+    avctx->initial_padding = 1 << (venc->log2_blocksize[1] - 1);
 
     ff_af_queue_init(avctx, &venc->afq);