I had a problem by using the SDK.
So, I would like to encode single YUV frame into H.265 format. Basically I can do it with settings in the SDK sample sample_encode part.
But, when I try to mandate the frame type through mfxEncodeCtrl I get MFX_ERR_INVALID_VIDEO_PARAM error.
memset(&control_buffer, 0, sizeof(mfxEncodeCtrl));
control_buffer.FrameType = MFX_FRAMETYPE_IDR | MFX_FRAMETYPE_REF;
sts = m_pmfxENC->EncodeFrameAsync(&control_buffer, &m_pEncSurfaces[nEncSurfIdx], &pCurrentTask->mfxBS, &pCurrentTask->EncSyncP);
It looks like there is a conflict between encoder initialization and the control buffer. But this is for sure 1 frame to be encoded, so, I don't see any conflict points. Maybe someone knows why it produces an error ?
Can you provide me with your application or file with changes of EncodeCtrl structure. I tried this on our end and did not see the problem of invalid video param, however I didn't see the frame type being enforced on the entire stream either. If you can send me your application, I can check what the issue is. If there is a bug in the SDK, will escalate it to the experts and try to get it resolved soon.
Thank you for your response.
Let me describe my test. Basically, I took sample_encode application, build it and run the following command (no modification to the source was done):
./sample_encode_drm h265 -i RED.yuv -o OutputEncodedFile -w 3840 -h 2160 -hw -p e5400a06c74d41f5b12d430bbaa23d0b
RED.yuv is 4K single frame. Encoder produced me IDR frame. I know that by looking into NAL type of the bitstream.
After I decided to set the control structure to see how it works. In function mfxStatus CEncodingPipeline::Run() (line 1341) of pipeline_encode.cpp I've set the control structure is in original message. Since there is only single frame encoding and for sure that frame will be IDR I was not expecting any problems. But I got that error.
Basically, I'm trying to figure ability of SDK to reencode single frames. The idea was to make frame intra only. Size might be bigger, but that acceptable in case of VBR. Since intra prediction doen't require any context from previous frames, I was expecting to do that.
I was looking into FEI API as well. Originally it exactly what I need, but I can't bind mfxFEIH265Output structure with encoder control structure.
I will appreciate if you can comment my investigation.
Thank you in advance.
Thanks for providing details! HEVC encoder doesn't support enforcing the frame type, hence you won't be able to use EncodeCtrl structure to do so. If you are encoding a single frame it will result into an IDR frame as you have confirmed through your test.
Another approach you can also try is to set the gop pattern by setting the GOPPicsize =1, which means that every frame will be an I frame.
Hope that answers you query on how you can generate intra frames using hevc encoder.