[FFmpeg-devel] [PATCH 3/3] lavc/encode: pick a sane default for bits_per_raw_sample if it's not set

Anton Khirnov anton at khirnov.net
Thu Jan 20 18:05:06 EET 2022


Fixes #9563.
---
 libavcodec/encode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index b6f81d1458..44ab81af3f 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -535,6 +535,9 @@ static int encode_preinit_audio(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
+    if (!avctx->bits_per_raw_sample)
+        avctx->bits_per_raw_sample = 8 * av_get_bytes_per_sample(avctx->sample_fmt);
+
     return 0;
 }
 
-- 
2.33.0



More information about the ffmpeg-devel mailing list