diff mbox series

[FFmpeg-devel] lavc/libopenjpegdec: Enable slice threading

Message ID 322cd4ca4823f4d20a8ff0f3b2c668f129910981.camel@acc.umu.se
State New
Headers show
Series [FFmpeg-devel] lavc/libopenjpegdec: Enable slice threading | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Tomas Härdin May 31, 2022, 9:17 a.m. UTC

Comments

Tomas Härdin June 1, 2022, 2:20 p.m. UTC | #1
I'm working on a new patchset for this and non-strict mode. Slice
threading requires openjpeg >= 2.2.0 while configure only demands
2.1.0.

/Tomas
diff mbox series

Patch

From 230f9e23072d971f184b90a8f108517fc866461f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Tue, 31 May 2022 10:54:08 +0200
Subject: [PATCH] lavc/libopenjpegdec: Enable slice threading

---
 libavcodec/libopenjpegdec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index 58715b43ee..649aadad42 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -369,6 +369,10 @@  static int libopenjpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture,
     // Tie decoder with decoding parameters
     opj_setup_decoder(dec, &ctx->dec_params);
 
+    if (avctx->active_thread_type == FF_THREAD_SLICE) {
+        opj_codec_set_threads(dec, avctx->thread_count);
+    }
+
     stream = opj_stream_default_create(OPJ_STREAM_READ);
 
     if (!stream) {
@@ -505,7 +509,7 @@  const FFCodec ff_libopenjpeg_decoder = {
     .p.long_name    = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"),
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_JPEG2000,
-    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | AV_CODEC_CAP_SLICE_THREADS,
     .p.max_lowres   = 31,
     .p.priv_class   = &openjpeg_class,
     .p.wrapper_name = "libopenjpeg",
-- 
2.30.2