예제 #1
0
int		process_instance( livido_port_t *my_instance, double timecode )
{
	uint8_t *A[4] = {NULL,NULL,NULL,NULL};
	uint8_t *O[4]= {NULL,NULL,NULL,NULL};
	char cmd[256];
	int palette;
	int w;
	int h;
	
	int error	  = lvd_extract_channel_values( my_instance, "out_channels", 0, &w,&h, O,&palette );
	if( error != LIVIDO_NO_ERROR )
		return LIVIDO_ERROR_NO_OUTPUT_CHANNELS; 
	Clvdgmic *gmic = NULL;
	livido_property_get( my_instance, "PLUGIN_private",0, &gmic);
	
        lvd_extract_channel_values( my_instance, "in_channels" , 0, &w, &h, A, &palette );

	int density =  lvd_extract_param_index( my_instance,"in_parameters", 0 );
	int smoothness = lvd_extract_param_index( my_instance,"in_parameters", 1 );
	int edges = lvd_extract_param_index(my_instance, "in_parameters",2);
	
	snprintf(cmd,sizeof(cmd),"-gimp_crystal %d,%f,%d", density, (float)smoothness/100.0f, edges );

	lvdgmic_push( gmic, w, h, 0, A, 0);

	lvdgmic_gmic( gmic, cmd );

	lvdgmic_pull( gmic, 0, O );

	livido_memset( O[1], 128, (w*h)/2);
	livido_memset( O[2], 128, (w*h)/2);

	return LIVIDO_NO_ERROR;
}
예제 #2
0
int		process_instance( livido_port_t *my_instance, double timecode )
{
	int len =0;
	uint8_t *O[4]= {NULL,NULL,NULL,NULL};

	int palette;
	int w;
	int h;
	
	//@ get output channel details
	int error	  = lvd_extract_channel_values( my_instance, "out_channels", 0, &w,&h, O,&palette );
	if( error != LIVIDO_NO_ERROR )
		return LIVIDO_ERROR_NO_OUTPUT_CHANNELS; //@ error codes in livido flanky

	int uv_len = lvd_uv_plane_len( palette,w,h );
	len = w * h;
	
	starfield_t *starfield = NULL;
	if ( livido_property_get( my_instance, "PLUGIN_private", 0, &starfield ) != LIVIDO_NO_ERROR )
    	return LIVIDO_ERROR_INTERNAL;

	//@ get parameter values
	int		number_of_stars =  lvd_extract_param_index( my_instance,"in_parameters", 0 );
	int		speed = 2 + lvd_extract_param_index( my_instance, "in_parameters", 1 );

	livido_memset( O[0], 0, len );
	livido_memset( O[1], 128, uv_len );
	livido_memset( O[2], 128, uv_len );

	int center_x = w >> 1;
	int center_y = h >> 1;
	int i;
	int temp_x, temp_y;
	
	STAR **stars = starfield->stars;

	for( i = 0; i < number_of_stars; i ++ ) {
			
		stars[i]->zpos -= stars[i]->speed;

		if( stars[i]->zpos <= 0 ) {
			init_star( stars[i], i + 1, speed );
		}

		temp_x = (stars[i]->xpos / stars[i]->zpos ) + center_x;
		temp_y = (stars[i]->ypos / stars[i]->zpos ) + center_y;

		if( temp_x < 0 || temp_x > (w-1) || temp_y < 0 || temp_y > (h-1) ) {
			init_star( stars[i], i + 1, speed );
			continue;
		}

		O[0][ temp_y * w + temp_x ] = stars[i]->color;
	}
	

	return LIVIDO_NO_ERROR;
}
예제 #3
0
livido_init_f	init_instance( livido_port_t *my_instance )
{
	int w = 0, h = 0;
        lvd_extract_dimensions( my_instance, "out_channels", &w, &h );

	int video_area = w * h * 3;

	displaywall_t *entry = (displaywall_t*) livido_malloc(sizeof(displaywall_t));
	livido_memset( entry, 0, sizeof(displaywall_t));

	entry->vecx = (int *)livido_malloc(sizeof(int) * video_area);
	entry->vecy = (int *)livido_malloc(sizeof(int) * video_area);
	if(entry->vecx == NULL || entry->vecy == NULL) {
		free(entry);
		return NULL;
	}

	entry->scale = 3;
	entry->dx = 0;
	entry->dy = 0;
	entry->speed = 10;
	entry->cx = w / 2;
	entry->cy = h / 2;

	displaywall_initVec(entry, w, h);

	livido_property_set( my_instance, "PLUGIN_private", LIVIDO_ATOM_TYPE_VOIDPTR,1, &entry);

	return LIVIDO_NO_ERROR;
}
예제 #4
0
livido_process_f		process_instance( livido_port_t *my_instance, double timecode )
{
	int len =0;
	int i = 0;
	uint8_t *A[4] = {NULL,NULL,NULL,NULL};
	uint8_t *O[4]= {NULL,NULL,NULL,NULL};

	int palette;
	int w;
	int h;
	
	int error	  = lvd_extract_channel_values( my_instance, "out_channels", 0, &w,&h, O,&palette );
	if( error != LIVIDO_NO_ERROR )
		return LIVIDO_ERROR_HARDWARE; 

        lvd_extract_channel_values( my_instance, "in_channels" , 0, &w, &h, A, &palette );

	int uv_len = lvd_uv_plane_len( palette,w,h );
	len = w * h;

	int		red    =  lvd_extract_param_index( my_instance,"in_parameters", 0 );
	int		green  =  lvd_extract_param_index( my_instance,"in_parameters", 1 );
	int		blue   =  lvd_extract_param_index( my_instance,"in_parameters", 2 );
	int		shift = 1;
        if( palette == LIVIDO_PALETTE_YUV444P )
                shift = 0;
	
	if( O[0] != A[0] ) {
		livido_memcpy( A[0], O[0], len );
	}
	
	int		y,u,v;
	GIMP_rgb2yuv( red, green, blue, y, u, v );

	livido_memset( O[1], u, uv_len );
	livido_memset( O[2], v, uv_len );

	return LIVIDO_NO_ERROR;
}
예제 #5
0
static int	lvd_zcrop_plane( uint8_t *D, uint8_t *S, int left, int right, int top, int bottom, int w, int h, uint8_t B )
{
	int x,y;
	uint8_t *src = S;
	uint8_t *dst = D;
	
	for( y = 0; y < top; y ++ ) {
		livido_memset( dst, B, w );
		dst += w;
		src += w;
	}

	for( y = top; y < bottom; y ++ ) {
		for( x = 0; x < left; x ++ ) {
			*(dst++) = B;
		}

		src += left;

		for( x = left; x < right; x++ ) {
			*(dst++) = *(src++);
		}

		for( x = right; x < w; x ++ ) {
			*(dst++) = B;
			src += 1;
		}
	}

	for( y = bottom; y < h; y ++ ) {
		livido_memset( dst,B, w );
		dst += w;
		src += w;
	}

	return 1;
}
예제 #6
0
livido_init_f	init_instance( livido_port_t *my_instance )
{
	int width = 0, height = 0;

	lvd_extract_dimensions( my_instance, "out_channels", &width, &height );

	scale0tilt_instance_t* inst = (scale0tilt_instance_t*)livido_malloc(sizeof(scale0tilt_instance_t));

	livido_memset( inst, 0, sizeof(scale0tilt_instance_t) );

	inst->w = width;
	inst->h = height;
	inst->sx = 1.0;
	inst->sy = 1.0;
	
	inst->format_src.frame_width  = inst->w;
	inst->format_src.frame_height = inst->h;
	inst->format_src.image_width  = inst->w;
	inst->format_src.image_height = inst->h;
	inst->format_src.pixel_width = 1;
	inst->format_src.pixel_height = 1;
	inst->format_src.pixelformat = GAVL_YUVJ_444_P;

	inst->video_scaler = gavl_video_scaler_create();
	inst->frame_src = gavl_video_frame_create( NULL );
	inst->frame_dst = gavl_video_frame_create( NULL );

	inst->frame_src->strides[0] = width;
	inst->frame_src->strides[1] = width;
	inst->frame_src->strides[2] = width;

	inst->frame_dst->strides[0] = width;
	inst->frame_dst->strides[1] = width;
	inst->frame_dst->strides[2] = width;

	update_scaler(inst);
	
	inst->temp = gavl_video_frame_create( &(inst->format_src) );
	inst->temp_alpha = gavl_video_frame_create( &(inst->format_src) );
	
	livido_property_set( my_instance, "PLUGIN_private", LIVIDO_ATOM_TYPE_VOIDPTR,1, &inst);

	return LIVIDO_NO_ERROR;
}
예제 #7
0
livido_init_f	init_instance( livido_port_t *my_instance )
{
	int w = 0, h = 0;
        lvd_extract_dimensions( my_instance, "out_channels", &w, &h );

	lvd_crop_t *c = (lvd_crop_t*) livido_malloc( sizeof(lvd_crop_t));
	livido_memset(c,0,sizeof(lvd_crop_t));

	c->buf[0]     = (uint8_t*) livido_malloc( sizeof(uint8_t) * RUP8(w * h * 4));
	c->buf[1]     = c->buf[0] + RUP8(w*h);
	c->buf[2]     = c->buf[1] + RUP8(w*h);
	c->flags	  = SWS_FAST_BILINEAR;

	c->w		  = -1;
	c->h		  = -1; 

	livido_property_set( my_instance, "PLUGIN_private", LIVIDO_ATOM_TYPE_VOIDPTR,1, &c);

	return LIVIDO_NO_ERROR;
}
예제 #8
0
static void update_scaler( scale0tilt_instance_t* inst )
{
	float dst_x, dst_y, dst_w, dst_h;
	float src_x, src_y, src_w, src_h;
        
	inst->do_scale = 1;
	src_x = inst->w * inst->cl;
	src_y = inst->h * inst->ct;
	src_w = inst->w * (1.0 - inst->cl - inst->cr );
	src_h = inst->h * (1.0 - inst->ct - inst->cb );

	dst_x = inst->w * inst->cl * inst->sx + inst->tx * inst->w;
	dst_y = inst->h * inst->ct * inst->sy + inst->ty * inst->h;
	dst_w = inst->w * (1.0 - inst->cl - inst->cr) * inst->sx;
	dst_h = inst->h * (1.0 - inst->ct - inst->cb) * inst->sy;

	if((dst_w < EPSILON) || (dst_h < EPSILON) || 
	   (src_w < EPSILON) || (src_h < EPSILON)) {
		inst->do_scale = 0;
		return;
	}

	if ( dst_x + dst_w > inst->w ) {
		src_w = src_w * ( (inst->w-dst_x) / dst_w );
		dst_w = inst->w - dst_x;
	}
	if ( dst_y + dst_h > inst->h ) {
		src_h = src_h * ( (inst->h-dst_y) / dst_h );
		dst_h = inst->h - dst_y;
	}
	if ( dst_x < 0 ) {
		src_x = src_x - dst_x * ( src_w / dst_w );
		src_w = src_w * ( (dst_w+dst_x) / dst_w );
		dst_w = dst_w + dst_x;
		dst_x = 0;
	}
	if ( dst_y < 0 ) {
		src_y = src_y - dst_y * ( src_h / dst_h );
		src_h = src_h * ( (dst_h+dst_y) / dst_h );
		dst_h = dst_h + dst_y;
		dst_y = 0;
	}

	if((dst_w < EPSILON) || (dst_h < EPSILON) ||
	   (src_w < EPSILON) || (src_h < EPSILON)) {
		inst->do_scale = 0;
		return;
	}

	gavl_video_options_t* options = gavl_video_scaler_get_options( inst->video_scaler );

	gavl_video_format_t format_dst;
	
	livido_memset(&format_dst, 0, sizeof(format_dst));
	format_dst.frame_width  = inst->w;
	format_dst.frame_height = inst->h;
	format_dst.image_width  = inst->w;
	format_dst.image_height = inst->h;
	format_dst.pixel_width = 1;
	format_dst.pixel_height = 1;
	format_dst.pixelformat = GAVL_YUVJ_444_P;

	gavl_rectangle_f_t src_rect;
	gavl_rectangle_i_t dst_rect;

	src_rect.x = src_x;
	src_rect.y = src_y;
	src_rect.w = src_w;
	src_rect.h = src_h;

	dst_rect.x = lroundf(dst_x);
	dst_rect.y = lroundf(dst_y);
	dst_rect.w = lroundf(dst_w);
	dst_rect.h = lroundf(dst_h);
	
	gavl_video_options_set_rectangles( options, &src_rect, &dst_rect );
	gavl_video_scaler_init( inst->video_scaler, &inst->format_src, &format_dst );
}
예제 #9
0
int		process_instance( livido_port_t *my_instance, double timecode )
{
	uint8_t *A[4] = {NULL,NULL,NULL,NULL};
	uint8_t *B[4] = {NULL,NULL,NULL,NULL};
	uint8_t *O[4] = {NULL,NULL,NULL,NULL};

	int palette;
	int w;
	int h;
	
	scale0tilt_instance_t *inst = NULL;
	livido_property_get( my_instance, "PLUGIN_private", 0, &inst );
	
	if( inst == NULL )
		return LIVIDO_ERROR_INTERNAL;

	int error  = lvd_extract_channel_values( my_instance, "out_channels", 0, &w,&h, O,&palette );
	if( error != LIVIDO_NO_ERROR )
		return LIVIDO_ERROR_NO_OUTPUT_CHANNELS;

    error = lvd_extract_channel_values( my_instance, "in_channels" , 0, &w, &h, A, &palette );
	if( error != LIVIDO_NO_ERROR )
		return LIVIDO_ERROR_NO_INPUT_CHANNELS;

    error = lvd_extract_channel_values( my_instance, "in_channels" , 1, &w, &h, B, &palette );
	if( error != LIVIDO_NO_ERROR )
		return LIVIDO_ERROR_NO_INPUT_CHANNELS;

	double width = (double)w;
	double height= (double)h;

	inst->cl = lvd_extract_param_index( my_instance,"in_parameters", 0 ) / width;
	inst->cr = ((double) lvd_extract_param_index( my_instance,"in_parameters", 1 )) / width;
	inst->ct = ((double) lvd_extract_param_index( my_instance, "in_parameters", 2 )) / height;
	inst->cb = ((double) lvd_extract_param_index( my_instance, "in_parameters", 3)) / height;
	
	inst->sx = ( (double) lvd_extract_param_index( my_instance,"in_parameters", 4 )  / width) * 2.0;
	inst->sy = ( (double) lvd_extract_param_index( my_instance,"in_parameters", 5 )  / height) * 2.0;
	inst->tx = ( (double) lvd_extract_param_index( my_instance, "in_parameters", 6 ) / width) * 2.0 - 1.0;
	inst->ty = ( (double) lvd_extract_param_index( my_instance, "in_parameters", 7) / height) * 2.0 - 1.0;

	int alpha = lvd_extract_param_index( my_instance, "in_parameters", 8 );

	inst->frame_src->strides[0] = width;
	inst->frame_src->strides[1] = width;
	inst->frame_src->strides[2] = width;

	inst->frame_dst->strides[0] = width;
	inst->frame_dst->strides[1] = width;
	inst->frame_dst->strides[2] = width;

	update_scaler( inst );

	gavl_video_frame_t* frame_src = inst->frame_src;

	inst->frame_src->planes[0] = B[0];
	inst->frame_src->planes[1] = B[1];
	inst->frame_src->planes[2] = B[2];

	inst->frame_dst->planes[0] = O[0];
	inst->frame_dst->planes[1] = O[1];
	inst->frame_dst->planes[2] = O[2];

	if ( inst->do_scale )
	{
		int len = w * h;
		int i;
		livido_memset( inst->temp_alpha->planes[0],0,len);

		/* scale alpha channel first */
		inst->frame_src->strides[0] = width;
		inst->frame_src->strides[1] = 0;
		inst->frame_src->strides[2] = 0;
		inst->frame_src->planes[0] = B[3];
	
		inst->temp_alpha->strides[0] = width;
		inst->temp_alpha->strides[1] = 0;
		inst->temp_alpha->strides[2] = 0;

		gavl_video_scaler_scale( inst->video_scaler, frame_src, inst->temp_alpha );

		/* setup pointers for frames */
		inst->frame_src->strides[1] = width;
		inst->frame_src->strides[2] = width;
		inst->frame_src->planes[0] = B[0];
		inst->frame_src->planes[1] = B[1];
		inst->frame_src->planes[2] = B[2];

		inst->frame_dst->strides[0] = width;
		inst->frame_dst->strides[1] = width;
		inst->frame_dst->strides[2] = width;
		inst->frame_dst->planes[0] = O[0];
		inst->frame_dst->planes[1] = O[1];
		inst->frame_dst->planes[2] = O[2];

		if(alpha)
		{	
			livido_memset( inst->temp->planes[0], 0, len );
			livido_memset( inst->temp->planes[1],128,len );
			livido_memset( inst->temp->planes[2],128,len );

			gavl_video_scaler_scale( inst->video_scaler, frame_src, inst->temp );

			const uint8_t *t0 = inst->temp->planes[0];
			const uint8_t *t1 = inst->temp->planes[1];
			const uint8_t *t2 = inst->temp->planes[2];
			const uint8_t *tA = inst->temp_alpha->planes[0];

			for( i = 0; i < len; i ++ ) {
				if( tA[i] > 0 )
				{
					unsigned int op1 = tA[i];
					unsigned int op0 = 0xff - tA[i];
					O[0][i] = (op0 * O[0][i] + op1 * t0[i]) >> 8;
					O[1][i] = (op0 * O[1][i] + op1 * t1[i]) >> 8;
					O[2][i] = (op0 * O[2][i] + op1 * t2[i]) >> 8;
					O[3][i] = op1;
				}
			}
		}