当前位置: 首页>>代码示例>>C++>>正文


C++ GlslManager类代码示例

本文整理汇总了C++中GlslManager的典型用法代码示例。如果您正苦于以下问题:C++ GlslManager类的具体用法?C++ GlslManager怎么用?C++ GlslManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GlslManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: filter_glsl_manager_init

mlt_filter filter_glsl_manager_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
	GlslManager* g = GlslManager::get_instance();
	if (g)
		g->inc_ref();
	else
		g = new GlslManager();
	return g->get_filter();
}
开发者ID:jksiezni,项目名称:mlt,代码行数:9,代码来源:filter_glsl_manager.cpp

示例2: delete_sync

void GlslManager::delete_sync(GLsync sync)
{
	// We do not know which thread we are called from, and we can only
	// delete this if we are in one with a valid OpenGL context.
	// Thus, store it for later deletion in render_frame_texture().
	GlslManager* g = GlslManager::get_instance();
	g->lock();
	g->syncs_to_delete.push_back(sync);
	g->unlock();
}
开发者ID:bmatherly,项目名称:mlt,代码行数:10,代码来源:filter_glsl_manager.cpp

示例3: release_texture

void GlslManager::release_texture(glsl_texture texture)
{
#if USE_TEXTURE_POOL
	texture->used = 0;
#else
	GlslManager* g = GlslManager::get_instance();
	g->lock();
	g->texture_list.push_back(texture);
	g->unlock();
#endif
}
开发者ID:bmatherly,项目名称:mlt,代码行数:11,代码来源:filter_glsl_manager.cpp

示例4: filter_movit_resample_init

mlt_filter filter_movit_resample_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
	mlt_filter filter = NULL;
	GlslManager* glsl = GlslManager::get_instance();

	if ( glsl && ( filter = mlt_filter_new() ) ) {
		mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
		glsl->add_ref( properties );
		filter->process = process;
	}
	return filter;
}
开发者ID:rt1729,项目名称:mlt,代码行数:12,代码来源:filter_movit_resample.cpp

示例5: filter_movit_vignette_init

mlt_filter filter_movit_vignette_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
	mlt_filter filter = NULL;
	GlslManager* glsl = GlslManager::get_instance();

	if ( glsl && ( filter = mlt_filter_new() ) ) {
		mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
		glsl->add_ref( properties );
		filter->process = process;
		mlt_properties_set_double( MLT_FILTER_PROPERTIES(filter), "radius", 0.3 );
		mlt_properties_set_double( MLT_FILTER_PROPERTIES(filter), "inner_radius", 0.3 );
	}
	return filter;
}
开发者ID:aib,项目名称:mlt,代码行数:14,代码来源:filter_movit_vignette.cpp

示例6: filter_white_balance_init

mlt_filter filter_white_balance_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
	mlt_filter filter = NULL;
	GlslManager* glsl = GlslManager::get_instance();

	if ( glsl && ( filter = mlt_filter_new() ) ) {
		mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
		glsl->add_ref( properties );
		mlt_properties_set( properties, "neutral_color", arg? arg : "#7f7f7f" );
		mlt_properties_set_double( properties, "color_temperature", 6500.0 );
		filter->process = process;
	}
	return filter;
}
开发者ID:rt1729,项目名称:mlt,代码行数:14,代码来源:filter_movit_white_balance.cpp

示例7: filter_movit_opacity_init

mlt_filter filter_movit_opacity_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
    mlt_filter filter = NULL;
    GlslManager* glsl = GlslManager::get_instance();

    if ( glsl && ( filter = mlt_filter_new() ) ) {
        mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
        glsl->add_ref( properties );
        mlt_properties_set( properties, "opacity", arg? arg : "1" );
        mlt_properties_set_double( properties, "alpha", -1.0 );
        filter->process = process;
    }
    return filter;
}
开发者ID:vpinon,项目名称:mlt,代码行数:14,代码来源:filter_movit_opacity.cpp

示例8: filter_movit_glow_init

