Repository navigation
Conversation
The port's RawImageType has five formats piex's enum lacks, so every type after Dng has a higher number than in RawImageTypes, and the bridge passed those numbers to and from C++ unchanged. Translate through a table in RawImageTypes order, as C++ callers expect.
This was referenced Nov 4, 2026
Collaborator
|
Hey, this is a good find, but I think this is outdated after our latest export. Sorry about that. I'll close this for now, but feel free to reopen or open a new one if you find another instance like this in your next scan. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use piex's RawImageTypes numbers in the cxx bridge
Problem
RecognizeRawImageTypeLite,IsOfType,GetNumberOfBytesForIsOfType,IsRaw(type)andGetPreviewImageData'soutput_type(C++, Rust) pass apiex::image_type_recognition::RawImageTypesacross the API. The port's ownRawImageTypehas five formats piex's enum does not have (Erf, PhaseOne, Pxn, Raw3fr, Rdc), inserted in alphabetical order, so every value afterDngis shifted (from_u32). The bridge passes the port's numbers across unchanged, in both directions:*out_type = recognized as u32,raw_type as u32andrecognize_raw_image_type_lite(data) as u32, cast back withstatic_cast<RawImageTypes>;RawImageType::from_u32(raw_type)on the caller'sRawImageTypesvalue.For example:
GetPreviewImageDataon a NEFoutput_type10,kNefImagekNrwImageRecognizeRawImageTypeLiteon an RW2 header (MM\0U)kRw2ImageRawImageTypeshas no value forIsOfType(MM\0U, kRw2Image)GetNumberOfBytesForIsOfType(kOrfImage)EPSONin it (an ERF)RecognizeRawImageTypeLite0,kNonRawImage;IsRawfalsekKdcImage;IsRawtrueA caller that names or routes files by type (for example, a file browser that labels each one) shows a NEF as NRW, an ORF as PEF, a PEF as QTK and a RAF as SRW. The port's Phase One and RDC values read as a RAF and as no value at all.
Question
Which behaviour do we want: C++'s or the Rust port's? Specifically, should the bridge use piex's
RawImageTypesnumbers, and report ERF, 3FR, Phase One, PXN and RDC askNonRawImage(like the C++ library), or the port's ownRawImageTypenumbers (like the Rust port)?This PR implements C++'s behaviour.
Fix
This PR changes
rust/src/cxx_bridge.rsto follow piex's numbering:CXX_RAW_IMAGE_TYPESlists the port's types inRawImageTypesorder.to_cxxgives a type's index there, and 0 (kNonRawImage) for the five types the enum lacks.from_cxxgives the type at an index.rust_get_preview_image_datawritesto_cxxof the type (both writes),rust_recognize_raw_image_type_litereturns it, andrust_is_raw_type,rust_is_of_typeandrust_get_number_of_bytes_for_is_of_typeread the caller's value withfrom_cxx.IsRaw(stream)(5):rust_is_rawcounts a header as raw only when its type has a value in piex's enum, asIsRawLitedoes in C++.The examples above then return what C++ returns. Replayed before and after (x86-64):
output_type10 (also ORF 12, PEF 13, RAF 15)kSrwImage)IsRawfalse (same for 3FR, Phase One, PXN, RDC headers)IsRawtrue (19, 15, 16, 21)IsRawfalseNotes for review:
RawImageTypesvalues, which is a change to piex's API.IsRaw(type)for a value outside the enum is a separate difference (C++ asserts). Abort in IsRaw(type) for a value outside RawImageTypes, as C++ does #10 covers it. Both PRs changerust_is_raw_type, so whichever lands second needs a rebase.IsRaw(20)toIsRaw(24)go from true to false with this PR: 20 to 24 are the port's enumerators but not piex's. C++ asserts on them; Abort in IsRaw(type) for a value outside RawImageTypes, as C++ does #10 covers that.IsOfTypeandGetNumberOfBytesForIsOfTypefor them become false and 0, as in C++.