[FFmpeg-devel] [PATCH 3/4] avutil/cuda_check: propagate AVERROR_UNRECOVERABLE when needed

Timo Rothenpieler timo at rothenpieler.org
Tue Nov 22 17:15:35 EET 2022



On 22/11/2022 14:31, James Almer wrote:
> On 11/22/2022 10:21 AM, Timo Rothenpieler wrote:
>> On 22/11/2022 14:07, James Almer wrote:
>>> Based on a patch by Soft Works.
>>>
>>> Signed-off-by: James Almer <jamrial at gmail.com>
>>> ---
>>>   libavutil/cuda_check.h | 4 ++++
>>>   1 file changed, 4 insertions(+)
>>>
>>> diff --git a/libavutil/cuda_check.h b/libavutil/cuda_check.h
>>> index f5a9234eaf..33aaf9c098 100644
>>> --- a/libavutil/cuda_check.h
>>> +++ b/libavutil/cuda_check.h
>>> @@ -49,6 +49,10 @@ static inline int ff_cuda_check(void *avctx,
>>>           av_log(avctx, AV_LOG_ERROR, " -> %s: %s", err_name, 
>>> err_string);
>>>       av_log(avctx, AV_LOG_ERROR, "\n");
>>> +    // Not recoverable
>>> +    if (err == CUDA_ERROR_UNKNOWN)
>>> +        return AVERROR_UNRECOVERABLE;
>>
>> Why does specifically CUDA_ERROR_UNKNOWN get mapped to unrecoverable?
> 
> It's the code that Soft Works found out was returned repeatedly no 
> matter how many packets you fed to the encoder, which meant it was stuck 
> in an unrecoverable state. See 
> http://ffmpeg.org/pipermail/ffmpeg-devel/2021-October/287153.html
> 
> If you know of cases where this error could be returned in valid 
> recoverable scenarios that are not already handled in some other way, 
> what do you suggest could be done?

It's more that that very much depends on the context the function is 
used in.
In the context of an active de/encoding loop, every non-success return 
would be unrecoverable. Or even during init.

While in other places a failure just breaks a single frame and if it 
somehow recovery, it can continue on. Though that's usually the exception.

In any case, this function does not seem the right place to map an 
arbitrary return code to such a result. Keep in mind every single 
filter/de/encoder uses this function to check CUDA call results.


More information about the ffmpeg-devel mailing list