diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c index 820a2544..afd7cb6e 100644 --- a/libtiff/tif_strip.c +++ b/libtiff/tif_strip.c @@ -287,7 +287,17 @@ uint64_t TIFFScanlineSize64(TIFF *tif) else { uint64_t scanline_samples; - scanline_samples = _TIFFMultiply64(tif, td->td_imagewidth, + uint32_t scanlinewidth = td->td_imagewidth; + + if (td->td_photometric == PHOTOMETRIC_YCBCR) + { + uint16_t SubsamplingHor, SubsamplingVer; + TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &SubsamplingHor, &SubsamplingVer); + if (SubsamplingHor > 1) // roundup width for YCbCr + scanlinewidth = TIFFroundup_32(scanlinewidth, SubsamplingHor); + } + + scanline_samples = _TIFFMultiply64(tif, scanlinewidth, td->td_samplesperpixel, module); scanline_size = TIFFhowmany_64(_TIFFMultiply64(tif, scanline_samples,