Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate compression method detection #1616

Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
851f42d
cmake generates relevant files to integrate all compression methods.
pleprince Jan 18, 2024
6ea5896
update utilities
pleprince Jan 18, 2024
616c443
fix gitignore
pleprince Jan 18, 2024
175efde
sanity check for gaps in enum ids.
pleprince Jan 19, 2024
28e6d7a
Use isValidCompressionId() instead of hard-coded test.
pleprince Jan 19, 2024
47dff96
generate ImfCRgbaFile.h
pleprince Jan 19, 2024
5e59339
move implementation to ImfCompression.cpp to hide CompressionDesc.
pleprince Jan 22, 2024
a2bae86
convert IdToDesc to a static array.
pleprince Jan 22, 2024
2757184
ImfCompressor.h was not correctly removed from the list.
pleprince Jan 22, 2024
35b4661
replace cmake_path() with string() if cmake version < 3.20.0. Flagged…
pleprince Jan 22, 2024
4e5c205
Only generate the files with option UPDATE_COMPRESSOR_LIST=ON.
pleprince Jan 22, 2024
43eed95
Fix incorrect defines.
pleprince Jan 23, 2024
ec4791f
Improve DO NOT EDIT messages.
pleprince Jan 23, 2024
85a86c9
Add new testCompressionApi test.
pleprince Jan 23, 2024
4b37dbf
Enable UPDATE_COMPRESSOR_LIST in ci_workflow.yml.
pleprince Jan 23, 2024
9e1eb81
Add missing ImfCompression.cpp to BUILD.bazel
pleprince Jan 23, 2024
b15ef90
Merge remote-tracking branch 'upstream/main' into Automate-compressio…
pleprince Jan 25, 2024
bd763ef
Remove cmake file generation but keep codec API and tests.
pleprince Feb 20, 2024
87fd8f6
Restore comments describing the codecs.
pleprince Feb 26, 2024
763e547
Move isValidCompression, isValidCompression, isValidDeepCompression f…
pleprince Feb 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ cc_library(
"src/lib/OpenEXR/ImfChromaticities.cpp",
"src/lib/OpenEXR/ImfChromaticitiesAttribute.cpp",
"src/lib/OpenEXR/ImfCompositeDeepScanLine.cpp",
"src/lib/OpenEXR/ImfCompression.cpp",
"src/lib/OpenEXR/ImfCompressionAttribute.cpp",
"src/lib/OpenEXR/ImfCompressor.cpp",
"src/lib/OpenEXR/ImfConvert.cpp",
Expand Down
45 changes: 6 additions & 39 deletions src/bin/exrenvmap/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false)

if (verbose)
{
std::string compressionNames;
getCompressionNamesString("/", compressionNames);

stream << "\n"
"Convert an OpenEXR latitude-longitude environment map\n"
"into a cube-face environment map or vice versa.\n"
Expand Down Expand Up @@ -119,7 +122,7 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false)
" -u sets level size rounding to ROUND_UP\n"
"\n"
" -z x sets the data compression method to x\n"
" (none/rle/zip/piz/pxr24/b44/b44a/dwaa/dwab,\n"
" (" << compressionNames.c_str() << ",\n"
" default is zip)\n"
"\n"
" -v verbose mode\n"
Expand All @@ -137,44 +140,8 @@ Compression
getCompression (const string& str)
{
Compression c;

if (str == "no" || str == "none" || str == "NO" || str == "NONE")
{
c = NO_COMPRESSION;
}
else if (str == "rle" || str == "RLE")
{
c = RLE_COMPRESSION;
}
else if (str == "zip" || str == "ZIP")
{
c = ZIP_COMPRESSION;
}
else if (str == "piz" || str == "PIZ")
{
c = PIZ_COMPRESSION;
}
else if (str == "pxr24" || str == "PXR24")
{
c = PXR24_COMPRESSION;
}
else if (str == "b44" || str == "B44")
{
c = B44_COMPRESSION;
}
else if (str == "b44a" || str == "B44A")
{
c = B44A_COMPRESSION;
}
else if (str == "dwaa" || str == "DWAA")
{
c = DWAA_COMPRESSION;
}
else if (str == "dwab" || str == "DWAB")
{
c = DWAB_COMPRESSION;
}
else
getCompressionIdFromName (str, c);
if (c == Compression::NUM_COMPRESSION_METHODS)
{
std::stringstream e;
e << "Unknown compression method \"" << str << "\"";
Expand Down
27 changes: 3 additions & 24 deletions src/bin/exrheader/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,9 @@ using namespace std;
void
printCompression (Compression c)
{
switch (c)
{
case NO_COMPRESSION: cout << "none"; break;

case RLE_COMPRESSION: cout << "run-length encoding"; break;

case ZIPS_COMPRESSION: cout << "zip, individual scanlines"; break;

case ZIP_COMPRESSION: cout << "zip, multi-scanline blocks"; break;

case PIZ_COMPRESSION: cout << "piz"; break;

case PXR24_COMPRESSION: cout << "pxr24"; break;

case B44_COMPRESSION: cout << "b44"; break;

case B44A_COMPRESSION: cout << "b44a"; break;

case DWAA_COMPRESSION: cout << "dwa, small scanline blocks"; break;

case DWAB_COMPRESSION: cout << "dwa, medium scanline blocks"; break;

default: cout << int (c); break;
}
std::string desc;
getCompressionDescriptionFromId(c, desc);
cout << desc.c_str();
}

void
Expand Down
45 changes: 6 additions & 39 deletions src/bin/exrmaketiled/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false)

if (verbose)
{
std::string compressionNames;
getCompressionNamesString("/", compressionNames);

stream << "\n"
"Read an OpenEXR image from infile, produce a tiled\n"
"version of the image, and save the result in outfile.\n"
Expand Down Expand Up @@ -71,7 +74,7 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false)
" -u sets level size rounding to ROUND_UP\n"
"\n"
" -z x sets the data compression method to x\n"
" (none/rle/zip/piz/pxr24/b44/b44a/dwaa/dwab,\n"
" (" << compressionNames.c_str() << ",\n"
" default is zip)\n"
"\n"
" -v verbose mode\n"
Expand All @@ -93,44 +96,8 @@ Compression
getCompression (const string& str)
{
Compression c;

if (str == "no" || str == "none" || str == "NO" || str == "NONE")
{
c = NO_COMPRESSION;
}
else if (str == "rle" || str == "RLE")
{
c = RLE_COMPRESSION;
}
else if (str == "zip" || str == "ZIP")
{
c = ZIP_COMPRESSION;
}
else if (str == "piz" || str == "PIZ")
{
c = PIZ_COMPRESSION;
}
else if (str == "pxr24" || str == "PXR24")
{
c = PXR24_COMPRESSION;
}
else if (str == "b44" || str == "B44")
{
c = B44_COMPRESSION;
}
else if (str == "b44a" || str == "B44A")
{
c = B44A_COMPRESSION;
}
else if (str == "dwaa" || str == "DWAA")
{
c = DWAA_COMPRESSION;
}
else if (str == "dwab" || str == "DWAB")
{
c = DWAB_COMPRESSION;
}
else
getCompressionIdFromName (str, c);
if (c == Compression::NUM_COMPRESSION_METHODS)
{
std::stringstream e;
e << "Unknown compression method \"" << str << "\"";
Expand Down
47 changes: 8 additions & 39 deletions src/bin/exrmultiview/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false)
stream << "Usage: " << program_name << " [options] viewname1 infile1 viewname2 infile2 ... outfile" << endl;

if (verbose)
{
std::string compressionNames;
getCompressionNamesString("/", compressionNames);

stream << "\n"
"Combine two or more single-view OpenEXR image files into\n"
"a single multi-view image file. On the command line,\n"
Expand All @@ -51,7 +55,7 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false)
"Options:\n"
"\n"
" -z x sets the data compression method to x\n"
" (none/rle/zip/piz/pxr24/b44/b44a/dwaa/dwab,\n"
" (" << compressionNames.c_str() << ",\n"
" default is piz)\n"
"\n"
" -v verbose mode\n"
Expand All @@ -62,50 +66,15 @@ usageMessage (ostream& stream, const char* program_name, bool verbose = false)
"\n"
"Report bugs via https://github.com/AcademySoftwareFoundation/openexr/issues or email [email protected]\n"
"";
}
}

