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(+)
@@ -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