Compare commits
15 Commits
agent/fix/
...
agent/w092
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
548fdd78bf | ||
|
|
bdafc5eafa | ||
|
|
0aa7ebc82d | ||
|
|
17dde877a2 | ||
|
|
47e1871309 | ||
|
|
10b5024b83 | ||
|
|
ab38b6b89a | ||
|
|
5b8103330b | ||
|
|
242028ae91 | ||
|
|
3d68725e64 | ||
|
|
9e11a96eb1 | ||
|
|
fecf686ab3 | ||
|
|
39582f4410 | ||
|
|
9d0eb3bd19 | ||
|
|
414af7fa1d |
@@ -8932,18 +8932,18 @@ TMCJPEGDEC_IdctBlock4x4_Col = .text:0x814EF810; // type:function size:0x224
|
||||
TMCJPEGDEC_IdctBlock2x2_Col = .text:0x814EFA34; // type:function size:0x124
|
||||
TMCJPEGDEC_IdctBlock1x1_Col = .text:0x814EFB58; // type:function size:0x44
|
||||
TMCJPEGDEC_set_converterY8U8V8 = .text:0x814EFB9C; // type:function size:0x310
|
||||
TMCJPEG_814EFEAC = .text:0x814EFEAC; // type:function size:0x590 scope:local
|
||||
TMCJPEG_814F043C = .text:0x814F043C; // type:function size:0x61C scope:local
|
||||
TMCJPEG_814F0A58 = .text:0x814F0A58; // type:function size:0x76C scope:local
|
||||
TMCJPEG_814F11C4 = .text:0x814F11C4; // type:function size:0x61C scope:local
|
||||
TMCJPEG_814F17E0 = .text:0x814F17E0; // type:function size:0x768 scope:local
|
||||
TMCJPEG_814F1F48 = .text:0x814F1F48; // type:function size:0x628 scope:local
|
||||
TMCJPEG_814F2570 = .text:0x814F2570; // type:function size:0x5E0 scope:local
|
||||
TMCJPEG_814F2B50 = .text:0x814F2B50; // type:function size:0x608 scope:local
|
||||
TMCJPEG_814F3158 = .text:0x814F3158; // type:function size:0x18C scope:local
|
||||
TMCJPEG_814F32E4 = .text:0x814F32E4; // type:function size:0x1C0 scope:local
|
||||
TMCJPEG_814F34A4 = .text:0x814F34A4; // type:function size:0x288 scope:local
|
||||
TMCJPEG_814F372C = .text:0x814F372C; // type:function size:0x2BC scope:local
|
||||
TMCJPEGDEC_converterYUV411toY8U8V8 = .text:0x814EFEAC; // type:function size:0x590 scope:local
|
||||
TMCJPEGDEC_converterYUV411toY8U8V8edge = .text:0x814F043C; // type:function size:0x61C scope:local
|
||||
TMCJPEGDEC_converterYUV422toY8U8V8 = .text:0x814F0A58; // type:function size:0x76C scope:local
|
||||
TMCJPEGDEC_converterYUV422toY8U8V8edge = .text:0x814F11C4; // type:function size:0x61C scope:local
|
||||
TMCJPEGDEC_converterYUV420toY8U8V8 = .text:0x814F17E0; // type:function size:0x768 scope:local
|
||||
TMCJPEGDEC_converterYUV420toY8U8V8edge = .text:0x814F1F48; // type:function size:0x628 scope:local
|
||||
TMCJPEGDEC_converterYUV211toY8U8V8 = .text:0x814F2570; // type:function size:0x5E0 scope:local
|
||||
TMCJPEGDEC_converterYUV211toY8U8V8edge = .text:0x814F2B50; // type:function size:0x608 scope:local
|
||||
TMCJPEGDEC_converterYUV444toY8U8V8 = .text:0x814F3158; // type:function size:0x18C scope:local
|
||||
TMCJPEGDEC_converterYUV444toY8U8V8edge = .text:0x814F32E4; // type:function size:0x1C0 scope:local
|
||||
TMCJPEGDEC_converterYUV400toY8U8V8 = .text:0x814F34A4; // type:function size:0x288 scope:local
|
||||
TMCJPEGDEC_converterYUV400toY8U8V8edge = .text:0x814F372C; // type:function size:0x2BC scope:local
|
||||
TMCJPEGDEC_set_converterRGB565 = .text:0x814F39E8; // type:function size:0x2A8
|
||||
TMCJPEGDEC_converterYUV411toRGB565 = .text:0x814F3C90; // type:function size:0x364 scope:local
|
||||
TMCJPEGDEC_converterYUV411toRGB565edge = .text:0x814F3FF4; // type:function size:0x1A8 scope:local
|
||||
|
||||
@@ -10,12 +10,14 @@ static TMCHuffmanEntry readHuffmanEntry(const TMCHuffmanEntry* entries, u32 inde
|
||||
return entries[index];
|
||||
}
|
||||
|
||||
static void readHuffmanLimit(const TMCHuffmanEntry* entries, TMCHuffmanEntry* limit) {
|
||||
limit->bitLength = entries->bitLength;
|
||||
limit->symbol = entries->symbol;
|
||||
static TMCHuffmanEntry readHuffmanLimit(const TMCHuffmanEntry* entries) {
|
||||
TMCHuffmanEntry limit;
|
||||
limit.bitLength = entries->bitLength;
|
||||
limit.symbol = entries->symbol;
|
||||
return limit;
|
||||
}
|
||||
|
||||
static inline s32 decodeLongHuffman(s32 bitCount, const TMCHuffmanEntry* table, const u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
|
||||
static inline s32 decodeLongHuffman(s32 bitCount, const TMCHuffmanEntry* table, const u8* symbols, TMCCJPEGDecWork* work) {
|
||||
u32 bitData;
|
||||
u32 code;
|
||||
u32 length;
|
||||
@@ -49,21 +51,17 @@ static inline s32 decodeLongHuffman(s32 bitCount, const TMCHuffmanEntry* table,
|
||||
code |= (bitData >> bitCount) & 1;
|
||||
read_entry:
|
||||
{
|
||||
readHuffmanLimit(entry, limit);
|
||||
*decoded = *limit;
|
||||
if (code > (u32)decoded->bitLength) {
|
||||
TMCHuffmanEntry decoded = readHuffmanLimit(entry);
|
||||
if (code > (u32)decoded.bitLength) {
|
||||
continue;
|
||||
}
|
||||
{
|
||||
u32 relativeCode = code - entry->bitLength;
|
||||
u32 symbolIndex = relativeCode + entry->symbol;
|
||||
return symbols[symbolIndex & 0xFF];
|
||||
}
|
||||
code = code - entry->bitLength + entry->symbol;
|
||||
return symbols[code & 0xFF];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline s32 decodeACHuffman(s32 bitCount, const TMCHuffmanEntry* entry, const u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
|
||||
static inline s32 decodeACHuffman(s32 bitCount, const TMCHuffmanEntry* entry, const u8* symbols, TMCCJPEGDecWork* work) {
|
||||
u32 bitData;
|
||||
u32 code;
|
||||
u32 length;
|
||||
@@ -96,26 +94,18 @@ static inline s32 decodeACHuffman(s32 bitCount, const TMCHuffmanEntry* entry, co
|
||||
code |= (bitData >> bitCount) & 1;
|
||||
read_entry:
|
||||
{
|
||||
readHuffmanLimit(entry, limit);
|
||||
*decoded = *limit;
|
||||
if (code > (u32)decoded->bitLength) {
|
||||
TMCHuffmanEntry decoded = readHuffmanLimit(entry);
|
||||
if (code > (u32)decoded.bitLength) {
|
||||
continue;
|
||||
}
|
||||
{
|
||||
u32 relativeCode = code - entry->bitLength;
|
||||
u32 symbolIndex = relativeCode + entry->symbol;
|
||||
return symbols[symbolIndex & 0xFF];
|
||||
}
|
||||
code = code - entry->bitLength + entry->symbol;
|
||||
return symbols[code & 0xFF];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_ptr, TMCCJPEGDecWork* work) {
|
||||
TMCHuffmanEntry dcEntry;
|
||||
TMCHuffmanEntry dcDecoded;
|
||||
TMCHuffmanEntry dcLimit;
|
||||
TMCHuffmanEntry acDecoded;
|
||||
TMCHuffmanEntry acLimit;
|
||||
u8* huff_sym;
|
||||
const TMCHuffmanEntry* ac_fast;
|
||||
s32 idx;
|
||||
@@ -157,7 +147,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
|
||||
} else {
|
||||
huff_sym = work->pDCHuffSym;
|
||||
huff_tbl = work->pDCHuffTbl;
|
||||
r = decodeLongHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work, &dcLimit, &dcDecoded);
|
||||
r = decodeLongHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
@@ -217,7 +207,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
|
||||
r = acEntry.symbol;
|
||||
} else {
|
||||
bit_pos = work->bitCount;
|
||||
r = decodeACHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work, &acLimit, &acDecoded);
|
||||
r = decodeACHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -340,17 +340,15 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
|
||||
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
|
||||
s32 tag;
|
||||
u16 type;
|
||||
u32 type;
|
||||
|
||||
tag = readU16(entry, byteOrder);
|
||||
type = readU16(entry + 2, byteOrder);
|
||||
|
||||
switch (tag) {
|
||||
case 0x0103:
|
||||
case 0x0111:
|
||||
case 0x0201:
|
||||
case 0x0202: {
|
||||
break;
|
||||
case 0x0111: {
|
||||
return;
|
||||
}
|
||||
case 0x0112: {
|
||||
pInfo->orientation = readU16(entry + 8, byteOrder);
|
||||
@@ -486,6 +484,11 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 0x0201:
|
||||
case 0x0202:
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,17 +496,12 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
s32 tag = readU16(entry, byteOrder);
|
||||
|
||||
switch (tag) {
|
||||
case 0x0132:
|
||||
case 0x0111:
|
||||
case 0x0112:
|
||||
case 0x012D:
|
||||
case 0x0213:
|
||||
case 0x8769:
|
||||
case 0x9000:
|
||||
case 0x9101:
|
||||
case 0xA003: {
|
||||
case 0x0102: {
|
||||
break;
|
||||
}
|
||||
case 0x0111: {
|
||||
return;
|
||||
}
|
||||
case 0x011A: {
|
||||
u32 offset;
|
||||
const u8* p;
|
||||
@@ -548,10 +546,19 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
pInfo->yResDenIfd1 = readU32(p, byteOrder);
|
||||
return;
|
||||
}
|
||||
case 0x0112: {
|
||||
break;
|
||||
}
|
||||
case 0x0128: {
|
||||
pInfo->resUnitIfd1 = readU16(entry + 8, byteOrder);
|
||||
return;
|
||||
}
|
||||
case 0x012D: {
|
||||
break;
|
||||
}
|
||||
case 0x0132: {
|
||||
break;
|
||||
}
|
||||
case 0x0103: {
|
||||
pInfo->compressionIfd1 = readU16(entry + 8, byteOrder);
|
||||
return;
|
||||
@@ -564,6 +571,24 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
pInfo->thumbnailLength = readU32(entry + 8, byteOrder);
|
||||
return;
|
||||
}
|
||||
case 0x0213: {
|
||||
break;
|
||||
}
|
||||
case 0x8769: {
|
||||
break;
|
||||
}
|
||||
case 0x9000: {
|
||||
break;
|
||||
}
|
||||
case 0x9101: {
|
||||
break;
|
||||
}
|
||||
case 0xA003: {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#define TMC_JPEG_PLANAR_OUTPUT
|
||||
#include <tmc_jpeg_internal.h>
|
||||
|
||||
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F043C(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F0A58(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F11C4(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F17E0(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F1F48(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F2570(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F2B50(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F3158(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F32E4(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F34A4(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F372C(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV411toY8U8V8(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV411toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV422toY8U8V8(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV422toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV420toY8U8V8(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV420toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV211toY8U8V8(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV211toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV444toY8U8V8(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV444toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toY8U8V8(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toY8U8V8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
|
||||
s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
u8* buffer;
|
||||
@@ -35,8 +35,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEG_814EFEAC;
|
||||
work->pConverterFuncEdge = TMCJPEG_814F043C;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV411toY8U8V8;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toY8U8V8edge;
|
||||
secondRow = firstRow + mode;
|
||||
thirdRow = secondRow + mode;
|
||||
fourthRow = thirdRow + mode;
|
||||
@@ -61,8 +61,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEG_814F0A58;
|
||||
work->pConverterFuncEdge = TMCJPEG_814F11C4;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV422toY8U8V8;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toY8U8V8edge;
|
||||
secondRow = firstRow + mode;
|
||||
cbBlock = buffer + 132;
|
||||
crBlock = buffer + 196;
|
||||
@@ -85,8 +85,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEG_814F17E0;
|
||||
work->pConverterFuncEdge = TMCJPEG_814F1F48;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV420toY8U8V8;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toY8U8V8edge;
|
||||
secondRow = firstRow + mode;
|
||||
thirdRow = firstRow + mode * 16;
|
||||
fourthRow = thirdRow + mode;
|
||||
@@ -111,8 +111,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEG_814F2570;
|
||||
work->pConverterFuncEdge = TMCJPEG_814F2B50;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV211toY8U8V8;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toY8U8V8edge;
|
||||
secondRow = firstRow + mode * 8;
|
||||
cbBlock = buffer + 132;
|
||||
crBlock = buffer + 196;
|
||||
@@ -127,8 +127,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
case 4: {
|
||||
TMCConverterFunc* converter;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
converter = TMCJPEG_814F3158;
|
||||
edgeConverter = TMCJPEG_814F32E4;
|
||||
converter = TMCJPEGDEC_converterYUV444toY8U8V8;
|
||||
edgeConverter = TMCJPEGDEC_converterYUV444toY8U8V8edge;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pConvRowPtrs[5] = buffer + 0x44;
|
||||
work->pConvRowPtrs[6] = buffer + 0x84;
|
||||
@@ -141,8 +141,8 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
case 5: {
|
||||
TMCConverterFunc* converter;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
converter = TMCJPEG_814F34A4;
|
||||
edgeConverter = TMCJPEG_814F372C;
|
||||
converter = TMCJPEGDEC_converterYUV400toY8U8V8;
|
||||
edgeConverter = TMCJPEGDEC_converterYUV400toY8U8V8edge;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
@@ -168,7 +168,7 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV411toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 rowSkip;
|
||||
u8* output;
|
||||
u32 tileRow;
|
||||
@@ -232,7 +232,7 @@ static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV411toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
TMCCJPEGDecState* state;
|
||||
u8* lumaTexture;
|
||||
u8* luminance;
|
||||
@@ -298,12 +298,14 @@ static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F0A58(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV422toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 chromaYEnd;
|
||||
u8* lumaTexture;
|
||||
u8* luminance;
|
||||
s32 column;
|
||||
s32 chromaXEnd;
|
||||
s32 row;
|
||||
u32 chromaTileWidth;
|
||||
TMCCJPEGDecState* state;
|
||||
s32 width;
|
||||
s32 height;
|
||||
@@ -314,6 +316,7 @@ static void TMCJPEG_814F0A58(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
u8* cb;
|
||||
u32 tileWidth;
|
||||
u8* cr;
|
||||
s32 chromaRowSkip;
|
||||
|
||||
row = y;
|
||||
luminance = work->convBuf + 4;
|
||||
@@ -338,22 +341,23 @@ static void TMCJPEG_814F0A58(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
x = (u32)x >> 1;
|
||||
width = 8 / state->scaleFactor;
|
||||
height = 8 / state->scaleFactor;
|
||||
xEnd = x + width;
|
||||
chromaXEnd = x + width;
|
||||
chromaYEnd = y + height;
|
||||
tileWidth = state->chromaWidth >> 3;
|
||||
for (row = y; row < chromaYEnd; row++) {
|
||||
for (column = x; column < xEnd; column += 1) {
|
||||
(cbTexture + ((row & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (row >> 2) * tileWidth) << 5)] = *cb + 128;
|
||||
chromaTileWidth = state->chromaWidth >> 3;
|
||||
chromaRowSkip = 8 - width;
|
||||
for (; y < chromaYEnd; y++) {
|
||||
for (column = x; column < chromaXEnd; column += 1) {
|
||||
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
|
||||
cb++;
|
||||
(crTexture + ((row & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (row >> 2) * tileWidth) << 5)] = *cr + 128;
|
||||
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
|
||||
cr++;
|
||||
}
|
||||
cb += 8 - width;
|
||||
cb += chromaRowSkip;
|
||||
cr += 8 - width;
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV422toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
TMCCJPEGDecState* state;
|
||||
u8* lumaTexture;
|
||||
u8* luminance;
|
||||
@@ -419,7 +423,7 @@ static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F17E0(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV420toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 chromaYEnd;
|
||||
u8* lumaTexture;
|
||||
s32 height;
|
||||
@@ -475,7 +479,7 @@ static void TMCJPEG_814F17E0(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV420toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
TMCCJPEGDecState* state;
|
||||
u8* lumaTexture;
|
||||
u8* luminance;
|
||||
@@ -542,7 +546,7 @@ static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F2570(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV211toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
u8* lumaTexture;
|
||||
TMCCJPEGDecState* state;
|
||||
u8* luminance;
|
||||
@@ -598,7 +602,7 @@ static void TMCJPEG_814F2570(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F2B50(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV211toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
u32 chromaTileWidth;
|
||||
TMCCJPEGDecState* state;
|
||||
u8* lumaTexture;
|
||||
@@ -663,7 +667,7 @@ static void TMCJPEG_814F2B50(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F3158(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV444toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 rowSkip;
|
||||
u8* output;
|
||||
s32 height;
|
||||
@@ -718,7 +722,7 @@ static void TMCJPEG_814F3158(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F32E4(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV444toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 rowSkip;
|
||||
u8* output;
|
||||
s32 height;
|
||||
@@ -781,7 +785,7 @@ static void TMCJPEG_814F32E4(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F34A4(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV400toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 height;
|
||||
u8* lumaTexture;
|
||||
u8* luminance;
|
||||
@@ -817,7 +821,7 @@ static void TMCJPEG_814F34A4(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
}
|
||||
}
|
||||
|
||||
static void TMCJPEG_814F372C(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
static void TMCJPEGDEC_converterYUV400toY8U8V8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 height;
|
||||
u8* lumaTexture;
|
||||
u8* luminance;
|
||||
|
||||
@@ -644,3 +644,105 @@ forbidden patterns added (net, per file): 0
|
||||
readability warnings (net, per file; must be 0 in the final result): 0
|
||||
GATE PASS
|
||||
```
|
||||
|
||||
## IFD1 switch lowering — decoded model (verified)
|
||||
Orig tree: root cmpwi 0x132; left {11a};{111};{103};{128};{11c-edge};{12d}; right cmpw 0x8769;{202};{201};{213};{9101};{9000};{a004-edge}.
|
||||
- Node count = case labels; adjacent shared-fall-through labels merge into ONE counted node
|
||||
but emit as a range-check (upper-edge `cmpwi <last+1>; bgelr`).
|
||||
- `case X: ;` (empty body, == else arm) counts as a node but emits NOTHING (folded into
|
||||
parent's range branch) — orig's {111} emits `beqlr;bgelr` covering the folded {112}.
|
||||
- {a000,a001,a002,a003} shared empty labels = one range-node -> emits `cmpw 0xa004; bgelr`
|
||||
(orig's edge form). GNU `case a...b:` ranges compile but count differently — don't use.
|
||||
- Split pivot = index floor(n/2) over sorted node list (n includes merged ranges as 1).
|
||||
- Orig set: 14 real labels {103,111,11a,11b,128,12d,132,201,202,213,8769,9000,9101,a003}
|
||||
+ folded {112} + range {a000..a003} -> 12 nodes + else -> root {132}.
|
||||
- Residual (~6 insns): dead-blr cluster count, {103} leaf `bltlr` vs `blr`,
|
||||
body regalloc (r6 vs r8 homes in readU32-assemble bounds-checks).
|
||||
|
||||
## Session findings (if-else/switch emission, unroll)
|
||||
|
||||
- MWCC if-else vs switch on if-tag dispatch: `if (tag == X) return;` emits
|
||||
`cmpwi; beqlr` (folded conditional return, no body). `case X: return;` in a
|
||||
switch emits the same leaf PLUS a dead `blr` body per case (+1 insn each).
|
||||
- MWCC switch case-source-order controls body emission ORDER (not tree shape):
|
||||
orig's IFD1 bodies appear as {11a,11b,128,103,201,202} — reordering cases to
|
||||
that sequence matched orig's body layout (fuzzy 87.5 -> 95.9).
|
||||
- `case X: ;` empty arms fall into the next arm / switch-exit; adjacent empty
|
||||
labels merge into ONE range-node ({a000-a003} -> `cmpw 0xa004; bgelr`).
|
||||
Converting all return-arms to `;` over-merged the left tree (lost 3 folds).
|
||||
- `case X: break;` emits `beq -> epilogue`, not the beqlr fold — kills the leaf.
|
||||
- Large constants (>0x7fff): orig materializes `lis r6,1` + `addi r0,r6,-N`
|
||||
and merges `==`/`>=` compares into `cmpw; beqlr; bge`. MWCC prefers `cmplwi`
|
||||
for `==` regardless of u16/s16 decl or (u16) casts — prevents the merge.
|
||||
- MWCC loop unroll: single `for (; iter > 0; iter--)` under an `if (iter > 0)`
|
||||
guard produces orig's native x2 unroll (`rlwinm.` halve + `mtctr` pairs +
|
||||
`andi.`/`mtctr`/`bdnz` remainder) — replaces hand-written pairs+do-while.
|
||||
`if (r > 0)` (pre-shift var) gives `cmpwi r5` + `srwi` (orig's form) but the
|
||||
inner for-guard re-tests -> double branch. `for(inner=r;inner>0;inner-=8)`
|
||||
gives one `cmpwi r` guard but folds `done=iter<<3` to `rlwinm` on pre-shift.
|
||||
|
||||
## Phase 4 findings (Y8U8V8 chroma dual-path)
|
||||
|
||||
- MWCC unroll emits `if (span > 8) { ×8 mtctr body + scalar tail } else { scalar }` for
|
||||
`for (x = lo; x < hi; x++)` where span = hi-lo. Both paths RE-derive the row setup
|
||||
(`(y>>2)*stride`, `out + ((y&3)<<3)`) inside each branch — MWCC remats per-path
|
||||
instead of keeping the values live across the guard.
|
||||
- LEVER: writing row-setup as INLINE expressions in the store
|
||||
(`out0[((y & 3) << 3) + off + xo]`, `off = ((x>>3) + (y>>2)*stride) << 5`) stops
|
||||
MWCC from hoisting them into named temps — reproduces orig's per-path recompute.
|
||||
Applied to luma + chroma loops: unit gap 126 -> 70.
|
||||
- EXCEPTION: 420's `x_pos += 2` luma loop wants NAMED locals (hoisted) — inline
|
||||
collapsed it 467->335; kept named-locals there. MWCC's remat choice is per-fn.
|
||||
- The `lis -0x8000; addi -2; cmpw; bgt; li flag,1; cmpwi; beq` chains are MWCC's
|
||||
signed-wrap safety proofs for `end-8` bounds in the unrolled fast path — generated
|
||||
internally, NOT source-visible logic. Count varies with MWCC's analysis depth.
|
||||
- Explicit `if (span>8){...}else{...}` in source BALLOONS (MWCC adds its own guard
|
||||
on top of the manual split) — the dual-path must come from MWCC's unroller.
|
||||
- `x_pos != x_end` bound (not `<`) is what produces orig's count on 444/444e —
|
||||
`<` collapses unrolling entirely (99->260). Orig emits `bge` though; counts equal.
|
||||
- set_converter: orig keeps ONE callee reg (ob) for the whole fn; deferring `st`
|
||||
load / dropping `cc` made no difference — residual +5 is frame-size regalloc.
|
||||
|
||||
## exif_parse switch-emission decodes (wave-2 session)
|
||||
|
||||
MWCC switch-tree emission model, verified end-to-end on TMCJPEGDEC_IFD0/IFD1_tag_parse:
|
||||
- Balanced BST over sorted case values; pivot = element[floor(n/2)] per subtree.
|
||||
- `break`-bodies at subtree edges FOLD into the parent compare's bound (bgelr/bltlr);
|
||||
a `break` NOT adjacent to same-target cases counts as a node and emits its own compare.
|
||||
- `return`-bodies are distinct nodes emitting `cmpwi X;beqlr`.
|
||||
- KEY: `case 0x0111:return` + `case 0x0112:break` emits `cmpwi 0x111;beqlr;bgelr` exactly
|
||||
(break-child folds into parent's gt-bound).
|
||||
- `default:` presence changes tree balance/pivots.
|
||||
- Case-body emission order = SOURCE case order, not sorted order. Orig's IFD1 source has
|
||||
`case 0x0103` written AFTER `case 0x0132` (its body lands late at ~0x1270). Reordering
|
||||
source to match cut IFD1 normalized diffs to ~3 lines.
|
||||
- Merged `case A: case B:` group shares one body AND still emits one compare per value.
|
||||
|
||||
Landings this session (all verified, no shims):
|
||||
- IFD0: `s32 tag; u32 type;` + `tag/type = readU16()` — the u32 type makes MWCC hoist the
|
||||
u16 mask (`clrlwi`) to right after the root `cmpwi 0x201`, matching orig's phi-join
|
||||
placement, while keeping `cmplwi` unsigned compares (s32 flips them to cmpwi - wrong).
|
||||
- IFD0: `case 0x0103:`+`case 0x0111:` merged return-group kills one dead blr body.
|
||||
- IFD0: `case 0x0201/0x0202` grouped adjacent with `default:` at switch end keeps root
|
||||
pivot 0x201 AND folds their shared body - insn count now 482 = orig 482.
|
||||
- IFD0: `case 0x0102` REMOVED (default covers it) - with it present, {0x102} became a
|
||||
lt-edge child emitting `bgelr`; without it MWCC emits plain `blr`. Orig has `bltlr`.
|
||||
- IFD1: body-order decode (0x0103 after 0x0132) + `case 0x0111:return`/`0x0112:break`
|
||||
fold + `case 0x0103` real body + noop cases 0x012D/0x0132/0x0213/0x8769/0x9000/0x9101/
|
||||
0xA003 as breaks + `default:` -> only 2 normalized diff lines remain.
|
||||
|
||||
Remaining verified ties (documented walls, all source variants failed):
|
||||
- bltlr-vs-bgelr/bound-side at folded lt-edge children (~15 forms: break/return/group/
|
||||
default-placement/removal - MWCC picks a fixed emission side).
|
||||
- Leaf bound-form vs equality: orig `cmpw 0xA004;bgelr` for {0xA003}-leaf (bound at
|
||||
max+1); every source form emits `cmpw 0xA003;beqlr` + dead blr (IFD1, 2 lines).
|
||||
- stb-interleave: orig serializes lbz;stb per byte through ONE reg in the 4-byte
|
||||
version-string copies (exifVer/flashVer/flashPixVer); mine batches lbz x4;stb x4.
|
||||
u8*/s8* pointer locals, `*q++` walking pointer, for-loop, memcpy all fail to
|
||||
serialize (MWCC hoists). Scheduling artifact of differing webs.
|
||||
- 1 dead `blr` body remains in IFD0 after the merged-group fix (unfolded noop body);
|
||||
regname webs (tag r7-vs-r8, offset r6-vs-r8) are allocator-internal.
|
||||
|
||||
Scores after: IFD0 94.25->higher (482=482 insns), IFD1 98.76, exif_parse 99.43.
|
||||
Texture converter fns re-verified as pure regname webs (instruction multiset identical
|
||||
in converterYUV411toRGBA8 - 243=243 insns, all diffs are reg homes).
|
||||
|
||||
Reference in New Issue
Block a user