[vlc-devel] [PATCH 10/11] vout/opengl: add a new API to convert textures

Thomas Guillem thomas at gllm.fr
Wed Dec 14 17:16:15 CET 2016


Add a new struct: opengl_tex_converter_t. This struct can be used to convert
textures in regards of a video_format_t. The main objective is to allow
developers to add support for HW specific chromas in separate files.
---
 modules/video_output/opengl/internal.h | 94 ++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)

diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h
index 2a31cbc..4639192 100644
--- a/modules/video_output/opengl/internal.h
+++ b/modules/video_output/opengl/internal.h
@@ -113,4 +113,98 @@ typedef struct {
 
 } opengl_shaders_api_t;
 
+typedef struct opengl_tex_converter_t opengl_tex_converter_t;
+
+/*
+ * Callback to initialize an opengl_tex_converter_t struct
+ *
+ * The implementation should initialize every members of the struct in regards
+ * of the video format.
+ *
+ * \param api function pointer to shaders commands
+ * \param fmt video format
+ * \param fc OpenGL tex converter that needs to be filled on success
+ * \return VLC_SUCCESS or a VLC error
+ */
+typedef int (*opengl_tex_converter_init_cb)(const opengl_shaders_api_t *api,
+                                            const video_format_t *fmt,
+                                            opengl_tex_converter_t *fc);
+
+/*
+ * Structure that is filled by an opengl_tex_converter_init_cb function
+ */
+struct opengl_tex_converter_t
+{
+    /* Video chroma used by this configuration, cannot be 0 */
+    vlc_fourcc_t chroma;
+    /* Description of the chroma, cannot be NULL */
+    const vlc_chroma_description_t *desc;
+    /* Texture mapping (usually: GL_TEXTURE_2D), cannot be 0 */
+    GLenum tex_target;
+
+    /* The compiled fragment shader, cannot be 0 */
+    GLuint fragment_shader;
+
+    /* Private context */
+    void *priv;
+
+    /*
+     * Callback to generate and prepare textures
+     *
+     * This function pointer cannot be NULL. The number of textures to generate
+     * is specified by desc->plane_count.
+     *
+     * \param fc OpenGL tex converter
+     * \param tex_width array of tex width (one per plane)
+     * \param tex_height array of tex height (one per plane)
+     * \param textures array of textures to generate (one per plane)
+     */
+    int (*pf_gen_textures)(const opengl_tex_converter_t *fc,
+                           const GLsizei *tex_width, const GLsizei *tex_height,
+                           GLuint *textures);
+
+    /*
+     * Callback to update a picture
+     *
+     * This function pointer cannot be NULL. The implementation should upload
+     * every planes of the picture.
+     *
+     * \param fc OpenGL tex converter
+     * \param textures array of textures to bind (one per plane)
+     * \param width width in pixels
+     * \param height height in pixels
+     * \param pic picture to update
+     * \param plane_offset offsets of each picture planes to read data from
+     * (one per plane, can be NULL)
+     */
+    int (*pf_update)(const opengl_tex_converter_t *fc, const GLuint *textures,
+                     unsigned width, unsigned height,
+                     const picture_t *pic, const size_t *plane_offset);
+
+    /*
+     * Callback to prepare the fragment shader
+     *
+     * This function pointer cannot be NULL. This callback can be used to
+     * specify values of uniform variables for the program object that is
+     * attached to the configured shader.
+     *
+     * \param fc OpenGL tex converter
+     * \param api function pointer to shaders commands
+     * \param alpha alpha value, used only for RGBA fragment shader
+     * \param program current program object
+     */
+    void (*pf_prepare_shader)(const opengl_tex_converter_t *fc,
+                              const opengl_shaders_api_t *api,
+                              GLuint program, float alpha);
+
+    /*
+     * Callback to release the shader and the private context
+     *
+     * This function pointer cannot be NULL.
+     * \param fc OpenGL tex converter
+     * \param api function pointer to shaders commands
+     */
+    void (*pf_release)(const opengl_tex_converter_t *fc,
+                       const opengl_shaders_api_t *api);
+};
 #endif /* include-guard */
-- 
2.10.2



More information about the vlc-devel mailing list