SPRUI30H November 2015 – May 2024 DRA745 , DRA746 , DRA750 , DRA756
The following C-code shows how configuration parameters are calculated:
// =======================================
// Required Input Parameter
// =======================================
// srcW, srcH, tarW, tarH, srcWi, tarWi
// input/output scan modes
// Note: srcH and tarH refer to number of lines in the frame even for interlace in/out
// scaling. Based on scaling scan mode input/output scan mode option,
// heights are adjusted during internal calculations see mod_srcH and mod_tarH.
pixel_scale_factor=4; // 10 bit pixel
hor_pixel_offset =0.0
// ============================================================================================
// Peaking Filter Configuration
// ============================================================================================
// ----------------------------------------------------------------
// HPF Coef
// ----------------------------------------------------------------
y_peak_enable = 0;
peak_select=0; // 0=peak at fs/4 1=NTSC 2=PAL
switch(peak_select) {
case 0: {// peak at fs/4 and gain = 1
HPF_coef0 = 0;
HPF_coef1 = 0;
HPF_coef2 = 0;
HPF_coef3 = -4;
HPF_coef4 = 0;
HPF_coef5 = 8; // mid tap
HPF_norm_shift = 4;
break;
}
case 1: {// NTSC: peak at 0.133*fs and gain=1
HPF_coef0 = -2;
HPF_coef1 = -8;
HPF_coef2 = -8;
HPF_coef3 = -2;
HPF_coef4 = 12;
HPF_coef5 = 16; // mid tap
HPF_norm_shift = 6;
break;
}
case 2: {// PAL: peak at 0.163*fs and gain=1
HPF_coef0 = 2;
HPF_coef1 = -4;
HPF_coef2 = -11;
HPF_coef3 = -7;
HPF_coef4 = 9;
HPF_coef5 = 22; // mid tap
HPF_norm_shift = 6;
break;
}
}
// ----------------------------------------------------------------
// NonLinear Coring Function typical values
// ----------------------------------------------------------------
NL_coring_thr = 16;
NL_limit = 200;
NL_lo_slope = 16;
NL_hi_thr = 400;
NL_hi_slope_shift = 4;
// ============================================================================================
// Edge Detection Configuration
// ============================================================================================
// edge detection
confidence_default = 0; // 0 =use 5 tap polyphase filter for SC with ev_enable =0
min_Gy_thr = 64; // 64
min_Gy_thr_range = 3; // 3 power of 2
gradient_thr = 200; // 200
gradient_thr_range = 6; // 6 power of 2
ev_thr = int(4.0*3.111+0.5); // edge vector soft switch threshold (3.2)
// ============================================================================================
// vertical scaler configuration
// ============================================================================================
// ----------------------------------------------------------------
// vertical scaler typical parameters
// ----------------------------------------------------------------
invert_field_ID = 0; // invert field ID input
delta_ev_thr = 1; // edge vector soft switch range
ver_pixel_offset = 0.0;
uv_intp_thr = pixel_scale_factor*16;
delta_y_thr = 4; // luma soft switch range
delta_uv_thr = 4; // chroma soft switch range
//
//
// ----------------------------------------------------------------
// Vertical Scaler Mode Determination
// ----------------------------------------------------------------
//
// interlace
// in out mode mod_srcH mod_tarH scale
// ----- ------ ---- -------- -------- -----------------
// 0 0 p->p srcH tarH tarH/srcH
// 0 1 p->i srcH tarH>>1 tarH/srcH
// 1 0 i->p srcH>>1 tarH tarH/(srcH/2)
// 1 1 i->i srcH>>1 tarH>>1 (tarH/2)/(srcH/2)
if (interlace_in) mod_srcH=srcH>>1; // interlace
else mod_srcH=srcH; // progressive
if (interlace_out) mod_tarH=tarH>>1; // interlace
else mod_tarH=tarH; // progressive
// determine vertical scaler
if ((interlace_in==0)&&(interlace_out==1)) {
if (tarH>((1+srcH)>>1)) use_rav = 0; // 1=use RAV scaler 0=use polyphase scaler
else use_rav = 1;
} else {
if (mod_tarH>((1+mod_srcH)>>1)) use_rav = 0; // 1=use RAV scaler 0=use polyphase scaler
else use_rav = 1;
}
// ----------------------------------------------------------------
// RAV or Polyphase parameters
// ----------------------------------------------------------------
if (use_rav) { // downscale
// ------------
// --- RAV ----
// ------------
if (use_internal_defaults) enable_edge_detection = 0;
if ((interlace_in==0)&&(interlace_out==1)) scale = double(tarH)/double(srcH);
else scale = double(mod_tarH)/double(mod_srcH);
sc_factor_rav = int(1024.0*scale+0.5);
// Peter's method
delta = (1.0/scale-1.0)/2.0;
int_part = floor(delta);
frac_part = delta-int_part;
row_acc_init_rav = int(1024*(scale+(1.0-scale)/2.0)+0.5); // top field
row_acc_init_b_rav = int(1024*(scale+(1.0-2.0*frac_part)*(1.0-(1.0+2.0*int_part)*scale)/2.0)+0.5); // bottom field
row_acc_inc = 0; // polyphase scaler
row_acc_offset = 0; // polyphase scaler
row_acc_offset_b = 0; // polyphase scaler
} else { // upscale using polyphase scaler
// ------------
// --- PPF ----
// ------------
if (use_internal_defaults) enable_edge_detection = 1;
sc_factor_rav = 0;
delta_rav = 0;
row_acc_init_rav = 0;
row_acc_init_b_rav = 0;
// upscaler
// interlace row acc init value
// in out mode row acc inc top bottom
// ---- ---- ---- --------------------- --- -----------------------
// 0 0 p->p (srcH-1)/(tarH-1) 0 0
// 0 1 p->i 2*(srcH-1)/(tarH-1) 0 (srcH-1)/(tarH-1)
// 1 0 i->p 1/2*(srcH-1)/(tarH-1) 0 -0.5
// 1 1 i->i (srcH-1)/(tarH-1) 0 [(srcH-1)/(tarH-1)-1]/2
row_acc_offset = int(65536.0*ver_pixel_offset +0.5); // progressive or top field
if (interlace_in) {
if (interlace_out) {
row_acc_inc = int(65536.0*double(srcH-1)/double(tarH-1)+0.5);
row_acc_offset_b = (int(65536.0/2.0*(double(srcH-1)/(double(tarH-1))-
1.0)+0.5))+row_acc_offset;
} else { // progressive out
row_acc_inc = int(65536.0*double(srcH-1)/(2.0*double(tarH-1))+0.5);
if ((-0.5+row_acc_offset)<0.0) round_factor=-0.5;
else round_factor= 0.5;
row_acc_offset_b = int(65536.0*(-0.5)+round_factor)+row_acc_offset;
}
} else { // progressive in
if (interlace_out) {
row_acc_inc = int(65536.0*2.0*double(srcH-1)/double(tarH-1)+0.5);
row_acc_offset_b = int(65536.0*double(srcH-1)/double(tarH-1)+0.5)+row_acc_offset;
} else { // progressive out
row_acc_inc = int(65536.0*double(srcH-1)/double(tarH-1)+0.5);
row_acc_offset_b = row_acc_offset;
}
}
}
// ============================================================================================
// Horizontal Scaler configuration
// ============================================================================================
// ----------------------------------------------------------------
// horizontal scaler mode determination
// ----------------------------------------------------------------
auto_hs = 1;
dcm_2x = 0;
dcm_4x = 0;
hp_bypass = 0;
if (srcWi==srcW) linear = 1;
else linear = 0;
// hor scaler parameters
if (tarW>srcW) { // upscale
mod_srcW = srcW;
mod_srcWi = srcWi;
} else if (tarW<=(srcW>>2)) { // downscale by <=1/4
mod_srcW = srcW>>2;
mod_srcWi = srcWi>>2;
} else if (tarW<=(srcW>>1)) { // downscale by <=1/2
mod_srcW = srcW>>1;
mod_srcWi = srcWi>>1;
} else { // downscale by <=1
mod_srcW = srcW;
mod_srcWi = srcWi;
}
// Not used any more:
// hs_factor = int(16.0*double(tarWi)/double(mod_srcWi)+0.5); // hor scale factor (6.4)
// ----------------------------------------------------------------
// Horizontal PolyPhase Settings --
// ----------------------------------------------------------------
lin_acc_inc = int(16777216.0*double(mod_srcWi-1)/double(tarWi-1)+0.5);
col_acc_offset = int(16777216.0*hor_pixel_offset +0.5);
nlin_left = (tarW-tarWi)>>1;
nlin_right = nlin_left+tarWi-1;
if (linear) {
nlin_acc_inc = 0;
nlin_acc_init = 0;
} else {
// ----------------------------------
// Non-linear scaling configuration
// ----------------------------------
nlin_left_src = (mod_srcW-mod_srcWi)>>1;
if (tarWi>=srcWi) { // upscale
d = 0.0;
round_factor = 0.5;
} else { // downscale
d = (double(tarW)-1.0)/2.0;
round_factor = -0.5;
}
K = 16777216.0*double(nlin_left_src)/(double(nlin_left)*double(nlin_left-2.0*d));
nlin_acc_inc = int(2.0*K+round_factor);
nlin_acc_init = int(K*(1.0-2.0*d)+0.5);
}
nlin_left_tar = nlin_left;
nlin_right_tar = nlin_right;
// ==========================================================================================
// Bypass Determination
// ==========================================================================================
// bypass
if ((srcW==tarW)&&(srcWi==tarWi)&&(mod_srcH==mod_tarH)) sc_bypass = 1;
else sc_bypass = 0;
//
}