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.

Sample Aspect Ratio

We use DM8168 and DVRRDK 03.00.00.00 / DVRRDK 04.00 based software. We try to change aspect ratio settings for recording and RTSP streaming output. I found in encLink_h264.c dynamic parameter print of sampleAspectRatioHeight and sampleAspectRatioWidth. But the parameter seem not to be used in MCFW.

Is it possible to change SAR and/or DAR (Storage Aspect Ratio and Display Aspect Ratio) in MCFW ?

  • The sampleAspectRatio params for not used for encoding.They are used for embedding the info in the H264 VUI layer .Is this what you require ? Or do you want to change the picture aspect ratio ? Changing picture aspect ratio requires appropriate scaler configuration.

  • We want to change both.

    RTSP stream output must contain a valid aspect ratio information

    also the display output must be set to 4:3 / 16:9 /...

    How can I acieve this with scaler parameters ?

     

  • I Found sclrPrm.outScaleFactor.ratio.widthRatio / heightRatio in multich_progressive_vcap_venc_vdec_vdis.c

    sclrPrm.scaleMode                                                      = DEI_SCALE_MODE_RATIO; sclrPrm.outScaleFactor.ratio.widthRatio.numerator    = 1; sclrPrm.outScaleFactor.ratio.widthRatio.denominator  = 2; sclrPrm.outScaleFactor.ratio.heightRatio.numerator   = 1; sclrPrm.outScaleFactor.ratio.heightRatio.denominator = 1; sclrPrm.numBufsPerCh                                               = 2;

    How can we set 4:3 or 16:9 ratio or other ratios for SD video output and independently for HDMI video output ?

     Is it possible to set this dynamicly ?

     

     

  • It is possible to set scaler output resolution dynamically. Refer the API documentation of SCLR_LINK_CMD_SET_OUTPUTRESOLUTION cmd. You can do SCLR_LINK_CMD_GET_OUTPUTRESOLUTION and then do SET by changing the required params.

    Scaler will however not insert LetterBox/PillarBox on the video frame. If you want to apply letterBix/PillarBox it is better you use SwMs and create a 1x1 layout of required dimension. The background of SwMs will be blanked out .

    The aspect ratio info can be got from the H264 decoder but this info is not exported to the application. SOme minor changes are required in decLink to support this.

    For the encoder VUI info , changes are required to the encoder dynamic params API to accept aspect ratio info from the application and then set the encoder VUI info accordingly. This requires some changes in encLink.

     

  • Ok, I understand that we can use VCAP_CHN_DYNAMIC_PARAM_S and the functions Vcap_getDynamicParamChn() / Vcap_setDynamicParamChn() to get / set the capture side resolution. We use this to switch between D1 and CIF capture.

    As I understand You it is only possible to use SWMS to scale for example  4:3 / 16:9. This means we have to create for every mosaic that we want to use PAL / NTSC and 4:3 / 16:9 versions, 4 versions for every mosaic in this case ?

     

  • I have extended Venc_setDynamicParam() chain for encoder "sample aspect ratio". For this, I have enabled aspectRatioInfoPresentFlag and set aspectRatioIdc. So we can set Int32 sampleAspectRatioWidth and Int32 sampleAspectRatioHeight dynamicly for every channel. For encoder side this works fine.

    Next is decoder: I have found the same members (sampleAspectRatioWidth, sampleAspectRatioHeight  and the flags)in: /ti_tools/codecs/REL.500.V.H264AVC.D.HP.IVAHD.02.00.05.00/500.V.H264AVC.D.HP.IVAHD.02.00/IVAHD_001/Inc/ih264vdec.h But I can not use a function chain for setting dynamic decoder parameter. How can we set aspect ratio here ?

     

  • The decoder parses the bitstream and populates the info in the outArgs. If the h264 stream sets aspect  ratio info correctly the H264 decoder will extract this info and is available to the decLink.

    My understanding of the changes to support aspect ratio on decode side  would be:

    1. Decoder parses bitstream and populates aspect ratio info.

    2. DecLink_h264.c modified to check aspect ratio info and if info present send event to application with aspect ratio info.Currently it sends event on decode error which can be used as reference.

       - DecLink sends aspect stores aspect ratio info and sends event whenever there is change.

    3. Applications gets the aspect ratio info and creates SwMs layout with correct width:height to maintain aspect ratio.

         SwMs will fill background not covered with video with black background and will achieve similar effect as pillar box/letter box.

  • I agree with the idea of this sequence.

    We want to adapt aspect ratio for video playback.

    In this case the aspect ratio stays constant during playback is running but must be set if playback starts.

    We will extend the setup of mosaic layout with an extended parameter "aspect ratio".

    But currently the retrieving of the aspect ratio information from decoder link api is not clear for me because a get-function of dynamic parameter is not available.

     

     

  • Ok, we use FFMPEG for video playback.

    It is possible to get aspect ratio and frame size information from here.

    This means I do not need retrieve this from the decoder in MCFW API.