On 2011-12-29 17:29:17 +0100, Luca Barbato wrote:
> Video4linux2 supports both interlaced and non-interlaced mode, do not
> ask for interlaced if not necessary.
> ---
> libavdevice/v4l2.c | 10 ++++++++--
> 1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
> index eb16171..a9e32bb 100644
> --- a/libavdevice/v4l2.c
> +++ b/libavdevice/v4l2.c
> @@ -64,6 +64,7 @@ struct video_data {
> enum io_method io_method;
> int width, height;
> int frame_size;
> + int interlaced;
> int top_field_first;
>
> int buffers;
> @@ -162,7 +163,7 @@ static int device_init(AVFormatContext *ctx, int *width,
> int *height, uint32_t p
> fmt.fmt.pix.width = *width;
> fmt.fmt.pix.height = *height;
> fmt.fmt.pix.pixelformat = pix_fmt;
> - fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
> + fmt.fmt.pix.field = V4L2_FIELD_ANY;
> res = ioctl(fd, VIDIOC_S_FMT, &fmt);
> if ((*width != fmt.fmt.pix.width) || (*height != fmt.fmt.pix.height)) {
> av_log(ctx, AV_LOG_INFO, "The V4L2 driver changed the video from
> %dx%d to %dx%d\n", *width, *height, fmt.fmt.pix.width, fmt.fmt.pix.height);
> @@ -175,6 +176,11 @@ static int device_init(AVFormatContext *ctx, int *width,
> int *height, uint32_t p
> res = -1;
> }
>
> + if (fmt.fmt.pix.field == V4L2_FIELD_INTERLACED) {
> + av_log(ctx, AV_LOG_DEBUG, "The V4L2 driver using the interlaced
> mode");
> + s->interlaced = 1;
> + }
I still think it would be a good idea to check if one of the strange
interlaced modes V4L2 supports is returned. I don't trust all drivers
to use something sane with V4L2_FIELD_ANY.
Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel