mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-20 06:40:01 +01:00
Libvje / refactor : opacitythreshold
* frame->width, frame->height
This commit is contained in:
@@ -49,12 +49,11 @@ vj_effect *opacitythreshold_init(int w, int h)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2,
|
void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2, int opacity,
|
||||||
int width, int height, int opacity,
|
int threshold, int t2)
|
||||||
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;
|
uint8_t a1, a2;
|
||||||
unsigned int op0, op1;
|
unsigned int op0, op1;
|
||||||
uint8_t *Y = frame->data[0];
|
uint8_t *Y = frame->data[0];
|
||||||
@@ -67,31 +66,31 @@ void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2,
|
|||||||
op1 = (opacity > 255) ? 255 : opacity;
|
op1 = (opacity > 255) ? 255 : opacity;
|
||||||
op0 = 255 - op1;
|
op0 = 255 - op1;
|
||||||
|
|
||||||
for (y = width; y < len; y += width) {
|
for (y = frame->width; y < len; y += frame->width) {
|
||||||
for (x = 1; x < width-1; x++) {
|
for (x = 1; x < frame->width-1; x++) {
|
||||||
a1 = Y[x + y];
|
a1 = Y[x + y];
|
||||||
a2 = Y2[x + y];
|
a2 = Y2[x + y];
|
||||||
if (a1 < threshold || a1 > t2) {
|
if (a1 < threshold || a1 > t2) {
|
||||||
a1 = (Y[y - width + x - 1] +
|
a1 = (Y[y - frame->width + x - 1] +
|
||||||
Y[y - width + x + 1] +
|
Y[y - frame->width + x + 1] +
|
||||||
Y[y - width + x] +
|
Y[y - frame->width + x] +
|
||||||
Y[y + x] +
|
Y[y + x] +
|
||||||
Y[y + x - 1] +
|
Y[y + x - 1] +
|
||||||
Y[y + x + 1] +
|
Y[y + x + 1] +
|
||||||
Y[y + width + x] +
|
Y[y + frame->width + x] +
|
||||||
Y[y + width + x + 1] +
|
Y[y + frame->width + x + 1] +
|
||||||
Y[y + width + x - 1]
|
Y[y + frame->width + x - 1]
|
||||||
) / 9;
|
) / 9;
|
||||||
|
|
||||||
a2 = (Y2[y - width + x - 1] +
|
a2 = (Y2[y - frame->width + x - 1] +
|
||||||
Y2[y - width + x + 1] +
|
Y2[y - frame->width + x + 1] +
|
||||||
Y2[y - width + x] +
|
Y2[y - frame->width + x] +
|
||||||
Y2[y + x] +
|
Y2[y + x] +
|
||||||
Y2[y + x - 1] +
|
Y2[y + x - 1] +
|
||||||
Y2[y + x + 1] +
|
Y2[y + x + 1] +
|
||||||
Y2[y + width + x] +
|
Y2[y + frame->width + x] +
|
||||||
Y2[y + width + x + 1] +
|
Y2[y + frame->width + x + 1] +
|
||||||
Y2[y + width + x - 1]
|
Y2[y + frame->width + x - 1]
|
||||||
) / 9;
|
) / 9;
|
||||||
|
|
||||||
Y[x + y] = (op0 * a1 + op1 * a2) >> 8;
|
Y[x + y] = (op0 * a1 + op1 * a2) >> 8;
|
||||||
|
|||||||
@@ -25,8 +25,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
vj_effect *opacitythreshold_init();
|
vj_effect *opacitythreshold_init();
|
||||||
void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2,
|
void opacitythreshold_apply( VJFrame *frame, VJFrame *frame2, int opacity,
|
||||||
int width, int height, int opacity,
|
int threshold, int t2);
|
||||||
int threshold, int t2);
|
|
||||||
void opacitythreshold_free();
|
void opacitythreshold_free();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -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 colormap_apply( VJFrame *frame, int r, int g, int b);
|
||||||
extern void opacity_apply(VJFrame *frame, VJFrame *frame2, int opacity);
|
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 opacityadv_apply(VJFrame *frame, VJFrame *frame2, int o, int t1, int t2);
|
||||||
extern void opacitythreshold_apply(VJFrame *frame, VJFrame *frame2,
|
extern void opacitythreshold_apply(VJFrame *frame, VJFrame *frame2, int o, int t1, int t2);
|
||||||
int w, int h, int o, int t1, int t2);
|
|
||||||
|
|
||||||
|
|
||||||
extern void posterize_apply( VJFrame *frame, int width, int height,
|
extern void posterize_apply( VJFrame *frame, int width, int height,
|
||||||
|
|||||||
@@ -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]);
|
iris_apply( frames[0],frames[1], frames[0]->width,frames[0]->height,arg[0],arg[1]);
|
||||||
break;
|
break;
|
||||||
case VJ_VIDEO_EFFECT_THRESHOLDSMOOTH:
|
case VJ_VIDEO_EFFECT_THRESHOLDSMOOTH:
|
||||||
opacitythreshold_apply(frames[0], frames[1], frames[0]->width,
|
opacitythreshold_apply(frames[0], frames[1], arg[0], arg[1], arg[2]);
|
||||||
frames[0]->height, arg[0], arg[1],arg[2]);
|
|
||||||
break;
|
break;
|
||||||
case VJ_VIDEO_EFFECT_THRESHOLD:
|
case VJ_VIDEO_EFFECT_THRESHOLD:
|
||||||
opacityadv_apply(frames[0], frames[1], arg[0], arg[1], arg[2]);
|
opacityadv_apply(frames[0], frames[1], arg[0], arg[1], arg[2]);
|
||||||
|
|||||||
Reference in New Issue
Block a user