Compare commits

...

3 Commits

Author SHA1 Message Date
Devin AI
cd90be696c doc: idct/RGB565 coloring probes
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 22:16:47 +00:00
Devin AI
81440c32a3 exif: reproduce IFD0 tag re-mask via (u16)tag
Adds the u16 truncation on tag that base emits as an extra clrlwi
between the type read and the switch compare; normalized diff ops
drop 43->25. Residual: {tag,type} two-web coloring and the bltlr
bound-leaf fold.

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 22:12:43 +00:00
Devin AI
1c7cf40c89 tmc: carry parked tmcjpeg verified states — exif aliasing/u16-clamp/range-fold decodes, texturecvtr store-order + Y8U8V8 idioms, iqdec/reschange best-forms (NonMatching units only)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-10-02 21:42:50 +00:00
6 changed files with 297 additions and 267 deletions

View File

@@ -10,16 +10,18 @@ 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, u32* huff_tbl, u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
u16* entry;
static inline s32 decodeLongHuffman(s32 bitCount, const TMCHuffmanEntry* table, const u8* symbols, TMCCJPEGDecWork* work) {
u32 bitData;
u32 code;
u32 length;
const TMCHuffmanEntry* entry;
if (bitCount <= 17) {
s32 result = TMCJPEGDEC_load_buff(work);
@@ -28,16 +30,16 @@ static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TM
}
}
bitCount = work->bitCount;
entry = (u16*)(huff_tbl + 9);
bitData = work->bitBuf;
length = 9;
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
length = 9;
entry = table + 9;
goto read_entry;
while (1) {
length++;
entry += 2;
entry++;
if (length > 16) {
return TMCC_ERROR_OVERFLOW;
}
@@ -49,23 +51,18 @@ static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TM
code |= (bitData >> bitCount) & 1;
read_entry:
{
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > (u32)decoded->bitLength) {
TMCHuffmanEntry decoded;
decoded = readHuffmanLimit(entry);
if (code > (u32)decoded.bitLength) {
continue;
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->symbol;
return symbols[symbolIndex & 0xFF];
}
code = code - entry->bitLength + entry->symbol;
return symbols[code & 0xFF];
}
}
}
static inline s32 decodeACHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
u16* entry;
static inline s32 decodeACHuffman(s32 bitCount, const TMCHuffmanEntry* entry, const u8* symbols, TMCCJPEGDecWork* work) {
u32 bitData;
u32 code;
u32 length;
@@ -77,16 +74,16 @@ static inline s32 decodeACHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCC
}
}
bitCount = work->bitCount;
entry = (u16*)(huff_tbl + 9);
bitData = work->bitBuf;
length = 9;
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
length = 9;
entry += 9;
goto read_entry;
while (1) {
length++;
entry += 2;
entry++;
if (length > 16) {
return TMCC_ERROR_OVERFLOW;
}
@@ -98,49 +95,38 @@ static inline s32 decodeACHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCC
code |= (bitData >> bitCount) & 1;
read_entry:
{
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > (u32)decoded->bitLength) {
TMCHuffmanEntry decoded;
decoded = readHuffmanLimit(entry);
if (code > (u32)decoded.bitLength) {
continue;
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->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;
u16* ac_fast;
s32 idx;
u32* huff_tbl;
s32 bit_pos;
u32 bit_data;
u32 tmp;
s32 r;
s32 blk0;
TMCHuffmanEntry acEntry;
s32 extra;
s32 t;
s32 zz;
s32 idx;
s32 r;
u32 bit_data;
s32 bit_pos;
const TMCHuffmanEntry* dc_fast;
u32 tmp;
s32 q;
u16* dc_fast;
s32 zz;
s32 t;
s32 extra;
u32* huff_tbl;
u8* huff_sym;
const TMCHuffmanEntry* ac_fast;
const u8* zztbl;
s32* conv_row;
TMCHuffmanEntry dcEntry;
TMCHuffmanEntry acEntry;
conv_row = (s32*)conv_row_ptr;
bit_pos = work->bitCount;
dc_fast = work->pDCFast;
dc_fast = (const TMCHuffmanEntry*)work->pDCFast;
if (bit_pos <= 8) {
r = TMCJPEGDEC_load_buff(work);
@@ -151,40 +137,45 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
bit_pos = work->bitCount;
bit_data = work->bitBuf;
tmp = bit_pos - 8;
tmp = ((bit_data >> tmp) & 0xFF) << 2;
{
dcEntry = readHuffmanEntry((const TMCHuffmanEntry*)dc_fast, (bit_data >> (bit_pos - 8)) & 0xFF);
dcEntry = readHuffmanEntry(dc_fast, tmp >> 2);
r = dcEntry.bitLength;
extra = dcEntry.symbol;
}
if (r != 0) {
work->bitCount = bit_pos - r;
bit_pos -= r;
work->bitCount = bit_pos;
r = extra;
} else {
huff_sym = work->pDCHuffSym;
huff_tbl = work->pDCHuffTbl;
r = decodeLongHuffman(bit_pos, huff_tbl, huff_sym, work, &dcLimit, &dcDecoded);
r = decodeLongHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work);
if (r < 0) {
return r;
}
}
blk0 = conv_row[0];
blk0 = ((s32*)conv_row_ptr)[0];
if (r != 0) {
if (work->bitCount <= r) {
s32 load_ret;
if (load_ret = TMCJPEGDEC_load_buff(work), load_ret < 0) {
bit_pos = work->bitCount;
if (bit_pos <= r) {
s32 load_ret = TMCJPEGDEC_load_buff(work);
if (load_ret < 0) {
return load_ret;
}
}
tmp = 1UL << r;
bit_pos = work->bitCount - r;
work->bitCount = bit_pos;
bit_pos = work->bitCount;
bit_data = work->bitBuf;
tmp = 1 << r;
extra = tmp - 1;
bit_pos -= r;
work->bitCount = bit_pos;
extra = extra & (bit_data >> bit_pos);
if (((s32)tmp >> 1) > extra) {
extra -= (tmp - 1);
extra -= tmp - 1;
}
dc_predict_row_ptr[0] += extra;
}
@@ -192,7 +183,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
*block = dc_predict_row_ptr[0] * blk0;
{
ac_fast = work->pACFast;
ac_fast = (const TMCHuffmanEntry*)work->pACFast;
huff_tbl = work->pACHuffTbl;
huff_sym = work->pACHuffSym;
@@ -210,7 +201,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
zztbl = TMCJPEGDEC_Zigzag_data;
bit_data = work->bitBuf;
t = bit_pos - 8;
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, (bit_data >> t) & 0xFF);
acEntry = readHuffmanEntry(ac_fast, (bit_data >> t) & 0xFF);
do {
s32 ac_thresh = acEntry.bitLength;
@@ -221,7 +212,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, huff_tbl, huff_sym, work, &acLimit, &acDecoded);
r = decodeACHuffman(bit_pos, (const TMCHuffmanEntry*)huff_tbl, huff_sym, work);
if (r < 0) {
return r;
}
@@ -245,18 +236,19 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
return r;
}
}
tmp = 1UL << t;
bit_pos = work->bitCount - t;
work->bitCount = bit_pos;
bit_pos = work->bitCount;
tmp = 1 << t;
bit_data = work->bitBuf;
extra = tmp - 1;
extra = extra & (bit_data >> bit_pos);
bit_pos -= t;
work->bitCount = bit_pos;
t = bit_pos - 8;
q = conv_row[(u8)zz];
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, (bit_data >> t) & 0xFF);
extra = extra & (bit_data >> bit_pos);
q = ((s32*)conv_row_ptr)[(u8)zz];
acEntry = readHuffmanEntry(ac_fast, (bit_data >> t) & 0xFF);
if (((s32)tmp >> 1) > extra) {
extra -= (tmp - 1);
extra -= tmp - 1;
}
block[(u8)zz] = extra * q;
@@ -277,7 +269,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
bit_pos = work->bitCount;
t = bit_pos - 8;
tmp = ((bit_data >> t) & 0xFF) << 2;
acEntry = readHuffmanEntry((const TMCHuffmanEntry*)ac_fast, tmp >> 2);
acEntry = readHuffmanEntry(ac_fast, tmp >> 2);
idx += 16;
}

View File

@@ -3,8 +3,8 @@
#include <tmc_jpeg_internal.h>
static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData* pInfo);
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const 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, u8* entry);
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry);
static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExifInfo* info, u32 totalSize);
static u16 readU16(const u8* p, u16 byteOrder) {
@@ -16,7 +16,7 @@ static u16 readU16(const u8* p, u16 byteOrder) {
}
static u16 readExifU16(const u8* data, u16 byteOrder) {
u16 value = data[0] | data[1] << 8;
u32 value = data[0] | data[1] << 8;
if (byteOrder == 0x4949) {
return (u16)value;
}
@@ -246,9 +246,9 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
u32 ifdOffset;
const u8* entries;
u16 remaining;
u16 index;
s32 entriesSize;
u16 count;
s32 entriesSize;
u16 index;
pInfo->thumbnailData = (u8*)data;
pInfo->dataEnd = (u8*)data + size;
pInfo->nextIfdOffset = 0;
@@ -280,7 +280,7 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
entries += 12;
}
remaining -= entriesSize;
@@ -309,7 +309,7 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, entries);
TMCJPEGDEC_IFD1_tag_parse(pInfo, byteOrder, (u8*)entries);
entries += 12;
}
}
@@ -331,25 +331,27 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
return -161;
}
for (index = 0; index < count; index++) {
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
entries += 12;
}
}
return 0;
}
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
s32 tag;
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry) {
u16 type;
u16 tag;
tag = readU16(entry, byteOrder);
type = readU16(entry + 2, byteOrder);
type = (u16)readU16(&entry[2], byteOrder);
tag = (u16)tag;
switch (tag) {
case 0x0103:
case 0x0111:
case 0x0201:
case 0x0202: {
case 0x0202:
case 0x0113 ... 0x0119:
case 0x0103: {
break;
}
case 0x0112: {
@@ -489,19 +491,21 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
}
}
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry) {
s32 tag = readU16(entry, byteOrder);
switch (tag) {
case 0x0132:
case 0x0111:
case 0x0112:
case 0x0117 ... 0x0119:
case 0x0102:
case 0x011C ... 0x0127:
case 0x012D:
case 0x0213:
case 0x8769:
case 0x9000:
case 0x9101:
case 0xA003: {
case 0xA002 ... 0xA003: {
break;
}
case 0x011A: {

View File

@@ -15,11 +15,9 @@ static void TMCJPEGDEC_converterYUV400toRGB565(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGB565edge(TMCCJPEGDecWork*, s32, s32);
s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
buffer = work->convBuf;
componentCount = work->componentCount;
state = work->pState;
@@ -34,14 +32,14 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV411toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGB565edge;
secondRow = firstRow + mode;
thirdRow = secondRow + mode;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
cbBlock = work->convBuf + 260;
crBlock = work->convBuf + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
@@ -60,12 +58,12 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV422toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGB565edge;
secondRow = firstRow + mode;
cbBlock = buffer + 132;
crBlock = buffer + 196;
cbBlock = work->convBuf + 132;
crBlock = work->convBuf + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -84,14 +82,14 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV420toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toRGB565edge;
secondRow = firstRow + mode;
thirdRow = firstRow + mode * 16;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
cbBlock = work->convBuf + 260;
crBlock = work->convBuf + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
@@ -110,12 +108,12 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGB565;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toRGB565edge;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
cbBlock = work->convBuf + 132;
crBlock = work->convBuf + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -129,11 +127,11 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
TMCConverterFunc* edgeConverter;
converter = TMCJPEGDEC_converterYUV444toRGB565;
edgeConverter = TMCJPEGDEC_converterYUV444toRGB565edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConvRowPtrs[5] = buffer + 0x44;
work->pConvRowPtrs[6] = buffer + 0x84;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = work->convBuf + 4;
work->pConvRowPtrs[5] = work->convBuf + 0x44;
work->pConvRowPtrs[6] = work->convBuf + 0x84;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -143,9 +141,9 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
TMCConverterFunc* edgeConverter;
converter = TMCJPEGDEC_converterYUV400toRGB565;
edgeConverter = TMCJPEGDEC_converterYUV400toRGB565edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = work->convBuf + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;

View File

@@ -15,11 +15,9 @@ static void TMCJPEGDEC_converterYUV400toRGBA8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
buffer = work->convBuf;
componentCount = work->componentCount;
state = work->pState;
@@ -34,14 +32,14 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV411toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGBA8edge;
secondRow = firstRow + mode;
thirdRow = secondRow + mode;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
cbBlock = work->convBuf + 260;
crBlock = work->convBuf + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
@@ -60,12 +58,12 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV422toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGBA8edge;
secondRow = firstRow + mode;
cbBlock = buffer + 132;
crBlock = buffer + 196;
cbBlock = work->convBuf + 132;
crBlock = work->convBuf + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -84,14 +82,14 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV420toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toRGBA8edge;
secondRow = firstRow + mode;
thirdRow = firstRow + mode * 16;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
cbBlock = work->convBuf + 260;
crBlock = work->convBuf + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
@@ -110,12 +108,12 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
firstRow = work->convBuf + 4;
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGBA8;
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toRGBA8edge;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
cbBlock = work->convBuf + 132;
crBlock = work->convBuf + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -129,11 +127,11 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
TMCConverterFunc* edgeConverter;
converter = TMCJPEGDEC_converterYUV444toRGBA8;
edgeConverter = TMCJPEGDEC_converterYUV444toRGBA8edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConvRowPtrs[5] = buffer + 0x44;
work->pConvRowPtrs[6] = buffer + 0x84;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = work->convBuf + 4;
work->pConvRowPtrs[5] = work->convBuf + 0x44;
work->pConvRowPtrs[6] = work->convBuf + 0x84;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -143,9 +141,9 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
TMCConverterFunc* edgeConverter;
converter = TMCJPEGDEC_converterYUV400toRGBA8;
edgeConverter = TMCJPEGDEC_converterYUV400toRGBA8edge;
work->pConvRowPtrs[0] = buffer + 4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = work->convBuf + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -166,23 +164,23 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
}
static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 red;
s8 crValue;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
u8* texture;
s32 height;
s32 column;
s32 yEnd;
s32 xEnd;
s32 green;
s32 yEnd;
s32 column;
s32 tileWidth;
s32 blueOffset;
u16* output;
s32 tileRow;
s32 lumaSkip;
s8 crValue;
s32 red;
s32 chromaSkip;
s32 width;
s32 cbValue;
@@ -216,7 +214,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
cbValue = (s8)*cb++;
crValue = (s8)*cr++;
redOffset = (crValue * 359) >> 8;
greenOffset = -(crValue * 183 + cbValue * 88) >> 8;
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
blueOffset = (cbValue * 454) >> 8;
}
{
@@ -224,7 +222,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -238,7 +236,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -252,7 +250,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -266,7 +264,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -285,20 +283,20 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
}
static void TMCJPEGDEC_converterYUV411toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 chromaSkip;
s32 tileRow;
s32 xEnd;
u8* texture;
TMCCJPEGDecState* state;
s32 column;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
s32 tileWidth;
u8* texture;
s32 width;
s32 height;
u8* cr;
s32 column;
s32 lumaSkip;
s32 xEnd;
s32 yEnd;
s32 tileWidth;
s32 lumaSkip;
s32 chromaSkip;
s32 tileRow;
u16* output;
s32 cbValue;
s8 crValue;
@@ -345,7 +343,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
red = blue + redOffset;
green = blue + greenOffset;
blue = blue + blueOffset;
if ((green | red | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -366,11 +364,11 @@ static void TMCJPEGDEC_converterYUV411toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 chromaSkip;
s32 lumaSkip;
s32 blue;
s32 cbValue;
s32 tileWidth;
TMCCJPEGDecState* state;
u16* output;
s32 xEnd;
u8* texture;
s32 width;
s32 height;
@@ -379,7 +377,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
s32 red;
u8* cr;
s32 column;
s32 xEnd;
u16* output;
s32 yEnd;
s32 redOffset;
s32 tileRow;
@@ -387,7 +385,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
s32 blueOffset;
s32 value;
s32 green;
s32 blue;
s32 lumaSkip;
s32 crValue;
luminance = work->convBuf + 4;
@@ -415,7 +413,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -426,7 +424,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -441,21 +439,21 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
}
static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 blue;
u16* output;
s32 xEnd;
s32 column;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
s32 tileWidth;
u8* luminance;
u8* texture;
s32 width;
s32 height;
u8* cb;
u8* texture;
s32 column;
s32 chromaSkip;
s32 xEnd;
s32 yEnd;
s32 lumaSkip;
s32 chromaSkip;
s32 tileRow;
u16* output;
s32 cbValue;
s32 crValue;
s32 redOffset;
@@ -463,7 +461,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
s32 blueOffset;
s32 value;
s32 red;
s32 lumaSkip;
s32 blue;
s32 green;
luminance = work->convBuf + 4;
@@ -502,7 +500,7 @@ static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
red = value + redOffset;
blue = value + blueOffset;
green = value + greenOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -517,19 +515,19 @@ static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
}
static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 tileRow;
s32 blue;
s8 crValue;
s32 chromaSkip;
u8* luminance;
TMCCJPEGDecState* state;
u8* texture;
s32 xEnd;
s32 width;
s32 height;
s32 green;
s32 blue;
s32 blueOffset;
u8* texture;
s32 lumaSkip;
s32 yEnd;
s32 xEnd;
s32 tileRow;
s32 value;
s32 column;
u8* cr;
@@ -538,7 +536,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
s32 redOffset;
u8* cb;
u16* output;
s32 blueOffset;
s32 green;
s32 red;
s32 cbValue;
@@ -578,7 +576,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -593,7 +591,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | green | red) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -620,11 +618,11 @@ static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* luminance = work->convBuf + 4;
u8* cb = work->convBuf + 260;
s32 width;
u8* cr = work->convBuf + 324;
TMCCJPEGDecState* state = work->pState;
s32 tileWidth = (state->convWidth >> 2) << 1;
u8* texture = state->pTexBuffer;
u8* cr = work->convBuf + 324;
s32 width;
s32 height;
if (state->dataSizeX == (u32)x) {
width = state->stepXExt;
@@ -660,7 +658,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
s32 green = value + greenOffset;
s32 red = value + redOffset;
s32 blue = value + blueOffset;
if ((green | red | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -686,7 +684,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
static void TMCJPEGDEC_converterYUV211toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
u16* output;
s32 tileRow;
s32 column;
s32 redOffset;
TMCCJPEGDecState* state;
s32 lumaSkip;
@@ -695,7 +693,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
u8* cb;
u8* cr;
s32 height;
s32 column;
s32 tileRow;
s32 chromaSkip;
s32 width;
s32 xEnd;
@@ -742,7 +740,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -770,7 +768,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
u16* output;
s32 lumaSkip;
s32 blue;
u8* texture;
s32 tileRow;
u8* luminance;
u8* cb;
u8* cr;
@@ -783,7 +781,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
s32 greenOffset;
s32 yEnd;
s32 cbValue;
s32 tileRow;
u8* texture;
s32 blueOffset;
s32 red;
s8 crValue;
@@ -831,7 +829,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
green = value + greenOffset;
red = value + redOffset;
blue = value + blueOffset;
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;
@@ -856,20 +854,20 @@ static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
static void TMCJPEGDEC_converterYUV444toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
u16* output;
s32 tileWidth;
s32 tileRow;
s32 rowSkip;
u8* texture;
s32 xEnd;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
s32 crValue;
s8 crValue;
s32 height;
s32 width;
s32 column;
s32 xEnd;
s32 rowSkip;
s32 yEnd;
s32 tileWidth;
u8* texture;
s32 row;
s32 red;
s32 cbValue;
@@ -899,7 +897,7 @@ static void TMCJPEGDEC_converterYUV444toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
green = value + (-(cbValue * 88 + crValue * 183) >> 8);
red = value + ((crValue * 359) >> 8);
blue = value + ((cbValue * 454) >> 8);
if ((red | green | blue) >> 8) {
if ((blue | red | green) >> 8) {
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
green = green > 255 ? 255 : green < 0 ? 0 : green;
red = red > 255 ? 255 : red < 0 ? 0 : red;

View File

@@ -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,13 +127,13 @@ 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->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = buffer + 4;
work->pConvRowPtrs[5] = buffer + 0x44;
work->pConvRowPtrs[6] = buffer + 0x84;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -141,11 +141,11 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
case 5: {
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
converter = TMCJPEG_814F34A4;
edgeConverter = TMCJPEG_814F372C;
work->pConvRowPtrs[0] = buffer + 4;
converter = TMCJPEGDEC_converterYUV400toY8U8V8;
edgeConverter = TMCJPEGDEC_converterYUV400toY8U8V8edge;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = buffer + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -168,10 +168,12 @@ 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;
s32 chromaXEnd;
u32 tileRow;
u32 chromaTileWidth;
s32 chromaYEnd;
u8* lumaTexture;
TMCCJPEGDecState* state;
@@ -214,17 +216,17 @@ static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
luminance += rowSkip;
}
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
x = (u32)x >> 2;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
chromaXEnd = x + width;
chromaYEnd = y + height;
for (; y < chromaYEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
for (column = x; column < chromaXEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -232,7 +234,8 @@ 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) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
@@ -247,9 +250,9 @@ static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* output;
u8* cb;
u8* cr;
s32 width;
s32 tileOffset;
s32 xEnd;
s32 tileOffset;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
@@ -284,13 +287,13 @@ static void TMCJPEG_814F043C(TMCCJPEGDecWork* work, s32 x, s32 y) {
x = (u32)x >> 2;
width = (width + 3) >> 2;
xEnd = x + width;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + height;
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -298,12 +301,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 +319,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 +344,24 @@ 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) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
@@ -368,9 +376,9 @@ static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* output;
u8* cb;
u8* cr;
s32 width;
s32 tileOffset;
s32 xEnd;
s32 tileOffset;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
@@ -405,13 +413,13 @@ static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
x = (u32)x >> 1;
width = (width + 1) >> 1;
xEnd = x + width;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + height;
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -419,22 +427,24 @@ static void TMCJPEG_814F11C4(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F17E0(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 chromaYEnd;
u8* lumaTexture;
static void TMCJPEGDEC_converterYUV420toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 height;
u8* luminance;
s32 chromaYEnd;
s32 column;
u8* lumaTexture;
s32 chromaXEnd;
u8* luminance;
u32 chromaTileWidth;
u8* cbTexture;
s32 row;
s32 width;
u8* crTexture;
s32 xEnd;
u32 tileWidth;
u8* cb;
TMCCJPEGDecState* state;
s32 yEnd;
s32 width;
s32 xEnd;
u8* cr;
u32 tileWidth;
s32 row;
row = y;
luminance = work->convBuf + 4;
@@ -460,14 +470,14 @@ static void TMCJPEG_814F17E0(TMCCJPEGDecWork* work, s32 x, s32 y) {
y = (u32)y >> 1;
width = 8 / state->scaleFactor;
height = 8 / state->scaleFactor;
xEnd = x + width;
chromaXEnd = x + width;
chromaYEnd = y + height;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
for (; y < chromaYEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
for (column = x; column < chromaXEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -475,7 +485,8 @@ 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) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
@@ -486,13 +497,13 @@ static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* crTexture;
u32 tileRow;
s32 height;
s32 width;
s32 yEnd;
u8* output;
u8* cb;
u8* cr;
s32 xEnd;
s32 tileOffset;
s32 yEnd;
s32 width;
u32 tileWidth;
luminance = work->convBuf + 4;
@@ -528,13 +539,13 @@ static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
x = (u32)x >> 1;
width = (width + 1) >> 1;
xEnd = x + width;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + ((height + 1) >> 1);
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -542,9 +553,10 @@ static void TMCJPEG_814F1F48(TMCCJPEGDecWork* work, s32 x, s32 y) {
}
}
static void TMCJPEG_814F2570(TMCCJPEGDecWork* work, s32 x, s32 y) {
u8* lumaTexture;
static void TMCJPEGDEC_converterYUV211toY8U8V8(TMCCJPEGDecWork* work, s32 x, s32 y) {
u32 chromaTileWidth;
TMCCJPEGDecState* state;
u8* lumaTexture;
u8* luminance;
s32 column;
s32 row;
@@ -584,13 +596,13 @@ static void TMCJPEG_814F2570(TMCCJPEGDecWork* work, s32 x, s32 y) {
luminance += 8 - width;
}
y = (u32)y >> 1;
tileWidth = state->chromaWidth >> 3;
chromaTileWidth = state->chromaWidth >> 3;
chromaEnd = y + 8 / state->scaleFactor;
for (; y < chromaEnd; y++) {
for (column = x; column < xEnd; column += 1) {
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cb + 128;
(cbTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cb + 128;
cb++;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * tileWidth) << 5)] = *cr + 128;
(crTexture + ((y & 3) << 3) + (column & 7))[(s32)(((column >> 3) + (y >> 2) * chromaTileWidth) << 5)] = *cr + 128;
cr++;
}
cb += 8 - width;
@@ -598,7 +610,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 +675,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 +730,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 +793,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 +829,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;

View File

@@ -644,3 +644,29 @@ forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
GATE PASS
```
## IFD0_tag_parse mask-lever (w1009)
- `tag = (u16)tag;` after `type = (u16)readU16(entry+2, byteOrder);` reproduces base's
extra `clrlwi` tag re-mask (SIZE now matches insn-for-insn except the bltlr leaf):
43 normalized diff ops -> 25. Residual: {tag,type} two-web coloring (base tag=r7/type=r8,
mine tag=r6->r8/type=r7) + the documented `bltlr` folded bound-leaf (the +1 SIZE).
- `tag = (u16)readU16(entry)` inline-cast puts the mask at base's POSITION (mid-second-read)
but renames it r6->r8 (43 ops) — keep the separate-statement form.
- set_converter{RGB565,RGBA8,Y8U8V8} all miss ONE insn: `addi r4, r3, 0x1858` (convBuf base).
Base keeps `work->convBuf` as a live web; MWCC folds every `convBuf + K` into
`addi rN, r3, 0x1858+K` from any source form (var decls, per-case defs, &arr[N], ptr walks).
Only an opaque param web (`static impl(work, convBuf)`) produces r4-based adds — but then
impl stays a separate symbol (base has none) and `inline` re-folds.
## w1009 idct/RGB565 coloring probes
- idct_block_var Lumi/Col (37/53 ops): SIZE-exact, all diffs pure in-window reg
renames (stmw r18 same). Base's zero-check or-chain emits `or r0, NEW, ACC`
(accumulator on src2); `ac = bN | ac` source form is canonicalized back to
acc-src1 by MWCC. Flat-expression `(b4|b6|...|b3)` emits a TREE merge, not
base's linear chain — `ac |=` linear chain kept.
- YUV444toRGB565 (11 ops): base coalesces red onto the correction operand web
and blue onto the last-use `value` web (`add r24,r25,r24; add r25,r25,r23`);
mine spawns r28 for red and reuses the dead correction web for blue.
red-first and blue-first source orders both regressed (15/14 ops) —
pure coloring perm.
- iqdec_b65_frv32 (39 ops): all renames (r26/r29, r4/r7 pointer pairs).