On Wed,  4 Jan 2012 15:07:34 +0100, Luca Barbato <lu_z...@gentoo.org> wrote:
> Let pass the codec name to -pixel_format and have the option renamed
> to -input_format.
> ---
>  libavdevice/v4l2.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> index 2895a01..a5bf058 100644
> --- a/libavdevice/v4l2.c
> +++ b/libavdevice/v4l2.c
> @@ -706,11 +706,15 @@ static int v4l2_read_header(AVFormatContext *s1, 
> AVFormatParameters *ap)
>      }
>  
>      if (s->pixel_format) {
> +        AVCodec *codec = avcodec_find_decoder_by_name(s->pixel_format);
> +
> +        if (codec)
> +            s1->video_codec_id = codec->id;
>  
>          pix_fmt = av_get_pix_fmt(s->pixel_format);
>  
> -        if (pix_fmt == PIX_FMT_NONE) {
> -            av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n",
> +        if (pix_fmt == PIX_FMT_NONE && !codec) {
> +            av_log(s1, AV_LOG_ERROR, "No such input format: %s.\n",
>                     s->pixel_format);
>  
>              res = AVERROR(EINVAL);
> @@ -816,7 +820,8 @@ static const AVOption options[] = {
>      { "standard",     "TV standard, used only by analog frame grabber",      
>       OFFSET(standard),     AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0,       
> DEC },
>      { "channel",      "TV channel, used only by frame grabber",              
>       OFFSET(channel),      AV_OPT_TYPE_INT,    {.dbl = 0 },    0, INT_MAX, 
> DEC },
>      { "video_size",   "A string describing frame size, such as 640x480 or 
> hd720.", OFFSET(video_size),   AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,      
>  DEC },
> -    { "pixel_format", "",                                                    
>       OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,       
> DEC },
> +    { "pixel_format", "Preferred pixel format (deprecated)",                 
>       OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,       
> DEC },

I'd keep both functioning for consistency with other demuxers.

> +    { "input_format", "Preferred input format",                              
>       OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,       
> DEC },

Not descriptive enough. It doesn't really tell the user how to use the option.

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to