[FFmpeg-devel] PATCH grab.c, adding support for hardware based VIDIOSFPS

Benoit Fouet benoit.fouet
Mon Jun 4 17:06:15 CEST 2007


Hi,

mmh wrote:

[snip]

>  > > @@ -327,9 +336,11 @@
>  > >              }
>  > >              break;
>  > >          }
>  > > -        ts.tv_sec = delay / 1000000;
>  > > -        ts.tv_nsec = (delay % 1000000) * 1000;
>  > > -        nanosleep(&ts, NULL);
>  > > +        if (s->sw_fps_reduction) {
>  > > +            ts.tv_sec = delay / 1000000;
>  > > +            ts.tv_nsec = (delay % 1000000) * 1000;
>  > > +            nanosleep(&ts, NULL);
>  > > +	}
>  > >   
>  > 
>  > and the cosmetics should come as a separate patch
>  > 
>
> Sorry, I don't agree really because the indentation here is part of
> the improvement I don't see it as a cosmetic.
>
>  > >      }
>  > >  
>  > >      if (av_new_packet(pkt, s->frame_size) < 0)
>  > >   
>
>
> This doesn't have the cosmetic removed because you can't see what the
> new functionality is with out it.  I will commit the white space
> separately if the group really wants me to.
>
>   
> ------------------------------------------------------------------------
>
> Index: libavformat/grab.c
> ===================================================================
> --- libavformat/grab.c	(revision 9203)
> +++ libavformat/grab.c	(working copy)
> @@ -28,6 +28,10 @@
>  #include <linux/videodev.h>
>  #include <time.h>
>  
> +#ifndef VIDIOSFPS
> +#define VIDIOSFPS		_IOW('v',BASE_VIDIOCPRIVATE+20, int)			/* Set fps */
> +#endif
> +
>   

if you define it here, there is no need to test if it is defined later
on, as it will always be true...

>  typedef struct {
>      int fd;
>      int frame_format; /* see VIDEO_PALETTE_xxx */
> @@ -35,6 +39,7 @@
>      int width, height;
>      int frame_rate;
>      int frame_rate_base;
> +    int sw_fps_reduction;
>      int64_t time_frame;
>      int frame_size;
>      struct video_capability video_cap;
> @@ -78,6 +83,7 @@
>      VideoData *s = s1->priv_data;
>      AVStream *st;
>      int width, height;
> +    int fps;
>   

this is the place i suggested you ifdef'd:
#ifdef VIDIOSFPS
    int fps
#endif

>      int video_fd, frame_size;
>      int ret, frame_rate, frame_rate_base;
>      int desired_palette, desired_depth;
> @@ -183,6 +189,14 @@
>              goto fail1;
>      }
>  
> +    fps = s->frame_rate / s->frame_rate_base;
> +
> +#ifdef VIDIOSFPS
> +    s->sw_fps_reduction  =  ioctl( video_fd, VIDIOSFPS, &fps ) < 0;
> +#else
> +    s->sw_fps_reduction  =  1;
> +#endif
> +
>   

the else is never reached

>      ret = ioctl(video_fd,VIDIOCGMBUF,&s->gb_buffers);
>      if (ret < 0) {
>          /* try to use read based access */
> @@ -327,9 +341,11 @@
>              }
>              break;
>          }
> -        ts.tv_sec = delay / 1000000;
> -        ts.tv_nsec = (delay % 1000000) * 1000;
> -        nanosleep(&ts, NULL);
> +        if (s->sw_fps_reduction) {
> +            ts.tv_sec = delay / 1000000;
> +            ts.tv_nsec = (delay % 1000000) * 1000;
> +            nanosleep(&ts, NULL);
> +	}
>   

Ben
-- 
Purple Labs S.A.
www.purplelabs.com




More information about the ffmpeg-devel mailing list