From: Hans Verkuil Date: Fri, 4 Oct 2013 08:43:27 +0000 (+0200) Subject: qv4l2: crop: take pixel aspect ratio into account. X-Git-Tag: v4l-utils-1.2.0~385 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a526ea4a25a0f9e009b8f8636a84ffc31f01ed1;p=platform%2Fupstream%2Fv4l-utils.git qv4l2: crop: take pixel aspect ratio into account. When cropping to a desired letterboxed/pillarboxed picture ratio you need to take the pixel aspect ratio into account as well. Also use 4.0/3.0 instead of 1.33 due to rounding errors (ditto for 1.57 and 1.78). Finally the pillarbox ratio was calculated the wrong way around. Signed-off-by: Hans Verkuil --- diff --git a/utils/qv4l2/capture-win.cpp b/utils/qv4l2/capture-win.cpp index 49cb3be..74581e4 100644 --- a/utils/qv4l2/capture-win.cpp +++ b/utils/qv4l2/capture-win.cpp @@ -80,20 +80,21 @@ void CaptureWin::resetSize() int CaptureWin::cropHeight(int width, int height) { + double realWidth = width * m_pixelAspectRatio; int validHeight; switch (m_cropMethod) { case QV4L2_CROP_W149: - validHeight = (int)(width / 1.57); + validHeight = realWidth / (14.0 / 9.0); break; case QV4L2_CROP_W169: - validHeight = (int)(width / 1.78); + validHeight = realWidth / (16.0 / 9.0); break; case QV4L2_CROP_C185: - validHeight = (int)(width / 1.85); + validHeight = realWidth / 1.85; break; case QV4L2_CROP_C239: - validHeight = (int)(width / 2.39); + validHeight = realWidth / 2.39; break; case QV4L2_CROP_TB: validHeight = height - 2; @@ -113,7 +114,7 @@ int CaptureWin::cropWidth(int width, int height) if (m_cropMethod != QV4L2_CROP_P43) return 0; - int validWidth = (int)(height / 1.33); + int validWidth = (height * 4.0 / 3.0) / m_pixelAspectRatio; if (validWidth < MIN_WIN_SIZE_WIDTH || validWidth >= width) return 0; diff --git a/utils/qv4l2/general-tab.cpp b/utils/qv4l2/general-tab.cpp index be33463..a0bc75f 100644 --- a/utils/qv4l2/general-tab.cpp +++ b/utils/qv4l2/general-tab.cpp @@ -152,11 +152,11 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) m_crop = new QComboBox(parent); m_crop->addItem("None"); m_crop->addItem("Top and Bottom Line"); - m_crop->addItem("Widescreen 14:9"); - m_crop->addItem("Widescreen 16:9"); - m_crop->addItem("Cinema 1.85:1"); - m_crop->addItem("Cinema 2.39:1"); - m_crop->addItem("Traditional 4:3"); + m_crop->addItem("Widescreen 14:9 (Letterbox)"); + m_crop->addItem("Widescreen 16:9 (Letterbox)"); + m_crop->addItem("Cinema 1.85:1 (Letterbox)"); + m_crop->addItem("Cinema 2.39:1 (Letterbox)"); + m_crop->addItem("Traditional 4:3 (Pillarbox)"); addLabel("Cropping"); addWidget(m_crop);