fix(sony): don't emit a bogus InternalBodySerial for the A7 V - #3
Merged
narrative-donc merged 1 commit intoAug 24, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts Sony maker-note parsing to avoid emitting an invalid, frame-varying InternalBodySerial for Sony ILCE-7M5 (A7 V) and ILCE-7RM6 (A7R VI) when the 0x9050 block does not match the expected Tag9050d signature.
Changes:
- Add an early-return gate in
process_Sony_0x9050()for ILCE-7M5/7RM6 when the first five raw bytes of the0x9050block are not all zero (signature absent). - Prevent downstream decoding of other
Tag9050dfields from the same block in that unsupported/encrypted variant (consistent with the stated intent to avoid emitting garbage).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
narrative-donc
marked this pull request as ready for review
August 23, 2026 22:51
narrative-donc
force-pushed
the
fix/sony-a7v-internal-serial
branch
from
August 23, 2026 23:11
22aa670 to
03cb8c9
Compare
narrative-donc
marked this pull request as draft
August 23, 2026 23:11
The ILCE-7M5 is routed to the Tag9050d layout, which reads InternalBodySerial
from six bytes at offset 0x38 of the 0x9050 block. Those bytes are not a body
serial on this camera: the value changes from frame to frame, so anything
keying on camera identity sees every frame as a different body. It split a
2-second burst into twelve separate groups in a scene-clustering consumer.
Measured across two bodies and both shipped firmwares:
- v1.01, one 12-frame burst: twelve distinct values (191100288e43,
180010000028, 44100000002, ...). Zero of the 256 raw bytes of the block
are constant across the burst, so no offset in it holds a body serial for
these files. The block does not carry the layout's five-zero-byte prefix
and nothing else in it decodes either - SonyFNumber reads as 57511365
against a real f/2.8, ShutterCount ranges 320..8683552 within the burst.
- v1.00, one session: three distinct values (2cff0000b108, e1fe0000e908,
37ff0000b908). Here the block does carry the prefix and its other fields
decode correctly, but the six bytes at 0x38 still move between frames -
they read XX ff 00 00 YY 08, a counter rather than an identity.
So the field is wrong on v1.01 because the whole block is a different format,
and wrong on v1.00 because 0x38 was never the serial. Exclude the camera from
this read, in the same way the 9050a branch already excludes the NEX-5N, NEX-7
and NEX-VG20.
Bodies that do have an identity report it in EXIF BodySerialNumber, which is
read elsewhere: the v1.00 samples keep BodySerial 02052278 with this change.
Scoped to the serial read alone, so CurAp, LensMount, LensType2 and
ImageCount3 continue to decode from the block on firmwares where it is valid.
Verified: InternalBodySerial is now empty on all 23 A7 V files across both
bodies, BodySerial 02052278 is preserved on the six samples that carry it,
and lens/aperture/ISO still decode on v1.00. Canon 5D Mark IV, 250D, 7D,
Nikon D5100, Fuji X20 and DSLR-A390 fixtures are unchanged.
The ILCE-7RM6 shares the Tag9050d routing and may well have the same problem,
but is not excluded here - no sample was available to test it.
narrative-donc
force-pushed
the
fix/sony-a7v-internal-serial
branch
from
August 23, 2026 23:13
03cb8c9 to
777e105
Compare
narrative-donc
marked this pull request as ready for review
August 23, 2026 23:46
narrative-donc
marked this pull request as draft
August 24, 2026 00:01
narrative-donc
marked this pull request as ready for review
August 24, 2026 00:05
puzza007
approved these changes
Aug 24, 2026
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.
Stack
Sony A7 V metadata — this PR targets #2, which carries the A7 V / A7R VI camera support it depends on.
InternalBodySerialread ← this PRRetarget to
masterif #2 lands first.Problem
Every frame from a single Sony A7 V reports a different camera body serial. A 12-frame burst from one camera yields twelve distinct serials:
A body serial is constant by definition, so anything keying on camera identity breaks. This surfaced in a scene-clustering consumer that partitions by camera: a 2-second burst that should form one scene was split into twelve, because each frame looked like a different camera.
Root cause
SonyID_ILCE_7M5is routed to theTag9050dlayout, which readsInternalBodySerialfrom six bytes at offset0x38of the0x9050block. Those bytes are not a body serial on this camera.Measured across two bodies and both shipped firmwares:
Firmware v1.01 — 12-frame burst, twelve distinct values. The whole block is a different format here: it lacks the five-zero-byte prefix the
Tag9050dlayout carries, and nothing in it decodes.SonyFNumberreads 57511365 against a real f/2.8;ShutterCountranges 320..8683552 within a two-second burst. Zero of the 256 raw (pre-decipher) bytes are constant across the burst — and since Sony's obfuscation is a fixed byte-substitution permutation, a constant plaintext byte must give a constant ciphertext byte. So no offset in the block holds a body serial for these files.Firmware v1.00 — 11 samples from a second body. Here the block does carry the prefix and its other fields decode correctly (lens, aperture, ISO all match EXIF). But the six bytes at
0x38still move between frames — three distinct values across a single session:sony_a7_v_012cff0000b108sony_a7_v_10e1fe0000e908sony_a7_v_20/30/4037ff0000b908The shape is always
XX ff 00 00 YY 08— a counter, not an identity.So the field is wrong on v1.01 because the whole block is a different format, and wrong on v1.00 because
0x38was never the serial there either.Corroborating: exiftool reports
InternalSerialNumber: 00000000for all 11 v1.00 samples — it reads a different field and finds nothing.Fix
Exclude the camera from this read, matching the existing idiom in the
9050abranch, which already excludes the NEX-5N, NEX-7 and NEX-VG20 from its ownInternalBodySerialread.Scoped to the serial read alone, not the whole block parse: on v1.00 the rest of
0x9050decodes correctly, soCurAp,LensMount,LensType2andImageCount3should keep working.Bodies that do have an identity report it in EXIF
BodySerialNumber, which is read elsewhere and is unaffected — the v1.00 samples keepBodySerial 02052278.Verification
Built the library and ran it against 23 A7 V files from two bodies.
InternalBodySerialnow empty on all 23, across both firmwares.BodySerial 02052278preserved on the six v1.00 samples that carry it.FE 50-150mm F2 GM, f/5.0, ISO 50).modelstill correctlyILCE-7M5throughout.No regressions on the other fixtures: Canon 5D Mark IV (
025021000537), EOS 250D (042070001554), EOS 7D (1130703009), Nikon D5100 (6137104) body serials unchanged; Fuji X20's internal serial preserved; DSLR-A390 ARW unchanged.Caveats
Tag9050drouting, so it was the obvious candidate to include — but two frames from one A7R VI body, 6.5 hours apart on firmware v1.01, both report49ff00006809. Stable, unlike the A7 V, so it is left alone. (Two files from one body show the value is stable, not that it is genuinely a serial — a model-wide constant would look the same. A second body would settle it.) The ILCE-7RM5 was also checked out of interest: two frames 20 days apart both reportd2fe00003b09, though it routes toTag9050cand is unaffected by this change either way.0x9416handler appears to miss the 7M5/7RM6 cumulative offset shifts, soreal_ISOand some lens metadata are wrong for these bodies independently of0x9050. Separately, on v1.01 filesshutterandfocal_lenare also wrong (constant 1/1250 against a true 1/135–1/157; 200mm against a true 25.8mm).