summaryrefslogtreecommitdiffstats
path: root/jni
diff options
context:
space:
mode:
authorWei-Ta Chen <weita@google.com>2011-09-30 18:08:38 -0700
committerWei-Ta Chen <weita@google.com>2011-10-03 10:41:55 -0700
commit317e8c783928e5eddfa7af260218dc36bb47a826 (patch)
tree0f1f1c48bc2109ed02d49f46d439e676d65743f4 /jni
parent575b49275691f5b539fe2c6dfde1741645dc3e93 (diff)
downloadLegacyCamera-317e8c783928e5eddfa7af260218dc36bb47a826.zip
LegacyCamera-317e8c783928e5eddfa7af260218dc36bb47a826.tar.gz
LegacyCamera-317e8c783928e5eddfa7af260218dc36bb47a826.tar.bz2
Reduce the frame memory we allocate.
We increment the LR frame counter and the HR frame counter at the same time and check the frame limit condition based on which counter hits the limit first. We can just combine the MAX_FRAMES_HR and MAX_FRAMES_LR to one. This reduces the memory we allocate to LR frames by 8~20 MBytes depending on the size of an input frame. Change-Id: I1b76d94db09985df21c946830295b94f39e99e59
Diffstat (limited to 'jni')
-rw-r--r--jni/feature_mos_jni.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/jni/feature_mos_jni.cpp b/jni/feature_mos_jni.cpp
index db9fd7d..e3fdea5 100644
--- a/jni/feature_mos_jni.cpp
+++ b/jni/feature_mos_jni.cpp
@@ -38,15 +38,14 @@ extern "C" {
char buffer[1024];
-const int MAX_FRAMES_HR = 100;
-const int MAX_FRAMES_LR = 200;
+const int MAX_FRAMES = 100;
static double mTx;
int tWidth[NR];
int tHeight[NR];
-ImageType tImage[NR][MAX_FRAMES_LR];// = {{ImageUtils::IMAGE_TYPE_NOIMAGE}}; // YVU24 format image
+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;
@@ -283,13 +282,10 @@ JNIEXPORT void JNICALL Java_com_android_camera_panorama_Mosaic_allocateMosaicMem
tWidth[LR] = int(width / H2L_FACTOR);
tHeight[LR] = int(height / H2L_FACTOR);
- for(int i=0; i<MAX_FRAMES_LR; i++)
+ for(int i=0; i<MAX_FRAMES; i++)
{
tImage[LR][i] = ImageUtils::allocateImage(tWidth[LR], tHeight[LR],
ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
- }
- for(int i=0; i<MAX_FRAMES_HR; i++)
- {
tImage[HR][i] = ImageUtils::allocateImage(tWidth[HR], tHeight[HR],
ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
}
@@ -300,12 +296,9 @@ JNIEXPORT void JNICALL Java_com_android_camera_panorama_Mosaic_allocateMosaicMem
JNIEXPORT void JNICALL Java_com_android_camera_panorama_Mosaic_freeMosaicMemory(
JNIEnv* env, jobject thiz)
{
- for(int i = 0; i < MAX_FRAMES_LR; i++)
+ for(int i = 0; i < MAX_FRAMES; i++)
{
ImageUtils::freeImage(tImage[LR][i]);
- }
- for(int i = 0; i < MAX_FRAMES_HR; i++)
- {
ImageUtils::freeImage(tImage[HR][i]);
}
@@ -375,7 +368,7 @@ JNIEXPORT jfloatArray JNICALL Java_com_android_camera_panorama_Mosaic_setSourceI
t0 = now_ms();
int ret_code;
- if(frame_number_HR<MAX_FRAMES_HR && frame_number_LR<MAX_FRAMES_LR)
+ if(frame_number_HR<MAX_FRAMES && frame_number_LR<MAX_FRAMES)
{
double last_tx = mTx;
@@ -428,7 +421,7 @@ JNIEXPORT jfloatArray JNICALL Java_com_android_camera_panorama_Mosaic_setSourceI
int ret_code;
- if(frame_number_HR<MAX_FRAMES_HR && frame_number_LR<MAX_FRAMES_LR)
+ if(frame_number_HR<MAX_FRAMES && frame_number_LR<MAX_FRAMES)
{
jbyte *pixels = env->GetByteArrayElements(photo_data, 0);
@@ -501,7 +494,7 @@ JNIEXPORT void JNICALL Java_com_android_camera_panorama_Mosaic_reset(
gCancelComputation[LR] = false;
gCancelComputation[HR] = false;
- Init(LR,MAX_FRAMES_LR);
+ Init(LR,MAX_FRAMES);
}
JNIEXPORT jint JNICALL Java_com_android_camera_panorama_Mosaic_reportProgress(