windowscodecs: Avoid redundant checks when reading a TIFF tile.
Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru> Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ea6118e9b7
commit
493fbabb85
@ -974,34 +974,25 @@ static HRESULT WINAPI TiffFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
|
|||||||
|
|
||||||
static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT tile_y)
|
static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT tile_y)
|
||||||
{
|
{
|
||||||
HRESULT hr=S_OK;
|
|
||||||
tsize_t ret;
|
tsize_t ret;
|
||||||
int swap_bytes;
|
int swap_bytes;
|
||||||
|
|
||||||
swap_bytes = pTIFFIsByteSwapped(This->parent->tiff);
|
swap_bytes = pTIFFIsByteSwapped(This->parent->tiff);
|
||||||
|
|
||||||
ret = pTIFFSetDirectory(This->parent->tiff, This->index);
|
ret = pTIFFSetDirectory(This->parent->tiff, This->index);
|
||||||
|
if (ret == -1)
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
if (This->decode_info.tiled)
|
||||||
|
ret = pTIFFReadEncodedTile(This->parent->tiff, tile_x + tile_y * This->decode_info.tiles_across, This->cached_tile, This->decode_info.tile_size);
|
||||||
|
else
|
||||||
|
ret = pTIFFReadEncodedStrip(This->parent->tiff, tile_y, This->cached_tile, This->decode_info.tile_size);
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
hr = E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
if (hr == S_OK)
|
|
||||||
{
|
|
||||||
if (This->decode_info.tiled)
|
|
||||||
{
|
|
||||||
ret = pTIFFReadEncodedTile(This->parent->tiff, tile_x + tile_y * This->decode_info.tiles_across, This->cached_tile, This->decode_info.tile_size);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = pTIFFReadEncodedStrip(This->parent->tiff, tile_y, This->cached_tile, This->decode_info.tile_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ret == -1)
|
|
||||||
hr = E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 8bpp grayscale with extra alpha */
|
/* 8bpp grayscale with extra alpha */
|
||||||
if (hr == S_OK && This->decode_info.source_bpp == 16 && This->decode_info.samples == 2 && This->decode_info.bpp == 32)
|
if (This->decode_info.source_bpp == 16 && This->decode_info.samples == 2 && This->decode_info.bpp == 32)
|
||||||
{
|
{
|
||||||
BYTE *src;
|
BYTE *src;
|
||||||
DWORD *dst, count = This->decode_info.tile_width * This->decode_info.tile_height;
|
DWORD *dst, count = This->decode_info.tile_width * This->decode_info.tile_height;
|
||||||
@ -1016,7 +1007,7 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hr == S_OK && This->decode_info.reverse_bgr)
|
if (This->decode_info.reverse_bgr)
|
||||||
{
|
{
|
||||||
if (This->decode_info.bps == 8)
|
if (This->decode_info.bps == 8)
|
||||||
{
|
{
|
||||||
@ -1027,7 +1018,7 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hr == S_OK && swap_bytes && This->decode_info.bps > 8)
|
if (swap_bytes && This->decode_info.bps > 8)
|
||||||
{
|
{
|
||||||
UINT row, i, samples_per_row;
|
UINT row, i, samples_per_row;
|
||||||
BYTE *sample, temp;
|
BYTE *sample, temp;
|
||||||
@ -1055,7 +1046,7 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hr == S_OK && This->decode_info.invert_grayscale)
|
if (This->decode_info.invert_grayscale)
|
||||||
{
|
{
|
||||||
BYTE *byte, *end;
|
BYTE *byte, *end;
|
||||||
|
|
||||||
@ -1071,13 +1062,10 @@ static HRESULT TiffFrameDecode_ReadTile(TiffFrameDecode *This, UINT tile_x, UINT
|
|||||||
*byte = ~(*byte);
|
*byte = ~(*byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hr == S_OK)
|
This->cached_tile_x = tile_x;
|
||||||
{
|
This->cached_tile_y = tile_y;
|
||||||
This->cached_tile_x = tile_x;
|
|
||||||
This->cached_tile_y = tile_y;
|
|
||||||
}
|
|
||||||
|
|
||||||
return hr;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
|
static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user