mlt_filter filter_movit_glow_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
	mlt_filter filter = NULL;
	GlslManager* glsl = GlslManager::get_instance();

	if ( glsl && ( filter = mlt_filter_new() ) ) {
		mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
		glsl->add_ref( properties );
		mlt_properties_set_double( properties, "radius", 20.0 );
		mlt_properties_set_double( properties, "blur_mix", 1.0 );
		mlt_properties_set_double( properties, "highlight_cutoff", 0.2 );
		filter->process = process;
	}
	return filter;
}
开发者ID:rt1729,项目名称:mlt,代码行数:15,代码来源:filter_movit_glow.cpp

示例9: movit_render

static int movit_render( EffectChain *chain, mlt_frame frame, mlt_image_format *format, mlt_image_format output_format, int width, int height, uint8_t **image )
{
	GlslManager* glsl = GlslManager::get_instance();
	int error;
	if ( output_format == mlt_image_glsl_texture ) {
		error = glsl->render_frame_texture( chain, frame, width, height, image );
	}
	else {
		error = glsl->render_frame_rgba( chain, frame, width, height, image );
		if ( !error && output_format != mlt_image_rgb24a ) {
			*format = mlt_image_rgb24a;
			error = convert_on_cpu( frame, image, format, output_format );
		}
	}
	return error;
}
开发者ID:jjcare,项目名称:mlt,代码行数:16,代码来源:filter_movit_convert.cpp

示例10: filter_movit_convert_init

mlt_filter filter_movit_convert_init( mlt_profile profile, mlt_service_type type, const char *id, char *arg )
{
	mlt_filter filter = NULL;
	GlslManager* glsl = GlslManager::get_instance();

	if ( glsl && ( filter = mlt_filter_new() ) )
	{
		mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
		glsl->add_ref( properties );
#ifdef WIN32
		// XXX avcolor_space is crashing on Windows in this context!
		mlt_filter cpu_csc = NULL;
#else
		mlt_filter cpu_csc = create_filter( profile, "avcolor_space" );
#endif
		if ( !cpu_csc )
			cpu_csc = create_filter( profile, "imageconvert" );
		if ( cpu_csc )
			mlt_properties_set_data( MLT_FILTER_PROPERTIES( filter ), "cpu_csc", cpu_csc, 0,
				(mlt_destructor) mlt_filter_close, NULL );
		filter->process = process;
	}
	return filter;
}
开发者ID:jjcare,项目名称:mlt,代码行数:24,代码来源:filter_movit_convert.cpp

示例11: convert_image

