Ejemplo n.º 1
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;
}
Ejemplo n.º 2
0
int	process_instance( livido_port_t *my_instance, double timecode )
{
	int len =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_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;
	
	len = w * h;

	int	src_red    =  lvd_extract_param_index( my_instance,"in_parameters", 0 );
	int	src_green  =  lvd_extract_param_index( my_instance,"in_parameters", 1 );
	int	src_blue   =  lvd_extract_param_index( my_instance,"in_parameters", 2 );

	int	dst_red    =  lvd_extract_param_index( my_instance,"in_parameters", 3 );
	int	dst_green  =  lvd_extract_param_index( my_instance,"in_parameters", 4 );
	int	dst_blue   =  lvd_extract_param_index( my_instance,"in_parameters", 5 );

	int mode	   =  lvd_extract_param_index( my_instance,"in_parameters", 6 );
	int black_incl	   =  lvd_extract_param_index( my_instance,"in_parameters", 7 );
		
	int		sy,su,sv;
	GIMP_rgb2yuv( src_red, src_green, src_blue, sy,su,sv );

	int		dy,du,dv;
	GIMP_rgb2yuv( dst_red, dst_green, dst_blue, dy,du,dv );

	uint8_t *ch0 = A[0];
	uint8_t *ch1 = A[1];
	uint8_t *ch2 = A[2];

	uint8_t *o0 = O[0];
	uint8_t *o1 = O[1];
	uint8_t *o2 = O[2];

	const int minY = ( mode == 1 ? 16: 0 );
	const int maxY = ( mode == 1 ? 235: 255 );
	const int minUV= ( mode == 1 ? 16: 0 );
	const int maxUV= ( mode == 1 ? 240: 255 );

	int i;

	if( black_incl ) {
		for( i = 0; i < len; i ++ )
		{
			o0[i] = CLAMP( ch0[i] + dy - sy,minY,maxY );
			o1[i] = CLAMP( ch1[i] + du - su,minUV,maxUV );
			o2[i] = CLAMP( ch2[i] + dv - sv,minUV,maxUV );
		}
	}
	else {
		for( i = 0; i < len; i ++ )
		{
			if(ch0[i] != 0 ) {
				o0[i] = CLAMP( ch0[i] + dy - sy,minY,maxY );
				o1[i] = CLAMP( ch1[i] + du - su,minUV,maxUV );
				o2[i] = CLAMP( ch2[i] + dv - sv,minUV,maxUV );
			}
		}

	}	


	return LIVIDO_NO_ERROR;
}