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

Remove some dead code when writing #1592

Merged
merged 2 commits into from
Dec 10, 2023

Conversation

kingsawyer
Copy link
Contributor

@kingsawyer kingsawyer commented Nov 10, 2023

The file version is set to 2 above for writing files, so it is impossible to take the first branch and write version 1 style. If people are interested in how older versions wrote they can look in history of ImfDwaCompressor.cpp or look at the read code.

the version is set to 2 above, so it is impossible to take the first branch.

Signed-off-by: Dave Sawyer <kingsawyer@gmail.com>
Copy link

linux-foundation-easycla bot commented Nov 10, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@lgritz
Copy link
Contributor

lgritz commented Nov 11, 2023

Just to make sure I understand here... this code is specific to DWA compression, which is only a file version 2 feature, so that's why we can eliminate all the "version 1" clauses?

@peterhillman
Copy link
Contributor

@lgritz it's not the version of OpenEXR library, or the general file format version. It's related to #119, where the internal DWA structure was changed and a version field bumped. The uncompress code supports the old DWAv1 compression format, but the unreachable code to write version 1 seems unnecessary. If anyone needed to write a DWAv1 file they could still change one line in the C++ library and use that.
@meshula I believe the sLegacyChannelRules is still required if a DWAv1 file needs to be read, as it looks like it's also used by the uncompress code

@meshula
Copy link
Contributor

meshula commented Nov 12, 2023

Oh, maybe I didn't grep outside of the OpenEXRCore folder.

@kingsawyer
Copy link
Contributor Author

@lgritz This is purely localized reasoning. The code is unreachable because the conditional is a constant value.

@lgritz
Copy link
Contributor

lgritz commented Nov 15, 2023

@kingsawyer Yes, but the subtext of my question was "are we satisfied that the assignment of that constant is not itself a bug."

@kingsawyer kingsawyer changed the title Remove some dead code Remove some dead code when writing Nov 15, 2023
@kingsawyer
Copy link
Contributor Author

@meshula Can you please reconsider your request as it would break v1 support?

@kingsawyer
Copy link
Contributor Author

@meshula Hello Nick?

@meshula
Copy link
Contributor

meshula commented Dec 5, 2023

Ah, I should have marked the question as resolved, since it was answered in the following discussion. @lgritz @peterhillman Any further comment?

@lgritz
Copy link
Contributor

lgritz commented Dec 5, 2023

Fine with me. My understanding is that this code only comes into play with DWA compression, and therefore MUST be a v2 file.

@peterhillman
Copy link
Contributor

Well, it's v2 of DWA, not the OpenEXR file version, so the modification to the comment is rather misleading.
Some DWAv1 files (created before #119 was merged) might still exist in the wild. The decompression code will still handle those files after this change. The C++ implementation can still be trivially modified to generate DWAv1 compression, but that code is likely to disappear when the C++ library switches to decompressing using OpenEXRCore.

I'm fine with this too, but I would suggest leaving a comment in the code stating that DWAv1 set me->_channelRules to sLegacyChannelRules. That would satisfy any code archeologists wanting to unpick the history. It would also help anybody wanting to modify the code to generate a new DWAv1 file for testing the decompressor.

Signed-off-by: Dave Sawyer <kingsawyer@gmail.com>
@kingsawyer
Copy link
Contributor Author

Updated to say DWA v2, but I don't think current code should talk much or at all about how obsolete code worked (or didn't). Easy enough to go back in the file history to see what it did. The vast majority will not care about implementation details of bygone days.

@peterhillman
Copy link
Contributor

Thanks for contributing the original PR and for this update. That's a clearer comment now. An extra few words in that comment block noting how to generate DWAv1 would be useful because the code still supports decompressing DWAv1 files, which means it's not quite obsolete. It may be confusing that the compressor has no trace of how to generate a file that would trigger the v1 branch in the decompressor. The full history of DWA compression isn't in this file, it's in ImfDwaCompressor.cpp (which I'd forgotten might be removed later), so git blame doesn't really help.

@kingsawyer
Copy link
Contributor Author

Updated the check-in comment to point to ImfDwaCompressor.cpp for history. That should be a good third path to finding the deleted code in case people don't want to look at the read code or sync the repo to an older hash. I don't think it's confusing that we write the latest format and read any of the old formats. It's how most any file format read/write works that wants to support backwards compatibility.

@meshula
Copy link
Contributor

meshula commented Dec 10, 2023

I think that's good, thanks

@meshula meshula merged commit 9be75dc into AcademySoftwareFoundation:main Dec 10, 2023
29 checks passed
cary-ilm pushed a commit to cary-ilm/openexr that referenced this pull request Feb 13, 2024
The file version is set to 2 above for writing files (it is impossible write version 1 data). Please refer to the history of history of ImfDwaCompressor.cpp or look at the reading code for details on the version 1 format.

Signed-off-by: Dave Sawyer <kingsawyer@gmail.com>
cary-ilm pushed a commit that referenced this pull request Feb 16, 2024
The file version is set to 2 above for writing files (it is impossible write version 1 data). Please refer to the history of history of ImfDwaCompressor.cpp or look at the reading code for details on the version 1 format.

Signed-off-by: Dave Sawyer <kingsawyer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants