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>2012-08-07 20:47:46 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-08-07 20:47:46 +0400
commit6cf1a9834b82ce18d5b5358fe431b48037f1bca4 (patch)
tree5f26a61e25eb477261994a5fb38d909813cff157 /source/blender/blenkernel/intern
parent258b4a8dad5b357b465a14a3e3a32fe6fafcd767 (diff)
Made image buffer threaded processor generic function,
so color management could use the same routines. Should be no functional changes.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/sequencer.c94
1 files changed, 48 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 869b8a0df6a..02ae9566eed 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -1646,6 +1646,12 @@ static void color_balance_float_float(Sequence *seq, float *rect_float, int widt
}
}
+typedef struct ColorBalanceInitData {
+ Sequence *seq;
+ ImBuf *ibuf;
+ float mul;
+} ColorBalanceInitData;
+
typedef struct ColorBalanceThread {
Sequence *seq;
float mul;
@@ -1656,6 +1662,28 @@ typedef struct ColorBalanceThread {
float *rect_float;
} ColorBalanceThread;
+static void color_balance_init_handle(void *handle_v, int start_line, int tot_line, void *init_data_v)
+{
+ ColorBalanceThread *handle = (ColorBalanceThread *) handle_v;
+ ColorBalanceInitData *init_data = (ColorBalanceInitData *) init_data_v;
+ ImBuf *ibuf = init_data->ibuf;
+
+ int offset = 4 * start_line * ibuf->x;
+
+ memset(handle, 0, sizeof(ColorBalanceThread));
+
+ handle->seq = init_data->seq;
+ handle->mul = init_data->mul;
+ handle->width = ibuf->x;
+ handle->height = tot_line;
+
+ if (ibuf->rect)
+ handle->rect = (unsigned char *) ibuf->rect + offset;
+
+ if (ibuf->rect_float)
+ handle->rect_float = ibuf->rect_float + offset;
+}
+
static void *color_balance_do_thread(void *thread_data_v)
{
ColorBalanceThread *thread_data = (ColorBalanceThread *) thread_data_v;
@@ -1680,62 +1708,36 @@ static void *color_balance_do_thread(void *thread_data_v)
static void color_balance(Sequence *seq, ImBuf *ibuf, float mul)
{
- int i, tot_thread = BLI_system_thread_count();
- int start_line, tot_line;
- ListBase threads;
- ColorBalanceThread handles[BLENDER_MAX_THREADS];
+ if (!ibuf->rect_float && seq->flag & SEQ_MAKE_FLOAT)
+ imb_addrectfloatImBuf(ibuf);
- if (!BLI_thread_is_main()) {
+ if (BLI_thread_is_main()) {
/* color balance could have been called from prefetching job which
* is already multithreaded, so doing threading here makes no sense
*/
- tot_thread = 1;
- }
+ ColorBalanceInitData init_data;
- if (!ibuf->rect_float && seq->flag & SEQ_MAKE_FLOAT)
- imb_addrectfloatImBuf(ibuf);
-
- if (tot_thread > 1)
- BLI_init_threads(&threads, color_balance_do_thread, tot_thread);
-
- start_line = 0;
- tot_line = ((float)(ibuf->y / tot_thread)) + 0.5f;
-
- for (i = 0; i < tot_thread; i++) {
- int offset;
+ init_data.seq = seq;
+ init_data.ibuf = ibuf;
+ init_data.mul = mul;
- handles[i].seq = seq;
- handles[i].mul = mul;
- handles[i].width = ibuf->x;
+ IMB_processor_apply_threaded(ibuf->y, sizeof(ColorBalanceThread), &init_data,
+ color_balance_init_handle, color_balance_do_thread);
- if (i < tot_thread - 1)
- handles[i].height = tot_line;
- else
- handles[i].height = ibuf->y - start_line;
-
- offset = 4 * start_line * ibuf->x;
-
- if (ibuf->rect)
- handles[i].rect = (unsigned char *)ibuf->rect + offset;
- else
- handles[i].rect = NULL;
+ }
+ else {
+ ColorBalanceThread handle;
- if (ibuf->rect_float)
- handles[i].rect_float = ibuf->rect_float + offset;
- else
- handles[i].rect_float = NULL;
+ handle.seq = seq;
+ handle.mul = mul;
+ handle.width = ibuf->x;
+ handle.height = ibuf->y;
+ handle.rect = (unsigned char *)ibuf->rect;
+ handle.rect_float = ibuf->rect_float;
- if (tot_thread > 1)
- BLI_insert_thread(&threads, &handles[i]);
+ color_balance_do_thread(&handle);
+} }
- start_line += tot_line;
- }
-
- if (tot_thread > 1)
- BLI_end_threads(&threads);
- else
- color_balance_do_thread(handles);
-}
/*
* input preprocessing for SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP and SEQ_TYPE_SCENE