Exemplo n.º 1
0
Value testingGradient_AST(argList *a) {
	checkArgs(a, 0);
	long long numFrames = (long long)OPTNUM("frames", 1000);
	long long width = (long long)OPTNUM("width", 200);
	long long height = (long long)OPTNUM("height", 200);

	////////////////////
	// Error Checking //
	////////////////////
	if(numFrames < 0 || width < 0 || height < 0)
		MkvsynthError("width, height, and frames must be numbers greater than 0");

	MkvsynthOutput *output = createOutputBuffer();

	///////////////
	// Meta Data //
	///////////////
	output->metaData->colorspace = MKVS_RGB48;
	output->metaData->width = width;
	output->metaData->height = height;
	output->metaData->fpsNumerator = 60;
	output->metaData->fpsDenominator = 1;

	////////////////////////
	// Pthread Parameters //
	////////////////////////
	struct TestingGradientParams *params = malloc(sizeof(struct TestingGradientParams));
	params->frames = numFrames;
	params->output = output;

	mkvsynthQueue((void *)params, testingGradient);

	RETURNCLIP(output);
}
    GlobalMinimumPositionInterface::GlobalMinimumPositionInterface(Framework* framework, CLMemBuffer* source, int taskSize)
        : ComputeKernel(framework, GlobalMinimumPosition_kernel_SourceCode, "computeGlobalMinimumPosition", "GlobalMinimumPositionInterface")
        , source(source)
        , taskSize(taskSize)
    {
        implementation->queryAndApplyOptimumWorkSize1D((taskSize / 2) + (taskSize % 2), this->workersTotal, this->workersInWorkgroup);
        this->numberOfWorkgroups = this->workersTotal / this->workersInWorkgroup;
        if( (this->workersTotal % this->workersInWorkgroup) != 0 )
            this->numberOfWorkgroups++;

        createOutputBuffer();
    }
Exemplo n.º 3
0
void AudioChannel::init()
{
    muted              = false;
    isMono             = false;
    hasCache           = false;
    isCaching          = false;
    instanceId         = ++INSTANCE_COUNT;
    _canCache          = false;
    _outputBuffer      = 0;
    _cachedBuffer      = 0;
    _cacheReadPointer  = 0;
    _cacheWritePointer = 0;
    _cacheStartOffset  = 0;
    _cacheEndOffset    = 0;
    processingChain    = new ProcessingChain();

    createOutputBuffer();
}
Exemplo n.º 4
0
 ColumnAverageKernel::ColumnAverageKernel(Framework* framework, GPUMapped<Image>* source)
     : ComputeKernel(framework, ColumnAverage_kernel_SourceCode, "computeColumnAverage", "ColumnAverageKernel")
 {
     setInput(source);
     createOutputBuffer();
 }
