| 2018 | /************************************************************************/ |
| 2019 | |
| 2020 | bool LIBERTIFFDataset::ProcessCompressionMethod() |
| 2021 | { |
| 2022 | if (m_image->compression() == LIBERTIFF_NS::Compression::PackBits) |
| 2023 | { |
| 2024 | GDALDataset::SetMetadataItem("COMPRESSION", "PACKBITS", |
| 2025 | "IMAGE_STRUCTURE"); |
| 2026 | } |
| 2027 | else if (m_image->compression() == LIBERTIFF_NS::Compression::Deflate || |
| 2028 | m_image->compression() == LIBERTIFF_NS::Compression::LegacyDeflate) |
| 2029 | { |
| 2030 | m_decompressor = CPLGetDecompressor("zlib"); |
| 2031 | GDALDataset::SetMetadataItem("COMPRESSION", "DEFLATE", |
| 2032 | "IMAGE_STRUCTURE"); |
| 2033 | } |
| 2034 | else if (m_image->compression() == LIBERTIFF_NS::Compression::ZSTD) |
| 2035 | { |
| 2036 | m_decompressor = CPLGetDecompressor("zstd"); |
| 2037 | if (!m_decompressor) |
| 2038 | { |
| 2039 | ReportError(CE_Failure, CPLE_NotSupported, |
| 2040 | "Compression = ZSTD unhandled because GDAL " |
| 2041 | "has not been built against libzstd"); |
| 2042 | return false; |
| 2043 | } |
| 2044 | GDALDataset::SetMetadataItem("COMPRESSION", "ZSTD", "IMAGE_STRUCTURE"); |
| 2045 | } |
| 2046 | else if (m_image->compression() == LIBERTIFF_NS::Compression::LZMA) |
| 2047 | { |
| 2048 | m_decompressor = CPLGetDecompressor("lzma"); |
| 2049 | if (!m_decompressor) |
| 2050 | { |
| 2051 | ReportError(CE_Failure, CPLE_NotSupported, |
| 2052 | "Compression = LZMA unhandled because GDAL " |
| 2053 | "has not been built against liblzma"); |
| 2054 | return false; |
| 2055 | } |
| 2056 | GDALDataset::SetMetadataItem("COMPRESSION", "LZMA", "IMAGE_STRUCTURE"); |
| 2057 | } |
| 2058 | else if (m_image->compression() == LIBERTIFF_NS::Compression::LZW) |
| 2059 | { |
| 2060 | GDALDataset::SetMetadataItem("COMPRESSION", "LZW", "IMAGE_STRUCTURE"); |
| 2061 | } |
| 2062 | else if (m_image->compression() == LIBERTIFF_NS::Compression::JPEG) |
| 2063 | { |
| 2064 | if (!GDALGetDriverByName("JPEG")) |
| 2065 | { |
| 2066 | ReportError( |
| 2067 | CE_Failure, CPLE_NotSupported, |
| 2068 | "Compression = JPEG not supported because JPEG driver missing"); |
| 2069 | return false; |
| 2070 | } |
| 2071 | if (m_image->photometricInterpretation() == |
| 2072 | LIBERTIFF_NS::PhotometricInterpretation::YCbCr && |
| 2073 | m_image->samplesPerPixel() == 3) |
| 2074 | { |
| 2075 | GDALDataset::SetMetadataItem("SOURCE_COLOR_SPACE", "YCbCr", |
| 2076 | "IMAGE_STRUCTURE"); |
| 2077 | GDALDataset::SetMetadataItem("COMPRESSION", "YCbCr JPEG", |
nothing calls this directly
no test coverage detected