Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer
@ 2023-03-30 18:00 Michael Niedermayer
  2023-03-30 18:00 ` [FFmpeg-devel] [PATCH 02/11] avcodec/j2kenc: remove misleading pred value Michael Niedermayer
                   ` (10 more replies)
  0 siblings, 11 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/j2kenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 6406f90ac2c..821967f9e43 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1810,7 +1810,7 @@ static const AVOption options[] = {
     { "tile_height",   "Tile Height",       OFFSET(tile_height),   AV_OPT_TYPE_INT,   { .i64 = 256         }, 1,     1<<30,           VE, },
     { "pred",          "DWT Type",          OFFSET(pred),          AV_OPT_TYPE_INT,   { .i64 = 0           }, 0,         1,           VE, "pred"        },
     { "dwt97int",      NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = 0           }, INT_MIN, INT_MAX,       VE, "pred"        },
-    { "dwt53",         NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = 0           }, INT_MIN, INT_MAX,       VE, "pred"        },
+    { "dwt53",         NULL,                0,                     AV_OPT_TYPE_CONST, { .i64 = 1           }, INT_MIN, INT_MAX,       VE, "pred"        },
     { "sop",           "SOP marker",        OFFSET(sop),           AV_OPT_TYPE_INT,   { .i64 = 0           }, 0,         1,           VE, },
     { "eph",           "EPH marker",        OFFSET(eph),           AV_OPT_TYPE_INT,   { .i64 = 0           }, 0,         1,           VE, },
     { "prog",          "Progression Order", OFFSET(prog),          AV_OPT_TYPE_INT,   { .i64 = 0           }, JPEG2000_PGOD_LRCP,         JPEG2000_PGOD_CPRL,           VE, "prog" },
-- 
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 02/11] avcodec/j2kenc: remove misleading pred value
  2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
@ 2023-03-30 18:00 ` Michael Niedermayer
  2023-03-30 18:00 ` [FFmpeg-devel] [PATCH 03/11] avcodec/j2kenc: Fix funky bpno errors on decoding Michael Niedermayer
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

This field is only checked for being 0 or not and not zero means 5/3

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/j2kenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 821967f9e43..0e23a8a8399 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1729,7 +1729,7 @@ static av_cold int j2kenc_init(AVCodecContext *avctx)
 
     if (avctx->pix_fmt == AV_PIX_FMT_PAL8 && (s->pred != FF_DWT97_INT || s->format != CODEC_JP2)) {
         av_log(s->avctx, AV_LOG_WARNING, "Forcing lossless jp2 for pal8\n");
-        s->pred = FF_DWT97_INT;
+        s->pred = 1;
         s->format = CODEC_JP2;
     }
 
