From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 2979045409 for ; Thu, 30 Mar 2023 18:02:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 192AF68C550; Thu, 30 Mar 2023 21:01:31 +0300 (EEST) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1FDC368C504 for ; Thu, 30 Mar 2023 21:01:24 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 3CB3840006 for ; Thu, 30 Mar 2023 18:01:23 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 30 Mar 2023 20:01:03 +0200 Message-Id: <20230330180106.11275-8-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230330180106.11275-1-michael@niedermayer.cc> References: <20230330180106.11275-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 08/11] avcodec/j2kenc: Planar RGB support X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Michael Niedermayer --- 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".