LegacyCamera: Fix build in ISO C++11 mode
Fixes building with -std=gnu++11 - this is useful for compatibility
with future compilers (where gnu++11 will be the default mode) and
to make additional language features/optimizations (e.g. constexpr)
available.
Change-Id: I4b0bd843731370e205c8bef4a313e7244d2ca5de
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
diff --git a/jni/feature_mos/src/mosaic/AlignFeatures.h b/jni/feature_mos/src/mosaic/AlignFeatures.h
index 19f3905..f003c6a 100644
--- a/jni/feature_mos/src/mosaic/AlignFeatures.h
+++ b/jni/feature_mos/src/mosaic/AlignFeatures.h
@@ -29,30 +29,34 @@
#include "ImageUtils.h"
#include "MatrixUtils.h"
+#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(constexpr)
+#define constexpr const
+#endif
+
class Align {
public:
// Types of alignment possible
- static const int ALIGN_TYPE_PAN = 1;
+ static constexpr int ALIGN_TYPE_PAN = 1;
// Return codes
- static const int ALIGN_RET_LOW_TEXTURE = -2;
- static const int ALIGN_RET_ERROR = -1;
- static const int ALIGN_RET_OK = 0;
- static const int ALIGN_RET_FEW_INLIERS = 1;
+ static constexpr int ALIGN_RET_LOW_TEXTURE = -2;
+ static constexpr int ALIGN_RET_ERROR = -1;
+ static constexpr int ALIGN_RET_OK = 0;
+ static constexpr int ALIGN_RET_FEW_INLIERS = 1;
///// Settings for feature-based alignment
// Number of features to use from corner detection
- static const int DEFAULT_NR_CORNERS=750;
- static const double DEFAULT_MAX_DISPARITY=0.1;//0.4;
+ static constexpr int DEFAULT_NR_CORNERS=750;
+ static constexpr double DEFAULT_MAX_DISPARITY=0.1;//0.4;
// Type of homography to model
- static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_R_T;
+ static constexpr int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_R_T;
// static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_PROJECTIVE;
// static const int DEFAULT_MOTION_MODEL=DB_HOMOGRAPHY_TYPE_AFFINE;
- static const unsigned int DEFAULT_REFERENCE_UPDATE_PERIOD=1500; // Manual reference frame update so set this to a large number
+ static constexpr unsigned int DEFAULT_REFERENCE_UPDATE_PERIOD=1500; // Manual reference frame update so set this to a large number
- static const int MIN_NR_REF_CORNERS = 25;
- static const int MIN_NR_INLIERS = 10;
+ static constexpr int MIN_NR_REF_CORNERS = 25;
+ static constexpr int MIN_NR_INLIERS = 10;
Align();
~Align();
diff --git a/jni/feature_mos/src/mosaic/Blend.h b/jni/feature_mos/src/mosaic/Blend.h
index 6371fde..dfc9afa 100644
--- a/jni/feature_mos/src/mosaic/Blend.h
+++ b/jni/feature_mos/src/mosaic/Blend.h
@@ -28,24 +28,28 @@
#define BLEND_RANGE_DEFAULT 6
#define BORDER 8
+#if __cplusplus < 201103L && !defined(__GXX_EXPERIMENTAL_CXX0X__) && !defined(constexpr)
+#define constexpr const
+#endif
+
// Percent of total mosaicing time spent on each of the following operations
-const float TIME_PERCENT_ALIGN = 20.0;
-const float TIME_PERCENT_BLEND = 75.0;
-const float TIME_PERCENT_FINAL = 5.0;
+constexpr float TIME_PERCENT_ALIGN = 20.0;
+constexpr float TIME_PERCENT_BLEND = 75.0;
+constexpr float TIME_PERCENT_FINAL = 5.0;
// This threshold determines the minimum separation between the image centers
// of the input image frames for them to be accepted for blending in the
// STRIP_TYPE_WIDE mode.
-const float STRIP_SEPARATION_THRESHOLD_PXLS = 10;
+constexpr float STRIP_SEPARATION_THRESHOLD_PXLS = 10;
// This threshold determines the number of pixels on either side of the strip
// to cross-fade using the images contributing to each seam.
-const float STRIP_CROSS_FADE_WIDTH_PXLS = 2;
+constexpr float STRIP_CROSS_FADE_WIDTH_PXLS = 2;
// This specifies the maximum pyramid level to which cross-fading is applied.
// The original image resolution is Level-0, half of that size is Level-1 and
// so on. BLEND_RANGE_DEFAULT specifies the number of pyramid levels used by
// the blending algorithm.
-const int STRIP_CROSS_FADE_MAX_PYR_LEVEL = 2;
+constexpr int STRIP_CROSS_FADE_MAX_PYR_LEVEL = 2;
/**
* Class for pyramid blending a mosaic.
@@ -54,19 +58,19 @@
public:
- static const int BLEND_TYPE_NONE = -1;
- static const int BLEND_TYPE_FULL = 0;
- static const int BLEND_TYPE_PAN = 1;
- static const int BLEND_TYPE_CYLPAN = 2;
- static const int BLEND_TYPE_HORZ = 3;
+ static constexpr int BLEND_TYPE_NONE = -1;
+ static constexpr int BLEND_TYPE_FULL = 0;
+ static constexpr int BLEND_TYPE_PAN = 1;
+ static constexpr int BLEND_TYPE_CYLPAN = 2;
+ static constexpr int BLEND_TYPE_HORZ = 3;
- static const int STRIP_TYPE_THIN = 0;
- static const int STRIP_TYPE_WIDE = 1;
+ static constexpr int STRIP_TYPE_THIN = 0;
+ static constexpr int STRIP_TYPE_WIDE = 1;
- static const int BLEND_RET_ERROR = -1;
- static const int BLEND_RET_OK = 0;
- static const int BLEND_RET_ERROR_MEMORY = 1;
- static const int BLEND_RET_CANCELLED = -2;
+ static constexpr int BLEND_RET_ERROR = -1;
+ static constexpr int BLEND_RET_OK = 0;
+ static constexpr int BLEND_RET_ERROR_MEMORY = 1;
+ static constexpr int BLEND_RET_CANCELLED = -2;
Blend();
~Blend();
@@ -119,8 +123,8 @@
void CropFinalMosaic(YUVinfo &imgMos, MosaicRect &cropping_rect);
private:
- static const float LIMIT_SIZE_MULTIPLIER = 5.0f * 2.0f;
- static const float LIMIT_HEIGHT_MULTIPLIER = 2.5f;
+ static constexpr float LIMIT_SIZE_MULTIPLIER = 5.0f * 2.0f;
+ static constexpr float LIMIT_HEIGHT_MULTIPLIER = 2.5f;
int MosaicSizeCheck(float sizeMultiplier, float heightMultiplier);
};
diff --git a/jni/feature_mos/src/mosaic/ImageUtils.cpp b/jni/feature_mos/src/mosaic/ImageUtils.cpp
index 6d0aac0..318df54 100644
--- a/jni/feature_mos/src/mosaic/ImageUtils.cpp
+++ b/jni/feature_mos/src/mosaic/ImageUtils.cpp
@@ -283,7 +283,7 @@
FILE *imgin = NULL;
int mval=0, format=0, eret;
- ImageType ret = IMAGE_TYPE_NOIMAGE;
+ ImageType ret = (ImageType)IMAGE_TYPE_NOIMAGE;
imgin = fopen(filename, "r");
if (imgin == NULL) {
diff --git a/jni/feature_mos_jni.cpp b/jni/feature_mos_jni.cpp
index e40b75a..9e1b2d5 100644
--- a/jni/feature_mos_jni.cpp
+++ b/jni/feature_mos_jni.cpp
@@ -47,8 +47,8 @@
ImageType tImage[NR][MAX_FRAMES];// = {{ImageUtils::IMAGE_TYPE_NOIMAGE}}; // YVU24 format image
Mosaic *mosaic[NR] = {NULL,NULL};
-ImageType resultYVU = ImageUtils::IMAGE_TYPE_NOIMAGE;
-ImageType resultBGR = ImageUtils::IMAGE_TYPE_NOIMAGE;
+ImageType resultYVU = (ImageType)ImageUtils::IMAGE_TYPE_NOIMAGE;
+ImageType resultBGR = (ImageType)ImageUtils::IMAGE_TYPE_NOIMAGE;
float gTRS[11]; // 9 elements of the transformation, 1 for frame-number, 1 for alignment error code.
// Variables to keep track of the mosaic computation progress for both LR & HR.
float gProgress[NR];