-- 
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 03/11] avcodec/j2kenc: Fix funky bpno errors on decoding
  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 ` Michael Niedermayer
  2023-03-30 18:00 ` [FFmpeg-devel] [PATCH 04/11] avcodec/j2kenc: Add AV_PIX_FMT_YUV440P Michael Niedermayer
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/j2kenc.c                      | 3 +--
 tests/ref/vsynth/vsynth1-jpeg2000-97     | 4 ++--
 tests/ref/vsynth/vsynth2-jpeg2000        | 4 ++--
 tests/ref/vsynth/vsynth2-jpeg2000-97     | 4 ++--
 tests/ref/vsynth/vsynth3-jpeg2000        | 4 ++--
 tests/ref/vsynth/vsynth3-jpeg2000-97     | 4 ++--
 tests/ref/vsynth/vsynth_lena-jpeg2000    | 4 ++--
 tests/ref/vsynth/vsynth_lena-jpeg2000-97 | 4 ++--
 8 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 0e23a8a8399..236c720dfed 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -721,11 +721,10 @@ static void encode_cblk(Jpeg2000EncoderContext *s, Jpeg2000T1Context *t1, Jpeg20
 
     if (max == 0){
         cblk->nonzerobits = 0;
-        bpno = 0;
     } else{
         cblk->nonzerobits = av_log2(max) + 1 - NMSEDEC_FRACBITS;
-        bpno = cblk->nonzerobits - 1;
     }
+    bpno = cblk->nonzerobits - 1;
 
     cblk->data[0] = 0;
     ff_mqc_initenc(&t1->mqc, cblk->data + 1);
diff --git a/tests/ref/vsynth/vsynth1-jpeg2000-97 b/tests/ref/vsynth/vsynth1-jpeg2000-97
index 6ab5aa4237c..c979ab5c364 100644
--- a/tests/ref/vsynth/vsynth1-jpeg2000-97
+++ b/tests/ref/vsynth/vsynth1-jpeg2000-97
@@ -1,4 +1,4 @@
-e4d03b2e3c03e56c7f831b1e662c4031 *tests/data/fate/vsynth1-jpeg2000-97.avi
-3643928 tests/data/fate/vsynth1-jpeg2000-97.avi
+5e6d32b7205d31245b0d1f015d08b515 *tests/data/fate/vsynth1-jpeg2000-97.avi
+3643886 tests/data/fate/vsynth1-jpeg2000-97.avi
 a2262f1da2f49bc196b780a6b47ec4e8 *tests/data/fate/vsynth1-jpeg2000-97.out.rawvideo
 stddev:    4.23 PSNR: 35.59 MAXDIFF:   53 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-jpeg2000 b/tests/ref/vsynth/vsynth2-jpeg2000
index d0df0099ea0..b60307d5da6 100644
--- a/tests/ref/vsynth/vsynth2-jpeg2000
+++ b/tests/ref/vsynth/vsynth2-jpeg2000
@@ -1,4 +1,4 @@
-8c8a68ca748190c71b3ea43e5ab7f502 *tests/data/fate/vsynth2-jpeg2000.avi
-1538736 tests/data/fate/vsynth2-jpeg2000.avi
+bfe90391779a02319aab98b06dd18e6c *tests/data/fate/vsynth2-jpeg2000.avi
+1538724 tests/data/fate/vsynth2-jpeg2000.avi
 64fadc87447268cf90503cb294db7f61 *tests/data/fate/vsynth2-jpeg2000.out.rawvideo
 stddev:    4.91 PSNR: 34.29 MAXDIFF:   55 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth2-jpeg2000-97 b/tests/ref/vsynth/vsynth2-jpeg2000-97
index 33c1fb2425d..591f8b6bb32 100644
--- a/tests/ref/vsynth/vsynth2-jpeg2000-97
+++ b/tests/ref/vsynth/vsynth2-jpeg2000-97
@@ -1,4 +1,4 @@
-c8f76055f59804ca72dbd66eb4db83a2 *tests/data/fate/vsynth2-jpeg2000-97.avi
-2464138 tests/data/fate/vsynth2-jpeg2000-97.avi
+aa5573136c54b1855d8d00efe2a149bd *tests/data/fate/vsynth2-jpeg2000-97.avi
+2464134 tests/data/fate/vsynth2-jpeg2000-97.avi
 1f63c8b065e847e4c63d57ce23442ea8 *tests/data/fate/vsynth2-jpeg2000-97.out.rawvideo
 stddev:    3.21 PSNR: 37.99 MAXDIFF:   26 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth3-jpeg2000 b/tests/ref/vsynth/vsynth3-jpeg2000
index ecc286b9a46..894dba27dc5 100644
--- a/tests/ref/vsynth/vsynth3-jpeg2000
+++ b/tests/ref/vsynth/vsynth3-jpeg2000
@@ -1,4 +1,4 @@
-776bf3234cbf25002f129b89baab42ea *tests/data/fate/vsynth3-jpeg2000.avi
-67400 tests/data/fate/vsynth3-jpeg2000.avi
+1d039969504abdc143b410f99b5f9171 *tests/data/fate/vsynth3-jpeg2000.avi
+67354 tests/data/fate/vsynth3-jpeg2000.avi
 098f5980667e1fcd50452b1dc1a74f61 *tests/data/fate/vsynth3-jpeg2000.out.rawvideo
 stddev:    5.47 PSNR: 33.36 MAXDIFF:   48 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth3-jpeg2000-97 b/tests/ref/vsynth/vsynth3-jpeg2000-97
index df10f43270c..5d9d0837917 100644
--- a/tests/ref/vsynth/vsynth3-jpeg2000-97
+++ b/tests/ref/vsynth/vsynth3-jpeg2000-97
@@ -1,4 +1,4 @@
-cd023db503f03ef72dd83e4617a90c7b *tests/data/fate/vsynth3-jpeg2000-97.avi
-85606 tests/data/fate/vsynth3-jpeg2000-97.avi
+522e12684aca4262a9d613cb2db7006c *tests/data/fate/vsynth3-jpeg2000-97.avi
+85526 tests/data/fate/vsynth3-jpeg2000-97.avi
 8def36ad1413ab3a5c2af2e1af4603f9 *tests/data/fate/vsynth3-jpeg2000-97.out.rawvideo
 stddev:    4.51 PSNR: 35.04 MAXDIFF:   47 bytes:    86700/    86700
diff --git a/tests/ref/vsynth/vsynth_lena-jpeg2000 b/tests/ref/vsynth/vsynth_lena-jpeg2000
index 88629add21a..e2cbc899d35 100644
--- a/tests/ref/vsynth/vsynth_lena-jpeg2000
+++ b/tests/ref/vsynth/vsynth_lena-jpeg2000
@@ -1,4 +1,4 @@
-b8aaa45236f77a2a626791d462fd8ac1 *tests/data/fate/vsynth_lena-jpeg2000.avi
-1188886 tests/data/fate/vsynth_lena-jpeg2000.avi
+51f061731d7fb987ff4e71789785225e *tests/data/fate/vsynth_lena-jpeg2000.avi
+1188882 tests/data/fate/vsynth_lena-jpeg2000.avi
 39a2c5b61cd0cf2821c6fb4cceba2fa8 *tests/data/fate/vsynth_lena-jpeg2000.out.rawvideo
 stddev:    4.30 PSNR: 35.45 MAXDIFF:   45 bytes:  7603200/  7603200
diff --git a/tests/ref/vsynth/vsynth_lena-jpeg2000-97 b/tests/ref/vsynth/vsynth_lena-jpeg2000-97
index b6f5f75f77a..05393001859 100644
--- a/tests/ref/vsynth/vsynth_lena-jpeg2000-97
+++ b/tests/ref/vsynth/vsynth_lena-jpeg2000-97
@@ -1,4 +1,4 @@
-b2d9525433c6300674f504922d762437 *tests/data/fate/vsynth_lena-jpeg2000-97.avi
-1937232 tests/data/fate/vsynth_lena-jpeg2000-97.avi
+80fe872c8afaad914da6ef037957d93b *tests/data/fate/vsynth_lena-jpeg2000-97.avi
+1937216 tests/data/fate/vsynth_lena-jpeg2000-97.avi
 1b97333a8dc115a5ba609b0070d89d4d *tests/data/fate/vsynth_lena-jpeg2000-97.out.rawvideo
 stddev:    2.82 PSNR: 39.10 MAXDIFF:   24 bytes:  7603200/  7603200
-- 
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 04/11] avcodec/j2kenc: Add AV_PIX_FMT_YUV440P
  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 ` Michael Niedermayer
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 05/11] avcodec/j2kenc: simplify pixel format setup Michael Niedermayer
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/j2kenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 236c720dfed..75bac3c2d84 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1841,7 +1841,7 @@ const FFCodec ff_jpeg2000_encoder = {
     .close          = j2kenc_destroy,
     .p.pix_fmts     = (const enum AVPixelFormat[]) {
         AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV444P, AV_PIX_FMT_GRAY8,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
+        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV440P,
         AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
         AV_PIX_FMT_PAL8,
         AV_PIX_FMT_RGB48, AV_PIX_FMT_GRAY16,
-- 
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 05/11] avcodec/j2kenc: simplify pixel format setup
  2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
                   ` (2 preceding siblings ...)
  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
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 06/11] avcodec/j2kenc: Replace BGR48 / GRAY16 test by test for number of bits Michael Niedermayer
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 06/11] avcodec/j2kenc: Replace BGR48 / GRAY16 test by test for number of bits
  2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
                   ` (3 preceding siblings ...)
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 05/11] avcodec/j2kenc: simplify pixel format setup Michael Niedermayer
@ 2023-03-30 18:01 ` Michael Niedermayer
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 07/11] avcodec/j2kenc: Replace RGB24 special case by generic test Michael Niedermayer
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

