aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorArthur Taylor <art@ified.ca>2021-01-07 12:55:59 -0800
committerLynne <dev@lynne.ee>2021-01-07 22:42:15 +0100
commitf4bdeddc3cab807e43e0450744dfe9a45661e1d7 (patch)
treebb45ef9d0392e762efc9f7eeaf6bdc1fcd0da8f9 /libavcodec
parent66deab3a2609aa9462709c82be5d4efbb6af2a08 (diff)
downloadffmpeg-f4bdeddc3cab807e43e0450744dfe9a45661e1d7.tar.gz
avcodec/libopusenc: Fix for header pre-skip value
The Opus header initial padding preskip amount is always to be expressed relative to 48kHz. However, the encoder delay returned from querying libopus is relative to the encoding samplerate. Multiply by the samplerate conversion factor to correct. Signed-off-by: Arthur Taylor <art@ified.ca>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/libopusenc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
index bf2d04b4fb..70d17f802b 100644
--- a/libavcodec/libopusenc.c
+++ b/libavcodec/libopusenc.c
@@ -94,7 +94,7 @@ static void libopus_write_header(AVCodecContext *avctx, int stream_count,
bytestream_put_buffer(&p, "OpusHead", 8);
bytestream_put_byte(&p, 1); /* Version */
bytestream_put_byte(&p, channels);
- bytestream_put_le16(&p, avctx->initial_padding); /* Lookahead samples at 48kHz */
+ bytestream_put_le16(&p, avctx->initial_padding * 48000 / avctx->sample_rate); /* Lookahead samples at 48kHz */
bytestream_put_le32(&p, avctx->sample_rate); /* Original sample rate */
bytestream_put_le16(&p, 0); /* Gain of 0dB is recommended. */