📄 _csl_reszcalcslicing.c
字号:
/** @file _csl_reszCalcSlicing.c
*
* @brief File for functional layer of CSL API @a CSL_reszCalcSlicing()
*
* Description
* - The @a CSL_reszCalcSlicing() function definition & it's associated
* functions
*
* @date 26th Aug, 2005
* @author Jesse Villarreal
*/
#include <csl_resz_aux.h>
#pragma CODE_SECTION (CSL_reszCalcSlicing, ".text:csl_section:resz");
/** @brief Calculates the appropriate Resize value or Input Size
* This function calculates and returns an array of structures located in
* the HwSetup struct that can be used by the CSL_reszSetSlice() function
* to adjust the Resizer's parameters for resizing each slice of a wide image.
*/
CSL_Status CSL_reszCalcSlicing(
/** Pointer to the object that holds reference to the
* instance of RESZ requested after the call
*/
CSL_ReszHandle hResz,
/** Pointer to structure holding the data
*/
CSL_ReszHwSetup *data
){
short i, maxWidth, phase_divider, phase_shift, numPhases, pixPerBurst, bytesPerPix;
if(data == NULL) return (CSL_ESYS_INVPARAMS);
// Set appropriate variables based on resize ratio (7-tap or 4-tap implementations)
if(data->ratios.hrzValue > 512)
{
maxWidth = 640;
phase_divider = 32;
phase_shift = 6;
numPhases = 4;
}
else
{
maxWidth = 1280;
phase_divider = 16;
phase_shift = 5;
numPhases = 8;
}
// Set appropriate variables based on input type ( YUV 4:2:2 or YUV 4:4:4 input)
if(data->inputType == CSL_RESZ_TYPE_SEPARATE)
{
pixPerBurst = 32;
bytesPerPix = 1;
}
else
{
pixPerBurst = 16;
bytesPerPix = 2;
}
// Calculate the output sizes for each of the slices
{
int remainingOutWidth = data->outputSize.width;
for(i=0;i<data->numSlices;i++)
{
data->sliceInfo[i].outWidth = (remainingOutWidth > maxWidth) ? maxWidth : remainingOutWidth;
remainingOutWidth -= data->sliceInfo[i].outWidth;
}
}
// Checks to see if the input width minimum requirement is met (worst case 4x resize)
// If not, then adjust the sizes for the last 2 slices.
if(data->sliceInfo[data->numSlices-1].outWidth < 120)
{
data->sliceInfo[data->numSlices-2].outWidth /= 2;
data->sliceInfo[data->numSlices-1].outWidth += data->sliceInfo[data->numSlices-2].outWidth;
}
// Calculate the remaining slice information based on the resizer module algorithm
{
int outPix = 0;
long fip_start=256*data->startPos.hStart + 2*phase_divider*data->startPhase.hPhase - 256;
long fip = fip_start;
int cip, pip;
for(i=0;i<data->numSlices;i++)
{
cip = (fip + phase_divider) >> phase_shift;
pip = (cip + numPhases) / numPhases;
data->sliceInfo[i].stPhase = cip % numPhases;
data->sliceInfo[i].inWidth = ((2*phase_divider*data->sliceInfo[i].stPhase +
(data->sliceInfo[i].outWidth-1) * data->ratios.hrzValue +
phase_divider) >> 8) + 7;
data->sliceInfo[i].inAddr = (Uint32 *)((Uint32)data->inputAddr + pip/pixPerBurst*32);
data->sliceInfo[i].stPix = pip%pixPerBurst;
data->sliceInfo[i].outAddr = (Uint32 *)((Uint32)data->outputAddr + outPix * bytesPerPix);
fip += data->sliceInfo[i].outWidth * data->ratios.hrzValue;
outPix += data->sliceInfo[i].outWidth;
}
}
return (CSL_SOK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -