Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/LibJXR/image/decode/strInvTransform.c view on Meta::CPAN
/** butterflies **/
d += a;
c -= b;
a -= (t1 = d >> 1);
b += (t2 = c >> 1);
/** rotate pi/4 **/
a -= (b * 3 + 6) >> 3;
b += (a * 3 + 2) >> 2;
a -= (b * 3 + 4) >> 3;
/** butterflies **/
b -= t2;
a += t1;
c += b;
d -= a;
*pa = a;
*pb = b;
*pc = c;
*pd = d;
}
/** Kron(Rotate(-pi/8), [1 1; 1 -1]/sqrt(2)) **/
/** [D C A B] => [a b c d] **/
Void invOdd(PixelI *pa, PixelI *pb, PixelI *pc, PixelI *pd)
{
PixelI a, b, c, d;
a = *pa;
b = *pb;
c = *pc;
d = *pd;
/** butterflies **/
b += d;
a -= c;
d -= (b) >> 1;
c += (a + 1) >> 1;
/** rotate pi/8 **/
IROTATE2(a, b);
IROTATE2(c, d);
/** butterflies **/
c -= (b + 1) >> 1;
d = ((a + 1) >> 1) - d;
b += c;
a -= d;
*pa = a;
*pb = b;
*pc = c;
*pd = d;
}
/*************************************************************************
Top-level function to inverse tranform possible part of a macroblock
*************************************************************************/
Int invTransformMacroblock(CWMImageStrCodec * pSC)
{
const OVERLAP olOverlap = pSC->WMISCP.olOverlap;
const COLORFORMAT cfColorFormat = pSC->m_param.cfColorFormat;
// const BITDEPTH_BITS bdBitDepth = pSC->WMII.bdBitDepth;
const Bool left = (pSC->cColumn == 0), right = (pSC->cColumn == pSC->cmbWidth);
const Bool top = (pSC->cRow == 0), bottom = (pSC->cRow == pSC->cmbHeight);
const Bool topORbottom = (top || bottom), leftORright = (left || right);
const Bool topORleft = (top || left), bottomORright = (bottom || right);
const size_t mbWidth = pSC->cmbWidth, mbX = pSC->cColumn;
PixelI * p = NULL;// * pt = NULL;
size_t i;
const size_t iChannels = (cfColorFormat == YUV_420 || cfColorFormat == YUV_422) ? 1 : pSC->m_param.cNumChannels;
const size_t tScale = pSC->m_Dparam->cThumbnailScale;
Int j = 0;
Int qp[MAX_CHANNELS], dcqp[MAX_CHANNELS], iStrength = (1 << pSC->WMII.cPostProcStrength);
// ERR_CODE result = ICERR_OK;
Bool bHPAbsent = (pSC->WMISCP.sbSubband == SB_NO_HIGHPASS || pSC->WMISCP.sbSubband == SB_DC_ONLY);
if(pSC->WMII.cPostProcStrength > 0){
// threshold for post processing
for(i = 0; i < iChannels; i ++){
qp[i] = pSC->pTile[pSC->cTileColumn].pQuantizerLP[i][pSC->MBInfo.iQIndexLP].iQP * iStrength * (olOverlap == OL_NONE ? 2 : 1);
dcqp[i] = pSC->pTile[pSC->cTileColumn].pQuantizerDC[i][0].iQP * iStrength;
}
if(left) // a new MB row
slideOneMBRow(pSC->pPostProcInfo, pSC->m_param.cNumChannels, mbWidth, top, bottom); // previous current row becomes previous row
}
//================================================================
// 400_Y, 444_YUV
for (i = 0; i < iChannels && tScale < 16; ++i)
{
PixelI* const p0 = pSC->p0MBbuffer[i];
PixelI* const p1 = pSC->p1MBbuffer[i];
Int iHPQP = 255;
if (!bHPAbsent)
iHPQP = pSC->pTile[pSC->cTileColumn].pQuantizerHP[i][pSC->MBInfo.iQIndexHP].iQP;
//================================
// second level inverse transform
if (!bottomORright)
{
if(pSC->WMII.cPostProcStrength > 0)
updatePostProcInfo(pSC->pPostProcInfo, p1, mbX, i); // update postproc info before IDCT
strIDCT4x4Stage2(p1);
if (pSC->m_param.bScaledArith) {
strNormalizeDec(p1, (i != 0));
}
}
//================================
// second level inverse overlap
if (OL_TWO == olOverlap)
{
if (leftORright && (!topORbottom))
src/Source/LibJXR/image/decode/strInvTransform.c view on Meta::CPAN
for (j = (left ? 0 : -128); j < (right ? -64 : 0); j += 64)
{
strPost4x4Stage1(p0 + j + 32, 0, iHPQP, bHPAbsent);
}
}
if (!bottom)
{
if (leftORright)
{
j = (left ? 0 + 10 : -64 + 14);
p = p1 + j;
strPost4(p + 0, p - 2, p + 6, p + 8);
strPost4(p + 1, p - 1, p + 7, p + 9);
p += 16;
strPost4(p + 0, p - 2, p + 6, p + 8);
strPost4(p + 1, p - 1, p + 7, p + 9);
p = NULL;
}
for (j = (left ? 0 : -128); j < (right ? -64 : 0); j += 64)
{
strPost4x4Stage1(p1 + j + 0, 0, iHPQP, bHPAbsent);
strPost4x4Stage1(p1 + j + 16, 0, iHPQP, bHPAbsent);
}
}
if (topORbottom)
{
p = (top ? p1 + 5 : p0 + 48 + 13);
for (j = (left ? 0 : -128); j < (right ? -64 : 0); j += 64)
{
strPost4(p + j + 0, p + j - 1, p + j + 59, p + j + 60);
strPost4(p + j + 2, p + j + 1, p + j + 61, p + j + 62);
}
p = NULL;
}
else
{
if (leftORright)
{
j = (left ? 0 + 0 : -64 + 4);
strPost4(p0 + j + 48 + 10 + 0, p0 + j + 48 + 10 - 2, p1 + j + 0, p1 + j + 2);
strPost4(p0 + j + 48 + 10 + 1, p0 + j + 48 + 10 - 1, p1 + j + 1, p1 + j + 3);
}
for (j = (left ? 0 : -128); j < (right ? -64 : 0); j += 64)
{
strPost4x4Stage1Split(p0 + j + 48, p1 + j + 0, 0, iHPQP, bHPAbsent);
}
}
}
}
return ICERR_OK;
}
Int invTransformMacroblock_alteredOperators_hard(CWMImageStrCodec * pSC)
{
const OVERLAP olOverlap = pSC->WMISCP.olOverlap;
const COLORFORMAT cfColorFormat = pSC->m_param.cfColorFormat;
// const BITDEPTH_BITS bdBitDepth = pSC->WMII.bdBitDepth;
const Bool left = (pSC->cColumn == 0), right = (pSC->cColumn == pSC->cmbWidth);
const Bool top = (pSC->cRow == 0), bottom = (pSC->cRow == pSC->cmbHeight);
const Bool topORbottom = (top || bottom), leftORright = (left || right);
const Bool topORleft = (top || left), bottomORright = (bottom || right);
Bool leftAdjacentColumn = (pSC->cColumn == 1), rightAdjacentColumn = (pSC->cColumn == pSC->cmbWidth - 1);
// Bool topAdjacentRow = (pSC->cRow == 1), bottomAdjacentRow = (pSC->cRow == pSC->cmbHeight - 1);
const size_t mbWidth = pSC->cmbWidth;
PixelI * p = NULL;// * pt = NULL;
size_t i;
const size_t iChannels = (cfColorFormat == YUV_420 || cfColorFormat == YUV_422) ? 1 : pSC->m_param.cNumChannels;
const size_t tScale = pSC->m_Dparam->cThumbnailScale;
Int j = 0;
Int qp[MAX_CHANNELS], dcqp[MAX_CHANNELS], iStrength = (1 << pSC->WMII.cPostProcStrength);
// ERR_CODE result = ICERR_OK;
#define mbX pSC->mbX
#define mbY pSC->mbY
#define tileX pSC->tileX
#define tileY pSC->tileY
#define bVertTileBoundary pSC->bVertTileBoundary
#define bHoriTileBoundary pSC->bHoriTileBoundary
#define bOneMBLeftVertTB pSC->bOneMBLeftVertTB
#define bOneMBRightVertTB pSC->bOneMBRightVertTB
#define iPredBefore pSC->iPredBefore
#define iPredAfter pSC->iPredAfter
if (pSC->WMISCP.bUseHardTileBoundaries) {
//Add tile location information
if (pSC->cColumn == 0) {
bVertTileBoundary = FALSE;
tileY = 0;
}
bOneMBLeftVertTB = bOneMBRightVertTB = FALSE;
if(tileY > 0 && tileY <= pSC->WMISCP.cNumOfSliceMinus1H && (pSC->cColumn - 1) == pSC->WMISCP.uiTileY[tileY])
bOneMBRightVertTB = TRUE;
if(tileY < pSC->WMISCP.cNumOfSliceMinus1H && pSC->cColumn == pSC->WMISCP.uiTileY[tileY + 1]) {
bVertTileBoundary = TRUE;
tileY++;
}
else
bVertTileBoundary = FALSE;
if(tileY < pSC->WMISCP.cNumOfSliceMinus1H && (pSC->cColumn + 1) == pSC->WMISCP.uiTileY[tileY + 1])
bOneMBLeftVertTB = TRUE;
if (pSC->cRow == 0) {
bHoriTileBoundary = FALSE;
tileX = 0;
}
else if(mbY != pSC->cRow && tileX < pSC->WMISCP.cNumOfSliceMinus1V && pSC->cRow == pSC->WMISCP.uiTileX[tileX + 1]) {
bHoriTileBoundary = TRUE;
tileX++;
}
else if(mbY != pSC->cRow)
bHoriTileBoundary = FALSE;
}
( run in 0.389 second using v1.01-cache-2.11-cpan-0068ddc7af1 )