From: "Tomas Härdin" <tjoppen@acc.umu.se>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 13/13] lavc/jpeg2000dec: Component-level threading of write_frame()
Date: Tue, 14 Jun 2022 16:47:23 +0200
Message-ID: <7b9cfcb8fe330310e5d7558d67d424d626fe6719.camel@acc.umu.se> (raw)
In-Reply-To: <10ec51ef44325c2de6d5de7b994a9b6c8eb5e3a2.camel@acc.umu.se>
[-- Attachment #1: Type: text/plain, Size: 212 bytes --]
Don't have access to the full machine to test this with 96 threads. On
2/3rds of an AMD EPYC 7R32 (-threads 64) it runs at 50 fps.
Specifically the decoder uses 59.2 seconds to decode a 60.0 second
clip.
/Tomas
[-- Attachment #2: 0013-lavc-jpeg2000dec-Component-level-threading-of-write_.patch --]
[-- Type: text/x-patch, Size: 5575 bytes --]
From 19fc2413dc2bafff577c68830cde48e08138771e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Tue, 14 Jun 2022 15:45:32 +0200
Subject: [PATCH 13/13] lavc/jpeg2000dec: Component-level threading of
write_frame()
Split off MCT and don't bother with it unless the picture actually uses MCT.
---
libavcodec/jpeg2000dec.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 18ebe5219d..8eaeda1c66 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -156,6 +156,7 @@ typedef struct Jpeg2000DecoderContext {
// used for idwt slicing
int reslevel, dir, slices;
int have_dwt97_int; // 1 if any coding style is FF_DWT97_INT
+ int have_mct;
} Jpeg2000DecoderContext;
/* get_bits functions for JPEG2000 packet bitstream
@@ -600,6 +601,9 @@ static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c,
return AVERROR_INVALIDDATA;
}
+ if (tmp.mct)
+ s->have_mct = 1;
+
if ((ret = get_cox(s, &tmp)) < 0)
return ret;
tmp.init = 1;
@@ -2073,16 +2077,14 @@ static int jpeg2000_dwt97_int_postshift(AVCodecContext *avctx, void *td,
#define WRITE_FRAME(D, PIXEL) \
static inline void write_frame_ ## D(Jpeg2000DecoderContext * s, Jpeg2000Tile * tile, \
- AVFrame * picture, int precision) \
+ AVFrame * picture, int precision, int compno) \
{ \
const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(s->avctx->pix_fmt); \
int planar = !!(pixdesc->flags & AV_PIX_FMT_FLAG_PLANAR); \
int pixelsize = planar ? 1 : pixdesc->nb_components; \
\
- int compno; \
int x, y; \
\
- for (compno = 0; compno < s->ncomponents; compno++) { \
Jpeg2000Component *comp = tile->comp + compno; \
Jpeg2000CodingStyle *codsty = tile->codsty + compno; \
PIXEL *line; \
@@ -2129,8 +2131,6 @@ static int jpeg2000_dwt97_int_postshift(AVCodecContext *avctx, void *td,
} \
line += picture->linesize[plane] / sizeof(PIXEL); \
} \
- } \
- \
}
WRITE_FRAME(8, uint8_t)
@@ -2138,26 +2138,36 @@ WRITE_FRAME(16, uint16_t)
#undef WRITE_FRAME
-static int jpeg2000_mct_write_frame(AVCodecContext *avctx, void *td,
- int jobnr, int threadnr)
+static int jpeg2000_mct(AVCodecContext *avctx, void *td,
+ int jobnr, int threadnr)
{
Jpeg2000DecoderContext *s = avctx->priv_data;
- AVFrame *picture = td;
Jpeg2000Tile *tile = s->tile + jobnr;
/* inverse MCT transformation */
if (tile->codsty[0].mct)
mct_decode(s, tile);
+ return 0;
+}
+
+static int jpeg2000_write_frame(AVCodecContext *avctx, void *td,
+ int jobnr, int threadnr)
+{
+ Jpeg2000DecoderContext *s = avctx->priv_data;
+ AVFrame *picture = td;
+ Jpeg2000Tile *tile = s->tile + jobnr / s->ncomponents;
+ int compno = jobnr % s->ncomponents;
+
if (s->precision <= 8) {
- write_frame_8(s, tile, picture, 8);
+ write_frame_8(s, tile, picture, 8, compno);
} else {
int precision = picture->format == AV_PIX_FMT_XYZ12 ||
picture->format == AV_PIX_FMT_RGB48 ||
picture->format == AV_PIX_FMT_RGBA64 ||
picture->format == AV_PIX_FMT_GRAY16 ? 16 : s->precision;
- write_frame_16(s, tile, picture, precision);
+ write_frame_16(s, tile, picture, precision, compno);
}
return 0;
@@ -2695,7 +2705,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture,
if (s->have_dwt97_int)
avctx->execute2(avctx, jpeg2000_dwt97_int_postshift, NULL, NULL, s->numXtiles * s->numYtiles * s->ncomponents * s->slices);
- avctx->execute2(avctx, jpeg2000_mct_write_frame, picture, NULL, s->numXtiles * s->numYtiles);
+ if (s->have_mct)
+ avctx->execute2(avctx, jpeg2000_mct, NULL, NULL, s->numXtiles * s->numYtiles);
+
+ avctx->execute2(avctx, jpeg2000_write_frame, picture, NULL, s->numXtiles * s->numYtiles * s->ncomponents);
jpeg2000_dec_cleanup(s, 0);
--
2.30.2
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-06-14 14:47 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-14 14:39 [FFmpeg-devel] [PATCH 01/13] lavc/jpeg2000dec: Finer granularity threading Tomas Härdin
2022-06-14 14:39 ` [FFmpeg-devel] [PATCH 02/13] lavc/jpeg2000dec: Reindent Tomas Härdin
2022-06-14 14:40 ` [FFmpeg-devel] [PATCH 03/13] lavc/jpeg2000dwt: Implement sliced transforms Tomas Härdin
2022-06-14 14:40 ` [FFmpeg-devel] [PATCH 04/13] lavc/jpeg2000dec: Implement IDWT slicing Tomas Härdin
2022-06-14 14:41 ` [FFmpeg-devel] [PATCH 05/13] lavc/jpeg2000dec: Thread init_tile() Tomas Härdin
2022-06-14 21:11 ` Michael Niedermayer
2022-06-15 13:11 ` Tomas Härdin
2022-06-15 21:05 ` Michael Niedermayer
2022-06-16 9:28 ` Tomas Härdin
2022-06-14 14:42 ` [FFmpeg-devel] [PATCH 06/13] lavu/mem: Add ff_fast_recalloc() Tomas Härdin
2022-06-14 20:26 ` Michael Niedermayer
2022-06-15 9:59 ` Tomas Härdin
2022-06-15 12:15 ` James Almer
2022-06-16 12:44 ` Tomas Härdin
2022-06-18 14:57 ` Anton Khirnov
2022-06-21 8:04 ` Tomas Härdin
2022-06-14 14:42 ` [FFmpeg-devel] [PATCH 07/13] lavc/jpeg2000*: Use ff_fast_recalloc() to eliminate lots of allocations Tomas Härdin
2022-06-14 15:23 ` Andreas Rheinhardt
2022-06-15 10:03 ` Tomas Härdin
2022-06-14 14:43 ` [FFmpeg-devel] [PATCH 08/13] lavc/jpeg2000: Switch Jpeg2000TgtNode to int32_t parent Tomas Härdin
2022-06-14 14:43 ` [FFmpeg-devel] [PATCH 09/13] lavc/jpeg2000: Speed up ff_jpeg2000_tag_tree_init() using stereotypes for sizes <= 4x4 Tomas Härdin
2022-06-18 15:00 ` Anton Khirnov
2022-06-21 7:57 ` Tomas Härdin
2022-06-14 14:43 ` [FFmpeg-devel] [PATCH 10/13] lavc/jpeg2000: Reindent Tomas Härdin
2022-06-14 14:44 ` [FFmpeg-devel] [PATCH 11/13] lavc/jpeg2000: Minimize calls to av_codec_is_encoder() Tomas Härdin
2022-06-14 15:04 ` Andreas Rheinhardt
2022-06-15 10:20 ` Tomas Härdin
2022-06-14 14:44 ` [FFmpeg-devel] [PATCH 12/13] lavc/jpeg2000dec: Use coarser slicing for initial reslevels Tomas Härdin
2022-06-14 14:47 ` Tomas Härdin [this message]
2022-06-18 14:50 ` [FFmpeg-devel] [PATCH 01/13] lavc/jpeg2000dec: Finer granularity threading Anton Khirnov
2022-06-24 8:19 ` Tomas Härdin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b9cfcb8fe330310e5d7558d67d424d626fe6719.camel@acc.umu.se \
--to=tjoppen@acc.umu.se \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git