Merge branch '8.7'
This commit is contained in:
commit
27d8cd40fe
@ -265,6 +265,7 @@ typedef struct _RtiffHeader {
|
||||
*/
|
||||
uint32 rows_per_strip;
|
||||
tsize_t strip_size;
|
||||
tsize_t scanline_size;
|
||||
int number_of_strips;
|
||||
|
||||
/* If read_scanlinewise is TRUE, the strips are too large to read in a
|
||||
@ -272,12 +273,12 @@ typedef struct _RtiffHeader {
|
||||
*/
|
||||
gboolean read_scanlinewise;
|
||||
|
||||
/* Strip read geometry. These are the read params as they will be used
|
||||
* to read, with either TIFFReadScanline() or TIFFReadEncodedStrip(),
|
||||
* not as they are stored in the file.
|
||||
/* Strip read geometry. Number of lines we read at once (whole strip
|
||||
* or 1) and size of the buffer we read to (a scanline, or a strip in
|
||||
* size).
|
||||
*/
|
||||
uint32 read_rows_per_strip;
|
||||
tsize_t read_strip_size;
|
||||
uint32 read_height;
|
||||
tsize_t read_size;
|
||||
} RtiffHeader;
|
||||
|
||||
/* Scanline-type process function.
|
||||
@ -1756,16 +1757,15 @@ static int
|
||||
rtiff_strip_read_interleaved( Rtiff *rtiff, tstrip_t strip, tdata_t buf )
|
||||
{
|
||||
int samples_per_pixel = rtiff->header.samples_per_pixel;
|
||||
int read_rows_per_strip = rtiff->header.read_rows_per_strip;
|
||||
int read_height = rtiff->header.read_height;
|
||||
int bits_per_sample = rtiff->header.bits_per_sample;
|
||||
int strip_y = strip * read_rows_per_strip;
|
||||
int strip_y = strip * read_height;
|
||||
|
||||
if( rtiff->header.separate ) {
|
||||
int page_width = rtiff->header.width;
|
||||
int page_height = rtiff->header.height;
|
||||
int strips_per_plane = 1 + (page_height - 1) /
|
||||
read_rows_per_strip;
|
||||
int strip_height = VIPS_MIN( read_rows_per_strip,
|
||||
int strips_per_plane = 1 + (page_height - 1) / read_height;
|
||||
int strip_height = VIPS_MIN( read_height,
|
||||
page_height - strip_y );
|
||||
int pels_per_strip = page_width * strip_height;
|
||||
int bytes_per_sample = bits_per_sample >> 3;
|
||||
@ -1805,9 +1805,9 @@ rtiff_stripwise_generate( VipsRegion *or,
|
||||
void *seq, void *a, void *b, gboolean *stop )
|
||||
{
|
||||
Rtiff *rtiff = (Rtiff *) a;
|
||||
int read_rows_per_strip = rtiff->header.read_rows_per_strip;
|
||||
int read_height = rtiff->header.read_height;
|
||||
int page_height = rtiff->header.height;
|
||||
tsize_t scanline_size = TIFFScanlineSize( rtiff->tiff );
|
||||
tsize_t scanline_size = rtiff->header.scanline_size;
|
||||
VipsRect *r = &or->valid;
|
||||
|
||||
int y;
|
||||
@ -1833,7 +1833,7 @@ rtiff_stripwise_generate( VipsRegion *or,
|
||||
* strip in the image.
|
||||
*/
|
||||
g_assert( r->height ==
|
||||
VIPS_MIN( read_rows_per_strip, or->im->Ysize - r->top ) );
|
||||
VIPS_MIN( read_height, or->im->Ysize - r->top ) );
|
||||
|
||||
/* And check that y_pos is correct. It should be, since we are inside
|
||||
* a vips_sequential().
|
||||
@ -1857,7 +1857,7 @@ rtiff_stripwise_generate( VipsRegion *or,
|
||||
|
||||
/* Strip number.
|
||||
*/
|
||||
tstrip_t strip_no = y_page / read_rows_per_strip;
|
||||
tstrip_t strip_no = y_page / read_height;
|
||||
|
||||
VipsRect image, page, strip, hit;
|
||||
|
||||
@ -1875,9 +1875,9 @@ rtiff_stripwise_generate( VipsRegion *or,
|
||||
page.height = page_height;
|
||||
|
||||
strip.left = 0;
|
||||
strip.top = page.top + strip_no * read_rows_per_strip;
|
||||
strip.top = page.top + strip_no * read_height;
|
||||
strip.width = rtiff->out->Xsize;
|
||||
strip.height = read_rows_per_strip;
|
||||
strip.height = read_height;
|
||||
|
||||
/* Clip strip against page and image ... the final strip will
|
||||
* be smaller.
|
||||
@ -1987,10 +1987,10 @@ rtiff_read_stripwise( Rtiff *rtiff, VipsImage *out )
|
||||
rtiff->header.strip_size );
|
||||
printf( "rtiff_read_stripwise: header.number_of_strips = %d\n",
|
||||
rtiff->header.number_of_strips );
|
||||
printf( "rtiff_read_stripwise: header.read_rows_per_strip = %u\n",
|
||||
rtiff->header.read_rows_per_strip );
|
||||
printf( "rtiff_read_stripwise: header.read_strip_size = %zd\n",
|
||||
rtiff->header.read_strip_size );
|
||||
printf( "rtiff_read_stripwise: header.read_height = %u\n",
|
||||
rtiff->header.read_height );
|
||||
printf( "rtiff_read_stripwise: header.read_size = %zd\n",
|
||||
rtiff->header.read_size );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
/* Double check: in memcpy mode, the vips linesize should exactly
|
||||
@ -2007,7 +2007,7 @@ rtiff_read_stripwise( Rtiff *rtiff, VipsImage *out )
|
||||
else
|
||||
vips_line_size = VIPS_IMAGE_SIZEOF_LINE( t[0] );
|
||||
|
||||
if( vips_line_size != TIFFScanlineSize( rtiff->tiff ) ) {
|
||||
if( vips_line_size != rtiff->header.scanline_size ) {
|
||||
vips_error( "tiff2vips",
|
||||
"%s", _( "unsupported tiff image type" ) );
|
||||
return( -1 );
|
||||
@ -2022,7 +2022,7 @@ rtiff_read_stripwise( Rtiff *rtiff, VipsImage *out )
|
||||
*/
|
||||
if( rtiff->header.separate ) {
|
||||
if( !(rtiff->plane_buf = vips_malloc( VIPS_OBJECT( out ),
|
||||
rtiff->header.read_strip_size )) )
|
||||
rtiff->header.read_size )) )
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
@ -2039,7 +2039,7 @@ rtiff_read_stripwise( Rtiff *rtiff, VipsImage *out )
|
||||
rtiff->n > 1 ) {
|
||||
tsize_t size;
|
||||
|
||||
size = rtiff->header.read_strip_size;
|
||||
size = rtiff->header.read_size;
|
||||
if( rtiff->header.separate )
|
||||
size *= rtiff->header.samples_per_pixel;
|
||||
|
||||
@ -2056,7 +2056,7 @@ rtiff_read_stripwise( Rtiff *rtiff, VipsImage *out )
|
||||
NULL, rtiff_stripwise_generate, NULL,
|
||||
rtiff, NULL ) ||
|
||||
vips_sequential( t[0], &t[1],
|
||||
"tile_height", rtiff->header.read_rows_per_strip,
|
||||
"tile_height", rtiff->header.read_height,
|
||||
NULL ) ||
|
||||
rtiff_autorotate( rtiff, t[1], &t[2] ) ||
|
||||
rtiff_unpremultiply( rtiff, t[2], &t[3] ) ||
|
||||
@ -2153,14 +2153,15 @@ rtiff_header_read( Rtiff *rtiff, RtiffHeader *header )
|
||||
header->rows_per_strip = 0;
|
||||
header->strip_size = 0;
|
||||
header->number_of_strips = 0;
|
||||
header->read_rows_per_strip = 0;
|
||||
header->read_strip_size = 0;
|
||||
header->read_height = 0;
|
||||
header->read_size = 0;
|
||||
}
|
||||
else {
|
||||
if( !tfget32( rtiff->tiff,
|
||||
TIFFTAG_ROWSPERSTRIP, &header->rows_per_strip ) )
|
||||
return( -1 );
|
||||
header->strip_size = TIFFStripSize( rtiff->tiff );
|
||||
header->scanline_size = TIFFScanlineSize( rtiff->tiff );
|
||||
header->number_of_strips = TIFFNumberOfStrips( rtiff->tiff );
|
||||
|
||||
/* libtiff has two strip-wise readers. TIFFReadEncodedStrip()
|
||||
@ -2184,9 +2185,8 @@ rtiff_header_read( Rtiff *rtiff, RtiffHeader *header )
|
||||
header->photometric_interpretation !=
|
||||
PHOTOMETRIC_YCBCR ) {
|
||||
header->read_scanlinewise = TRUE;
|
||||
header->read_rows_per_strip = 1;
|
||||
header->read_strip_size =
|
||||
TIFFScanlineSize( rtiff->tiff );
|
||||
header->read_height = 1;
|
||||
header->read_size = rtiff->header.scanline_size;
|
||||
}
|
||||
else {
|
||||
header->read_scanlinewise = FALSE;
|
||||
@ -2197,11 +2197,9 @@ rtiff_header_read( Rtiff *rtiff, RtiffHeader *header )
|
||||
*
|
||||
* And it musn't be zero.
|
||||
*/
|
||||
header->read_rows_per_strip =
|
||||
VIPS_CLIP( 1,
|
||||
header->rows_per_strip,
|
||||
header->height );
|
||||
header->read_strip_size = header->strip_size;
|
||||
header->read_height = VIPS_CLIP( 1,
|
||||
header->rows_per_strip, header->height );
|
||||
header->read_size = header->strip_size;
|
||||
}
|
||||
|
||||
/* Stop some compiler warnings.
|
||||
@ -2240,8 +2238,8 @@ rtiff_header_equal( RtiffHeader *h1, RtiffHeader *h2 )
|
||||
return( 0 );
|
||||
}
|
||||
else {
|
||||
if( h1->read_rows_per_strip != h2->read_rows_per_strip ||
|
||||
h1->read_strip_size != h2->read_strip_size ||
|
||||
if( h1->read_height != h2->read_height ||
|
||||
h1->read_size != h2->read_size ||
|
||||
h1->number_of_strips != h2->number_of_strips )
|
||||
return( 0 );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user