stitcher: optimize the image quality
diff --git a/xcore/interface/feature_match.cpp b/xcore/interface/feature_match.cpp
index 82a0118..4a6a428 100644
--- a/xcore/interface/feature_match.cpp
+++ b/xcore/interface/feature_match.cpp
@@ -81,7 +81,7 @@
         sum = 0.0f;
 
         for (size_t i = 0; i < offsets.size (); ++i) {
-            if (fabs (offsets[i] - mean_offset) >= 8.0f)
+            if (fabs (offsets[i] - mean_offset) >= _config.recur_offset_error)
                 continue;
             sum += offsets[i];
             ++recur_count;
@@ -123,11 +123,13 @@
 
     int last_overlap_width = stitch1.pos_x + stitch1.width + (dst_width - (stitch0.pos_x + stitch0.width));
     // int final_overlap_width = stitch1.pos_x + stitch1.width + (dst_width - (stitch0.pos_x - x_offset + stitch0.width));
+    if ((stitch0.pos_x - x_offset + stitch0.width) > dst_width)
+        x_offset = dst_width - (stitch0.pos_x + stitch0.width);
     int final_overlap_width = last_overlap_width + x_offset;
     final_overlap_width = XCAM_ALIGN_AROUND (final_overlap_width, 8);
     XCAM_ASSERT (final_overlap_width >= _config.sitch_min_width);
     int center = final_overlap_width / 2;
-    XCAM_ASSERT (center > _config.sitch_min_width / 2);
+    XCAM_ASSERT (center >= _config.sitch_min_width / 2);
 
     stitch1.pos_x = XCAM_ALIGN_AROUND (center - _config.sitch_min_width / 2, 8);
     stitch1.width = _config.sitch_min_width;
diff --git a/xcore/interface/feature_match.h b/xcore/interface/feature_match.h
index c73cbb4..06c0b7b 100644
--- a/xcore/interface/feature_match.h
+++ b/xcore/interface/feature_match.h
@@ -33,14 +33,20 @@
     int min_corners;           // number of minimum efficient corners
     float offset_factor;       // last_offset * offset_factor + cur_offset * (1.0f - offset_factor)
     float delta_mean_offset;   // cur_mean_offset - last_mean_offset
-    float max_adjusted_offset; // max offset of each adjustment
+    float recur_offset_error;  // cur_offset - mean_offset
+    float max_adjusted_offset; // maximum offset of each adjustment
+    float max_valid_offset_y;  // valid maximum offset in vertical direction
+    float max_track_error;     // maximum track error
 
     CVFMConfig ()
         : sitch_min_width (56)
         , min_corners (8)
         , offset_factor (0.8f)
         , delta_mean_offset (5.0f)
+        , recur_offset_error (8.0f)
         , max_adjusted_offset (12.0f)
+        , max_valid_offset_y (8.0f)
+        , max_track_error (24.0f)
     {}
 };