BGR48 is not supported and this was probably meant to be RGB48 so this fixes
RGB48 a bit

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/j2kenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index c3a7a264dc0..d837b8b949e 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1542,7 +1542,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     s->lambda = s->picture->quality * LAMBDA_SCALE;
 
-    if (avctx->pix_fmt == AV_PIX_FMT_BGR48 || avctx->pix_fmt == AV_PIX_FMT_GRAY16)
+    if (s->cbps[0] > 8)
         copy_frame_16(s);
     else
         copy_frame_8(s);
-- 
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 07/11] avcodec/j2kenc: Replace RGB24 special case by generic test
  2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
                   ` (4 preceding siblings ...)
  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 ` Michael Niedermayer
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 08/11] avcodec/j2kenc: Planar RGB support Michael Niedermayer
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

This fixes RGB48 with libavcodec as decoder

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/j2kenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index d837b8b949e..8d9c1fdb1c0 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1530,6 +1530,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     int tileno, ret;
     Jpeg2000EncoderContext *s = avctx->priv_data;
     uint8_t *chunkstart, *jp2cstart, *jp2hstart;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
 
     if ((ret = ff_alloc_packet(avctx, pkt, avctx->width*avctx->height*9 + AV_INPUT_BUFFER_MIN_SIZE)) < 0)
         return ret;
@@ -1586,7 +1587,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         bytestream_put_byte(&s->buf, 1);
         bytestream_put_byte(&s->buf, 0);
         bytestream_put_byte(&s->buf, 0);
