mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 09:25:45 +08:00
Merge pull request #25447 from vrabaud:tiff
Remove unnecessary FIXIT section in grfmt_tiff.cpp #25447 No int64/uint64 is used in the code anymore. grfmt_tiff.hpp includes the tiff.h header inside of the tiff_dummy_namespace declaration. One implication of this is that all namespaced declarations made in tiff.h become qualified with tiff_dummy_namespace::. Because tiff.h includes standard library headers, the std namespace declarations are converted to tiff_dummy_namespace::std declarations. Subsequently, grfmt_tiff.hpp declares using namespace tiff_dummy_namespace;. This can lead to an ambiguity error during the resolution of the std namespace. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work
This commit is contained in:
parent
882f46e1d3
commit
fc5eb101bf
@ -53,22 +53,8 @@
|
||||
#include "grfmt_tiff.hpp"
|
||||
#include <limits>
|
||||
|
||||
// TODO FIXIT Conflict declarations for common types like int64/uint64
|
||||
namespace tiff_dummy_namespace {
|
||||
#include "tiff.h"
|
||||
#include "tiffio.h"
|
||||
}
|
||||
using namespace tiff_dummy_namespace;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
namespace numeric_types = tiff_dummy_namespace;
|
||||
#else
|
||||
#include <cstdint>
|
||||
namespace numeric_types {
|
||||
using uint16 = std::uint16_t;
|
||||
using uint32 = std::uint32_t;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@ -274,8 +260,8 @@ bool TiffDecoder::readHeader()
|
||||
|
||||
if (tif)
|
||||
{
|
||||
numeric_types::uint32 wdth = 0, hght = 0;
|
||||
numeric_types::uint16 photometric = 0;
|
||||
uint32_t wdth = 0, hght = 0;
|
||||
uint16_t photometric = 0;
|
||||
|
||||
CV_TIFF_CHECK_CALL(TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &wdth));
|
||||
CV_TIFF_CHECK_CALL(TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &hght));
|
||||
@ -283,7 +269,7 @@ bool TiffDecoder::readHeader()
|
||||
|
||||
{
|
||||
bool isGrayScale = photometric == PHOTOMETRIC_MINISWHITE || photometric == PHOTOMETRIC_MINISBLACK;
|
||||
numeric_types::uint16 bpp = 8, ncn = isGrayScale ? 1 : 3;
|
||||
uint16_t bpp = 8, ncn = isGrayScale ? 1 : 3;
|
||||
if (0 == TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bpp))
|
||||
{
|
||||
// TIFF bi-level images don't require TIFFTAG_BITSPERSAMPLE tag
|
||||
@ -306,7 +292,7 @@ bool TiffDecoder::readHeader()
|
||||
(ncn != 1 && ncn != 3 && ncn != 4)))
|
||||
bpp = 8;
|
||||
|
||||
numeric_types::uint16 sample_format = SAMPLEFORMAT_UINT;
|
||||
uint16_t sample_format = SAMPLEFORMAT_UINT;
|
||||
TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &sample_format);
|
||||
int wanted_channels = normalizeChannelsNumber(ncn);
|
||||
switch (bpp)
|
||||
@ -388,7 +374,7 @@ bool TiffDecoder::nextPage()
|
||||
readHeader();
|
||||
}
|
||||
|
||||
static void fixOrientationPartial(Mat &img, numeric_types::uint16 orientation)
|
||||
static void fixOrientationPartial(Mat &img, uint16_t orientation)
|
||||
{
|
||||
switch(orientation) {
|
||||
case ORIENTATION_RIGHTTOP:
|
||||
@ -444,7 +430,7 @@ static void fixOrientationFull(Mat &img, int orientation)
|
||||
* For 8 bit some corrections are done by TIFFReadRGBAStrip/Tile already.
|
||||
* Not so for 16/32/64 bit.
|
||||
*/
|
||||
static void fixOrientation(Mat &img, numeric_types::uint16 orientation, bool isOrientationFull)
|
||||
static void fixOrientation(Mat &img, uint16_t orientation, bool isOrientationFull)
|
||||
{
|
||||
if( isOrientationFull )
|
||||
{
|
||||
@ -605,7 +591,7 @@ bool TiffDecoder::readData( Mat& img )
|
||||
CV_Assert(!m_tif.empty());
|
||||
TIFF* tif = (TIFF*)m_tif.get();
|
||||
|
||||
numeric_types::uint16 photometric = (numeric_types::uint16)-1;
|
||||
uint16_t photometric = (uint16_t)-1;
|
||||
CV_TIFF_CHECK_CALL(TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric));
|
||||
|
||||
if (m_hdr && depth >= CV_32F)
|
||||
@ -621,14 +607,14 @@ bool TiffDecoder::readData( Mat& img )
|
||||
{
|
||||
int is_tiled = TIFFIsTiled(tif) != 0;
|
||||
bool isGrayScale = photometric == PHOTOMETRIC_MINISWHITE || photometric == PHOTOMETRIC_MINISBLACK;
|
||||
numeric_types::uint16 bpp = 8, ncn = isGrayScale ? 1 : 3;
|
||||
uint16_t bpp = 8, ncn = isGrayScale ? 1 : 3;
|
||||
if (0 == TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bpp))
|
||||
{
|
||||
// TIFF bi-level images don't require TIFFTAG_BITSPERSAMPLE tag
|
||||
bpp = 1;
|
||||
}
|
||||
CV_TIFF_CHECK_CALL_DEBUG(TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &ncn));
|
||||
numeric_types::uint16 img_orientation = ORIENTATION_TOPLEFT;
|
||||
uint16_t img_orientation = ORIENTATION_TOPLEFT;
|
||||
CV_TIFF_CHECK_CALL_DEBUG(TIFFGetField(tif, TIFFTAG_ORIENTATION, &img_orientation));
|
||||
constexpr const int bitsPerByte = 8;
|
||||
int dst_bpp = (int)(img.elemSize1() * bitsPerByte);
|
||||
@ -638,7 +624,7 @@ bool TiffDecoder::readData( Mat& img )
|
||||
int wanted_channels = normalizeChannelsNumber(img.channels());
|
||||
bool doReadScanline = false;
|
||||
|
||||
numeric_types::uint32 tile_width0 = m_width, tile_height0 = 0;
|
||||
uint32_t tile_width0 = m_width, tile_height0 = 0;
|
||||
|
||||
if (is_tiled)
|
||||
{
|
||||
@ -656,7 +642,7 @@ bool TiffDecoder::readData( Mat& img )
|
||||
tile_width0 = m_width;
|
||||
|
||||
if (tile_height0 == 0 ||
|
||||
(!is_tiled && tile_height0 == std::numeric_limits<numeric_types::uint32>::max()) )
|
||||
(!is_tiled && tile_height0 == std::numeric_limits<uint32_t>::max()) )
|
||||
tile_height0 = m_height;
|
||||
|
||||
const int TILE_MAX_WIDTH = (1 << 24);
|
||||
@ -681,7 +667,7 @@ bool TiffDecoder::readData( Mat& img )
|
||||
( (uint64_t) MAX_TILE_SIZE * 95 / 100)
|
||||
)
|
||||
{
|
||||
uint16_t planerConfig = (numeric_types::uint16)-1;
|
||||
uint16_t planerConfig = (uint16_t)-1;
|
||||
CV_TIFF_CHECK_CALL(TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planerConfig));
|
||||
|
||||
doReadScanline = (!is_tiled) // no tile
|
||||
@ -737,7 +723,7 @@ bool TiffDecoder::readData( Mat& img )
|
||||
MAX_TILE_SIZE * 95 / 100
|
||||
)
|
||||
{
|
||||
uint16_t planerConfig = (numeric_types::uint16)-1;
|
||||
uint16_t planerConfig = (uint16_t)-1;
|
||||
CV_TIFF_CHECK_CALL(TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planerConfig));
|
||||
|
||||
doReadScanline = (!is_tiled) // no tile
|
||||
@ -821,7 +807,7 @@ bool TiffDecoder::readData( Mat& img )
|
||||
uchar* bstart = src_buffer;
|
||||
if (doReadScanline)
|
||||
{
|
||||
CV_TIFF_CHECK_CALL((int)TIFFReadScanline(tif, (numeric_types::uint32*)src_buffer, y) >= 0);
|
||||
CV_TIFF_CHECK_CALL((int)TIFFReadScanline(tif, (uint32_t*)src_buffer, y) >= 0);
|
||||
|
||||
if ( isNeedConvert16to8 )
|
||||
{
|
||||
@ -843,11 +829,11 @@ bool TiffDecoder::readData( Mat& img )
|
||||
}
|
||||
else if (!is_tiled)
|
||||
{
|
||||
CV_TIFF_CHECK_CALL(TIFFReadRGBAStrip(tif, y, (numeric_types::uint32*)src_buffer));
|
||||
CV_TIFF_CHECK_CALL(TIFFReadRGBAStrip(tif, y, (uint32_t*)src_buffer));
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_TIFF_CHECK_CALL(TIFFReadRGBATile(tif, x, y, (numeric_types::uint32*)src_buffer));
|
||||
CV_TIFF_CHECK_CALL(TIFFReadRGBATile(tif, x, y, (uint32_t*)src_buffer));
|
||||
// Tiles fill the buffer from the bottom up
|
||||
bstart += (tile_height0 - tile_height) * tile_width0 * 4;
|
||||
}
|
||||
@ -941,15 +927,15 @@ bool TiffDecoder::readData( Mat& img )
|
||||
{
|
||||
if (doReadScanline)
|
||||
{
|
||||
CV_TIFF_CHECK_CALL((int)TIFFReadScanline(tif, (numeric_types::uint32*)src_buffer, y) >= 0);
|
||||
CV_TIFF_CHECK_CALL((int)TIFFReadScanline(tif, (uint32_t*)src_buffer, y) >= 0);
|
||||
}
|
||||
else if (!is_tiled)
|
||||
{
|
||||
CV_TIFF_CHECK_CALL((int)TIFFReadEncodedStrip(tif, tileidx, (numeric_types::uint32*)src_buffer, src_buffer_size) >= 0);
|
||||
CV_TIFF_CHECK_CALL((int)TIFFReadEncodedStrip(tif, tileidx, (uint32_t*)src_buffer, src_buffer_size) >= 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_TIFF_CHECK_CALL((int)TIFFReadEncodedTile(tif, tileidx, (numeric_types::uint32*)src_buffer, src_buffer_size) >= 0);
|
||||
CV_TIFF_CHECK_CALL((int)TIFFReadEncodedTile(tif, tileidx, (uint32_t*)src_buffer, src_buffer_size) >= 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < tile_height; i++)
|
||||
@ -1266,7 +1252,7 @@ bool TiffEncoder::writeLibTiff( const std::vector<Mat>& img_vec, const std::vect
|
||||
int page_compression = compression;
|
||||
|
||||
int bitsPerChannel = -1;
|
||||
numeric_types::uint16 sample_format = SAMPLEFORMAT_INT;
|
||||
uint16_t sample_format = SAMPLEFORMAT_INT;
|
||||
switch (depth)
|
||||
{
|
||||
case CV_8U:
|
||||
|
Loading…
Reference in New Issue
Block a user