Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2020-02-07 14:00:57 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-02-07 14:01:50 +0300
commit28cd16ec448f57b863f8be0a8f5d303d94bc1f1f (patch)
tree9a1f5ea9db62095ab281fa29accafa13ca5ca2c1 /source/blender/blenkernel/intern/tracking_util.c
parent0f7a90d4ad2c144b82679c24020e1338a3fc7cef (diff)
Cleanup: Tracking, reduce scope of variables
Mainly affects for() loops. The reason why loop parameter was declared outside of the loop roots back to the times when not all compilers supported C99.
Diffstat (limited to 'source/blender/blenkernel/intern/tracking_util.c')
-rw-r--r--source/blender/blenkernel/intern/tracking_util.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c
index ed582dc5b94..ada6ce96d58 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -126,7 +126,6 @@ void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
MovieTrackingTrack *track;
ListBase tracks = {NULL, NULL}, new_tracks = {NULL, NULL};
ListBase *old_tracks;
- int a;
if (map->is_camera) {
old_tracks = &tracking->tracks;
@@ -146,7 +145,7 @@ void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
* this is needed to keep names in unique state and it's faster to change names
* of currently operating tracks (if needed)
*/
- for (a = 0; a < map->num_tracks; a++) {
+ for (int a = 0; a < map->num_tracks; a++) {
MovieTrackingTrack *old_track;
bool mapped_to_old = false;
@@ -221,11 +220,9 @@ void tracks_map_merge(TracksMap *map, MovieTracking *tracking)
void tracks_map_free(TracksMap *map, void (*customdata_free)(void *customdata))
{
- int i = 0;
-
BLI_ghash_free(map->hash, NULL, NULL);
- for (i = 0; i < map->num_tracks; i++) {
+ for (int i = 0; i < map->num_tracks; i++) {
if (map->customdata && customdata_free) {
customdata_free(&map->customdata[i * map->customdata_size]);
}
@@ -345,12 +342,11 @@ void tracking_get_marker_coords_for_tracking(int frame_width,
double search_pixel_x[5],
double search_pixel_y[5])
{
- int i;
float unified_coords[2];
float pixel_coords[2];
/* Convert the corners into search space coordinates. */
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
marker_unified_to_search_pixel(
frame_width, frame_height, marker, marker->pattern_corners[i], pixel_coords);
search_pixel_x[i] = pixel_coords[0] - 0.5f;
@@ -373,12 +369,11 @@ void tracking_set_marker_coords_from_tracking(int frame_width,
const double search_pixel_x[5],
const double search_pixel_y[5])
{
- int i;
float marker_unified[2];
float search_pixel[2];
/* Convert the corners into search space coordinates. */
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
search_pixel[0] = search_pixel_x[i] + 0.5;
search_pixel[1] = search_pixel_y[i] + 0.5;
search_pixel_to_marker_unified(
@@ -394,7 +389,7 @@ void tracking_set_marker_coords_from_tracking(int frame_width,
* Otherwise, the entire patch shifted, and that delta should be applied to
* all the coordinates.
*/
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
marker->pattern_corners[i][0] -= marker_unified[0];
marker->pattern_corners[i][1] -= marker_unified[1];
}
@@ -672,8 +667,6 @@ static ImBuf *accessor_get_preprocessed_ibuf(TrackingImageAccessor *accessor,
static ImBuf *make_grayscale_ibuf_copy(ImBuf *ibuf)
{
ImBuf *grayscale = IMB_allocImBuf(ibuf->x, ibuf->y, 32, 0);
- size_t size;
- int i;
BLI_assert(ibuf->channels == 3 || ibuf->channels == 4);
@@ -682,13 +675,13 @@ static ImBuf *make_grayscale_ibuf_copy(ImBuf *ibuf)
*
* Will generalize it later.
*/
- size = (size_t)grayscale->x * (size_t)grayscale->y * sizeof(float);
+ const size_t size = (size_t)grayscale->x * (size_t)grayscale->y * sizeof(float);
grayscale->channels = 1;
if ((grayscale->rect_float = MEM_mapallocN(size, "tracking grayscale image")) != NULL) {
grayscale->mall |= IB_rectfloat;
grayscale->flags |= IB_rectfloat;
- for (i = 0; i < grayscale->x * grayscale->y; i++) {
+ for (int i = 0; i < grayscale->x * grayscale->y; i++) {
const float *pixel = ibuf->rect_float + ibuf->channels * i;
grayscale->rect_float[i] = 0.2126f * pixel[0] + 0.7152f * pixel[1] + 0.0722f * pixel[2];
@@ -785,14 +778,12 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
clamped_height);
}
else {
- int y;
/* TODO(sergey): We don't do any color space or alpha conversion
* here. Probably Libmv is better to work in the linear space,
* but keep sRGB space here for compatibility for now.
*/
- for (y = 0; y < clamped_height; y++) {
- int x;
- for (x = 0; x < clamped_width; x++) {
+ for (int y = 0; y < clamped_height; y++) {
+ for (int x = 0; x < clamped_width; x++) {
int src_x = x + clamped_origin_x, src_y = y + clamped_origin_y;
int dst_x = x + dst_offset_x, dst_y = y + dst_offset_y;
int dst_index = (dst_y * width + dst_x) * 4,