call TIFFGetField() on YCBCRSUBSAMPLING for tif_jpeg hack

This commit is contained in:
Frank Warmerdam 2002-07-31 21:05:57 +00:00
parent a0605bac6b
commit a6873099d0
2 changed files with 25 additions and 9 deletions

View File

@ -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 * Copyright (c) 1988-1997 Sam Leffler
@ -319,8 +319,19 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
} }
#ifdef YCBCR_SUPPORT #ifdef YCBCR_SUPPORT
if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) 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", fprintf(fd, " YCbCr Subsampling: %u, %u\n",
td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1]); subsampling[0], subsampling[1] );
}
if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) {
fprintf(fd, " YCbCr Positioning: "); fprintf(fd, " YCbCr Positioning: ");
switch (td->td_ycbcrpositioning) { switch (td->td_ycbcrpositioning) {

View File

@ -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 * Copyright (c) 1991-1997 Sam Leffler
@ -92,12 +92,17 @@ TIFFVStripSize(TIFF* tif, uint32 nrows)
* horizontal/vertical subsampling area include * horizontal/vertical subsampling area include
* YCbCr data for the extended image. * YCbCr data for the extended image.
*/ */
tsize_t w = uint16 ycbcrsubsampling[2];
TIFFroundup(td->td_imagewidth, td->td_ycbcrsubsampling[0]); tsize_t w, scanline, samplingarea;
tsize_t scanline = TIFFhowmany(w*td->td_bitspersample, 8);
tsize_t samplingarea = TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING,
td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1]; ycbcrsubsampling + 0,
nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]); 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 */ /* NB: don't need TIFFhowmany here 'cuz everything is rounded */
return ((tsize_t) return ((tsize_t)
(nrows*scanline + 2*(nrows*scanline / samplingarea))); (nrows*scanline + 2*(nrows*scanline / samplingarea)));