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.

Dynamically change output resolution of swMs



Hello,

We'd like to change output resolution of swMs dynamically, but it seems not to work.
When setting new resolution (layout) to swMs, displayWindow is configured in Demo_swMsGenerateLayout(). However, it doesn't seem to be applied to the output of swMs according to the encoded data. The resolution is not changed and keeps its value as that when chain created.

Below is the usecase:
captureLink -> swMs -> NSF -> IPC VPSS -> IPC Video -> Encode ...

We suppose below function can configure swMs output resolution, but seems not...
Demo_swMsGenerateLayout()
{
...
// configure swMs resolution
vdMosaicParam->displayWindow.height = outHeight;
vdMosaicParam->displayWindow.width = outWidth;
vdMosaicParam->displayWindow.start_X = 0;
vdMosaicParam->displayWindow.start_Y = 0;
...
}

Vdis_setMosaicParams(); // set to swMs link

  • The SwMsLink is not exporting SystemFrameInfo.rtChannelInfo . hence when you dynamically modify SwMs output resolution encLink is unaware of resolution change ar rtChannelInfo is not populated. You will have to modify swmsLink to export this info based on current active layoutPrms.

  • Hello, Badri

    Per our understanding, rtChannelInfo is the layout data for each input channel. The output resolution is not contained in rtChannelInfo data structure. Could you help confirm which data structure in swMs carries the output resolution and can be delivered to next link dynamically?

    In addition, do we need to enable any update flag for notification of next link? 

    According to sclrLink, sclrRtOutFrmPrm seems the data structure to carry resolution and chRtOutInfoUpdate seems the flag to notify change... 

    Thank you very much for help~~~

    Int32 SclrLink_drvSetChDynamicOutputRes(SclrLink_Obj * pObj, SclrLink_chDynamicSetOutRes * params)

    {
    Int32 status = FVID2_SOK;
    SclrLink_ChObj *pChObj;
    UInt32 chId;

    if (params->chId < SCLR_LINK_MAX_CH)
    {
    chId = params->chId;
    pChObj = &pObj->chObj[chId];

    pChObj->chRtOutInfoUpdate = TRUE;

    pChObj->sclrRtOutFrmPrm.width = params->width;
    pChObj->sclrRtOutFrmPrm.height = params->height;
    pChObj->sclrRtOutFrmPrm.pitch[0] = params->pitch[0];
    pChObj->sclrRtOutFrmPrm.pitch[1] = params->pitch[1];
    }
    return (status);
    }

  • 1. Each link exchanges video frame with the next link via FVID2_Frame structure.

    2. FVID2_Frame has a appData pointer which points to a SystemFrameInfo structure.

    3. SystemFrameInfo structure has the following members:

        -- rtChInfoUpdate;
        -- rtChInfo;

    4. When encoder receives a FVID2_Frame it

          -- checks is rtChInfoUpdate flag is set to TRUE 

          --  if TRUE

                     it checks the width , height info in rtChInfo

                     -- if new width and height of the FVID2_Frame is different from the current configured resolution of the encoder channel it detects a resolution change and updates the encoder configuration for new resolution.

     

    The problem you are seeing is because when SwMs link outputs a FVID2_Frame it does not set the rtChInfo width and height in the System_FrameInfo

  • Modification to SwMs to export the rtChannelInfo requires the following changes:

    1. When switch layout occurs SwMs should determine the output width and output height from the layout params

    2. The output width and height should be stored and populated in rtChannelInfo.width , rtChannelInfo.height, rtChannelInfo.pitch and rtChInfoUpdate should be set to TRUE.

  • Hello, Badri

    Thank you very much for your reply. It looks workable for high to low resolution change, but we still faced several problems. 

    When connect swMs to display link after rtChInfo changed (from 1080p to 720p), we got messages as below:

    ...

    [m3vpss ] DISPLAY:Runtime Size change:[1280x720->1920x1080] for Inst 1
    [m3vpss ] DISPLAY:Runtime Size change:[1920x1080->1280x720] for Inst 0
    [m3vpss ] DISPLAY:Runtime Size change:[1920x1080->1280x720] for Inst 1
    [m3vpss ] DISPLAY:Runtime Size change:[1280x720->1920x1080] for Inst 0
    [m3vpss ] DISPLAY:Runtime Size change:[1280x720->1920x1080] for Inst 1
    [m3vpss ] DISPLAY:Runtime Size change:[1920x1080->1280x720] for Inst 1
    [m3vpss ] DISPLAY:Runtime Size change:[1920x1080->1280x720] for Inst 0
    ...

    The output resolution seems to be changed continually. If we connected swMs to encode link, the resolution of encoded stream kept changing as display. It seem that our programming is not correct...

    1. How to define the value of pitch[] for 720p and other resolution? 

    ((System_FrameInfo *)pOutFrame->appData)->rtChInfo.pitch[0]

    2. Where to put our code for resolution change?

    Currently, we put the code between 

    SwMsLink_DrvProcessFrames() and SwMsLink_drvUnlock() in SwMsLink_drvDoScaling(). Is that correct?

    Below is our current programming:

    Int32 SwMsLink_drvDoScaling(SwMsLink_Obj * pObj)

    {

    ...

    SwMsLink_drvLock(pObj);

    SwMsLink_drvMakeFrameLists(pObj, pOutFrame);

    SwMsLink_DrvProcessFrames(pObj);

    // our code here

    if( pObj->rtOutInfoUpdate == TRUE ) // rtOutInfoUpdate is new defined variable in SwMsLink_Obj

    {
    ((System_FrameInfo *)pOutFrame->appData)->rtChInfo.width = pObj->layoutParams.outputWidth ;
    ((System_FrameInfo *)pOutFrame->appData)->rtChInfo.height = pObj->layoutParams.outputHeight ;
    ((System_FrameInfo *)pOutFrame->appData)->rtChInfo.pitch[0] = 3840 ; // we don't know how to set pitch[] for resolution which is not 1080p
    ((System_FrameInfo *)pOutFrame->appData)->rtChInfo.pitch[1] = 0 ;
    ((System_FrameInfo *)pOutFrame->appData)->rtChInfo.pitch[2] = 0 ;

    pOutFrameInfo->rtChInfoUpdate = TRUE ; // enable rtChInfoUpdate

    pObj->rtOutInfoUpdate = FALSE ;
    }

    SwMsLink_drvUnlock(pObj);

    ...

    }

    3. Is it necessary to update pObj->outFrameFormat.width and pObj->outFrameFormat.height?

    When to update these two variables? In SwMsLink_drvSwitchLayout() or SwMsLink_drvDoScaling()?

  • SwMsLink_LayoutPrm doesn't have outputWidth and outputHeight. Did you add it. Check if the outputWidth/Height setting is correct if you have added it.

    Can you remove if( pObj->rtOutInfoUpdate == TRUE ) and always update rtChInfo ?

    For pitch use

    pObj->info.queInfo[0].chInfo[0].pitch[0]/

    pObj->info.queInfo[0].chInfo[0].pitch[1]/

    pObj->info.queInfo[0].chInfo[0].pitch[2]

    The place you have put the rtChInfo update is correct.

    CJ said:
    3. Is it necessary to update pObj->outFrameFormat.width and pObj->outFrameFormat.height?

    - No don't change these parameters.