This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM8168+DVRRDK4.0.0.3 SCALAR failed!!!



execuse me,everyone!I have a question when i use DM8168 scalar.The question is described as follows:
1、My environment is DM8168 and dvrrdk4.0.0.3
2、My links are connected as follows:
                             |-->DEI-->|
                             |                 |
                             |-->DEI-->|
CAP-->select-->|                 |-->merge-->ipcoutVpss-->ipcInVideo-->ENC-->ipcBitsOutRtos-->ipcBitsInHost-->ES 
                             |-->DEI-->|
                             |                |
                             |-->DEI-->|
after we reveive the ES stream ,we packet it as TS stream.
3、In DEI module,we have used the scalar function.The params of dei is setted as follows:

static void set_dei_prm(DeiLink_CreateParams *deiPrm, Int32 outQueId, Bool bypass, Bool byScEnable)
{
Int32 chId;
deiPrm[0].enableOut[DEI_LINK_OUT_QUE_DEI_SC] = FALSE;
deiPrm[0].enableOut[DEI_LINK_OUT_QUE_VIP_SC] = FALSE;
deiPrm[0].enableOut[DEI_LINK_OUT_QUE_VIP_SC_SECONDARY_OUT] = FALSE;
deiPrm[0].enableOut[DEI_LINK_OUT_QUE_DEI_SC_SECONDARY_OUT] = FALSE;
deiPrm[0].enableOut[DEI_LINK_OUT_QUE_DEI_SC_TERTIARY_OUT] = FALSE;

deiPrm[0].enableOut[DEI_LINK_OUT_QUE_VIP_SC] = TRUE;
deiPrm[0].tilerEnable[DEI_LINK_OUT_QUE_VIP_SC] = FALSE;

deiPrm[0].comprEnable = FALSE;
deiPrm[0].setVipScYuv422Format = FALSE;
deiPrm[0].enableDeiForceBypass = bypass;
deiPrm[0].enableLineSkipSc = FALSE;
deiPrm[0].enableForceInterlacedInput = FALSE;

deiPrm[0].inputDeiFrameRate = 50;
deiPrm[0].outputDeiFrameRate = 50;

if(bypass)
{
//progress drop by select
deiPrm[0].inputFrameRate [DEI_LINK_OUT_QUE_VIP_SC] = 25;
deiPrm[0].outputFrameRate[DEI_LINK_OUT_QUE_VIP_SC] = 25;
}
else
{
deiPrm[0].inputFrameRate [DEI_LINK_OUT_QUE_VIP_SC] = 50;
deiPrm[0].outputFrameRate[DEI_LINK_OUT_QUE_VIP_SC] = 25;
}


/* Set Output Scaling at DEI based on ratio */
deiPrm[0].outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][0].scaleMode = DEI_SCALE_MODE_RATIO;
deiPrm[0].outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][0].ratio.heightRatio.numerator = 1;
deiPrm[0].outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][0].ratio.heightRatio.denominator = 1;
deiPrm[0].outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][0].ratio.widthRatio.numerator = 1;
deiPrm[0].outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][0].ratio.widthRatio.denominator = 1;
deiPrm[0].outScaleEnable[DEI_LINK_OUT_QUE_VIP_SC] = byScEnable;
for (chId=1; chId < DEI_LINK_MAX_CH; chId++)
deiPrm[0].outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][chId] = deiPrm[0].outScaleFactor[DEI_LINK_OUT_QUE_VIP_SC][0];


//modify end
}

From this function,we can know we use the DEI_LINK_OUT_QUE_VIP_SC.

4、Then we dynamic set the dei scalar output resolution as this:

status = System_linkControl(
gVcapModuleContext.deiId[deiId],
DEI_LINK_CMD_GET_OUTPUTRESOLUTION,
&(params),
sizeof(params),
TRUE
);
params.width = SystemUtils_align(psCapChnDynaParam->chDynamicRes.width, 16);
params.height = SystemUtils_align(psCapChnDynaParam->chDynamicRes.height, 1);
status = System_linkControl(
gVcapModuleContext.deiId[deiId],
DEI_LINK_CMD_SET_OUTPUTRESOLUTION,
&(params),
sizeof(params),
TRUE
);


5、Then we open the lazy loading mode in function DeiLink_drvSetScCoeffs :
Vps_ScLazyLoadingParams lazyLoadingParams;

lazyLoadingParams.enableLazyLoading = TRUE;
lazyLoadingParams.enableFilterSelect = TRUE;
lazyLoadingParams.scalarId = VPS_M2M_DEI_SCALAR_ID_VIP_SC;
retVal = FVID2_control(pObj->fvidHandle,
IOCTL_VPS_SC_SET_LAZY_LOADING,
&lazyLoadingParams,
NULL);
UTILS_assert(FVID2_SOK == retVal);

now the question is :
when we has not open the lazy loading mode,the result of the scalar is very good .But the quality of the video is not very good.

When we open the lazy loading mode,the source video resolution 1920x1080I@60. When we set the dei scalar output resolution is 961x540,the scalar result is good,and the quality of the picture is better .

But when the dei scalar output resolution is smaller or equal than 1/2 of the source resolution such as 960x540/959x540/940x530 ,the scalar result is not good. We found the scalar cut half of the source video,and then shrink the video.
When the dei salar output resolution is smaller than 1/4 of the source resolution such as 479x269,we can found the scalar cut 1/4 of  the source video and then shrink the video.

And then we have test many operation,we found:

1, if the source video resolution is W*H,and then we set the output resolution as (W/2)*H first time,the scalar result is good,but when we set the output resolution as (W/2)*H  again,the scalar result is not good,the scalar cut half of the source video,and then shrink the video.

2,if we first set the output resolution as (W/2-X)*H,the scalar result is not good.Then we set the output resolution as (W/2)*H  ,the result is good.

I want to know why? We just want to shrink the whole video picture,but not the 1/2 or 1/4 of the video picture.
If you have good ideas ,please tell me! Thank you very much.

  • Pls apply patch in this post for selecting correct scaler coefficients in DEI:

    http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/717/7444.dvr_5F00_rdk_5F00_deiscalercoefficients.patch.txt

    Go thru this post for details:

    http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/717/p/328614/1149514.aspx#1149514

    Undo all code changes to use lazy loading. We have seen issues with lazy loading like you mentioned

  • thanks for your help!

    First, I think there are two points in your answer:

    1,when I use the DEI scalar,the quality of the picture is not good ,the reason is we have not set the coeffs corretly.

        If we can set the coeffs as your answer ,the DEI scalar will not affect the quality of the picture.

    2,If we can set the coeffs as your answer, the lazy mode will run correctly.

    whether I understand correctly?

    Then there is one question more.In your answer, there is 

    DeiLink_drvSelectScCoeffs function to select the coeffs for the scalar.But if there are 4 channels in the scalar,

    the coeffs will be same in the 4 channels, and the coeffs will affect the 4 channel video in the same way.

    In my application,I want the 4 channel which is in the same scalar has its own parameters, and the parameters  in the 4 channels can be the same or not same. Is there any way to solute the question!

    We are expecting donation from you! Thank you very much!

  • The patch I shared is to select correct scaler coefficients. If you apply the patch you should _not_ enable lazy loading.

    The quality should be good even without enabling lazy loading since the correct scaler coefficients are selected.

    The coefficients are per scaler IP and not per channel. It is not possible to use different set of coefficients for different channels.

  • Thanks for your help!   Your answer is very good!