[FFmpeg-devel] [PATCH 2/2] lavd/v4l2: list formats supported by a decoder as compressed

Stefano Sabatini stefasab at gmail.com
Mon Jan 28 00:28:35 CET 2013


On date Sunday 2013-01-27 12:17:40 +0100, Stephan Hilb encoded:
> The v4l2 pixel format V4L2_PIX_FMT_CPIA1 is a compressed format and is
> supported through the cpia decoder, but gets listed as "Unsupported"
> because V4L2_FMT_FLAG_COMPRESSED isn't set by the driver.
> 
> Therefore, use the existence of an appropriate decoder as a means of
> judging whether the format is compressed and supported.
> ---
>  libavdevice/v4l2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> index 1bf173d..31705d3 100644
> --- a/libavdevice/v4l2.c
> +++ b/libavdevice/v4l2.c
> @@ -353,13 +353,13 @@ static void list_formats(AVFormatContext *ctx, int fd, int type)
>  
>          vfd.index++;
>  
> -        if (!(vfd.flags & V4L2_FMT_FLAG_COMPRESSED) &&

> +        if (!(vfd.flags & V4L2_FMT_FLAG_COMPRESSED) && !codec_id &&

The condition could be factorized.

>              type & V4L_RAWFORMATS) {
>              const char *fmt_name = av_get_pix_fmt_name(pix_fmt);
>              av_log(ctx, AV_LOG_INFO, "Raw       : %9s : %20s :",
>                     fmt_name ? fmt_name : "Unsupported",
>                     vfd.description);
> -        } else if (vfd.flags & V4L2_FMT_FLAG_COMPRESSED &&
> +        } else if ((vfd.flags & V4L2_FMT_FLAG_COMPRESSED || codec_id) &&
>                     type & V4L_COMPFORMATS) {

I don't think this is correct, since for example I got rawvideo listed
as compressed. Basically "compressed" and "uncompressed" are V4L
concepts, which make no much sense in the libav* space (and I tend to
dislike the somehow arbitrary distinction made in the list_formats
code, which doesn't map well with libav* internals), but maybe we can
find some clever way to cope with it.
-- 
FFmpeg = Fast Fiendish Mind-dumbing Perennial Erroneous Gem


More information about the ffmpeg-devel mailing list