Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/LibJXR/jxrgluelib/JXRGlueJxr.c view on Meta::CPAN
if (pID->WMP.wmiI.cThumbnailWidth > 0)
{
while(cThumbnailScale * pID->WMP.wmiI.cThumbnailWidth < pID->uWidth)
cThumbnailScale <<= 1;
}
// note the following implementation can't handle fractional linesperMBRow limiting
// us to >= 1/256 thumbnail which is unfortunate, but all the PS plugin needs is 1/256
// and I didn't care to get into floating point or a bunch of conditional tests or
// other rewrite for a case not needed nor tested by PS plugin. sorry.
linesperMBRow = 16 / cThumbnailScale;
#ifdef REENTRANT_MODE
if (0 == pID->WMP.DecoderCurrMBRow)
{
#endif // REENTRANT_MODE
// Set the fPaddedUserBuffer if the following conditions are met
if (0 == ((size_t)pb % 128) && // Frame buffer is aligned to 128-byte boundary
0 == (pRect->Height % 16) && // Horizontal resolution is multiple of 16
0 == (pRect->Width % 16) && // Vertical resolution is multiple of 16
0 == (cbStride % 128)) // Stride is a multiple of 128 bytes
{
pID->WMP.wmiI.fPaddedUserBuffer = TRUE;
// Note that there are additional conditions in strdec_x86.c's strDecOpt
// which could prevent optimization from being engaged
}
#ifdef REENTRANT_MODE
}
#endif // REENTRANT_MODE
//if(pID->WMP.wmiSCP.uAlphaMode != 1)
if((!pID->WMP.bHasAlpha) || (pID->WMP.wmiSCP.uAlphaMode != 1))
{
if(pID->WMP.bHasAlpha)//planar alpha
{
tempAlphaMode = pID->WMP.wmiSCP.uAlphaMode;
pID->WMP.wmiSCP.uAlphaMode = 0;
}
pID->WMP.wmiSCP.fMeasurePerf = TRUE;
#ifdef REENTRANT_MODE
if (0 == pID->WMP.DecoderCurrMBRow)
{
Call(pID->WMP.wmiSCP.pWStream->GetPos(pID->WMP.wmiSCP.pWStream, &(pID->WMP.cMarker)));
FailIf(ICERR_OK != ImageStrDecInit(&pID->WMP.wmiI, &pID->WMP.wmiSCP, &pID->WMP.ctxSC), WMP_errFail);
}
// Re-entrant mode incurs 1 MBR delay, so to get 0th MBR, we have to ask for 1st MBR
cMBRow = ((U32) pID->WMP.cLinesCropped + pRect->Y + pRect->Height +
(pRect->Y + pRect->Height >= (I32) pID->WMP.wmiI.cROIHeight ? linesperMBRow - 1 : 0)) / // round up if last MBR
linesperMBRow + 1;
cMBRowStart = ((U32) pID->WMP.cLinesCropped + pRect->Y) / linesperMBRow + 1;
// if current request starts before current state, then rewind.
if (cMBRowStart < pID->WMP.DecoderCurrMBRow)
{
pID->WMP.DecoderCurrMBRow = 0;
pID->WMP.cLinesDecoded = 0;
pID->WMP.cLinesCropped = 0;
pID->WMP.fFirstNonZeroDecode = FALSE;
FailIf(ICERR_OK != ImageStrDecTerm(pID->WMP.ctxSC), WMP_errFail);
Call(pID->WMP.wmiSCP.pWStream->SetPos(pID->WMP.wmiSCP.pWStream, pID->WMP.cMarker));
FailIf(ICERR_OK != ImageStrDecInit(&pID->WMP.wmiI, &pID->WMP.wmiSCP, &pID->WMP.ctxSC), WMP_errFail);
}
// In "Low Memory mode", we don't have full frame buffer. We therefore cannot rotate the image.
// We can flip H, V and HV, but no rotations.
FailIf(pID->WMP.wmiI.oOrientation >= O_RCW, WMP_errFail);
// In low-memory mode, the full frame buffer is unavailable. This doesn't seem to
// matter in O_NONE and O_FLIPH, but for O_FLIPV and O_FLIPVH, outputMBRow tries to write to
// the bottom of full-frame buffer. Adjust the buffer pointer to compensate.
if (O_FLIPV == pID->WMP.wmiI.oOrientation || O_FLIPVH == pID->WMP.wmiI.oOrientation)
{
I32 iActualY2 = pRect->Y + pRect->Height;
pbLowMemAdj = pb - (pID->WMP.wmiI.cROIHeight - (iActualY2 - pID->WMP.cLinesCropped)) * cbStride;
}
else
{
pbLowMemAdj = pb - pRect->Y * cbStride;
}
wmiBI.pv = pbLowMemAdj;
for (i = (U32)pID->WMP.DecoderCurrMBRow; i < cMBRow; i++)
{
size_t cLinesDecoded;
wmiBI.uiFirstMBRow = i;
wmiBI.uiLastMBRow = i;
FailIf(ICERR_OK != ImageStrDecDecode(pID->WMP.ctxSC, &wmiBI, &cLinesDecoded), WMP_errFail);
pID->WMP.cLinesDecoded = cLinesDecoded;
if (FALSE == pID->WMP.fFirstNonZeroDecode && cLinesDecoded > 0)
{
pID->WMP.cLinesCropped += (linesperMBRow - cLinesDecoded);
pID->WMP.fFirstNonZeroDecode = TRUE;
// update cMBRow if partial MB row cropped
cMBRow = ((U32) pID->WMP.cLinesCropped + pRect->Y + pRect->Height +
(pRect->Y + pRect->Height >= (I32) pID->WMP.wmiI.cROIHeight ? linesperMBRow - 1 : 0)) / // round up if last MBR
linesperMBRow + 1;
}
if (0 == cLinesDecoded && i > 0)
{
pID->WMP.cLinesCropped += linesperMBRow;
// update cMBRow if whole MB row cropped
cMBRow++;
}
}
wmiBI.pv = pbLowMemAdj;
// If we're past the top of the image, then we're done, so terminate.
if (linesperMBRow * (cMBRow - 1) >= (U32) pID->WMP.cLinesCropped + pID->WMP.wmiI.cROIHeight) {
FailIf(ICERR_OK != ImageStrDecTerm(pID->WMP.ctxSC), WMP_errFail);
}
pID->WMP.DecoderCurrMBRow = cMBRow; // Set to next possible MBRow that is decodable
#else
FailIf(ICERR_OK != ImageStrDecInit(&pID->WMP.wmiI, &pID->WMP.wmiSCP, &pID->WMP.ctxSC), WMP_errFail);
FailIf(ICERR_OK != ImageStrDecDecode(pID->WMP.ctxSC, &wmiBI), WMP_errFail);
FailIf(ICERR_OK != ImageStrDecTerm(pID->WMP.ctxSC), WMP_errFail);
#endif //REENTRANT_MODE
if(pID->WMP.bHasAlpha)//planar alpha
{
pID->WMP.wmiSCP.uAlphaMode = tempAlphaMode;
}
}
// if(pID->WMP.bHasAlpha && pID->WMP.wmiSCP.uAlphaMode == 2)
// if(pID->WMP.bHasAlpha && pID->WMP.wmiSCP.uAlphaMode != 1)
if(pID->WMP.bHasAlpha && pID->WMP.wmiSCP.uAlphaMode != 0)
{
pID->WMP.wmiI_Alpha = pID->WMP.wmiI;
( run in 0.501 second using v1.01-cache-2.11-cpan-df04353d9ac )