Compare commits
3 Commits
agent/w092
...
agent/fix/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
379c84d5f6 | ||
|
|
bf65a26b5e | ||
|
|
e174f2c2be |
12
configure.py
12
configure.py
@@ -455,7 +455,7 @@ def IPLSection(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
|
||||
def ZI8Lib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
|
||||
return {
|
||||
"lib": lib_name,
|
||||
"mw_version": config.linker_version,
|
||||
"mw_version": "GC/3.0a5",
|
||||
"cflags": cflags_zi8,
|
||||
"progress_category": "rvlmwm",
|
||||
"objects": objects,
|
||||
@@ -991,11 +991,11 @@ config.libs = [
|
||||
Object(Matching, "clib/zi8copy.c"),
|
||||
Object(Matching, "clib/zi8dawg.c"),
|
||||
Object(Matching, "clib/zi8getc.c"),
|
||||
Object(NonMatching, "clib/zi8getc2.c"),
|
||||
Object(Matching, "clib/zi8getc2.c"),
|
||||
Object(Matching, "clib/zi8getSW.c"),
|
||||
Object(Matching, "clib/zi8initd.c"),
|
||||
Object(Matching, "clib/zi8is.c"),
|
||||
Object(NonMatching, "clib/zi8match.c"),
|
||||
Object(Matching, "clib/zi8match.c"),
|
||||
Object(Matching, "clib/zi8misc.c"),
|
||||
Object(Matching, "clib/zi8pud2.c"),
|
||||
Object(Matching, "clib/Zi8punct.c"),
|
||||
@@ -1003,13 +1003,13 @@ config.libs = [
|
||||
Object(NonMatching, "clib/zi8uwd.c"),
|
||||
Object(Matching, "clib/zi8ver.c"),
|
||||
Object(Matching, "clib/zi8ZHuwd.c"),
|
||||
Object(NonMatching, "clib/zidawg1.c"),
|
||||
Object(Matching, "clib/zidawg1.c"),
|
||||
Object(Matching, "clib/zikorean.c"),
|
||||
Object(Matching, "clib/ziswordw.c"),
|
||||
Object(NonMatching, "clib/zkokeyp.c"),
|
||||
Object(Matching, "clib/zierror.c"),
|
||||
Object(NonMatching, "clib/zmtkey.c"),
|
||||
Object(NonMatching, "clib/zoemdata.c"),
|
||||
Object(Matching, "clib/zmtkey.c"),
|
||||
Object(Matching, "clib/zoemdata.c"),
|
||||
Object(NonMatching, "clib/zprepare.c"),
|
||||
]
|
||||
),
|
||||
|
||||
@@ -49,17 +49,17 @@ typedef struct {
|
||||
u8 flashVer[4]; // 0x640
|
||||
s8 flashPixVer[4]; // 0x644
|
||||
u16 colorSpace; // 0x648
|
||||
u8 unk_0x64A[0x02];
|
||||
u8 colorSpacePadding[0x02];
|
||||
u32 pixelXDim; // 0x64C
|
||||
u32 pixelYDim; // 0x650
|
||||
u16 compressionIfd1; // 0x654
|
||||
u8 unk_0x656[0x02];
|
||||
u8 compressionPadding[0x02];
|
||||
u32 xResNumIfd1; // 0x658
|
||||
u32 xResDenIfd1; // 0x65C
|
||||
u32 planarConfigIfd1; // 0x660
|
||||
u32 yResDenIfd1; // 0x664
|
||||
u16 resUnitIfd1; // 0x668
|
||||
u8 unk_0x66A[0x02];
|
||||
u8 resolutionPadding[0x02];
|
||||
u32 thumbnailOffset; // 0x66C
|
||||
u32 thumbnailLength; // 0x670
|
||||
u8* thumbnailData; // 0x674
|
||||
@@ -67,19 +67,40 @@ typedef struct {
|
||||
} TMCCJPEGDecExifData;
|
||||
|
||||
typedef struct {
|
||||
u8 unk_0x00[0x04];
|
||||
u16 posX;
|
||||
u16 posY;
|
||||
s32 position; // 0x04
|
||||
u8 unk_0x08[0x04];
|
||||
u32 state; // 0x0C
|
||||
u8 unk_0x10[0x10];
|
||||
u16 maxX;
|
||||
u16 maxY;
|
||||
u8 stepX;
|
||||
u8 stepY;
|
||||
u8 stepXExt;
|
||||
u8 stepYExt;
|
||||
u32 dataSizeX;
|
||||
u32 dataSizeY;
|
||||
u8 exifFlags; // 0x20
|
||||
u8 thumbFlag; // 0x21
|
||||
u8 unk_0x22[0x2A];
|
||||
u8 componentCount;
|
||||
u8 dimensionPadding;
|
||||
u16 jpegWidth;
|
||||
u16 jpegHeight;
|
||||
u16 outputWidth;
|
||||
u16 outputHeight;
|
||||
u32 convWidth;
|
||||
u32 convHeight;
|
||||
u32 chromaWidth;
|
||||
u32 chromaHeight;
|
||||
u8* pLumaBuffer;
|
||||
u8* pCbBuffer;
|
||||
u8* pCrBuffer;
|
||||
void* pTexBuffer;
|
||||
TMCCJPEGDecExifData exifData; // 0x4C
|
||||
TMCCJPEGDecWork* pWorkBuf; // 0x6C8
|
||||
u8 unk_0x6CC[0x04];
|
||||
s32 decodeResult;
|
||||
u8 converterType; // 0x6D0
|
||||
u8 unk_0x6D1[0x03];
|
||||
u8 alignmentPadding[0x03];
|
||||
} TMCCJPEGDecExifInfo;
|
||||
|
||||
typedef struct {
|
||||
|
||||
@@ -39,43 +39,32 @@ typedef void(TMCConverterFunc)(TMCCJPEGDecWork*, s32 x, s32 y);
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// TODO: The following two structs are subsets of TMCCJPEGDecWork.
|
||||
// Their members in TMCCJPEGDecWork should eventually be removed and replaced with these structs as a member.
|
||||
// Some code accesses scaleFlag, frameWidth and convBuf as a pointer and uses them as a base to do further pointer arithmetic on,
|
||||
// so they likely were nested structs.
|
||||
typedef struct {
|
||||
u8 scaleFlag; // 0x00
|
||||
u8 unk_0x01[0x3E7];
|
||||
u8* pDCACPtrs[6]; // 0x03E8-0x03FF
|
||||
u8 zigzagData[64]; // 0x0400-0x043F
|
||||
u16* pDCFast; // 0x0440
|
||||
u32* pDCHuffTbl; // 0x0444
|
||||
u8* pDCHuffSym; // 0x0448
|
||||
u32 unk_0x4A4; // 0x044C
|
||||
u16* pACFast; // 0x0450
|
||||
u32* pACHuffTbl; // 0x0454
|
||||
u8* pACHuffSym; // 0x0458
|
||||
u32 unk_0x4C5;
|
||||
u8 unk_0x460[0x1B4];
|
||||
u32 thumbHuffSize[3]; // 0x0614
|
||||
u8 unk_0x620[0x1E8];
|
||||
u8 huffDecTblDC1[0x400]; // 0x0808-0x0C07
|
||||
u8 huffDecTblAC0[0x400]; // 0x0C08-0x1007
|
||||
u8 huffDecTblAC1[0x400]; // 0x1008-0x1407
|
||||
u8 valPtrDC0[0x44]; // 0x1408-0x144B
|
||||
u8 valPtrDC1[0x44]; // 0x144C-0x148F
|
||||
u8 valPtrAC0[0x44]; // 0x1490-0x14D3
|
||||
u8 valPtrAC1[0x44]; // 0x14D4-0x1517
|
||||
u8 maxCodeDC0[0x10]; // 0x1518-0x1527
|
||||
u8 maxCodeDC1[0x10]; // 0x1528-0x1537
|
||||
u8 maxCodeAC0[0x100]; // 0x1538-0x1637
|
||||
u8 maxCodeAC1[0x100]; // 0x1638-0x1737
|
||||
u8 unk_0x1738[0x04];
|
||||
u8 huffTblInitFlag[4]; // 0x173C
|
||||
u8 unk_0x1740[0x50];
|
||||
u8 quantTblFlag[4]; // 0x1790
|
||||
u8 dcTblFlag[2]; // 0x1794
|
||||
u8 acTblFlag[2]; // 0x1796
|
||||
u32 coefficients[4][64];
|
||||
u8 zigzagData[64];
|
||||
u16* pDCFast;
|
||||
u32* pDCHuffTbl;
|
||||
u8* pDCHuffSym;
|
||||
u32 reservedDC;
|
||||
u16* pACFast;
|
||||
u32* pACHuffTbl;
|
||||
u8* pACHuffSym;
|
||||
u32 reservedAC;
|
||||
u16 huffDecTblDC0[0x200];
|
||||
u16 huffDecTblDC1[0x200];
|
||||
u16 huffDecTblAC0[0x200];
|
||||
u16 huffDecTblAC1[0x200];
|
||||
u32 valPtrDC0[17];
|
||||
u32 valPtrDC1[17];
|
||||
u32 valPtrAC0[17];
|
||||
u32 valPtrAC1[17];
|
||||
u8 maxCodeDC0[0x10];
|
||||
u8 maxCodeDC1[0x10];
|
||||
u8 maxCodeAC0[0x100];
|
||||
u8 maxCodeAC1[0x100];
|
||||
u8 quantTblFlag[4];
|
||||
u8 dcTblFlag[2];
|
||||
u8 acTblFlag[2];
|
||||
} TMCJpegTableInfo;
|
||||
|
||||
typedef struct {
|
||||
@@ -101,9 +90,18 @@ typedef struct {
|
||||
u8 maxVSamp; // 0x29
|
||||
u16 restartInterval; // 0x2A
|
||||
u8 scanCount; // 0x2C
|
||||
u8 unk_0x2D[0x03];
|
||||
u8 alignmentPadding[0x03];
|
||||
} TMCJpegFrameInfo;
|
||||
|
||||
typedef struct {
|
||||
u8 map[4];
|
||||
u32 dcPredict[4];
|
||||
u8 id[4];
|
||||
u8 quantTable[4];
|
||||
u8 dcTable[4];
|
||||
u8 acTable[4];
|
||||
} TMCFrameComponents;
|
||||
|
||||
struct TMCCJPEGDecWork_t {
|
||||
u32 bitBuf; // 0x00
|
||||
s32 bitCount; // 0x04
|
||||
@@ -116,47 +114,11 @@ struct TMCCJPEGDecWork_t {
|
||||
s32 remaining; // 0x20
|
||||
TMCCReadCallback* pCallback; // 0x24
|
||||
void* pCbCtx; // 0x28
|
||||
u8 compMap[4]; // 0x2C
|
||||
u32 dcPredict[4]; // 0x30
|
||||
u8 compId[4]; // 0x40
|
||||
u8 compQTbl[4]; // 0x44
|
||||
u8 copDCTbl[4]; // 0x48
|
||||
u8 copACTbl[4]; // 0x4C
|
||||
TMCFrameComponents components;
|
||||
u16 restartCnt; // 0x50
|
||||
u16 rstMarkerIdx; // 0x52
|
||||
u32 mcuPos; // 0x54
|
||||
// Section below is likely a nested struct
|
||||
u8 scaleFlag; // 0x58
|
||||
u8 unk_0x59[0x3E7];
|
||||
u8* pDCACPtrs[6]; // 0x440
|
||||
u8 zigzagData[64]; // 0x458
|
||||
u16* pDCFast; // 0x498
|
||||
u32* pDCHuffTbl; // 0x49C
|
||||
u8* pDCHuffSym; // 0x4A0
|
||||
u32 unk_0x4A4;
|
||||
u16* pACFast; // 0x4A8
|
||||
u32* pACHuffTbl; // 0x4AC
|
||||
u8* pACHuffSym; // 0x4B0
|
||||
u8 unk_0x4B4[0x1B8];
|
||||
u32 thumbHuffSize[3]; // 0x66C
|
||||
u8 unk_0x678[0x1E8];
|
||||
u8 huffDecTblDC1[0x400]; // 0x860-0xC5F
|
||||
u8 huffDecTblAC0[0x400]; // 0xC60-0x105F
|
||||
u8 huffDecTblAC1[0x400]; // 0x1060-0x145F
|
||||
u8 valPtrDC0[0x44]; // 0x1460-0x14A3
|
||||
u8 valPtrDC1[0x44]; // 0x14A4-0x14E7
|
||||
u8 valPtrAC0[0x44]; // 0x14E8-0x152B
|
||||
u8 valPtrAC1[0x44]; // 0x152C-0x156F
|
||||
u8 maxCodeDC0[0x10]; // 0x1570-0x157F
|
||||
u8 maxCodeDC1[0x10]; // 0x1580-0x158F
|
||||
u8 maxCodeAC0[0x100]; // 0x1590-0x168F
|
||||
u8 maxCodeAC1[0x100]; // 0x1690-0x178F
|
||||
u8 unk_0x1790[0x04];
|
||||
u8 huffTblInitFlag[4]; // 0x1794
|
||||
u8 unk_0x1798[0x50];
|
||||
u8 quantTblFlag[4]; // 0x17E8
|
||||
u8 dcTblFlag[2]; // 0x17EC
|
||||
u8 acTblFlag[2]; // 0x17EE
|
||||
TMCJpegTableInfo tables;
|
||||
// Section below is likely a nested struct
|
||||
u16 frameWidth; // 0x17F0
|
||||
u16 frameHeight; // 0x17F2
|
||||
@@ -180,7 +142,7 @@ struct TMCCJPEGDecWork_t {
|
||||
u8 maxVSamp; // 0x1819
|
||||
u16 restartInterval; // 0x181A
|
||||
u8 scanCount; // 0x181C
|
||||
u8 unk_0x181D[0x03];
|
||||
u8 framePadding[0x03];
|
||||
TMCIdctFunc* idctPtr; // 0x1820
|
||||
TMCIdctFunc* idctLumiPtr; // 0x1824
|
||||
TMCDecodeFunc* decodePtr; // 0x1828
|
||||
@@ -191,10 +153,10 @@ struct TMCCJPEGDecWork_t {
|
||||
u8* pConvRowPtrs[7]; // 0x183C
|
||||
u8 convBuf[0x184]; // 0x1858
|
||||
u8 idctMode; // 0x19DC
|
||||
u8 unk_0x19DD;
|
||||
u8 pitchPadding;
|
||||
u16 pitch; // 0x19DE
|
||||
u8 converterFlags; // 0x19E0
|
||||
u8 unk_0x19E1[0x03];
|
||||
u8 statePadding[0x03];
|
||||
TMCCJPEGDecState* pState; // 0x19E4
|
||||
};
|
||||
|
||||
@@ -213,7 +175,7 @@ s32 TMCJPEGDEC_rewind_ptr(TMCCJPEGDecWork* work);
|
||||
|
||||
typedef struct {
|
||||
u32* huffTable; // 0x00
|
||||
u8* valptr; // 0x04
|
||||
u32* valptr; // 0x04
|
||||
u32* maxCode; // 0x08
|
||||
u8 count; // 0x0C
|
||||
} TMCHuffParam;
|
||||
@@ -228,7 +190,7 @@ s32 TMCJPEGDEC_scanstart(TMCCJPEGDecWork* work);
|
||||
s32 TMCJPEGDEC_scan_varinit(TMCCJPEGDecWork* work);
|
||||
s32 TMCJPEGDEC_restart_interval(TMCCJPEGDecWork* work, u32 maxMCU, u32 mcuCount);
|
||||
s32 TMCJPEGDEC_err_restart(TMCCJPEGDecWork* work);
|
||||
void TMCJPEGDEC_set_entropytbl(TMCCJPEGDecWork* work, s32 idx, u8 data);
|
||||
void TMCJPEGDEC_set_entropytbl(TMCJpegTableInfo* work, s32 idx, u8 data);
|
||||
|
||||
s32 TMCJPEGDEC_Decompscan(TMCCJPEGDecWork* work);
|
||||
s32 TMCJPEGDEC_Setsize(TMCCJPEGDecWork* work);
|
||||
@@ -252,13 +214,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work);
|
||||
s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work);
|
||||
s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work);
|
||||
|
||||
#ifdef TMC_JPEG_FRAME_PARSER
|
||||
extern const u8 TMCJPEGDEC_SampleH_N[6][4];
|
||||
extern const u8 TMCJPEGDEC_SampleV_N[6][4];
|
||||
#else
|
||||
extern const u8 TMCJPEGDEC_SampleH_N[24];
|
||||
extern const u8 TMCJPEGDEC_SampleV_N[24];
|
||||
#endif
|
||||
extern const u8 TMCJPEGDEC_Zigzag_data[64];
|
||||
extern const u32 TMCJPEGDEC_Zigzag_loop[64];
|
||||
#ifdef TMC_JPEG_FRAME_PARSER
|
||||
|
||||
@@ -140,7 +140,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
|
||||
|
||||
conv_row = (s32*)conv_row_ptr;
|
||||
bit_pos = work->bitCount;
|
||||
dc_fast = work->pDCFast;
|
||||
dc_fast = work->tables.pDCFast;
|
||||
|
||||
if (bit_pos <= 8) {
|
||||
r = TMCJPEGDEC_load_buff(work);
|
||||
@@ -161,8 +161,8 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
|
||||
work->bitCount = bit_pos - r;
|
||||
r = extra;
|
||||
} else {
|
||||
huff_sym = work->pDCHuffSym;
|
||||
huff_tbl = work->pDCHuffTbl;
|
||||
huff_sym = work->tables.pDCHuffSym;
|
||||
huff_tbl = work->tables.pDCHuffTbl;
|
||||
r = decodeLongHuffman(bit_pos, huff_tbl, huff_sym, work, &dcLimit, &dcDecoded);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
@@ -196,9 +196,9 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
|
||||
u32* ac_huff_tbl;
|
||||
u8* ac_huff_sym;
|
||||
|
||||
ac_fast = work->pACFast;
|
||||
ac_huff_tbl = work->pACHuffTbl;
|
||||
ac_huff_sym = work->pACHuffSym;
|
||||
ac_fast = work->tables.pACFast;
|
||||
ac_huff_tbl = work->tables.pACHuffTbl;
|
||||
ac_huff_sym = work->tables.pACHuffSym;
|
||||
|
||||
memset(block + 1, 0, 0xFC);
|
||||
|
||||
@@ -279,8 +279,8 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
|
||||
bit_data = work->bitBuf;
|
||||
bit_pos = work->bitCount;
|
||||
t = bit_pos - 8;
|
||||
tmp = ((bit_data >> t) & 0xFF) << 2;
|
||||
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, tmp >> 2);
|
||||
tmp = (bit_data >> t) & 0xFF;
|
||||
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, tmp);
|
||||
|
||||
idx += 16;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ s32 TMCJPEGDEC_init_ptr_buff(TMCCJPEGDecWork* work, void* param) {
|
||||
u32 newRemaining;
|
||||
const TMCCJPEGDecInitParam* input = (const TMCCJPEGDecInitParam*)((u8*)param - offsetof(TMCCJPEGDecInitParam, pBuf2));
|
||||
|
||||
if ((u32)input->pBuf2 & 0x1F)
|
||||
if ((u32)input->pBuf2 & (DEFAULT_ALIGN - 1))
|
||||
return -1;
|
||||
if (input->buf2Size & 0x1F)
|
||||
if (input->buf2Size & (DEFAULT_ALIGN - 1))
|
||||
return -1;
|
||||
if (input->dataSize == 0)
|
||||
return -1;
|
||||
|
||||
@@ -27,7 +27,7 @@ s32 TMCJPEGDEC_init_buff_thumbnail(TMCCJPEGDecWork* work, u8* dst, u8* src) {
|
||||
endAddress = (u32)buffer->pBufCur + endAddress;
|
||||
buffer->remaining = 0;
|
||||
buffer->pBufEnd = (u8*)endAddress;
|
||||
buffer->pBufMark = (u8*)((u32)endAddress - 0x22);
|
||||
buffer->pBufMark = (u8*)endAddress - 0x22;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ s32 TMCJPEGDEC_make_huffdec(const u8* dht, u8* tb, TMCHuffParam* hp) {
|
||||
|
||||
|
||||
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJpegTableInfo* info) {
|
||||
TMCCJPEGDecWork* work = (TMCCJPEGDecWork*)info;
|
||||
TMCJpegTableInfo* work = info;
|
||||
void* hufftable;
|
||||
void* maxcode;
|
||||
void* valptr;
|
||||
@@ -129,15 +129,15 @@ void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJ
|
||||
if (tblType == 0) {
|
||||
switch (tblID) {
|
||||
case 0: {
|
||||
hufftable = &work->zigzagData[8];
|
||||
hufftable = work->huffDecTblDC0;
|
||||
maxcode = work->maxCodeDC0;
|
||||
tbl->huffTable = hufftable;
|
||||
tbl->maxCode = maxcode;
|
||||
tbl->valptr = work->valPtrDC0;
|
||||
work->huffTblInitFlag[0] = 1;
|
||||
memset(hufftable, 0, 0x400);
|
||||
memset(work->maxCodeDC0, 0, 0x10);
|
||||
memset(work->valPtrDC0, 0, 0x44);
|
||||
work->dcTblFlag[0] = 1;
|
||||
memset(hufftable, 0, sizeof(work->huffDecTblDC0));
|
||||
memset(work->maxCodeDC0, 0, sizeof(work->maxCodeDC0));
|
||||
memset(work->valPtrDC0, 0, sizeof(work->valPtrDC0));
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
@@ -147,10 +147,10 @@ void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJ
|
||||
tbl->huffTable = hufftable;
|
||||
tbl->maxCode = maxcode;
|
||||
tbl->valptr = valptr;
|
||||
work->huffTblInitFlag[1] = 1;
|
||||
memset(hufftable, 0, 0x400);
|
||||
memset(work->maxCodeDC1, 0, 0x10);
|
||||
memset(work->valPtrDC1, 0, 0x44);
|
||||
work->dcTblFlag[1] = 1;
|
||||
memset(hufftable, 0, sizeof(work->huffDecTblDC1));
|
||||
memset(work->maxCodeDC1, 0, sizeof(work->maxCodeDC1));
|
||||
memset(work->valPtrDC1, 0, sizeof(work->valPtrDC1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -163,10 +163,10 @@ void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJ
|
||||
tbl->huffTable = hufftable;
|
||||
tbl->maxCode = maxcode;
|
||||
tbl->valptr = valptr;
|
||||
work->huffTblInitFlag[2] = 1;
|
||||
memset(hufftable, 0, 0x400);
|
||||
memset(work->maxCodeAC0, 0, 0x100);
|
||||
memset(work->valPtrAC0, 0, 0x44);
|
||||
work->acTblFlag[0] = 1;
|
||||
memset(hufftable, 0, sizeof(work->huffDecTblAC0));
|
||||
memset(work->maxCodeAC0, 0, sizeof(work->maxCodeAC0));
|
||||
memset(work->valPtrAC0, 0, sizeof(work->valPtrAC0));
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
@@ -176,10 +176,10 @@ void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCJ
|
||||
tbl->huffTable = hufftable;
|
||||
tbl->maxCode = maxcode;
|
||||
tbl->valptr = valptr;
|
||||
work->huffTblInitFlag[3] = 1;
|
||||
memset(hufftable, 0, 0x400);
|
||||
memset(work->maxCodeAC1, 0, 0x100);
|
||||
memset(work->valPtrAC1, 0, 0x44);
|
||||
work->acTblFlag[1] = 1;
|
||||
memset(hufftable, 0, sizeof(work->huffDecTblAC1));
|
||||
memset(work->maxCodeAC1, 0, sizeof(work->maxCodeAC1));
|
||||
memset(work->valPtrAC1, 0, sizeof(work->valPtrAC1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,16 @@ enum TMCExifTag {
|
||||
TMC_EXIF_TAG_PIXEL_Y_DIMENSION = 0xA003,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u8 tag[2];
|
||||
u8 type[2];
|
||||
u8 count[4];
|
||||
u8 value[4];
|
||||
} TMCExifEntry;
|
||||
|
||||
static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData* pInfo);
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry);
|
||||
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, TMCExifEntry* entry);
|
||||
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const TMCExifEntry* entry);
|
||||
static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExifInfo* info, u32 totalSize);
|
||||
|
||||
static u16 readU16(const u8* p, u16 byteOrder) {
|
||||
@@ -316,8 +323,8 @@ static s32 TMCJPEGDEC_exif_parse(const u8* entries, u32 size, TMCCJPEGDecExifDat
|
||||
return -161;
|
||||
}
|
||||
for (index = 0; index < count; index++) {
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
|
||||
entries += 12;
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (TMCExifEntry*)entries);
|
||||
entries += sizeof(TMCExifEntry);
|
||||
}
|
||||
remaining -= (s32)count * 12;
|
||||
if (remaining < 4) {
|
||||
@@ -344,8 +351,8 @@ static s32 TMCJPEGDEC_exif_parse(const u8* entries, u32 size, TMCCJPEGDecExifDat
|
||||
return -161;
|
||||
}
|
||||
for (ifd1Index = 0; ifd1Index < ifd1Count; ifd1Index++) {
|
||||
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, ifd1Entries);
|
||||
ifd1Entries += 12;
|
||||
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, (const TMCExifEntry*)ifd1Entries);
|
||||
ifd1Entries += sizeof(TMCExifEntry);
|
||||
}
|
||||
}
|
||||
ifdOffset = pInfo->nextIfdOffset;
|
||||
@@ -365,19 +372,19 @@ static s32 TMCJPEGDEC_exif_parse(const u8* entries, u32 size, TMCCJPEGDecExifDat
|
||||
return -161;
|
||||
}
|
||||
for (exifIndex = 0; exifIndex < exifCount; exifIndex++) {
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)exifEntries);
|
||||
exifEntries += 12;
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (TMCExifEntry*)exifEntries);
|
||||
exifEntries += sizeof(TMCExifEntry);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry) {
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, TMCExifEntry* entry) {
|
||||
s32 tag;
|
||||
u32 type;
|
||||
|
||||
tag = readExifU16(entry, byteOrder);
|
||||
type = readExifU16(entry + 2, byteOrder);
|
||||
tag = readExifU16(entry->tag, byteOrder);
|
||||
type = readExifU16(entry->type, byteOrder);
|
||||
|
||||
switch (tag) {
|
||||
case TMC_EXIF_TAG_COMPRESSION:
|
||||
@@ -387,11 +394,11 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
break;
|
||||
}
|
||||
case TMC_EXIF_TAG_ORIENTATION: {
|
||||
pInfo->orientation = readU16(entry + 8, byteOrder);
|
||||
pInfo->orientation = readU16(entry->value, byteOrder);
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_X_RESOLUTION: {
|
||||
u32 offset = readU32(entry + 8, byteOrder);
|
||||
u32 offset = readU32(entry->value, byteOrder);
|
||||
const u8* p = pInfo->thumbnailData + offset;
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
@@ -400,7 +407,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->xResNum = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
p = pInfo->thumbnailData + (offset + sizeof(u32));
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -411,7 +418,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_Y_RESOLUTION: {
|
||||
u32 offset = readU32(entry + 8, byteOrder);
|
||||
u32 offset = readU32(entry->value, byteOrder);
|
||||
const u8* p = pInfo->thumbnailData + offset;
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
@@ -420,7 +427,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->yResNum = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
p = pInfo->thumbnailData + (offset + sizeof(u32));
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -431,11 +438,11 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_RESOLUTION_UNIT: {
|
||||
pInfo->resUnit = readU16(entry + 8, byteOrder);
|
||||
pInfo->resUnit = readU16(entry->value, byteOrder);
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_TRANSFER_FUNCTION: {
|
||||
u32 offset = readU32(entry + 8, byteOrder);
|
||||
u32 offset = readU32(entry->value, byteOrder);
|
||||
u32 channel;
|
||||
u32 index;
|
||||
for (channel = 0; channel < 3; channel++) {
|
||||
@@ -444,87 +451,87 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
if (pInfo->thumbnailData > p) {
|
||||
break;
|
||||
}
|
||||
if (p > pInfo->dataEnd - 2) {
|
||||
if (p > pInfo->dataEnd - sizeof(u16)) {
|
||||
break;
|
||||
}
|
||||
pInfo->transferFunc[channel][index] = readU16(p, byteOrder);
|
||||
offset += 2;
|
||||
offset += sizeof(u16);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_DATE_TIME: {
|
||||
u32 offset = readU32(entry + 8, byteOrder);
|
||||
u32 offset = readU32(entry->value, byteOrder);
|
||||
const u8* p = pInfo->thumbnailData + offset;
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
if (p > pInfo->dataEnd - 20) {
|
||||
if (p > pInfo->dataEnd - sizeof(pInfo->dateTime)) {
|
||||
return;
|
||||
}
|
||||
{
|
||||
u32 index;
|
||||
for (index = 0; index < 20; index++) {
|
||||
for (index = 0; index < sizeof(pInfo->dateTime); index++) {
|
||||
pInfo->dateTime[index] = p[index];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_YCBCR_POSITIONING: {
|
||||
pInfo->yCbCrPos = readU16(entry + 8, byteOrder);
|
||||
pInfo->yCbCrPos = readU16(entry->value, byteOrder);
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_EXIF_IFD: {
|
||||
pInfo->nextIfdOffset = readU32(entry + 8, byteOrder);
|
||||
pInfo->nextIfdOffset = readU32(entry->value, byteOrder);
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_EXIF_VERSION: {
|
||||
pInfo->exifVer[0] = entry[8];
|
||||
pInfo->exifVer[1] = entry[9];
|
||||
pInfo->exifVer[2] = entry[10];
|
||||
pInfo->exifVer[3] = entry[11];
|
||||
pInfo->exifVer[0] = entry->value[0];
|
||||
pInfo->exifVer[1] = entry->value[1];
|
||||
pInfo->exifVer[2] = entry->value[2];
|
||||
pInfo->exifVer[3] = entry->value[3];
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_COMPONENTS_CONFIGURATION: {
|
||||
pInfo->flashVer[0] = entry[8];
|
||||
pInfo->flashVer[1] = entry[9];
|
||||
pInfo->flashVer[2] = entry[10];
|
||||
pInfo->flashVer[3] = entry[11];
|
||||
pInfo->flashVer[0] = entry->value[0];
|
||||
pInfo->flashVer[1] = entry->value[1];
|
||||
pInfo->flashVer[2] = entry->value[2];
|
||||
pInfo->flashVer[3] = entry->value[3];
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_FLASHPIX_VERSION: {
|
||||
pInfo->flashPixVer[0] = entry[8];
|
||||
pInfo->flashPixVer[1] = entry[9];
|
||||
pInfo->flashPixVer[2] = entry[10];
|
||||
pInfo->flashPixVer[3] = entry[11];
|
||||
pInfo->flashPixVer[0] = entry->value[0];
|
||||
pInfo->flashPixVer[1] = entry->value[1];
|
||||
pInfo->flashPixVer[2] = entry->value[2];
|
||||
pInfo->flashPixVer[3] = entry->value[3];
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_COLOR_SPACE: {
|
||||
pInfo->colorSpace = readU16(entry + 8, byteOrder);
|
||||
pInfo->colorSpace = readU16(entry->value, byteOrder);
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_PIXEL_X_DIMENSION: {
|
||||
if (type == TMC_EXIF_TYPE_SHORT) {
|
||||
pInfo->pixelXDim = readU16(entry + 8, byteOrder);
|
||||
pInfo->pixelXDim = readU16(entry->value, byteOrder);
|
||||
} else if (type == TMC_EXIF_TYPE_LONG) {
|
||||
pInfo->pixelXDim = readU32(entry + 8, byteOrder);
|
||||
pInfo->pixelXDim = readU32(entry->value, byteOrder);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
case TMC_EXIF_TAG_PIXEL_Y_DIMENSION: {
|
||||
if (type == TMC_EXIF_TYPE_SHORT) {
|
||||
pInfo->pixelYDim = readU16(entry + 8, byteOrder);
|
||||
pInfo->pixelYDim = readU16(entry->value, byteOrder);
|
||||
} else if (type == TMC_EXIF_TYPE_LONG) {
|
||||
pInfo->pixelYDim = readU32(entry + 8, byteOrder);
|
||||
pInfo->pixelYDim = readU32(entry->value, byteOrder);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
|
||||
s32 tag = readU16(entry, byteOrder);
|
||||
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const TMCExifEntry* entry) {
|
||||
s32 tag = readU16(entry->tag, byteOrder);
|
||||
|
||||
switch (tag) {
|
||||
case TMC_EXIF_TAG_DATE_TIME:
|
||||
@@ -545,7 +552,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
case TMC_EXIF_TAG_X_RESOLUTION: {
|
||||
u32 offset;
|
||||
const u8* p;
|
||||
offset = readU32(entry + 8, byteOrder);
|
||||
offset = readU32(entry->value, byteOrder);
|
||||
p = pInfo->thumbnailData + offset;
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
@@ -554,7 +561,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->xResNumIfd1 = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
p = pInfo->thumbnailData + (offset + sizeof(u32));
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -567,7 +574,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
case TMC_EXIF_TAG_Y_RESOLUTION: {
|
||||
u32 offset;
|
||||
const u8* p;
|
||||
offset = readU32(entry + 8, byteOrder);
|
||||
offset = readU32(entry->value, byteOrder);
|
||||
p = pInfo->thumbnailData + offset;
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
@@ -576,7 +583,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
p = pInfo->thumbnailData + (offset + sizeof(u32));
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -587,19 +594,19 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_RESOLUTION_UNIT: {
|
||||
pInfo->resUnitIfd1 = readU16(entry + 8, byteOrder);
|
||||
pInfo->resUnitIfd1 = readU16(entry->value, byteOrder);
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_COMPRESSION: {
|
||||
pInfo->compressionIfd1 = readU16(entry + 8, byteOrder);
|
||||
pInfo->compressionIfd1 = readU16(entry->value, byteOrder);
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT: {
|
||||
pInfo->thumbnailOffset = readU32(entry + 8, byteOrder);
|
||||
pInfo->thumbnailOffset = readU32(entry->value, byteOrder);
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: {
|
||||
pInfo->thumbnailLength = readU32(entry + 8, byteOrder);
|
||||
pInfo->thumbnailLength = readU32(entry->value, byteOrder);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ static s32 TMCJPEGDEC_parse_sof(TMCCJPEGDecWork* work);
|
||||
static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work);
|
||||
|
||||
s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void* buf) {
|
||||
u8* compMapBase;
|
||||
TMCFrameComponents* compMapBase;
|
||||
u8* compMapPtr;
|
||||
u32* mcuDataInfo;
|
||||
|
||||
@@ -34,7 +34,7 @@ s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void*
|
||||
u16 pitch;
|
||||
|
||||
u8* frameInfo;
|
||||
u8* scaleInfo;
|
||||
TMCJpegTableInfo* scaleInfo;
|
||||
|
||||
u8** convRowPtrs;
|
||||
TMCCJPEGDecState* state;
|
||||
@@ -44,12 +44,12 @@ s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void*
|
||||
TMCDecodeFunc* decodeFunc;
|
||||
|
||||
state = work->pState;
|
||||
compMapBase = work->compMap;
|
||||
compMapBase = &work->components;
|
||||
frameInfo = (u8*)&work->frameWidth;
|
||||
compMapPtr = compMapBase;
|
||||
scaleInfo = &work->scaleFlag;
|
||||
compMapPtr = compMapBase->map;
|
||||
scaleInfo = &work->tables;
|
||||
convRowPtrs = work->pConvRowPtrs;
|
||||
mcuDataInfo = (u32*)(compMapBase + 4);
|
||||
mcuDataInfo = compMapBase->dcPredict;
|
||||
mcuIdx = 0;
|
||||
|
||||
decodeFunc = work->decodePtr;
|
||||
@@ -60,15 +60,15 @@ s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void*
|
||||
|
||||
while (mcuIdx < ((TMCJpegFrameInfo*)frameInfo)->scanCompCount) {
|
||||
compIdx = *compMapPtr;
|
||||
entTblBase = scaleInfo + ((u32) * (compMapBase + compIdx + 0x18) << 8);
|
||||
TMCJPEGDEC_set_entropytbl((TMCCJPEGDecWork*)scaleInfo, *(compMapBase + compIdx + 0x1c), *(compMapBase + compIdx + 0x20));
|
||||
entTblBase = (u8*)scaleInfo->coefficients[compMapBase->quantTable[compIdx]];
|
||||
TMCJPEGDEC_set_entropytbl(scaleInfo, compMapBase->dcTable[compIdx], compMapBase->acTable[compIdx]);
|
||||
|
||||
curBlockInfo = convRowPtrs;
|
||||
specificConvRowPtr = convRowPtrs + compIdx;
|
||||
blockCountPtr = frameInfo + mcuIdx;
|
||||
blockIdx = 0;
|
||||
|
||||
while (blockIdx < (s32) * (blockCountPtr + 0x1c)) {
|
||||
while (blockIdx < *(blockCountPtr + 0x1c)) {
|
||||
s32 stackBlock[64];
|
||||
s32 ret;
|
||||
|
||||
@@ -113,7 +113,7 @@ static inline void initZigzag(TMCCJPEGDecWork* work) {
|
||||
work->restartInterval = 0;
|
||||
work->scanCount = 0;
|
||||
for (i = 0; i < 64; i++) {
|
||||
work->zigzagData[i] = *zigzag++ << 2;
|
||||
work->tables.zigzagData[i] = *zigzag++ << 2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -199,10 +199,10 @@ s32 TMCJPEGDEC_scanstart(TMCCJPEGDecWork* work) {
|
||||
return r;
|
||||
}
|
||||
|
||||
work->dcPredict[0] = 0;
|
||||
work->dcPredict[1] = 0;
|
||||
work->dcPredict[2] = 0;
|
||||
work->dcPredict[3] = 0;
|
||||
work->components.dcPredict[0] = 0;
|
||||
work->components.dcPredict[1] = 0;
|
||||
work->components.dcPredict[2] = 0;
|
||||
work->components.dcPredict[3] = 0;
|
||||
work->restartCnt = 0;
|
||||
r = TMCJPEGDEC_init_buff(work);
|
||||
if (r < 0) {
|
||||
@@ -230,11 +230,11 @@ s32 TMCJPEGDEC_scan_varinit(TMCCJPEGDecWork* work) {
|
||||
u8 component;
|
||||
|
||||
hSamp = p->maxHSamp;
|
||||
component = work->compMap[0];
|
||||
component = work->components.map[0];
|
||||
qTblH = p->hSampFactor[component];
|
||||
hMul8 = hSamp * 8;
|
||||
p->mcuXCount = (u8)(hMul8 / qTblH);
|
||||
p->mcuXRem = (u8)(p->maxVSamp * 8 / p->vSampFactor[component]);
|
||||
p->mcuXCount = hMul8 / qTblH;
|
||||
p->mcuXRem = p->maxVSamp * 8 / p->vSampFactor[component];
|
||||
p->mcuYCount = p->frameWidth / p->mcuXCount;
|
||||
p->mcuXCount2 = p->frameHeight / p->mcuXRem;
|
||||
} else {
|
||||
@@ -255,15 +255,15 @@ s32 TMCJPEGDEC_scan_varinit(TMCCJPEGDecWork* work) {
|
||||
p->remX = remX;
|
||||
p->remY = remY;
|
||||
|
||||
p->mcuYCount = p->mcuYCount + ((u8)remX != 0 ? 1 : 0);
|
||||
p->mcuXCount2 = p->mcuXCount2 + ((u8)remY != 0 ? 1 : 0);
|
||||
p->mcuTotal = (u32)p->mcuYCount * (u32)p->mcuXCount2;
|
||||
p->mcuYCount = p->mcuYCount + ((u8)remX != 0);
|
||||
p->mcuXCount2 = p->mcuXCount2 + ((u8)remY != 0);
|
||||
p->mcuTotal = (u32)p->mcuYCount * p->mcuXCount2;
|
||||
|
||||
for (idx = 0; idx < p->scanCompCount; idx++) {
|
||||
u8 compId;
|
||||
u32 blocks;
|
||||
|
||||
compId = work->compMap[idx];
|
||||
compId = work->components.map[idx];
|
||||
if (p->scanCompCount == 1) {
|
||||
blocks = 1;
|
||||
} else {
|
||||
@@ -295,10 +295,10 @@ static inline void restartMcuPosition(TMCCJPEGDecWork* work, TMCCJPEGDecState* s
|
||||
blockCount = mcuCount / stepY;
|
||||
column = maxMCU / stepX;
|
||||
position = blockCount * pitch + column + 1;
|
||||
work->dcPredict[0] = 0;
|
||||
work->dcPredict[1] = 0;
|
||||
work->dcPredict[2] = 0;
|
||||
work->dcPredict[3] = 0;
|
||||
work->components.dcPredict[0] = 0;
|
||||
work->components.dcPredict[1] = 0;
|
||||
work->components.dcPredict[2] = 0;
|
||||
work->components.dcPredict[3] = 0;
|
||||
work->restartCnt = 0;
|
||||
row = position / pitch;
|
||||
remainder = position - row * pitch;
|
||||
@@ -516,7 +516,7 @@ static s32 TMCJPEGDEC_parse_dht(s32 first, TMCCJPEGDecWork* work) {
|
||||
s32 r;
|
||||
TMCHuffParam tblSet;
|
||||
|
||||
scaleInfo = (TMCJpegTableInfo*)&work->scaleFlag;
|
||||
scaleInfo = &work->tables;
|
||||
|
||||
memset(countBuf, 0, sizeof(countBuf));
|
||||
|
||||
@@ -592,8 +592,7 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
|
||||
u32 data[64];
|
||||
} CopyBlock64;
|
||||
|
||||
typedef struct { u32 coefficients[4][64]; } QuantizationTables;
|
||||
QuantizationTables* scaleInfo;
|
||||
TMCJpegTableInfo* scaleInfo;
|
||||
u32 tblCopy[64];
|
||||
u32* d;
|
||||
u16 len;
|
||||
@@ -602,7 +601,7 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
|
||||
d = tblCopy;
|
||||
*(CopyBlock64*)d = *(CopyBlock64*)scJpegAanScale;
|
||||
|
||||
scaleInfo = (QuantizationTables*)&work->scaleFlag;
|
||||
scaleInfo = &work->tables;
|
||||
|
||||
r = TMCJPEGDEC_get_wbyte(&len, work);
|
||||
if (r < 0) {
|
||||
@@ -628,7 +627,7 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
|
||||
return -0x41;
|
||||
}
|
||||
|
||||
((TMCJpegTableInfo*)scaleInfo)->quantTblFlag[qtInfo] = 1;
|
||||
scaleInfo->quantTblFlag[qtInfo] = 1;
|
||||
|
||||
zigPtr = TMCJPEGDEC_Zigzag_data;
|
||||
for (zzIdx = 0; zzIdx < 64; zzIdx++) {
|
||||
@@ -643,7 +642,7 @@ static s32 TMCJPEGDEC_parse_dqt(TMCCJPEGDecWork* work) {
|
||||
return r;
|
||||
}
|
||||
|
||||
val = (u32)byte * tblCopy[zz];
|
||||
val = byte * tblCopy[zz];
|
||||
scaleInfo->coefficients[qtInfo][zz] = val;
|
||||
if (val == 0) {
|
||||
return -0x41;
|
||||
@@ -689,19 +688,10 @@ static inline s32 storeSampling(TMCJpegFrameInfo* frame, s32 index, u8 packed) {
|
||||
return horizontal;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
u8 map[4];
|
||||
u32 dcPredict[4];
|
||||
u8 id[4];
|
||||
u8 quantTable[4];
|
||||
u8 dcTable[4];
|
||||
u8 acTable[4];
|
||||
} TMCFrameComponents;
|
||||
|
||||
static inline s32 validateFrameComponents(TMCCJPEGDecWork* work) {
|
||||
s32 idx;
|
||||
TMCJpegFrameInfo* frameInfo = (TMCJpegFrameInfo*)&work->frameWidth;
|
||||
TMCFrameComponents* components = (TMCFrameComponents*)work->compMap;
|
||||
TMCFrameComponents* components = &work->components;
|
||||
for (idx = 0; idx < frameInfo->compCount; idx++) {
|
||||
if (frameInfo->hSampFactor[idx] < 1 || frameInfo->hSampFactor[idx] > 4) {
|
||||
return TMCC_ERROR_HEADER;
|
||||
@@ -720,7 +710,7 @@ static s32 TMCJPEGDEC_parse_sof(TMCCJPEGDecWork* work) {
|
||||
s32 maxHSamp;
|
||||
s32 maxVSamp;
|
||||
TMCJpegFrameInfo* frameInfo = (TMCJpegFrameInfo*)&work->frameWidth;
|
||||
TMCFrameComponents* components = (TMCFrameComponents*)work->compMap;
|
||||
TMCFrameComponents* components = &work->components;
|
||||
u16 value;
|
||||
u8 byte;
|
||||
s32 r;
|
||||
@@ -823,18 +813,10 @@ nextSample:
|
||||
}
|
||||
|
||||
static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
|
||||
typedef struct {
|
||||
u8 map[4];
|
||||
u32 dcPredict[4];
|
||||
u8 id[4];
|
||||
u8 quantTable[4];
|
||||
u8 dcTable[4];
|
||||
u8 acTable[4];
|
||||
} TMCComponentInfo;
|
||||
s32 idx;
|
||||
TMCComponentInfo* components;
|
||||
TMCFrameComponents* components;
|
||||
TMCJpegTableInfo* scalePtr;
|
||||
TMCComponentInfo* mapPtr;
|
||||
TMCFrameComponents* mapPtr;
|
||||
|
||||
s32 dcTbl;
|
||||
s32 acTbl;
|
||||
@@ -845,8 +827,8 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
|
||||
s32 ci;
|
||||
u8 scanByte;
|
||||
|
||||
components = (TMCComponentInfo*)work->compMap;
|
||||
scalePtr = (TMCJpegTableInfo*)&work->scaleFlag;
|
||||
components = &work->components;
|
||||
scalePtr = &work->tables;
|
||||
|
||||
r = TMCJPEGDEC_get_wbyte(&len, work);
|
||||
if (r < 0) {
|
||||
@@ -876,7 +858,7 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
|
||||
for (ci = 0; ci < work->compCount; ci++) {
|
||||
if ((s32)scanByte == (s32)components->id[ci]) {
|
||||
components->map[idx] = ci;
|
||||
mapPtr = (TMCComponentInfo*)&components->map[idx];
|
||||
mapPtr = (TMCFrameComponents*)&components->map[idx];
|
||||
goto componentFound;
|
||||
}
|
||||
}
|
||||
@@ -1125,10 +1107,10 @@ s32 TMCJPEGDEC_err_restart(TMCCJPEGDecWork* work) {
|
||||
pitch = state->maxX;
|
||||
val = work->mcuPos;
|
||||
|
||||
work->dcPredict[0] = 0;
|
||||
work->dcPredict[1] = 0;
|
||||
work->dcPredict[2] = 0;
|
||||
work->dcPredict[3] = 0;
|
||||
work->components.dcPredict[0] = 0;
|
||||
work->components.dcPredict[1] = 0;
|
||||
work->components.dcPredict[2] = 0;
|
||||
work->components.dcPredict[3] = 0;
|
||||
work->restartCnt = 0;
|
||||
|
||||
next = (u8)(val & 0xFF) * (s32)pitch + (val >> 16) + (s32)(u8)(rstDiff * interval);
|
||||
@@ -1150,18 +1132,18 @@ s32 TMCJPEGDEC_err_restart(TMCCJPEGDecWork* work) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void TMCJPEGDEC_set_entropytbl(TMCCJPEGDecWork* work, s32 idx, u8 data) {
|
||||
void TMCJPEGDEC_set_entropytbl(TMCJpegTableInfo* work, s32 idx, u8 data) {
|
||||
switch (idx) {
|
||||
case 0: {
|
||||
work->pDCACPtrs[0] = &work->zigzagData[8];
|
||||
work->pDCACPtrs[2] = work->maxCodeDC0;
|
||||
work->pDCACPtrs[1] = work->valPtrDC0;
|
||||
work->pDCFast = work->huffDecTblDC0;
|
||||
work->pDCHuffSym = work->maxCodeDC0;
|
||||
work->pDCHuffTbl = work->valPtrDC0;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
work->pDCACPtrs[0] = work->huffDecTblDC1;
|
||||
work->pDCACPtrs[2] = work->maxCodeDC1;
|
||||
work->pDCACPtrs[1] = work->valPtrDC1;
|
||||
work->pDCFast = work->huffDecTblDC1;
|
||||
work->pDCHuffSym = work->maxCodeDC1;
|
||||
work->pDCHuffTbl = work->valPtrDC1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1170,14 +1152,14 @@ void TMCJPEGDEC_set_entropytbl(TMCCJPEGDecWork* work, s32 idx, u8 data) {
|
||||
goto ac1;
|
||||
}
|
||||
if ((s32)data < 1 && (s32)data >= 0) {
|
||||
work->pDCACPtrs[4] = work->huffDecTblAC0;
|
||||
*(void**)work->zigzagData = work->maxCodeAC0;
|
||||
work->pDCACPtrs[5] = work->valPtrAC0;
|
||||
work->pACFast = work->huffDecTblAC0;
|
||||
work->pACHuffSym = work->maxCodeAC0;
|
||||
work->pACHuffTbl = work->valPtrAC0;
|
||||
}
|
||||
return;
|
||||
|
||||
ac1:
|
||||
work->pDCACPtrs[4] = work->huffDecTblAC1;
|
||||
*(void**)work->zigzagData = work->maxCodeAC1;
|
||||
work->pDCACPtrs[5] = work->valPtrAC1;
|
||||
work->pACFast = work->huffDecTblAC1;
|
||||
work->pACHuffSym = work->maxCodeAC1;
|
||||
work->pACHuffTbl = work->valPtrAC1;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
#include <tmc_jpeg_internal.h>
|
||||
|
||||
// clang-format off
|
||||
const u8 TMCJPEGDEC_SampleH_N[24] = {
|
||||
4, 1, 1, 0,
|
||||
2, 1, 1, 0,
|
||||
2, 1, 1, 0,
|
||||
1, 1, 1, 0,
|
||||
1, 1, 1, 0,
|
||||
1, 0, 0, 0
|
||||
const u8 TMCJPEGDEC_SampleH_N[6][4] = {
|
||||
{4, 1, 1, 0},
|
||||
{2, 1, 1, 0},
|
||||
{2, 1, 1, 0},
|
||||
{1, 1, 1, 0},
|
||||
{1, 1, 1, 0},
|
||||
{1, 0, 0, 0}
|
||||
};
|
||||
|
||||
const u8 TMCJPEGDEC_SampleV_N[24] = {
|
||||
1, 1, 1, 0,
|
||||
1, 1, 1, 0,
|
||||
2, 1, 1, 0,
|
||||
2, 1, 1, 0,
|
||||
1, 1, 1, 0,
|
||||
1, 0, 0, 0
|
||||
const u8 TMCJPEGDEC_SampleV_N[6][4] = {
|
||||
{1, 1, 1, 0},
|
||||
{1, 1, 1, 0},
|
||||
{2, 1, 1, 0},
|
||||
{2, 1, 1, 0},
|
||||
{1, 1, 1, 0},
|
||||
{1, 0, 0, 0}
|
||||
};
|
||||
|
||||
const u8 TMCJPEGDEC_Zigzag_data[64] = {
|
||||
|
||||
@@ -10,7 +10,7 @@ static u8 clampU8(s32 v) {
|
||||
}
|
||||
|
||||
static s8 clampS8(s32 v) {
|
||||
return (v < 128 && v > -129) ? (s8)v : (v > 0) ? 127 : -128;
|
||||
return (v < 128 && v > -129) ? v : (v > 0) ? 127 : -128;
|
||||
}
|
||||
|
||||
void TMCJPEGDEC_IdctBlock4x4(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
|
||||
|
||||
@@ -38,7 +38,7 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
s32* conv_row;
|
||||
|
||||
conv_row = (s32*)conv_row_ptr;
|
||||
dcf = work->pDCFast;
|
||||
dcf = work->tables.pDCFast;
|
||||
if (work->bitCount <= 8) {
|
||||
r = TMCJPEGDEC_load_buff(work);
|
||||
if (r < 0) {
|
||||
@@ -54,7 +54,7 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
work->bitCount -= val;
|
||||
val = tmp;
|
||||
} else {
|
||||
val = TMCJPEGDEC_vl_decode_rc(work->pDCHuffTbl, work->pDCHuffSym, work);
|
||||
val = TMCJPEGDEC_vl_decode_rc(work->tables.pDCHuffTbl, work->tables.pDCHuffSym, work);
|
||||
if (val < 0) {
|
||||
return val;
|
||||
}
|
||||
@@ -73,9 +73,9 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
|
||||
*block = dc_predict_row_ptr[0] * conv_row[0];
|
||||
|
||||
ac_fast = work->pACFast;
|
||||
ac_vl = work->pACHuffTbl;
|
||||
ac_sym = work->pACHuffSym;
|
||||
ac_fast = work->tables.pACFast;
|
||||
ac_vl = work->tables.pACHuffTbl;
|
||||
ac_sym = work->tables.pACHuffSym;
|
||||
blk_size = work->blockSize;
|
||||
blk_mul = work->blockSizeMul;
|
||||
|
||||
|
||||
@@ -240,14 +240,14 @@ vowel:
|
||||
}
|
||||
|
||||
ziBool Zi8ITspecialExclusion(ziWChar* ending, ziS32 length, ziU32 candidateLength) {
|
||||
ziPtr beginning;
|
||||
ziWChar* beginning;
|
||||
const ZiExclusionPair* pair;
|
||||
int index;
|
||||
beginning = ending - length--;
|
||||
pair = IT_EXCLUDE_PAIRS;
|
||||
for (; pair->replacement != 0; ++pair) {
|
||||
for (index = 0; index < length; ++index) {
|
||||
if (((ziWChar*)beginning)[index] != pair->prefix[index]) break;
|
||||
if (beginning[index] != pair->prefix[index]) break;
|
||||
}
|
||||
if (index >= length && pair->prefix[index] == 0) {
|
||||
if (!Zi8IsVowel(47, *ending)) return ZI8_TRUE;
|
||||
@@ -258,14 +258,14 @@ ziBool Zi8ITspecialExclusion(ziWChar* ending, ziS32 length, ziU32 candidateLengt
|
||||
}
|
||||
|
||||
ziBool Zi8_814659E8(ziWChar* ending, ziS32 length, ziU32 candidateLength) {
|
||||
ziPtr beginning;
|
||||
ziWChar* beginning;
|
||||
const ZiExclusionPair* pair;
|
||||
int index;
|
||||
beginning = ending - length--;
|
||||
pair = FrenchExcludePairs;
|
||||
for (; pair->replacement != 0; ++pair) {
|
||||
for (index = 0; index < length; ++index) {
|
||||
if (((ziWChar*)beginning)[index] != pair->prefix[index]) break;
|
||||
if (beginning[index] != pair->prefix[index]) break;
|
||||
}
|
||||
if (index >= length && pair->prefix[index] == 0) {
|
||||
if (!Zi8IsVowel(88, *ending)) return ZI8_TRUE;
|
||||
|
||||
@@ -187,7 +187,8 @@ unsigned int Zi8MatchROMdata1(ziWChar *elements, ziU8 count, ziU8 language, ziWC
|
||||
ZI_WORK->groupPtr = (ziU8*)group;
|
||||
if (ZI_WORK->groupPtr == 0) {
|
||||
if (Zi8GetTableSize(language & 0xff,0xb,ZI_WORK) != 0) {
|
||||
ZI_WORK->groupPtr = (ziU8*)(tableAddress = Zi8GetTableAddress(language & 0xff,0xb,ZI_WORK));
|
||||
tableAddress = Zi8GetTableAddress(language & 0xff,0xb,ZI_WORK);
|
||||
ZI_WORK->groupPtr = (ziU8*)tableAddress;
|
||||
}
|
||||
}
|
||||
if (ZI_WORK->groupPtr != 0) {
|
||||
|
||||
@@ -765,8 +765,7 @@ ziU8 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final,
|
||||
*initial = 0x7E00;
|
||||
*final = ((ziU16)Zi8BpmfInitials[value] & 0x7F) << 9;
|
||||
resultCount++;
|
||||
count--;
|
||||
if (count == 0) {
|
||||
if (--count == 0) {
|
||||
*bestInitial = *initial;
|
||||
*bestFinal = *final;
|
||||
if ((value >= 0xE) && (value <= 0x14)) {
|
||||
@@ -778,8 +777,7 @@ ziU8 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final,
|
||||
text++;
|
||||
if (*text == 0xF360) {
|
||||
resultCount++;
|
||||
count--;
|
||||
if (count == 0) {
|
||||
if (--count == 0) {
|
||||
return resultCount;
|
||||
}
|
||||
Zi8ReplaceLastError(0x156, ZI_WORK);
|
||||
@@ -805,8 +803,7 @@ bpmf_value_22:
|
||||
*final |= 0x80;
|
||||
*initial |= 0x180;
|
||||
resultCount++;
|
||||
count--;
|
||||
if (count == 0) {
|
||||
if (--count == 0) {
|
||||
*bestInitial = *initial | 0x78;
|
||||
*bestFinal = *final | 0x38;
|
||||
return resultCount;
|
||||
@@ -817,8 +814,7 @@ bpmf_value_23:
|
||||
*final |= 0x100;
|
||||
*initial |= 0x180;
|
||||
resultCount++;
|
||||
count--;
|
||||
if (count == 0) {
|
||||
if (--count == 0) {
|
||||
*bestInitial = *initial | 0x78;
|
||||
*bestFinal = *final | 0x38;
|
||||
return resultCount;
|
||||
@@ -829,8 +825,7 @@ bpmf_value_24:
|
||||
*final |= 0x180;
|
||||
*initial |= 0x180;
|
||||
resultCount++;
|
||||
count--;
|
||||
if (count == 0) {
|
||||
if (--count == 0) {
|
||||
*bestInitial = *initial | 0x78;
|
||||
*bestFinal = *final | 0x38;
|
||||
return resultCount;
|
||||
@@ -848,8 +843,7 @@ after_bpmf_initial:
|
||||
*final |= (ziU16)Zi8BpmfInitials[value] << 3;
|
||||
*initial |= 0x78;
|
||||
resultCount++;
|
||||
count--;
|
||||
if (count == 0) {
|
||||
if (--count == 0) {
|
||||
*bestInitial = *initial;
|
||||
*bestFinal = *final;
|
||||
return resultCount;
|
||||
@@ -875,8 +869,7 @@ after_bpmf_initial:
|
||||
*bestInitial = *initial;
|
||||
*bestFinal = *final;
|
||||
resultCount++;
|
||||
count--;
|
||||
if (count != 0) {
|
||||
if (--count != 0) {
|
||||
Zi8ReplaceLastError(0x157, ZI_WORK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ ziBool Zi8_81480224(ziUserWord* word ZI_NEED_WORK) {
|
||||
ziUwdNode* previous;
|
||||
ziUwdNode* current;
|
||||
ziUwdNode* added;
|
||||
ziUserWord* candidate;
|
||||
ziU8 position;
|
||||
ziUserWord* candidate;
|
||||
if (ZI_WORK->uwdCount >= 32) {
|
||||
Zi8LogError(0x19D, __zi8_work_data);
|
||||
return 0;
|
||||
@@ -41,7 +41,7 @@ ziBool Zi8_81480224(ziUserWord* word ZI_NEED_WORK) {
|
||||
current = ZI_WORK->uwdList;
|
||||
while (current != 0) {
|
||||
candidate = (ziUserWord*)current->word;
|
||||
if (ZI_WORK->uwdPrioritySort == 1 && candidate->priority < word->priority) break;
|
||||
if (ZI_WORK->uwdPrioritySort == 1 && word->priority > candidate->priority) break;
|
||||
if (candidate->length == length) {
|
||||
position = 0;
|
||||
while (position < length) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <stddef.h>
|
||||
#include <zi8clib/zierror.h>
|
||||
|
||||
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
|
||||
@@ -12,8 +13,8 @@ typedef struct {
|
||||
} ZiKoreanKeyEntry;
|
||||
|
||||
ziU16 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
|
||||
ziU32 value;
|
||||
ziU16 count;
|
||||
ziU16 value;
|
||||
ziU16 i;
|
||||
|
||||
count = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
|
||||
@@ -306,7 +307,7 @@ ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI
|
||||
if (param->wordCharCount == 0) goto scan_key_table;
|
||||
{
|
||||
if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
|
||||
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 8) != 0)) {
|
||||
((keyTable[(search.keyIndex << 3) + search.keyIndex + offsetof(ZiKoreanKeyEntry, keyBytes[4])] & 8) != 0)) {
|
||||
search.wordOffset = ((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childLow |
|
||||
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 3) << 16 |
|
||||
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childHigh << 8);
|
||||
|
||||
@@ -92,8 +92,7 @@ tables_ready:
|
||||
return 0;
|
||||
}
|
||||
|
||||
tableCount = 0;
|
||||
keyIndex = tableCount;
|
||||
keyIndex = tableCount = 0;
|
||||
for (; (ziU16)keyIndex < key; keyIndex++) {
|
||||
tableCount += dataAddress[(ziU16)keyIndex];
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ ziU8 Zi8MatchOEMdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* word
|
||||
ziU32 position;
|
||||
ziU32 fallback = 0;
|
||||
if (!continuation) ZI_WORK->oemIdx = 0;
|
||||
index = ZI_WORK->oemIdx;
|
||||
if ((ziS32)index >= ZI_WORK->oemLen) goto failed;
|
||||
if ((index = ZI_WORK->oemIdx) >= ZI_WORK->oemLen) goto failed;
|
||||
if (ZI_WORK->oemMatch == 0) goto failed;
|
||||
if ((ziS32)length >= (ziS32)--capacity) {
|
||||
failed:
|
||||
@@ -53,8 +52,7 @@ posEntry:
|
||||
}
|
||||
if ((ziS32)position < length) {
|
||||
if (complete) word[length] = 1; else word[length] = 0;
|
||||
index++;
|
||||
if ((ziS32)index >= ZI_WORK->oemLen) goto oemFailed;
|
||||
if (++index >= ZI_WORK->oemLen) goto oemFailed;
|
||||
goto matchRetry;
|
||||
}
|
||||
if (fallback) {
|
||||
@@ -62,8 +60,7 @@ posEntry:
|
||||
*word = *pattern;
|
||||
return 1;
|
||||
}
|
||||
index++;
|
||||
ZI_WORK->oemIdx = index;
|
||||
ZI_WORK->oemIdx = ++index;
|
||||
while (word[position] != 0) position++;
|
||||
return position;
|
||||
matchRetry:
|
||||
|
||||
73
tools/decomp-assist/jpeg-sample-array-types.audit.md
Normal file
73
tools/decomp-assist/jpeg-sample-array-types.audit.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# JPEG sample-array type correction
|
||||
|
||||
Current base: `bf65a26b5e38cddaa37b0e12e15e55ba61f57dd9` (43U only).
|
||||
Original validation base: `e174f2c2bedc4baa28490dcf53989c9a2994bd2e`.
|
||||
|
||||
## Source correction
|
||||
|
||||
- Declare and define `TMCJPEGDEC_SampleH_N` and `TMCJPEGDEC_SampleV_N`
|
||||
consistently as `const u8[6][4]`, using six explicitly grouped rows.
|
||||
- Remove the obsolete H/V declaration conditional. The independent
|
||||
`TMCJPEGDEC_SampleComps` incomplete-array condition and parser flag remain
|
||||
unchanged; they are outside this type mismatch.
|
||||
- Preserve every initializer byte and both existing `[sample][component]`
|
||||
consumers in `TMCJPEGDEC_parse_sof`. Both tables remain 24 bytes, at
|
||||
`.rodata` offsets 0 and 24. No flags, dummy state, casts or assembly added.
|
||||
|
||||
## Original e174f2c2 validation snapshot
|
||||
|
||||
A clean baseline and candidate were built in an isolated leaf with local
|
||||
copies of the recovered tools and original input. Main's build was untouched.
|
||||
The comparisons and numbers in this section describe the JPEG correction
|
||||
relative to the original e174f2c2 baseline, before the disjoint eZiText changes
|
||||
in bf65a26b. They are not current-main metrics.
|
||||
|
||||
- Full `ninja -j4` 43U build passed. The header change rebuilt all 15 dependent
|
||||
objects, followed by linking and the DOL check.
|
||||
- Explicit `ninja build/43U/ok`, with the generated stamp removed first,
|
||||
passed: `build/43U/main.dol: OK`.
|
||||
- DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
- Baseline/candidate full reports are byte-identical, SHA256
|
||||
`dfe72493ec41da47a3052f4903a2ccddccfa1907002b6831274b76ee0b4844ef`.
|
||||
All 1,027 units and 12,563 function records are unchanged.
|
||||
- All 1,027 source objects preserve all 2,717 allocated sections, including
|
||||
bytes, lengths, types, flags and alignments, and all 117,551 relocation
|
||||
records (locations, types, target names/sections/offsets/sizes/bindings and
|
||||
addends). This includes all 15 header-dependent objects.
|
||||
- `jdec_main`: 13/13 exact functions; 5,604/5,604 code bytes and 256/256 data
|
||||
bytes matched and linked. Its complete `.text` and `.rodata` match retail;
|
||||
all 67 relocations have identical canonical destinations and addends.
|
||||
- `jpformat`: 376/376 data bytes matched and linked. `.rodata` is exactly
|
||||
368/368 bytes; both H/V tables retain their bytes and addresses. Existing
|
||||
`.sdata2` remains 6 source bytes versus 8 retail bytes, with identical
|
||||
contents and two retail zero-padding bytes; alignment remains 8. No
|
||||
relocations exist in either object.
|
||||
- `pool_diff.py`: identical pools for all 15 dependents (0/0 strings each).
|
||||
- `ctxdiff.py`, using the recovered local helper: all 13 `jdec_main`
|
||||
functions have equal instruction counts and `diffs 0`; 1,401/1,401 total
|
||||
instructions. `jpformat` contains no functions.
|
||||
- `decomp_status.py` ran. `check_decomp_complete.py` still returns 1 for the
|
||||
existing repository-wide incomplete state; its baseline/candidate findings
|
||||
are identical. This correction makes no repository-completion claim.
|
||||
- `git diff --check` passed.
|
||||
|
||||
Original-snapshot global values were unchanged: 93.996216% exact code, 99.817444% fuzzy,
|
||||
80.08451% linked code, 99.9941% matched data, 85.36267% linked data,
|
||||
12,469/12,563 exact functions and 982/1,027 complete units.
|
||||
|
||||
Detailed local evidence is in the sibling `wii-jpeg-array-evidence` directory:
|
||||
`audit.py`, `audit.txt`, baseline/final build logs and reports,
|
||||
`all-dependent-pools.txt`, `pools-ctxdiff.txt`, `explicit-ok.txt`, and completion
|
||||
checker outputs. Original input and binary build artifacts remain local.
|
||||
|
||||
## Rebased bf65a26b independent verification
|
||||
|
||||
After the disjoint eZiText change in PR #1221 landed, the parent mechanically
|
||||
rebased the correction onto bf65a26b and independently rebuilt both main and
|
||||
the leaf. The parent reported identical full reports and identical allocated
|
||||
sections and relocation records across all 1,027 source objects between that
|
||||
new baseline and the rebased leaf. Both full 43U builds passed and retained
|
||||
DOL SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
|
||||
The correction still preserves the separate `SampleComps` conditional. This
|
||||
audit update changes documentation only; it does not change source or flags.
|
||||
418
tools/decomp-assist/rx35.attempts.md
Normal file
418
tools/decomp-assist/rx35.attempts.md
Normal file
@@ -0,0 +1,418 @@
|
||||
# rx35 compiler correction and allocator evidence
|
||||
|
||||
Worktree sol-high, branch agent/w1005/rx35, HEAD and fetched origin/main
|
||||
38ade13d6fb4320b5779d1e6df4b9250a018b7d8. Existing rx4 logs are untracked
|
||||
and retained. This run owns configure.py and eZiText source only.
|
||||
|
||||
Read AGENTS.md, f-round.md, common.md, levers.md including 20-22, and the
|
||||
mwdbg README before source work. Applied unslop and writing-for-agents.
|
||||
The task authorizes the ZI8 compiler correction and Matching flips despite
|
||||
the older common.md matching-only instruction.
|
||||
|
||||
Acceptance requires every baseline-exact eZiText function to remain exact,
|
||||
unchanged or improved data, honest equivalent C, fresh object evidence,
|
||||
symorder and doldiff for linking, full gate, and DOL SHA1
|
||||
26116613f624061ba99c8d1a299aaa6efa85670d. A compiler correction and its source
|
||||
retuning must be committed together only after that gate passes.
|
||||
|
||||
The installed mwdbg pins GC/3.0a5.2 and rejects GC/3.0a5 before execution.
|
||||
Investigating a local debugger mapping under build/rx35; shared tools remain
|
||||
unchanged. Captures will need independent whole-object identity verification.
|
||||
The ccsweep2 copy changes only its output directory to keep trial objects here.
|
||||
|
||||
Prior rx4 evidence was read for workflow and data-section constraints. Its
|
||||
GC/3.0a5.2 allocator conclusions are not assumed to hold for GC/3.0a5.
|
||||
|
||||
Fresh compiler sweep: EZTX is 7/7 instruction-exact under both versions, so
|
||||
EZTX stays on GC/3.0a5.2. ZI8 GC/3.0a5 immediately matches both zi81key
|
||||
spelling helpers, two zi8cgetc helpers, both zi8getc2 helpers, Zi8GetPyFinal,
|
||||
ZiDAWGgetCHARattribute, and three zkokeyp helpers. The fresh baseline already
|
||||
has ZiDAWGGetGraphInfo exact. All eZiText string pools are identical.
|
||||
|
||||
Regression target maps: Zi8MatchROMdata1 wants elements/count/output/capacity/
|
||||
mode/acceptPrefix in r20/r21/r22/r23/r24/r25 and the table address in r26.
|
||||
GC/3.0a5 spills the current unused integer tableAddress to the stack and shifts
|
||||
those saved registers. Both exclusion functions want ending r27, beginning
|
||||
r28; current code reverses those. Zi8GetBpmfPhonetic wants count r26, value r27;
|
||||
current code reverses those. Zi8_81480224 wants candidate r26, position r27,
|
||||
word-priority evaluated first, and index-first address additions.
|
||||
|
||||
The local debugger port maps 24 hooks by unique relocation-masked instruction
|
||||
sequences, globals by corresponding instruction operands, and all 496 opcode
|
||||
names by exact table comparison. The after-scheduling hook has the same call
|
||||
sequence with one x86 local register changed. Runtime capture and whole-object
|
||||
validation remain required before treating the port as evidence.
|
||||
|
||||
Manual source trials restored three exact regressions. Splitting tableAddress
|
||||
assignment from the groupPtr store restores Zi8MatchROMdata1 to 128/128,
|
||||
100%, data 120/120; nesting a pointer-typed assignment did not. Using a
|
||||
ziWChar pointer for beginning and removing the void-pointer indexing cast
|
||||
restores both exclusions to 51/51 and 100%. Reordering declarations or
|
||||
splitting the postfix length decrement did not.
|
||||
|
||||
Zi8GetBpmfPhonetic restores 309/309 and 100% by combining each count decrement
|
||||
with its following zero test. These are separate full expressions in the
|
||||
same sequence; the tested value remains the decremented byte. Per-site
|
||||
expanded subtraction, declaration order, count-copy and full-width local
|
||||
controls did not match. No caller or public type changes are retained.
|
||||
|
||||
With the split DAWG assignment retained, a fresh link already restores the
|
||||
required DOL SHA1. doldiff reports zero differing bytes. The other regression
|
||||
fixes and new Matching flips still need their final gate.
|
||||
|
||||
New exact functions under GC/3.0a5: Zi8_8148302C uses a halfword character
|
||||
value declared after its table count, 59/59 and 100%; changing the type alone
|
||||
did not fix r27/r28. Zi8getKeyLayout chains keyIndex = tableCount = 0, 182/182
|
||||
and 100%; this moves tableCount from r27 to target r26 and language from r26
|
||||
to target r27. Splitting call assignments and declaration-order controls did
|
||||
not move that pair. The named initialization is semantically unchanged.
|
||||
|
||||
The user-word helper improves from the old main 99.52586 to 99.82758 with
|
||||
position declared before candidate and the word priority tested first.
|
||||
Its remaining two differences commute the operands of address additions.
|
||||
Byte-offset and flexible-array controls did not match; none is retained.
|
||||
|
||||
All three initial Matching flips pass the linked DOL hash and doldiff with
|
||||
zero bytes different. symorder's only discrepancies were anonymous table and
|
||||
exception labels. A second comparison checked every offset, size and named
|
||||
symbol after normalizing only those anonymous names; all three passed.
|
||||
|
||||
Fresh comparison proves the large zi81key functions, Zi8AlphaGetCandidates,
|
||||
zi8InternalGetZH and Zi8PrepareMatch have identical instruction streams under
|
||||
GC/3.0a5 and GC/3.0a5.2. Their earlier allocator hypotheses are therefore
|
||||
being rechecked against new captures, not assumed fixed by the version change.
|
||||
|
||||
Zi8MatchOEMdata is now 192/192 and 100%. Combining all three index updates
|
||||
with their consumers fixes the saved-register cycle: initialize index in its
|
||||
limit check, test ++index directly, and store ++index into oemIdx. One or two
|
||||
combinations reach 99.40104 with only index/length swapped; all three put
|
||||
index r26, length r27, pattern r28 and work r29 as retail requires. Splitting
|
||||
the capacity decrement is a rejected control. Every index update and read
|
||||
remains in its original execution order.
|
||||
|
||||
Data-preserving source controls were run on the larger functions. The three
|
||||
initial spelling-control tags accidentally used absent source spellings and
|
||||
are no-ops, excluded from attempt counts. Corrected postfix, compound and
|
||||
expanded-index forms were then compiled. New a5 measurements reproduce the
|
||||
old 1697/1701 instruction behavior. ZH const-input changes add nine
|
||||
instructions and lose data; native type and compound-mask controls do not
|
||||
move output. Alpha initialization gains a fuzzy fraction but adds two
|
||||
instructions and loses data. Prepare's chained first-element assignment,
|
||||
explicit component-byte cast and split phonetic zero stores were tested
|
||||
alone and in all seven combinations; none preserves the full data credit.
|
||||
|
||||
The shared mwdbg requests stayed queued for over 20 minutes. They were
|
||||
canceled before capture. A private copy of retrowin32 now listens on localhost
|
||||
19035, with its own worktree lock. Only the two-byte TCP port immediate changed
|
||||
in that emulator copy; compiler executables and compiler flags are unchanged.
|
||||
The shared source-search CPU limiter is unchanged. Port patch hashes and the
|
||||
verified x86 instruction are saved in build/rx35/emulator-port.json.
|
||||
|
||||
First a5 debugger run exposed a real layout difference: the function link-name
|
||||
field is +0x40, not a5.2's +0x44. The a5 LinkName routine at 0x556400 and the
|
||||
runtime object both prove +0x40. The mapping was corrected before using any
|
||||
allocator evidence. Failed diagnostics are retained under build/rx35/private-*.
|
||||
|
||||
The corrected a5 debugger capture completed. Its alpha object is byte-identical
|
||||
to an independent wibo compile. The validator checked reversed simplify order,
|
||||
assignment events, representative maps and every PCode register rewrite with
|
||||
zero mismatches. This validates the local port for this capture, not every
|
||||
unsupported debugger feature.
|
||||
|
||||
The exclusion dump exposes an important distinction: ending r28 and beginning
|
||||
r27 are already physical in backend-00 before graph coloring. The graph pass
|
||||
only assigns temporaries r32-r41; r39 merges into call-result r3, and the
|
||||
parameter moves are rejected for interference. Therefore the surviving
|
||||
callee-saved swap originates in the earlier no-opt variable assignment, not
|
||||
in simplify degree or graph coalescing. A typed-beginning capture will confirm
|
||||
the changed preassignment. The earlier heuristic about graph priority alone
|
||||
does not explain these named-register swaps.
|
||||
|
||||
The a5 no-opt selector was traced at 0x46ad60. It scans parameter and local
|
||||
objects, chooses the greatest reference weight, and replaces a choice on an
|
||||
equal weight. Named locals are preassigned before the graph pass begins.
|
||||
Zi8ITspecialExclusion: void beginning has weight 2, below ending 3, so ending
|
||||
gets r28 and beginning r27. Making beginning ziWChar* raises it to weight 3;
|
||||
the local wins the parameter tie and gets target r28, leaving ending r27.
|
||||
The graph priority and call-result coalescing stay unchanged.
|
||||
Zi8getKeyLayout: separate tableCount=0; keyIndex=tableCount makes tableCount
|
||||
weight 7, tied with language, and the local wins r27. Chaining their zero
|
||||
initialization removes the extra tableCount read: weight 6, r26. Language 7
|
||||
now takes target r27. Both mwdbg objects equal independent wibo objects.
|
||||
The remaining UWD and Korean-table address additions retain opposite commuted
|
||||
operands after typed-member, array, integer-address and const controls. No
|
||||
integer-address or byte-offset experiment is retained. Three 1200-second
|
||||
search seeds (49,149,249) now also cover these two functions, using the shared
|
||||
24-slot limiter and immutable source snapshots inside this worktree.
|
||||
|
||||
Fresh no-opt trace confirms the DAWG repair: nested tableAddress assignment
|
||||
has weight 1 and remains on the stack. Splitting the groupPtr assignment
|
||||
raises tableAddress to weight 2, takes target r26, and shifts six weight-2
|
||||
parameters down one register. The object is identical to an independent build.
|
||||
OEM index weight falls 12 -> 9 when its three updates feed their consumers;
|
||||
work/pattern stay weight 12 and length stays 10. The resulting assignments
|
||||
are work r29, pattern r28, length r27, index r26, exactly matching retail.
|
||||
|
||||
Zi8_814834AC target maps i=r28, tableA load=r4, scaled byte index=r3.
|
||||
The source pre-color ADD is v115=v112+v114: tableA v112 (degree 11,
|
||||
priority index 80) resolves r4; offset v114 (degree 9, priority 78) resolves
|
||||
r3; sum v115 (degree 10, priority 77) resolves r3. The second occurrence is
|
||||
v122=v119+v121 with the same assignments. These colors already match retail;
|
||||
the ADD operand order differs before coloring. This is an instruction-
|
||||
selection difference, not a saved-register swap or coalescing failure.
|
||||
Twenty further signed/unsigned address-expression controls did not fix it.
|
||||
|
||||
Prepare's combined element assignment, explicit halfword component-byte cast,
|
||||
and separate phonetic zero stores remove all non-register structural changes
|
||||
except three extra call-result copies (943 vs 940). This candidate loses data
|
||||
and is not retained. Its mwdbg capture and three additional 1200-second seeds
|
||||
349/449/549 are queued to investigate the actual coalescing differences.
|
||||
A 64-shape spelling output-loop experiment did not reach exactness; the best
|
||||
normal source shape is 1701 instructions and remains an unretained trial.
|
||||
|
||||
Debugger transport optimization: stop-local page reads initially missed a
|
||||
cache invalidation after the debugger called LinkName, so those captures
|
||||
reported empty names and failed before recording any result. The cache now
|
||||
clears explicitly after every inferior resume and LinkName call. A repeated
|
||||
51-instruction exclusion capture produced byte-identical regalloc JSON,
|
||||
no-opt events, initial PCode and final PCode versus the uncached capture;
|
||||
the independent object/PCode validator also passes. No failed capture is
|
||||
included as measurement evidence. For large functions only the selected and
|
||||
assigned no-opt hooks are enabled; graph priority/degree/coalescing hooks
|
||||
remain complete. The redundant full candidate-scan ZH capture was interrupted
|
||||
and requeued with that smaller no-opt hook set.
|
||||
|
||||
origin/main advanced externally to 8899a830 during this run. None of its
|
||||
source edits touch eZiText. The rx35 branch remains on its assigned 38ade13d
|
||||
baseline; no fetch, rebase, merge or edit outside this worktree was performed
|
||||
while examining the new ref. Final regression comparisons use the recorded
|
||||
38ade13d baseline and independent baseline-report.json snapshot.
|
||||
|
||||
Transport experiments enabled TCP_NODELAY on only the private emulator/GDB
|
||||
connection. A temporary native shim changes socket options, never compiler
|
||||
memory or flags; both the object and allocator output remain unchanged. The
|
||||
full event trace is still too slow on the 10676-instruction ZH function.
|
||||
A snapshot mode was therefore validated against the full exclusion capture:
|
||||
actual compiler priority list, before-simplify graph, final graph, every
|
||||
register rewrite and final PCode are identical. Large captures retain all
|
||||
coalescing events and named-register assignments, but skip per-node simplify
|
||||
and color-event breakpoints. Their validator explicitly marks those skipped
|
||||
event checks null; graph/PCode and independent-object checks remain required.
|
||||
The interrupted ZH event trace is partial evidence only, not a validated
|
||||
capture. Its complete snapshot capture is queued on a separate private port.
|
||||
|
||||
All original source-search seeds finished. No candidate from seeds
|
||||
49/149/249 produced another exact function. Korean state flattening into
|
||||
normal scalar locals and a real key array was also tested: 682-684 versus
|
||||
669 target instructions, 93.55-94.49%, data 40/180. None is retained.
|
||||
|
||||
Reproduction artifacts: rx35.mwdbg-a5.patch records the private a5 driver,
|
||||
launcher and optional TCP shim relative to the shared tool versions whose
|
||||
SHA256 values are in rx35.mwdbg-port.json. Apply it only to copies. The launcher
|
||||
expects its private files under the current worktree's build/rx35 directory;
|
||||
its default project is now the current directory. Shared debugger files,
|
||||
compiler executables, and other worktrees were not edited.
|
||||
|
||||
Confirmed Bpmf no-opt weights: count 22 -> 15, value remains 21; value moves
|
||||
r26 -> target r27 and count r27 -> target r26. Graph priority is descending
|
||||
v147..v32, max simplify degree 16, with no accepted coalesces in either shape.
|
||||
The count/value change is therefore entirely in named-register preassignment.
|
||||
Korean key helper: count/value both weight 2. Their declaration/type order
|
||||
changes the local tie order from value r28/count r27 to target count r28/value
|
||||
r27; value's explicit halfword calculation is unchanged.
|
||||
UWD: position/candidate both weight 7. Declaring position first changes their
|
||||
local tie order from candidate r27/position r26 to target position r27/
|
||||
candidate r26. Word is r28, work r31, current r30 and added r29 in both.
|
||||
The retained priority comparison orders the reads as in retail. Two ADD
|
||||
operand orders remain; no forced-register source was introduced.
|
||||
|
||||
Prepare structural candidate, measured graph evidence: extra copies at source
|
||||
instruction 87, 646 and 654 are v62->r4, v103->r0 and v104->r4, while retail
|
||||
stores r3 directly. Before simplification their degrees are 7, 6 and 7;
|
||||
priority positions are 189, 150 and 149 (zero-based). All have r3 as an
|
||||
interference neighbor. v62 is also the strokePrefix address in block 117,
|
||||
live beside an index already coalesced to r3; v103/v104 are also the index
|
||||
and recordMasks address in block 28, live beside the 0xff value coalesced to
|
||||
r3. Thus unrelated uses of the same virtual temporary slots block merging
|
||||
those call-result copies. Sixty-three unsigned-index, typed-constant and
|
||||
commuted-OR source variants did not remove all three copies. Three further
|
||||
annealing seeds 349/449/549 completed; only a tiny fuzzy-only candidate was
|
||||
saved, still 943/940 with data loss. It is not retained.
|
||||
|
||||
Korean candidates: retail requires keyTable r28/work r27. Current no-opt
|
||||
weights are keyTable 13/work 14, so the compiler assigns them r27/r28. The
|
||||
other saved values match: param r31 (110), options r30 (40), wordNode r29
|
||||
(27). Removing an identity pointer cast or changing its void view leaves
|
||||
code unchanged. Flattening the pre-existing state makes keyTable miss the
|
||||
no-opt eligibility threshold, adds stack loads, and regresses the function.
|
||||
Reversing real local declarations repairs much of its stack layout, but
|
||||
produces 683/669. Using a typed table gives 661/669 and loses data. None is
|
||||
retained; no new carrier structure is added.
|
||||
|
||||
The larger functions retain their target saved-register roles. Spelling uses
|
||||
tableIndex r31, params r30, character r29, work r28, options r27. Its 207-node
|
||||
priority starts v259,v258,v257; 21 coalesces and 212 interference rejections
|
||||
remain after the postfix/index trial. The trial changes degrees but keeps
|
||||
1701/1700 instructions. Retail needs one fewer byte narrowing and a different
|
||||
pair of support-call copies. Candidates uses params r31, index r30, work r29,
|
||||
options r28; its 188-node priority starts v258,v257,v256, with 39 coalesces and
|
||||
182 interference rejections. It remains 2405/2397 with three extra capacity
|
||||
reloads and a net balance of call-result/index copies.
|
||||
Alpha uses parameters r31, workData r30, index r29, wordCursor r28,
|
||||
optionData r27. Chained dictionary initialization changes 171 -> 172 colored
|
||||
temporaries and 55 -> 56 coalesces; degree graphs and code/data regress, so
|
||||
it is rejected. ZH uses request r31, work r30 and options r29. Making its
|
||||
input read-only leaves those named weights 352/277/99 unchanged but changes
|
||||
206 -> 210 colored temporaries and 31 -> 27 coalesces, adding nine instructions.
|
||||
The live ZH and Alpha differences include expression/store order as well as
|
||||
register choices; neither is classified as a proven pure allocator tie.
|
||||
All degree summaries for snapshot captures refer to the before-simplify graph.
|
||||
Every PCode register rewrite checked in these captures agrees with the final
|
||||
graph: Spelling 2979, Candidates 4499, Alpha 6545 and ZH 18821 operands.
|
||||
|
||||
Final clean gate: PASS, all 31 eZiText units included; zero baseline-exact
|
||||
function drops, zero code/data/link regressions, zero forbidden additions,
|
||||
zero readability warnings. The build was cleaned by gate.py before rebuilding.
|
||||
The independent stored 38ade13d report also shows zero exact-function drops.
|
||||
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
doldiff: 0 differing bytes; both files 3867904 bytes.
|
||||
New Matching units: zi8getc2, zidawg1, zi8match, zmtkey, zoemdata.
|
||||
Their symbol order, offsets, sizes and named symbols agree after normalizing
|
||||
only anonymous @ and jump-table names. Raw symorder logs are in build/rx35.
|
||||
The actual linked DOL independently validates their placement.
|
||||
|
||||
EziText exact functions: 127 -> 141 / 149. Eight functions remain nonexact;
|
||||
zi81key still accounts for the final 108 unmatched data bytes. The complete-
|
||||
project checker reports DECOMPLETE_FAIL because code/data/link totals remain
|
||||
incomplete. No project-completion claim is made. Global worker-baseline code:
|
||||
94.00436% exact, 99.81261% fuzzy, 79.93427% linked; data 99.99410% matched.
|
||||
Zi8GetKOcandidates has a disclosed fuzzy-only compiler-version drop,
|
||||
98.87145 -> 98.72197; it was already nonexact and the required exact-name
|
||||
regression gate passes. Full per-function before/after values and measures
|
||||
are in rx35.results.json.
|
||||
|
||||
Completed searches:
|
||||
Zi8MatchOEMdata-249.log: done 827 trials; best-nodrop energy -98.8802
|
||||
Zi8MatchOEMdata-49.log: done 1382 trials; best-nodrop energy -98.8802
|
||||
Zi8_81480224-149.log: done 1092 trials; best-nodrop energy -99.8276
|
||||
zi8InternalGetZH-249.log: done 457 trials; best-nodrop energy -98.3363
|
||||
Zi8Get1KeyPressCandidates-49.log: done 1139 trials; best-nodrop energy -80.4193
|
||||
Zi8_81480224-49.log: done 1075 trials; best-nodrop energy -99.8276
|
||||
Zi8PrepareMatch-249.log: done 792 trials; best-nodrop energy -96.9947
|
||||
Zi8Get1KeyPressSpelling-249.log: done 713 trials; best-nodrop energy -97.5559
|
||||
Zi8_814834AC-149.log: done 1066 trials; best-nodrop energy -99.9417
|
||||
Zi8Get1KeyPressCandidates-149.log: done 1131 trials; best-nodrop energy -80.4193
|
||||
Zi8_81480224-249.log: done 1072 trials; best-nodrop energy -99.8276
|
||||
Zi8AlphaGetCandidates-49.log: done 1020 trials; best-nodrop energy -95.6485
|
||||
zi8InternalGetZH-149.log: done 597 trials; best-nodrop energy -98.3363
|
||||
Zi8Get1KeyPressCandidates-249.log: done 678 trials; best-nodrop energy -80.4193
|
||||
Zi8_814834AC-49.log: done 1061 trials; best-nodrop energy -99.9417
|
||||
Zi8MatchOEMdata-149.log: done 837 trials; best-nodrop energy -98.8802
|
||||
Zi8PrepareMatch-49.log: done 1312 trials; best-nodrop energy -96.9947
|
||||
zi8InternalGetZH-49.log: done 746 trials; best-nodrop energy -98.3363
|
||||
Zi8GetKOcandidates-49.log: done 1284 trials; best-nodrop energy -98.722
|
||||
Zi8getKeyLayout-49.log: done 1385 trials; best-nodrop energy -99.533
|
||||
Zi8getKeyLayout-249.log: done 818 trials; best-nodrop energy -99.533
|
||||
Zi8PrepareMatch-149.log: done 797 trials; best-nodrop energy -96.9947
|
||||
Zi8GetKOcandidates-149.log: done 1300 trials; best-nodrop energy -98.722
|
||||
Zi8Get1KeyPressSpelling-49.log: done 1164 trials; best-nodrop energy -97.5559
|
||||
Zi8_814834AC-249.log: done 1051 trials; best-nodrop energy -99.9417
|
||||
Zi8Get1KeyPressSpelling-149.log: done 1179 trials; best-nodrop energy -97.5559
|
||||
Zi8GetKOcandidates-249.log: done 790 trials; best-nodrop energy -98.722
|
||||
Zi8AlphaGetCandidates-249.log: done 850 trials; best-nodrop energy -95.6485
|
||||
Zi8getKeyLayout-149.log: done 869 trials; best-nodrop energy -99.533
|
||||
Zi8AlphaGetCandidates-149.log: done 654 trials; best-nodrop energy -95.6485
|
||||
prepare-structural-search-349.log: done 1169 trials; best-nodrop energy -91.367
|
||||
prepare-structural-search-449.log: done 1183 trials; best-nodrop energy -91.367
|
||||
prepare-structural-search-549.log: done 1173 trials; best-nodrop energy -91.3681
|
||||
|
||||
Unit exact-function counts, recorded from the final fresh report:
|
||||
zi81key: 5 -> 7 / 9
|
||||
zi8alpha: 11 -> 11 / 12
|
||||
zi8cgetc: 5 -> 7 / 8
|
||||
zi8getc2: 15 -> 17 / 17
|
||||
zi8match: 9 -> 10 / 10
|
||||
zi8uwd: 3 -> 3 / 4
|
||||
zidawg1: 5 -> 6 / 6
|
||||
zkokeyp: 1 -> 5 / 7
|
||||
zmtkey: 3 -> 4 / 4
|
||||
zoemdata: 2 -> 3 / 3
|
||||
zprepare: 0 -> 0 / 1
|
||||
|
||||
Final debugger validation:
|
||||
All 40 completed captures match their independent wibo objects. The two large
|
||||
zi8InternalGetZH captures contain three conditional branches whose targets
|
||||
exceed the signed 16-bit branch range. Each becomes an inverted conditional
|
||||
skip plus an unconditional branch; the apparent three-instruction PCode
|
||||
alignment failure is fully explained. The supplemental validator checks the
|
||||
inverted predicate (excluding its prediction hint), CR bit, eight-byte skip,
|
||||
original out-of-range displacement and exact destination block. It then
|
||||
checks all ordinary machine-register operands with those three expansions
|
||||
accounted for: 8604 instructions / 16379 operands for the baseline and 8615 /
|
||||
16401 for the rejected const-input trial. The original naive alignment result
|
||||
is retained beside this proof in rx35.allocator.json.
|
||||
|
||||
The reproduction patch now includes the snapshot-aware validator and both
|
||||
far-branch validation scripts. Run validate.py with a local build/tools/wibo,
|
||||
then check-long-branches.py and validate-expanded-branches.py for the named
|
||||
ZH captures. No shared debugger or other worktree was modified. All 141 exact
|
||||
eZiText functions also passed fresh ctxdiff with identical instruction counts
|
||||
and zero differences (build/rx35/final-ctxdiff.json). No source or configure
|
||||
change was made after the clean all-unit gate.
|
||||
|
||||
## Landing repair: Zi8GetKOcandidates only
|
||||
|
||||
Resumed at fed3bdbb after the orchestrator rebased and removed bulky artifacts.
|
||||
The new acceptance rule compares every function score, including fuzzy ones.
|
||||
Required minimum: the old-compiler score 98.87145, with every other eZiText
|
||||
function unchanged from this resumed branch. Only zkokeyp.c and this log are
|
||||
in scope. All new captures, measurements and rejected trials stay in build/rx35r1.
|
||||
|
||||
Fresh source baseline: Zi8GetKOcandidates 98.72197, 669/669 instructions,
|
||||
zkokeyp data 180/180. Pool identical. The other six function scores match the
|
||||
accepted branch, including Zi8_814834AC at 99.94169.
|
||||
|
||||
Rejected controls: pointer/index association and signed byte views leave the
|
||||
same output; arithmetic and typed-record subscripts usually change instruction
|
||||
counts and lose data. Splitting output increments, changing condition forms,
|
||||
removing redundant casts, and consolidating null-error handling did not meet
|
||||
the score floor. A real five-byte array initializer reached 98.7728 but moved
|
||||
stack objects; it is not retained. No carrier, forced register, redundant
|
||||
operation or compiler change is retained.
|
||||
|
||||
Accepted source: read the first packed key flag through the byte table using
|
||||
offsetof(ZiKoreanKeyEntry, keyBytes[4]). This names the same existing field
|
||||
instead of casting the computed address to a record and then selecting it.
|
||||
The row offset is still keyIndex*9; keyIndex is unsigned 16-bit and the 0xffff
|
||||
sentinel still short-circuits before the read. The additional field offset is
|
||||
four, so all arithmetic is within signed 32-bit range. The same unsigned byte
|
||||
and bit 8 are tested, with unchanged calls, side effects and branch condition.
|
||||
stddef.h supplies offsetof; no layout, symbol, flag or public type changed.
|
||||
|
||||
mwdbg confirms keyTable's reference weight rises 13 -> 14. It ties the work
|
||||
parameter at 14 and wins the local/parameter tie: keyTable r28, work r27, as
|
||||
retail requires. Param/options/wordNode remain r31/r30/r29 at weights
|
||||
110/40/27. The 213-node GPR priority order and 14 successful coalesces remain;
|
||||
52 candidate coalesces are rejected for interference. This is a named-register
|
||||
preassignment repair, not a different graph coloring priority. The capture
|
||||
matches an independent wibo object byte-for-byte. All 1224 allocation operand
|
||||
rewrites and 1027 machine-register operands across 537 instructions pass.
|
||||
|
||||
Focused result: Zi8GetKOcandidates 98.72197 -> 98.998505, still 669/669.
|
||||
All six other function scores are identical and data stays 180/180.
|
||||
The clean eZiText gate and explicit per-function fuzzy comparisons follow.
|
||||
|
||||
The graph priority and coalesced representative pairs compare identical.
|
||||
Before-simplify degree changes: v59 6->5, v58 8->7.
|
||||
Focused ctxdiff improves from 103 to 71 differences, both 669 instructions.
|
||||
There are 214 private compile records, including controls and baseline refreshes.
|
||||
|
||||
Final clean gate: GATE PASS across all 31 eZiText units, base 044ab571.
|
||||
Baseline regressions, forbidden additions and readability warnings are all zero.
|
||||
Fresh reports compare all 149 eZiText functions: only Zi8GetKOcandidates
|
||||
changes, 98.72197 -> 98.998505. Every other function score is identical.
|
||||
All eZiText scores meet or exceed the pre-switch 044ab571 baseline; the
|
||||
old score for this function was 98.87145. No common function in the full
|
||||
project report has a fuzzy drop against that baseline either.
|
||||
DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
Only zkokeyp.c and this .md log are committed; artifacts remain under build/rx35r1.
|
||||
291
tools/decomp-assist/rx48.cleanup.md
Normal file
291
tools/decomp-assist/rx48.cleanup.md
Normal file
@@ -0,0 +1,291 @@
|
||||
# rx48 expression cleanup
|
||||
|
||||
Base: `7c64b0a1f94be5770d04288c93d0c668f43d4250`, branch `agent/w1005/rx48`.
|
||||
Scope: TMC_JPEG except texturecvtr and buffer/idct_block_var.c. Excluded files may receive identifier renames only.
|
||||
|
||||
Acceptance: preserve complete source object bytes, every objdiff measure and per-function score, identical pools, and the full 43U DOL SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`. This expression-cleanup assignment supersedes the generic requirement to gain exact matches.
|
||||
|
||||
Fresh baseline: 1027 source objects saved under `/tmp/rx48-cleanup`; all 11 owned pools identical. Owned totals are 47/49 exact functions, 17724/20616 matched code bytes, and 632/632 matched data bytes. The two pre-existing EXIF mismatches must stay unchanged. Pre-existing untracked g2 logs are outside this change.
|
||||
|
||||
Prior evidence: `rx38.cleanup.md` records rejected direct-work member substitutions, public state field renaming, and control-flow/cast changes. This round tests typed component/table views and remaining independent expressions. Public init fields `unk_0x24` and `unk_0x2C` have out-of-scope users in `src/utility/iplJpegDecoder.cpp`; retain them. Unknown storage gets a semantic name only when uses prove its role.
|
||||
|
||||
## Trials
|
||||
|
||||
- KEEP component view: move existing TMCFrameComponents definition into internal header: all checked object bytes identical. Trial 001.
|
||||
- KEEP decompmcu: address DC predictors through existing component view: all checked object bytes identical. Trial 002.
|
||||
- KEEP decompmcu: quantization selector through component view: all checked object bytes identical. Trial 003.
|
||||
- KEEP decompmcu: entropy selectors through component view: all checked object bytes identical. Trial 004.
|
||||
- KEEP decompmcu: component base is a typed pointer throughout: all checked object bytes identical. Trial 005.
|
||||
- REVERT decompmcu: block-count cursor starts at the frame member: jdec_main: TMCJPEGDEC_decompmcu. Trial 006.
|
||||
- REVERT typed table layout: replace shifted work casts and overlapping placeholders with quantization and Huffman members: compile failure. Trial 007.
|
||||
- KEEP typed table layout: replace shifted work casts and overlapping placeholders with quantization and Huffman members: all checked object bytes identical. Trial 008.
|
||||
- KEEP internal header: name four existing alignment gaps: all checked object bytes identical. Trial 009.
|
||||
- REVERT decompmcu: preserve typed frame base and use its block-count array: jdec_main: TMCJPEGDEC_decompmcu. Trial 010.
|
||||
- REVERT decompmcu: direct block-count array instead of byte cursor: jdec_main: TMCJPEGDEC_decompmcu. Trial 011.
|
||||
- REVERT decompmcu: cursor based on existing work block-count field: jdec_main: TMCJPEGDEC_decompmcu. Trial 012.
|
||||
- KEEP work components: use a real nested member for all component metadata: all checked object bytes identical. Trial 013.
|
||||
- KEEP scan parser: share the component type instead of a local duplicate: all checked object bytes identical. Trial 014.
|
||||
- KEEP public EXIF header: name three proven alignment gaps: all checked object bytes identical. Trial 015.
|
||||
- KEEP public EXIF info: name alignment after converterType: all checked object bytes identical. Trial 016.
|
||||
- REVERT decompmcu: const typed frame while preserving byte cursor: jdec_main: TMCJPEGDEC_decompmcu. Trial 017.
|
||||
- KEEP EXIF decoder state: type fields actually accessed by Setsize, converters and restart handling: all checked object bytes identical. Trial 018.
|
||||
- REVERT public decoder state: name trailing alignment gap: iplNandSDWorker; iplNandSDCardManager. Trial 019.
|
||||
|
||||
## Layout evidence
|
||||
|
||||
The old table declaration contained shifted aliases. The table helpers received `work + 0x58` cast as a complete work object. Their apparent `zigzagData + 8`, `huffDecTblDC1`, and `valPtrDC0` accesses therefore addressed table-relative offsets `0x460`, `0x860`, and `0x1460`. The replacement defines those arrays at the actual helper addresses and passes `TMCJpegTableInfo*` throughout. Quantization coefficients occupy four 256-byte tables. Two untouched words retain reserved names because this source never accesses them.
|
||||
|
||||
EXIF state fields are proven by the existing `work->pState = (TMCCJPEGDecState*)pInfo` assignment and calls into Setsize, converters, and restart handling. Their offsets equal the public decoder-state members. Four opaque public ranges and the public decoder-state debug layout remain constrained.
|
||||
|
||||
Target MWCC compile-time assertions pass:
|
||||
|
||||
```text
|
||||
MWCC layout PASS: 70 sizeof/offsetof assertions
|
||||
sizeof(TMCCJPEGDecWork) = 0x19e8
|
||||
sizeof(TMCFrameComponents) = 0x24
|
||||
sizeof(TMCJpegTableInfo) = 0x1798
|
||||
sizeof(TMCJpegFrameInfo) = 0x30
|
||||
sizeof(TMCCJPEGDecInitParam) = 0x30
|
||||
sizeof(TMCCJPEGDecState) = 0x6d4
|
||||
sizeof(TMCCJPEGDecExifInfo) = 0x6d4
|
||||
sizeof(TMCCJPEGDecExifData) = 0x67c
|
||||
offsetof(TMCCJPEGDecWork, components) = 0x2c
|
||||
offsetof(TMCCJPEGDecWork, components.dcPredict) = 0x30
|
||||
offsetof(TMCCJPEGDecWork, components.id) = 0x40
|
||||
offsetof(TMCCJPEGDecWork, components.quantTable) = 0x44
|
||||
offsetof(TMCCJPEGDecWork, components.dcTable) = 0x48
|
||||
offsetof(TMCCJPEGDecWork, components.acTable) = 0x4c
|
||||
offsetof(TMCCJPEGDecWork, tables) = 0x58
|
||||
offsetof(TMCCJPEGDecWork, tables.zigzagData) = 0x458
|
||||
offsetof(TMCCJPEGDecWork, tables.pDCFast) = 0x498
|
||||
offsetof(TMCCJPEGDecWork, tables.pDCHuffTbl) = 0x49c
|
||||
offsetof(TMCCJPEGDecWork, tables.pDCHuffSym) = 0x4a0
|
||||
offsetof(TMCCJPEGDecWork, tables.reservedDC) = 0x4a4
|
||||
offsetof(TMCCJPEGDecWork, tables.pACFast) = 0x4a8
|
||||
offsetof(TMCCJPEGDecWork, tables.pACHuffTbl) = 0x4ac
|
||||
offsetof(TMCCJPEGDecWork, tables.pACHuffSym) = 0x4b0
|
||||
offsetof(TMCCJPEGDecWork, tables.reservedAC) = 0x4b4
|
||||
offsetof(TMCCJPEGDecWork, tables.quantTblFlag) = 0x17e8
|
||||
offsetof(TMCCJPEGDecWork, tables.dcTblFlag) = 0x17ec
|
||||
offsetof(TMCCJPEGDecWork, tables.acTblFlag) = 0x17ee
|
||||
offsetof(TMCCJPEGDecWork, frameWidth) = 0x17f0
|
||||
offsetof(TMCCJPEGDecWork, scanCompCount) = 0x180b
|
||||
offsetof(TMCCJPEGDecWork, blockCount) = 0x180c
|
||||
offsetof(TMCCJPEGDecWork, restartInterval) = 0x181a
|
||||
offsetof(TMCCJPEGDecWork, idctPtr) = 0x1820
|
||||
offsetof(TMCCJPEGDecWork, pConvRowPtrs) = 0x183c
|
||||
offsetof(TMCCJPEGDecWork, convBuf) = 0x1858
|
||||
offsetof(TMCCJPEGDecWork, pitch) = 0x19de
|
||||
offsetof(TMCCJPEGDecWork, pState) = 0x19e4
|
||||
offsetof(TMCJpegTableInfo, huffDecTblDC0) = 0x460
|
||||
offsetof(TMCJpegTableInfo, huffDecTblDC1) = 0x860
|
||||
offsetof(TMCJpegTableInfo, huffDecTblAC0) = 0xc60
|
||||
offsetof(TMCJpegTableInfo, huffDecTblAC1) = 0x1060
|
||||
offsetof(TMCJpegTableInfo, valPtrDC0) = 0x1460
|
||||
offsetof(TMCJpegTableInfo, valPtrDC1) = 0x14a4
|
||||
offsetof(TMCJpegTableInfo, valPtrAC0) = 0x14e8
|
||||
offsetof(TMCJpegTableInfo, valPtrAC1) = 0x152c
|
||||
offsetof(TMCJpegTableInfo, maxCodeDC0) = 0x1570
|
||||
offsetof(TMCJpegTableInfo, maxCodeDC1) = 0x1580
|
||||
offsetof(TMCJpegTableInfo, maxCodeAC0) = 0x1590
|
||||
offsetof(TMCJpegTableInfo, maxCodeAC1) = 0x1690
|
||||
offsetof(TMCCJPEGDecExifInfo, posX) - offsetof(TMCCJPEGDecState, posX) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, posY) - offsetof(TMCCJPEGDecState, posY) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, position) - offsetof(TMCCJPEGDecState, position) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, maxX) - offsetof(TMCCJPEGDecState, maxX) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, maxY) - offsetof(TMCCJPEGDecState, maxY) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, stepX) - offsetof(TMCCJPEGDecState, stepX) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, stepY) - offsetof(TMCCJPEGDecState, stepY) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, stepXExt) - offsetof(TMCCJPEGDecState, stepXExt) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, stepYExt) - offsetof(TMCCJPEGDecState, stepYExt) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, dataSizeX) - offsetof(TMCCJPEGDecState, dataSizeX) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, dataSizeY) - offsetof(TMCCJPEGDecState, dataSizeY) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, componentCount) - offsetof(TMCCJPEGDecState, componentCount) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, jpegWidth) - offsetof(TMCCJPEGDecState, jpegWidth) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, jpegHeight) - offsetof(TMCCJPEGDecState, jpegHeight) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, outputWidth) - offsetof(TMCCJPEGDecState, outputWidth) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, outputHeight) - offsetof(TMCCJPEGDecState, outputHeight) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, convWidth) - offsetof(TMCCJPEGDecState, convWidth) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, convHeight) - offsetof(TMCCJPEGDecState, convHeight) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, pTexBuffer) - offsetof(TMCCJPEGDecState, pTexBuffer) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, pWorkBuf) - offsetof(TMCCJPEGDecState, pWorkBuf) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, decodeResult) - offsetof(TMCCJPEGDecState, decodeResult) = 0x0
|
||||
offsetof(TMCCJPEGDecExifInfo, converterType) - offsetof(TMCCJPEGDecState, converterType) = 0x0
|
||||
```
|
||||
|
||||
First group quick gate: GATE PASS; 0 regressions, forbidden patterns, or readability warnings. All 1027 complete source objects still match the fresh baseline.
|
||||
|
||||
## Further expression trials
|
||||
|
||||
- KEEP IFD0/IFD1 rational values: derive denominator offset from scalar size: all checked object bytes identical. Trial 020.
|
||||
- KEEP IFD0 transfer/date values: derive read bounds and copy length from field types: all checked object bytes identical. Trial 021.
|
||||
- REVERT IFD0/IFD1 entries: use typed tag, type and value byte fields: exif_parse: TMCJPEGDEC_IFD0_tag_parse. Trial 022.
|
||||
- REVERT IFD0/IFD1 ignored tags: return directly from the no-op cases: exif_parse: TMCJPEGDEC_IFD0_tag_parse, TMCJPEGDEC_IFD1_tag_parse. Trial 023.
|
||||
- KEEP Huffman initialization: size all twelve table clears from typed arrays: all checked object bytes identical. Trial 024.
|
||||
- KEEP buffer initialization: use SDK DEFAULT_ALIGN for both alignment checks: all checked object bytes identical. Trial 025.
|
||||
- KEEP thumbnail buffer: do lookbehind arithmetic on the byte pointer: all checked object bytes identical. Trial 026.
|
||||
- KEEP IFD0/IFD1 entries without changing IFD0 constness: use typed tag, type and value byte fields: all checked object bytes identical. Trial 027.
|
||||
- KEEP EXIF traversal: derive directory-entry strides from the entry type: all checked object bytes identical. Trial 028.
|
||||
- KEEP AC lookup: keep the table index without cancelling shifts: all checked object bytes identical. Trial 029.
|
||||
- KEEP signed IDCT clamp: rely on the declared return type for narrowing: all checked object bytes identical. Trial 030.
|
||||
- KEEP scan geometry: replace boolean-to-one ternaries with their comparisons: all checked object bytes identical. Trial 031.
|
||||
- REVERT frame parser: compare component count without redundant signed promotions: jdec_main: TMCJPEGDEC_parse_sof. Trial 032.
|
||||
- KEEP scan geometry: let byte fields perform assignment narrowing: all checked object bytes identical. Trial 033.
|
||||
- KEEP scan geometry: remove duplicate unsigned product conversion: all checked object bytes identical. Trial 034.
|
||||
- KEEP decompmcu: compare byte block count without explicit signed promotion: all checked object bytes identical. Trial 035.
|
||||
- REVERT decompmcu: typed frame and block cursor after removing count promotion: jdec_main: TMCJPEGDEC_decompmcu. Trial 036.
|
||||
- KEEP quantization parser: rely on unsigned table entry to promote byte product: all checked object bytes identical. Trial 037.
|
||||
|
||||
## Scope audit and remaining expressions
|
||||
|
||||
Reviewed all 11 owned units. `jpformat.c` contains fixed sampling and zigzag tables. `decapi.c` and `jdec.c` retain the already-tested rx38 expressions that change bytes. No owned source uses GX, NAND, ES, CARD, button-mask, or scene constants. The two buffer alignment checks now use the SDK's existing `DEFAULT_ALIGN`.
|
||||
|
||||
All 17 internal `unk_` declarations are gone. Eight public placeholder declarations became typed EXIF state members or named alignment gaps. Eleven public placeholders remain: two init fields have out-of-scope users, four opaque ranges have no proven role, and five decoder-state fields are constrained by the observed changes to unrelated debug objects. No excluded source file changed.
|
||||
|
||||
The table and component members replaced shifted work-pointer casts, quantization offsets, selector offsets, and pointer-slot indexing. The EXIF directory entry uses byte arrays because its values have file-selected endianness and may be unaligned. The IFD0 pointer retains its original mutability; adding const changed instructions.
|
||||
|
||||
The remaining `decompmcu` frame byte cursor is load-bearing. Trials 006, 010, 011, 012, 017, and 036 tested different member/cursor forms. Trial 036 has 113/113 instructions but 13 differences, all register allocation. It was reverted. The focused diff is saved in `/tmp/rx48-cleanup/trial-036.txt`.
|
||||
|
||||
Both existing nonmatching functions have at least three distinct compiled cleanup trials. IFD0: denominator size 020, transfer/date bounds 021, typed entries 022/027, direct returns 023. IFD1: denominator size 020, typed entries 022/027, direct returns 023. Their original mismatches remain unchanged; this task requires preservation, not new matches.
|
||||
|
||||
Accepted counts describe expression sites except layouts and placeholder declarations: four typed layouts, 25 placeholder declarations removed, 25 constant/size substitutions, seven independent cast simplifications, two boolean-ternary simplifications, and one cancelling-shift simplification. Casts and offsets eliminated as part of the typed layouts are counted with those layouts, not again. The 25 size substitutions comprise 12 table clears, two alignment checks, four rational offsets, four transfer/date bounds or increments, and three directory-entry strides.
|
||||
|
||||
## Final verification
|
||||
|
||||
Full clean gate, without `--quick`, passed for all 11 owned units. No source edits followed it. The fresh report and complete ELF hashes match the starting snapshot across all 1027 source units.
|
||||
|
||||
```text
|
||||
Whole-object SHA256: 1027/1027 unchanged
|
||||
Objdiff measures/sections/functions: 1027 units unchanged
|
||||
Pools: 15/15 identical
|
||||
Ctxdiff: 47/49 exact functions, two original EXIF mismatches unchanged
|
||||
Owned matched code/data: 17724/632 bytes unchanged
|
||||
main.dol SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d
|
||||
BYTE PRESERVATION PASS
|
||||
MWCC layout PASS: 75 sizeof/offsetof assertions
|
||||
```
|
||||
|
||||
The final layout pass adds EXIF entry checks: size 12, tag offset 0, type offset 2, count offset 4, value offset 8. The public-state overlay checks and internal work offsets above pass unchanged.
|
||||
|
||||
Before -> after: instruction-exact functions 47/49 -> 47/49; objdiff code 17724/20616 -> 17724/20616 bytes; data 632/632 -> 632/632 bytes.
|
||||
|
||||
Open matching work, unchanged:
|
||||
|
||||
- `TMCJPEGDEC_IFD0_tag_parse`: 99.49065%, 480/481 instructions, dispatch and register differences.
|
||||
- `TMCJPEGDEC_IFD1_tag_parse`: 96.14876%, 239/242 instructions, dispatch and register differences.
|
||||
|
||||
Final gate command:
|
||||
|
||||
```sh
|
||||
python3 /mnt/drive2/projects/wii-ipl-workers/_restore0928-tools/gate.py \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3 \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/api/decapi \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3 \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var \
|
||||
libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32 \
|
||||
--base 7c64b0a1f94be5770d04288c93d0c668f43d4250
|
||||
```
|
||||
|
||||
```text
|
||||
full build: ok
|
||||
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] objdiff: code 1228/1228 data None/None functions 2/2 fuzzy 100.0000 linked code 1228
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] instruction-exact functions: 2/2
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] section .text size 1228 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3] baseline: code 1228/1228 data None functions 2 fuzzy 100.0000
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] objdiff: code 2444/2444 data None/None functions 10/10 fuzzy 100.0000 linked code 2444
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] instruction-exact functions: 10/10
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] section .text size 2444 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system] baseline: code 2444/2444 data None functions 10 fuzzy 100.0000
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] objdiff: code 316/316 data None/None functions 3/3 fuzzy 100.0000 linked code 316
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] instruction-exact functions: 3/3
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] section .text size 316 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode] baseline: code 316/316 data None functions 3 fuzzy 100.0000
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] objdiff: code 1100/1100 data None/None functions 3/3 fuzzy 100.0000 linked code 1100
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] instruction-exact functions: 3/3
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] section .text size 1100 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/api/decapi] baseline: code 1100/1100 data None functions 3 fuzzy 100.0000
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] objdiff: code 1020/1020 data None/None functions 3/3 fuzzy 100.0000 linked code 1020
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] instruction-exact functions: 3/3
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] section .text size 1020 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec] baseline: code 1020/1020 data None functions 3 fuzzy 100.0000
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] objdiff: code 5604/5604 data 256/256 functions 13/13 fuzzy 100.0000 linked code 5604
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] instruction-exact functions: 13/13
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .rodata size 256 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] section .text size 5604 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main] baseline: code 5604/5604 data 256 functions 13 fuzzy 100.0000
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] objdiff: code None/None data 376/376 functions 0/None fuzzy 100.0000 linked code 0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] instruction-exact functions: 0/0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] section .rodata size 368 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] section .sdata2 size 8 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jpformat] baseline: code None/None data 376 functions 0 fuzzy 100.0000
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] objdiff: code 2196/5088 data None/None functions 4/6 fuzzy 99.0747 linked code 0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] instruction-exact functions: 4/6
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] section .text size 5088 match 99.074684
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] below 100: TMCJPEGDEC_IFD0_tag_parse 99.49065
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] below 100: TMCJPEGDEC_IFD1_tag_parse 96.14876
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse] baseline: code 2196/5088 data None functions 4 fuzzy 99.0747
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] objdiff: code 908/908 data None/None functions 2/2 fuzzy 100.0000 linked code 908
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] instruction-exact functions: 2/2
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] section .text size 908 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3] baseline: code 908/908 data None functions 2 fuzzy 100.0000
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] objdiff: code 1804/1804 data None/None functions 6/6 fuzzy 100.0000 linked code 1804
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] instruction-exact functions: 6/6
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] section .text size 1804 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var] baseline: code 1804/1804 data None functions 6 fuzzy 100.0000
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] pool: IDENTICAL
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] objdiff: code 1104/1104 data None/None functions 1/1 fuzzy 100.0000 linked code 1104
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] instruction-exact functions: 1/1
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] section .text size 1104 match 100.0
|
||||
[libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32] baseline: code 1104/1104 data None functions 1 fuzzy 100.0000
|
||||
regressions vs baseline: 0
|
||||
global matched_code_percent: 93.99622 -> 93.99622
|
||||
global fuzzy_match_percent: 99.81744 -> 99.81744
|
||||
global complete_code_percent: 80.08451 -> 80.08451
|
||||
global matched_data_percent: 99.99410 -> 99.99410
|
||||
forbidden patterns added (net, per file): 0
|
||||
readability warnings (net, per file; must be 0 in the final result): 0
|
||||
GATE PASS
|
||||
```
|
||||
|
||||
## Files and commits
|
||||
|
||||
```text
|
||||
libs/RVLMiddleware/TMC_JPEG/include/tmc_jpeg.h
|
||||
libs/RVLMiddleware/TMC_JPEG/include/tmc_jpeg_internal.h
|
||||
libs/RVLMiddleware/TMC_JPEG/src/b65/iqdec_b65_frv32.c
|
||||
libs/RVLMiddleware/TMC_JPEG/src/buffer/buffer_system.c
|
||||
libs/RVLMiddleware/TMC_JPEG/src/buffer/getcode.c
|
||||
libs/RVLMiddleware/TMC_JPEG/src/buffer/mkhdec3.c
|
||||
libs/RVLMiddleware/TMC_JPEG/src/exif/exif_parse.c
|
||||
libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main.c
|
||||
libs/RVLMiddleware/TMC_JPEG/src/reschange/idct_resolution_change_var.c
|
||||
libs/RVLMiddleware/TMC_JPEG/src/reschange/iqdec_resolution_change_a3.c
|
||||
tools/decomp-assist/rx48.cleanup.md
|
||||
```
|
||||
|
||||
```text
|
||||
fee427cd refactor: type jpeg component and entropy table storage
|
||||
e924ba6e refactor: describe jpeg exif decoder state fields
|
||||
2fab68f0 refactor: use typed jpeg exif entries and field sizes
|
||||
50ace99f refactor: derive jpeg buffer alignment and table clear sizes
|
||||
05f1ddbf refactor: simplify jpeg geometry casts and huffman indexing
|
||||
```
|
||||
|
||||
Final source review: no excluded files, existing assembly, configuration, or link status changed. The two reserved table words preserve existing storage; no padding was added. All 37 trials are logged. Raw frame access, existing public names, and remaining opaque ranges are retained for the measured code-generation, scope, or evidence constraints above.
|
||||
Reference in New Issue
Block a user