diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | intern/cycles/app/cycles_standalone.cpp | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/CCGSubSurf_legacy.c | 779 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/seqeffects.c | 575 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_ghash.h | 74 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 8 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_rotate_edges.c | 2 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_capi_utils.h | 6 |
8 files changed, 835 insertions, 613 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f159d40dd1..fb74675088e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -729,7 +729,7 @@ if(WITH_INTERNATIONAL) endif() if(WITH_PYTHON) - # While we have this as an '#error' in bpy_util.h, + # While we have this as an '#error' in 'bpy_capi_utils.h', # upgrading Python tends to cause confusion for users who build. # Give the error message early to make this more obvious. # diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp index 0b9a4042e0e..2d4b0d35e54 100644 --- a/intern/cycles/app/cycles_standalone.cpp +++ b/intern/cycles/app/cycles_standalone.cpp @@ -121,7 +121,6 @@ static void scene_init() static void session_init() { options.session = new Session(options.session_params); - options.session->reset(session_buffer_params(), options.session_params.samples); if(options.session_params.background && !options.quiet) options.session->progress.set_update_callback(function_bind(&session_print_status)); @@ -134,6 +133,7 @@ static void session_init() scene_init(); options.session->scene = options.scene; + options.session->reset(session_buffer_params(), options.session_params.samples); options.session->start(); } diff --git a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c index e9002af19b1..f68d1a2697c 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf_legacy.c +++ b/source/blender/blenkernel/intern/CCGSubSurf_legacy.c @@ -27,6 +27,7 @@ #include "BLI_utildefines.h" /* for BLI_assert */ #include "BLI_math.h" +#include "BLI_task.h" #include "CCGSubSurf.h" #include "CCGSubSurf_intern.h" @@ -121,179 +122,251 @@ static float EDGE_getSharpness(CCGEdge *e, int lvl) return e->crease - lvl; } -static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, - CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF, - int numEffectedV, int numEffectedE, int numEffectedF) + + +typedef struct CCGSubSurfCalcSubdivData { + CCGSubSurf *ss; + CCGVert **effectedV; + CCGEdge **effectedE; + CCGFace **effectedF; + int numEffectedV; + int numEffectedE; + int numEffectedF; + + int curLvl; +} CCGSubSurfCalcSubdivData; + +static void ccgSubSurf__calcVertNormals_faces_accumulate_cb(void *userdata, int ptrIdx) { - int i, ptrIdx; - int subdivLevels = ss->subdivLevels; - int lvl = ss->subdivLevels; - int edgeSize = ccg_edgesize(lvl); - int gridSize = ccg_gridsize(lvl); - int normalDataOffset = ss->normalDataOffset; - int vertDataSize = ss->meshIFC.vertDataSize; + CCGSubSurfCalcSubdivData *data = userdata; -#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) - for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { - CCGFace *f = (CCGFace *) effectedF[ptrIdx]; - int S, x, y; - float no[3]; + CCGSubSurf *ss = data->ss; + CCGFace *f = data->effectedF[ptrIdx]; - for (S = 0; S < f->numVerts; S++) { - for (y = 0; y < gridSize - 1; y++) { - for (x = 0; x < gridSize - 1; x++) { - NormZero(FACE_getIFNo(f, lvl, S, x, y)); - } - } + const int subdivLevels = ss->subdivLevels; + const int lvl = ss->subdivLevels; + const int gridSize = ccg_gridsize(lvl); + const int normalDataOffset = ss->normalDataOffset; + const int vertDataSize = ss->meshIFC.vertDataSize; - if (FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected) { - for (x = 0; x < gridSize - 1; x++) { - NormZero(FACE_getIFNo(f, lvl, S, x, gridSize - 1)); - } + int S, x, y; + float no[3]; + + for (S = 0; S < f->numVerts; S++) { + for (y = 0; y < gridSize - 1; y++) { + for (x = 0; x < gridSize - 1; x++) { + NormZero(FACE_getIFNo(f, lvl, S, x, y)); } - if (FACE_getEdges(f)[S]->flags & Edge_eEffected) { - for (y = 0; y < gridSize - 1; y++) { - NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, y)); - } + } + + if (FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected) { + for (x = 0; x < gridSize - 1; x++) { + NormZero(FACE_getIFNo(f, lvl, S, x, gridSize - 1)); } - if (FACE_getVerts(f)[S]->flags & Vert_eEffected) { - NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, gridSize - 1)); + } + if (FACE_getEdges(f)[S]->flags & Edge_eEffected) { + for (y = 0; y < gridSize - 1; y++) { + NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, y)); } } + if (FACE_getVerts(f)[S]->flags & Vert_eEffected) { + NormZero(FACE_getIFNo(f, lvl, S, gridSize - 1, gridSize - 1)); + } + } - for (S = 0; S < f->numVerts; S++) { - int yLimit = !(FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected); - int xLimit = !(FACE_getEdges(f)[S]->flags & Edge_eEffected); - int yLimitNext = xLimit; - int xLimitPrev = yLimit; - - for (y = 0; y < gridSize - 1; y++) { - for (x = 0; x < gridSize - 1; x++) { - int xPlusOk = (!xLimit || x < gridSize - 2); - int yPlusOk = (!yLimit || y < gridSize - 2); - - FACE_calcIFNo(f, lvl, S, x, y, no); - - NormAdd(FACE_getIFNo(f, lvl, S, x + 0, y + 0), no); - if (xPlusOk) - NormAdd(FACE_getIFNo(f, lvl, S, x + 1, y + 0), no); - if (yPlusOk) - NormAdd(FACE_getIFNo(f, lvl, S, x + 0, y + 1), no); - if (xPlusOk && yPlusOk) { - if (x < gridSize - 2 || y < gridSize - 2 || FACE_getVerts(f)[S]->flags & Vert_eEffected) { - NormAdd(FACE_getIFNo(f, lvl, S, x + 1, y + 1), no); - } + for (S = 0; S < f->numVerts; S++) { + int yLimit = !(FACE_getEdges(f)[(S - 1 + f->numVerts) % f->numVerts]->flags & Edge_eEffected); + int xLimit = !(FACE_getEdges(f)[S]->flags & Edge_eEffected); + int yLimitNext = xLimit; + int xLimitPrev = yLimit; + + for (y = 0; y < gridSize - 1; y++) { + for (x = 0; x < gridSize - 1; x++) { + int xPlusOk = (!xLimit || x < gridSize - 2); + int yPlusOk = (!yLimit || y < gridSize - 2); + + FACE_calcIFNo(f, lvl, S, x, y, no); + + NormAdd(FACE_getIFNo(f, lvl, S, x + 0, y + 0), no); + if (xPlusOk) + NormAdd(FACE_getIFNo(f, lvl, S, x + 1, y + 0), no); + if (yPlusOk) + NormAdd(FACE_getIFNo(f, lvl, S, x + 0, y + 1), no); + if (xPlusOk && yPlusOk) { + if (x < gridSize - 2 || y < gridSize - 2 || FACE_getVerts(f)[S]->flags & Vert_eEffected) { + NormAdd(FACE_getIFNo(f, lvl, S, x + 1, y + 1), no); } + } - if (x == 0 && y == 0) { - int K; + if (x == 0 && y == 0) { + int K; - if (!yLimitNext || 1 < gridSize - 1) - NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, 1), no); - if (!xLimitPrev || 1 < gridSize - 1) - NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, 1, 0), no); + if (!yLimitNext || 1 < gridSize - 1) + NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, 1), no); + if (!xLimitPrev || 1 < gridSize - 1) + NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, 1, 0), no); - for (K = 0; K < f->numVerts; K++) { - if (K != S) { - NormAdd(FACE_getIFNo(f, lvl, K, 0, 0), no); - } + for (K = 0; K < f->numVerts; K++) { + if (K != S) { + NormAdd(FACE_getIFNo(f, lvl, K, 0, 0), no); } } - else if (y == 0) { - NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, x), no); - if (!yLimitNext || x < gridSize - 2) - NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, x + 1), no); - } - else if (x == 0) { - NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, y, 0), no); - if (!xLimitPrev || y < gridSize - 2) - NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, y + 1, 0), no); - } + } + else if (y == 0) { + NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, x), no); + if (!yLimitNext || x < gridSize - 2) + NormAdd(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, x + 1), no); + } + else if (x == 0) { + NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, y, 0), no); + if (!xLimitPrev || y < gridSize - 2) + NormAdd(FACE_getIFNo(f, lvl, (S - 1 + f->numVerts) % f->numVerts, y + 1, 0), no); } } } } - /* XXX can I reduce the number of normalisations here? */ - for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { - CCGVert *v = (CCGVert *) effectedV[ptrIdx]; - float *no = VERT_getNo(v, lvl); +} - NormZero(no); +static void ccgSubSurf__calcVertNormals_faces_finalize_cb(void *userdata, int ptrIdx) +{ + CCGSubSurfCalcSubdivData *data = userdata; - for (i = 0; i < v->numFaces; i++) { - CCGFace *f = v->faces[i]; - NormAdd(no, FACE_getIFNo(f, lvl, ccg_face_getVertIndex(f, v), gridSize - 1, gridSize - 1)); - } + CCGSubSurf *ss = data->ss; + CCGFace *f = data->effectedF[ptrIdx]; - if (UNLIKELY(v->numFaces == 0)) { - NormCopy(no, VERT_getCo(v, lvl)); + const int subdivLevels = ss->subdivLevels; + const int lvl = ss->subdivLevels; + const int gridSize = ccg_gridsize(lvl); + const int normalDataOffset = ss->normalDataOffset; + const int vertDataSize = ss->meshIFC.vertDataSize; + + int S, x, y; + + for (S = 0; S < f->numVerts; S++) { + NormCopy(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, gridSize - 1), + FACE_getIFNo(f, lvl, S, gridSize - 1, 0)); + } + + for (S = 0; S < f->numVerts; S++) { + for (y = 0; y < gridSize; y++) { + for (x = 0; x < gridSize; x++) { + float *no = FACE_getIFNo(f, lvl, S, x, y); + Normalize(no); + } } - Normalize(no); + VertDataCopy((float *)((byte *)FACE_getCenterData(f) + normalDataOffset), + FACE_getIFNo(f, lvl, S, 0, 0), ss); - for (i = 0; i < v->numFaces; i++) { - CCGFace *f = v->faces[i]; - NormCopy(FACE_getIFNo(f, lvl, ccg_face_getVertIndex(f, v), gridSize - 1, gridSize - 1), no); + for (x = 1; x < gridSize - 1; x++) { + NormCopy(FACE_getIENo(f, lvl, S, x), + FACE_getIFNo(f, lvl, S, x, 0)); } } - for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) { - CCGEdge *e = (CCGEdge *) effectedE[ptrIdx]; +} - if (e->numFaces) { - CCGFace *fLast = e->faces[e->numFaces - 1]; - int x; +static void ccgSubSurf__calcVertNormals_edges_accumulate_cb(void *userdata, int ptrIdx) +{ + CCGSubSurfCalcSubdivData *data = userdata; - for (i = 0; i < e->numFaces - 1; i++) { - CCGFace *f = e->faces[i]; - const int f_ed_idx = ccg_face_getEdgeIndex(f, e); - const int f_ed_idx_last = ccg_face_getEdgeIndex(fLast, e); + CCGSubSurf *ss = data->ss; + CCGEdge *e = data->effectedE[ptrIdx]; - for (x = 1; x < edgeSize - 1; x++) { - NormAdd(_face_getIFNoEdge(fLast, e, f_ed_idx_last, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), - _face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); - } + const int subdivLevels = ss->subdivLevels; + const int lvl = ss->subdivLevels; + const int edgeSize = ccg_edgesize(lvl); + const int normalDataOffset = ss->normalDataOffset; + const int vertDataSize = ss->meshIFC.vertDataSize; + + if (e->numFaces) { + CCGFace *fLast = e->faces[e->numFaces - 1]; + int x, i; + + for (i = 0; i < e->numFaces - 1; i++) { + CCGFace *f = e->faces[i]; + const int f_ed_idx = ccg_face_getEdgeIndex(f, e); + const int f_ed_idx_last = ccg_face_getEdgeIndex(fLast, e); + + for (x = 1; x < edgeSize - 1; x++) { + NormAdd(_face_getIFNoEdge(fLast, e, f_ed_idx_last, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), + _face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } + } - for (i = 0; i < e->numFaces - 1; i++) { - CCGFace *f = e->faces[i]; - const int f_ed_idx = ccg_face_getEdgeIndex(f, e); - const int f_ed_idx_last = ccg_face_getEdgeIndex(fLast, e); + for (i = 0; i < e->numFaces - 1; i++) { + CCGFace *f = e->faces[i]; + const int f_ed_idx = ccg_face_getEdgeIndex(f, e); + const int f_ed_idx_last = ccg_face_getEdgeIndex(fLast, e); - for (x = 1; x < edgeSize - 1; x++) { - NormCopy(_face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), - _face_getIFNoEdge(fLast, e, f_ed_idx_last, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); - } + for (x = 1; x < edgeSize - 1; x++) { + NormCopy(_face_getIFNoEdge(f, e, f_ed_idx, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset), + _face_getIFNoEdge(fLast, e, f_ed_idx_last, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } } } +} -#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) - for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { - CCGFace *f = (CCGFace *) effectedF[ptrIdx]; - int S, x, y; +static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, + CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF, + int numEffectedV, int numEffectedE, int numEffectedF) +{ + int i, ptrIdx; + const int subdivLevels = ss->subdivLevels; + const int lvl = ss->subdivLevels; + const int edgeSize = ccg_edgesize(lvl); + const int gridSize = ccg_gridsize(lvl); + const int normalDataOffset = ss->normalDataOffset; + const int vertDataSize = ss->meshIFC.vertDataSize; + + CCGSubSurfCalcSubdivData data = { + .ss = ss, + .effectedV = effectedV, + .effectedE = effectedE, + .effectedF = effectedF, + .numEffectedV = numEffectedV, + .numEffectedE = numEffectedE, + .numEffectedF = numEffectedF + }; + + BLI_task_parallel_range(0, numEffectedF, + &data, + ccgSubSurf__calcVertNormals_faces_accumulate_cb, + numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT); - for (S = 0; S < f->numVerts; S++) { - NormCopy(FACE_getIFNo(f, lvl, (S + 1) % f->numVerts, 0, gridSize - 1), - FACE_getIFNo(f, lvl, S, gridSize - 1, 0)); + /* XXX can I reduce the number of normalisations here? */ + for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { + CCGVert *v = (CCGVert *) effectedV[ptrIdx]; + float *no = VERT_getNo(v, lvl); + + NormZero(no); + + for (i = 0; i < v->numFaces; i++) { + CCGFace *f = v->faces[i]; + NormAdd(no, FACE_getIFNo(f, lvl, ccg_face_getVertIndex(f, v), gridSize - 1, gridSize - 1)); } - for (S = 0; S < f->numVerts; S++) { - for (y = 0; y < gridSize; y++) { - for (x = 0; x < gridSize; x++) { - float *no = FACE_getIFNo(f, lvl, S, x, y); - Normalize(no); - } - } + if (UNLIKELY(v->numFaces == 0)) { + NormCopy(no, VERT_getCo(v, lvl)); + } - VertDataCopy((float *)((byte *)FACE_getCenterData(f) + normalDataOffset), - FACE_getIFNo(f, lvl, S, 0, 0), ss); + Normalize(no); - for (x = 1; x < gridSize - 1; x++) - NormCopy(FACE_getIENo(f, lvl, S, x), - FACE_getIFNo(f, lvl, S, x, 0)); + for (i = 0; i < v->numFaces; i++) { + CCGFace *f = v->faces[i]; + NormCopy(FACE_getIFNo(f, lvl, ccg_face_getVertIndex(f, v), gridSize - 1, gridSize - 1), no); } } + BLI_task_parallel_range(0, numEffectedE, + &data, + ccgSubSurf__calcVertNormals_edges_accumulate_cb, + numEffectedE * edgeSize * 4 >= CCG_OMP_LIMIT); + + BLI_task_parallel_range(0, numEffectedF, + &data, + ccgSubSurf__calcVertNormals_faces_finalize_cb, + numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT); + for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) { CCGEdge *e = (CCGEdge *) effectedE[ptrIdx]; @@ -322,100 +395,268 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, } } -static void ccgSubSurf__calcSubdivLevel( - CCGSubSurf *ss, - CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF, - const int numEffectedV, const int numEffectedE, const int numEffectedF, const int curLvl) + +static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_midpoints_cb(void *userdata, int ptrIdx) { + CCGSubSurfCalcSubdivData *data = userdata; + + CCGSubSurf *ss = data->ss; + CCGFace *f = data->effectedF[ptrIdx]; + const int subdivLevels = ss->subdivLevels; + const int curLvl = data->curLvl; const int nextLvl = curLvl + 1; - int edgeSize = ccg_edgesize(curLvl); - int gridSize = ccg_gridsize(curLvl); - int ptrIdx, i; - int vertDataSize = ss->meshIFC.vertDataSize; - float *q = ss->q, *r = ss->r; + const int gridSize = ccg_gridsize(curLvl); + const int vertDataSize = ss->meshIFC.vertDataSize; -#pragma omp parallel for private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) - for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { - CCGFace *f = (CCGFace *) effectedF[ptrIdx]; - int S, x, y; + int S, x, y; - /* interior face midpoints + /* interior face midpoints + * - old interior face points + */ + for (S = 0; S < f->numVerts; S++) { + for (y = 0; y < gridSize - 1; y++) { + for (x = 0; x < gridSize - 1; x++) { + int fx = 1 + 2 * x; + int fy = 1 + 2 * y; + const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0); + const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0); + const float *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1); + const float *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1); + float *co = FACE_getIFCo(f, nextLvl, S, fx, fy); + + VertDataAvg4(co, co0, co1, co2, co3, ss); + } + } + } + + /* interior edge midpoints + * - old interior edge points + * - new interior face midpoints + */ + for (S = 0; S < f->numVerts; S++) { + for (x = 0; x < gridSize - 1; x++) { + int fx = x * 2 + 1; + const float *co0 = FACE_getIECo(f, curLvl, S, x + 0); + const float *co1 = FACE_getIECo(f, curLvl, S, x + 1); + const float *co2 = FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx); + const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1); + float *co = FACE_getIECo(f, nextLvl, S, fx); + + VertDataAvg4(co, co0, co1, co2, co3, ss); + } + + /* interior face interior edge midpoints * - old interior face points + * - new interior face midpoints */ - for (S = 0; S < f->numVerts; S++) { + + /* vertical */ + for (x = 1; x < gridSize - 1; x++) { for (y = 0; y < gridSize - 1; y++) { - for (x = 0; x < gridSize - 1; x++) { - int fx = 1 + 2 * x; - int fy = 1 + 2 * y; - const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y + 0); - const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y + 0); - const float *co2 = FACE_getIFCo(f, curLvl, S, x + 1, y + 1); - const float *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1); - float *co = FACE_getIFCo(f, nextLvl, S, fx, fy); - - VertDataAvg4(co, co0, co1, co2, co3, ss); - } + int fx = x * 2; + int fy = y * 2 + 1; + const float *co0 = FACE_getIFCo(f, curLvl, S, x, y + 0); + const float *co1 = FACE_getIFCo(f, curLvl, S, x, y + 1); + const float *co2 = FACE_getIFCo(f, nextLvl, S, fx - 1, fy); + const float *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy); + float *co = FACE_getIFCo(f, nextLvl, S, fx, fy); + + VertDataAvg4(co, co0, co1, co2, co3, ss); } } - /* interior edge midpoints - * - old interior edge points - * - new interior face midpoints - */ - for (S = 0; S < f->numVerts; S++) { + /* horizontal */ + for (y = 1; y < gridSize - 1; y++) { for (x = 0; x < gridSize - 1; x++) { int fx = x * 2 + 1; - const float *co0 = FACE_getIECo(f, curLvl, S, x + 0); - const float *co1 = FACE_getIECo(f, curLvl, S, x + 1); - const float *co2 = FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx); - const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1); - float *co = FACE_getIECo(f, nextLvl, S, fx); - + int fy = y * 2; + const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y); + const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y); + const float *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy - 1); + const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1); + float *co = FACE_getIFCo(f, nextLvl, S, fx, fy); + VertDataAvg4(co, co0, co1, co2, co3, ss); } + } + } +} - /* interior face interior edge midpoints - * - old interior face points - * - new interior face midpoints - */ - - /* vertical */ - for (x = 1; x < gridSize - 1; x++) { - for (y = 0; y < gridSize - 1; y++) { - int fx = x * 2; - int fy = y * 2 + 1; - const float *co0 = FACE_getIFCo(f, curLvl, S, x, y + 0); - const float *co1 = FACE_getIFCo(f, curLvl, S, x, y + 1); - const float *co2 = FACE_getIFCo(f, nextLvl, S, fx - 1, fy); - const float *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy); - float *co = FACE_getIFCo(f, nextLvl, S, fx, fy); - - VertDataAvg4(co, co0, co1, co2, co3, ss); - } - } +static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_centerpoints_shift_cb(void *userdata, int ptrIdx) +{ + CCGSubSurfCalcSubdivData *data = userdata; + + CCGSubSurf *ss = data->ss; + CCGFace *f = data->effectedF[ptrIdx]; + + const int subdivLevels = ss->subdivLevels; + const int curLvl = data->curLvl; + const int nextLvl = curLvl + 1; + const int gridSize = ccg_gridsize(curLvl); + const int vertDataSize = ss->meshIFC.vertDataSize; + + float *q_thread = alloca(vertDataSize); + float *r_thread = alloca(vertDataSize); - /* horizontal */ + int S, x, y; + + /* interior center point shift + * - old face center point (shifting) + * - old interior edge points + * - new interior face midpoints + */ + VertDataZero(q_thread, ss); + for (S = 0; S < f->numVerts; S++) { + VertDataAdd(q_thread, FACE_getIFCo(f, nextLvl, S, 1, 1), ss); + } + VertDataMulN(q_thread, 1.0f / f->numVerts, ss); + VertDataZero(r_thread, ss); + for (S = 0; S < f->numVerts; S++) { + VertDataAdd(r_thread, FACE_getIECo(f, curLvl, S, 1), ss); + } + VertDataMulN(r_thread, 1.0f / f->numVerts, ss); + + VertDataMulN((float *)FACE_getCenterData(f), f->numVerts - 2.0f, ss); + VertDataAdd((float *)FACE_getCenterData(f), q_thread, ss); + VertDataAdd((float *)FACE_getCenterData(f), r_thread, ss); + VertDataMulN((float *)FACE_getCenterData(f), 1.0f / f->numVerts, ss); + + for (S = 0; S < f->numVerts; S++) { + /* interior face shift + * - old interior face point (shifting) + * - new interior edge midpoints + * - new interior face midpoints + */ + for (x = 1; x < gridSize - 1; x++) { for (y = 1; y < gridSize - 1; y++) { - for (x = 0; x < gridSize - 1; x++) { - int fx = x * 2 + 1; - int fy = y * 2; - const float *co0 = FACE_getIFCo(f, curLvl, S, x + 0, y); - const float *co1 = FACE_getIFCo(f, curLvl, S, x + 1, y); - const float *co2 = FACE_getIFCo(f, nextLvl, S, fx, fy - 1); - const float *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1); - float *co = FACE_getIFCo(f, nextLvl, S, fx, fy); - - VertDataAvg4(co, co0, co1, co2, co3, ss); - } + int fx = x * 2; + int fy = y * 2; + const float *co = FACE_getIFCo(f, curLvl, S, x, y); + float *nCo = FACE_getIFCo(f, nextLvl, S, fx, fy); + + VertDataAvg4(q_thread, + FACE_getIFCo(f, nextLvl, S, fx - 1, fy - 1), + FACE_getIFCo(f, nextLvl, S, fx + 1, fy - 1), + FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 1), + FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1), + ss); + + VertDataAvg4(r_thread, + FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 0), + FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 0), + FACE_getIFCo(f, nextLvl, S, fx + 0, fy - 1), + FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1), + ss); + + VertDataCopy(nCo, co, ss); + VertDataSub(nCo, q_thread, ss); + VertDataMulN(nCo, 0.25f, ss); + VertDataAdd(nCo, r_thread, ss); } } + + /* interior edge interior shift + * - old interior edge point (shifting) + * - new interior edge midpoints + * - new interior face midpoints + */ + for (x = 1; x < gridSize - 1; x++) { + int fx = x * 2; + const float *co = FACE_getIECo(f, curLvl, S, x); + float *nCo = FACE_getIECo(f, nextLvl, S, fx); + + VertDataAvg4(q_thread, + FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx - 1), + FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx + 1), + FACE_getIFCo(f, nextLvl, S, fx + 1, +1), + FACE_getIFCo(f, nextLvl, S, fx - 1, +1), + ss); + + VertDataAvg4(r_thread, + FACE_getIECo(f, nextLvl, S, fx - 1), + FACE_getIECo(f, nextLvl, S, fx + 1), + FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx), + FACE_getIFCo(f, nextLvl, S, fx, 1), + ss); + + VertDataCopy(nCo, co, ss); + VertDataSub(nCo, q_thread, ss); + VertDataMulN(nCo, 0.25f, ss); + VertDataAdd(nCo, r_thread, ss); + } } +} + +static void ccgSubSurf__calcSubdivLevel_verts_copydata_cb(void *userdata, int ptrIdx) +{ + CCGSubSurfCalcSubdivData *data = userdata; + + CCGSubSurf *ss = data->ss; + CCGFace *f = data->effectedF[ptrIdx]; + + const int subdivLevels = ss->subdivLevels; + const int nextLvl = data->curLvl + 1; + const int gridSize = ccg_gridsize(nextLvl); + const int cornerIdx = gridSize - 1; + const int vertDataSize = ss->meshIFC.vertDataSize; + + int S, x; + + for (S = 0; S < f->numVerts; S++) { + CCGEdge *e = FACE_getEdges(f)[S]; + CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts]; + + VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float *)FACE_getCenterData(f), ss); + VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float *)FACE_getCenterData(f), ss); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss); + VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx), ss); + for (x = 1; x < gridSize - 1; x++) { + float *co = FACE_getIECo(f, nextLvl, S, x); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, 0), co, ss); + VertDataCopy(FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 0, x), co, ss); + } + for (x = 0; x < gridSize - 1; x++) { + int eI = gridSize - 1 - x; + VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize), ss); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize), ss); + } + } +} + +static void ccgSubSurf__calcSubdivLevel( + CCGSubSurf *ss, + CCGVert **effectedV, CCGEdge **effectedE, CCGFace **effectedF, + const int numEffectedV, const int numEffectedE, const int numEffectedF, const int curLvl) +{ + const int subdivLevels = ss->subdivLevels; + const int nextLvl = curLvl + 1; + int edgeSize = ccg_edgesize(curLvl); + int ptrIdx, i; + const int vertDataSize = ss->meshIFC.vertDataSize; + float *q = ss->q, *r = ss->r; + + CCGSubSurfCalcSubdivData data = { + .ss = ss, + .effectedV = effectedV, + .effectedE = effectedE, + .effectedF = effectedF, + .numEffectedV = numEffectedV, + .numEffectedE = numEffectedE, + .numEffectedF = numEffectedF, + .curLvl = curLvl + }; + + BLI_task_parallel_range(0, numEffectedF, + &data, + ccgSubSurf__calcSubdivLevel_interior_faces_edges_midpoints_cb, + numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT); /* exterior edge midpoints * - old exterior edge points * - new interior face midpoints */ + /* Not worth parallelizing. */ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) { CCGEdge *e = (CCGEdge *) effectedE[ptrIdx]; float sharpness = EDGE_getSharpness(e, curLvl); @@ -470,6 +711,7 @@ static void ccgSubSurf__calcSubdivLevel( * - old exterior edge points * - new interior face midpoints */ + /* Not worth parallelizing. */ for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { CCGVert *v = (CCGVert *) effectedV[ptrIdx]; const float *co = VERT_getCo(v, curLvl); @@ -600,6 +842,7 @@ static void ccgSubSurf__calcSubdivLevel( * - old exterior edge midpoints * - new interior face midpoints */ + /* Not worth parallelizing. */ for (ptrIdx = 0; ptrIdx < numEffectedE; ptrIdx++) { CCGEdge *e = (CCGEdge *) effectedE[ptrIdx]; float sharpness = EDGE_getSharpness(e, curLvl); @@ -682,151 +925,25 @@ static void ccgSubSurf__calcSubdivLevel( } } -#pragma omp parallel private(ptrIdx) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) - { - float *q_thread, *r_thread; - -#pragma omp critical - { - q_thread = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf q"); - r_thread = MEM_mallocN(ss->meshIFC.vertDataSize, "CCGSubsurf r"); - } - -#pragma omp for schedule(static) - for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { - CCGFace *f = (CCGFace *) effectedF[ptrIdx]; - int S, x, y; - - /* interior center point shift - * - old face center point (shifting) - * - old interior edge points - * - new interior face midpoints - */ - VertDataZero(q_thread, ss); - for (S = 0; S < f->numVerts; S++) { - VertDataAdd(q_thread, FACE_getIFCo(f, nextLvl, S, 1, 1), ss); - } - VertDataMulN(q_thread, 1.0f / f->numVerts, ss); - VertDataZero(r_thread, ss); - for (S = 0; S < f->numVerts; S++) { - VertDataAdd(r_thread, FACE_getIECo(f, curLvl, S, 1), ss); - } - VertDataMulN(r_thread, 1.0f / f->numVerts, ss); - - VertDataMulN((float *)FACE_getCenterData(f), f->numVerts - 2.0f, ss); - VertDataAdd((float *)FACE_getCenterData(f), q_thread, ss); - VertDataAdd((float *)FACE_getCenterData(f), r_thread, ss); - VertDataMulN((float *)FACE_getCenterData(f), 1.0f / f->numVerts, ss); - - for (S = 0; S < f->numVerts; S++) { - /* interior face shift - * - old interior face point (shifting) - * - new interior edge midpoints - * - new interior face midpoints - */ - for (x = 1; x < gridSize - 1; x++) { - for (y = 1; y < gridSize - 1; y++) { - int fx = x * 2; - int fy = y * 2; - const float *co = FACE_getIFCo(f, curLvl, S, x, y); - float *nCo = FACE_getIFCo(f, nextLvl, S, fx, fy); - - VertDataAvg4(q_thread, - FACE_getIFCo(f, nextLvl, S, fx - 1, fy - 1), - FACE_getIFCo(f, nextLvl, S, fx + 1, fy - 1), - FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 1), - FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1), - ss); - - VertDataAvg4(r_thread, - FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 0), - FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 0), - FACE_getIFCo(f, nextLvl, S, fx + 0, fy - 1), - FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1), - ss); - - VertDataCopy(nCo, co, ss); - VertDataSub(nCo, q_thread, ss); - VertDataMulN(nCo, 0.25f, ss); - VertDataAdd(nCo, r_thread, ss); - } - } - - /* interior edge interior shift - * - old interior edge point (shifting) - * - new interior edge midpoints - * - new interior face midpoints - */ - for (x = 1; x < gridSize - 1; x++) { - int fx = x * 2; - const float *co = FACE_getIECo(f, curLvl, S, x); - float *nCo = FACE_getIECo(f, nextLvl, S, fx); - - VertDataAvg4(q_thread, - FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx - 1), - FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx + 1), - FACE_getIFCo(f, nextLvl, S, fx + 1, +1), - FACE_getIFCo(f, nextLvl, S, fx - 1, +1), ss); - - VertDataAvg4(r_thread, - FACE_getIECo(f, nextLvl, S, fx - 1), - FACE_getIECo(f, nextLvl, S, fx + 1), - FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx), - FACE_getIFCo(f, nextLvl, S, fx, 1), - ss); - - VertDataCopy(nCo, co, ss); - VertDataSub(nCo, q_thread, ss); - VertDataMulN(nCo, 0.25f, ss); - VertDataAdd(nCo, r_thread, ss); - } - } - } - -#pragma omp critical - { - MEM_freeN(q_thread); - MEM_freeN(r_thread); - } - } + BLI_task_parallel_range(0, numEffectedF, + &data, + ccgSubSurf__calcSubdivLevel_interior_faces_edges_centerpoints_shift_cb, + numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT); /* copy down */ edgeSize = ccg_edgesize(nextLvl); - gridSize = ccg_gridsize(nextLvl); - const int cornerIdx = gridSize - 1; -#pragma omp parallel for private(i) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) + /* Not worth parallelizing. */ for (i = 0; i < numEffectedE; i++) { CCGEdge *e = effectedE[i]; VertDataCopy(EDGE_getCo(e, nextLvl, 0), VERT_getCo(e->v0, nextLvl), ss); VertDataCopy(EDGE_getCo(e, nextLvl, edgeSize - 1), VERT_getCo(e->v1, nextLvl), ss); } -#pragma omp parallel for private(i) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) - for (i = 0; i < numEffectedF; i++) { - CCGFace *f = effectedF[i]; - int S, x; - - for (S = 0; S < f->numVerts; S++) { - CCGEdge *e = FACE_getEdges(f)[S]; - CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts]; - - VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float *)FACE_getCenterData(f), ss); - VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float *)FACE_getCenterData(f), ss); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss); - VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx), ss); - for (x = 1; x < gridSize - 1; x++) { - float *co = FACE_getIECo(f, nextLvl, S, x); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, 0), co, ss); - VertDataCopy(FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 0, x), co, ss); - } - for (x = 0; x < gridSize - 1; x++) { - int eI = gridSize - 1 - x; - VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize), ss); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize), ss); - } - } - } + BLI_task_parallel_range(0, numEffectedF, + &data, + ccgSubSurf__calcSubdivLevel_verts_copydata_cb, + numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT); } void ccgSubSurf__sync_legacy(CCGSubSurf *ss) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index df21512a262..ee80438db64 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -61,9 +61,10 @@ #include "BLF_api.h" -static void slice_get_byte_buffers(const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2, - const ImBuf *ibuf3, const ImBuf *out, int start_line, unsigned char **rect1, - unsigned char **rect2, unsigned char **rect3, unsigned char **rect_out) +static void slice_get_byte_buffers( + const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2, + const ImBuf *ibuf3, const ImBuf *out, int start_line, unsigned char **rect1, + unsigned char **rect2, unsigned char **rect3, unsigned char **rect_out) { int offset = 4 * start_line * context->rectx; @@ -77,9 +78,10 @@ static void slice_get_byte_buffers(const SeqRenderData *context, const ImBuf *ib *rect3 = (unsigned char *)ibuf3->rect + offset; } -static void slice_get_float_buffers(const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2, - const ImBuf *ibuf3, const ImBuf *out, int start_line, - float **rect1, float **rect2, float **rect3, float **rect_out) +static void slice_get_float_buffers( + const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2, + const ImBuf *ibuf3, const ImBuf *out, int start_line, + float **rect1, float **rect2, float **rect3, float **rect_out) { int offset = 4 * start_line * context->rectx; @@ -173,7 +175,9 @@ static void init_alpha_over_or_under(Sequence *seq) seq->seq1 = seq2; } -static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) +static void do_alphaover_effect_byte( + float facf0, float facf1, int x, int y, + unsigned char *rect1, unsigned char *rect2, unsigned char *out) { float fac2, mfac, fac, fac4; int xo; @@ -238,7 +242,9 @@ static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y, un } } -static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, float *rect1, float *rect2, float *out) +static void do_alphaover_effect_float( + float facf0, float facf1, int x, int y, + float *rect1, float *rect2, float *out) { float fac2, mfac, fac, fac4; int xo; @@ -301,9 +307,10 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, f } } -static void do_alphaover_effect(const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, - float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), - int start_line, int total_lines, ImBuf *out) +static void do_alphaover_effect( + const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, + float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), + int start_line, int total_lines, ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; @@ -323,7 +330,9 @@ static void do_alphaover_effect(const SeqRenderData *context, Sequence *UNUSED(s /*********************** Alpha Under *************************/ -static void do_alphaunder_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) +static void do_alphaunder_effect_byte( + float facf0, float facf1, int x, int y, + unsigned char *rect1, unsigned char *rect2, unsigned char *out) { float fac2, fac, fac4; int xo; @@ -395,7 +404,9 @@ static void do_alphaunder_effect_byte(float facf0, float facf1, int x, int y, un } } -static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, float *rect1, float *rect2, float *out) +static void do_alphaunder_effect_float( + float facf0, float facf1, int x, int y, + float *rect1, float *rect2, float *out) { float fac2, fac, fac4; int xo; @@ -469,9 +480,10 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, } } -static void do_alphaunder_effect(const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), - int start_line, int total_lines, ImBuf *out) +static void do_alphaunder_effect( + const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), + int start_line, int total_lines, ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; @@ -491,7 +503,9 @@ static void do_alphaunder_effect(const SeqRenderData *context, Sequence *UNUSED( /*********************** Cross *************************/ -static void do_cross_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) +static void do_cross_effect_byte( + float facf0, float facf1, int x, int y, + unsigned char *rect1, unsigned char *rect2, unsigned char *out) { int fac1, fac2, fac3, fac4; int xo; @@ -579,9 +593,10 @@ static void do_cross_effect_float(float facf0, float facf1, int x, int y, float } } -static void do_cross_effect(const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), - int start_line, int total_lines, ImBuf *out) +static void do_cross_effect( + const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), + int start_line, int total_lines, ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; @@ -739,8 +754,9 @@ static void free_gammacross(Sequence *UNUSED(seq)) { } -static void do_gammacross_effect_byte(float facf0, float UNUSED(facf1), int x, int y, unsigned char *rect1, - unsigned char *rect2, unsigned char *out) +static void do_gammacross_effect_byte( + float facf0, float UNUSED(facf1), int x, int y, unsigned char *rect1, + unsigned char *rect2, unsigned char *out) { float fac1, fac2; int xo; @@ -790,8 +806,9 @@ static void do_gammacross_effect_byte(float facf0, float UNUSED(facf1), int x, } } -static void do_gammacross_effect_float(float facf0, float UNUSED(facf1), int x, int y, float *rect1, - float *rect2, float *out) +static void do_gammacross_effect_float( + float facf0, float UNUSED(facf1), int x, int y, float *rect1, + float *rect2, float *out) { float fac1, fac2; int xo; @@ -833,9 +850,10 @@ static struct ImBuf *gammacross_init_execution(const SeqRenderData *context, ImB return out; } -static void do_gammacross_effect(const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), - int start_line, int total_lines, ImBuf *out) +static void do_gammacross_effect( + const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), + int start_line, int total_lines, ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; @@ -855,8 +873,9 @@ static void do_gammacross_effect(const SeqRenderData *context, Sequence *UNUSED( /*********************** Add *************************/ -static void do_add_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, - unsigned char *out) +static void do_add_effect_byte( + float facf0, float facf1, int x, int y, + unsigned char *rect1, unsigned char *rect2, unsigned char *out) { int xo, fac1, fac3; unsigned char *cp1, *cp2, *rt; @@ -942,8 +961,9 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, float *r } } -static void do_add_effect(const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) +static void do_add_effect( + const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; @@ -963,7 +983,9 @@ static void do_add_effect(const SeqRenderData *context, Sequence *UNUSED(seq), f /*********************** Sub *************************/ -static void do_sub_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) +static void do_sub_effect_byte( + float facf0, float facf1, int x, int y, + unsigned char *rect1, unsigned char *rect2, unsigned char *out) { int xo, fac1, fac3; unsigned char *cp1, *cp2, *rt; @@ -1005,7 +1027,9 @@ static void do_sub_effect_byte(float facf0, float facf1, int x, int y, unsigned } } -static void do_sub_effect_float(float UNUSED(facf0), float facf1, int x, int y, float *rect1, float *rect2, float *out) +static void do_sub_effect_float( + float UNUSED(facf0), float facf1, int x, int y, + float *rect1, float *rect2, float *out) { int xo; float /* fac1, */ fac3_inv; @@ -1049,8 +1073,9 @@ static void do_sub_effect_float(float UNUSED(facf0), float facf1, int x, int y, } } -static void do_sub_effect(const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) +static void do_sub_effect( + const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; @@ -1074,7 +1099,9 @@ static void do_sub_effect(const SeqRenderData *context, Sequence *UNUSED(seq), f #define XOFF 8 #define YOFF 8 -static void do_drop_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect2i, unsigned char *rect1i, unsigned char *outi) +static void do_drop_effect_byte( + float facf0, float facf1, int x, int y, + unsigned char *rect2i, unsigned char *rect1i, unsigned char *outi) { int temp, fac, fac1, fac2; unsigned char *rt1, *rt2, *out; @@ -1114,7 +1141,9 @@ static void do_drop_effect_byte(float facf0, float facf1, int x, int y, unsigned memcpy(out, rt1, sizeof(*out) * yoff * 4 * width); } -static void do_drop_effect_float(float facf0, float facf1, int x, int y, float *rect2i, float *rect1i, float *outi) +static void do_drop_effect_float( + float facf0, float facf1, int x, int y, + float *rect2i, float *rect1i, float *outi) { float temp, fac, fac1, fac2; float *rt1, *rt2, *out; @@ -1156,8 +1185,9 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y, float * /*********************** Mul *************************/ -static void do_mul_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, - unsigned char *out) +static void do_mul_effect_byte( + float facf0, float facf1, int x, int y, + unsigned char *rect1, unsigned char *rect2, unsigned char *out) { int xo, fac1, fac3; unsigned char *rt1, *rt2, *rt; @@ -1204,7 +1234,9 @@ static void do_mul_effect_byte(float facf0, float facf1, int x, int y, unsigned } } -static void do_mul_effect_float(float facf0, float facf1, int x, int y, float *rect1, float *rect2, float *out) +static void do_mul_effect_float( + float facf0, float facf1, int x, int y, + float *rect1, float *rect2, float *out) { int xo; float fac1, fac3; @@ -1249,8 +1281,9 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, float *r } } -static void do_mul_effect(const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) +static void do_mul_effect( + const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; @@ -1272,7 +1305,9 @@ static void do_mul_effect(const SeqRenderData *context, Sequence *UNUSED(seq), f typedef void (*IMB_blend_func_byte)(unsigned char *dst, const unsigned char *src1, const unsigned char *src2); typedef void (*IMB_blend_func_float)(float *dst, const float *src1, const float *src2); -BLI_INLINE void apply_blend_function_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out, IMB_blend_func_byte blend_function) +BLI_INLINE void apply_blend_function_byte( + float facf0, float facf1, int x, int y, + unsigned char *rect1, unsigned char *rect2, unsigned char *out, IMB_blend_func_byte blend_function) { int xo; unsigned char *rt1, *rt2, *rt; @@ -1309,7 +1344,9 @@ BLI_INLINE void apply_blend_function_byte(float facf0, float facf1, int x, int y } } -BLI_INLINE void apply_blend_function_float(float facf0, float facf1, int x, int y, float *rect1, float *rect2, float *out, IMB_blend_func_float blend_function) +BLI_INLINE void apply_blend_function_float( + float facf0, float facf1, int x, int y, + float *rect1, float *rect2, float *out, IMB_blend_func_float blend_function) { int xo; float *rt1, *rt2, *rt; @@ -1346,7 +1383,9 @@ BLI_INLINE void apply_blend_function_float(float facf0, float facf1, int x, int } } -static void do_blend_effect_float(float facf0, float facf1, int x, int y, float *rect1, float *rect2, int btype, float *out) +static void do_blend_effect_float( + float facf0, float facf1, int x, int y, + float *rect1, float *rect2, int btype, float *out) { switch (btype) { case SEQ_TYPE_ADD: @@ -1417,7 +1456,9 @@ static void do_blend_effect_float(float facf0, float facf1, int x, int y, float } } -static void do_blend_effect_byte(float facf0, float facf1, int x, int y, unsigned char *rect1, unsigned char *rect2, int btype, unsigned char *out) +static void do_blend_effect_byte( + float facf0, float facf1, int x, int y, + unsigned char *rect1, unsigned char *rect2, int btype, unsigned char *out) { switch (btype) { case SEQ_TYPE_ADD: @@ -1488,8 +1529,9 @@ static void do_blend_effect_byte(float facf0, float facf1, int x, int y, unsigne } } -static void do_blend_mode_effect(const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) +static void do_blend_mode_effect( + const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; @@ -1507,7 +1549,7 @@ static void init_colormix_effect(Sequence *seq) { ColorMixVars *data; - if (seq->effectdata){ + if (seq->effectdata) { MEM_freeN(seq->effectdata); } seq->effectdata = MEM_callocN(sizeof(ColorMixVars), "colormixvars"); @@ -1516,8 +1558,9 @@ static void init_colormix_effect(Sequence *seq) data->factor = 1.0f; } -static void do_colormix_effect(const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float UNUSED(facf0), float UNUSED(facf1), - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) +static void do_colormix_effect( + const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float UNUSED(facf0), float UNUSED(facf1), + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) { float facf; @@ -1840,8 +1883,9 @@ static void copy_wipe_effect(Sequence *dst, Sequence *src) dst->effectdata = MEM_dupallocN(src->effectdata); } -static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, unsigned char *rect1, - unsigned char *rect2, unsigned char *out) +static void do_wipe_effect_byte( + Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, + unsigned char *rect1, unsigned char *rect2, unsigned char *out) { WipeZone wipezone; WipeVars *wipe = (WipeVars *)seq->effectdata; @@ -1906,8 +1950,9 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), } } -static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, float *rect1, - float *rect2, float *out) +static void do_wipe_effect_float( + Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, + float *rect1, float *rect2, float *out) { WipeZone wipezone; WipeVars *wipe = (WipeVars *)seq->effectdata; @@ -1965,18 +2010,21 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1) } } -static ImBuf *do_wipe_effect(const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) +static ImBuf *do_wipe_effect( + const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) { ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { - do_wipe_effect_float(seq, facf0, facf1, context->rectx, context->recty, ibuf1->rect_float, - ibuf2->rect_float, out->rect_float); + do_wipe_effect_float( + seq, facf0, facf1, context->rectx, context->recty, ibuf1->rect_float, + ibuf2->rect_float, out->rect_float); } else { - do_wipe_effect_byte(seq, facf0, facf1, context->rectx, context->recty, (unsigned char *) ibuf1->rect, - (unsigned char *) ibuf2->rect, (unsigned char *) out->rect); + do_wipe_effect_byte( + seq, facf0, facf1, context->rectx, context->recty, (unsigned char *) ibuf1->rect, + (unsigned char *) ibuf2->rect, (unsigned char *) out->rect); } return out; @@ -2024,8 +2072,9 @@ static void copy_transform_effect(Sequence *dst, Sequence *src) dst->effectdata = MEM_dupallocN(src->effectdata); } -static void transform_image(int x, int y, ImBuf *ibuf1, ImBuf *out, float scale_x, float scale_y, - float translate_x, float translate_y, float rotate, int interpolation) +static void transform_image( + int x, int y, ImBuf *ibuf1, ImBuf *out, float scale_x, float scale_y, + float translate_x, float translate_y, float rotate, int interpolation) { int xo, yo, xi, yi; float xt, yt, xr, yr; @@ -2105,8 +2154,9 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x } -static ImBuf *do_transform_effect(const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, - float UNUSED(facf1), ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) +static ImBuf *do_transform_effect( + const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, + float UNUSED(facf1), ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) { ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); @@ -2277,7 +2327,9 @@ static void RVAddBitmaps_float(float *a, float *b, float *c, int width, int heig } } -static void RVIsolateHighlights_float(float *in, float *out, int width, int height, float threshold, float boost, float clamp) +static void RVIsolateHighlights_float( + float *in, float *out, int width, int height, + float threshold, float boost, float clamp) { int x, y, index; float intensity; @@ -2340,8 +2392,9 @@ static void copy_glow_effect(Sequence *dst, Sequence *src) dst->effectdata = MEM_dupallocN(src->effectdata); } -static void do_glow_effect_byte(Sequence *seq, int render_size, float facf0, float UNUSED(facf1), int x, int y, - unsigned char *rect1, unsigned char *UNUSED(rect2), unsigned char *out) +static void do_glow_effect_byte( + Sequence *seq, int render_size, float facf0, float UNUSED(facf1), int x, int y, + unsigned char *rect1, unsigned char *UNUSED(rect2), unsigned char *out) { float *outbuf, *inbuf; GlowVars *glow = (GlowVars *)seq->effectdata; @@ -2364,8 +2417,9 @@ static void do_glow_effect_byte(Sequence *seq, int render_size, float facf0, flo MEM_freeN(outbuf); } -static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, float UNUSED(facf1), int x, int y, - float *rect1, float *UNUSED(rect2), float *out) +static void do_glow_effect_float( + Sequence *seq, int render_size, float facf0, float UNUSED(facf1), int x, int y, + float *rect1, float *UNUSED(rect2), float *out) { float *outbuf = out; float *inbuf = rect1; @@ -2377,20 +2431,23 @@ static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, fl RVAddBitmaps_float(inbuf, outbuf, outbuf, x, y); } -static ImBuf *do_glow_effect(const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) +static ImBuf *do_glow_effect( + const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) { ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int render_size = 100 * context->rectx / context->scene->r.xsch; if (out->rect_float) { - do_glow_effect_float(seq, render_size, facf0, facf1, context->rectx, context->recty, - ibuf1->rect_float, ibuf2->rect_float, out->rect_float); + do_glow_effect_float( + seq, render_size, facf0, facf1, context->rectx, context->recty, + ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { - do_glow_effect_byte(seq, render_size, facf0, facf1, context->rectx, context->recty, - (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, (unsigned char *) out->rect); + do_glow_effect_byte( + seq, render_size, facf0, facf1, context->rectx, context->recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, (unsigned char *) out->rect); } return out; @@ -2434,8 +2491,9 @@ static int early_out_color(Sequence *UNUSED(seq), float UNUSED(facf0), float UNU return EARLY_NO_INPUT; } -static ImBuf *do_solid_color(const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) +static ImBuf *do_solid_color( + const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) { ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); @@ -2527,8 +2585,9 @@ static int early_out_multicam(Sequence *UNUSED(seq), float UNUSED(facf0), float return EARLY_NO_INPUT; } -static ImBuf *do_multicam(const SeqRenderData *context, Sequence *seq, float cfra, float UNUSED(facf0), float UNUSED(facf1), - ImBuf *UNUSED(ibuf1), ImBuf *UNUSED(ibuf2), ImBuf *UNUSED(ibuf3)) +static ImBuf *do_multicam( + const SeqRenderData *context, Sequence *seq, float cfra, float UNUSED(facf0), float UNUSED(facf1), + ImBuf *UNUSED(ibuf1), ImBuf *UNUSED(ibuf2), ImBuf *UNUSED(ibuf3)) { ImBuf *i; ImBuf *out; @@ -2609,8 +2668,9 @@ static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, fl return i; } -static ImBuf *do_adjustment(const SeqRenderData *context, Sequence *seq, float cfra, float UNUSED(facf0), float UNUSED(facf1), - ImBuf *UNUSED(ibuf1), ImBuf *UNUSED(ibuf2), ImBuf *UNUSED(ibuf3)) +static ImBuf *do_adjustment( + const SeqRenderData *context, Sequence *seq, float cfra, float UNUSED(facf0), float UNUSED(facf1), + ImBuf *UNUSED(ibuf1), ImBuf *UNUSED(ibuf2), ImBuf *UNUSED(ibuf3)) { ImBuf *i = NULL; ImBuf *out; @@ -2825,26 +2885,30 @@ void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, bool for } } -static ImBuf *do_speed_effect(const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) +static ImBuf *do_speed_effect( + const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) { ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { - do_cross_effect_float(facf0, facf1, context->rectx, context->recty, - ibuf1->rect_float, ibuf2->rect_float, out->rect_float); + do_cross_effect_float( + facf0, facf1, context->rectx, context->recty, + ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { - do_cross_effect_byte(facf0, facf1, context->rectx, context->recty, - (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, (unsigned char *) out->rect); + do_cross_effect_byte( + facf0, facf1, context->rectx, context->recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, (unsigned char *) out->rect); } return out; } /*********************** overdrop *************************/ -static void do_overdrop_effect(const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) +static void do_overdrop_effect( + const SeqRenderData *context, Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *UNUSED(ibuf3), int start_line, int total_lines, ImBuf *out) { int x = context->rectx; int y = total_lines; @@ -2938,13 +3002,14 @@ static float *make_gaussian_blur_kernel(float rad, int size) return gausstab; } -static void do_gaussian_blur_effect_byte_x(Sequence *seq, - int start_line, - int x, int y, - int frame_width, - int UNUSED(frame_height), - unsigned char *rect, - unsigned char *out) +static void do_gaussian_blur_effect_byte_x( + Sequence *seq, + int start_line, + int x, int y, + int frame_width, + int UNUSED(frame_height), + unsigned char *rect, + unsigned char *out) { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = seq->effectdata; @@ -2990,13 +3055,14 @@ static void do_gaussian_blur_effect_byte_x(Sequence *seq, #undef INDEX } -static void do_gaussian_blur_effect_byte_y(Sequence *seq, - int start_line, - int x, int y, - int UNUSED(frame_width), - int frame_height, - unsigned char *rect, - unsigned char *out) +static void do_gaussian_blur_effect_byte_y( + Sequence *seq, + int start_line, + int x, int y, + int UNUSED(frame_width), + int frame_height, + unsigned char *rect, + unsigned char *out) { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = seq->effectdata; @@ -3042,13 +3108,14 @@ static void do_gaussian_blur_effect_byte_y(Sequence *seq, #undef INDEX } -static void do_gaussian_blur_effect_float_x(Sequence *seq, - int start_line, - int x, int y, - int frame_width, - int UNUSED(frame_height), - float *rect, - float *out) +static void do_gaussian_blur_effect_float_x( + Sequence *seq, + int start_line, + int x, int y, + int frame_width, + int UNUSED(frame_height), + float *rect, + float *out) { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = seq->effectdata; @@ -3085,13 +3152,14 @@ static void do_gaussian_blur_effect_float_x(Sequence *seq, #undef INDEX } -static void do_gaussian_blur_effect_float_y(Sequence *seq, - int start_line, - int x, int y, - int UNUSED(frame_width), - int frame_height, - float *rect, - float *out) +static void do_gaussian_blur_effect_float_y( + Sequence *seq, + int start_line, + int x, int y, + int UNUSED(frame_width), + int frame_height, + float *rect, + float *out) { #define INDEX(_x, _y) (((_y) * (x) + (_x)) * 4) GaussianBlurVars *data = seq->effectdata; @@ -3130,113 +3198,123 @@ static void do_gaussian_blur_effect_float_y(Sequence *seq, #undef INDEX } -static void do_gaussian_blur_effect_x_cb(const SeqRenderData *context, - Sequence *seq, - ImBuf *ibuf, - int start_line, - int total_lines, - ImBuf *out) +static void do_gaussian_blur_effect_x_cb( + const SeqRenderData *context, + Sequence *seq, + ImBuf *ibuf, + int start_line, + int total_lines, + ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slice_get_float_buffers(context, - ibuf, - NULL, - NULL, - out, - start_line, - &rect1, - &rect2, - NULL, - &rect_out); - - do_gaussian_blur_effect_float_x(seq, - start_line, - context->rectx, - total_lines, - context->rectx, - context->recty, - ibuf->rect_float, - rect_out); + slice_get_float_buffers( + context, + ibuf, + NULL, + NULL, + out, + start_line, + &rect1, + &rect2, + NULL, + &rect_out); + + do_gaussian_blur_effect_float_x( + seq, + start_line, + context->rectx, + total_lines, + context->rectx, + context->recty, + ibuf->rect_float, + rect_out); } else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slice_get_byte_buffers(context, - ibuf, - NULL, - NULL, - out, - start_line, - &rect1, - &rect2, - NULL, - &rect_out); - - do_gaussian_blur_effect_byte_x(seq, - start_line, - context->rectx, - total_lines, - context->rectx, - context->recty, - (unsigned char *) ibuf->rect, - rect_out); - } -} - -static void do_gaussian_blur_effect_y_cb(const SeqRenderData *context, - Sequence *seq, - ImBuf *ibuf, - int start_line, - int total_lines, - ImBuf *out) + slice_get_byte_buffers( + context, + ibuf, + NULL, + NULL, + out, + start_line, + &rect1, + &rect2, + NULL, + &rect_out); + + do_gaussian_blur_effect_byte_x( + seq, + start_line, + context->rectx, + total_lines, + context->rectx, + context->recty, + (unsigned char *) ibuf->rect, + rect_out); + } +} + +static void do_gaussian_blur_effect_y_cb( + const SeqRenderData *context, + Sequence *seq, + ImBuf *ibuf, + int start_line, + int total_lines, + ImBuf *out) { if (out->rect_float) { float *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slice_get_float_buffers(context, - ibuf, - NULL, - NULL, - out, - start_line, - &rect1, - &rect2, - NULL, - &rect_out); - - do_gaussian_blur_effect_float_y(seq, - start_line, - context->rectx, - total_lines, - context->rectx, - context->recty, - ibuf->rect_float, - rect_out); + slice_get_float_buffers( + context, + ibuf, + NULL, + NULL, + out, + start_line, + &rect1, + &rect2, + NULL, + &rect_out); + + do_gaussian_blur_effect_float_y( + seq, + start_line, + context->rectx, + total_lines, + context->rectx, + context->recty, + ibuf->rect_float, + rect_out); } else { unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL; - slice_get_byte_buffers(context, - ibuf, - NULL, - NULL, - out, - start_line, - &rect1, - &rect2, - NULL, - &rect_out); - - do_gaussian_blur_effect_byte_y(seq, - start_line, - context->rectx, - total_lines, - context->rectx, - context->recty, - (unsigned char *) ibuf->rect, - rect_out); + slice_get_byte_buffers( + context, + ibuf, + NULL, + NULL, + out, + start_line, + &rect1, + &rect2, + NULL, + &rect_out); + + do_gaussian_blur_effect_byte_y( + seq, + start_line, + context->rectx, + total_lines, + context->rectx, + context->recty, + (unsigned char *) ibuf->rect, + rect_out); } } @@ -3255,10 +3333,11 @@ typedef struct RenderGaussianBlurEffectThread { int start_line, tot_line; } RenderGaussianBlurEffectThread; -static void render_effect_execute_init_handle(void *handle_v, - int start_line, - int tot_line, - void *init_data_v) +static void render_effect_execute_init_handle( + void *handle_v, + int start_line, + int tot_line, + void *init_data_v) { RenderGaussianBlurEffectThread *handle = (RenderGaussianBlurEffectThread *) handle_v; RenderGaussianBlurEffectInitData *init_data = (RenderGaussianBlurEffectInitData *) init_data_v; @@ -3275,36 +3354,39 @@ static void render_effect_execute_init_handle(void *handle_v, static void *render_effect_execute_do_x_thread(void *thread_data_v) { RenderGaussianBlurEffectThread *thread_data = (RenderGaussianBlurEffectThread *) thread_data_v; - do_gaussian_blur_effect_x_cb(thread_data->context, - thread_data->seq, - thread_data->ibuf, - thread_data->start_line, - thread_data->tot_line, - thread_data->out); + do_gaussian_blur_effect_x_cb( + thread_data->context, + thread_data->seq, + thread_data->ibuf, + thread_data->start_line, + thread_data->tot_line, + thread_data->out); return NULL; } static void *render_effect_execute_do_y_thread(void *thread_data_v) { RenderGaussianBlurEffectThread *thread_data = (RenderGaussianBlurEffectThread *) thread_data_v; - do_gaussian_blur_effect_y_cb(thread_data->context, - thread_data->seq, - thread_data->ibuf, - thread_data->start_line, - thread_data->tot_line, - thread_data->out); + do_gaussian_blur_effect_y_cb( + thread_data->context, + thread_data->seq, + thread_data->ibuf, + thread_data->start_line, + thread_data->tot_line, + thread_data->out); return NULL; } -static ImBuf *do_gaussian_blur_effect(const SeqRenderData *context, - Sequence *seq, - float UNUSED(cfra), - float UNUSED(facf0), - float UNUSED(facf1), - ImBuf *ibuf1, - ImBuf *UNUSED(ibuf2), - ImBuf *UNUSED(ibuf3)) +static ImBuf *do_gaussian_blur_effect( + const SeqRenderData *context, + Sequence *seq, + float UNUSED(cfra), + float UNUSED(facf0), + float UNUSED(facf1), + ImBuf *ibuf1, + ImBuf *UNUSED(ibuf2), + ImBuf *UNUSED(ibuf3)) { ImBuf *out = prepare_effect_imbufs(context, ibuf1, NULL, NULL); @@ -3315,22 +3397,24 @@ static ImBuf *do_gaussian_blur_effect(const SeqRenderData *context, init_data.ibuf = ibuf1; init_data.out = out; - IMB_processor_apply_threaded(out->y, - sizeof(RenderGaussianBlurEffectThread), - &init_data, - render_effect_execute_init_handle, - render_effect_execute_do_x_thread); + IMB_processor_apply_threaded( + out->y, + sizeof(RenderGaussianBlurEffectThread), + &init_data, + render_effect_execute_init_handle, + render_effect_execute_do_x_thread); ibuf1 = out; init_data.ibuf = ibuf1; out = prepare_effect_imbufs(context, ibuf1, NULL, NULL); init_data.out = out; - IMB_processor_apply_threaded(out->y, - sizeof(RenderGaussianBlurEffectThread), - &init_data, - render_effect_execute_init_handle, - render_effect_execute_do_y_thread); + IMB_processor_apply_threaded( + out->y, + sizeof(RenderGaussianBlurEffectThread), + &init_data, + render_effect_execute_init_handle, + render_effect_execute_do_y_thread); IMB_freeImBuf(ibuf1); @@ -3374,8 +3458,9 @@ static int early_out_text(Sequence *seq, float UNUSED(facf0), float UNUSED(facf1 return EARLY_NO_INPUT; } -static ImBuf *do_text_effect(const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float UNUSED(facf0), float UNUSED(facf1), - ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) +static ImBuf *do_text_effect( + const SeqRenderData *context, Sequence *seq, float UNUSED(cfra), float UNUSED(facf0), float UNUSED(facf1), + ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *ibuf3) { ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); TextVars *data = seq->effectdata; diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index 2720c0058b7..b4819ff4e55 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -20,16 +20,18 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. - * * ***** END GPL LICENSE BLOCK ***** */ - + #ifndef __BLI_GHASH_H__ #define __BLI_GHASH_H__ /** \file BLI_ghash.h * \ingroup bli + * + * GHash is a hash-map implementation (unordered key, value pairs). + * + * This is also used to implement a 'set' (see #GSet below). */ #include "BLI_sys_types.h" /* for bool */ @@ -81,11 +83,14 @@ enum { /* *** */ -GHash *BLI_ghash_new_ex(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info, - const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; -GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; -GHash *BLI_ghash_copy(GHash *gh, GHashKeyCopyFP keycopyfp, - GHashValCopyFP valcopyfp) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_new_ex( + GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info, + const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_new( + GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_copy( + GHash *gh, GHashKeyCopyFP keycopyfp, + GHashValCopyFP valcopyfp) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); void BLI_ghash_reserve(GHash *gh, const unsigned int nentries_reserve); void BLI_ghash_insert(GHash *gh, void *key, void *val); @@ -97,9 +102,11 @@ void **BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT; bool BLI_ghash_ensure_p(GHash *gh, void *key, void ***r_val) ATTR_WARN_UNUSED_RESULT; bool BLI_ghash_ensure_p_ex(GHash *gh, const void *key, void ***r_key, void ***r_val) ATTR_WARN_UNUSED_RESULT; bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); -void BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); -void BLI_ghash_clear_ex(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp, - const unsigned int nentries_reserve); +void BLI_ghash_clear( + GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp); +void BLI_ghash_clear_ex( + GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp, + const unsigned int nentries_reserve); void *BLI_ghash_popkey(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp) ATTR_WARN_UNUSED_RESULT; bool BLI_ghash_haskey(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT; bool BLI_ghash_pop(GHash *gh, GHashIterState *state, void **r_key, void **r_val) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); @@ -193,18 +200,26 @@ bool BLI_ghashutil_uinthash_v4_cmp(const void *a, const void *b); /** \} */ -GHash *BLI_ghash_ptr_new_ex(const char *info, - const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; -GHash *BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; -GHash *BLI_ghash_str_new_ex(const char *info, - const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; -GHash *BLI_ghash_str_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; -GHash *BLI_ghash_int_new_ex(const char *info, - const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; -GHash *BLI_ghash_int_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; -GHash *BLI_ghash_pair_new_ex(const char *info, - const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; -GHash *BLI_ghash_pair_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_ptr_new_ex( + const char *info, + const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_ptr_new( + const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_str_new_ex( + const char *info, + const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_str_new( + const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_int_new_ex( + const char *info, + const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_int_new( + const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_pair_new_ex( + const char *info, + const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GHash *BLI_ghash_pair_new( + const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; typedef struct GHashPair { const void *first; @@ -216,8 +231,12 @@ unsigned int BLI_ghashutil_pairhash(const void *ptr); bool BLI_ghashutil_paircmp(const void *a, const void *b); void BLI_ghashutil_pairfree(void *ptr); - -/* *** */ +/** + * GSet is a 'set' implementation (unordered collection of unique elements). + * + * Internally this is a 'GHash' without any keys, + * which is why this API's are in the same header & source file. + */ typedef struct GSet GSet; @@ -237,8 +256,9 @@ typedef struct GSetIterator { ; } GSetIterator; -GSet *BLI_gset_new_ex(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info, - const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; +GSet *BLI_gset_new_ex( + GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info, + const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; GSet *BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; GSet *BLI_gset_copy(GSet *gs, GSetKeyCopyFP keycopyfp) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT; unsigned int BLI_gset_size(GSet *gs) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 432c82afe4a..1b96237e262 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -254,8 +254,8 @@ void BM_mesh_select_mode_flush_ex(BMesh *bm, const short selectmode) /* both loops only set edge/face flags and read off verts */ BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && - BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && + !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { BM_elem_flag_enable(e, BM_ELEM_SELECT); } @@ -366,8 +366,8 @@ void BM_mesh_select_flush(BMesh *bm) BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e->v1, BM_ELEM_SELECT) && - BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && - !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) + BM_elem_flag_test(e->v2, BM_ELEM_SELECT) && + !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { BM_elem_flag_enable(e, BM_ELEM_SELECT); } diff --git a/source/blender/bmesh/operators/bmo_rotate_edges.c b/source/blender/bmesh/operators/bmo_rotate_edges.c index dd6bf77dd3c..9832fdb57d3 100644 --- a/source/blender/bmesh/operators/bmo_rotate_edges.c +++ b/source/blender/bmesh/operators/bmo_rotate_edges.c @@ -18,7 +18,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -/** \file blender/bmesh/operators/bmo_rotate_edge.c +/** \file blender/bmesh/operators/bmo_rotate_edges.c * \ingroup bmesh * * Rotate edges topology that share two faces. diff --git a/source/blender/python/intern/bpy_capi_utils.h b/source/blender/python/intern/bpy_capi_utils.h index 171c46d8e86..abb37d6e30c 100644 --- a/source/blender/python/intern/bpy_capi_utils.h +++ b/source/blender/python/intern/bpy_capi_utils.h @@ -24,8 +24,8 @@ * \ingroup pythonintern */ -#ifndef __BPY_UTIL_H__ -#define __BPY_UTIL_H__ +#ifndef __BPY_CAPI_UTILS_H__ +#define __BPY_CAPI_UTILS_H__ #if PY_VERSION_HEX < 0x03060000 # error "Python 3.6 or greater is required, you'll need to update your python." @@ -50,4 +50,4 @@ void BPy_SetContext(struct bContext *C); extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate); extern void bpy_context_clear(struct bContext *C, PyGILState_STATE *gilstate); -#endif /* __BPY_UTIL_H__ */ +#endif /* __BPY_CAPI_UTILS_H__ */ |