[FFmpeg-devel] [PATCH] avcodec/libopenjpeg: set guard bits to 1 for 2K cinema

Marc-Antoine ARNAUD marc-antoine.arnaud at luminvent.com
Thu Nov 7 15:26:01 EET 2024


Signed-off-by: Marc-Antoine Arnaud <marc-antoine.arnaud at luminvent.com>
---
 libavcodec/libopenjpegenc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 06937cb9cac..ee2513d2a38 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -691,6 +691,17 @@ static int
libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         ret = AVERROR_EXTERNAL;
         goto done;
     }
+
+    if (ctx->cinema_mode == OPJ_CINEMA2K_24 || ctx->profile ==
OPJ_CINEMA2K) {
+        const char* options[2] = { "GUARD_BITS=1", NULL };
+        opj_encoder_set_extra_options(compress, options);
+    }
+
     stream = opj_stream_default_create(OPJ_STREAM_WRITE);

     if (!stream) {
--
2.39.3 (Apple Git-146)

Le jeu. 7 nov. 2024 à 14:06, Marc-Antoine ARNAUD <
marc-antoine.arnaud at luminvent.com> a écrit :

> Signed-off-by: Marc-Antoine Arnaud <marc-antoine.arnaud at luminvent.com>
> ---
>  libavcodec/libopenjpegenc.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
> index 06937cb9cac..ee2513d2a38 100644
> --- a/libavcodec/libopenjpegenc.c
> +++ b/libavcodec/libopenjpegenc.c
> @@ -691,6 +691,17 @@ static int
> libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
>          ret = AVERROR_EXTERNAL;
>          goto done;
>      }
> +
> +    if (ctx->cinema_mode == OPJ_CINEMA2K_24 || ctx->profile ==
> OPJ_CINEMA2K) {
> +        const char* options[4] = { NULL, NULL };
> +        char szGuardBits[32];
> +        int guard_bits = 1;
> +        sprintf(szGuardBits, "GUARD_BITS=%d", guard_bits);
> +        options[0] = szGuardBits;
> +
> +        opj_encoder_set_extra_options(compress, options);
> +    }
> +
>      stream = opj_stream_default_create(OPJ_STREAM_WRITE);
>
>      if (!stream) {
> --
> 2.39.3 (Apple Git-146)
>


-- 
Marc-Antoine ARNAUD
CEO & Founder

mobile:  +33 6 84 71 84 45 <+33+6+84+71+84+45>
email:     marc-antoine.arnaud at luminvent.com
<arnaud.marc-antoine at luminvent.com>
website:  luminvent.com


More information about the ffmpeg-devel mailing list