diff mbox series

[FFmpeg-devel,2/2] avcodec/encode: Fix default setting of bits_per_raw_sample

Message ID tencent_7E816A341D3E9D577D9D74E04E5B5234BB09@qq.com
State Accepted
Commit 35dc129940246088d376e5c343b8076ffbea2b64
Headers show
Series [FFmpeg-devel,1/2] avformat/mov: Update bits_per_coded_sample after read pcmC | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Zhao Zhili Feb. 22, 2024, 9:37 a.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

bits_per_raw_sample doesn't always match size of AV_SAMPLE_FMT_,
e.g., S24.
---
 libavcodec/encode.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index a436be2657..8ca07814ee 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -736,6 +736,8 @@  static int encode_preinit_audio(AVCodecContext *avctx)
         }
     }
 
+    if (!avctx->bits_per_raw_sample)
+        avctx->bits_per_raw_sample = av_get_exact_bits_per_sample(avctx->codec_id);
     if (!avctx->bits_per_raw_sample)
         avctx->bits_per_raw_sample = 8 * av_get_bytes_per_sample(avctx->sample_fmt);