mirror of
https://github.com/raspberrypi/userland.git
synced 2025-12-06 04:49:12 +00:00
RaspiStill example code for YUV fast paths
Update RaspiStill framework to provide access to the new EGL image targets that provide a fastpath for mapping the individual YUV planes to one byte per pixel GL_LUMINANCE buffers. These are still accessed as OES textures so this is effectively a greyscale image created from a single plane of a MMAL buffer. Also added some example code (yuv, sobel) that demonstrates how to use the new EGL image targets. Also, add -gc to the command line to capture the GL frame-buffer as a TGA file. Thanks to Tim Gover
This commit is contained in:
@@ -26,8 +26,8 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef RASPITEX_UTIL_H
|
||||
#define RASPITEX_UTIL_H
|
||||
#ifndef RASPITEX_UTIL_H_
|
||||
#define RASPITEX_UTIL_H_
|
||||
|
||||
#define VCOS_LOG_CATEGORY (&raspitex_log_category)
|
||||
#include <math.h>
|
||||
@@ -41,6 +41,34 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
extern VCOS_LOG_CAT_T raspitex_log_category;
|
||||
|
||||
#define SHADER_MAX_ATTRIBUTES 16
|
||||
#define SHADER_MAX_UNIFORMS 16
|
||||
/**
|
||||
* Container for a simple shader program. The uniform and attribute locations
|
||||
* are automatically setup by raspitex_build_shader_program.
|
||||
*/
|
||||
typedef struct RASPITEXUTIL_SHADER_PROGRAM_T
|
||||
{
|
||||
const char *vertex_source; /// Pointer to vertex shader source
|
||||
const char *fragment_source; /// Pointer to fragment shader source
|
||||
|
||||
/// Array of uniform names for raspitex_build_shader_program to process
|
||||
const char *uniform_names[SHADER_MAX_UNIFORMS];
|
||||
/// Array of attribute names for raspitex_build_shader_program to process
|
||||
const char *attribute_names[SHADER_MAX_ATTRIBUTES];
|
||||
|
||||
GLint vs; /// Vertex shader handle
|
||||
GLint fs; /// Fragment shader handle
|
||||
GLint program; /// Shader program handle
|
||||
|
||||
/// The locations for uniforms defined in uniform_names
|
||||
GLint uniform_locations[SHADER_MAX_UNIFORMS];
|
||||
|
||||
/// The locations for attributes defined in attribute_names
|
||||
GLint attribute_locations[SHADER_MAX_ATTRIBUTES];
|
||||
} RASPITEXUTIL_SHADER_PROGRAM_T;
|
||||
|
||||
|
||||
/* Uncomment to enable extra GL error checking */
|
||||
//#define CHECK_GL_ERRORS
|
||||
#if defined(CHECK_GL_ERRORS)
|
||||
@@ -50,7 +78,7 @@ do { \
|
||||
X; \
|
||||
while ((err = glGetError())) \
|
||||
{ \
|
||||
vcos_log_trace("GL error 0x%x in " #X "file %s line %d", err, __FILE__,__LINE__); \
|
||||
vcos_log_error("GL error 0x%x in " #X "file %s line %d", err, __FILE__,__LINE__); \
|
||||
vcos_assert(err == GL_NO_ERROR); \
|
||||
exit(err); \
|
||||
} \
|
||||
@@ -68,8 +96,21 @@ int raspitexutil_update_model(RASPITEX_STATE* raspitex_state);
|
||||
int raspitexutil_redraw(RASPITEX_STATE* raspitex_state);
|
||||
void raspitexutil_gl_term(RASPITEX_STATE *raspitex_state);
|
||||
void raspitexutil_destroy_native_window(RASPITEX_STATE *raspitex_state);
|
||||
int raspitexutil_create_textures(RASPITEX_STATE *raspitex_state);
|
||||
int raspitexutil_update_texture(RASPITEX_STATE *raspitex_state,
|
||||
EGLClientBuffer mm_buf);
|
||||
int raspitexutil_update_y_texture(RASPITEX_STATE *raspitex_state,
|
||||
EGLClientBuffer mm_buf);
|
||||
int raspitexutil_update_u_texture(RASPITEX_STATE *raspitex_state,
|
||||
EGLClientBuffer mm_buf);
|
||||
int raspitexutil_update_v_texture(RASPITEX_STATE *raspitex_state,
|
||||
EGLClientBuffer mm_buf);
|
||||
int raspitexutil_capture_bgra(struct RASPITEX_STATE *state,
|
||||
uint8_t **buffer, size_t *buffer_size);
|
||||
void raspitexutil_close(RASPITEX_STATE* raspitex_state);
|
||||
|
||||
#endif /* RASPITEX_UTIL_H */
|
||||
/* Utility functions */
|
||||
int raspitexutil_build_shader_program(RASPITEXUTIL_SHADER_PROGRAM_T *p);
|
||||
void raspitexutil_brga_to_rgba(uint8_t *buffer, size_t size);
|
||||
|
||||
#endif /* RASPITEX_UTIL_H_ */
|
||||
|
||||
Reference in New Issue
Block a user