[vlc-commits] vout/opengl: add a new API to convert textures

Thomas Guillem git at videolan.org
Mon Dec 19 12:06:41 CET 2016


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Dec 14 16:48:56 2016 +0100| [b94de34ccda1c02ddeb84059794ef90e1299b61b] | committer: Thomas Guillem

vout/opengl: add a new API to convert textures

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b94de34ccda1c02ddeb84059794ef90e1299b61b
---

 modules/video_output/opengl/internal.h | 126 +++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)

diff --git a/modules/video_output/opengl/internal.h b/modules/video_output/opengl/internal.h
index b215c43..fc98965 100644
--- a/modules/video_output/opengl/internal.h
+++ b/modules/video_output/opengl/internal.h
@@ -117,4 +117,130 @@ 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 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 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
+{
+    /* Pointer to object parent, set by the caller of the init cb */
+    vlc_object_t *parent;
+    /* Function pointer to shaders commands, set by the caller of the init cb */
+    const opengl_shaders_api_t *api;
+    /* Set it to request a special orientation (by default = fmt.orientation) */
+    video_orientation_t orientation;
+
+    /* 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)
+     * \return VLC_SUCCESS or a VLC error
+     */
+    int (*pf_gen_textures)(const opengl_tex_converter_t *fc,
+                           const GLsizei *tex_width, const GLsizei *tex_height,
+                           GLuint *textures);
+
+    /*
+     * Callback to delete textures generated by pf_gen_textures()
+     *
+     * This function pointer cannot be NULL.
+     *
+     * \param fc OpenGL tex converter
+     * \param textures array of textures to delete (one per plane)
+     */
+    void (*pf_del_textures)(const opengl_tex_converter_t *fc,
+                            const GLuint *textures);
+
+    /*
+     * Callback to allocate a picture pool
+     *
+     * This function pointer *can* be NULL. If NULL, A generic pool with
+     * pictures allocated from the video_format_t will be used.
+     *
+     * \param fc OpenGL tex converter
+     * \param fmt video format
+     * \param requested_count number of pictures to allocate
+     * \param textures textures generated by pf_gen_textures()
+     * \return the picture pool or NULL in case of error
+     */
+    picture_pool_t *(*pf_get_pool)(const opengl_tex_converter_t *fc,
+                                   const video_format_t *fmt,
+                                   unsigned requested_count,
+                                   const 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)
+     * \return VLC_SUCCESS or a VLC error
+     */
+    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 alpha alpha value, used only for RGBA fragment shader
+     * \param program current program object
+     */
+    void (*pf_prepare_shader)(const opengl_tex_converter_t *fc,
+                              GLuint program, float alpha);
+
+    /*
+     * Callback to release the shader and the private context
+     *
+     * This function pointer cannot be NULL.
+     * \param fc OpenGL tex converter
+     */
+    void (*pf_release)(const opengl_tex_converter_t *fc);
+};
 #endif /* include-guard */



More information about the vlc-commits mailing list