Patches attached.
From 624514b681886ac340b76202b857a0870b7bc65d Mon Sep 17 00:00:00 2001 From: Paul B Mahol <one...@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 <one...@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
From 63be79c448309b7dde3ea4d430a0c015b01a6575 Mon Sep 17 00:00:00 2001 From: Paul B Mahol <one...@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 <one...@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
From 46682b156fe60760fbbc34df42a41113b9b44923 Mon Sep 17 00:00:00 2001 From: Paul B Mahol <one...@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 <one...@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
From 05f484b592d6e381a593b114556e242e23677067 Mon Sep 17 00:00:00 2001 From: Paul B Mahol <one...@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 <one...@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
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".