Skip to content

OpenEXR encoder: add capability to set the DWA compression level#22790

Merged
alalek merged 3 commits intoopencv:4.xfrom
reunanen:add-capability-to-set-DWA-compression-level-in-OpenEXR-encoding
Nov 11, 2022
Merged

OpenEXR encoder: add capability to set the DWA compression level#22790
alalek merged 3 commits intoopencv:4.xfrom
reunanen:add-capability-to-set-DWA-compression-level-in-OpenEXR-encoding

Conversation

@reunanen
Copy link
Copy Markdown
Contributor

extracted from #21324

(cherry picked from commit aa276ec)

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

}
if (params[i] == IMWRITE_EXR_DWA_COMPRESSION_LEVEL)
{
header.dwaCompressionLevel() = params[i + 1];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add compile-time version check here (through #if)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, added checks. DWA compression should be available since version 2.2, didn't realize that there may still be older versions out there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, looks like the setting itself is available only from version 3 on.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ok now.

@reunanen reunanen force-pushed the add-capability-to-set-DWA-compression-level-in-OpenEXR-encoding branch from 147b53e to 9494b9e Compare November 10, 2022 17:01
#if defined(OPENEXR_VERSION_MAJOR) && OPENEXR_VERSION_MAJOR >= 3
header.dwaCompressionLevel() = params[i + 1];
#elif defined(OPENEXR_VERSION_MAJOR)
throw std::runtime_error("Setting `IMWRITE_EXR_DWA_COMPRESSION_LEVEL` not supported in OpenEXR version " + std::to_string(OPENEXR_VERSION_MAJOR) + " (version 3 is required)");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw std::runtime_error

Lets use CV_LOG_ONCE_WARNING(NULL, "message"); instead to keep existed behavior for unknown/unsupported hints.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

@alalek alalek merged commit 1ba0984 into opencv:4.x Nov 11, 2022
@reunanen reunanen deleted the add-capability-to-set-DWA-compression-level-in-OpenEXR-encoding branch November 11, 2022 09:00
@alalek alalek mentioned this pull request Jan 8, 2023
a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
…WA-compression-level-in-OpenEXR-encoding

OpenEXR encoder: add capability to set the DWA compression level

* OpenEXR encoder: add capability to set the DWA compression level from outside

* Do not try to call `header.dwaCompressionLevel()` if OpenEXR is not version 3 or later

* Minor cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants