Re: [MPlayer-dev-eng] [PATCH] fix v4l2 free_demuxer crash - uvcvideo
- Date: Tue, 24 Jun 2008 23:16:06 +0200
- From: Jindrich Makovicka <makovick@xxxxxxxxx>
- Subject: Re: [MPlayer-dev-eng] [PATCH] fix v4l2 free_demuxer crash - uvcvideo
On Fri, 6 Jun 2008 18:38:05 +0200
Ötvös Attila <dc@xxxxxxxxx> wrote:
> Ezzel a dátummal: Friday 30 May 2008 13.28.33 Vladimir Voroshilov ezt
> írta:
>
> Hi Vladimir Voroshilov!
>
> >
> > if (ioctl(priv->video_fd, VIDIOC_G_STD, &id) < 0) {
[...]
> >
> > And the rest of your patch is not needed.
> >
> > P.S. i didn't test code above.
> > P.P.S i don't know how much "hackish" is either my or your solution.
>
> I tested. It work.
Nevertheless, it would still be nice to have some fallback when the fps
is really unknown. getfps() in the attachment should be consistent with
the fallback code in tv.c.
Regards,
--
Jindrich Makovicka
Index: tvi_v4l2.c
===================================================================
--- tvi_v4l2.c (revision 27133)
+++ tvi_v4l2.c (working copy)
@@ -336,13 +336,23 @@
}
+/*
+** Get current FPS.
+*/
+static double getfps(priv_t *priv)
+{
+ if (priv->tv_param->fps > 0)
+ return priv->tv_param->fps;
+ if (priv->standard.frameperiod.denominator && priv->standard.frameperiod.numerator)
+ return (double)priv->standard.frameperiod.denominator / priv->standard.frameperiod.numerator;
+ return 25.0;
+}
+
// sets and sanitizes audio buffer/block sizes
static void setup_audio_buffer_sizes(priv_t *priv)
{
int bytes_per_sample = priv->audio_in.bytes_per_sample;
- double fps = (double)priv->standard.frameperiod.denominator /
- priv->standard.frameperiod.numerator;
- int seconds = priv->video_buffer_size_max/fps;
+ int seconds = priv->video_buffer_size_max/getfps(priv);
if (seconds < 5) seconds = 5;
if (seconds > 500) seconds = 500;
@@ -438,9 +448,22 @@
int i=0;
if (ioctl(priv->video_fd, VIDIOC_G_STD, &id) < 0) {
- mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get standard failed: %s\n",
- info.short_name, strerror(errno));
- return -1;
+ struct v4l2_streamparm parm;
+
+ /* Here is comment why ioctl below is required bla-bla-bla */
+ parm.type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if(ioctl(priv->video_fd, VIDIOC_G_PARM, &parm) >= 0) {
+ mp_msg(MSGT_TV, MSGL_WARN, "%s: your device driver does not support VIDIOC_G_STD ioctl,"
+ " VIDIOC_G_PARM was used instead.\n", info.short_name);
+ priv->standard.index=0;
+ priv->standard.id=0;
+ priv->standard.frameperiod=parm.parm.capture.timeperframe;
+ return 0;
+ }
+
+ mp_msg(MSGT_TV, MSGL_ERR, "%s: ioctl get standard failed: %s\n",
+ info.short_name, strerror(errno));
+ return -1;
}
do {
priv->standard.index = i++;
@@ -701,11 +724,15 @@
priv->immediate_mode = 1;
return TVI_CONTROL_TRUE;
case TVI_CONTROL_VID_GET_FPS:
- *(float *)arg = (float)priv->standard.frameperiod.denominator /
- priv->standard.frameperiod.numerator;
- mp_msg(MSGT_TV, MSGL_V, "%s: get fps: %f\n", info.short_name,
- *(float *)arg);
- return TVI_CONTROL_TRUE;
+ if (priv->standard.frameperiod.denominator && priv->standard.frameperiod.numerator) {
+ *(float *)arg = (float)priv->standard.frameperiod.denominator /
+ priv->standard.frameperiod.numerator;
+ mp_msg(MSGT_TV, MSGL_V, "%s: get fps: %f\n", info.short_name,
+ *(float *)arg);
+ return TVI_CONTROL_TRUE;
+ }
+ mp_msg(MSGT_TV, MSGL_ERR, "%s: Cannot get fps\n", info.short_name);
+ return TVI_CONTROL_FALSE;
case TVI_CONTROL_VID_GET_BITS:
if (getfmt(priv) < 0) return TVI_CONTROL_FALSE;
*(int *)arg = pixfmt2depth(priv->format.fmt.pix.pixelformat);
@@ -1087,13 +1114,9 @@
if (priv->streamon) {
struct v4l2_buffer buf;
-
+
/* get performance */
- frames = 1 + (priv->curr_frame - priv->first_frame +
- priv->standard.frameperiod.numerator * 500000 /
- priv->standard.frameperiod.denominator) *
- priv->standard.frameperiod.denominator /
- priv->standard.frameperiod.numerator / 1000000;
+ frames = 1 + lrintf((double)(priv->curr_frame - priv->first_frame) / (1e6 * getfps(priv)));
dropped = frames - priv->frames;
/* turn off streaming */
_______________________________________________
MPlayer-dev-eng mailing list
MPlayer-dev-eng@xxxxxxxxxxxx
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng