diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-01-26 13:42:55 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-01-26 13:44:43 +0300 |
commit | c8d2ebe13c1a93a7390df60607525c47614b4984 (patch) | |
tree | f6c5f8403db37778e4905d4f865070cec187089e /intern | |
parent | f1f42c6172c7e656f42cb4895c0badf10f33a1ad (diff) |
Compositor: Speedup movie (un)distortion operation
Avoid per-pixel camera intrincs object construction and synchronization.
Here on a bit synthetic file it gives about 40% speedup with a single node.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/libmv/intern/camera_intrinsics.cc | 22 | ||||
-rw-r--r-- | intern/libmv/intern/camera_intrinsics.h | 4 | ||||
-rw-r--r-- | intern/libmv/intern/stub.cc | 26 |
3 files changed, 18 insertions, 34 deletions
diff --git a/intern/libmv/intern/camera_intrinsics.cc b/intern/libmv/intern/camera_intrinsics.cc index 0ce757cc93b..24a34ae40bb 100644 --- a/intern/libmv/intern/camera_intrinsics.cc +++ b/intern/libmv/intern/camera_intrinsics.cc @@ -264,33 +264,23 @@ void libmv_cameraIntrinsicsDistortFloat( } void libmv_cameraIntrinsicsApply( - const libmv_CameraIntrinsicsOptions* libmv_camera_intrinsics_options, + const struct libmv_CameraIntrinsics* libmv_intrinsics, double x, double y, double* x1, double* y1) { - /* Do a lens distortion if focal length is non-zero only. */ - if (libmv_camera_intrinsics_options->focal_length) { - CameraIntrinsics* camera_intrinsics = - libmv_cameraIntrinsicsCreateFromOptions(libmv_camera_intrinsics_options); - camera_intrinsics->ApplyIntrinsics(x, y, x1, y1); - LIBMV_OBJECT_DELETE(camera_intrinsics, CameraIntrinsics); - } + CameraIntrinsics *intrinsics = (CameraIntrinsics *) libmv_intrinsics; + intrinsics->ApplyIntrinsics(x, y, x1, y1); } void libmv_cameraIntrinsicsInvert( - const libmv_CameraIntrinsicsOptions* libmv_camera_intrinsics_options, + const struct libmv_CameraIntrinsics* libmv_intrinsics, double x, double y, double* x1, double* y1) { - /* Do a lens un-distortion if focal length is non-zero only/ */ - if (libmv_camera_intrinsics_options->focal_length) { - CameraIntrinsics *camera_intrinsics = - libmv_cameraIntrinsicsCreateFromOptions(libmv_camera_intrinsics_options); - camera_intrinsics->InvertIntrinsics(x, y, x1, y1); - LIBMV_OBJECT_DELETE(camera_intrinsics, CameraIntrinsics); - } + CameraIntrinsics *intrinsics = (CameraIntrinsics *) libmv_intrinsics; + intrinsics->InvertIntrinsics(x, y, x1, y1); } static void libmv_cameraIntrinsicsFillFromOptions( diff --git a/intern/libmv/intern/camera_intrinsics.h b/intern/libmv/intern/camera_intrinsics.h index 9910d16a108..50a0073437b 100644 --- a/intern/libmv/intern/camera_intrinsics.h +++ b/intern/libmv/intern/camera_intrinsics.h @@ -108,14 +108,14 @@ void libmv_cameraIntrinsicsDistortFloat( float* destination_image); void libmv_cameraIntrinsicsApply( - const libmv_CameraIntrinsicsOptions* libmv_camera_intrinsics_options, + const struct libmv_CameraIntrinsics* libmv_intrinsics, double x, double y, double* x1, double* y1); void libmv_cameraIntrinsicsInvert( - const libmv_CameraIntrinsicsOptions* libmv_camera_intrinsics_options, + const struct libmv_CameraIntrinsics* libmv_intrinsics, double x, double y, double* x1, diff --git a/intern/libmv/intern/stub.cc b/intern/libmv/intern/stub.cc index ad648203764..47e1915e072 100644 --- a/intern/libmv/intern/stub.cc +++ b/intern/libmv/intern/stub.cc @@ -303,29 +303,23 @@ void libmv_cameraIntrinsicsDistortFloat( /* ************ utils ************ */ void libmv_cameraIntrinsicsApply( - const libmv_CameraIntrinsicsOptions* libmv_camera_intrinsics_options, - double x, - double y, + const struct libmv_CameraIntrinsics* /*libmv_intrinsics*/, + double /*x*/, + double /*y*/, double* x1, double* y1) { - double focal_length = libmv_camera_intrinsics_options->focal_length; - double principal_x = libmv_camera_intrinsics_options->principal_point_x; - double principal_y = libmv_camera_intrinsics_options->principal_point_y; - *x1 = x * focal_length + principal_x; - *y1 = y * focal_length + principal_y; + *x1 = 0.0; + *y1 = 0.0; } void libmv_cameraIntrinsicsInvert( - const libmv_CameraIntrinsicsOptions* libmv_camera_intrinsics_options, - double x, - double y, + const struct libmv_CameraIntrinsics* /*libmv_intrinsics*/, + double /*x*/, + double /*y*/, double* x1, double* y1) { - double focal_length = libmv_camera_intrinsics_options->focal_length; - double principal_x = libmv_camera_intrinsics_options->principal_point_x; - double principal_y = libmv_camera_intrinsics_options->principal_point_y; - *x1 = (x - principal_x) / focal_length; - *y1 = (y - principal_y) / focal_length; + *x1 = 0.0; + *y1 = 0.0; } void libmv_homography2DFromCorrespondencesEuc(/* const */ double (* /*x1*/)[2], |