summaryrefslogtreecommitdiffstats
path: root/jni
diff options
context:
space:
mode:
Diffstat (limited to 'jni')
-rw-r--r--jni/feature_mos/src/mosaic/Blend.cpp14
-rw-r--r--jni/feature_mos/src/mosaic/Blend.h10
-rw-r--r--jni/feature_mos/src/mosaic/Mosaic.cpp5
-rw-r--r--jni/feature_mos/src/mosaic/Mosaic.h3
-rw-r--r--jni/feature_mos_jni.cpp26
5 files changed, 49 insertions, 9 deletions
diff --git a/jni/feature_mos/src/mosaic/Blend.cpp b/jni/feature_mos/src/mosaic/Blend.cpp
index 46a4410..5d05abe 100644
--- a/jni/feature_mos/src/mosaic/Blend.cpp
+++ b/jni/feature_mos/src/mosaic/Blend.cpp
@@ -89,7 +89,9 @@ void Blend::AlignToMiddleFrame(MosaicFrame **frames, int frames_size)
}
}
-int Blend::runBlend(MosaicFrame **frames, int frames_size, ImageType &imageMosaicYVU, int &mosaicWidth, int &mosaicHeight)
+int Blend::runBlend(MosaicFrame **frames, int frames_size,
+ ImageType &imageMosaicYVU, int &mosaicWidth, int &mosaicHeight,
+ float &progress)
{
int ret;
int numCenters;
@@ -182,7 +184,8 @@ int Blend::runBlend(MosaicFrame **frames, int frames_size, ImageType &imageMosai
MosaicRect cropping_rect;
// Do merging and blending :
- ret = DoMergeAndBlend(frames, numCenters, width, height, *imgMos, fullRect, cropping_rect);
+ ret = DoMergeAndBlend(frames, numCenters, width, height, *imgMos, fullRect,
+ cropping_rect, progress);
if (m_wb.blendingType == BLEND_TYPE_HORZ)
CropFinalMosaic(*imgMos, cropping_rect);
@@ -252,7 +255,8 @@ int Blend::FillFramePyramid(MosaicFrame *mb)
}
int Blend::DoMergeAndBlend(MosaicFrame **frames, int nsite,
- int width, int height, YUVinfo &imgMos, MosaicRect &rect, MosaicRect &cropping_rect)
+ int width, int height, YUVinfo &imgMos, MosaicRect &rect,
+ MosaicRect &cropping_rect, float &progress)
{
m_pMosaicYPyr = NULL;
m_pMosaicUPyr = NULL;
@@ -298,6 +302,8 @@ int Blend::DoMergeAndBlend(MosaicFrame **frames, int nsite,
ProcessPyramidForThisFrame(csite, mb->vcrect, mb->brect, rect, imgMos, mb->trs, site_idx);
+ progress += TIME_PERCENT_BLEND/nsite;
+
site_idx++;
}
@@ -309,6 +315,8 @@ int Blend::DoMergeAndBlend(MosaicFrame **frames, int nsite,
if (m_pMosaicUPyr) free(m_pMosaicUPyr);
if (m_pMosaicYPyr) free(m_pMosaicYPyr);
+ progress += TIME_PERCENT_FINAL;
+
return BLEND_RET_OK;
}
diff --git a/jni/feature_mos/src/mosaic/Blend.h b/jni/feature_mos/src/mosaic/Blend.h
index b58eef9..050b485 100644
--- a/jni/feature_mos/src/mosaic/Blend.h
+++ b/jni/feature_mos/src/mosaic/Blend.h
@@ -29,6 +29,11 @@
#define BLEND_RANGE_DEFAULT 6
#define BORDER 8
+// 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;
+
//#define LINEAR_INTERP
//#define LOGII(...) //
@@ -69,7 +74,8 @@ public:
int initialize(int blendingType, int frame_width, int frame_height);
- int runBlend(MosaicFrame **frames, int frames_size, ImageType &imageMosaicYVU, int &mosaicWidth, int &mosaicHeight);
+ int runBlend(MosaicFrame **frames, int frames_size, ImageType &imageMosaicYVU,
+ int &mosaicWidth, int &mosaicHeight, float &progress);
protected:
@@ -99,7 +105,7 @@ protected:
void ClipBlendRect(CSite *csite, BlendRect &brect);
void AlignToMiddleFrame(MosaicFrame **frames, int frames_size);
- int DoMergeAndBlend(MosaicFrame **frames, int nsite, int width, int height, YUVinfo &imgMos, MosaicRect &rect, MosaicRect &cropping_rect);
+ int DoMergeAndBlend(MosaicFrame **frames, int nsite, int width, int height, YUVinfo &imgMos, MosaicRect &rect, MosaicRect &cropping_rect, float &progress);
void ComputeMask(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, int site_idx);
void ProcessPyramidForThisFrame(CSite *csite, BlendRect &vcrect, BlendRect &brect, MosaicRect &rect, YUVinfo &imgMos, double trs[3][3], int site_idx);
diff --git a/jni/feature_mos/src/mosaic/Mosaic.cpp b/jni/feature_mos/src/mosaic/Mosaic.cpp
index f8f3265..1b50c0c 100644
--- a/jni/feature_mos/src/mosaic/Mosaic.cpp
+++ b/jni/feature_mos/src/mosaic/Mosaic.cpp
@@ -153,7 +153,7 @@ int Mosaic::addFrame(ImageType imageYVU)
}
-int Mosaic::createMosaic()
+int Mosaic::createMosaic(float &progress)
{
printf("Creating mosaic\n");
@@ -167,7 +167,8 @@ int Mosaic::createMosaic()
// Blend the mosaic (alignment has already been done)
if (blender != NULL)
{
- blender->runBlend((MosaicFrame **) frames, frames_size, imageMosaicYVU, mosaicWidth, mosaicHeight);
+ blender->runBlend((MosaicFrame **) frames, frames_size, imageMosaicYVU,
+ mosaicWidth, mosaicHeight, progress);
}
return MOSAIC_RET_OK;
diff --git a/jni/feature_mos/src/mosaic/Mosaic.h b/jni/feature_mos/src/mosaic/Mosaic.h
index c34688c..25abc43 100644
--- a/jni/feature_mos/src/mosaic/Mosaic.h
+++ b/jni/feature_mos/src/mosaic/Mosaic.h
@@ -109,9 +109,10 @@ public:
/*!
* After adding all frames, call this function to perform the final blending.
+ * \param progress Variable to set the current progress in.
* \return Return code signifying success or failure.
*/
- int createMosaic();
+ int createMosaic(float &progress);
/*!
* Obtains the resulting mosaic and its dimensions.
diff --git a/jni/feature_mos_jni.cpp b/jni/feature_mos_jni.cpp
index d82c47d..1c163ab 100644
--- a/jni/feature_mos_jni.cpp
+++ b/jni/feature_mos_jni.cpp
@@ -65,6 +65,8 @@ Mosaic *mosaic[NR] = {NULL,NULL};
ImageType resultYVU = ImageUtils::IMAGE_TYPE_NOIMAGE;
ImageType resultBGR = ImageUtils::IMAGE_TYPE_NOIMAGE;
float gTRS[10];
+// Variables to keep track of the mosaic computation progress for both LR & HR.
+float gProgress[NR];
int c;
int ret;
@@ -211,7 +213,7 @@ void Finalize(int mID)
t0 = now_ms();
// Create the mosaic
- ret = mosaic[mID]->createMosaic();
+ ret = mosaic[mID]->createMosaic(gProgress[mID]);
t1 = now_ms();
time_c = t1 - t0;
LOGV("CreateMosaic: %g ms",time_c);
@@ -527,9 +529,21 @@ JNIEXPORT void JNICALL Java_com_android_camera_panorama_Mosaic_reset(
frame_number_HR = 0;
frame_number_LR = 0;
+ gProgress[LR] = 0.0;
+ gProgress[HR] = 0.0;
+
Init(LR,MAX_FRAMES_LR);
}
+JNIEXPORT jint JNICALL Java_com_android_camera_panorama_Mosaic_reportProgress(
+ JNIEnv* env, jobject thiz, jboolean hires)
+{
+ if(bool(hires))
+ return (jint) gProgress[HR];
+ else
+ return (jint) gProgress[LR];
+}
+
JNIEXPORT void JNICALL Java_com_android_camera_panorama_Mosaic_createMosaic(
JNIEnv* env, jobject thiz, jboolean value)
{
@@ -539,24 +553,34 @@ JNIEXPORT void JNICALL Java_com_android_camera_panorama_Mosaic_createMosaic(
{
double t0, t1, time_c;
+ gProgress[HR] = 0.0;
t0 = now_ms();
Init(HR, frame_number_HR);
+
for(int k = 0; k < frame_number_HR; k++)
{
AddFrame(HR, k, NULL);
+ gProgress[HR] += TIME_PERCENT_ALIGN/frame_number_HR;
}
+ gProgress[HR] = TIME_PERCENT_ALIGN;
+
t1 = now_ms();
time_c = t1 - t0;
LOGV("AlignAll [HR]: %g ms",time_c);
Finalize(HR);
+
+ gProgress[HR] = 100.0;
+
high_res = false;
}
else
{
+ gProgress[LR] = TIME_PERCENT_ALIGN;
Finalize(LR);
+ gProgress[LR] = 100.0;
}
}