From: "Tomas Härdin" <git@haerdin.se>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 07/11] lavc/jpeg2000: Speed up ff_jpeg2000_tag_tree_init() using stereotypes for sizes <= 4x4
Date: Wed, 28 Sep 2022 12:07:38 +0200
Message-ID: <09bb5c361832325cabe36845a51ebe060a2fc4c8.camel@haerdin.se> (raw)
In-Reply-To: <65e79fe701374868bb2f4b70ce8fd220938e2e86.camel@haerdin.se>
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0007-lavc-jpeg2000-Speed-up-ff_jpeg2000_tag_tree_init-usi.patch --]
[-- Type: text/x-patch, Size: 2598 bytes --]
From a31a6d82b257f51618389a67af18d49cc78ac240 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Wed, 8 Jun 2022 10:08:15 +0200
Subject: [PATCH 07/11] lavc/jpeg2000: Speed up ff_jpeg2000_tag_tree_init()
using stereotypes for sizes <= 4x4
---
libavcodec/jpeg2000.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 4ddb45bf33..203782502c 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -51,6 +51,31 @@ static int32_t tag_tree_size(int w, int h)
return (int32_t)(res + 1);
}
+#define T(x) (x*sizeof(Jpeg2000TgtNode))
+
+static const size_t tt_sizes[16] = {
+ T(1),T(3),T(6),T(7),T(3),T(5),T(9),T(11),T(6),T(9),T(14),T(17),T(7),T(11),T(17),T(21),
+};
+
+static const Jpeg2000TgtNode tt_stereotypes[16][21] = {
+ {{-1},},
+ {{2},{2},{-1},},
+ {{3},{3},{4},{5},{5},{-1},},
+ {{4},{4},{5},{5},{6},{6},{-1},},
+ {{2},{2},{-1},},
+ {{4},{4},{4},{4},{-1},},
+ {{6},{6},{7},{6},{6},{7},{8},{8},{-1},},
+ {{8},{8},{9},{9},{8},{8},{9},{9},{10},{10},{-1},},
+ {{3},{3},{4},{5},{5},{-1},},
+ {{6},{6},{6},{6},{7},{7},{8},{8},{-1},},
+ {{9},{9},{10},{9},{9},{10},{11},{11},{12},{13},{13},{13},{13},{-1},},
+ {{12},{12},{13},{13},{12},{12},{13},{13},{14},{14},{15},{15},{16},{16},{16},{16},{-1},},
+ {{4},{4},{5},{5},{6},{6},{-1},},
+ {{8},{8},{8},{8},{9},{9},{9},{9},{10},{10},{-1},},
+ {{12},{12},{13},{12},{12},{13},{14},{14},{15},{14},{14},{15},{16},{16},{16},{16},{-1},},
+ {{16},{16},{17},{17},{16},{16},{17},{17},{18},{18},{19},{19},{18},{18},{19},{19},{20},{20},{20},{20},{-1},},
+};
+
/* allocate the memory for tag tree */
static int ff_jpeg2000_tag_tree_init(Jpeg2000TgtNode **old, unsigned int *size, int w, int h)
{
@@ -59,6 +84,16 @@ static int ff_jpeg2000_tag_tree_init(Jpeg2000TgtNode **old, unsigned int *size,
int32_t tt_size, ofs = 0;
size_t prod;
+ if (w <= 4 && h <= 4) {
+ int idx = w-1 + (h-1)*4;
+ size_t sz = tt_sizes[idx];
+ av_fast_malloc(old, size, sz);
+ if (*old) {
+ memcpy(*old, tt_stereotypes[idx], sz);
+ return 0;
+ } else
+ return AVERROR(ENOMEM);
+ } else {
tt_size = tag_tree_size(w, h);
if (av_size_mult(tt_size, sizeof(*t), &prod))
@@ -87,6 +122,7 @@ static int ff_jpeg2000_tag_tree_init(Jpeg2000TgtNode **old, unsigned int *size,
}
t[0].parent = -1;
return 0;
+ }
}
void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h, int val)
--
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-09-28 10:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 10:04 [FFmpeg-devel] [PATCH 01/11] lavc/jpeg2000dec: Finer granularity threading Tomas Härdin
2022-09-28 10:05 ` [FFmpeg-devel] [PATCH 02/11] lavc/jpeg2000dec: Reindent Tomas Härdin
2022-09-28 10:05 ` [FFmpeg-devel] [PATCH 03/11] lavc/jpeg2000dwt: Implement sliced transforms Tomas Härdin
2022-09-28 10:06 ` [FFmpeg-devel] [PATCH 04/11] lavc/jpeg2000dec: Thread init_tile() Tomas Härdin
2022-09-28 14:14 ` Tomas Härdin
2022-09-28 10:06 ` [FFmpeg-devel] [PATCH 05/11] lavc/jpeg2000*: Use av_realloc_array_reuse() and av_reallocz_array_reuse() to eliminate lots of allocations Tomas Härdin
2022-09-28 10:07 ` [FFmpeg-devel] [PATCH 06/11] lavc/jpeg2000: Switch Jpeg2000TgtNode to int32_t parent Tomas Härdin
2022-09-28 10:07 ` Tomas Härdin [this message]
2022-09-28 10:07 ` [FFmpeg-devel] [PATCH 08/11] lavc/jpeg2000: Reindent Tomas Härdin
2022-09-28 10:08 ` [FFmpeg-devel] [PATCH 09/11] lavc/jpeg2000: Minimize calls to av_codec_is_encoder() Tomas Härdin
2022-09-28 10:09 ` [FFmpeg-devel] [PATCH 10/11] lavc/jpeg2000dec: Use coarser slicing for initial reslevels Tomas Härdin
2022-09-28 10:10 ` [FFmpeg-devel] [PATCH 11/11] lavc/jpeg2000dec: Component-level threading of write_frame() 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=09bb5c361832325cabe36845a51ebe060a2fc4c8.camel@haerdin.se \
--to=git@haerdin.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