Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Renit_S_
Beginner
62 Views

Problem in VPP downscaling in letterBox Mode

Hello,

In my application I want to Encode 1928*1080 (16:9 )size video buffer (UYVY format) to 720*576 (4:3) H264 stream using IQSV encoder.

What parameter in VPP, I have to set encoder perform downscaling in such a way, there is letter box at top and bottom.

 I tried to set following parameter in VPP 

mfxStatus CEncodingPipeline::InitMfxVppParams(sInputParams *pInParams)
{
    MSDK_CHECK_POINTER(pInParams,  MFX_ERR_NULL_PTR);   

    // specify memory type
    if (pInParams->bd3dAlloc)
    {
        m_mfxVppParams.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY;
    }
    else
    {
        m_mfxVppParams.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY | MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
    }    

    // input frame info  
    m_mfxVppParams.vpp.In.FourCC    = MFX_FOURCC_NV12;
    m_mfxVppParams.vpp.In.PicStruct = 2;
    ConvertFrameRate(25,25,1);

   m_mfxVppParams.vpp.In.Width     = 1920; 
   m_mfxVppParams.vpp.In.Height    = 1088;
   m_mfxVppParams.vpp.In.CropW = 1920;
   m_mfxVppParams.vpp.In.CropH = 1080;

    // fill output frame info
    memcpy(&m_mfxVppParams.vpp.Out, &m_mfxVppParams.vpp.In, sizeof(mfxFrameInfo));

    // only resizing is supported
    m_mfxVppParams.vpp.Out.Width = 720
    m_mfxVppParams.vpp.Out.Height = 576

    m_mfxVppParams.vpp.Out.CropX = 0;
    m_mfxVppParams.vpp.Out.CropY = 36;
    m_mfxVppParams.vpp.Out.CropW = 720;
    m_mfxVppParams.vpp.Out.CropH = 504;

 // configure and attach external parameters 
    AllocAndInitVppDoNotUse();
    m_VppExtParams.push_back((mfxExtBuffer *)&m_VppDoNotUse);
  }

mfxStatus CEncodingPipeline::AllocAndInitVppDoNotUse()
{    
    m_VppDoNotUse.NumAlg = 4;

    m_VppDoNotUse.AlgList = new mfxU32 [m_VppDoNotUse.NumAlg];    
    MSDK_CHECK_POINTER(m_VppDoNotUse.AlgList,  MFX_ERR_MEMORY_ALLOC);

    m_VppDoNotUse.AlgList[0] = MFX_EXTBUFF_VPP_DENOISE; // turn off denoising (on by default)
    m_VppDoNotUse.AlgList[1] = MFX_EXTBUFF_VPP_SCENE_ANALYSIS; // turn off scene analysis (on by default)
    m_VppDoNotUse.AlgList[2] = MFX_EXTBUFF_VPP_DETAIL; // turn off detail enhancement (on by default)
    m_VppDoNotUse.AlgList[3] = MFX_EXTBUFF_VPP_PROCAMP; // turn off processing amplified (on by default)

    return MFX_ERR_NONE;

} // CEncodingPipeline::AllocAndInitVppDoNotUse()

Regards

Renit Shah

0 Kudos
3 Replies
Anthony_P_Intel
Employee
62 Views

Hi,

I am not seeing any issue using NV12 buffer input and output with VPP.  How are you converting your UYVY format buffer to VPP Input?  What do you observe as an output?

I believe you have the right size and crop parameters to achieve what you want (letterbox).

 

Renit_S_
Beginner
62 Views

Hello Tony,

Thanks for reply.

I am converting UYVY to NV12 using third party color converter.

please find my encoder setting also

    m_mfxEncParams.mfx.CodecId                 =MFX_CODEC_MPEG2;
    m_mfxEncParams.mfx.TargetUsage             = pInParams->nTargetUsage; // trade-off between quality and speed
    m_mfxEncParams.mfx.TargetKbps              = 8000; // in Kbps
    m_mfxEncParams.mfx.MaxKbps                   = 0;
    m_mfxEncParams.mfx.RateControlMethod       = MFX_RATECONTROL_CBR; 
    ConvertFrameRate(25, 25, 1);    
    m_mfxEncParams.mfx.EncodedOrder            = 0; // binary flag, 0 signals encoder to take frames in display order
    
    m_mfxEncParams.mfx.GopOptFlag               = MFX_GOP_CLOSED ;
    m_mfxEncParams.mfx.IdrInterval               = 1;//Keep IdrInterval as 0 to make all I frames as IDR-REF frames
    m_mfxEncParams.mfx.DecodedOrder               = 0;      //Taken from Mainconcept  
    m_mfxEncParams.mfx.GopRefDist               = 2 + 1;  //To set Number of B-Frames,
                                                                                //If Number of B-Frame needs to be N then GopRefDist should be N+1
    m_mfxEncParams.mfx.GopPicSize               = 16
  
   if (pInParams->bd3dAlloc)
    {
        m_mfxEncParams.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY;
    }
    else
    {
        m_mfxEncParams.IOPattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
    }    

    // frame info parameters
    m_mfxEncParams.mfx.FrameInfo.FourCC       = MFX_FOURCC_NV12;
    m_mfxEncParams.mfx.FrameInfo.ChromaFormat = MFX_CHROMAFORMAT_YUV420;
    m_mfxEncParams.mfx.FrameInfo.PicStruct    = pInParams->nPicStruct;

    m_mfxEncParams.mfx.FrameInfo.AspectRatioW = 4 * 576;
    m_mfxEncParams.mfx.FrameInfo.AspectRatioH = 3 * 720;  

    // set frame size and crops
    // width must be a multiple of 16 
    // height must be a multiple of 16 in case of frame picture and a multiple of 32 in case of field picture
    m_mfxEncParams.mfx.FrameInfo.Width  = MSDK_ALIGN16(720);
    m_mfxEncParams.mfx.FrameInfo.Height = (MFX_PICSTRUCT_PROGRESSIVE == m_mfxEncParams.mfx.FrameInfo.PicStruct)?
        MSDK_ALIGN16(576) : MSDK_ALIGN32(576);
    
    m_mfxEncParams.mfx.FrameInfo.CropX = 0; 
    m_mfxEncParams.mfx.FrameInfo.CropY = 0;
    m_mfxEncParams.mfx.FrameInfo.CropW = 720;
    m_mfxEncParams.mfx.FrameInfo.CropH = 576;
    


Thanks & Regards

Renit
  

 

 

Anthony_P_Intel
Employee
62 Views

Hi Renit,

The encode parameters should not matter, as the input to the encode step is just a 720x576 uncompressed frame.

What is the actual issue you are seeing, as I see this scaling and letterboxing working well? What does your output look like?

 

Reply