[FFmpeg-devel] [PATCH] add an option to forbid the fallback to sw when hardware init fails

Hendrik Leppkes h.leppkes at gmail.com
Tue Oct 30 11:11:21 EET 2018


On Tue, Oct 30, 2018 at 10:08 AM Linjie Fu <linjie.fu at intel.com> wrote:
>
> Currently ff_get_format will go through all usable choices if the
> chosen format was not supported. It will fallback to software if
> the hardware init fails.
>
> According to the comment in ticket #7519, provided an option
> "-fallback_forbid 1" to return directly if hardware init fails
> and forbid the fallback to software.
>
> Signed-off-by: Linjie Fu <linjie.fu at intel.com>
> ---
>  libavcodec/avcodec.h       |  8 ++++++++
>  libavcodec/decode.c        | 11 +++++++++--
>  libavcodec/options_table.h |  1 +
>  3 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 705a3ce4f3..fac3c6acb2 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3312,6 +3312,14 @@ typedef struct AVCodecContext {
>       * used as reference pictures).
>       */
>      int extra_hw_frames;
> +
> +    /**
> +     * - forbid the fallback to software path in ff_get_format
> +     * - when the hardware init fails. (0 -> disabled)
> +     * - encoding: unused.
> +     * - decoding: Set by user.
> +     */
> +    int fallback_forbid;
>  } AVCodecContext;
>

This is really something user-code should implement, its easy enough
to detect in eg. get_buffer2, and return an error from there.

- Hendrik


More information about the ffmpeg-devel mailing list