[FFmpeg-devel] [PATCH] avcodec/libopenjpeg: overwrite the bitrate

Marc-Antoine ARNAUD marc-antoine.arnaud at luminvent.com
Thu Nov 7 12:45:55 EET 2024


Signed-off-by: Marc-Antoine Arnaud <marc-antoine.arnaud at luminvent.com>

---
 libavcodec/libopenjpegenc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 01b67dffda4..06937cb9cac 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -301,6 +301,12 @@ static av_cold int
libopenjpeg_encode_init(AVCodecContext *avctx)
         break;
     }

+    // overwrite the bitrate if it's upper to 10M (default value is 200k)
+    if (avctx->bit_rate > 10000000) {
+        ctx->enc_params.max_cs_size = avctx->bit_rate *
avctx->time_base.num / 8 / avctx->time_base.den;
+        ctx->enc_params.max_comp_size = ctx->enc_params.max_cs_size / 1.25;
+    }
+
     switch (ctx->profile) {
     case OPJ_CINEMA2K:
         if (ctx->enc_params.rsiz == OPJ_PROFILE_CINEMA_4K) {
--

2.39.3 (Apple Git-146)


More information about the ffmpeg-devel mailing list