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

vp9e: do not allocate internal resources via external allocator #762

Closed
dvrogozh opened this issue Oct 16, 2018 · 7 comments
Closed

vp9e: do not allocate internal resources via external allocator #762

dvrogozh opened this issue Oct 16, 2018 · 7 comments
Labels
P1 Very important to be fixed

Comments

@dvrogozh
Copy link
Contributor

Please, switch vp9 encoder to use internal mediasdk core and avoid any external allocations for internal resources.

@dvrogozh dvrogozh added the P1 Very important to be fixed label Oct 16, 2018
DmitryMalishev added a commit to DmitryMalishev/MediaSDK that referenced this issue Nov 13, 2018
DmitryMalishev added a commit to DmitryMalishev/MediaSDK that referenced this issue Nov 20, 2018
DmitryMalishev added a commit to DmitryMalishev/MediaSDK that referenced this issue Nov 22, 2018
DmitryMalishev added a commit to DmitryMalishev/MediaSDK that referenced this issue Dec 13, 2018
DmitryMalishev added a commit to DmitryMalishev/MediaSDK that referenced this issue Dec 13, 2018
fzhar pushed a commit to fzhar/MediaSDK that referenced this issue Dec 26, 2018
jonrecker pushed a commit to jonrecker/MediaSDK that referenced this issue Feb 19, 2019
jonrecker pushed a commit to jonrecker/MediaSDK that referenced this issue Feb 19, 2019
@xhaihao
Copy link
Contributor

xhaihao commented Apr 29, 2019

@dvrogozh @onabiull @DmitryMalishev is D3DDDIFMT_INTELENCODE_MBSEGMENTMAP (MFX_FOURCC_VP9_SEGMAP) an internal resource ? According to

if (m_bSetExtFrameAlloc && request->Info.FourCC != MFX_FOURCC_P8)
, MediaSDK still tries to use the external frame allocator for D3DDDIFMT_INTELENCODE_MBSEGMENTMAP on linux

@DmitryMalishev
Copy link
Contributor

Hi @xhaihao,
MFX_FOURCC_VP9_SEGMAP surface has MFX_MEMTYPE_INTERNAL_FRAME flag when inited:

request.Type = MFX_MEMTYPE_D3D_INT;

MFX_MEMTYPE_D3D_INT = MFX_MEMTYPE_FROM_ENCODE | MFX_MEMTYPE_DXVA2_DECODER_TARGET | MFX_MEMTYPE_INTERNAL_FRAME,

It means that internal frame allocator should be used for this surface allocation:
if (m_bSetExtFrameAlloc && request->Info.FourCC != MFX_FOURCC_P8)
{
// Default allocator should be used if D3D manager is not set and internal D3D buffers are required
if (!m_Display && request->Type & MFX_MEMTYPE_INTERNAL_FRAME)

Do you see in debug that it is not the case? Please let us know if so.

@eshiryae, could you please track this request if more help required?

@xhaihao
Copy link
Contributor

xhaihao commented May 14, 2019

@DmitryMalishev @eshiryae No, it is not the case because m_Display is not NULL.

Maybe MFX_FOURCC_VP9_SEGMAP should go into the else block too.

else
{
// Default Allocator is used for internal memory allocation and all coded buffers allocation
if (request->Type & MFX_MEMTYPE_EXTERNAL_FRAME)
return MFX_ERR_MEMORY_ALLOC;
m_bUseExtAllocForHWFrames = false;
sts = DefaultAllocFrames(request, response);
MFX_CHECK_STS(sts);
return TraceFrames(request, response, sts);
}

@DmitryMalishev
Copy link
Contributor

@xhaihao, thank you for the clarification.
Before solving it out we(@eshiryae) would like to ask you a couple of things:
[1] What is the impacted usage scenario? Do you have workaround?
[2] Is it urgent change request?
[3] Is it possible to make it work by returning an UNSUPPORTED status from the external allocator on this request to make it use the internal allocator then?

sts = (*m_FrameAllocator.frameAllocator.Alloc)(m_FrameAllocator.frameAllocator.pthis, &temp_request, response);
// if external allocator cannot allocate d3d frames - use default memory allocator
if (MFX_ERR_UNSUPPORTED == sts || MFX_ERR_MEMORY_ALLOC == sts)
{
// Default Allocator is used for internal memory allocation only

@xhaihao
Copy link
Contributor

xhaihao commented May 15, 2019

@DmitryMalishev we are enabling vp9 encode in both ffmpeg/qsv and gst-msdk which have an external allocator. We may workaround it by returning an UNSUPPORTED status however we have to provide the workaround in both ffmpeg/qsv and gst-msdk, another thing is we failed to find MFX_FOURCC_VP9_SEGMAP in mfx header files, so we have to define it in ffmpeg/qsv and gst-msdk. Hence I think it would be better to fix it in MediaSDK.

lizhong1008 added a commit to lizhong1008/ffmpeg-1 that referenced this issue May 15, 2019
1. must enable low_power mode since just VDENC can be supported by iHD
driver right now
2. Coding option1 and extra_data are not supported by MSDK
3. IVF header will be inserted in MSDK by default, but it is not needed
in FFmpeg level, so disable it.
4. Internal buffer MFX_FOURCC_VP9_SEGMAP should not exposed to FFmpeg,
see Intel-Media-SDK/MediaSDK#762

Signed-off-by: Zhong Li <zhong.li@intel.com>
@eshiryae
Copy link
Contributor

Hi @xhaihao, thank you for the details, we understand the problem and will work to solve it.

@eshiryae
Copy link
Contributor

eshiryae commented Jun 5, 2019

Hi @xhaihao, it is expected behavior for hw library and in this case you should return an unsupported error(MFX_ERR_UNSUPPORTED) for segmentation map allocation try. All resources which unsupported by external allocator are allocated by internal allocator.
According MFX_FOURCC_VP9_SEGMAP, you can define it as it's done here:

MFX_FOURCC_VP9_SEGMAP = MFX_MAKEFOURCC('V','P','8','S'),

lizhong1008 added a commit to lizhong1008/ffmpeg-1 that referenced this issue Sep 29, 2019
Return MFX_ERR_UNSUPPORTED for MFX_FOURCC_VP9_SEGMAP to force internal allocator.
See Intel-Media-SDK/MediaSDK#762 for more detail

Signed-off-by: Zhong Li <zhong.li@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P1 Very important to be fixed
Projects
None yet
Development

No branches or pull requests

4 participants