diff mbox series

[FFmpeg-devel,12/13] lavc/jpeg2000dec: Use coarser slicing for initial reslevels

Message ID deb1a569020898aefcce77caaa84935099f6a56c.camel@acc.umu.se
State New
Headers show
Series [FFmpeg-devel,01/13] lavc/jpeg2000dec: Finer granularity threading | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch

Commit Message

Tomas Härdin June 14, 2022, 2:44 p.m. UTC

diff mbox series

Patch

From 15761070d1cdc622ffbc5d6aeb0a50e063361012 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Tue, 14 Jun 2022 11:19:06 +0200
Subject: [PATCH 12/13] lavc/jpeg2000dec: Use coarser slicing for initial
 reslevels

This brings -lowres 2 lossless 4K J2K on an AMD EPYC 7R32 to 52 fps (2080% CPU).
---
 libavcodec/jpeg2000dec.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index a2b9f0166b..18ebe5219d 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2679,7 +2679,16 @@  static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
 
     for (s->reslevel = 0; s->reslevel < maxreslevels; s->reslevel++) {
         for (s->dir = 0; s->dir < 2; s->dir++) {
+            int before = s->slices;
+            int div = s->slices >= 96 ? 7 : 5;
+
+            if (s->reslevel < div) {
+                int halve = 1<<(div - s->reslevel + (s->slices >= 96 ? 0 : 1 - s->dir));
+                s->slices = (s->slices + halve-1)/halve;
+            }
+
             avctx->execute2(avctx, jpeg2000_idwt, NULL, NULL, s->numXtiles * s->numYtiles * s->ncomponents * s->slices);
+            s->slices = before;
         }
     }
 
-- 
2.30.2