Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

[AVCe] Expand zero ROI to minimum supported size #2907

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions _studio/mfx_lib/encode_hw/h264/src/mfx_h264_encode_hw_utils_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2335,26 +2335,30 @@ void MfxHwH264Encode::ConfigureTask(

for (mfxU16 i = 0; i < numRoi; i ++)
{
if (extRoiRuntime)
if (pRoi->ROI[i].Left != 0 && pRoi->ROI[i].Top != 0 &&
pRoi->ROI[i].Right != 0 && pRoi->ROI[i].Bottom != 0)
{
mfxRoiDesc task_roi = {pRoi->ROI[i].Left, pRoi->ROI[i].Top,
pRoi->ROI[i].Right, pRoi->ROI[i].Bottom,
(mfxI16)((pRoi->ROIMode == MFX_ROI_MODE_PRIORITY ? (-1) : 1) * pRoi->ROI[i].DeltaQP) };
if (extRoiRuntime)
{
mfxRoiDesc task_roi = {pRoi->ROI[i].Left, pRoi->ROI[i].Top,
pRoi->ROI[i].Right, pRoi->ROI[i].Bottom,
(mfxI16)((pRoi->ROIMode == MFX_ROI_MODE_PRIORITY ? (-1) : 1) * pRoi->ROI[i].DeltaQP) };

// check runtime ROI
mfxStatus sts = CheckAndFixRoiQueryLike(video, &task_roi, extRoiRuntime->ROIMode);
// check runtime ROI
mfxStatus sts = CheckAndFixRoiQueryLike(video, &task_roi, extRoiRuntime->ROIMode);

if (sts != MFX_ERR_UNSUPPORTED) {
task.m_roi[task.m_numRoi] = task_roi;
task.m_numRoi++;
if (sts != MFX_ERR_UNSUPPORTED) {
task.m_roi[task.m_numRoi] = task_roi;
task.m_numRoi++;
}
}
else
{
task.m_roi[task.m_numRoi] = {pRoi->ROI[i].Left, pRoi->ROI[i].Top,
pRoi->ROI[i].Right, pRoi->ROI[i].Bottom,
(mfxI16)((pRoi->ROIMode == MFX_ROI_MODE_PRIORITY ? (-1) : 1) * pRoi->ROI[i].DeltaQP) };
task.m_numRoi ++;
}
}
else
{
task.m_roi[task.m_numRoi] = {pRoi->ROI[i].Left, pRoi->ROI[i].Top,
pRoi->ROI[i].Right, pRoi->ROI[i].Bottom,
(mfxI16)((pRoi->ROIMode == MFX_ROI_MODE_PRIORITY ? (-1) : 1) * pRoi->ROI[i].DeltaQP) };
task.m_numRoi ++;
}
}
task.m_roiMode = MFX_ROI_MODE_QP_DELTA;
Expand Down
9 changes: 9 additions & 0 deletions _studio/mfx_lib/shared/src/mfx_h264_enc_common_hw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4501,6 +4501,15 @@ mfxStatus MfxHwH264Encode::CheckVideoParamQueryLike(

for (mfxU16 i = 0; i < extRoi->NumROI; i++)
{
auto& rect = extRoi->ROI[i];
if (rect.Left == 0 && rect.Right == 0 && rect.Top == 0 && rect.Bottom == 0)
{
// Allow zero rect sizes at input. Output min supported sizes.
rect.Right = 16;
rect.Bottom = 16;
changed = true;
}

sts = CheckAndFixRoiQueryLike(par, (mfxRoiDesc*)(&(extRoi->ROI[i])), extRoi->ROIMode);
if (sts < MFX_ERR_NONE)
unsupported = true;
Expand Down