[Ffmpeg-devel] [PATCH] video4linux2 input

Michael Niedermayer michaelni
Mon Jan 30 18:44:21 CET 2006


Hi

On Mon, Jan 30, 2006 at 03:04:58PM +0100, Luca Abeni wrote:
> Hi all,
> 
> I think my video4linux2 input format is ready for inclusion. It still
> has some unimplemented features (for example, read() and user-pointer
> based input still have to be implemented, and QBUF/DQBUF failures are
> currently not handled) but it works fairly well (for me, it works better
> than the current video4linux input), and I think missing features can be
> added later.
> 
> So, attached are the new v4l2.c file and a patch for ffmpeg CVS (I hope
> I got the configure part right... ;-).
> 
> Changes from the previous version of v4l2.c:
> - removed the crop stuff
> - introduced code to correctly (I hope ;-) set interlaced_frame and top_field_first
> - changed some constants from "#define" to "enum"
> - changed the code to use as many video buffers as possible
> - some cleanups
> 
> If there are problems in the code preventing its inclusion in ffmpeg
> CVS, let me know and I'll do my best to fix them.
[...]
>     enum io_method io_method;
>     int width, height;
>     int frame_rate;
>     int frame_rate_base;
>     int frame_size;
>     int top_field_first;
> 
>     int buffers;
>     void **buf_start;
>     unsigned int *buf_len;
> };
> 
> struct fmt_map {
>     int ff_fmt;

shouldnt this be a enum PixelFormat


[...]
> static uint32_t fmt_ff2v4l(int pix_fmt)

same here


[...]
> static int v4l2_read_header(AVFormatContext *s1, AVFormatParameters *ap)
> {
>     struct video_data *s = s1->priv_data;
>     AVStream *st;
>     int width, height;
>     int res, frame_rate, frame_rate_base;
>     uint32_t desired_format, capabilities;
>     const char *video_device;
> 
>     if (!ap || ap->width <= 0 || ap->height <= 0 || ap->time_base.den <= 0) {
>         av_log(s1, AV_LOG_ERROR, "Missing/Wrong parameters\n");
> 
>         return -1;
>     }
> 
>     width = ap->width;
>     height = ap->height;
>     frame_rate = ap->time_base.den;
>     frame_rate_base = ap->time_base.num;
> 
>     if((unsigned)width > 32767 || (unsigned)height > 32767) {
>         av_log(s1, AV_LOG_ERROR, "Wrong size %dx%d\n", width, height);
> 
>         return -1;
>     }
> 
>     st = av_new_stream(s1, 0);
>     if (!st) {
>         return -ENOMEM;
>     }
>     av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */

why 48 and not 64


[...]

except these minor things it looks ok and can be applied if it works

-- 
Michael





More information about the ffmpeg-devel mailing list