📄 jpeg_mcubuffer.c
字号:
" R7 = R2;\n"
" R6 = R1;\n"
" R0 = R2;\n"
" SP += -12;\n"
" CALL.X _JPEG_Mcu_div;\n"
" SP += 12;\n"
" R0 *= R6;\n"
" R0 = R7 - R0;\n"
" (R7:6) = [SP++];\n"
"JMBW5: P0 = R0;\n"
" R1 = R6 - R0;\n"
" P1 = R1;\n"
" CC = R6 <= R0;\n"
" R7 = R0;\n"
" P0 = P4 + (P0<<2);\n"
" R0 = R0 -|- R0 || R2 = [P0++];\n"
" IF CC JUMP JMBW15;\n"
" R1 = 1;\n"
" LSETUP (JMBW11, JMBW12) LC0 = P1;\n"
"JMBW11: CC = R2 == R1;\n"
" IF CC JUMP JMBW13;\n"
"JMBW12: R7 = R7 + R1 (NS) || R2 = [P0++];\n"
" JUMP JMBW15;\n"
"JMBW13: R0 = P5;\n"
" CALL.X _sStoreLosslessMcuBuffer;\n"
"JMBW14: P0 = R7;\n"
" R1 = 0; NOP;\n"
" [P5 + 44] = R7;\n"
" R0 = 1;\n"
" P0 = P4 + (P0<<2);\n"
" [P0] = R1;\n"
"JMBW15: SP += 12;\n"
" (R7:6) = [SP++];\n"
" (P5:4) = [SP++];\n"
" UNLINK;\n"
"JMBWRTS: RTS;\n"
".global _JPEG_McuBuffer_WRITE;\n");
#else
int32 JPEG_McuBuffer_WRITE(tMcuBuffer *lDer)
{
int32 lCount1, lCount2;
if(lDer->mcuLossy)
{
lCount2 = lDer->processBufferIndex + 1;
//lCount2 %= (lDer->numberOfBuffers);
if (lCount2 >= lDer->numberOfBuffers)
lCount2 = 0;
for(lCount1 = lCount2; lCount1 < lDer->numberOfBuffers; lCount1++)
{
if(lDer->mcuFree[lCount1] == BUSY)
{
goto WRITEBACK;
}
}
return E_FALSE; // no processed buffer available
WRITEBACK:
switch(lDer->interLeaveFormat)
{
case YUV420:
{
sStore420McuBuffer(lDer);
break;
}
case YUV422:
{
sStore422McuBuffer(lDer);
break;
}
case YUV444:
case RGB:
{
sStore444McuBuffer(lDer);
break;
}
case MONOCHROME:
{
sStoreMonoMcuBuffer(lDer);
break;
}
}
lDer->processBufferIndex = lCount1;
lDer->mcuFree[lCount1] = FREE;
return E_TRUE; // success
}
else
{
lCount2 = lDer->processBufferIndex + 1;
lCount2 %= (lDer->numberOfBuffers);
for(lCount1 = lCount2; lCount1 < lDer->numberOfBuffers; lCount1++)
{
if(lDer->mcuFree[lCount1] == BUSY)
{
goto WRITEBACK_LL;
}
}
return E_FALSE; // no processed buffer available
WRITEBACK_LL:
sStoreLosslessMcuBuffer(lDer);
lDer->processBufferIndex = lCount1;
lDer->mcuFree[lCount1] = FREE;
return E_TRUE; // success
}
}
#endif
/*
********************************************************************************
** Function: JPEG_McuBuffer_Progressive_NEXT
**
** Description: Setting the values for next component. (Encoder only)
**
** Arguments:
** mcuHandle[IN] Handle to the Mcu Buffer data access instance.
**
** Outputs:
**
** Return value: E_TRUE or E_FALSE
********************************************************************************
*/
#ifndef JPEGBUFFERVALIDATED
static void JPEG_McuBuffer_Progressive_NEXT(tMcuBuffer *mcuHandle)
{
mcuHandle->x = 0;
mcuHandle->y = 0;
mcuHandle->mcuBufferIndex = 0;
mcuHandle->processBufferIndex = 0;
mcuHandle->numberOfEmptyBuffers = mcuHandle->numberOfBuffers;
if(mcuHandle->componentNumber == 0)
{
mcuHandle->lumCurrPos = mcuHandle->cbCurrPos;
switch(mcuHandle->interLeaveFormat)
{
case YUV420:
mcuHandle->frameWidth >>= 1;
mcuHandle->originalFramWidth = mcuHandle->progressiveFrameWidth_next;
mcuHandle->originalFramHeight = mcuHandle->progressiveFrameHeight_next;
break;
case YUV422:
mcuHandle->frameWidth >>= 1;
mcuHandle->originalFramWidth = mcuHandle->progressiveFrameWidth_next;
break;
case YUV444:
case MONOCHROME:
case RGB:
break;
}
}
else
{
mcuHandle->lumCurrPos = mcuHandle->crCurrPos;
}
mcuHandle->componentNumber++;
}
#endif
/*
********************************************************************************
** Function: JPEG_McuBuffer_Lossless_NEXT
**
** Description: Set the mcu structure element values for next component.
** (Encoder only)
**
** Arguments:
** mcuHandle[IN] Handle to the Mcu Buffer data access instance.
**
** Outputs:
**
** Return value: E_TRUE or E_FALSE
********************************************************************************
*/
//static
void JPEG_McuBuffer_Lossless_NEXT(tMcuBuffer *mcuHandle)
{
mcuHandle->x = 0;
mcuHandle->y = 0;
mcuHandle->mcuBufferIndex = 0;
mcuHandle->processBufferIndex = 0;
mcuHandle->numberOfEmptyBuffers = mcuHandle->numberOfBuffers;
if(mcuHandle->componentNumber == 0)
{
mcuHandle->lumCurrPos = mcuHandle->cbCurrPos;
switch(mcuHandle->interLeaveFormat)
{
case YUV420:
mcuHandle->frameHeight >>= 1;
mcuHandle->frameWidth >>= 1;
break;
case YUV422:
mcuHandle->frameWidth >>= 1;
break;
case YUV444:
case MONOCHROME:
case RGB:
break;
}
}
else
{
mcuHandle->lumCurrPos = mcuHandle->crCurrPos;
}
mcuHandle->componentNumber++;
}
#ifndef JPEGBUFFERVALIDATED
/*
********************************************************************************
** Function: sFormRowLossless
**
** Description: Copy one Row of Frame component data. (Encoder only)
**
** Arguments:
** mcuHandle[IN] Handle to the Mcu Buffer data access instance.
** mcuData [OUT] Pointer to macroblock data structures.
**
** Outputs:
**
** Return value: None
********************************************************************************
*/
static void sFormRowLossless(tMcuBuffer *mcuHandle, uint8 *mcuData)
{
int32 lCount1;
uint8 *lTempFrame;
uint8 *lBlock;
lBlock = (uint8 *) mcuData;
/* Luminance Block(s) */
lTempFrame = mcuHandle->lumCurrPos;
for(lCount1 = 0; lCount1 < mcuHandle->frameWidth; lCount1 ++)
{
lBlock[lCount1] = lTempFrame[lCount1];
}
return;
}
/*
********************************************************************************
** Function: sFormMCU420
**
** Description: Copy 6 blocks corresponding to the yuv420 data from the
** frame store. (Encoder only)
**
** Arguments:
** mcuHandle[IN] Handle to the Mcu Buffer data access instance.
** mcuData [OUT] Pointer to macroblock data structures.
**
** Outputs:
**
** Return value: None
********************************************************************************
*/
static void sFormMCU420(tMcuBuffer *mbdata, uint8 *mcudata)
{
int32 lCount1;
int32 lCount2;
tPixel *lTempFrame;
tPixel *lTempFrame1;
uint8 *block;
int32 lLumWidth = mbdata->frameWidth;
int32 lChroWidth = mbdata->frameWidth >> 1;
block = mcudata;
/* Luminance Block(s) */
/*Luminance Block 1*/
lTempFrame = mbdata->lumCurrPos;
lTempFrame1 = lTempFrame;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lLumWidth;
}
/*Luminance Block 2*/
// lTempFrame = lTempFrame1 + BLOCK_SIZE;
lTempFrame = lTempFrame1 + BLOCK_WIDTH;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lLumWidth;
}
/*Luminance Block 3*/
lTempFrame = lTempFrame1 + (BLOCK_WIDTH * (lLumWidth));
lTempFrame1 = lTempFrame;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lLumWidth;
}
/*Luminance Block 4*/
lTempFrame = lTempFrame1 + BLOCK_WIDTH;
// lTempFrame = lTempFrame1 + BLOCK_SIZE;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lLumWidth;
}
/* Chrominance Block(s) "Cb" */
lTempFrame = mbdata->cbCurrPos;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lChroWidth;
}
/* Chrominance Block(s) "Cr" */
lTempFrame = mbdata->crCurrPos;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lChroWidth;
}
return;
}
/*
********************************************************************************
** Function: sFormMCU422
**
** Description: Copy 4 blocks corresponding to the yuv422 data from the
** frame store. (Encoder only)
**
** Arguments:
** mcuHandle[IN] Handle to the Mcu Buffer data access instance.
** mcuData [OUT] Pointer to macroblock data structures.
**
** Outputs:
**
** Return value: None
********************************************************************************
*/
static void sFormMCU422(tMcuBuffer *mbdata, uint8 *mcudata)
{
int32 lCount1;
int32 lCount2;
tPixel *lTempFrame;
tPixel *lTempFrame1;
uint8 *block;
int32 lLumWidth = mbdata->frameWidth;
int32 lChroWidth = mbdata->frameWidth >> 1;
block = mcudata;
/* Luminance Block(s) */
/*Luminance Block 1*/
lTempFrame1 = mbdata->lumCurrPos;
lTempFrame = lTempFrame1;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lLumWidth;
}
/*Luminance Block 2*/
// lTempFrame = lTempFrame1 + BLOCK_SIZE;
lTempFrame = lTempFrame1 + BLOCK_WIDTH;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lLumWidth;
}
/* Chrominance Block(s) "Cb" */
lTempFrame = mbdata->cbCurrPos;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lChroWidth;
}
/* Chrominance Block(s) "Cr" */
lTempFrame = mbdata->crCurrPos;
for(lCount1 = 0; lCount1 < BLOCK_WIDTH; lCount1 ++)
{
for(lCount2 = 0; lCount2 < BLOCK_WIDTH; lCount2 ++)
{
block[lCount2] = lTempFrame[lCount2];
}
block += BLOCK_WIDTH;
lTempFrame += lChroWidth;
}
return;
}
/*
********************************************************************************
** Function: sFormMCU444
**
** Description: Copy 3 blocks corresponding to the yuv444 data from the
** frame store. (Encoder only)
**
** Arguments:
** mcuHandle[IN] Handle to the Mcu Buffer data access instance.
** mcuData [OUT] Pointer to macroblock data structures.
**
** Outputs:
**
** Return value: None
********************************************************************************
*/
static void sFormMCU444(tMcuBuffer *mbdata, uint8 *mcudata)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -