aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOve Brynestad <ovebryne@cisco.com>2014-08-07 12:58:39 +0200
committerHans Verkuil <hans.verkuil@cisco.com>2014-08-08 11:13:03 +0200
commitae1dee94de5f4a496e74be67681320aab9abd020 (patch)
tree514a99ff6c52966d2b6e88d2b5cbe270f06e9ff6
parent3851b2fb91fc6867f01149b4c5bb824324ba3d69 (diff)
qv4l2: Fixed cropping bug
Pillar/letterboxing was assumed given by m_cropMethod, but is also depending on pixelAspectRatio and frame aspect ratio Signed-off-by: Ove Brynestad <ovebryne@cisco.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--utils/qv4l2/capture-win.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/utils/qv4l2/capture-win.cpp b/utils/qv4l2/capture-win.cpp
index 82431cd1..66bfa249 100644
--- a/utils/qv4l2/capture-win.cpp
+++ b/utils/qv4l2/capture-win.cpp
@@ -128,28 +128,36 @@ QSize CaptureWin::cropSize(QSize size)
QSize croppedSize = size;
double realWidth = size.width() * m_pixelAspectRatio;
double realHeight = size.height() / m_pixelAspectRatio;
+ double aspectRatio = 1;
switch (m_cropMethod) {
case QV4L2_CROP_P43:
- croppedSize.setWidth(realHeight * 4.0 / 3.0);
+ aspectRatio = 4.0 / 3.0;
break;
case QV4L2_CROP_W149:
- croppedSize.setHeight(realWidth / (14.0 / 9.0));
+ aspectRatio = 14.0 / 9.0;
break;
case QV4L2_CROP_W169:
- croppedSize.setHeight(realWidth / (16.0 / 9.0));
+ aspectRatio = 16.0 / 9.0;
break;
case QV4L2_CROP_C185:
- croppedSize.setHeight(realWidth / 1.85);
+ aspectRatio = 1.85;
break;
case QV4L2_CROP_C239:
- croppedSize.setHeight(realWidth / 2.39);
+ aspectRatio = 2.39;
break;
case QV4L2_CROP_TB:
croppedSize.setHeight(size.height() - 2);
break;
default:
- ; // No cropping
+ break; // No cropping
+ }
+
+ if ((m_cropMethod != QV4L2_CROP_TB) && (m_cropMethod != QV4L2_CROP_NONE)) {
+ if (realWidth / size.height() < aspectRatio)
+ croppedSize.setHeight(realWidth / aspectRatio);
+ else
+ croppedSize.setWidth(realHeight * aspectRatio);
}
if (croppedSize.width() < MIN_WIN_SIZE_WIDTH || croppedSize.width() >= size.width())

Privacy Policy