decomp(jpeg): idct Lumi 97.5 -> 99.7, Col 96.4 -> 97.9 #1322
@@ -31,116 +31,159 @@ static s32 scalingClampU8(s32 value) {
|
||||
return value < 0 ? 0 : 255;
|
||||
}
|
||||
|
||||
static s32 clampLumaDc(s32 coefficient) {
|
||||
return clampU8((coefficient >> 11) + 0x80);
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma optimization_level 3
|
||||
void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
|
||||
s32 workspace[64];
|
||||
s32 pitch4;
|
||||
s32 rowOddOutput3;
|
||||
s32 columnOddOutput2;
|
||||
s32 columnC6;
|
||||
s32 columnOddSumRotation;
|
||||
s32 rowDc;
|
||||
s32 columnC1;
|
||||
s32 columnC5;
|
||||
s32 columnC7;
|
||||
s32 columnC4;
|
||||
s32 columnEvenBaseDifference;
|
||||
s32 columnC3;
|
||||
s32 rowC4;
|
||||
s32 rowC2;
|
||||
s32 columnC2;
|
||||
s32 columnScaledEvenRotation;
|
||||
int columnAcBits;
|
||||
s32 rowOddSumRotation;
|
||||
s32 rowEvenOutput1;
|
||||
s32 rowOddOutput1;
|
||||
s32* dst;
|
||||
s32 columnEvenOutput0;
|
||||
s32 columnEvenOutput1;
|
||||
s32 columnEvenOutput3;
|
||||
s32 columnOddHighDifference;
|
||||
s32 columnOddLowSum;
|
||||
s32 rowCount;
|
||||
s32 columnEvenBaseSum;
|
||||
s32 rowEvenBaseDifference;
|
||||
s32 rowOddDifferenceRotation;
|
||||
s32 columnOddLowDifference;
|
||||
s32 columnOddHighSum;
|
||||
s32 rowEvenOutput2;
|
||||
s32 columnOddMix;
|
||||
s32 columnEvenOutput2;
|
||||
s32 rowEvenOutput0;
|
||||
s32 rowC1;
|
||||
s32 columnOddOutput1;
|
||||
s32 rowC3;
|
||||
s32 columnDc;
|
||||
s32 rowEvenSum;
|
||||
s32 rowEvenRotationSum;
|
||||
s32 rowSampleDc;
|
||||
u8* columnOutput;
|
||||
s32 rowOddHighDifference;
|
||||
s32 columnEvenRotationSum;
|
||||
s32 pitch4;
|
||||
s32 rowOddOutput2;
|
||||
s32* src;
|
||||
s32 pitch7;
|
||||
s32 rowCount;
|
||||
s32 columnOddOutput0;
|
||||
s32 rowEvenBaseSum;
|
||||
s32 rowEvenOutput3;
|
||||
s32 rowC6;
|
||||
s32 rowOddLowDifference;
|
||||
s32 rowOddHighSum;
|
||||
s32 columnOddDifferenceRotation;
|
||||
s32 pitch6;
|
||||
s32 pitch5;
|
||||
s32 rowOddLowRotation;
|
||||
s32 rowC5;
|
||||
s32 columnOddOutput3;
|
||||
s32 pitch3;
|
||||
s32 pitch2;
|
||||
int rowAcBits;
|
||||
s32 rowOddLowSum;
|
||||
s32 processed;
|
||||
u8 columnSample;
|
||||
s32 pitch2;
|
||||
s32 rowOddOutput0;
|
||||
s32 rowC7;
|
||||
s32 column;
|
||||
s32 rowOddMix;
|
||||
s32 rowEvenRotation;
|
||||
s32 rowOddDifferenceSum;
|
||||
s32 rowOddHighRotation;
|
||||
s32 rowOddSumDifference;
|
||||
s32 columnOddDifferenceSum;
|
||||
s32 columnOddHighRotation;
|
||||
s32 columnOddLowRotation;
|
||||
s32 columnEvenRotation;
|
||||
s32 columnOddSumDifference;
|
||||
int columnEvenSum;
|
||||
|
||||
rowCount = (zigzag >> 4) * 8;
|
||||
dst = workspace;
|
||||
for (processed = 0; processed < rowCount; processed += 8) {
|
||||
s32 c1;
|
||||
s32 c2;
|
||||
int acBits;
|
||||
s32 c7;
|
||||
s32 c5;
|
||||
s32 c4;
|
||||
s32 c3;
|
||||
s32 c6;
|
||||
c4 = block[4];
|
||||
c6 = block[6];
|
||||
c2 = block[2];
|
||||
c1 = block[1];
|
||||
c7 = block[7];
|
||||
c5 = block[5];
|
||||
c3 = block[3];
|
||||
acBits = c4 | c6;
|
||||
acBits = c2 | acBits;
|
||||
acBits = c1 | acBits;
|
||||
acBits = c7 | acBits;
|
||||
acBits = c5 | acBits;
|
||||
acBits = c3 | acBits;
|
||||
if (acBits == 0) {
|
||||
s32 dc = block[0];
|
||||
dst[7] = dc;
|
||||
dst[6] = dc;
|
||||
dst[5] = dc;
|
||||
dst[4] = dc;
|
||||
dst[3] = dc;
|
||||
dst[2] = dc;
|
||||
dst[1] = dc;
|
||||
dst[0] = dc;
|
||||
rowC4 = block[4];
|
||||
rowC6 = block[6];
|
||||
rowC2 = block[2];
|
||||
rowC1 = block[1];
|
||||
rowC7 = block[7];
|
||||
rowC5 = block[5];
|
||||
rowC3 = block[3];
|
||||
rowAcBits = rowC4 | rowC6;
|
||||
rowAcBits = rowC2 | rowAcBits;
|
||||
rowAcBits = rowC1 | rowAcBits;
|
||||
rowAcBits = rowC7 | rowAcBits;
|
||||
rowAcBits = rowC5 | rowAcBits;
|
||||
rowAcBits = rowC3 | rowAcBits;
|
||||
if (rowAcBits == 0) {
|
||||
rowSampleDc = block[0];
|
||||
dst[7] = rowSampleDc;
|
||||
dst[6] = rowSampleDc;
|
||||
dst[5] = rowSampleDc;
|
||||
dst[4] = rowSampleDc;
|
||||
dst[3] = rowSampleDc;
|
||||
dst[2] = rowSampleDc;
|
||||
dst[1] = rowSampleDc;
|
||||
dst[0] = rowSampleDc;
|
||||
} else {
|
||||
s32 dc;
|
||||
s32 evenSum;
|
||||
s32 oddSumRotation;
|
||||
s32 oddOutput0;
|
||||
s32 evenRotationSum;
|
||||
s32 evenRotation;
|
||||
s32 oddLowDifference;
|
||||
s32 oddDifferenceRotation;
|
||||
s32 evenOutput3;
|
||||
s32 oddOutput1;
|
||||
s32 oddHighSum;
|
||||
s32 oddOutput2;
|
||||
s32 evenBaseSum;
|
||||
s32 evenOutput0;
|
||||
s32 oddDifferenceSum;
|
||||
s32 evenOutput2;
|
||||
s32 oddMix;
|
||||
s32 oddLowRotation;
|
||||
s32 oddOutput3;
|
||||
s32 evenOutput1;
|
||||
s32 oddHighRotation;
|
||||
s32 oddLowSum;
|
||||
s32 oddSumDifference;
|
||||
s32 evenBaseDifference;
|
||||
s32 oddHighDifference;
|
||||
oddHighSum = c1 + c7;
|
||||
dc = block[0];
|
||||
evenSum = c6 + c2;
|
||||
oddLowDifference = c5 - c3;
|
||||
oddHighDifference = c1 - c7;
|
||||
evenRotation = c2 - c6;
|
||||
c2 = evenRotation * 0xB5 >> 8;
|
||||
evenBaseDifference = dc - c4;
|
||||
oddLowSum = c5 + c3;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
oddDifferenceRotation = oddDifferenceSum * 0x62 >> 8;
|
||||
oddLowRotation = oddLowDifference * 0x8B;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
evenRotationSum = c2 + evenSum;
|
||||
evenOutput1 = evenBaseDifference + c2;
|
||||
oddLowRotation >>= 8;
|
||||
evenBaseSum = dc + c4;
|
||||
oddMix = oddHighRotation - oddDifferenceRotation;
|
||||
evenOutput2 = evenBaseDifference - c2;
|
||||
oddOutput1 = oddSumRotation + oddMix;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
oddLowSum += oddMix;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
oddOutput3 = oddDifferenceRotation + oddLowRotation;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
dst[0] = evenOutput0 + oddOutput0;
|
||||
dst[7] = evenOutput0 - oddOutput0;
|
||||
dst[1] = evenOutput1 + oddOutput1;
|
||||
dst[6] = evenOutput1 - oddOutput1;
|
||||
dst[2] = evenOutput2 + oddOutput2;
|
||||
dst[5] = evenOutput2 - oddOutput2;
|
||||
dst[3] = evenOutput3 + oddOutput3;
|
||||
dst[4] = evenOutput3 - oddOutput3;
|
||||
rowOddHighSum = rowC1 + rowC7;
|
||||
rowDc = block[0];
|
||||
rowEvenSum = rowC6 + rowC2;
|
||||
rowOddLowDifference = rowC5 - rowC3;
|
||||
rowOddHighDifference = rowC1 - rowC7;
|
||||
rowEvenRotation = rowC2 - rowC6;
|
||||
rowC2 = rowEvenRotation * 0xB5 >> 8;
|
||||
rowEvenBaseDifference = rowDc - rowC4;
|
||||
rowOddLowSum = rowC5 + rowC3;
|
||||
rowOddSumDifference = rowOddHighSum - rowOddLowSum;
|
||||
rowOddSumRotation = rowOddSumDifference * 0xB5 >> 8;
|
||||
rowOddDifferenceSum = rowOddLowDifference + rowOddHighDifference;
|
||||
rowOddDifferenceRotation = rowOddDifferenceSum * 0x62 >> 8;
|
||||
rowOddLowRotation = rowOddLowDifference * 0x8B;
|
||||
rowOddHighRotation = rowOddHighDifference * 0x14E >> 8;
|
||||
rowEvenRotationSum = rowEvenSum + rowC2;
|
||||
rowEvenOutput1 = rowEvenBaseDifference + rowC2;
|
||||
rowOddLowRotation >>= 8;
|
||||
rowEvenBaseSum = rowDc + rowC4;
|
||||
rowOddMix = rowOddHighRotation - rowOddDifferenceRotation;
|
||||
rowEvenOutput2 = rowEvenBaseDifference - rowC2;
|
||||
rowOddOutput1 = rowOddSumRotation + rowOddMix;
|
||||
rowEvenOutput3 = rowEvenBaseSum - rowEvenRotationSum;
|
||||
rowOddLowSum += rowOddMix;
|
||||
rowEvenOutput0 = rowEvenBaseSum + rowEvenRotationSum;
|
||||
rowOddOutput0 = rowOddHighSum + rowOddLowSum;
|
||||
rowOddOutput3 = rowOddDifferenceRotation + rowOddLowRotation;
|
||||
rowOddOutput2 = rowOddOutput3 + rowOddSumRotation;
|
||||
dst[0] = rowEvenOutput0 + rowOddOutput0;
|
||||
dst[7] = rowEvenOutput0 - rowOddOutput0;
|
||||
dst[1] = rowEvenOutput1 + rowOddOutput1;
|
||||
dst[6] = rowEvenOutput1 - rowOddOutput1;
|
||||
dst[2] = rowEvenOutput2 + rowOddOutput2;
|
||||
dst[5] = rowEvenOutput2 - rowOddOutput2;
|
||||
dst[3] = rowEvenOutput3 + rowOddOutput3;
|
||||
dst[4] = rowEvenOutput3 - rowOddOutput3;
|
||||
}
|
||||
block += 8;
|
||||
dst += 8;
|
||||
@@ -160,117 +203,170 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
|
||||
pitch6 = pitch * 6;
|
||||
pitch7 = pitch * 8 - pitch;
|
||||
for (column = 7; column >= 0; column--) {
|
||||
s32 c1;
|
||||
s32 c2;
|
||||
s32 c5;
|
||||
s32 c3;
|
||||
s32 c6;
|
||||
s32 c4;
|
||||
s32 c7;
|
||||
int acBits;
|
||||
u8* output;
|
||||
c4 = src[32];
|
||||
c6 = src[48];
|
||||
c2 = src[16];
|
||||
c1 = src[8];
|
||||
c7 = src[56];
|
||||
c5 = src[40];
|
||||
c3 = src[24];
|
||||
acBits = c4 | c6;
|
||||
acBits = c2 | acBits;
|
||||
acBits = c1 | acBits;
|
||||
acBits = c7 | acBits;
|
||||
acBits = c5 | acBits;
|
||||
acBits = c3 | acBits;
|
||||
output = conv_row_ptr + column;
|
||||
if (acBits == 0) {
|
||||
u8 sample = clampU8((*src >> 11) + 0x80);
|
||||
output[pitch7] = sample;
|
||||
output[pitch6] = sample;
|
||||
output[pitch5] = sample;
|
||||
output[pitch4] = sample;
|
||||
output[pitch3] = sample;
|
||||
output[pitch2] = sample;
|
||||
output[pitch] = sample;
|
||||
output[0] = sample;
|
||||
columnC4 = src[32];
|
||||
columnC6 = src[48];
|
||||
columnC2 = src[16];
|
||||
columnC1 = src[8];
|
||||
columnC7 = src[56];
|
||||
columnC5 = src[40];
|
||||
columnC3 = src[24];
|
||||
columnAcBits = columnC4 | columnC6;
|
||||
columnAcBits = columnC2 | columnAcBits;
|
||||
columnAcBits = columnC1 | columnAcBits;
|
||||
columnAcBits = columnC7 | columnAcBits;
|
||||
columnAcBits = columnC5 | columnAcBits;
|
||||
columnAcBits = columnC3 | columnAcBits;
|
||||
columnOutput = conv_row_ptr + column;
|
||||
if (columnAcBits == 0) {
|
||||
columnSample = clampLumaDc(*src);
|
||||
columnOutput[pitch7] = columnSample;
|
||||
columnOutput[pitch6] = columnSample;
|
||||
columnOutput[pitch5] = columnSample;
|
||||
columnOutput[pitch4] = columnSample;
|
||||
columnOutput[pitch3] = columnSample;
|
||||
columnOutput[pitch2] = columnSample;
|
||||
columnOutput[pitch] = columnSample;
|
||||
columnOutput[0] = columnSample;
|
||||
} else {
|
||||
s32 oddDifferenceSum;
|
||||
s32 oddSumRotation;
|
||||
s32 evenBaseSum;
|
||||
s32 evenOutput2;
|
||||
s32 dc;
|
||||
s32 evenBaseDifference;
|
||||
s32 evenOutput0;
|
||||
s32 evenOutput1;
|
||||
s32 evenOutput3;
|
||||
s32 oddHighRotation;
|
||||
s32 oddMix;
|
||||
s32 oddHighDifference;
|
||||
s32 oddLowSum;
|
||||
s32 oddLowRotation;
|
||||
s32 evenRotation;
|
||||
s32 oddLowDifference;
|
||||
s32 oddSumDifference;
|
||||
s32 oddHighSum;
|
||||
s32 evenRotationSum;
|
||||
s32 oddOutput0;
|
||||
s32 evenSum;
|
||||
s32 oddOutput2;
|
||||
s32 oddDifferenceRotation;
|
||||
s32 oddOutput1;
|
||||
s32 oddOutput3;
|
||||
evenSum = c6 + c2;
|
||||
evenRotation = c2 - c6;
|
||||
oddLowSum = c5 + c3;
|
||||
oddHighDifference = c1 - c7;
|
||||
oddLowDifference = c5 - c3;
|
||||
oddHighSum = c1 + c7;
|
||||
c2 = evenRotation * 0xB5 >> 8;
|
||||
dc = *src + 0x40000;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
evenBaseSum = dc + c4;
|
||||
oddDifferenceRotation = oddDifferenceSum * 0x62 >> 8;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
evenRotationSum = c2 + evenSum;
|
||||
oddMix = oddHighRotation - oddDifferenceRotation;
|
||||
oddLowSum += oddMix;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
evenBaseDifference = dc - c4;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
evenOutput1 = evenBaseDifference + c2;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
oddLowRotation = oddLowDifference * 0x8B >> 8;
|
||||
oddOutput3 = oddDifferenceRotation + oddLowRotation;
|
||||
evenOutput2 = evenBaseDifference - c2;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
oddOutput1 = oddSumRotation + oddMix;
|
||||
output[0] = scalingClampU8(evenOutput0 + oddOutput0);
|
||||
output[pitch7] = scalingClampU8(evenOutput0 - oddOutput0);
|
||||
output[pitch] = scalingClampU8(evenOutput1 + oddOutput1);
|
||||
output[pitch6] = scalingClampU8(evenOutput1 - oddOutput1);
|
||||
output[pitch2] = scalingClampU8(evenOutput2 + oddOutput2);
|
||||
output[pitch5] = scalingClampU8(evenOutput2 - oddOutput2);
|
||||
output[pitch3] = scalingClampU8(evenOutput3 + oddOutput3);
|
||||
output[pitch4] = scalingClampU8(evenOutput3 - oddOutput3);
|
||||
columnEvenSum = columnC6 + columnC2;
|
||||
columnEvenRotation = columnC2 - columnC6;
|
||||
columnOddLowSum = columnC5 + columnC3;
|
||||
columnOddHighDifference = columnC1 - columnC7;
|
||||
columnOddLowDifference = columnC5 - columnC3;
|
||||
columnOddHighSum = columnC1 + columnC7;
|
||||
columnScaledEvenRotation = columnEvenRotation * 0xB5 >> 8;
|
||||
columnDc = *src + 0x40000;
|
||||
columnOddDifferenceSum = columnOddLowDifference + columnOddHighDifference;
|
||||
columnOddSumDifference = columnOddHighSum - columnOddLowSum;
|
||||
columnOddSumRotation = columnOddSumDifference * 0xB5 >> 8;
|
||||
columnEvenBaseSum = columnDc + columnC4;
|
||||
columnOddDifferenceRotation = columnOddDifferenceSum * 0x62 >> 8;
|
||||
columnOddHighRotation = columnOddHighDifference * 0x14E >> 8;
|
||||
columnEvenRotationSum = columnScaledEvenRotation + columnEvenSum;
|
||||
columnOddMix = columnOddHighRotation - columnOddDifferenceRotation;
|
||||
columnOddLowSum += columnOddMix;
|
||||
columnEvenOutput0 = columnEvenBaseSum + columnEvenRotationSum;
|
||||
columnEvenBaseDifference = columnDc - columnC4;
|
||||
columnEvenOutput3 = columnEvenBaseSum - columnEvenRotationSum;
|
||||
columnEvenOutput1 = columnEvenBaseDifference + columnScaledEvenRotation;
|
||||
columnOddOutput0 = columnOddHighSum + columnOddLowSum;
|
||||
columnOddLowRotation = columnOddLowDifference * 0x8B >> 8;
|
||||
columnOddOutput3 = columnOddDifferenceRotation + columnOddLowRotation;
|
||||
columnEvenOutput2 = columnEvenBaseDifference - columnScaledEvenRotation;
|
||||
columnOddOutput2 = columnOddOutput3 + columnOddSumRotation;
|
||||
columnOddOutput1 = columnOddSumRotation + columnOddMix;
|
||||
columnOutput[0] = scalingClampU8(columnEvenOutput0 + columnOddOutput0);
|
||||
columnOutput[pitch7] = scalingClampU8(columnEvenOutput0 - columnOddOutput0);
|
||||
columnOutput[pitch] = scalingClampU8(columnEvenOutput1 + columnOddOutput1);
|
||||
columnOutput[pitch6] = scalingClampU8(columnEvenOutput1 - columnOddOutput1);
|
||||
columnOutput[pitch2] = scalingClampU8(columnEvenOutput2 + columnOddOutput2);
|
||||
columnOutput[pitch5] = scalingClampU8(columnEvenOutput2 - columnOddOutput2);
|
||||
columnOutput[pitch3] = scalingClampU8(columnEvenOutput3 + columnOddOutput3);
|
||||
columnOutput[pitch4] = scalingClampU8(columnEvenOutput3 - columnOddOutput3);
|
||||
}
|
||||
src--;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma pop
|
||||
|
||||
static s32 clampChromaDc(s32 value) {
|
||||
return clampS8(value >> 11);
|
||||
}
|
||||
|
||||
void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
|
||||
s32 workspace[64];
|
||||
s32* src;
|
||||
s32 column;
|
||||
s32 rowCount;
|
||||
s32 processed;
|
||||
s32 rowOuter;
|
||||
s32 columnOddOutput2;
|
||||
s32* dst;
|
||||
s32 columnEvenRotationSum;
|
||||
s32 rowOddSumRotation;
|
||||
s32 rowOddOutput1;
|
||||
s32* src;
|
||||
s32 rowC3;
|
||||
s32 rowMid;
|
||||
s32 columnOddSumRotation;
|
||||
s32 columnOddOutput3;
|
||||
s32 columnC1;
|
||||
s32 columnEvenBaseSum;
|
||||
s32 sparseDc;
|
||||
s32 columnEvenBaseDifference;
|
||||
s32 columnOddDifferenceRotation;
|
||||
s32 columnC7;
|
||||
s32 rowOdd;
|
||||
s32 rowDc;
|
||||
s32 rowC6;
|
||||
s32 rowC2;
|
||||
s32 columnC6;
|
||||
s32 rowOddOutput3;
|
||||
s32 columnOddOutput1;
|
||||
s32 columnScaledEvenRotation;
|
||||
s32 rowCount;
|
||||
s32 columnC5;
|
||||
s32 rowSampleDc;
|
||||
s32 column;
|
||||
s32 columnOddOutput0;
|
||||
s32 rowEvenBaseDifference;
|
||||
s32 columnEvenOutput0;
|
||||
s32 columnOddMix;
|
||||
s32 columnEvenOutput1;
|
||||
s32 columnDc;
|
||||
s32 rowRotation;
|
||||
s32 columnC4;
|
||||
s32 columnC3;
|
||||
s32 rowOddDifferenceRotation;
|
||||
s32 rowC1;
|
||||
int columnAcBits;
|
||||
s32 columnEvenOutput3;
|
||||
s32 rowOddOutput2;
|
||||
s32 processed;
|
||||
s32 rowEvenOutput1;
|
||||
s32 rowOddOutput0;
|
||||
s32 columnEvenOutput2;
|
||||
s32 rowEvenBaseSum;
|
||||
s32 rowC7;
|
||||
s32 rowC5;
|
||||
s32 rowOddMix;
|
||||
s32 rowLowRotation;
|
||||
s32 rowEvenOutput2;
|
||||
s32 rowScaledEvenRotation;
|
||||
s32 columnOddHighDifference;
|
||||
s32 rowEvenOutput3;
|
||||
s32 rowEvenOutput0;
|
||||
s32 rowMix;
|
||||
s32 rowC4;
|
||||
s32 columnOddLowSum;
|
||||
s32 rowOddLowDifference;
|
||||
s32 columnOddLowDifference;
|
||||
s32 columnOddHighSum;
|
||||
s32 rowInner;
|
||||
s32 rowOddHighSum;
|
||||
s32 rowOddHighDifference;
|
||||
int rowAcBits;
|
||||
s32 rowOddLowSum;
|
||||
u8* columnOutput;
|
||||
s32 columnC2;
|
||||
s32 rowEvenRotationSum;
|
||||
int columnEvenSum;
|
||||
s32 rowEvenSum;
|
||||
s32 flatDc;
|
||||
s32 rowSample;
|
||||
s32 rowOddLowRotation;
|
||||
s32 rowOddDifferenceSum;
|
||||
s32 rowOddSumDifference;
|
||||
s32 rowEvenRotation;
|
||||
s32 rowOddHighRotation;
|
||||
s32 columnSample;
|
||||
s32 columnOddHighRotation;
|
||||
s32 columnOddSumDifference;
|
||||
s32 columnOddDifferenceSum;
|
||||
s32 columnOddLowRotation;
|
||||
s32 columnEvenRotation;
|
||||
|
||||
if (zigzag == 0x11) {
|
||||
s32 dc = block[0];
|
||||
s32 sample = clampS8(dc >> 11);
|
||||
memset(conv_row_ptr, (s8)sample, 64);
|
||||
flatDc = block[0];
|
||||
rowSample = clampS8(flatDc >> 11);
|
||||
memset(conv_row_ptr, (s8)rowSample, 64);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -278,30 +374,22 @@ void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigza
|
||||
if ((zigzag & 0xF) <= 2) {
|
||||
dst = workspace;
|
||||
for (processed = 0; processed < rowCount; processed += 8) {
|
||||
s32 mid;
|
||||
s32 odd;
|
||||
s32 outer;
|
||||
s32 dc;
|
||||
s32 inner;
|
||||
s32 rotation;
|
||||
s32 lowRotation;
|
||||
s32 mix;
|
||||
odd = block[1];
|
||||
rotation = odd * 0xB5 >> 8;
|
||||
lowRotation = odd * 0x62 >> 8;
|
||||
dc = block[0];
|
||||
mix = (odd * 0x14E >> 8) - lowRotation;
|
||||
outer = odd + mix;
|
||||
dst[0] = dc + outer;
|
||||
inner = rotation + mix;
|
||||
dst[7] = dc - outer;
|
||||
dst[1] = dc + inner;
|
||||
mid = lowRotation + rotation;
|
||||
dst[6] = dc - inner;
|
||||
dst[2] = dc + mid;
|
||||
dst[5] = dc - mid;
|
||||
dst[3] = dc + lowRotation;
|
||||
dst[4] = dc - lowRotation;
|
||||
rowOdd = block[1];
|
||||
rowRotation = rowOdd * 0xB5 >> 8;
|
||||
rowLowRotation = rowOdd * 0x62 >> 8;
|
||||
sparseDc = block[0];
|
||||
rowMix = (rowOdd * 0x14E >> 8) - rowLowRotation;
|
||||
rowOuter = rowOdd + rowMix;
|
||||
dst[0] = sparseDc + rowOuter;
|
||||
rowInner = rowRotation + rowMix;
|
||||
dst[7] = sparseDc - rowOuter;
|
||||
dst[1] = sparseDc + rowInner;
|
||||
rowMid = rowLowRotation + rowRotation;
|
||||
dst[6] = sparseDc - rowInner;
|
||||
dst[2] = sparseDc + rowMid;
|
||||
dst[5] = sparseDc - rowMid;
|
||||
dst[3] = sparseDc + rowLowRotation;
|
||||
dst[4] = sparseDc - rowLowRotation;
|
||||
dst += 8;
|
||||
block += 8;
|
||||
}
|
||||
@@ -313,99 +401,66 @@ void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigza
|
||||
} else {
|
||||
dst = workspace;
|
||||
for (processed = 0; processed < rowCount; processed += 8) {
|
||||
s32 c2;
|
||||
s32 c7;
|
||||
s32 c3;
|
||||
s32 c5;
|
||||
s32 c1;
|
||||
s32 c6;
|
||||
int acBits;
|
||||
s32 c4;
|
||||
c4 = block[4];
|
||||
c6 = block[6];
|
||||
c2 = block[2];
|
||||
c1 = block[1];
|
||||
c7 = block[7];
|
||||
c5 = block[5];
|
||||
c3 = block[3];
|
||||
acBits = c4 | c6;
|
||||
acBits = c2 | acBits;
|
||||
acBits = c1 | acBits;
|
||||
acBits = c7 | acBits;
|
||||
acBits = c5 | acBits;
|
||||
acBits = c3 | acBits;
|
||||
if (acBits == 0) {
|
||||
s32 dc = block[0];
|
||||
dst[7] = dc;
|
||||
dst[6] = dc;
|
||||
dst[5] = dc;
|
||||
dst[4] = dc;
|
||||
dst[3] = dc;
|
||||
dst[2] = dc;
|
||||
dst[1] = dc;
|
||||
dst[0] = dc;
|
||||
rowC4 = block[4];
|
||||
rowC6 = block[6];
|
||||
rowC2 = block[2];
|
||||
rowC1 = block[1];
|
||||
rowC7 = block[7];
|
||||
rowC5 = block[5];
|
||||
rowC3 = block[3];
|
||||
rowAcBits = rowC4 | rowC6;
|
||||
rowAcBits = rowC2 | rowAcBits;
|
||||
rowAcBits = rowC1 | rowAcBits;
|
||||
rowAcBits = rowC7 | rowAcBits;
|
||||
rowAcBits = rowC5 | rowAcBits;
|
||||
rowAcBits = rowC3 | rowAcBits;
|
||||
if (rowAcBits == 0) {
|
||||
rowSampleDc = block[0];
|
||||
dst[7] = rowSampleDc;
|
||||
dst[6] = rowSampleDc;
|
||||
dst[5] = rowSampleDc;
|
||||
dst[4] = rowSampleDc;
|
||||
dst[3] = rowSampleDc;
|
||||
dst[2] = rowSampleDc;
|
||||
dst[1] = rowSampleDc;
|
||||
dst[0] = rowSampleDc;
|
||||
} else {
|
||||
s32 evenBaseDifference;
|
||||
s32 oddOutput3;
|
||||
s32 oddMix;
|
||||
s32 evenOutput1;
|
||||
s32 evenOutput2;
|
||||
s32 oddDifferenceRotation;
|
||||
s32 oddLowRotation;
|
||||
s32 oddDifferenceSum;
|
||||
s32 evenSum;
|
||||
s32 oddLowSum;
|
||||
s32 dc;
|
||||
s32 oddSumDifference;
|
||||
s32 oddLowDifference;
|
||||
s32 evenBaseSum;
|
||||
s32 oddSumRotation;
|
||||
s32 evenRotationSum;
|
||||
s32 evenRotation;
|
||||
s32 evenOutput0;
|
||||
s32 oddOutput1;
|
||||
s32 oddHighDifference;
|
||||
s32 oddOutput0;
|
||||
s32 evenOutput3;
|
||||
s32 oddHighSum;
|
||||
s32 oddOutput2;
|
||||
s32 oddHighRotation;
|
||||
oddHighDifference = c1 - c7;
|
||||
oddLowSum = c5 + c3;
|
||||
evenSum = c6 + c2;
|
||||
oddHighSum = c1 + c7;
|
||||
evenRotation = c2 - c6;
|
||||
dc = block[0];
|
||||
evenBaseDifference = dc - c4;
|
||||
c2 = evenRotation * 0xB5 >> 8;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddLowDifference = c5 - c3;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
evenBaseSum = dc + c4;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
oddDifferenceRotation = oddDifferenceSum * 0x62 >> 8;
|
||||
evenRotationSum = c2 + evenSum;
|
||||
oddMix = oddHighRotation - oddDifferenceRotation;
|
||||
oddOutput1 = oddSumRotation + oddMix;
|
||||
evenOutput1 = evenBaseDifference + c2;
|
||||
oddLowRotation = oddLowDifference * 0x8B;
|
||||
oddLowSum += oddMix;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
oddLowRotation >>= 8;
|
||||
oddOutput3 = oddDifferenceRotation + oddLowRotation;
|
||||
evenOutput2 = evenBaseDifference - c2;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
dst[0] = evenOutput0 + oddOutput0;
|
||||
dst[7] = evenOutput0 - oddOutput0;
|
||||
dst[1] = evenOutput1 + oddOutput1;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
dst[6] = evenOutput1 - oddOutput1;
|
||||
dst[2] = evenOutput2 + oddOutput2;
|
||||
dst[5] = evenOutput2 - oddOutput2;
|
||||
dst[3] = evenOutput3 + oddOutput3;
|
||||
dst[4] = evenOutput3 - oddOutput3;
|
||||
rowOddHighDifference = rowC1 - rowC7;
|
||||
rowOddLowSum = rowC5 + rowC3;
|
||||
rowEvenSum = rowC6 + rowC2;
|
||||
rowOddHighSum = rowC1 + rowC7;
|
||||
rowEvenRotation = rowC2 - rowC6;
|
||||
rowDc = block[0];
|
||||
rowEvenBaseDifference = rowDc - rowC4;
|
||||
rowScaledEvenRotation = rowEvenRotation * 0xB5 >> 8;
|
||||
rowOddSumDifference = rowOddHighSum - rowOddLowSum;
|
||||
rowOddLowDifference = rowC5 - rowC3;
|
||||
rowOddSumRotation = rowOddSumDifference * 0xB5 >> 8;
|
||||
rowEvenBaseSum = rowDc + rowC4;
|
||||
rowOddHighRotation = rowOddHighDifference * 0x14E >> 8;
|
||||
rowOddDifferenceSum = rowOddLowDifference + rowOddHighDifference;
|
||||
rowOddDifferenceRotation = rowOddDifferenceSum * 0x62 >> 8;
|
||||
rowEvenRotationSum = rowScaledEvenRotation + rowEvenSum;
|
||||
rowOddMix = rowOddHighRotation - rowOddDifferenceRotation;
|
||||
rowOddOutput1 = rowOddSumRotation + rowOddMix;
|
||||
rowEvenOutput1 = rowEvenBaseDifference + rowScaledEvenRotation;
|
||||
rowOddLowRotation = rowOddLowDifference * 0x8B;
|
||||
rowOddLowSum += rowOddMix;
|
||||
rowEvenOutput3 = rowEvenBaseSum - rowEvenRotationSum;
|
||||
rowEvenOutput0 = rowEvenBaseSum + rowEvenRotationSum;
|
||||
rowOddLowRotation >>= 8;
|
||||
rowOddOutput3 = rowOddDifferenceRotation + rowOddLowRotation;
|
||||
rowEvenOutput2 = rowEvenBaseDifference - rowScaledEvenRotation;
|
||||
rowOddOutput0 = rowOddHighSum + rowOddLowSum;
|
||||
dst[0] = rowEvenOutput0 + rowOddOutput0;
|
||||
dst[7] = rowEvenOutput0 - rowOddOutput0;
|
||||
dst[1] = rowEvenOutput1 + rowOddOutput1;
|
||||
rowOddOutput2 = rowOddOutput3 + rowOddSumRotation;
|
||||
dst[6] = rowEvenOutput1 - rowOddOutput1;
|
||||
dst[2] = rowEvenOutput2 + rowOddOutput2;
|
||||
dst[5] = rowEvenOutput2 - rowOddOutput2;
|
||||
dst[3] = rowEvenOutput3 + rowOddOutput3;
|
||||
dst[4] = rowEvenOutput3 - rowOddOutput3;
|
||||
}
|
||||
block += 8;
|
||||
dst += 8;
|
||||
@@ -419,100 +474,66 @@ void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigza
|
||||
|
||||
src = workspace + 7;
|
||||
for (column = 7; column >= 0; column--) {
|
||||
s32 c1;
|
||||
s32 c3;
|
||||
int acBits;
|
||||
s32 c7;
|
||||
s32 c2;
|
||||
s32 c5;
|
||||
u8* output;
|
||||
s32 c6;
|
||||
s32 c4;
|
||||
c4 = src[32];
|
||||
output = conv_row_ptr + column;
|
||||
c6 = src[48];
|
||||
c2 = src[16];
|
||||
c1 = src[8];
|
||||
c7 = src[56];
|
||||
c5 = src[40];
|
||||
c3 = src[24];
|
||||
acBits = c4 | c6;
|
||||
acBits = c2 | acBits;
|
||||
acBits = c1 | acBits;
|
||||
acBits = c7 | acBits;
|
||||
acBits = c5 | acBits;
|
||||
acBits = c3 | acBits;
|
||||
if (acBits == 0) {
|
||||
s32 sample = clampS8(*src >> 11);
|
||||
output[56] = (u8)sample;
|
||||
output[48] = (u8)sample;
|
||||
output[40] = (u8)sample;
|
||||
output[32] = (u8)sample;
|
||||
output[24] = (u8)sample;
|
||||
output[16] = (u8)sample;
|
||||
output[8] = (u8)sample;
|
||||
output[0] = (u8)sample;
|
||||
columnC4 = src[32];
|
||||
columnOutput = conv_row_ptr + column;
|
||||
columnC6 = src[48];
|
||||
columnC2 = src[16];
|
||||
columnC1 = src[8];
|
||||
columnC7 = src[56];
|
||||
columnC5 = src[40];
|
||||
columnC3 = src[24];
|
||||
columnAcBits = columnC4 | columnC6;
|
||||
columnAcBits = columnC2 | columnAcBits;
|
||||
columnAcBits = columnC1 | columnAcBits;
|
||||
columnAcBits = columnC7 | columnAcBits;
|
||||
columnAcBits = columnC5 | columnAcBits;
|
||||
columnAcBits = columnC3 | columnAcBits;
|
||||
if (columnAcBits == 0) {
|
||||
columnSample = clampChromaDc(*src);
|
||||
columnOutput[56] = (u8)columnSample;
|
||||
columnOutput[48] = (u8)columnSample;
|
||||
columnOutput[40] = (u8)columnSample;
|
||||
columnOutput[32] = (u8)columnSample;
|
||||
columnOutput[24] = (u8)columnSample;
|
||||
columnOutput[16] = (u8)columnSample;
|
||||
columnOutput[8] = (u8)columnSample;
|
||||
columnOutput[0] = (u8)columnSample;
|
||||
} else {
|
||||
s32 evenSum;
|
||||
s32 evenOutput2;
|
||||
s32 oddOutput0;
|
||||
s32 oddMix;
|
||||
s32 evenBaseSum;
|
||||
s32 oddHighRotation;
|
||||
s32 evenRotationSum;
|
||||
s32 oddSumDifference;
|
||||
s32 evenOutput1;
|
||||
s32 oddHighSum;
|
||||
s32 evenOutput0;
|
||||
s32 oddOutput1;
|
||||
s32 oddDifferenceSum;
|
||||
s32 oddLowSum;
|
||||
s32 oddOutput3;
|
||||
s32 evenBaseDifference;
|
||||
s32 oddHighDifference;
|
||||
s32 oddOutput2;
|
||||
s32 dc;
|
||||
s32 oddLowDifference;
|
||||
s32 evenOutput3;
|
||||
s32 oddDifferenceRotation;
|
||||
s32 oddLowRotation;
|
||||
s32 evenRotation;
|
||||
s32 oddSumRotation;
|
||||
oddHighSum = c1 + c7;
|
||||
evenRotation = c2 - c6;
|
||||
oddLowSum = c5 + c3;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
evenSum = c6 + c2;
|
||||
oddLowDifference = c5 - c3;
|
||||
c2 = evenRotation * 0xB5 >> 8;
|
||||
oddHighDifference = c1 - c7;
|
||||
dc = *src;
|
||||
evenRotationSum = c2 + evenSum;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
oddDifferenceRotation = oddDifferenceSum * 0x62 >> 8;
|
||||
evenBaseDifference = dc - c4;
|
||||
evenBaseSum = dc + c4;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
oddMix = oddHighRotation - oddDifferenceRotation;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
evenOutput1 = evenBaseDifference + c2;
|
||||
evenOutput2 = evenBaseDifference - c2;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
oddLowRotation = oddLowDifference * 0x8B >> 8;
|
||||
oddOutput3 = oddDifferenceRotation + oddLowRotation;
|
||||
oddLowSum += oddMix;
|
||||
oddOutput1 = oddSumRotation + oddMix;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
output[0] = (u8)clampS8((evenOutput0 + oddOutput0) >> 11);
|
||||
output[56] = (u8)clampS8((evenOutput0 - oddOutput0) >> 11);
|
||||
output[8] = (u8)clampS8((evenOutput1 + oddOutput1) >> 11);
|
||||
output[48] = (u8)clampS8((evenOutput1 - oddOutput1) >> 11);
|
||||
output[16] = (u8)clampS8((evenOutput2 + oddOutput2) >> 11);
|
||||
output[40] = (u8)clampS8((evenOutput2 - oddOutput2) >> 11);
|
||||
output[24] = (u8)clampS8((evenOutput3 + oddOutput3) >> 11);
|
||||
output[32] = (u8)clampS8((evenOutput3 - oddOutput3) >> 11);
|
||||
columnOddHighSum = columnC1 + columnC7;
|
||||
columnEvenRotation = columnC2 - columnC6;
|
||||
columnOddLowSum = columnC5 + columnC3;
|
||||
columnOddSumDifference = columnOddHighSum - columnOddLowSum;
|
||||
columnEvenSum = columnC6 + columnC2;
|
||||
columnOddLowDifference = columnC5 - columnC3;
|
||||
columnScaledEvenRotation = columnEvenRotation * 0xB5 >> 8;
|
||||
columnOddHighDifference = columnC1 - columnC7;
|
||||
columnDc = *src;
|
||||
columnEvenRotationSum = columnScaledEvenRotation + columnEvenSum;
|
||||
columnOddSumRotation = columnOddSumDifference * 0xB5 >> 8;
|
||||
columnOddDifferenceSum = columnOddLowDifference + columnOddHighDifference;
|
||||
columnOddDifferenceRotation = columnOddDifferenceSum * 0x62 >> 8;
|
||||
columnEvenBaseDifference = columnDc - columnC4;
|
||||
columnEvenBaseSum = columnDc + columnC4;
|
||||
columnOddHighRotation = columnOddHighDifference * 0x14E >> 8;
|
||||
columnOddMix = columnOddHighRotation - columnOddDifferenceRotation;
|
||||
columnEvenOutput3 = columnEvenBaseSum - columnEvenRotationSum;
|
||||
columnEvenOutput1 = columnEvenBaseDifference + columnScaledEvenRotation;
|
||||
columnEvenOutput2 = columnEvenBaseDifference - columnScaledEvenRotation;
|
||||
columnEvenOutput0 = columnEvenBaseSum + columnEvenRotationSum;
|
||||
columnOddLowRotation = columnOddLowDifference * 0x8B >> 8;
|
||||
columnOddOutput3 = columnOddDifferenceRotation + columnOddLowRotation;
|
||||
columnOddLowSum += columnOddMix;
|
||||
columnOddOutput1 = columnOddSumRotation + columnOddMix;
|
||||
columnOddOutput0 = columnOddHighSum + columnOddLowSum;
|
||||
columnOddOutput2 = columnOddOutput3 + columnOddSumRotation;
|
||||
columnOutput[0] = (u8)clampS8((columnEvenOutput0 + columnOddOutput0) >> 11);
|
||||
columnOutput[56] = (u8)clampS8((columnEvenOutput0 - columnOddOutput0) >> 11);
|
||||
columnOutput[8] = (u8)clampS8((columnEvenOutput1 + columnOddOutput1) >> 11);
|
||||
columnOutput[48] = (u8)clampS8((columnEvenOutput1 - columnOddOutput1) >> 11);
|
||||
columnOutput[16] = (u8)clampS8((columnEvenOutput2 + columnOddOutput2) >> 11);
|
||||
columnOutput[40] = (u8)clampS8((columnEvenOutput2 - columnOddOutput2) >> 11);
|
||||
columnOutput[24] = (u8)clampS8((columnEvenOutput3 + columnOddOutput3) >> 11);
|
||||
columnOutput[32] = (u8)clampS8((columnEvenOutput3 - columnOddOutput3) >> 11);
|
||||
}
|
||||
src--;
|
||||
}
|
||||
|
||||
16418
tools/decomp-assist/g-idct.attempts.md
Normal file
16418
tools/decomp-assist/g-idct.attempts.md
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user