v4l2-ctl: fix the field-per-second calculation
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 20 Mar 2013 08:15:57 +0000 (09:15 +0100)
committerHans Verkuil <hans.verkuil@cisco.com>
Wed, 20 Mar 2013 08:15:57 +0000 (09:15 +0100)
The height in the bt_timings struct is the height of the full frame,
so for the fields-per-second calculation the height should be divided
by two.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/v4l2-ctl/v4l2-ctl-stds.cpp

index d39faca..3370132 100644 (file)
@@ -259,10 +259,16 @@ static void print_dv_timings(const struct v4l2_dv_timings *t)
                                (bt->polarities & V4L2_DV_VSYNC_POS_POL) ? '+' : '-',
                                (bt->polarities & V4L2_DV_HSYNC_POS_POL) ? '+' : '-');
                printf("\tPixelclock: %lld Hz", bt->pixelclock);
-               if (bt->width && bt->height)
-                       printf(" (%.2f fields per second)", (double)bt->pixelclock /
+               if (bt->width && bt->height) {
+                       if (bt->interlaced)
+                               printf(" (%.2f fields per second)", (double)bt->pixelclock /
+                                       ((bt->width + bt->hfrontporch + bt->hsync + bt->hbackporch) *
+                                        (bt->height / 2 + bt->vfrontporch + bt->vsync + bt->vbackporch)));
+                       else
+                               printf(" (%.2f frames per second)", (double)bt->pixelclock /
                                        ((bt->width + bt->hfrontporch + bt->hsync + bt->hbackporch) *
                                         (bt->height + bt->vfrontporch + bt->vsync + bt->vbackporch)));
+               }
                printf("\n");
                printf("\tHorizontal frontporch: %d\n", bt->hfrontporch);
                printf("\tHorizontal sync: %d\n", bt->hsync);