Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 05/11] avcodec/j2kenc: simplify pixel format setup
Date: Thu, 30 Mar 2023 20:01:00 +0200
Message-ID: <20230330180106.11275-5-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, 4 insertions(+), 10 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 75bac3c2d84..c3a7a264dc0 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1716,6 +1716,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
     Jpeg2000EncoderContext *s = avctx->priv_data;
     Jpeg2000CodingStyle *codsty = &s->codsty;
     Jpeg2000QuantStyle  *qntsty = &s->qntsty;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
 
     s->avctx = avctx;
     av_log(s->avctx, AV_LOG_DEBUG, "init\n");
@@ -1758,20 +1759,13 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
     s->width = avctx->width;
     s->height = avctx->height;
 
+    s->ncomponents = desc->nb_components;
     for (i = 0; i < 3; i++) {
-        if (avctx->pix_fmt == AV_PIX_FMT_GRAY16 || avctx->pix_fmt == AV_PIX_FMT_RGB48)
-            s->cbps[i] = 16;
-        else
-            s->cbps[i] = 8;
+        s->cbps[i] = desc->comp[i].depth;
     }
 
-    if (avctx->pix_fmt == AV_PIX_FMT_RGB24 || avctx->pix_fmt == AV_PIX_FMT_RGB48){
-        s->ncomponents = 3;
-    } else if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 || avctx->pix_fmt == AV_PIX_FMT_PAL8 || avctx->pix_fmt == AV_PIX_FMT_GRAY16){
-        s->ncomponents = 1;
-    } else{ // planar YUV
+    if ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && s->ncomponents > 1) {
         s->planar = 1;
-        s->ncomponents = 3;
         ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
                                                s->chroma_shift, s->chroma_shift + 1);
         if (ret)
-- 
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".

  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 ` Michael Niedermayer [this message]
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 ` [FFmpeg-devel] [PATCH 08/11] avcodec/j2kenc: Planar RGB support Michael Niedermayer
2023-03-31 14:19   ` 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-5-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