本文整理汇总了C++中GlslManager::get_pbo方法的典型用法代码示例。如果您正苦于以下问题:C++ GlslManager::get_pbo方法的具体用法?C++ GlslManager::get_pbo怎么用?C++ GlslManager::get_pbo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlslManager
的用法示例。
在下文中一共展示了GlslManager::get_pbo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert_image
//.........这里部分代码省略.........
if ( finalize_chain )
chain->finalize();
}
if ( output_format != mlt_image_glsl ) {
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( frame, *image, 0, NULL );
mlt_properties_set_data( properties, "movit.convert.texture", texture, 0,
(mlt_destructor) GlslManager::release_texture, NULL );
mlt_properties_set_int( properties, "format", output_format );
*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;
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();
*image = (uint8_t*) mlt_pool_alloc( img_size );
mlt_frame_set_image( frame, *image, img_size, mlt_pool_release );
memcpy( *image, buf, img_size );
if ( output_format == mlt_image_yuv422 || output_format == mlt_image_yuv420p ) {
*format = mlt_image_rgb24;
error = convert_on_cpu( frame, image, format, output_format );
}
// Release PBO and FBO
glUnmapBuffer( GL_PIXEL_PACK_BUFFER_ARB );
check_error();
glBindBuffer( GL_PIXEL_PACK_BUFFER_ARB, 0 );
check_error();
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
check_error();
glBindTexture( GL_TEXTURE_2D, 0 );
check_error();
mlt_properties_set_data( properties, "movit.convert.texture", texture, 0,
(mlt_destructor) GlslManager::release_texture, NULL);
mlt_properties_set_int( properties, "format", output_format );
*format = output_format;
}
else {
error = 1;
}
}
if ( fbo ) GlslManager::release_fbo( fbo );
}
else {
mlt_properties_set_int( properties, "format", output_format );
*format = output_format;
}
GlslManager::get_instance()->unlock_service( frame );
return error;
}
示例2: 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();
//.........这里部分代码省略.........