* [FFmpeg-devel] [PATCH v2] avcodec/tiff: add read support for compressed rgb floating point formats
@ 2022-10-01 23:05 mindmark
2022-10-02 17:06 ` Michael Niedermayer
2022-11-14 16:50 ` Anton Khirnov
0 siblings, 2 replies; 6+ messages in thread
From: mindmark @ 2022-10-01 23:05 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Mark Reid
From: Mark Reid <mindmark@gmail.com>
floating point uses a slightly different predictor technique describe here
http://chriscox.org/TIFFTN3d1.pdf
Here is a link the test files, if someone could add them to fate me
https://www.dropbox.com/s/fg59h2os4gb4wug/tiff_fate_samples.zip
---
libavcodec/tiff.c | 68 ++++++++++++++++++++++
tests/fate/image.mak | 20 ++++++-
tests/ref/fate/tiff-lzw-rgbaf32le | 6 ++
tests/ref/fate/tiff-lzw-rgbf32le | 6 ++
tests/ref/fate/tiff-uncompressed-rgbaf32le | 6 ++
tests/ref/fate/tiff-uncompressed-rgbf32le | 6 ++
tests/ref/fate/tiff-zip-rgbaf32le | 6 ++
tests/ref/fate/tiff-zip-rgbf32le | 6 ++
8 files changed, 123 insertions(+), 1 deletion(-)
create mode 100644 tests/ref/fate/tiff-lzw-rgbaf32le
create mode 100644 tests/ref/fate/tiff-lzw-rgbf32le
create mode 100644 tests/ref/fate/tiff-uncompressed-rgbaf32le
create mode 100644 tests/ref/fate/tiff-uncompressed-rgbf32le
create mode 100644 tests/ref/fate/tiff-zip-rgbaf32le
create mode 100644 tests/ref/fate/tiff-zip-rgbf32le
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 3a610ada85..ce31a40e37 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -2249,6 +2249,74 @@ again:
}
}
+ /* Floating point predictor
+ TIFF Technical Note 3 http://chriscox.org/TIFFTN3d1.pdf */
+ if (s->predictor == 3) {
+ int channels = s->bppcount;
+ int group_size;
+ uint8_t *tmpbuf;
+ int bpc;
+
+ dst = five_planes ? five_planes : p->data[plane];
+ soff = s->bpp >> 3;
+ if (s->planar) {
+ soff = FFMAX(soff / s->bppcount, 1);
+ channels = 1;
+ }
+ ssize = s->width * soff;
+ bpc = FFMAX(soff / s->bppcount, 1); /* Bytes per component */
+ group_size = s->width * channels;
+
+ tmpbuf = av_malloc(ssize);
+ if (!tmpbuf)
+ return AVERROR(ENOMEM);
+
+ if (s->avctx->pix_fmt == AV_PIX_FMT_RGBF32LE ||
+ s->avctx->pix_fmt == AV_PIX_FMT_RGBAF32LE) {
+ for (i = 0; i < decoded_height; i++) {
+ /* Copy first sample byte for each channel */
+ for (j = 0; j < channels; j++)
+ tmpbuf[j] = dst[j];
+
+ /* Decode horizontal differences */
+ for (j = channels; j < ssize; j++)
+ tmpbuf[j] = dst[j] + tmpbuf[j-channels];
+
+ /* Combine shuffled bytes from their separate groups. Each
+ byte of every floating point value in a row of pixels is
+ split and combined into separate groups. A group of all
+ the sign/exponents bytes in the row and groups for each
+ of the upper, mid, and lower mantissa bytes in the row. */
+ for (j = 0; j < group_size; j++) {
+ for (int k = 0; k < bpc; k++) {
+ dst[bpc * j + k] = tmpbuf[(bpc - k - 1) * group_size + j];
+ }
+ }
+ dst += stride;
+ }
+ } else if (s->avctx->pix_fmt == AV_PIX_FMT_RGBF32BE ||
+ s->avctx->pix_fmt == AV_PIX_FMT_RGBAF32BE) {
+ /* Same as LE only the shuffle at the end is reversed */
+ for (i = 0; i < decoded_height; i++) {
+ for (j = 0; j < channels; j++)
+ tmpbuf[j] = dst[j];
+
+ for (j = channels; j < ssize; j++)
+ tmpbuf[j] = dst[j] + tmpbuf[j-channels];
+
+ for (j = 0; j < group_size; j++) {
+ for (int k = 0; k < bpc; k++) {
+ dst[bpc * j + k] = tmpbuf[k * group_size + j];
+ }
+ }
+ dst += stride;
+ }
+ } else {
+ av_log(s->avctx, AV_LOG_ERROR, "unsupported floating point pixel format\n");
+ }
+ av_free(tmpbuf);
+ }
+
if (s->photometric == TIFF_PHOTOMETRIC_WHITE_IS_ZERO) {
int c = (s->avctx->pix_fmt == AV_PIX_FMT_PAL8 ? (1<<s->bpp) - 1 : 255);
dst = p->data[plane];
diff --git a/tests/fate/image.mak b/tests/fate/image.mak
index 03e794dc48..167c8ccf2c 100644
--- a/tests/fate/image.mak
+++ b/tests/fate/image.mak
@@ -501,7 +501,25 @@ fate-tiff-fax-g3: CMD = framecrc -i $(TARGET_SAMPLES)/CCITT_fax/G31D.TIF
FATE_TIFF += fate-tiff-fax-g3s
fate-tiff-fax-g3s: CMD = framecrc -i $(TARGET_SAMPLES)/CCITT_fax/G31DS.TIF
-FATE_TIFF-$(call DEMDEC, IMAGE2, TIFF) += $(FATE_TIFF)
+FATE_TIFF += fate-tiff-uncompressed-rgbf32le
+fate-tiff-uncompressed-rgbf32le: CMD = framecrc -i $(TARGET_SAMPLES)/tiff/uncompressed_rgbf32le.tif
+
+FATE_TIFF += fate-tiff-uncompressed-rgbaf32le
+fate-tiff-uncompressed-rgbaf32le: CMD = framecrc -i $(TARGET_SAMPLES)/tiff/uncompressed_rgbaf32le.tif
+
+FATE_TIFF += fate-tiff-lzw-rgbf32le
+fate-tiff-lzw-rgbf32le: CMD = framecrc -i $(TARGET_SAMPLES)/tiff/lzw_rgbf32le.tif
+
+FATE_TIFF += fate-tiff-lzw-rgbaf32le
+fate-tiff-lzw-rgbaf32le: CMD = framecrc -i $(TARGET_SAMPLES)/tiff/lzw_rgbaf32le.tif
+
+FATE_TIFF += fate-tiff-zip-rgbf32le
+fate-tiff-zip-rgbf32le: CMD = framecrc -i $(TARGET_SAMPLES)/tiff/zip_rgbf32le.tif
+
+FATE_TIFF += fate-tiff-zip-rgbaf32le
+fate-tiff-zip-rgbaf32le: CMD = framecrc -i $(TARGET_SAMPLES)/tiff/zip_rgbaf32le.tif
+
+FATE_TIFF-$(call FRAMECRC, IMAGE2, TIFF) += $(FATE_TIFF)
FATE_IMAGE_FRAMECRC += $(FATE_TIFF-yes)
fate-tiff: $(FATE_TIFF-yes)
diff --git a/tests/ref/fate/tiff-lzw-rgbaf32le b/tests/ref/fate/tiff-lzw-rgbaf32le
new file mode 100644
index 0000000000..c99aa02ef0
--- /dev/null
+++ b/tests/ref/fate/tiff-lzw-rgbaf32le
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 8x8
+#sar 0: 0/1
+0, 0, 0, 1, 1024, 0x877e1d5f
diff --git a/tests/ref/fate/tiff-lzw-rgbf32le b/tests/ref/fate/tiff-lzw-rgbf32le
new file mode 100644
index 0000000000..a6d3fabfda
--- /dev/null
+++ b/tests/ref/fate/tiff-lzw-rgbf32le
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 8x8
+#sar 0: 0/1
+0, 0, 0, 1, 768, 0xad26ed90
diff --git a/tests/ref/fate/tiff-uncompressed-rgbaf32le b/tests/ref/fate/tiff-uncompressed-rgbaf32le
new file mode 100644
index 0000000000..c99aa02ef0
--- /dev/null
+++ b/tests/ref/fate/tiff-uncompressed-rgbaf32le
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 8x8
+#sar 0: 0/1
+0, 0, 0, 1, 1024, 0x877e1d5f
diff --git a/tests/ref/fate/tiff-uncompressed-rgbf32le b/tests/ref/fate/tiff-uncompressed-rgbf32le
new file mode 100644
index 0000000000..a6d3fabfda
--- /dev/null
+++ b/tests/ref/fate/tiff-uncompressed-rgbf32le
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 8x8
+#sar 0: 0/1
+0, 0, 0, 1, 768, 0xad26ed90
diff --git a/tests/ref/fate/tiff-zip-rgbaf32le b/tests/ref/fate/tiff-zip-rgbaf32le
new file mode 100644
index 0000000000..c99aa02ef0
--- /dev/null
+++ b/tests/ref/fate/tiff-zip-rgbaf32le
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 8x8
+#sar 0: 0/1
+0, 0, 0, 1, 1024, 0x877e1d5f
diff --git a/tests/ref/fate/tiff-zip-rgbf32le b/tests/ref/fate/tiff-zip-rgbf32le
new file mode 100644
index 0000000000..a6d3fabfda
--- /dev/null
+++ b/tests/ref/fate/tiff-zip-rgbf32le
@@ -0,0 +1,6 @@
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 8x8
+#sar 0: 0/1
+0, 0, 0, 1, 768, 0xad26ed90
--
2.31.1.windows.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] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2] avcodec/tiff: add read support for compressed rgb floating point formats
2022-10-01 23:05 [FFmpeg-devel] [PATCH v2] avcodec/tiff: add read support for compressed rgb floating point formats mindmark
@ 2022-10-02 17:06 ` Michael Niedermayer
2022-10-02 17:18 ` James Almer
2022-11-14 16:50 ` Anton Khirnov
1 sibling, 1 reply; 6+ messages in thread
From: Michael Niedermayer @ 2022-10-02 17:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: samples-request
[-- Attachment #1.1: Type: text/plain, Size: 720 bytes --]
On Sat, Oct 01, 2022 at 04:05:12PM -0700, mindmark@gmail.com wrote:
> From: Mark Reid <mindmark@gmail.com>
>
> floating point uses a slightly different predictor technique describe here
> http://chriscox.org/TIFFTN3d1.pdf
>
> Here is a link the test files, if someone could add them to fate me
> https://www.dropbox.com/s/fg59h2os4gb4wug/tiff_fate_samples.zip
ccing samples-request@ffmpeg.org, for sample upload req
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"
[-- 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] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2] avcodec/tiff: add read support for compressed rgb floating point formats
2022-10-02 17:06 ` Michael Niedermayer
@ 2022-10-02 17:18 ` James Almer
2022-10-20 16:49 ` Mark Reid
0 siblings, 1 reply; 6+ messages in thread
From: James Almer @ 2022-10-02 17:18 UTC (permalink / raw)
To: ffmpeg-devel
On 10/2/2022 2:06 PM, Michael Niedermayer wrote:
> On Sat, Oct 01, 2022 at 04:05:12PM -0700, mindmark@gmail.com wrote:
>> From: Mark Reid <mindmark@gmail.com>
>>
>> floating point uses a slightly different predictor technique describe here
>> http://chriscox.org/TIFFTN3d1.pdf
>>
>
>> Here is a link the test files, if someone could add them to fate me
>> https://www.dropbox.com/s/fg59h2os4gb4wug/tiff_fate_samples.zip
>
> ccing samples-request@ffmpeg.org, for sample upload req
>
> thx
Done.
_______________________________________________
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] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2] avcodec/tiff: add read support for compressed rgb floating point formats
2022-10-02 17:18 ` James Almer
@ 2022-10-20 16:49 ` Mark Reid
2022-11-01 3:17 ` Mark Reid
0 siblings, 1 reply; 6+ messages in thread
From: Mark Reid @ 2022-10-20 16:49 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sun, Oct 2, 2022 at 10:18 AM James Almer <jamrial@gmail.com> wrote:
> On 10/2/2022 2:06 PM, Michael Niedermayer wrote:
> > On Sat, Oct 01, 2022 at 04:05:12PM -0700, mindmark@gmail.com wrote:
> >> From: Mark Reid <mindmark@gmail.com>
> >>
> >> floating point uses a slightly different predictor technique describe
> here
> >> http://chriscox.org/TIFFTN3d1.pdf
> >>
> >
> >> Here is a link the test files, if someone could add them to fate me
> >> https://www.dropbox.com/s/fg59h2os4gb4wug/tiff_fate_samples.zip
> >
> > ccing samples-request@ffmpeg.org, for sample upload req
> >
> > thx
>
> Done.
>
ping
> _______________________________________________
> 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] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2] avcodec/tiff: add read support for compressed rgb floating point formats
2022-10-20 16:49 ` Mark Reid
@ 2022-11-01 3:17 ` Mark Reid
0 siblings, 0 replies; 6+ messages in thread
From: Mark Reid @ 2022-11-01 3:17 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, Oct 20, 2022 at 9:49 AM Mark Reid <mindmark@gmail.com> wrote:
>
> On Sun, Oct 2, 2022 at 10:18 AM James Almer <jamrial@gmail.com> wrote:
>
>> On 10/2/2022 2:06 PM, Michael Niedermayer wrote:
>> > On Sat, Oct 01, 2022 at 04:05:12PM -0700, mindmark@gmail.com wrote:
>> >> From: Mark Reid <mindmark@gmail.com>
>> >>
>> >> floating point uses a slightly different predictor technique describe
>> here
>> >> http://chriscox.org/TIFFTN3d1.pdf
>> >>
>> >
>> >> Here is a link the test files, if someone could add them to fate me
>> >> https://www.dropbox.com/s/fg59h2os4gb4wug/tiff_fate_samples.zip
>> >
>> > ccing samples-request@ffmpeg.org, for sample upload req
>> >
>> > thx
>>
>> Done.
>>
>
> ping
>
ping
_______________________________________________
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] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2] avcodec/tiff: add read support for compressed rgb floating point formats
2022-10-01 23:05 [FFmpeg-devel] [PATCH v2] avcodec/tiff: add read support for compressed rgb floating point formats mindmark
2022-10-02 17:06 ` Michael Niedermayer
@ 2022-11-14 16:50 ` Anton Khirnov
1 sibling, 0 replies; 6+ messages in thread
From: Anton Khirnov @ 2022-11-14 16:50 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Mark Reid
Quoting mindmark@gmail.com (2022-10-02 01:05:12)
> From: Mark Reid <mindmark@gmail.com>
>
> floating point uses a slightly different predictor technique describe here
> http://chriscox.org/TIFFTN3d1.pdf
>
> Here is a link the test files, if someone could add them to fate me
> https://www.dropbox.com/s/fg59h2os4gb4wug/tiff_fate_samples.zip
>
>
> ---
> libavcodec/tiff.c | 68 ++++++++++++++++++++++
> tests/fate/image.mak | 20 ++++++-
> tests/ref/fate/tiff-lzw-rgbaf32le | 6 ++
> tests/ref/fate/tiff-lzw-rgbf32le | 6 ++
> tests/ref/fate/tiff-uncompressed-rgbaf32le | 6 ++
> tests/ref/fate/tiff-uncompressed-rgbf32le | 6 ++
> tests/ref/fate/tiff-zip-rgbaf32le | 6 ++
> tests/ref/fate/tiff-zip-rgbf32le | 6 ++
> 8 files changed, 123 insertions(+), 1 deletion(-)
> create mode 100644 tests/ref/fate/tiff-lzw-rgbaf32le
> create mode 100644 tests/ref/fate/tiff-lzw-rgbf32le
> create mode 100644 tests/ref/fate/tiff-uncompressed-rgbaf32le
> create mode 100644 tests/ref/fate/tiff-uncompressed-rgbf32le
> create mode 100644 tests/ref/fate/tiff-zip-rgbaf32le
> create mode 100644 tests/ref/fate/tiff-zip-rgbf32le
Looks acceptable, will push in a few days if nobody objects.
But decode_frame() is starting to look very long and smelly and could
definitely use some refactoring.
--
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] 6+ messages in thread
end of thread, other threads:[~2022-11-14 16:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-01 23:05 [FFmpeg-devel] [PATCH v2] avcodec/tiff: add read support for compressed rgb floating point formats mindmark
2022-10-02 17:06 ` Michael Niedermayer
2022-10-02 17:18 ` James Almer
2022-10-20 16:49 ` Mark Reid
2022-11-01 3:17 ` Mark Reid
2022-11-14 16:50 ` Anton Khirnov
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