-        if (avctx->pix_fmt == AV_PIX_FMT_RGB24 || avctx->pix_fmt == AV_PIX_FMT_PAL8) {
+        if ((desc->flags & AV_PIX_FMT_FLAG_RGB) || avctx->pix_fmt == AV_PIX_FMT_PAL8) {
             bytestream_put_be32(&s->buf, 16);
         } else if (s->ncomponents == 1) {
             bytestream_put_be32(&s->buf, 17);
-- 
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 08/11] avcodec/j2kenc: Planar RGB support
  2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
                   ` (5 preceding siblings ...)
  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
  2023-03-31 14:19   ` Anton Khirnov
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 09/11] avcodec/j2kenc: More complete list of supported pixel formats Michael Niedermayer
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 09/11] avcodec/j2kenc: More complete list of supported pixel formats
  2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
                   ` (6 preceding siblings ...)
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 08/11] avcodec/j2kenc: Planar RGB support Michael Niedermayer
@ 2023-03-30 18:01 ` Michael Niedermayer
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 10/11] avcodec/j2kenc: support threads Michael Niedermayer
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/j2kenc.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 0715d424a15..b4ecc010ca7 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1843,11 +1843,16 @@ const FFCodec ff_jpeg2000_encoder = {
     FF_CODEC_ENCODE_CB(encode_frame),
     .close          = j2kenc_destroy,
     .p.pix_fmts     = (const enum AVPixelFormat[]) {
-        AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV444P, AV_PIX_FMT_GRAY8,
-        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV440P,
-        AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
+        AV_PIX_FMT_RGB24, AV_PIX_FMT_RGB48,
+        AV_PIX_FMT_GBR24P,AV_PIX_FMT_GBRP9, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, AV_PIX_FMT_GBRP16,
+        AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,
+        AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV420P16,
+        AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV422P16,
+        AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14, AV_PIX_FMT_YUV444P16,
+        AV_PIX_FMT_YUV440P,
+        AV_PIX_FMT_YUV411P,
+        AV_PIX_FMT_YUV410P,
         AV_PIX_FMT_PAL8,
-        AV_PIX_FMT_RGB48, AV_PIX_FMT_GRAY16,
         AV_PIX_FMT_NONE
     },
     .p.priv_class   = &j2k_class,
-- 
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 10/11] avcodec/j2kenc: support threads
  2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
                   ` (7 preceding siblings ...)
  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 ` 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
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/j2kenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index b4ecc010ca7..8475d140daf 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -1837,7 +1837,8 @@ const FFCodec ff_jpeg2000_encoder = {
     CODEC_LONG_NAME("JPEG 2000"),
     .p.type         = AVMEDIA_TYPE_VIDEO,
     .p.id           = AV_CODEC_ID_JPEG2000,
-    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
+    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE |
+                      AV_CODEC_CAP_FRAME_THREADS,
     .priv_data_size = sizeof(Jpeg2000EncoderContext),
     .init           = j2kenc_init,
     FF_CODEC_ENCODE_CB(encode_frame),
-- 
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [FFmpeg-devel] [PATCH 11/11] Remove libopenjpeg decoder
  2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
                   ` (8 preceding siblings ...)
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 10/11] avcodec/j2kenc: support threads Michael Niedermayer
@ 2023-03-30 18:01 ` Michael Niedermayer
  2023-04-02 21:20 ` [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-03-30 18:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

We do not support other video/image decoders when we have our own.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 configure                   |   1 -
 libavcodec/Makefile         |   1 -
 libavcodec/allcodecs.c      |   1 -
 libavcodec/libopenjpegdec.c | 516 ------------------------------------
 4 files changed, 519 deletions(-)
 delete mode 100644 libavcodec/libopenjpegdec.c

diff --git a/configure b/configure
index fe367462a10..aa72aaef6b0 100755
--- a/configure
+++ b/configure
@@ -3364,7 +3364,6 @@ libopencore_amrwb_decoder_deps="libopencore_amrwb"
 libopenh264_decoder_deps="libopenh264"
 libopenh264_decoder_select="h264_mp4toannexb_bsf"
 libopenh264_encoder_deps="libopenh264"
-libopenjpeg_decoder_deps="libopenjpeg"
 libopenjpeg_encoder_deps="libopenjpeg"
 libopenmpt_demuxer_deps="libopenmpt"
 libopus_decoder_deps="libopus"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 711d2690d0b..b30747fdb99 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1102,7 +1102,6 @@ OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER)  += libopencore-amr.o
 OBJS-$(CONFIG_LIBOPENCORE_AMRWB_DECODER)  += libopencore-amr.o
 OBJS-$(CONFIG_LIBOPENH264_DECODER)        += libopenh264dec.o libopenh264.o
 OBJS-$(CONFIG_LIBOPENH264_ENCODER)        += libopenh264enc.o libopenh264.o
-OBJS-$(CONFIG_LIBOPENJPEG_DECODER)        += libopenjpegdec.o
 OBJS-$(CONFIG_LIBOPENJPEG_ENCODER)        += libopenjpegenc.o
 OBJS-$(CONFIG_LIBOPUS_DECODER)            += libopusdec.o libopus.o     \
                                              vorbis_data.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 3cbb93347b4..aabfa9be50f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -782,7 +782,6 @@ extern const FFCodec ff_libopencore_amrnb_encoder;
 extern const FFCodec ff_libopencore_amrnb_decoder;
 extern const FFCodec ff_libopencore_amrwb_decoder;
 extern const FFCodec ff_libopenjpeg_encoder;
-extern const FFCodec ff_libopenjpeg_decoder;
 extern const FFCodec ff_libopus_encoder;
 extern const FFCodec ff_libopus_decoder;
 extern const FFCodec ff_librav1e_encoder;
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
deleted file mode 100644
index 206db07ec70..00000000000
--- a/libavcodec/libopenjpegdec.c
+++ /dev/null
@@ -1,516 +0,0 @@
-/*
- * JPEG 2000 decoding support via OpenJPEG
- * Copyright (c) 2009 Jaikrishnan Menon <realityman@gmx.net>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/**
- * @file
- * JPEG 2000 decoder using libopenjpeg
- */
-
-#include "libavutil/common.h"
-#include "libavutil/imgutils.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/opt.h"
-#include "libavutil/pixfmt.h"
-
-#include "avcodec.h"
-#include "codec_internal.h"
-#include "decode.h"
-#include "thread.h"
-
-#include <openjpeg.h>
-
-#define JP2_SIG_TYPE    0x6A502020
-#define JP2_SIG_VALUE   0x0D0A870A
-
-// pix_fmts with lower bpp have to be listed before
-// similar pix_fmts with higher bpp.
-#define RGB_PIXEL_FORMATS  AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA,                 \
-                           AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64
-
-#define GRAY_PIXEL_FORMATS AV_PIX_FMT_GRAY8, AV_PIX_FMT_YA8,                  \
-                           AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, \
-                           AV_PIX_FMT_GRAY16, AV_PIX_FMT_YA16
-
-#define YUV_PIXEL_FORMATS  AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUVA420P, \
-                           AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA422P, \
-                           AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVA444P, \
-                           AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9, \
-                           AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9, \
-                           AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, \
-                           AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10, \
-                           AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, \
-                           AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, \
-                           AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, \
-                           AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16
-
-#define XYZ_PIXEL_FORMATS  AV_PIX_FMT_XYZ12
-
-static const enum AVPixelFormat libopenjpeg_rgb_pix_fmts[]  = {
-    RGB_PIXEL_FORMATS
-};
-static const enum AVPixelFormat libopenjpeg_gray_pix_fmts[] = {
-    GRAY_PIXEL_FORMATS
-};
-static const enum AVPixelFormat libopenjpeg_yuv_pix_fmts[]  = {
-    YUV_PIXEL_FORMATS
-};
-static const enum AVPixelFormat libopenjpeg_all_pix_fmts[]  = {
-    RGB_PIXEL_FORMATS, GRAY_PIXEL_FORMATS, YUV_PIXEL_FORMATS, XYZ_PIXEL_FORMATS
-};
-
-typedef struct LibOpenJPEGContext {
-    AVClass *class;
-    opj_dparameters_t dec_params;
-    int lowqual;
-} LibOpenJPEGContext;
-
-static void error_callback(const char *msg, void *data)
-{
-    av_log(data, AV_LOG_ERROR, "%s", msg);
-}
-
-static void warning_callback(const char *msg, void *data)
-{
-    av_log(data, AV_LOG_WARNING, "%s", msg);
-}
-
-static void info_callback(const char *msg, void *data)
-{
-    av_log(data, AV_LOG_DEBUG, "%s", msg);
-}
-
-typedef struct BufferReader {
-    int pos;
-    int size;
-    const uint8_t *buffer;
-} BufferReader;
-
-static OPJ_SIZE_T stream_read(void *out_buffer, OPJ_SIZE_T nb_bytes, void *user_data)
-{
-    BufferReader *reader = user_data;
-    int remaining;
-
-    if (reader->pos == reader->size) {
-        return (OPJ_SIZE_T)-1;
-    }
-    remaining = reader->size - reader->pos;
-    if (nb_bytes > remaining) {
-        nb_bytes = remaining;
-    }
-    memcpy(out_buffer, reader->buffer + reader->pos, nb_bytes);
-    reader->pos += (int)nb_bytes;
-    return nb_bytes;
-}
-
-static OPJ_OFF_T stream_skip(OPJ_OFF_T nb_bytes, void *user_data)
-{
-    BufferReader *reader = user_data;
-    if (nb_bytes < 0) {
-        if (reader->pos == 0) {
-            return (OPJ_SIZE_T)-1;
-        }
-        if (nb_bytes + reader->pos < 0) {
-            nb_bytes = -reader->pos;
-        }
-    } else {
-        int remaining;
-
-        if (reader->pos == reader->size) {
-            return (OPJ_SIZE_T)-1;
-        }
-        remaining = reader->size - reader->pos;
-        if (nb_bytes > remaining) {
-            nb_bytes = remaining;
-        }
-    }
-    reader->pos += (int)nb_bytes;
-    return nb_bytes;
-}
-
-static OPJ_BOOL stream_seek(OPJ_OFF_T nb_bytes, void *user_data)
-{
-    BufferReader *reader = user_data;
-    if (nb_bytes < 0 || nb_bytes > reader->size) {
-        return OPJ_FALSE;
-    }
-    reader->pos = (int)nb_bytes;
-    return OPJ_TRUE;
-}
-
-static inline int libopenjpeg_matches_pix_fmt(const opj_image_t *image, enum AVPixelFormat pix_fmt)
-{
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
-    int match = 1;
-
-    if (desc->nb_components != image->numcomps) {
-        return 0;
-    }
-
-    switch (desc->nb_components) {
-    case 4:
-        match = match &&
-                desc->comp[3].depth >= image->comps[3].prec &&
-                1 == image->comps[3].dx &&
-                1 == image->comps[3].dy;
-    case 3:
-        match = match &&
-                desc->comp[2].depth >= image->comps[2].prec &&
-                1 << desc->log2_chroma_w == image->comps[2].dx &&
-                1 << desc->log2_chroma_h == image->comps[2].dy;
-    case 2:
-        match = match &&
-                desc->comp[1].depth >= image->comps[1].prec &&
-                1 << desc->log2_chroma_w == image->comps[1].dx &&
-                1 << desc->log2_chroma_h == image->comps[1].dy;
-    case 1:
-        match = match &&
-                desc->comp[0].depth >= image->comps[0].prec &&
-                1 == image->comps[0].dx &&
-                1 == image->comps[0].dy;
-    default:
-        break;
-    }
-
-    return match;
-}
-
-static inline enum AVPixelFormat libopenjpeg_guess_pix_fmt(const opj_image_t *image) {
-    int index;
-    const enum AVPixelFormat *possible_fmts = NULL;
-    int possible_fmts_nb = 0;
-
-    switch (image->color_space) {
-    case OPJ_CLRSPC_SRGB:
-        possible_fmts    = libopenjpeg_rgb_pix_fmts;
-        possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_rgb_pix_fmts);
-        break;
-    case OPJ_CLRSPC_GRAY:
-        possible_fmts    = libopenjpeg_gray_pix_fmts;
-        possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_gray_pix_fmts);
-        break;
-    case OPJ_CLRSPC_SYCC:
-        possible_fmts    = libopenjpeg_yuv_pix_fmts;
-        possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_yuv_pix_fmts);
-        break;
-    default:
-        possible_fmts    = libopenjpeg_all_pix_fmts;
-        possible_fmts_nb = FF_ARRAY_ELEMS(libopenjpeg_all_pix_fmts);
-        break;
-    }
-
-    for (index = 0; index < possible_fmts_nb; ++index)
-        if (libopenjpeg_matches_pix_fmt(image, possible_fmts[index])) {
-            return possible_fmts[index];
-        }
-
-    return AV_PIX_FMT_NONE;
-}
-
-static inline int libopenjpeg_ispacked(enum AVPixelFormat pix_fmt)
-{
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
-    int i, component_plane;
-
-    if (pix_fmt == AV_PIX_FMT_GRAY16)
-        return 0;
-
-    component_plane = desc->comp[0].plane;
-    for (i = 1; i < desc->nb_components; i++)
-        if (component_plane != desc->comp[i].plane)
-            return 0;
-    return 1;
-}
-
-static inline void libopenjpeg_copy_to_packed8(AVFrame *picture, opj_image_t *image) {
-    uint8_t *img_ptr;
-    int index, x, y, c;
-    for (y = 0; y < picture->height; y++) {
-        index   = y * picture->width;
-        img_ptr = picture->data[0] + y * picture->linesize[0];
-        for (x = 0; x < picture->width; x++, index++)
-            for (c = 0; c < image->numcomps; c++)
-                *img_ptr++ = 0x80 * image->comps[c].sgnd + image->comps[c].data[index];
-    }
-}
-
-static inline void libopenjpeg_copy_to_packed16(AVFrame *picture, opj_image_t *image) {
-    uint16_t *img_ptr;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(picture->format);
-    int index, x, y, c;
-    int adjust[4];
-    for (x = 0; x < image->numcomps; x++)
-        adjust[x] = FFMAX(FFMIN(desc->comp[x].depth - image->comps[x].prec, 8), 0) + desc->comp[x].shift;
-
-    for (y = 0; y < picture->height; y++) {
-        index   = y * picture->width;
-        img_ptr = (uint16_t *) (picture->data[0] + y * picture->linesize[0]);
-        for (x = 0; x < picture->width; x++, index++)
-            for (c = 0; c < image->numcomps; c++)
-                *img_ptr++ = (1 << image->comps[c].prec - 1) * image->comps[c].sgnd +
-                             (unsigned)image->comps[c].data[index] << adjust[c];
-    }
-}
-
-static inline void libopenjpeg_copyto8(AVFrame *picture, opj_image_t *image) {
-    int *comp_data;
-    uint8_t *img_ptr;
-    int index, x, y;
-
-    for (index = 0; index < image->numcomps; index++) {
-        comp_data = image->comps[index].data;
-        for (y = 0; y < image->comps[index].h; y++) {
-            img_ptr = picture->data[index] + y * picture->linesize[index];
-            for (x = 0; x < image->comps[index].w; x++) {
-                *img_ptr = 0x80 * image->comps[index].sgnd + *comp_data;
-                img_ptr++;
-                comp_data++;
-            }
-        }
-    }
-}
-
-static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {
-    int *comp_data;
-    uint16_t *img_ptr;
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(picture->format);
-    int index, x, y;
-    int adjust[4];
-    for (x = 0; x < image->numcomps; x++)
-        adjust[x] = FFMAX(FFMIN(desc->comp[x].depth - image->comps[x].prec, 8), 0) + desc->comp[x].shift;
-
-    for (index = 0; index < image->numcomps; index++) {
-        comp_data = image->comps[index].data;
-        for (y = 0; y < image->comps[index].h; y++) {
-            img_ptr = (uint16_t *)(picture->data[index] + y * picture->linesize[index]);
-            for (x = 0; x < image->comps[index].w; x++) {
-                *img_ptr = (1 << image->comps[index].prec - 1) * image->comps[index].sgnd +
-                           (unsigned)*comp_data << adjust[index];
-                img_ptr++;
-                comp_data++;
-            }
-        }
-    }
-}
-
-static av_cold int libopenjpeg_decode_init(AVCodecContext *avctx)
-{
-    LibOpenJPEGContext *ctx = avctx->priv_data;
-
-    opj_set_default_decoder_parameters(&ctx->dec_params);
-    return 0;
-}
-
-static int libopenjpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture,
-                                    int *got_frame, AVPacket *avpkt)
-{
-    const uint8_t *buf      = avpkt->data;
-    int buf_size            = avpkt->size;
-    LibOpenJPEGContext *ctx = avctx->priv_data;
-    const AVPixFmtDescriptor *desc;
-    int width, height, ret;
-    int pixel_size = 0;
-    int ispacked   = 0;
-    int i;
-    opj_image_t *image = NULL;
-    BufferReader reader = {0, avpkt->size, avpkt->data};
-    opj_codec_t *dec = NULL;
-    opj_stream_t *stream = NULL;
-
-    *got_frame = 0;
-
-    // Check if input is a raw jpeg2k codestream or in jp2 wrapping
-    if ((AV_RB32(buf) == 12) &&
-        (AV_RB32(buf + 4) == JP2_SIG_TYPE) &&
-        (AV_RB32(buf + 8) == JP2_SIG_VALUE)) {
-        dec = opj_create_decompress(OPJ_CODEC_JP2);
-    } else {
-        /* If the AVPacket contains a jp2c box, then skip to
-         * the starting byte of the codestream. */
-        if (AV_RB32(buf + 4) == AV_RB32("jp2c"))
-            buf += 8;
-        dec = opj_create_decompress(OPJ_CODEC_J2K);
-    }
-
-    if (!dec) {
-        av_log(avctx, AV_LOG_ERROR, "Error initializing decoder.\n");
-        ret = AVERROR_EXTERNAL;
-        goto done;
-    }
-
-    if (!opj_set_error_handler(dec, error_callback, avctx) ||
-        !opj_set_warning_handler(dec, warning_callback, avctx) ||
-        !opj_set_info_handler(dec, info_callback, avctx)) {
-        av_log(avctx, AV_LOG_ERROR, "Error setting decoder handlers.\n");
-        ret = AVERROR_EXTERNAL;
-        goto done;
-    }
-
-    ctx->dec_params.cp_layer = ctx->lowqual;
-    ctx->dec_params.cp_reduce = avctx->lowres;
-
-    // Tie decoder with decoding parameters
-    opj_setup_decoder(dec, &ctx->dec_params);
-
-    stream = opj_stream_default_create(OPJ_STREAM_READ);
-
-    if (!stream) {
-        av_log(avctx, AV_LOG_ERROR,
-               "Codestream could not be opened for reading.\n");
-        ret = AVERROR_EXTERNAL;
-        goto done;
-    }
-
-    opj_stream_set_read_function(stream, stream_read);
-    opj_stream_set_skip_function(stream, stream_skip);
-    opj_stream_set_seek_function(stream, stream_seek);
-    opj_stream_set_user_data(stream, &reader, NULL);
-    opj_stream_set_user_data_length(stream, avpkt->size);
-    // Decode the header only.
-    ret = !opj_read_header(stream, dec, &image);
-
-    if (ret) {
-        av_log(avctx, AV_LOG_ERROR, "Error decoding codestream header.\n");
-        ret = AVERROR_EXTERNAL;
-        goto done;
-    }
-
-    width  = image->x1 - image->x0;
-    height = image->y1 - image->y0;
-
-    ret = ff_set_dimensions(avctx, width, height);
-    if (ret < 0)
-        goto done;
-
-    if (avctx->pix_fmt != AV_PIX_FMT_NONE)
-        if (!libopenjpeg_matches_pix_fmt(image, avctx->pix_fmt))
-            avctx->pix_fmt = AV_PIX_FMT_NONE;
-
-    if (avctx->pix_fmt == AV_PIX_FMT_NONE)
-        avctx->pix_fmt = libopenjpeg_guess_pix_fmt(image);
-
-    if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
-        av_log(avctx, AV_LOG_ERROR, "Unable to determine pixel format.\n");
-        ret = AVERROR_UNKNOWN;
-        goto done;
-    }
-    for (i = 0; i < image->numcomps; i++)
-        if (image->comps[i].prec > avctx->bits_per_raw_sample)
-            avctx->bits_per_raw_sample = image->comps[i].prec;
-
-    if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0)
-        goto done;
-
-    ret = !opj_decode(dec, stream, image);
-
-    if (ret) {
-        av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n");
-        ret = AVERROR_EXTERNAL;
-        goto done;
-    }
-
-    for (i = 0; i < image->numcomps; i++) {
-        if (!image->comps[i].data) {
-            av_log(avctx, AV_LOG_ERROR,
-                   "Image component %d contains no data.\n", i);
-            ret = AVERROR_INVALIDDATA;
-            goto done;
-        }
-    }
-
-    desc       = av_pix_fmt_desc_get(avctx->pix_fmt);
-    pixel_size = desc->comp[0].step;
-    ispacked   = libopenjpeg_ispacked(avctx->pix_fmt);
-
-    switch (pixel_size) {
-    case 1:
-        if (ispacked) {
-            libopenjpeg_copy_to_packed8(picture, image);
-        } else {
-            libopenjpeg_copyto8(picture, image);
-        }
-        break;
-    case 2:
-        if (ispacked) {
-            libopenjpeg_copy_to_packed8(picture, image);
-        } else {
-            libopenjpeg_copyto16(picture, image);
-        }
-        break;
-    case 3:
-    case 4:
-        if (ispacked) {
-            libopenjpeg_copy_to_packed8(picture, image);
-        }
-        break;
-    case 6:
-    case 8:
-        if (ispacked) {
-            libopenjpeg_copy_to_packed16(picture, image);
-        }
-        break;
-    default:
-        avpriv_report_missing_feature(avctx, "Pixel size %d", pixel_size);
-        ret = AVERROR_PATCHWELCOME;
-        goto done;
-    }
-
-    *got_frame = 1;
-    picture->pict_type = AV_PICTURE_TYPE_I;
-    picture->key_frame = 1;
-    ret        = buf_size;
-
-done:
-    opj_image_destroy(image);
-    opj_stream_destroy(stream);
-    opj_destroy_codec(dec);
-    return ret;
-}
-
-#define OFFSET(x) offsetof(LibOpenJPEGContext, x)
-#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
-
-static const AVOption options[] = {
-    { "lowqual", "Limit the number of layers used for decoding",
-        OFFSET(lowqual), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VD },
-    { NULL },
-};
-
-static const AVClass openjpeg_class = {
-    .class_name = "libopenjpeg",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-};
-
-const FFCodec ff_libopenjpeg_decoder = {
-    .p.name         = "libopenjpeg",
-    CODEC_LONG_NAME("OpenJPEG JPEG 2000"),
-    .p.type         = AVMEDIA_TYPE_VIDEO,
-    .p.id           = AV_CODEC_ID_JPEG2000,
-    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
-    .p.max_lowres   = 31,
-    .p.priv_class   = &openjpeg_class,
-    .p.wrapper_name = "libopenjpeg",
-    .caps_internal  = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
-    .priv_data_size = sizeof(LibOpenJPEGContext),
-    .init           = libopenjpeg_decode_init,
-    FF_CODEC_DECODE_CB(libopenjpeg_decode_frame),
-};
-- 
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [FFmpeg-devel] [PATCH 08/11] avcodec/j2kenc: Planar RGB support
  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
  0 siblings, 1 reply; 14+ messages in thread
From: Anton Khirnov @ 2023-03-31 14:19 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Quoting Michael Niedermayer (2023-03-30 20:01:03)
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/j2kenc.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)

Having tests for all these new features would be really nice.

-- 
Anton Khirnov
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [FFmpeg-devel] [PATCH 08/11] avcodec/j2kenc: Planar RGB support
  2023-03-31 14:19   ` Anton Khirnov
@ 2023-04-02 21:19     ` Michael Niedermayer
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-04-02 21:19 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 722 bytes --]

On Fri, Mar 31, 2023 at 04:19:12PM +0200, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2023-03-30 20:01:03)
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/j2kenc.c | 14 +++++++++++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> Having tests for all these new features would be really nice.

ill add some tests
if you want me to add more say so, iam not sure how exhaustive to
cover pixel formats for example

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: 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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer
  2023-03-30 18:00 [FFmpeg-devel] [PATCH 01/11] avcodec/j2kenc: fix 5/3 DWT identifer Michael Niedermayer
                   ` (9 preceding siblings ...)
  2023-03-30 18:01 ` [FFmpeg-devel] [PATCH 11/11] Remove libopenjpeg decoder Michael Niedermayer
@ 2023-04-02 21:20 ` Michael Niedermayer
  10 siblings, 0 replies; 14+ messages in thread
From: Michael Niedermayer @ 2023-04-02 21:20 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 451 bytes --]

On Thu, Mar 30, 2023 at 08:00:56PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/j2kenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply patchset with some tests added

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: 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".

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-04-02 21:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

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