From patchwork Thu Mar 30 18:01:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 40931 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp121150pzb; Thu, 30 Mar 2023 11:02:52 -0700 (PDT) X-Google-Smtp-Source: AKy350aAYDMbnXVT/u0aDWDyJPcedvn7wr7cCRmtkziEQysHgi/cJx7furqo5qlugI6NhIrGTA+v X-Received: by 2002:a17:907:205b:b0:931:cac0:60ec with SMTP id pg27-20020a170907205b00b00931cac060ecmr22930139ejb.48.1680199371829; Thu, 30 Mar 2023 11:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680199371; cv=none; d=google.com; s=arc-20160816; b=y4s86FLYTQ8J9XFGfeLrrPahbMFydmu5bNVQ3YEGom/JAUu6VTFgBPwtoW604iqX+7 Zzy/ZUdaLdyWm9sHxXg+akLogjWSpQeFOntJh+LKyZOgydriom8ofQcnQEbhwcns38W9 VqYlZE5OgtuHqpQ1xWDitzq4+z5224ZGmilTLj8QxRFnPdjugBs4rGr1yOOxJtE3+1w7 NMiScUHaKNTum4G5DywVSQnJDK8kEZh1HOzLHpNh2uw0MLRSeB8oUKuOtvXX8ug4+BWi P+p1AukkWDls8VnH/c3DWZXrGriiC+5Jvag1xxjoKASx5wvNfsMvQnISuSP1jjlYHju4 K70g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=iGvc90cCKrXmcB07/zz9be/GzVHBB1FYlKgeINgcpdo=; b=ODI86zYnuRo3OHhNzLE2Tl4DI5bDwbOWEGiuK6YiiriYyn2XGJzPpSHgbpgu0amhrT 58taICrWWsS9to9kK0knxmw0ztYnt5BpuZfZLRYNHQZFAGPFKvr87HMXZFcees4lavQo vr3ONbwx9Y8aznkgZM1fJq/WT7Kr2Y3GCa0ZBzXDrjWauuATHO4Zydt3fQaLKFj1OwHK OKpZkVy2rnnS1x1D0W0QPOC+/cBMiUnu1eaZuMDp+VnqBewVEX9mIgrx8Ms8xhxx3cYC XuYXTbsxNoyvhWMwG04eH2gBokXFjpbmRSDtzx5UZ8JxOii0Zqfsli05e0TSzTCyxCN1 oiVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l6-20020a1709060e0600b0094495cc0dcfsi195568eji.70.2023.03.30.11.02.44; Thu, 30 Mar 2023 11:02:51 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4AB7468C413; Thu, 30 Mar 2023 21:01:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: x757aPsJquEe 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);