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

Stephan Hilb stephan at ecshi.net
Sun Jan 27 12:17:40 CET 2013


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 &&
             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) {
             AVCodec *codec = avcodec_find_decoder(codec_id);
             av_log(ctx, AV_LOG_INFO, "Compressed: %9s : %20s :",
-- 
1.8.1.1



More information about the ffmpeg-devel mailing list