From a6873099d06546003d4b2f738e418ca05e5f289b Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Wed, 31 Jul 2002 21:05:57 +0000 Subject: [PATCH] call TIFFGetField() on YCBCRSUBSAMPLING for tif_jpeg hack --- libtiff/tif_print.c | 15 +++++++++++++-- libtiff/tif_strip.c | 19 ++++++++++++------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c index 5ceafbf4..2fe9acc9 100644 --- a/libtiff/tif_print.c +++ b/libtiff/tif_print.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_print.c,v 1.7 2002-03-27 06:31:29 warmerda Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_print.c,v 1.8 2002-07-31 21:05:57 warmerda Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -319,8 +319,19 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) } #ifdef YCBCR_SUPPORT if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) + { + /* + * For hacky reasons (see tif_jpeg.c - JPEGFixupTestSubsampling), + * we need to fetch this rather than trust what is in our + * structures. + */ + uint16 subsampling[2]; + + TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING, + subsampling + 0, subsampling + 1 ); fprintf(fd, " YCbCr Subsampling: %u, %u\n", - td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1]); + subsampling[0], subsampling[1] ); + } if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { fprintf(fd, " YCbCr Positioning: "); switch (td->td_ycbcrpositioning) { diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c index c7c018a7..aecbb139 100644 --- a/libtiff/tif_strip.c +++ b/libtiff/tif_strip.c @@ -1,4 +1,4 @@ -/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_strip.c,v 1.1 1999-07-27 21:50:27 mike Exp $ */ +/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_strip.c,v 1.2 2002-07-31 21:05:57 warmerda Exp $ */ /* * Copyright (c) 1991-1997 Sam Leffler @@ -92,12 +92,17 @@ TIFFVStripSize(TIFF* tif, uint32 nrows) * horizontal/vertical subsampling area include * YCbCr data for the extended image. */ - tsize_t w = - TIFFroundup(td->td_imagewidth, td->td_ycbcrsubsampling[0]); - tsize_t scanline = TIFFhowmany(w*td->td_bitspersample, 8); - tsize_t samplingarea = - td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; - nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); + uint16 ycbcrsubsampling[2]; + tsize_t w, scanline, samplingarea; + + TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING, + ycbcrsubsampling + 0, + ycbcrsubsampling + 1 ); + + w = TIFFroundup(td->td_imagewidth, ycbcrsubsampling[0]); + scanline = TIFFhowmany(w*td->td_bitspersample, 8); + samplingarea = ycbcrsubsampling[0]*ycbcrsubsampling[1]; + nrows = TIFFroundup(nrows, ycbcrsubsampling[1]); /* NB: don't need TIFFhowmany here 'cuz everything is rounded */ return ((tsize_t) (nrows*scanline + 2*(nrows*scanline / samplingarea)));