Hello,
I'm implementing real time AVC/H264 encoding of game play using OpenVideo encode, everything is working as intended on resolutions up to 1920x1080 but anything higher than that results in an error at OVEncodeSEndConfig function.
Here's some sample code
Configuration
pConfig = &this->configCtrl; | ||
ZeroMemory(pConfig, sizeof(OvConfigCtrl)); |
pConfig->encodeMode = (OVE_ENCODE_MODE)1; | /**< encode mode */ | ||||
pConfig->width = lpbih->biWidth; | |||||
pConfig->height = lpbih->biHeight; |
/**************************************************************************/ | |||||||||||||
/* fill-in the profile and level */ | |||||||||||||
/**************************************************************************/ | |||||||||||||
pConfig->profileLevel.level | = 40; | /**< encode profile */ | |||||||||||
pConfig->profileLevel.profile | = 77; |
pConfig->pictFormat | = (OVE_PICTURE_FORMAT)1; | |||||||||
pConfig->priority | = (OVE_ENCODE_TASK_PRIORITY)2;//1; |
/**************************************************************************/ | |||||||||
/* fill-in the picture control structures */ | |||||||||
/**************************************************************************/ | |||||||||
pConfig->pictControl.size | = sizeof(OVE_CONFIG_PICTURE_CONTROL); | ||||||||
pConfig->pictControl.useConstrainedIntraPred | = 0; | ||||||||
pConfig->pictControl.cabacEnable | = 1; | ||||||||
pConfig->pictControl.cabacIDC | = 0; | ||||||||
pConfig->pictControl.loopFilterDisable | = 0; | ||||||||
pConfig->pictControl.encLFBetaOffset | = 0; | ||||||||
pConfig->pictControl.encLFAlphaC0Offset | = 0; | ||||||||
pConfig->pictControl.encIDRPeriod | = 0; | ||||||||
pConfig->pictControl.encIPicPeriod | = 0; | ||||||||
pConfig->pictControl.encHeaderInsertionSpacing | = 0; | ||||||||
pConfig->pictControl.encCropLeftOffset | = 0; | ||||||||
pConfig->pictControl.encCropRightOffset | = 0; | ||||||||
pConfig->pictControl.encCropTopOffset | = 0; | ||||||||
pConfig->pictControl.encCropBottomOffset | = 4; | ||||||||
pConfig->pictControl.encNumMBsPerSlice | = (unsigned int)(ceil((float)pConfig->width / 16.0f) * ceil((float)pConfig->height / 16.0f)); | ||||||||
pConfig->pictControl.encNumSlicesPerFrame | = 1; | ||||||||
pConfig->pictControl.encForceIntraRefresh | = 0; | ||||||||
pConfig->pictControl.encForceIMBPeriod | = 0; | ||||||||
pConfig->pictControl.encInsertVUIParam | = 0; | ||||||||
pConfig->pictControl.encInsertSEIMsg | = 0; |
/**************************************************************************/ | |||||||||
/* fill-in the rate control structures */ | |||||||||
/**************************************************************************/ | |||||||||
pConfig->rateControl.size | = sizeof(OVE_CONFIG_RATE_CONTROL); | ||||||||
pConfig->rateControl.encRateControlMethod | = 4; | ||||||||
pConfig->rateControl.encRateControlTargetBitRate | = 15000000; | ||||||||
pConfig->rateControl.encRateControlPeakBitRate | = 0; | ||||||||
pConfig->rateControl.encRateControlFrameRateNumerator = this->Framerate_; | |||||||||
pConfig->rateControl.encGOPSize | = 0; | ||||||||
pConfig->rateControl.encRCOptions | = 0; | ||||||||
pConfig->rateControl.encQP_I | = 22; | ||||||||
pConfig->rateControl.encQP_P | = 22; | ||||||||
pConfig->rateControl.encQP_B | = 0; | ||||||||
pConfig->rateControl.encVBVBufferSize | = pConfig->rateControl.encRateControlTargetBitRate / 2; | ||||||||
pConfig->rateControl.encRateControlFrameRateDenominator = 1; |
/**************************************************************************/ | ||||||||
/* fill-in the motion estimation control structures */ | ||||||||
/**************************************************************************/ | ||||||||
pConfig->meControl.size = sizeof(OVE_CONFIG_MOTION_ESTIMATION); | ||||||||
pConfig->meControl.imeDecimationSearch | = 1; | |||||||
pConfig->meControl.motionEstHalfPixel | = 1; | |||||||
pConfig->meControl.motionEstQuarterPixel | = 1; | |||||||
pConfig->meControl.disableFavorPMVPoint | = 0; | |||||||
pConfig->meControl.forceZeroPointCenter | = 1; | |||||||
pConfig->meControl.lsmVert | = 0; | |||||||
pConfig->meControl.encSearchRangeX | = 36; | |||||||
pConfig->meControl.encSearchRangeY | = 36; | |||||||
pConfig->meControl.encSearch1RangeX | = 0; | |||||||
pConfig->meControl.encSearch1RangeY | = 0; | |||||||
pConfig->meControl.disable16x16Frame1 | = 0; | |||||||
pConfig->meControl.disableSATD | = 0; | |||||||
pConfig->meControl.enableAMD | = 1; | |||||||
pConfig->meControl.encDisableSubMode | = 0; | |||||||
pConfig->meControl.encIMESkipX | = 0; | |||||||
pConfig->meControl.encIMESkipY | = 0; | |||||||
pConfig->meControl.encEnImeOverwDisSubm | = 0; | |||||||
pConfig->meControl.encImeOverwDisSubmNo | = 0; | |||||||
pConfig->meControl.encIME2SearchRangeX | = 4; | |||||||
pConfig->meControl.encIME2SearchRangeY | = 4; |
/**************************************************************************/ | ||||||
/* fill-in the RDO control structures */ | ||||||
/**************************************************************************/ | ||||||
pConfig->rdoControl.size = sizeof(OVE_CONFIG_RDO); | ||||||
pConfig->rdoControl.encDisableTbePredIFrame | = 0; | |||||
pConfig->rdoControl.encDisableTbePredPFrame | = 0; | |||||
pConfig->rdoControl.useFmeInterpolY | = 0; | |||||
pConfig->rdoControl.useFmeInterpolUV | = 0; | |||||
pConfig->rdoControl.enc16x16CostAdj | = 0; | |||||
pConfig->rdoControl.encSkipCostAdj | = 0; | |||||
pConfig->rdoControl.encForce16x16skip | = (uint8)0; |
The code is failing here when I try resolutions higher than 1920x1080 (1920x1200 is enough to trigger the error)
/**************************************************************************/ |
/* send configuration values for this session */
/**************************************************************************/ |
configBuffers[0].config.pPictureControl = &(pConfig->pictControl);
configBuffers[0].configType = OVE_CONFIG_TYPE_PICTURE_CONTROL;
configBuffers[1].config.pRateControl = &(pConfig->rateControl);
configBuffers[1].configType = OVE_CONFIG_TYPE_RATE_CONTROL;
configBuffers[2].config.pMotionEstimation = &(pConfig->meControl);
configBuffers[2].configType = OVE_CONFIG_TYPE_MOTION_ESTIMATION;
configBuffers[3].config.pRDO = &(pConfig->rdoControl);
configBuffers[3].configType = OVE_CONFIG_TYPE_RDO;
// At this point everything is already set, session and configuration is valid
// and the code works fine with resolutions up to 1920x1080
res = OVEncodeSendConfig (session, numOfConfigBuffers, configBuffers); <====== FAIL
Is that a known error or limitation?
Solved! Go to Solution.
Found the answer in UVD3 whitepaper. Good news is it works and it's screaming fast! Bad news is no real time encoding for resolutions higher than 1080p.
Video Codec Engine (VCE)
As the PC has become the central hub for multimedia content in the house, there a growing need for end-users access and transfer video content to other devices like tablets, or streaming to other PCs in real-time, requiring video encode, which is a very complex and long processing, especially for to encode or stream HD video. For years, HD video encode has been limited to PCs with high-end CPU and was slower than real-time, creating frustration to end-users.
To solve this challenge, new and dedicated hardware named the Video Codec Engine (VCE) was introduced with AMD Radeon™ HD 7900 Series to accelerate HD video encoding. This technology is also present in the AMD Radeon™ HD 7700 and HD 7800 Series GPUs.
At the heart of VCE is a multi-stream hardware H.264/AVC encoder (Figure 11). It is power-efficient and faster than real-time, enabling 60 FPS encoding of content with a resolution up to 1920x1080 (1080p).
VCE supports 4:2:0 color sampling encode, the most commonly used color space of consumer video formats. VCE also includes optimizations for scene changes and variable compression bitrate for an enhanced visual quality of the encoded video.
Found the answer in UVD3 whitepaper. Good news is it works and it's screaming fast! Bad news is no real time encoding for resolutions higher than 1080p.
Video Codec Engine (VCE)
As the PC has become the central hub for multimedia content in the house, there a growing need for end-users access and transfer video content to other devices like tablets, or streaming to other PCs in real-time, requiring video encode, which is a very complex and long processing, especially for to encode or stream HD video. For years, HD video encode has been limited to PCs with high-end CPU and was slower than real-time, creating frustration to end-users.
To solve this challenge, new and dedicated hardware named the Video Codec Engine (VCE) was introduced with AMD Radeon™ HD 7900 Series to accelerate HD video encoding. This technology is also present in the AMD Radeon™ HD 7700 and HD 7800 Series GPUs.
At the heart of VCE is a multi-stream hardware H.264/AVC encoder (Figure 11). It is power-efficient and faster than real-time, enabling 60 FPS encoding of content with a resolution up to 1920x1080 (1080p).
VCE supports 4:2:0 color sampling encode, the most commonly used color space of consumer video formats. VCE also includes optimizations for scene changes and variable compression bitrate for an enhanced visual quality of the encoded video.
Adding link to the whitepaper for the sake of other developers: http://www.amd.com/us/Documents/UVD3_whitepaper.pdf