How to use h.264 High Profile but disable CABAC and B slices

How to use h.264 High Profile but disable CABAC and B slices

How to use h.264 High Profile but disable CABAC and B slices

Thanks

8 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
Best Reply

You can write something like this

mfxVideoParam mvp;
mfxExtCodingOption meco, *pmeco = &meco;

memset(0, &mvp, sizeof(mvp));
memset(0, &meco, sizeof(meco));

// Specify AVC high profile
mvp.mfx.CodecId = MFX_CODEC_AVC;
mvp.mfx.CodecProfile = MFX_PROFILE_AVC_HIGH;
// Disable B slices
mvp.mfx.GopRefDist = 1;

// To disable CABAC it is necessary to attach one extended buffer mfxExtCodingOption to video params
meco.CAVLC = 1;
meco.Header.BufferId = MFX_EXTBUFF_CODING_OPTION;
meco.Header.BufferSz = sizeof(meco);
mvp.NumExtParam = 1;
mvp.ExtParam = (mfxExtBuffer **)&pmeco;

// Other parameters have to specified in video params for correct encoder initialization

...

MFXVideoEncode_Init(session, &mvp);

Hi Gregory,
I got it.
But should I use meco.CAVLC = MFX_CODINGOPTION_ON instead of meco.CAVLC = 1 ?

Thanks.

Yes, you should use preferably useMFX_CODINGOPTION_ON enum instead.Thanks,Petter

Hi,I modify the smaple to disable B-slice and CABAC.But sts = m_pmfxENC->QueryIOSurf(&m_mfxEncParams, &EncRequest); inmfxStatus CEncodingPipeline::AllocFrames() return MFX_ERR_NULL_PTR.Is there aynthing wrong?Thanks.mfxStatus CEncodingPipeline::InitMfxEncParams(sInputParams *pInParams){ m_mfxEncParams.mfx.GopRefDist = 1;// Disable B slices // To disable CABAC it is necessary to attach one extended buffer mfxExtCodingOption to video params mfxExtCodingOption meco; //mfxExtCodingOption *pmeco = &meco; memset( &meco,0, sizeof(meco)); meco.CAVLC = MFX_CODINGOPTION_ON; meco.Header.BufferId = MFX_EXTBUFF_CODING_OPTION; meco.Header.BufferSz = sizeof(meco); m_mfxEncParams.NumExtParam=1; m_mfxEncParams.ExtParam = (mfxExtBuffer **)&meco; m_mfxEncParams.mfx.CodecId = pInParams->CodecId; m_mfxEncParams.mfx.TargetUsage = pInParams->nTargetUsage; // trade-off between quality and speed m_mfxEncParams.mfx.TargetKbps = pInParams->nBitRate; // in Kbps m_mfxEncParams.mfx.RateControlMethod = MFX_RATECONTROL_CBR; ConvertFrameRate(pInParams->dFrameRate, &m_mfxEncParams.mfx.FrameInfo.FrameRateExtN, &m_mfxEncParams.mfx.FrameInfo.FrameRateExtD); m_mfxEncParams.mfx.EncodedOrder = 0; // binary flag, 0 signals encoder to take frames in display order // specify memory type 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; // 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(pInParams->nDstWidth); m_mfxEncParams.mfx.FrameInfo.Height = (MFX_PICSTRUCT_PROGRESSIVE == m_mfxEncParams.mfx.FrameInfo.PicStruct)? MSDK_ALIGN16(pInParams->nDstHeight) : MSDK_ALIGN32(pInParams->nDstHeight); m_mfxEncParams.mfx.FrameInfo.CropX = 0; m_mfxEncParams.mfx.FrameInfo.CropY = 0; m_mfxEncParams.mfx.FrameInfo.CropW = pInParams->nDstWidth; m_mfxEncParams.mfx.FrameInfo.CropH = pInParams->nDstHeight; // we don't specify profile and level and let the encoder choose those basing on parameters // we must specify profile only for MVC codec if (m_bIsMVC) { m_mfxEncParams.mfx.CodecProfile = MFX_PROFILE_AVC_STEREO_HIGH; } // configure and attach external parameters if (pInParams->bIsMVC) m_EncExtParams.push_back((mfxExtBuffer *)&m_MVCSeqDesc); if (!m_EncExtParams.empty()) { m_mfxEncParams.ExtParam = &m_EncExtParams[0]; // vector is stored linearly in memory m_mfxEncParams.NumExtParam = (mfxU16)m_EncExtParams.size(); } return MFX_ERR_NONE;}

Hi kkbee,

I'm pretty sure the issue you are facing is due to "EncRequest" structure not having the extended buffer pointer set. Can you please check?

"QueryIOSurf" function will validate the input parameters and write the selected output parameters to the"EncRequest" structure. If the extended buffer pointer has not been set you will get the error you have seen. You can initialize the"EncRequest" structure to point to the same extended buffer as "m_mfxEncParams".

Regards,Petter

Hi again,

I read your message too fast. I realize now that you get an error when calling"QueryIOSurf", and not"Query". :(

Looking at this again it seems the issue may have to do with the way you initialize "m_mfxEncParams.ExtParam". It needs to be a pointer to pointer as Gregory explained in his code snippet. Also, to make sure you do not loose local data on the stack when you go out of the function scope, please move "mfxExtCodingOptionmeco" storage to the class intead.

Regards,Petter

I got it.Because I use local meco variable.After running CEncodingPipeline::InitMfxEncParams, meco is invalid.Thank for your help.

发表评论

登录添加评论。还不是成员?立即加入