Skip to content

Commit ce1932b

Browse files
committedMar 6, 2025
dont use grad_x for pixels selected for grad_y and vice-versa: 3x fewer alignment failures
1 parent 1ac8f3d commit ce1932b

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed
 

‎alignment.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ bool VideoAligner::AlignNextFrame(
678678
#endif
679679

680680
if (i > 0) {
681-
// Move from half-resolution to full-resolution
681+
// Move up the pyramid to 2x higher resolution
682682
transform.TX *= 2.0;
683683
transform.TY *= 2.0;
684684
}

‎generators.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,20 @@ class sparse_jac_generator : public Halide::Generator<sparse_jac_generator>
350350

351351
Expr scale = 1.f / grad_x.width();
352352

353+
// Sparse pixels selected based on grad_x should only use grad_x in calculation
353354
output_x(x, y, c) = mux(c, {
354-
(grad_x(ix0, iy0) * ix0 + grad_y(ix0, iy0) * iy0) * scale,
355-
(grad_x(ix0, iy0) * -iy0 + grad_y(ix0, iy0) * ix0) * scale,
356-
(grad_x(ix0, iy0)),
357-
(grad_y(ix0, iy0)),
355+
2.f * grad_x(ix0, iy0) * ix0 * scale,
356+
2.f * grad_x(ix0, iy0) * -iy0 * scale,
357+
2.f * grad_x(ix0, iy0),
358+
0.f,
358359
});
359360

361+
// Sparse pixels selected based on grad_y should only use grad_y in calculation
360362
output_y(x, y, c) = mux(c, {
361-
(grad_x(ix1, iy1) * ix1 + grad_y(ix1, iy1) * iy1) * scale,
362-
(grad_x(ix1, iy1) * -iy1 + grad_y(ix1, iy1) * ix1) * scale,
363-
(grad_x(ix1, iy1)),
364-
(grad_y(ix1, iy1)),
363+
2.f * grad_y(ix1, iy1) * iy1 * scale,
364+
2.f * grad_y(ix1, iy1) * ix1 * scale,
365+
0.f,
366+
2.f * grad_y(ix1, iy1),
365367
});
366368
}
367369

‎schedules/sparse_jac.schedule.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ inline void apply_schedule_sparse_jac(
1919
using ::Halide::TailStrategy;
2020
using ::Halide::Var;
2121
Func output_y = pipeline.get_func(5);
22-
Func output_x = pipeline.get_func(3);
22+
Func output_x = pipeline.get_func(2);
2323
Var v0(output_y.get_schedule().dims()[0].var);
2424
Var v0i("v0i");
2525
Var v1(output_y.get_schedule().dims()[1].var);

0 commit comments

Comments
 (0)
Please sign in to comment.