[FFmpeg-devel] [PATCH] lavfi/vf_scale_cuda: Add format option

Timo Rothenpieler timo at rothenpieler.org
Fri May 24 16:00:35 EEST 2019


On 24/05/2019 01:49, Josh Allmann wrote:
> Makes certain usages of the lavfi API easier.
> ---
>   libavfilter/vf_scale_cuda.c | 12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
> index b7cdb81081..6b1ef2bb6f 100644
> --- a/libavfilter/vf_scale_cuda.c
> +++ b/libavfilter/vf_scale_cuda.c
> @@ -81,6 +81,7 @@ typedef struct CUDAScaleContext {
>   
>       char *w_expr;               ///< width  expression string
>       char *h_expr;               ///< height expression string
> +    char *format_str;
>   
>       CUcontext   cu_ctx;
>       CUmodule    cu_module;
> @@ -101,7 +102,15 @@ static av_cold int cudascale_init(AVFilterContext *ctx)
>   {
>       CUDAScaleContext *s = ctx->priv;
>   
> -    s->format = AV_PIX_FMT_NONE;
> +    if (!strcmp(s->format_str, "same")) {
> +        s->format = AV_PIX_FMT_NONE;
> +    } else {
> +        s->format = av_get_pix_fmt(s->format_str);
> +        if (s->format == AV_PIX_FMT_NONE) {
> +            av_log(ctx, AV_LOG_ERROR, "Unrecognized pixel format: %s\n", s->format_str);
> +            return AVERROR(EINVAL);
> +        }
> +    }
>       s->frame = av_frame_alloc();
>       if (!s->frame)
>           return AVERROR(ENOMEM);
> @@ -533,6 +542,7 @@ fail:
>   static const AVOption options[] = {
>       { "w",      "Output video width",  OFFSET(w_expr),     AV_OPT_TYPE_STRING, { .str = "iw"   }, .flags = FLAGS },
>       { "h",      "Output video height", OFFSET(h_expr),     AV_OPT_TYPE_STRING, { .str = "ih"   }, .flags = FLAGS },
> +    { "format", "Output pixel format", OFFSET(format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
>       { NULL },
>   };

I'm not sure what to think about a dummy option like this. It might be 
very confusing for users to see a format option, which only accepts a 
single value, "same", and effectively does nothing.

Not strictly against it, since I can see the convenience it adds when 
building command lines, but I'd like some second opinions on this.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4538 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190524/d8f814ff/attachment.bin>


More information about the ffmpeg-devel mailing list