Album JPEG decoder and metadata

Embedded codec calls, Exif admission, RGB555 output and measured decoder differences.

The American album loader calls a real embedded JPEG implementation through relocated wrapper 02235628. This is no longer an unresolved external decoder boundary. The connected path reaches metadata scanning, entropy decoding, integer IDCT, native pixel emission, canvas resizing and thumbnail caching. European counterparts have independently matched instruction bodies and selected pixel executions. The same exact family was not found in Japanese V2; that does not prove it has no different decoder. [1]

OperationUS V2EU V2
Metadata scan020CE9D4020CFA8C
Pixel decode020CEB34020CFBEC
Coefficient block020CF560020D0618
IDCT preparation020CF704020D07BC
Integer IDCT020CF780020D0838
RGB555 emission020D00B4020D116C
Facade020D068C020D1744
TIFF directories020D0BBC020D1C74
APP1 entry020D1340020D23F8

Wrapper arguments and results

The six arguments are mutable JPEG bytes, byte length, pixel destination, initial width bound, initial height bound and mode. The last two are stack arguments. Lengths at least 204,800 are rejected. A metadata-only call with flag 0x10 must find property 0x1001 with at least eight bytes before real decoding. Width/height are read and written through signed halfwords; the backend returns actual dimensions. [1]

ReturnMeaning
0Successful decode with actual dimensions 640 × 480 or 160 × 120
18Real decoding returned false
19Initial metadata scan returned false
20Length, metadata or final dimensions failed admission

Accepted dimensions are not tied to mode: a 160 × 120 image fits full-photo bounds and is accepted. A 320 × 240 image can write its tightly packed pixels and then fail final admission; the wrapper does not clear that partial result. A 640 × 480 image with thumbnail bounds fails before output. The outer loader owns destination cleanup. [1]

Exif and borrowed properties

The scan recognises SOI, marker lengths and APP1. TIFF parsing checks Exif followed by two NUL bytes and recognises II/MM endianness, although this execution set covers little-endian only. It expects the camera's directory layout, including a first directory at offset eight and data offsets relative to JPEG byte twelve; it is not a general TIFF parser. [1]

TagUse
0131Software marker and parsed length
0132Twenty-byte date/time copy
8769Exif directory
927CMakerNote directory
A005Additional directory
0201Embedded JPEG thumbnail offset when mode bit zero is set
1000Expected first vendor entry: type seven, count twenty-eight
1001First exposed vendor property; admission needs at least eight bytes
1002Second vendor property

The semantic contents of vendor properties are unresolved. Their pointers refer into the input JPEG rather than owned copies. Metadata at 022312B8 stores lengths at +0/+2/+4, policy at +8 and property 1002/1001 pointers at +0x0C/+0x10. Handling APP1 resets those exposed fields; the top-level metadata-only scan does not reset them otherwise. A subsequent JPEG without APP1 can therefore retain a preceding image's property state. The connected cases cover empty, accepted and short-property state, not a bypass of a genuine camera signature. [1]

Validation policy

The wrapper checks system word +436 at base 02FFE000, bit ten. When clear, real decode selects policy zero; when set, software-marker bytes affect policy. Policy one additionally follows Exif/MakerNote, temporarily removes a twenty-eight-byte field, calls relocated validation routines and restores it. Genuine signed camera data and those validation callees remain unverified. The previous codec policy is restored after real decoding, even on failure. [1]

Pixel format and sampling

pixel16 = 0x8000 | (red >> 3)
        | ((green >> 3) << 5) | ((blue >> 3) << 10)

Pixels are little-endian, rows use actual width, and the decoder packs width/height into the low/high halves of its return. Zero means failure. The inspected branch handles frame markers C0/C1 and first-component sampling 11, 21, 12 or 22. Its 4:2:0 emitter reuses chroma per 2 × 2 luma group rather than interpolating it. Solid black, white, red and blue controls match an independent RGB555 decoder exactly. AC-bearing images do not all match. [1]

FixtureSamplingDifferent pixelsRGB5 difference ranges
16 × 16 grey4:4:485 / 256All −1…+1
16 × 16 colour4:4:4165 / 256All −1…+1
16 × 16 colour4:2:0232 / 256R −7…+6, G −4…+4, B −9…+8
17 × 13 grey4:4:470 / 221All −5…+26
19 × 11 colour4:2:0190 / 209R −9…+16, G −10…+12, B −14…+21
160 × 120 pattern4:2:014163 / 19200R −9…+7, G −6…+5, B −13…+15
640 × 480 pattern4:2:0230568 / 307200R −9…+8, G −6…+5, B −13…+15

These differences are retained, not converted into equality by a tolerance. The aligned 4:4:4 results are consistent with integer precision differences, but a complete independent IDCT/conversion derivation is unfinished. At a partial right-hand block, one emitter advances the decoded index only for pixels written. A one-column edge consumes indices zero through seven rather than zero, eight, sixteen and so on. Independent emitter controls isolate this from JPEG arithmetic. Normal admitted album sizes are block-aligned, so it is not a demonstrated normal album-screen defect. [1]

Connected full/thumbnail loader checks now execute the real decoder, resize and cache with file/scratch inputs supplied explicitly. They retain the thumbnail's 1,152 cleared corner pixels. Remaining questions include policy-one signatures, big-endian execution, additional marker families, complete album discovery/reset and physical timing/cache behaviour. [1]

The photo album is validated before image selection

Relocated American V2 ARM9i loader 022358E8 receives an album object, two buffers and their sizes, plus an optional error-word pointer. It clears both buffers before looking up photo:/private/ds/app/484E494A/pit.bin. Expected length comes from the caller; the checked 8,032-byte fixture has a 32-byte header and five hundred sixteen-byte records, not a proven universal allocation size. [2]

Validator 02235550 requires word 50495430, whose little-endian bytes are 30 54 49 50, record count five hundred at decimal offset eight and zero at ten. Offset twenty-two supplies the record-array offset. 02235888 temporarily clears the CRC halfword at twenty, computes over the supplied length, restores the field and compares it. Original SDK routines 020BCAE0/020BCB24 agree with an independent reflected CRC16 using polynomial A001 and initial zero. [2]

02235790 ignores inactive records with bit zero clear. Active records require the field from bits one–ten below 900, bits eleven–seventeen below 100 and bits twenty-two–twenty-three below three. Two intervening two-bit fields are extracted and compared with four. This path does not introduce a further rejection for reserved high bits. Values 899, 99 and two pass; their next boundaries fail with a recomputed valid CRC. [2]

FailureLoader result
Missing path12
Directory instead of file13
Open1
Unexpected size4
Incorrect read count, including negative5
Header, CRC or active-record validation13
Close after opening2, replacing a prior read/validation result

Open failure copies the last filesystem error; read/close failures copy the file object's error word. Early stat/size failures do not invent an error-word value. Eighteen comparisons check full buffers, CRC restoration, errors and call order. Filesystem services and the final directory/slot stage remain boundaries; this is not a physical camera or successful scene-entry test. [2]

Sources

  1. [1] Flipnote Decompilation Project — Original embedded JPEG codec and connected album pipeline
  2. [2] Flipnote Decompilation Project — Original photo-album header, CRC and loader errors

← All documentation