Compression
getCompression (const string& str)
{
Compression c;

if (str == "no" || str == "none" || str == "NO" || str == "NONE")
{
c = NO_COMPRESSION;
}
else if (str == "rle" || str == "RLE")
{
c = RLE_COMPRESSION;
}
else if (str == "zip" || str == "ZIP")
{
c = ZIP_COMPRESSION;
}
else if (str == "piz" || str == "PIZ")
{
c = PIZ_COMPRESSION;
}
else if (str == "pxr24" || str == "PXR24")
{
c = PXR24_COMPRESSION;
}
else if (str == "b44" || str == "B44")
{
c = B44_COMPRESSION;
}
else if (str == "b44a" || str == "B44A")
{
c = B44A_COMPRESSION;
}
else if (str == "dwaa" || str == "DWAA")
{
c = DWAA_COMPRESSION;
}
else if (str == "dwab" || str == "DWAB")
{
c = DWAB_COMPRESSION;
}
else
getCompressionIdFromName (str, c);
if (c == Compression::NUM_COMPRESSION_METHODS)
{
std::stringstream e;
e << "Unknown compression method \"" << str << "\"";
Expand Down
2 changes: 2 additions & 0 deletions src/lib/OpenEXR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ openexr_define_library(OpenEXR
ImfAutoArray.h
ImfB44Compressor.h
ImfCheckedArithmetic.h
ImfCompression.h
ImfCompressor.h
ImfDwaCompressor.h
ImfDwaCompressorSimd.h
Expand Down Expand Up @@ -42,6 +43,7 @@ openexr_define_library(OpenEXR
ImfCompositeDeepScanLine.cpp
ImfCompressionAttribute.cpp
ImfCompressor.cpp
ImfCompression.cpp
ImfConvert.cpp
ImfCRgbaFile.cpp
ImfDeepCompositing.cpp
Expand Down
4 changes: 2 additions & 2 deletions src/lib/OpenEXR/ImfB44Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class B44Compressor : public Compressor

virtual ~B44Compressor ();

B44Compressor (const B44Compressor& other) = delete;
B44Compressor (const B44Compressor& other) = delete;
B44Compressor& operator= (const B44Compressor& other) = delete;
B44Compressor (B44Compressor&& other) = delete;
B44Compressor& operator= (B44Compressor&& other) = delete;
B44Compressor& operator= (B44Compressor&& other) = delete;

virtual int numScanLines () const;

Expand Down
1 change: 1 addition & 0 deletions src/lib/OpenEXR/ImfCRgbaFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ typedef struct ImfRgba ImfRgba;
#define IMF_B44A_COMPRESSION 7
#define IMF_DWAA_COMPRESSION 8
#define IMF_DWAB_COMPRESSION 9
#define IMF_NUM_COMPRESSION_METHODS 10

/*
** Channels; values must be the same as in Imf::RgbaChannels.
Expand Down
Loading