[Bf-blender-cvs] [9a1585a] master: Code cleanup: use bool flag for direction in clip prefetch

Sergey Sharybin noreply at git.blender.org
Wed Jan 1 18:27:25 CET 2014


Commit: 9a1585a5331ec4dd3fcf7d024548820098181601
Author: Sergey Sharybin
Date:   Wed Jan 1 23:23:12 2014 +0600
https://developer.blender.org/rB9a1585a5331ec4dd3fcf7d024548820098181601

Code cleanup: use bool flag for direction in clip prefetch

That was nothing really wrong with the old short used for
direction, but that became kinda annoying because of compiler
idiocy which considered direction might have been zero.

Using explicit dual-state flag is more clear anyway.

===================================================================

M	source/blender/editors/space_clip/clip_editor.c

===================================================================

diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 0e1a2f9..20e69fc 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -603,7 +603,10 @@ typedef struct PrefetchQueue {
 	int initial_frame, current_frame, start_frame, end_frame;
 	short render_size, render_flag;
 
-	short direction;
+	/* If true prefecthing goes forward in time,
+	 * othwewise it goes backwards in time (starting from current frame).
+	 */
+	bool forward;
 
 	SpinLock spin;
 
@@ -707,17 +710,17 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip
 	{
 		int current_frame;
 
-		if (queue->direction > 0) {
+		if (queue->forward) {
 			current_frame = prefetch_find_uncached_frame(clip, queue->current_frame + 1, queue->end_frame,
 			                                             queue->render_size, queue->render_flag, 1);
 			/* switch direction if read frames from current up to scene end frames */
 			if (current_frame > queue->end_frame) {
 				queue->current_frame = queue->initial_frame;
-				queue->direction = -1;
+				queue->forward = false;
 			}
 		}
 
-		if (queue->direction < 0) {
+		if (!queue->forward) {
 			current_frame = prefetch_find_uncached_frame(clip, queue->current_frame - 1, queue->start_frame,
 			                                             queue->render_size, queue->render_flag, -1);
 		}
@@ -732,7 +735,7 @@ static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip
 
 			queue->current_frame = current_frame;
 
-			if (queue->direction > 0) {
+			if (queue->forward) {
 				frames_processed = queue->current_frame - queue->initial_frame;
 			}
 			else {
@@ -808,7 +811,7 @@ static void start_prefetch_threads(MovieClip *clip, int start_frame, int current
 	queue.end_frame = end_frame;
 	queue.render_size = render_size;
 	queue.render_flag = render_flag;
-	queue.direction = 1;
+	queue.forward = 1;
 
 	queue.stop = stop;
 	queue.do_update = do_update;




More information about the Bf-blender-cvs mailing list