From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 08/11] avcodec/j2kenc: Planar RGB support
Date: Thu, 30 Mar 2023 20:01:03 +0200
Message-ID: <20230330180106.11275-8-michael@niedermayer.cc> (raw)
In-Reply-To: <20230330180106.11275-1-michael@niedermayer.cc>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavcodec/j2kenc.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 8d9c1fdb1c0..0715d424a15 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -115,6 +115,7 @@ typedef struct {
int width, height; ///< image width and height
uint8_t cbps[4]; ///< bits per sample in particular components
+ uint8_t comp_remap[4];
int chroma_shift[2];
uint8_t planar;
int ncomponents;
@@ -512,17 +513,18 @@ static int init_tiles(Jpeg2000EncoderContext *s)
Jpeg2000Tile *tile = s->tile + tileno; \
if (s->planar){ \
for (compno = 0; compno < s->ncomponents; compno++){ \
+ int icompno = s->comp_remap[compno]; \
Jpeg2000Component *comp = tile->comp + compno; \
int *dst = comp->i_data; \
int cbps = s->cbps[compno]; \
- line = (const PIXEL*)s->picture->data[compno] \
- + comp->coord[1][0] * (s->picture->linesize[compno] / sizeof(PIXEL)) \
+ line = (const PIXEL*)s->picture->data[icompno] \
+ + comp->coord[1][0] * (s->picture->linesize[icompno] / sizeof(PIXEL)) \
+ comp->coord[0][0]; \
for (y = comp->coord[1][0]; y < comp->coord[1][1]; y++){ \
const PIXEL *ptr = line; \
for (x = comp->coord[0][0]; x < comp->coord[0][1]; x++) \
*dst++ = *ptr++ - (1 << (cbps - 1)); \
- line += s->picture->linesize[compno] / sizeof(PIXEL); \
+ line += s->picture->linesize[icompno] / sizeof(PIXEL); \
} \
} \
} else{ \
@@ -1763,6 +1765,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
s->ncomponents = desc->nb_components;
for (i = 0; i < 3; i++) {
s->cbps[i] = desc->comp[i].depth;
+ s->comp_remap[i] = i; //default
}
if ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && s->ncomponents > 1) {
@@ -1771,6 +1774,11 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
s->chroma_shift, s->chroma_shift + 1);
if (ret)
return ret;
+ if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
+ s->comp_remap[0] = 2;
+ s->comp_remap[1] = 0;
+ s->comp_remap[2] = 1;
+ }
}
ff_thread_once(&init_static_once, init_luts);
--
2.17.1
_______________________________________________
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:[~2023-03-30 18:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
2023-03-30 18:00 ` [FFmpeg-devel] [PATCH 02/11] avcodec/j2kenc: remove misleading pred value Michael Niedermayer
2023-03-30 18:00 ` [FFmpeg-devel] [PATCH 03/11] avcodec/j2kenc: Fix funky bpno errors on decoding Michael Niedermayer
2023-03-30 18:00 ` [FFmpeg-devel] [PATCH 04/11] avcodec/j2kenc: Add AV_PIX_FMT_YUV440P Michael Niedermayer
2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 05/11] avcodec/j2kenc: simplify pixel format setup Michael Niedermayer
2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 06/11] avcodec/j2kenc: Replace BGR48 / GRAY16 test by test for number of bits Michael Niedermayer
2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 07/11] avcodec/j2kenc: Replace RGB24 special case by generic test Michael Niedermayer
2023-03-30 18:01 ` Michael Niedermayer [this message]
2023-03-31 14:19 ` [FFmpeg-devel] [PATCH 08/11] avcodec/j2kenc: Planar RGB support Anton Khirnov
2023-04-02 21:19 ` Michael Niedermayer
2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 09/11] avcodec/j2kenc: More complete list of supported pixel formats Michael Niedermayer
2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 10/11] avcodec/j2kenc: support threads Michael Niedermayer
2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 11/11] Remove libopenjpeg decoder Michael Niedermayer
2023-04-02 21:20 ` [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
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=20230330180106.11275-8-michael@niedermayer.cc \
--to=michael@niedermayer.cc \
--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