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] float in tiff
@ 2022-09-14 16:01 Paul B Mahol
  2022-09-23 18:14 ` Paul B Mahol
  0 siblings, 1 reply; 4+ messages in thread
From: Paul B Mahol @ 2022-09-14 16:01 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 18 bytes --]

Patches attached.

[-- Attachment #2: 0001-avutil-add-RGB-single-precision-float-formats.patch --]
[-- Type: text/x-patch, Size: 2509 bytes --]

From 624514b681886ac340b76202b857a0870b7bc65d Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Wed, 14 Sep 2022 14:09:02 +0200
Subject: [PATCH 1/4] avutil: add RGB single-precision float formats

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavutil/pixdesc.c | 25 +++++++++++++++++++++++++
 libavutil/pixfmt.h  |  3 +++
 2 files changed, 28 insertions(+)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index d7c6ebfdc4..fb3fddd5b2 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2636,6 +2636,31 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
         },
         .flags = AV_PIX_FMT_FLAG_BE,
     },
+    [AV_PIX_FMT_RGBF32BE] = {
+        .name = "rgbf32be",
+        .nb_components = 3,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 12, 0, 0, 32 },       /* R */
+            { 0, 12, 4, 0, 32 },       /* G */
+            { 0, 12, 8, 0, 32 },       /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB |
+                 AV_PIX_FMT_FLAG_FLOAT,
+    },
+    [AV_PIX_FMT_RGBF32LE] = {
+        .name = "rgbf32le",
+        .nb_components = 3,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 12, 0, 0, 32 },       /* R */
+            { 0, 12, 4, 0, 32 },       /* G */
+            { 0, 12, 8, 0, 32 },       /* B */
+        },
+        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT,
+    },
 };
 
 static const char * const color_range_names[] = {
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index a1c4c9fb75..3c34d73e2c 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -386,6 +386,9 @@ enum AVPixelFormat {
     AV_PIX_FMT_XV36BE,      ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, big-endian, variant of Y412 where alpha channel is left undefined
     AV_PIX_FMT_XV36LE,      ///< packed XVYU 4:4:4, 48bpp, data in the high bits, zeros in the low bits, little-endian, variant of Y412 where alpha channel is left undefined
 
+    AV_PIX_FMT_RGBF32BE,    ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., big-endian
+    AV_PIX_FMT_RGBF32LE,    ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., little-endian
+
     AV_PIX_FMT_NB         ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
 };
 
-- 
2.37.2


[-- Attachment #3: 0002-avutil-add-RGBA-single-float-precision-packed-format.patch --]
[-- Type: text/x-patch, Size: 2601 bytes --]

From 63be79c448309b7dde3ea4d430a0c015b01a6575 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Wed, 14 Sep 2022 14:13:06 +0200
Subject: [PATCH 2/4] avutil: add RGBA single-float precision packed formats

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavutil/pixdesc.c | 28 ++++++++++++++++++++++++++++
 libavutil/pixfmt.h  |  3 +++
 2 files changed, 31 insertions(+)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index fb3fddd5b2..6b8daa0a8e 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -2661,6 +2661,34 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
         },
         .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT,
     },
+    [AV_PIX_FMT_RGBAF32BE] = {
+        .name = "rgbaf32be",
+        .nb_components = 4,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 16,  0, 0, 32 },      /* R */
+            { 0, 16,  4, 0, 32 },      /* G */
+            { 0, 16,  8, 0, 32 },      /* B */
+            { 0, 16, 12, 0, 32 },      /* A */
+        },
+        .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB |
+                 AV_PIX_FMT_FLAG_FLOAT | AV_PIX_FMT_FLAG_ALPHA,
+    },
+    [AV_PIX_FMT_RGBAF32LE] = {
+        .name = "rgbaf32le",
+        .nb_components = 4,
+        .log2_chroma_w = 0,
+        .log2_chroma_h = 0,
+        .comp = {
+            { 0, 16,  0, 0, 32 },      /* R */
+            { 0, 16,  4, 0, 32 },      /* G */
+            { 0, 16,  8, 0, 32 },      /* B */
+            { 0, 16, 12, 0, 32 },      /* A */
+        },
+        .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_FLOAT |
+                 AV_PIX_FMT_FLAG_ALPHA,
+    },
 };
 
 static const char * const color_range_names[] = {
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 3c34d73e2c..f8b3c0514f 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -389,6 +389,9 @@ enum AVPixelFormat {
     AV_PIX_FMT_RGBF32BE,    ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., big-endian
     AV_PIX_FMT_RGBF32LE,    ///< IEEE-754 single precision packed RGB 32:32:32, 96bpp, RGBRGB..., little-endian
 
+    AV_PIX_FMT_RGBAF32BE,   ///< IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., big-endian
+    AV_PIX_FMT_RGBAF32LE,   ///< IEEE-754 single precision packed RGBA 32:32:32:32, 128bpp, RGBARGBA..., little-endian
+
     AV_PIX_FMT_NB         ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
 };
 
-- 
2.37.2


[-- Attachment #4: 0003-avcodec-tiff-add-packed-planar-32bit-float-support.patch --]
[-- Type: text/x-patch, Size: 3521 bytes --]

From 46682b156fe60760fbbc34df42a41113b9b44923 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Wed, 14 Sep 2022 13:58:21 +0200
Subject: [PATCH 3/4] avcodec/tiff: add packed/planar 32bit float support

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavcodec/tiff.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index beb427e007..02840c3cff 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -1027,14 +1027,14 @@ static int init_image(TiffContext *s, AVFrame *frame)
     int create_gray_palette = 0;
 
     // make sure there is no aliasing in the following switch
-    if (s->bpp >= 100 || s->bppcount >= 10) {
+    if (s->bpp > 128 || s->bppcount >= 10) {
         av_log(s->avctx, AV_LOG_ERROR,
                "Unsupported image parameters: bpp=%d, bppcount=%d\n",
                s->bpp, s->bppcount);
         return AVERROR_INVALIDDATA;
     }
 
-    switch (s->planar * 1000 + s->bpp * 10 + s->bppcount + s->is_bayer * 10000) {
+    switch (s->planar * 10000 + s->bpp * 10 + s->bppcount + s->is_bayer * 100000) {
     case 11:
         if (!s->palette_is_set) {
             s->avctx->pix_fmt = AV_PIX_FMT_MONOBLACK;
@@ -1053,7 +1053,7 @@ static int init_image(TiffContext *s, AVFrame *frame)
     case 121:
         s->avctx->pix_fmt = AV_PIX_FMT_GRAY12;
         break;
-    case 10081:
+    case 100081:
         switch (AV_RL32(s->pattern)) {
         case 0x02010100:
             s->avctx->pix_fmt = AV_PIX_FMT_BAYER_RGGB8;
@@ -1073,10 +1073,10 @@ static int init_image(TiffContext *s, AVFrame *frame)
             return AVERROR_PATCHWELCOME;
         }
         break;
-    case 10101:
-    case 10121:
-    case 10141:
-    case 10161:
+    case 100101:
+    case 100121:
+    case 100141:
+    case 100161:
         switch (AV_RL32(s->pattern)) {
         case 0x02010100:
             s->avctx->pix_fmt = AV_PIX_FMT_BAYER_RGGB16;
@@ -1144,18 +1144,30 @@ static int init_image(TiffContext *s, AVFrame *frame)
     case 644:
         s->avctx->pix_fmt = s->le ? AV_PIX_FMT_RGBA64LE  : AV_PIX_FMT_RGBA64BE;
         break;
-    case 1243:
+    case 10243:
         s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
         break;
-    case 1324:
+    case 10324:
         s->avctx->pix_fmt = AV_PIX_FMT_GBRAP;
         break;
-    case 1483:
+    case 10483:
         s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GBRP16LE : AV_PIX_FMT_GBRP16BE;
         break;
-    case 1644:
+    case 10644:
         s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GBRAP16LE : AV_PIX_FMT_GBRAP16BE;
         break;
+    case 963:
+        s->avctx->pix_fmt = s->le ? AV_PIX_FMT_RGBF32LE : AV_PIX_FMT_RGBF32BE;
+        break;
+    case 1284:
+        s->avctx->pix_fmt = s->le ? AV_PIX_FMT_RGBAF32LE : AV_PIX_FMT_RGBAF32BE;
+        break;
+    case 10963:
+        s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GBRPF32LE : AV_PIX_FMT_GBRPF32BE;
+        break;
+    case 11284:
+        s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GBRAPF32LE : AV_PIX_FMT_GBRAPF32BE;
+        break;
     default:
         av_log(s->avctx, AV_LOG_ERROR,
                "This format is not supported (bpp=%d, bppcount=%d)\n",
@@ -1732,7 +1744,7 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
         }
     }
 end:
-    if (s->bpp > 64U) {
+    if (s->bpp > 128U) {
         av_log(s->avctx, AV_LOG_ERROR,
                 "This format is not supported (bpp=%d, %d components)\n",
                 s->bpp, count);
-- 
2.37.2


[-- Attachment #5: 0004-avfilter-vf_extractplanes-add-support-for-packed-rgb.patch --]
[-- Type: text/x-patch, Size: 1561 bytes --]

From 05f484b592d6e381a593b114556e242e23677067 Mon Sep 17 00:00:00 2001
From: Paul B Mahol <onemda@gmail.com>
Date: Wed, 14 Sep 2022 16:41:48 +0200
Subject: [PATCH 4/4] avfilter/vf_extractplanes: add support for packed rgb
 float formats

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/vf_extractplanes.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavfilter/vf_extractplanes.c b/libavfilter/vf_extractplanes.c
index 60b55578cf..3c794eaa28 100644
--- a/libavfilter/vf_extractplanes.c
+++ b/libavfilter/vf_extractplanes.c
@@ -124,6 +124,7 @@ AVFILTER_DEFINE_CLASS(extractplanes);
 
 #define FLOAT_FORMATS(suf)                                     \
         AV_PIX_FMT_GRAYF32##suf,                               \
+        AV_PIX_FMT_RGBF32##suf, AV_PIX_FMT_RGBAF32##suf,       \
         AV_PIX_FMT_GBRPF32##suf, AV_PIX_FMT_GBRAPF32##suf      \
 
 static int query_formats(AVFilterContext *ctx)
@@ -283,6 +284,13 @@ static void extract_from_packed(uint8_t *dst, int dst_linesize,
                 dst[x * 2    ] = src[x * step + comp * 2    ];
                 dst[x * 2 + 1] = src[x * step + comp * 2 + 1];
             }
+        case 4:
+            for (x = 0; x < width; x++) {
+                dst[x * 4    ] = src[x * step + comp * 4    ];
+                dst[x * 4 + 1] = src[x * step + comp * 4 + 1];
+                dst[x * 4 + 2] = src[x * step + comp * 4 + 2];
+                dst[x * 4 + 3] = src[x * step + comp * 4 + 3];
+            }
             break;
         }
         dst += dst_linesize;
-- 
2.37.2


[-- Attachment #6: 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] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] float in tiff
  2022-09-14 16:01 [FFmpeg-devel] [PATCH] float in tiff Paul B Mahol
@ 2022-09-23 18:14 ` Paul B Mahol
  2022-09-27 20:54   ` Mark Reid
  0 siblings, 1 reply; 4+ messages in thread
From: Paul B Mahol @ 2022-09-23 18:14 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On 9/14/22, Paul B Mahol <onemda@gmail.com> wrote:
> Patches attached.
>

Will apply soon.
_______________________________________________
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] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] float in tiff
  2022-09-23 18:14 ` Paul B Mahol
