[FFmpeg-devel,v10,04/13] lavc/tiff: Apply color scaling to uncompressed DNGs

Submitted by velocityra@gmail.com on Aug. 7, 2019, 3:27 p.m.

Details

Message ID 20190807152723.18892-4-velocityra@gmail.com
State New
Headers show

Commit Message

velocityra@gmail.com Aug. 7, 2019, 3:27 p.m.
From: Nick Renieris <velocityra@gmail.com>

Signed-off-by: Nick Renieris <velocityra@gmail.com>
---
 libavcodec/tiff.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Aug. 7, 2019, 10:21 p.m.
On Wed, Aug 07, 2019 at 06:27:14PM +0300, velocityra@gmail.com wrote:
> From: Nick Renieris <velocityra@gmail.com>
> 
> Signed-off-by: Nick Renieris <velocityra@gmail.com>
> ---
>  libavcodec/tiff.c | 22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> index c7e2adb3ae..b6f626daca 100644
> --- a/libavcodec/tiff.c
> +++ b/libavcodec/tiff.c
> @@ -679,6 +679,25 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
>                  for (i = 0; i < width; i++)
>                      dst[i] = ff_reverse[src[i]];
>              }
> +
> +            /* Color processing for DNG images with uncompressed strips (non-tiled) */
> +            if (is_dng) {

This variable is only added in a later patch
so this does not build

also some change in this patchset breaks:
./ffplay tickets/2826/pred6disc7.jpg
file should be here:
https://trac.ffmpeg.org/raw-attachment/ticket/2826/pred6disc7.jpg

Thanks

[...]
velocityra@gmail.com Aug. 8, 2019, 8:50 p.m.
Thanks for the review Michael, pushing fixes and a commit that makes
some more images compatible.

Στις Πέμ, 8 Αυγ 2019 στις 1:22 π.μ., ο/η Michael Niedermayer
<michael@niedermayer.cc> έγραψε:
>
> On Wed, Aug 07, 2019 at 06:27:14PM +0300, velocityra@gmail.com wrote:
> > From: Nick Renieris <velocityra@gmail.com>
> >
> > Signed-off-by: Nick Renieris <velocityra@gmail.com>
> > ---
> >  libavcodec/tiff.c | 22 +++++++++++++++++++++-
> >  1 file changed, 21 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
> > index c7e2adb3ae..b6f626daca 100644
> > --- a/libavcodec/tiff.c
> > +++ b/libavcodec/tiff.c
> > @@ -679,6 +679,25 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
> >                  for (i = 0; i < width; i++)
> >                      dst[i] = ff_reverse[src[i]];
> >              }
> > +
> > +            /* Color processing for DNG images with uncompressed strips (non-tiled) */
> > +            if (is_dng) {
>
> This variable is only added in a later patch
> so this does not build
>
> also some change in this patchset breaks:
> ./ffplay tickets/2826/pred6disc7.jpg
> file should be here:
> https://trac.ffmpeg.org/raw-attachment/ticket/2826/pred6disc7.jpg
>
> Thanks
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Does the universe only have a finite lifespan? No, its going to go on
> forever, its just that you wont like living in it. -- Hiranya Peiri
> _______________________________________________
> 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".

Patch hide | download patch | download mbox

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index c7e2adb3ae..b6f626daca 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -679,6 +679,25 @@  static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid
                 for (i = 0; i < width; i++)
                     dst[i] = ff_reverse[src[i]];
             }
+
+            /* Color processing for DNG images with uncompressed strips (non-tiled) */
+            if (is_dng) {
+                int is_u16, pixel_size_bytes, pixel_size_bits;
+
+                is_u16 = (s->bpp > 8);
+                pixel_size_bits = (is_u16 ? 16 : 8);
+                pixel_size_bytes = (is_u16 ? sizeof(uint16_t) : sizeof(uint8_t));
+
+                dng_blit(s,
+                         dst,
+                         0, // no stride, only 1 line
+                         dst,
+                         0, // no stride, only 1 line
+                         width / pixel_size_bytes * pixel_size_bits / s->bpp, // need to account for [1, 16] bpp
+                         1,
+                         is_u16);
+            }
+
             src += width;
             break;
         case TIFF_PACKBITS:
@@ -1950,7 +1969,8 @@  again:
         FFSWAP(int,      p->linesize[0], p->linesize[1]);
     }
 
-    if (s->is_bayer && s->white_level && s->bpp == 16) {
+    if (s->is_bayer && s->white_level && s->bpp == 16 &&
+        !(s->tiff_type == TIFF_TYPE_DNG || s->tiff_type == TIFF_TYPE_CINEMADNG)) {
         uint16_t *dst = (uint16_t *)p->data[0];
         for (i = 0; i < s->height; i++) {
             for (j = 0; j < s->width; j++)