From 41d7ce1d92ca83c934c59504af7fcea6d1fe78f4 Mon Sep 17 00:00:00 2001 From: "[d.j.a.y] Jerome Blanchi" Date: Wed, 20 Apr 2016 12:13:40 +0200 Subject: [PATCH] Libvje / refactor : opacitythreshold * frame->width, frame->height --- .../libvje/effects/opacitythreshold.c | 35 +++++++++---------- .../libvje/effects/opacitythreshold.h | 5 ++- .../veejay-server/libvje/internal.h | 3 +- .../veejay-server/libvje/vj-effman.c | 3 +- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/veejay-current/veejay-server/libvje/effects/opacitythreshold.c b/veejay-current/veejay-server/libvje/effects/opacitythreshold.c index aab0f1bb..255d3445 100644 --- a/veejay-current/veejay-server/libvje/effects/opacitythreshold.c +++ b/veejay-current/veejay-server/libvje/effects/opacitythreshold.c @@ -49,12 +49,11 @@ vj_effect *opacitythreshold_init(int w, int h) -void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2, - int width, int height, int opacity, - int threshold, int t2) +void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2, int opacity, + int threshold, int t2) { - unsigned int x, y, len = width * height-width; + unsigned int x, y, len = frame->width * frame->height-frame->width; uint8_t a1, a2; unsigned int op0, op1; uint8_t *Y = frame->data[0]; @@ -67,31 +66,31 @@ void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2, op1 = (opacity > 255) ? 255 : opacity; op0 = 255 - op1; - for (y = width; y < len; y += width) { - for (x = 1; x < width-1; x++) { + for (y = frame->width; y < len; y += frame->width) { + for (x = 1; x < frame->width-1; x++) { a1 = Y[x + y]; a2 = Y2[x + y]; if (a1 < threshold || a1 > t2) { - a1 = (Y[y - width + x - 1] + - Y[y - width + x + 1] + - Y[y - width + x] + + a1 = (Y[y - frame->width + x - 1] + + Y[y - frame->width + x + 1] + + Y[y - frame->width + x] + Y[y + x] + Y[y + x - 1] + Y[y + x + 1] + - Y[y + width + x] + - Y[y + width + x + 1] + - Y[y + width + x - 1] + Y[y + frame->width + x] + + Y[y + frame->width + x + 1] + + Y[y + frame->width + x - 1] ) / 9; - a2 = (Y2[y - width + x - 1] + - Y2[y - width + x + 1] + - Y2[y - width + x] + + a2 = (Y2[y - frame->width + x - 1] + + Y2[y - frame->width + x + 1] + + Y2[y - frame->width + x] + Y2[y + x] + Y2[y + x - 1] + Y2[y + x + 1] + - Y2[y + width + x] + - Y2[y + width + x + 1] + - Y2[y + width + x - 1] + Y2[y + frame->width + x] + + Y2[y + frame->width + x + 1] + + Y2[y + frame->width + x - 1] ) / 9; Y[x + y] = (op0 * a1 + op1 * a2) >> 8; diff --git a/veejay-current/veejay-server/libvje/effects/opacitythreshold.h b/veejay-current/veejay-server/libvje/effects/opacitythreshold.h index f231c617..bdbcbfb0 100644 --- a/veejay-current/veejay-server/libvje/effects/opacitythreshold.h +++ b/veejay-current/veejay-server/libvje/effects/opacitythreshold.h @@ -25,8 +25,7 @@ #include vj_effect *opacitythreshold_init(); -void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2, - int width, int height, int opacity, - int threshold, int t2); +void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2, int opacity, + int threshold, int t2); void opacitythreshold_free(); #endif diff --git a/veejay-current/veejay-server/libvje/internal.h b/veejay-current/veejay-server/libvje/internal.h index 6244a9d4..412fca6c 100644 --- a/veejay-current/veejay-server/libvje/internal.h +++ b/veejay-current/veejay-server/libvje/internal.h @@ -321,8 +321,7 @@ extern void negatechannel_apply( VJFrame *frame, int chan, int val); extern void colormap_apply( VJFrame *frame, int r, int g, int b); extern void opacity_apply(VJFrame *frame, VJFrame *frame2, int opacity); extern void opacityadv_apply(VJFrame *frame, VJFrame *frame2, int o, int t1, int t2); -extern void opacitythreshold_apply(VJFrame *frame, VJFrame *frame2, - int w, int h, int o, int t1, int t2); +extern void opacitythreshold_apply(VJFrame *frame, VJFrame *frame2, int o, int t1, int t2); extern void posterize_apply( VJFrame *frame, int width, int height, diff --git a/veejay-current/veejay-server/libvje/vj-effman.c b/veejay-current/veejay-server/libvje/vj-effman.c index a3dd5cd8..40b71e50 100644 --- a/veejay-current/veejay-server/libvje/vj-effman.c +++ b/veejay-current/veejay-server/libvje/vj-effman.c @@ -516,8 +516,7 @@ static void vj_effman_apply_video_effect( VJFrame **frames, vjp_kf *todo_info,in iris_apply( frames[0],frames[1], frames[0]->width,frames[0]->height,arg[0],arg[1]); break; case VJ_VIDEO_EFFECT_THRESHOLDSMOOTH: - opacitythreshold_apply(frames[0], frames[1], frames[0]->width, - frames[0]->height, arg[0], arg[1],arg[2]); + opacitythreshold_apply(frames[0], frames[1], arg[0], arg[1], arg[2]); break; case VJ_VIDEO_EFFECT_THRESHOLD: opacityadv_apply(frames[0], frames[1], arg[0], arg[1], arg[2]);