@ 2022-09-27 20:54   ` Mark Reid
  2022-09-28  8:42     ` Paul B Mahol
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Reid @ 2022-09-27 20:54 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Fri, Sep 23, 2022 at 11:14 AM Paul B Mahol <onemda@gmail.com> wrote:

> On 9/14/22, Paul B Mahol <onemda@gmail.com> wrote:
> > Patches attached.
> >
>
> Will apply soon.
>

Were you planning on adding swscale support for the rgbaf32 formats? Didn't
want to start working on it if you already started :)


> _______________________________________________
> 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".
>
_______________________________________________
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] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] float in tiff
  2022-09-27 20:54   ` Mark Reid
@ 2022-09-28  8:42     ` Paul B Mahol
  0 siblings, 0 replies; 4+ messages in thread
From: Paul B Mahol @ 2022-09-28  8:42 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On 9/27/22, Mark Reid <mindmark@gmail.com> wrote:
> On Fri, Sep 23, 2022 at 11:14 AM Paul B Mahol <onemda@gmail.com> wrote:
>
>> On 9/14/22, Paul B Mahol <onemda@gmail.com> wrote:
>> > Patches attached.
>> >
>>
>> Will apply soon.
>>
>
> Were you planning on adding swscale support for the rgbaf32 formats? Didn't
> want to start working on it if you already started :)

Nope, feel free to do it.

>
>
>> _______________________________________________
>> 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".
>>
> _______________________________________________
> 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".
>
_______________________________________________
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] 4+ messages in thread

end of thread, other threads:[~2022-09-28  8:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-14 16:01 [FFmpeg-devel] [PATCH] float in tiff Paul B Mahol
2022-09-23 18:14 ` Paul B Mahol
2022-09-27 20:54   ` Mark Reid
2022-09-28  8:42     ` Paul B Mahol

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