From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:MDEC (PlayStation macroblock decoder)" |
|---|
| claim | "In DuckStation's MDEC an input halfword is quantizer scale in bits 10-15 and a signed 10-bit value in bits 0-9; 0xFE00 is skipped as padding only before the first halfword of a block; a macroblock is 6 blocks (NUM_BLOCKS). The coefficient table depends on the routine: the legacy DecodeRLE_Old (used when the mdec_use_old_routines setting is on) stores through the column-major 'zagzig' table 0,1,8,16,9,2,3,10,17,24,... and the normal DecodeRLE_New through the row-major 'zigzag' table 0,8,1,2,9,16,24,... with 4 extra bits of precision." |
|---|
| scope | | level | "platform" |
|---|
| applies_to | "Platform:PlayStation" |
|---|
| observed_in | |
|---|
|
|---|
| data | | trigger | "decoding a macroblock" |
|---|
| effect | "Old: the first (DC) coefficient is signed10*qt[0], later ones (signed10*qt[i]*scale+4)/8; clamped to -0x400..0x3FF and written to blk[zagzig[i]]; with scale 0 the value is signed10*2 and is written to blk[i] without the table. New: DC = (val*qt[0])<<4 (val<<5 when scale is 0) with a +-8 rounding term, later ones ((val*scale*qt[i])>>3)<<4 (val<<5 when scale*qt[i] is 0), clamped to -0x4000..0x3FFF, written to blk[zigzag[i]]." |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "DecodeRLE_Old, zagzig table and the 0xFE00 skip" |
|---|
| repo | "stenzek/duckstation" |
|---|
| commit | "8a5b99b8b3ec82712292fea6355438eed85dd79e" |
|---|
| path | "src/core/mdec.cpp" |
|---|
| lines | "31, 862-900" |
|---|
|
| type | "source" |
|---|
| detail | "Read DecodeRLE_Old and DecodeRLE_New completely and the call sites choosing between them on g_settings.mdec_use_old_routines." |
|---|
| repo | "stenzek/duckstation" |
|---|
| commit | "8a5b99b8b3ec82712292fea6355438eed85dd79e" |
|---|
| path | "src/core/mdec.cpp" |
|---|
| lines | "569-630, 862-1030" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "RLE halfword and zigzag" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-19T02:09:28.148Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T06:59:26.911Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read DuckStation mdec.cpp at 8a5b99b DecodeRLE_Old (862-935) and DecodeRLE_New (992-1050) fully plus call sites 569-630. Tables, scaling, clamps, 0xFE00 skip only before first halfword and scale-0 special cases all match the corrected claim." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T04:13:24.298Z" |
|---|
| summary | "The claim described only the legacy DecodeRLE_Old routine; the default DecodeRLE_New uses a different table and scaling. Read both functions and their callers." |
|---|
| changed | | "claim" |
| "data" |
| "evidence" |
|
|---|
|
|
|---|