MSDK decoder error handing for wrong level_idc clips. #582
Comments
|
DecodeHeader() is optional but in this case application takes responsibility of filling correct mfxVideoParam . If the issue is not seen using DecodeHeader it means that FFMPEG passed wrong mfxVideoParam to Init() function. The question: where are these param from ? |
|
@dmitry-gurulev : please, participate in the discussion. Can someone, please:
My thoughts around this issue are the following:
|
|
@dmitryermilov ,there is nothing wrong that ffmpeg passing to init(), the parameters are parsed by ffmpeg software decoder. The root cause is the input clip hasn't strictly following H264 spec: the level_idc is conflict with other parameters: conflict with resolution in Intel-FFmpeg-Plugin/Intel_FFmpeg_plugins#37 and conflict with reference number in Intel-FFmpeg-Plugin/Intel_FFmpeg_plugins#32. |
|
@dvrogozh, DecodeHeader sets mfxBitstream::DataOffset to first valid SPS it found in the bitstream. DecodeFrameAsync will work in both cases - if user bitstream starts form header or doesn't.
|
|
I fully agree with Dmitry G. reply |
|
@dmitry-gurulev : I don't fully understand your answer. This in particular: "In that certain case decoder is initialized w/ level 1.0, but accord. to SPS level should be at least 2.1." Did you intent to answer that SPS contains incorrect level 1.0, but there are other parameters in the same SPS which signify that level should be at least 2.1? |
Yes, that's exactly what I mean. |
|
@lizhong1008 : please, take a look into the following description and provide your comments:
So, the key point is that mediadk:
So, in a way ffmpeg-qsv bites its own tail: library provides you a way to detect correct settings, but you neither don't use this api nor implement an alternative. Question: what is motivation behind avoiding to use DecodeHeader? Could you, please, provide explanation and/or implement this support in the ffmpeg-qsv? |
|
@dvrogozh , resolution change has been handled in ffmpeg: https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvdec.c#L523 . For other cases need to be reinit, let us create a new discussion thread. Then, Let's talk MFX DecodeHeader:
### My question: Is there any technology difficulty to move such error handing implementation from DecodeHeader to somewhere else? |
|
@lizhong1008 : the mediasdk uAPI to get correct parameters to continue decoding is DecodeHeader. And I honestly do not see any reason to define another uAPI for the same purpose if there is the one already. As of now, if application don't want to use this uAPI, it just restricts supported use cases to those which has completely correct bitstreams.
I don't see this as a technology question of what can and can not be done. We talk about a software, a lot of things can be done. To me that's a question of how uAPI is defined and what is and is not permitted within uAPI calls. For example, if decoder was initialized to handle X (i.e. it allocated required resources, etc.), it can not dynamically reinitialize DecodeFrameAsync to handle Y (i.e. reallocate resources). That's why -14 was returned from DecodeFrameAsync and this is correct. If you meet such situation, you have one of the 2 choices:
You do not have a strict separation in ffmpeg on the areas of responsibility. You can use ffmpeg parser, but you still pass same bitstream to mediasdk. If the situation was that ffmpeg parser worked, processed part of the bitstream and passed remained part to mediasdk that would be the case of your concerns that mediasdk don't support something, but you have other situation... As a result selective approach of what you want mediasdk to do and what you don't is quite strange. |
Common issue with incorrect level_idc is num_ref_frames more than calculated DPB size (DPB depends on level_idc). DecodeHeader can increase level_idc after parsing sps header. Other functions (Init/Query/QueryIOSurf) know nothing about sps and num_ref_frames and can't do error handling. |
|
Finally I agree to replace current parser with MFXVideoDECODE_DecodeHeader() for ffmpeg-qsv. And patch has been sent: https://patchwork.ffmpeg.org/patch/11809/. |
|
Hi @lizhong1008 , Was the ffmpeg change merged? |
|
@dmitryermilov not yet, community still would like to use ffmpeg software parser. |
|
@dmitryermilov , ffmpeg change merged, so it can be closed now. |
Some clips declare a wrong level_idc, smaller than it should be. Then will trigger an error MFX_ERR_INCOMPATIBLE_VIDEO_PARAM and make decoding process interrupted. If using MSDK parser MFXVideoDECODE_DecodeHeader, this error won't happen. However, using MFXVideoDECODE_DecodeHeader is an optional, not must. So the error handling should be move to somewhere more common.
More details please refer Intel-FFmpeg-Plugin/Intel_FFmpeg_plugins#37
The text was updated successfully, but these errors were encountered: