MCPcopy Create free account
hub / github.com/OSGeo/gdal / ProcessCompressionMethod

Method ProcessCompressionMethod

frmts/libertiff/libertiffdataset.cpp:2020–2214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2018/************************************************************************/
2019
2020bool 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",

Callers

nothing calls this directly

Calls 7

CPLGetDecompressorFunction · 0.85
CPLDebugFunction · 0.85
ReportErrorFunction · 0.50
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected