DngCreator: Improve black level support; avoid large stack allocation
- Switch the BlackLevel entry to be RATIONAL
- Switch to heap allocation instead of stack allocation for lens
shading map construction
- Add orientation enums for convenience
Bug: 25862995
Bug: 27073274
Change-Id: I7031a33c4797dc8b2c8030d26b749066e03bff9e
diff --git a/media/img_utils/include/img_utils/TagDefinitions.h b/media/img_utils/include/img_utils/TagDefinitions.h
index e9a7480..1cc9866 100644
--- a/media/img_utils/include/img_utils/TagDefinitions.h
+++ b/media/img_utils/include/img_utils/TagDefinitions.h
@@ -193,6 +193,18 @@
};
/**
+ * Convenience values for tags with enumerated values
+ */
+
+enum {
+ TAG_ORIENTATION_NORMAL = 1,
+ TAG_ORIENTATION_ROTATE_180 = 3,
+ TAG_ORIENTATION_ROTATE_90 = 6,
+ TAG_ORIENTATION_ROTATE_270 = 8,
+ TAG_ORIENTATION_UNKNOWN = 9
+};
+
+/**
* TIFF_EP_TAG_DEFINITIONS contains tags defined in the TIFF EP spec
*/
const TagDefinition_t TIFF_EP_TAG_DEFINITIONS[] = {
@@ -731,7 +743,7 @@
{ // BlackLevel
"BlackLevel",
0xC61Au,
- LONG,
+ RATIONAL,
RAW_IFD,
0,
UNDEFINED_ENDIAN
diff --git a/media/img_utils/src/DngUtils.cpp b/media/img_utils/src/DngUtils.cpp
index 9473dce..9dc5f05 100644
--- a/media/img_utils/src/DngUtils.cpp
+++ b/media/img_utils/src/DngUtils.cpp
@@ -18,6 +18,7 @@
#include <inttypes.h>
+#include <vector>
#include <math.h>
namespace android {
@@ -63,10 +64,17 @@
double spacingV = 1.0 / lsmHeight;
double spacingH = 1.0 / lsmWidth;
- float redMap[lsmWidth * lsmHeight];
- float greenEvenMap[lsmWidth * lsmHeight];
- float greenOddMap[lsmWidth * lsmHeight];
- float blueMap[lsmWidth * lsmHeight];
+ std::vector<float> redMapVector(lsmWidth * lsmHeight);
+ float *redMap = redMapVector.data();
+
+ std::vector<float> greenEvenMapVector(lsmWidth * lsmHeight);
+ float *greenEvenMap = greenEvenMapVector.data();
+
+ std::vector<float> greenOddMapVector(lsmWidth * lsmHeight);
+ float *greenOddMap = greenOddMapVector.data();
+
+ std::vector<float> blueMapVector(lsmWidth * lsmHeight);
+ float *blueMap = blueMapVector.data();
size_t lsmMapSize = lsmWidth * lsmHeight * 4;