From: "Tomas Härdin" <git@haerdin.se>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 09/11] lavc/jpeg2000: Minimize calls to av_codec_is_encoder()
Date: Wed, 28 Sep 2022 12:08:12 +0200
Message-ID: <975acd73022f0784d26f3799605104e344d9f958.camel@haerdin.se> (raw)
In-Reply-To: <65e79fe701374868bb2f4b70ce8fd220938e2e86.camel@haerdin.se>
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0009-lavc-jpeg2000-Minimize-calls-to-av_codec_is_encoder.patch --]
[-- Type: text/x-patch, Size: 4211 bytes --]
From ecb1d9ff671b83bddb0d1c7d31d60ade4b5cdead Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Tue, 14 Jun 2022 10:57:45 +0200
Subject: [PATCH 09/11] lavc/jpeg2000: Minimize calls to av_codec_is_encoder()
---
libavcodec/jpeg2000.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index 2574c2b97e..bb6efab72e 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -248,7 +248,7 @@ static void init_band_stepsize(AVCodecContext *avctx,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int bandno, int gbandno, int reslevelno,
- int cbps)
+ int cbps, int is_enc)
{
/* TODO: Implementation of quantization step not finished,
* see ISO/IEC 15444-1:2002 E.1 and A.6.4. */
@@ -306,7 +306,7 @@ static void init_band_stepsize(AVCodecContext *avctx,
/* FIXME: In OpenJPEG code stepsize = stepsize * 0.5. Why?
* If not set output of entropic decoder is not correct. */
- if (!av_codec_is_encoder(avctx->codec))
+ if (!is_enc)
band->f_stepsize *= 0.5;
}
@@ -317,7 +317,8 @@ static int init_prec(AVCodecContext *avctx,
Jpeg2000CodingStyle *codsty,
int precno, int bandno, int reslevelno,
int log2_band_prec_width,
- int log2_band_prec_height)
+ int log2_band_prec_height,
+ int is_enc)
{
Jpeg2000Prec *prec = band->prec + precno;
int nb_codeblocks, cblkno, ret;
@@ -414,7 +415,7 @@ static int init_prec(AVCodecContext *avctx,
cblk->lblock = 3;
cblk->length = 0;
cblk->npasses = 0;
- if (av_codec_is_encoder(avctx->codec)) {
+ if (is_enc) {
av_freep(&cblk->layers);
cblk->layers = av_calloc(codsty->nlayers, sizeof(*cblk->layers));
if (!cblk->layers)
@@ -431,7 +432,7 @@ static int init_band(AVCodecContext *avctx,
Jpeg2000CodingStyle *codsty,
Jpeg2000QuantStyle *qntsty,
int bandno, int gbandno, int reslevelno,
- int cbps, int dx, int dy)
+ int cbps, int dx, int dy, int is_enc)
{
Jpeg2000Band *band = reslevel->band + bandno;
uint8_t log2_band_prec_width, log2_band_prec_height;
@@ -440,7 +441,7 @@ static int init_band(AVCodecContext *avctx,
int nb_precincts;
int i, j, ret;
- init_band_stepsize(avctx, band, codsty, qntsty, bandno, gbandno, reslevelno, cbps);
+ init_band_stepsize(avctx, band, codsty, qntsty, bandno, gbandno, reslevelno, cbps, is_enc);
/* computation of tbx_0, tbx_1, tby_0, tby_1
* see ISO/IEC 15444-1:2002 B.5 eq. B-15 and tbl B.1
@@ -494,7 +495,8 @@ static int init_band(AVCodecContext *avctx,
for (precno = 0; precno < nb_precincts; precno++) {
ret = init_prec(avctx, band, reslevel, comp, codsty,
precno, bandno, reslevelno,
- log2_band_prec_width, log2_band_prec_height);
+ log2_band_prec_width, log2_band_prec_height,
+ is_enc);
if (ret < 0)
return ret;
}
@@ -511,6 +513,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
int reslevelno, bandno, gbandno = 0, ret, i, j;
uint32_t csize;
size_t prod;
+ int is_enc = av_codec_is_encoder(avctx->codec);
if (codsty->nreslevels2decode <= 0) {
av_log(avctx, AV_LOG_ERROR, "nreslevels2decode %d invalid or uninitialized\n", codsty->nreslevels2decode);
@@ -608,7 +611,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
ret = init_band(avctx, reslevel,
comp, codsty, qntsty,
bandno, gbandno, reslevelno,
- cbps, dx, dy);
+ cbps, dx, dy, is_enc);
if (ret < 0)
return ret;
}
--
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:08 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 ` [FFmpeg-devel] [PATCH 07/11] lavc/jpeg2000: Speed up ff_jpeg2000_tag_tree_init() using stereotypes for sizes <= 4x4 Tomas Härdin
2022-09-28 10:07 ` [FFmpeg-devel] [PATCH 08/11] lavc/jpeg2000: Reindent Tomas Härdin
2022-09-28 10:08 ` Tomas Härdin [this message]
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=975acd73022f0784d26f3799605104e344d9f958.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