static int convert_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, mlt_image_format output_format )
{
	// Nothing to do!
	if ( *format == output_format )
		return 0;

	mlt_properties properties = MLT_FRAME_PROPERTIES( frame );

	mlt_log_debug( NULL, "filter_movit_convert: %s -> %s\n",
		mlt_image_format_name( *format ), mlt_image_format_name( output_format ) );

	// Use CPU if glsl not initialized or not supported.
	GlslManager* glsl = GlslManager::get_instance();
	if ( !glsl || !glsl->get_int("glsl_supported" ) )
		return convert_on_cpu( frame, image, format, output_format );

	// Do non-GL image conversions on a CPU-based image converter.
	if ( *format != mlt_image_glsl && output_format != mlt_image_glsl && output_format != mlt_image_glsl_texture )
		return convert_on_cpu( frame, image, format, output_format );

	int error = 0;
	int width = mlt_properties_get_int( properties, "width" );
	int height = mlt_properties_get_int( properties, "height" );
	int img_size = mlt_image_format_size( *format, width, height, NULL );
	mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
	mlt_service service = MLT_PRODUCER_SERVICE(producer);
	GlslManager::get_instance()->lock_service( frame );
	EffectChain* chain = GlslManager::get_chain( service );
	MltInput* input = GlslManager::get_input( service );

	if ( !chain || !input ) {
		GlslManager::get_instance()->unlock_service( frame );
		return 2;
	}

	if ( *format != mlt_image_glsl ) {
		bool finalize_chain = false;
		if ( output_format == mlt_image_glsl_texture ) {
			// We might already have a texture from a previous conversion from mlt_image_glsl.
			glsl_texture texture = (glsl_texture) mlt_properties_get_data( properties, "movit.convert.texture", NULL );
			// XXX: requires a special property set on the frame by the app for now
			// because we do not have reliable way to clear the texture property
			// when a downstream filter has changed image.
			if ( texture && mlt_properties_get_int( properties, "movit.convert.use_texture") ) {
				*image = (uint8_t*) &texture->texture;
				mlt_frame_set_image( frame, *image, 0, NULL );
				mlt_properties_set_int( properties, "format", output_format );
				*format = output_format;
				GlslManager::get_instance()->unlock_service( frame );
				return error;
			} else {
				// Use a separate chain to convert image in RAM to OpenGL texture.
				// Use cached chain if available and compatible.
				Mlt::Producer producer( mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) ) );
				chain = (EffectChain*) producer.get_data( "movit.convert.chain" );
				input = (MltInput*) producer.get_data( "movit.convert.input" );
				int w = producer.get_int( "movit.convert.width" );
				int h = producer.get_int( "movit.convert.height" );
				mlt_image_format f = (mlt_image_format) producer.get_int( "movit.convert.format" );
				if ( !chain || width != w || height != h || output_format != f ) {
					chain = new EffectChain( width, height );
					input = new MltInput( width, height );
					chain->add_input( input );
					chain->add_effect( new Mlt::VerticalFlip() );
					finalize_chain = true;
					producer.set( "movit.convert.chain", chain, 0, (mlt_destructor) delete_chain );
					producer.set( "movit.convert.input", input, 0 );
					producer.set( "movit.convert.width", width );
					producer.set( "movit.convert.height", height );
					producer.set( "movit.convert.format", output_format );
				}
			}
		}
		if ( *format == mlt_image_rgb24a || *format == mlt_image_opengl ) { 
			input->useFlatInput( chain, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, width, height );
			input->set_pixel_data( *image );
		}
		else if ( *format == mlt_image_rgb24 ) {
			input->useFlatInput( chain, FORMAT_RGB, width, height );
			input->set_pixel_data( *image );
		}
		else if ( *format == mlt_image_yuv420p ) {
			ImageFormat image_format;
			YCbCrFormat ycbcr_format;
			if ( 709 == mlt_properties_get_int( properties, "colorspace" ) ) {
				image_format.color_space = COLORSPACE_REC_709;
				image_format.gamma_curve = GAMMA_REC_709;
				ycbcr_format.luma_coefficients = YCBCR_REC_709;
			} else if ( 576 == mlt_properties_get_int( properties, "height" ) ) {
				image_format.color_space = COLORSPACE_REC_601_625;
				image_format.gamma_curve = GAMMA_REC_601;
				ycbcr_format.luma_coefficients = YCBCR_REC_601;
			} else {
				image_format.color_space = COLORSPACE_REC_601_525;
				image_format.gamma_curve = GAMMA_REC_601;
				ycbcr_format.luma_coefficients = YCBCR_REC_601;
			}
			ycbcr_format.full_range = mlt_properties_get_int( properties, "force_full_luma" );
			ycbcr_format.chroma_subsampling_x = ycbcr_format.chroma_subsampling_y = 2;
			// TODO: make new frame properties set by producers
//.........这里部分代码省略.........
开发者ID:hrshadhin,项目名称:mlt,代码行数:101,代码来源:filter_movit_convert.cpp

示例12: get_image

static int get_image( mlt_frame a_frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
	int error = 0;

	// Get the b frame from the stack
	mlt_frame b_frame = (mlt_frame) mlt_frame_pop_frame( a_frame );

	// Get the transition object
	mlt_transition transition = (mlt_transition) mlt_frame_pop_service( a_frame );

	// Get the properties of the transition
	mlt_properties properties = MLT_TRANSITION_PROPERTIES( transition );

	// Get the properties of the a frame
	mlt_properties a_props = MLT_FRAME_PROPERTIES( a_frame );

	// Get the movit objects
	mlt_service service = MLT_TRANSITION_SERVICE( transition );
	mlt_service_lock( service );
	EffectChain* chain = GlslManager::get_chain( service );
	MltInput* a_input = GlslManager::get_input( service );
	MltInput* b_input = (MltInput*) mlt_properties_get_data( properties, "movit input B", NULL );
	mlt_image_format output_format = *format;

	if ( !chain || !a_input ) {
		mlt_service_unlock( service );
		return 2;
	}

	// Get the frames' textures
	GLuint* texture_id[2] = {0, 0};
	*format = mlt_image_glsl_texture;
	mlt_frame_get_image( a_frame, (uint8_t**) &texture_id[0], format, width, height, 0 );
	a_input->useFBOInput( chain, *texture_id[0] );
	*format = mlt_image_glsl_texture;
	mlt_frame_get_image( b_frame, (uint8_t**) &texture_id[1], format, width, height, 0 );
	b_input->useFBOInput( chain, *texture_id[1] );

	// Set resolution to that of the a_frame
	*width = mlt_properties_get_int( a_props, "width" );
	*height = mlt_properties_get_int( a_props, "height" );

	// Setup rendering to an FBO
	GlslManager* glsl = GlslManager::get_instance();
	glsl_fbo fbo = glsl->get_fbo( *width, *height );
	if ( output_format == mlt_image_glsl_texture ) {
		glsl_texture texture = glsl->get_texture( *width, *height, GL_RGBA );

		glBindFramebuffer( GL_FRAMEBUFFER, fbo->fbo );
		check_error();
		glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->texture, 0 );
		check_error();
		glBindFramebuffer( GL_FRAMEBUFFER, 0 );
		check_error();

		GlslManager::render( service, chain, fbo->fbo, *width, *height );

		glFinish();
		check_error();
		glBindFramebuffer( GL_FRAMEBUFFER, 0 );
		check_error();

		*image = (uint8_t*) &texture->texture;
		mlt_frame_set_image( a_frame, *image, 0, NULL );
		mlt_properties_set_data( properties, "movit.convert", texture, 0,
			(mlt_destructor) GlslManager::release_texture, NULL );
		*format = output_format;
	}
	else {
		// Use a PBO to hold the data we read back with glReadPixels()
		// (Intel/DRI goes into a slow path if we don't read to PBO)
		GLenum gl_format = ( output_format == mlt_image_rgb24a || output_format == mlt_image_opengl )?
			GL_RGBA : GL_RGB;
		int img_size = *width * *height * ( gl_format == GL_RGB? 3 : 4 );
		glsl_pbo pbo = glsl->get_pbo( img_size );
		glsl_texture texture = glsl->get_texture( *width, *height, gl_format );

		if ( fbo && pbo && texture ) {
			// Set the FBO
			glBindFramebuffer( GL_FRAMEBUFFER, fbo->fbo );
			check_error();
			glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->texture, 0 );
			check_error();
			glBindFramebuffer( GL_FRAMEBUFFER, 0 );
			check_error();

			GlslManager::render( service, chain, fbo->fbo, *width, *height );

			// Read FBO into PBO
			glBindBuffer( GL_PIXEL_PACK_BUFFER_ARB, pbo->pbo );
			check_error();
			glBufferData( GL_PIXEL_PACK_BUFFER_ARB, img_size, NULL, GL_STREAM_READ );
			check_error();
			glReadPixels( 0, 0, *width, *height, gl_format, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0) );
			check_error();

			// Copy from PBO
			uint8_t* buf = (uint8_t*) glMapBuffer( GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY );
			check_error();

//.........这里部分代码省略.........
开发者ID:adiibanez,项目名称:mlt,代码行数:101,代码来源:transition_movit_overlay.cpp

示例13: convert_image

static int convert_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, mlt_image_format output_format )
{
	// Nothing to do!
	if ( *format == output_format )
		return 0;

	mlt_properties properties = MLT_FRAME_PROPERTIES( frame );

	mlt_log_debug( NULL, "filter_movit_convert: %s -> %s (%d)\n",
		mlt_image_format_name( *format ), mlt_image_format_name( output_format ),
		mlt_frame_get_position( frame ) );

	// Use CPU if glsl not initialized or not supported.
	GlslManager* glsl = GlslManager::get_instance();
	if ( !glsl || !glsl->get_int("glsl_supported" ) )
		return convert_on_cpu( frame, image, format, output_format );

	// Do non-GL image conversions on a CPU-based image converter.
	if ( *format != mlt_image_glsl && output_format != mlt_image_glsl && output_format != mlt_image_glsl_texture )
		return convert_on_cpu( frame, image, format, output_format );

	int error = 0;
	int width = mlt_properties_get_int( properties, "width" );
	int height = mlt_properties_get_int( properties, "height" );
	GlslManager::get_instance()->lock_service( frame );
	
	// If we're at the beginning of a series of Movit effects, store the input
	// sent into the chain.
	if ( output_format == mlt_image_glsl ) {
		mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
		mlt_profile profile = mlt_service_profile( MLT_PRODUCER_SERVICE( producer ) );
		MltInput *input = create_input( properties, *format, profile->width, profile->height, width, height );
		GlslManager::set_input( producer, frame, input );
		uint8_t *img_copy = make_input_copy( *format, *image, width, height );
		GlslManager::set_input_pixel_pointer( producer, frame, img_copy );

		*image = (uint8_t *) -1;
		mlt_frame_set_image( frame, *image, 0, NULL );
	}

	// If we're at the _end_ of a series of Movit effects, render the chain.
	if ( *format == mlt_image_glsl ) {
		mlt_service leaf_service = (mlt_service) *image;

		if ( leaf_service == (mlt_service) -1 ) {
			// Something on the way requested conversion to mlt_glsl,
			// but never added an effect. Don't build a Movit chain;
			// just do the conversion and we're done.
			mlt_producer producer = mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) );
			MltInput *input = GlslManager::get_input( producer, frame );
			*image = GlslManager::get_input_pixel_pointer( producer, frame );
			*format = input->get_format();
			delete input;
			GlslManager::get_instance()->unlock_service( frame );
			return convert_on_cpu( frame, image, format, output_format );
		}

		// Construct the chain unless we already have a good one.
		finalize_movit_chain( leaf_service, frame );

		// Set per-frame parameters now that we know which Effect instances to set them on.
		// (finalize_movit_chain may already have done this, though, but twice doesn't hurt.)
		GlslChain *chain = GlslManager::get_chain( leaf_service );
		set_movit_parameters( chain, leaf_service, frame );

		error = movit_render( chain->effect_chain, frame, format, output_format, width, height, image );

		dispose_pixel_pointers( chain, leaf_service, frame );
	}

	// If we've been asked to render some frame directly to a texture (without any
	// effects in-between), we create a new mini-chain to do so.
	if ( *format != mlt_image_glsl && output_format == mlt_image_glsl_texture ) {
		// We might already have a texture from a previous conversion from mlt_image_glsl.
		glsl_texture texture = (glsl_texture) mlt_properties_get_data( properties, "movit.convert.texture", NULL );
		// XXX: requires a special property set on the frame by the app for now
		// because we do not have reliable way to clear the texture property
		// when a downstream filter has changed image.
		if ( texture && mlt_properties_get_int( properties, "movit.convert.use_texture") ) {
			*image = (uint8_t*) &texture->texture;
			mlt_frame_set_image( frame, *image, 0, NULL );
		} else {
			// Use a separate chain to convert image in RAM to OpenGL texture.
			// Use cached chain if available and compatible.
			Mlt::Producer producer( mlt_producer_cut_parent( mlt_frame_get_original_producer( frame ) ) );
			EffectChain *chain = (EffectChain*) producer.get_data( "movit.convert.chain" );
			MltInput *input = (MltInput*) producer.get_data( "movit.convert.input" );
			int w = producer.get_int( "movit.convert.width" );
			int h = producer.get_int( "movit.convert.height" );
			mlt_image_format f = (mlt_image_format) producer.get_int( "movit.convert.format" );
			if ( !chain || !input || width != w || height != h || *format != f ) {
				chain = new EffectChain( width, height, GlslManager::get_instance()->get_resource_pool() );
				input = create_input( properties, *format, width, height, width, height );
				chain->add_input( input->get_input() );
				chain->add_effect( new Mlt::VerticalFlip() );
				ImageFormat movit_output_format;
				movit_output_format.color_space = COLORSPACE_sRGB;
				movit_output_format.gamma_curve = GAMMA_sRGB;
				chain->add_output(movit_output_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED);
				chain->set_dither_bits(8);
//.........这里部分代码省略.........
开发者ID:jjcare,项目名称:mlt,代码行数:101,代码来源:filter_movit_convert.cpp


注:本文中的GlslManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。