Skip to content

sony: read the A580 family camera settings block as bytes - #9470

Open
hennikul wants to merge 1 commit into
Exiv2:mainfrom
hennikul:sony-camerasettings3
Open

sony: read the A580 family camera settings block as bytes#9470
hennikul wants to merge 1 commit into
Exiv2:mainfrom
hennikul:sony-camerasettings3

Conversation

@hennikul

Copy link
Copy Markdown

Fixes #9469.

The problem

The camera settings block of the A33/A55/A450/A580/NEX family is an array of
bytes, but sonyCsSelector has no byte oriented variant to offer, so these
models fall through to the short based sonyCsCfg. Every Exif.Sony2Cs
value for them is two unrelated bytes glued together.

On a DSLR-A580, Sony2Cs.DriveMode reports 4121. The block begins
68 38 38 80 10 02 13 01 10 19 08 ..., and 4121 is 0x1019, bytes 8 and 9
read as a big endian short. AspectRatio really lives at byte 0x0a and is
not reachable at all today.

The change

  • sony2Cs3Cfg, a third configuration whose default element is
    ttUnsignedByte, added to sony2CsSet
  • sonyCsSelector selects it by model
  • a new Exif.Sony2Cs3 group naming AspectRatio at byte 0x0a

Only AspectRatio is named, because it is the only tag I could verify. The
rest of the block is now reported with correct values under Sony2Cs3 and
can be named by anyone with the samples to check them; ExifTool documents the
layout as CameraSettings3.

The model list is matched in full, not by substring. contains(model, "NEX-5") would also catch the NEX-5N, NEX-5R and NEX-5T, which are a
different layout again and are parsed correctly today.

Testing

CC0 samples from raw.pixls.us, comparing a pristine build of main against
this branch.

AspectRatio now agrees with ExifTool on all nine affected models available
there:

Model ExifTool Exiv2 (this branch)
DSLR-A580 16:9 16:9
DSLR-A450, A500, A560 3:2 3:2
NEX-5, NEX-C3 3:2 3:2
SLT-A33, A35, A55 3:2 3:2

Before this change none of them reported an aspect ratio, and every other
Sony2Cs value was wrong.

Output is byte for byte unchanged for DSLR-A200, A330, A380, A700, A900,
NEX-5N, NEX-5R and ILCE-7M3. NEX-5N is the only model of any of these that
appears in test/data/test_reference_files, and it is deliberately not in
the list, so no reference output should move.

DSLR-A550, NEX-3 and NEX-VG10E are in the list on ExifTool's authority; I had
no sample to confirm them. They are currently misparsed either way, so
including them cannot be worse than leaving them out, but I am happy to drop
them if you would rather only ship what is verified.

Found while trying to read the in-camera aspect ratio for darktable, where
Canon and Olympus both work through Exiv2 and Sony was the odd one out.

I can add a test if you point me at a suitable sample to use.

Disclosure: written with AI assistance (Claude Code with Claude Opus 5). I
have reviewed it and take responsibility for it.

Fixes Exiv2#9469.

The camera settings block of the A33/A55/A450/A580/NEX family is an array
of bytes, but sonyCsSelector had no byte oriented variant to offer, so these
models fell through to the short based sonyCsCfg. Every Exif.Sony2Cs value
for them is two unrelated bytes glued together: on a DSLR-A580,
Sony2Cs.DriveMode reports 4121, which is bytes 8 and 9 of the array read as
a big endian short.

Add a third configuration whose elements are bytes, select it by model, and
name AspectRatio in it, which sits at byte 0x0a and was not reachable at all
before. The remaining elements are now reported with their correct values
under Exif.Sony2Cs3, awaiting names from anyone with the samples to verify
them; ExifTool documents the rest of the layout as CameraSettings3.

The model list is matched in full rather than by substring, because "NEX-5"
would otherwise catch the NEX-5N, NEX-5R and NEX-5T, which are a different
layout again and are parsed correctly today.

Checked against CC0 samples from raw.pixls.us. AspectRatio now agrees with
ExifTool on all nine of the affected models available there: DSLR-A450,
A500, A560, A580, NEX-5, NEX-C3, SLT-A33, A35 and A55, the A580 being the
one shot at 16:9 and the rest at 3:2. Output for DSLR-A200, A330, A380,
A700, A900, NEX-5N, NEX-5R and ILCE-7M3 is byte for byte unchanged.

DSLR-A550, NEX-3 and NEX-VG10E are in the model list on ExifTool's authority
but I had no sample to confirm them with.

AI disclosure: written with AI assistance (Claude Code with Claude Opus 5).
I have reviewed it and take responsibility for it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.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.

Sony A580 family: camera settings block is byte oriented but parsed as shorts

1 participant