mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-24 16:49:59 +01:00
Initial checkin of veejay 1.4
git-svn-id: svn://code.dyne.org/veejay/trunk@1172 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
This commit is contained in:
152
veejay-current/veejay-server/libvje/effects/radialblur.c
Normal file
152
veejay-current/veejay-server/libvje/effects/radialblur.c
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Linux VeeJay
|
||||
*
|
||||
* Copyright(C)2002 Niels Elburg <elburg@hio.hen.nl>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License , or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 , USA.
|
||||
*/
|
||||
/*
|
||||
* Copyright (C) 2000-2004 the xine project
|
||||
*
|
||||
* This file is part of xine, a free video player.
|
||||
*
|
||||
* xine is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* xine is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
* $Id: radialblur.c,v 1.1.1.1 2004/10/27 23:49:01 niels Exp $
|
||||
*
|
||||
* mplayer's boxblur
|
||||
* Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <libvjmem/vjmem.h>
|
||||
#include "radialblur.h"
|
||||
#include "common.h"
|
||||
//FIXME: private
|
||||
static uint8_t *radial_src[3];
|
||||
|
||||
vj_effect *radialblur_init(int w,int h)
|
||||
{
|
||||
vj_effect *ve = (vj_effect *) vj_calloc(sizeof(vj_effect));
|
||||
ve->num_params = 3;
|
||||
ve->defaults = (int *) vj_calloc(sizeof(int) * ve->num_params); /* default values */
|
||||
ve->limits[0] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* min */
|
||||
ve->limits[1] = (int *) vj_calloc(sizeof(int) * ve->num_params); /* max */
|
||||
ve->defaults[0] = 15;
|
||||
ve->defaults[1] = 0;
|
||||
ve->defaults[2] = 2;
|
||||
|
||||
ve->limits[0][0] = 0;
|
||||
ve->limits[1][0] = 90; // radius
|
||||
ve->limits[0][1] = 0; // power
|
||||
ve->limits[1][1] = 100;
|
||||
ve->limits[0][2] = 0; // direction
|
||||
ve->limits[1][2] = 2; // 2 = both
|
||||
ve->description = "Radial Blur";
|
||||
ve->sub_format = 0;
|
||||
ve->extra_frame = 0;
|
||||
ve->has_user = 0;
|
||||
ve->param_description = vje_build_param_list( ve->num_params, "Radius", "Power", "Direction");
|
||||
return ve;
|
||||
}
|
||||
|
||||
int radialblur_malloc(int w, int h)
|
||||
{
|
||||
radial_src[0] = (uint8_t*) vj_yuvalloc(w,h);
|
||||
if(!radial_src[0]) return 0;
|
||||
radial_src[1] = radial_src[0] + (w * h);
|
||||
radial_src[2] = radial_src[1] + (w * h);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void rhblur_apply( uint8_t *dst , uint8_t *src, int w, int h, int r , int p)
|
||||
{
|
||||
int y;
|
||||
for(y = 0; y < h ; y ++ )
|
||||
{
|
||||
blur2( dst + y * w, src + y *w , w, r,p, 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
static void rvblur_apply( uint8_t *dst, uint8_t *src, int w, int h, int r , int p)
|
||||
{
|
||||
int x;
|
||||
for(x=0; x < w; x++)
|
||||
{
|
||||
blur2( dst + x, src + x , h, r, p, w, w );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void radialblur_apply(VJFrame *frame, int width, int height, int radius, int power, int direction)
|
||||
{
|
||||
const int len = frame->len;
|
||||
const int uv_len = frame->uv_len;
|
||||
|
||||
uint8_t *Y = frame->data[0];
|
||||
uint8_t *Cb= frame->data[1];
|
||||
uint8_t *Cr= frame->data[2];
|
||||
|
||||
if(radius == 0) return;
|
||||
// inplace
|
||||
|
||||
veejay_memcpy( radial_src[0] , Y, len);
|
||||
veejay_memcpy( radial_src[1] , Cb, uv_len);
|
||||
veejay_memcpy( radial_src[2] , Cr, uv_len);
|
||||
|
||||
switch(direction)
|
||||
{
|
||||
case 0: rhblur_apply( Y, radial_src[0],width, height, radius, power );
|
||||
rhblur_apply( Cb, radial_src[1],frame->uv_width, frame->uv_height, radius, power );
|
||||
rhblur_apply( Cr, radial_src[2],frame->uv_width, frame->uv_height, radius, power );
|
||||
break;
|
||||
case 1: rvblur_apply( Y, radial_src[0],width, height, radius, power );
|
||||
rvblur_apply( Cb, radial_src[1],frame->uv_width, frame->uv_height, radius, power );
|
||||
rvblur_apply( Cr, radial_src[2],frame->uv_width, frame->uv_height, radius, power );
|
||||
break;
|
||||
case 2:
|
||||
rhblur_apply( Y, radial_src[0],width, height, radius, power );
|
||||
rhblur_apply( Cb, radial_src[1],frame->uv_width, frame->uv_height, radius, power );
|
||||
rhblur_apply( Cr, radial_src[2],frame->uv_width, frame->uv_height, radius, power );
|
||||
rvblur_apply( Y, radial_src[0],width, height, radius, power );
|
||||
rvblur_apply( Cb, radial_src[1],frame->uv_width, frame->uv_height, radius, power );
|
||||
rvblur_apply( Cr, radial_src[2],frame->uv_width, frame->uv_height, radius, power );
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void radialblur_free()
|
||||
{
|
||||
if( radial_src[0] )
|
||||
free(radial_src[0]);
|
||||
radial_src[0] = NULL;
|
||||
radial_src[1] = NULL;
|
||||
radial_src[2] = NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user