On Thu, 11 Sep 2014 18:08:12 +0300, =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= 
<[email protected]> wrote:
> This allows the application to fall back on another hwaccel or more
> likely on software decoding.
> ---
>  libavcodec/utils.c | 47 +++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 37 insertions(+), 10 deletions(-)
> 

The concept itself is looks ok, but it should probably be documented somewhere.

> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index c5fa50d..600854e 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -902,11 +902,26 @@ static AVHWAccel *find_hwaccel(enum AVCodecID codec_id,
>  int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
>  {
>      const AVPixFmtDescriptor *desc;
> -    enum AVPixelFormat ret = avctx->get_format(avctx, fmt);
> +    enum AVPixelFormat *choices;
> +    enum AVPixelFormat ret;
> +    unsigned n = 0;
> +
> +    while (fmt[n] != AV_PIX_FMT_NONE)
> +        ++n;
> +
> +    choices = av_malloc(++n * sizeof(*choices));

nit: IMO it'd be clearer to initialize n to 1; also, av_malloc_array is probably
     appropriate

> +    if (choices == NULL)
> +        return AV_PIX_FMT_NONE;
> +
> +    memcpy(choices, fmt, n * sizeof(*choices));
> +retry:

Ugh, a backward goto. I think it'd be much cleaner to put this in a proper loop,
with the body split off into a separate function.

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to