qv4l2/v4l2-ctl: add support for 14x9 video aspect ratio.
authorHans Verkuil <hans.verkuil@cisco.com>
Fri, 8 Aug 2014 08:34:26 +0000 (10:34 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Fri, 8 Aug 2014 08:34:26 +0000 (10:34 +0200)
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/qv4l2/tpg-tab.cpp
utils/v4l2-ctl/v4l2-ctl-streaming.cpp
utils/v4l2-ctl/vivid-tpg.c
utils/v4l2-ctl/vivid-tpg.h

index 2b69d63..8ef1bbe 100644 (file)
@@ -102,6 +102,7 @@ void ApplicationWindow::addTpgTab(int m_winWidth)
        combo = new QComboBox(w);
        combo->addItem("Source Width x Height");
        combo->addItem("4x3");
+       combo->addItem("14x9");
        combo->addItem("16x9");
        combo->addItem("16x9 Anamorphic");
        addWidget(grid, combo);
index 60905fe..1c901bb 100644 (file)
@@ -97,7 +97,7 @@ void streaming_usage(void)
               "                     <aspect> can be one of: square, ntsc, pal\n"
               "  --stream-out-video-aspect=<aspect\n"
               "                     select a video aspect ratio. The default is to use the frame ratio.\n"
-              "                     <aspect> can be one of: 4x3, 16x9, anamorphic\n"
+              "                     <aspect> can be one of: 4x3, 14x9, 16x9, anamorphic\n"
               "  --stream-out-alpha=<alpha-value>\n"
               "                     value to use for the alpha component, range 0-255. The default is 0.\n"
               "  --stream-out-alpha-red-only\n"
@@ -318,6 +318,8 @@ void streaming_cmd(int ch, char *optarg)
        case OptStreamOutVideoAspect:
                if (!strcmp(optarg, "4x3"))
                        stream_out_video_aspect = TPG_VIDEO_ASPECT_4X3;
+               else if (!strcmp(optarg, "14x9"))
+                       stream_out_video_aspect = TPG_VIDEO_ASPECT_14X9_CENTRE;
                else if (!strcmp(optarg, "16x9"))
                        stream_out_video_aspect = TPG_VIDEO_ASPECT_16X9_CENTRE;
                else if (!strcmp(optarg, "anamorphic"))
index 5bb60c5..13b6e5f 100644 (file)
@@ -50,6 +50,7 @@ const char * const tpg_pattern_strings[] = {
 const char * const tpg_aspect_strings[] = {
        "Source Width x Height",
        "4x3",
+       "14x9",
        "16x9",
        "16x9 Anamorphic",
        NULL
@@ -832,6 +833,22 @@ static void tpg_calculate_square_border(struct tpg_data *tpg)
                tpg->border.height = ((3 * w) / 4) & ~1;
                tpg->border.top = (h - tpg->border.height) / 2;
                break;
+       case TPG_VIDEO_ASPECT_14X9_CENTRE:
+               if (tpg->pix_aspect) {
+                       tpg->border.height = tpg->pix_aspect == TPG_PIXEL_ASPECT_NTSC ? 420 : 506;
+                       tpg->border.top = (h - tpg->border.height) / 2;
+                       break;
+               }
+               if (9 * w >= 14 * h) {
+                       tpg->border.width = ((14 * h) / 9) & ~1;
+                       if (((w - tpg->border.width) / 2) & ~1)
+                               tpg->border.width -= 2;
+                       tpg->border.left = (w - tpg->border.width) / 2;
+                       break;
+               }
+               tpg->border.height = ((9 * w) / 14) & ~1;
+               tpg->border.top = (h - tpg->border.height) / 2;
+               break;
        case TPG_VIDEO_ASPECT_16X9_CENTRE:
                if (tpg->pix_aspect) {
                        tpg->border.height = tpg->pix_aspect == TPG_PIXEL_ASPECT_NTSC ? 368 : 442;
index 8ca49e4..1ac8039 100644 (file)
@@ -92,6 +92,7 @@ enum tpg_quality {
 enum tpg_video_aspect {
        TPG_VIDEO_ASPECT_IMAGE,
        TPG_VIDEO_ASPECT_4X3,
+       TPG_VIDEO_ASPECT_14X9_CENTRE,
        TPG_VIDEO_ASPECT_16X9_CENTRE,
        TPG_VIDEO_ASPECT_16X9_ANAMORPHIC,
 };