Exemplo n.º 5
0
void MeshViewer::initContext()
{
	m_context->setRayTypeCount( 3 );
	m_context->setStackSize( 1024 );
	//m_context->setStackSize( 1180 );
	//m_context->setStackSize( 8192 );
	//m_context->setStackSize( 4096 );

	// Si hay shadow mapping creamos dos puntos de entrada
	if (m_shadow_mapping) m_context->setEntryPointCount( 2 );
	else				  m_context->setEntryPointCount( 1 );

	// Definición de programas
	// Se usa el set para el fácil traslado hacia el main
	setMesh("models/16_city/", "Paris2011_64Bit_Shape_3a.obj");
	setPathProgram("../x64/Release/PTX_files/");
	setCameraProgram("orthographic_camera.cu", "orthographic_camera");
	setExceptionProgram("orthographic_camera.cu", "exception");
	setMissProgram("obj_material.cu", "miss");
	setIntersectProgram("triangle_mesh.cu", "mesh_intersect");
	setBoundsProgram("triangle_mesh.cu", "mesh_bounds");
	setAnyHitProgram("obj_material.cu", "any_hit_shadow");
	setClosestHitProgram("obj_material.cu", "closest_hit_radiance");

	/*setMesh("models/16_city/", "Paris2011_64Bit_Shape_3a.obj");
	setPathProgram("../x64/Release/PTX_files/");
	setCameraProgram("column_camera.cu", "pinhole_camera");
	setExceptionProgram("column_camera.cu", "exception");
	setMissProgram("column_material.cu", "miss");
	setIntersectProgram("column_mesh.cu", "mesh_intersect");
	setBoundsProgram("column_mesh.cu", "mesh_bounds");
	setAnyHitProgram("column_material.cu", "any_hit_shadow");
	setClosestHitProgram("column_material.cu", "closest_hit_radiance");*/

	m_context->setPrintEnabled(true);
	m_context->setPrintLaunchIndex(400);
	m_context->setPrintBufferSize(8192);

	// Cuidado con los BUFFERS!!
	// En el caso de querer hacer un simple trace() sin que todo sea controlado por la clase
	// GLUTDisplay, se tienen que utilizar buffers corrientes (los comentados).
	m_context[ "radiance_ray_type"   ]->setUint( 0u );
	m_context[ "shadow_ray_type"     ]->setUint( 1u ); 
	m_context[ "max_depth"           ]->setInt( 5 );
	m_context[ "ambient_light_color" ]->setFloat( 0.6f, 0.6f, 0.6f ); 
	//m_context[ "output_buffer"       ]->set( m_context->createBuffer( RT_BUFFER_OUTPUT, RT_FORMAT_UNSIGNED_BYTE4, WIDTH, HEIGHT)); 
	//m_context[ "z_buffer"            ]->set( m_context->createBuffer( RT_BUFFER_OUTPUT, RT_FORMAT_FLOAT, WIDTH, HEIGHT) ); 
	m_context[ "output_buffer"       ]->set( createOutputBuffer(RT_FORMAT_UNSIGNED_BYTE4, WIDTH, HEIGHT) );
	m_context[ "z_buffer"            ]->set( createOutputBuffer(RT_FORMAT_FLOAT, WIDTH, HEIGHT) );
	m_context[ "real_launch_dim"     ]->setUint(WIDTH, HEIGHT); 

	// Ray generation program setup
	const std::string camera_ptx = m_program_path + m_camera_file + ".ptx";
	Program ray_gen_program = m_context->createProgramFromPTXFile( camera_ptx, m_camera_name );
	m_context->setRayGenerationProgram( m_column_entry, ray_gen_program );

	// Exception program
	const std::string except_ptx = m_program_path + m_exception_file + ".ptx";
	m_context->setExceptionProgram( m_column_entry, m_context->createProgramFromPTXFile( except_ptx, m_exception_name ) );
	m_context[ "bad_color" ]->setFloat( 0.0f, 1.0f, 0.0f );

	// Miss program 
	const std::string miss_ptx = m_program_path + m_miss_file + ".ptx";
	m_context->setMissProgram( m_column_entry, m_context->createProgramFromPTXFile( miss_ptx, m_miss_name ) );
	m_context[ "bg_color" ]->setFloat(  0.34f, 0.55f, 0.85f );


	const std::string camera_ptx_shadow = m_program_path + "column_camera.cu" + ".ptx";
	ray_gen_program = m_context->createProgramFromPTXFile( camera_ptx_shadow, "pinhole_camera" );
	m_context->setRayGenerationProgram( 1, ray_gen_program );
	// Exception program
	const std::string except_ptx_shadow = m_program_path + "column_camera.cu" + ".ptx";
	m_context->setExceptionProgram( 1, m_context->createProgramFromPTXFile( except_ptx_shadow, "exception" ) );
	// Miss program 
	const std::string miss_ptx_shadow = m_program_path + "column_material.cu" + ".ptx";
	m_context->setMissProgram( 1, m_context->createProgramFromPTXFile( miss_ptx_shadow, "miss" ) );
}
Exemplo n.º 6
0
Value ffmpegDecode_AST(argList *a) {

	///////////////////////////
	// Parse Input Arguments //
	///////////////////////////
	struct ffmpegDecode *params = malloc(sizeof(struct ffmpegDecode));
	checkArgs(a, 1, typeStr);
	char *filename = MANDSTR(0);
	params->output = createOutputBuffer();

	//////////////////////////////
	// Initialize Stuff To NULL //
	//////////////////////////////
	params->formatContext = NULL;
	params->codecContext = NULL;
	params->codec = NULL;
	params->frame = NULL;
	params->rgbFrame = NULL;
	params->rgbFramePayload = NULL;
	
	//////////////////////////////////////
	// Error Checking And Initializtion //
	//////////////////////////////////////
	av_register_all();
	
	int avOpen = avformat_open_input(&params->formatContext, filename, NULL, NULL);

	if(avOpen != 0)
		MkvsynthError("Input file could not be opened.");
	
	if(avformat_find_stream_info(params->formatContext, NULL) < 0)
		MkvsynthError("Input file does not seem to be a video.");

	av_dump_format(params->formatContext, 0, filename, 0);
	
	int i;
	for(i = 0; i < params->formatContext->nb_streams; i++) {
		if(params->formatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
			params->videoStream = i;
			break;
		}
	}
	
	if(params->videoStream == -1)
		MkvsynthError("Input file does not seem to have a video stream.");

	params->codecContext = params->formatContext->streams[params->videoStream]->codec;

	params->codec = avcodec_find_decoder(params->codecContext->codec_id);
	if(params->codec == NULL)
		MkvsynthError("Unrecognized video codec.");

	int openCodec = avcodec_open2(params->codecContext, params->codec, &params->dictionary);

	if(openCodec < 0)
		MkvsynthError("Failed to open codec.");

	params->frame = avcodec_alloc_frame();
	params->rgbFrame = avcodec_alloc_frame();

	int bytes = avpicture_get_size(PIX_FMT_RGB48, params->codecContext->width, params->codecContext->height);
	params->rgbFramePayload = (uint8_t *)av_malloc(bytes);
	
	params->resizeContext = sws_getContext (
		params->codecContext->width,
		params->codecContext->height,
		params->codecContext->pix_fmt,
		params->codecContext->width,
		params->codecContext->height,
		PIX_FMT_RGB48,
		SWS_SPLINE,
		NULL,
		NULL,
		NULL);

	avpicture_fill((AVPicture *)params->rgbFrame, params->rgbFramePayload, PIX_FMT_RGB48, params->codecContext->width, params->codecContext->height);

	///////////////
	// Meta Data //
	///////////////
	params->output->metaData->width = params->codecContext->width;
	params->output->metaData->height = params->codecContext->height;
	params->output->metaData->colorspace = MKVS_RGB48;
	params->output->metaData->fpsNumerator = params->formatContext->streams[params->videoStream]->avg_frame_rate.num;
	params->output->metaData->fpsDenominator = params->formatContext->streams[params->videoStream]->avg_frame_rate.den;

	//////////////////////
	// Queue and Return //
	//////////////////////
	mkvsynthQueue((void *)params, ffmpegDecode);
	RETURNCLIP(params->output);
}
Exemplo n.º 7
0
void CannonBall::initScene( InitialCameraData& camera_data )
{
	// Two Rays, on light and one shadow
	m_context->setRayTypeCount( 2 );
	m_context->setEntryPointCount( 1 );
	m_context->setStackSize( 2520 );

	m_context["max_depth"]->setInt( 6 );
    m_context["radiance_ray_type"]->setUint( 0u );
    m_context["shadow_ray_type"]->setUint( 1u );
    m_context["scene_epsilon"]->setFloat( 1.e-3f );

	// Output buffer
	optix::Variable output_buffer = m_context["output_buffer"];

    output_buffer->set(createOutputBuffer(RT_FORMAT_UNSIGNED_BYTE4, WIDTH, HEIGHT ) );

	// Set up camera
    camera_data = InitialCameraData( optix::make_float3( 8.3f, 4.0f, -20.0f ), // eye
                                     optix::make_float3( 0.5f, 0.3f,  1.0f ), // lookat
                                     optix::make_float3( 0.0f, 1.0f,  0.0f ), // up
                                     60.0f );                          // vfov

    // Declare camera variables.  The values do not matter, they will be overwritten in trace.
    m_context["eye"]->setFloat( optix::make_float3( 0.0f, 0.0f, 0.0f ) );
    m_context["U"]->setFloat( optix::make_float3( 0.0f, 0.0f, 0.0f ) );
    m_context["V"]->setFloat( optix::make_float3( 0.0f, 0.0f, 0.0f ) );
    m_context["W"]->setFloat( optix::make_float3( 0.0f, 0.0f, 0.0f ) );

	// Ray generation program
	std::string ptx_path = helpers.getPTXPath( project_name, "pinhole_camera.cu" );
	optix::Program ray_gen_program = m_context->createProgramFromPTXFile( ptx_path, "pinhole_camera" );
	m_context->setRayGenerationProgram( 0, ray_gen_program );

	// Exception program
	optix::Program exception_program = m_context->createProgramFromPTXFile( ptx_path, "exception" );
    m_context->setExceptionProgram( 0, exception_program );
    m_context["bad_color"]->setFloat( 0.0f, 1.0f, 0.0f );

	// Miss program
	m_context->setMissProgram( 0, m_context->createProgramFromPTXFile( helpers.getPTXPath( project_name, "constantbg.cu" ), "miss" ) );
    m_context["bg_color"]->setFloat( optix::make_float3(108.0f/255.0f, 166.0f/255.0f, 205.0f/255.0f) * 0.5f );

	// Setup lights
    m_context["ambient_light_color"]->setFloat(0,0,0);
    BasicLight lights[] = { 
      { { -7.0f, 15.0f, -7.0f }, { .8f, .8f, .8f }, 1 }
    };

    optix::Buffer light_buffer = m_context->createBuffer(RT_BUFFER_INPUT);
    light_buffer->setFormat(RT_FORMAT_USER);
    light_buffer->setElementSize(sizeof(BasicLight));
    light_buffer->setSize( sizeof(lights)/sizeof(lights[0]) );
    memcpy(light_buffer->map(), lights, sizeof(lights));
    light_buffer->unmap();

    m_context["lights"]->set(light_buffer);

	// Create scene geometry
	createGeometry();

	// FInalize
	m_context->validate();
	m_context->compile();
}