Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
gl,video: Make ptrs to VideoInfo and (GL)AllocationParams immutable
These parameters are incorrectly regarded as mutable in G-IR making them
"incompatible" with languages that are explicit about mutability like
Rust. In order to clean up the code and expected API there, update the
signatures here, right at the source (instead of overriding them in
Gir.toml and hoping for the best).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1005>
  • Loading branch information
MarijnS95 authored and GStreamer Merge Bot committed Jan 14, 2021
1 parent fa8b5b9 commit abb026e
Show file tree
Hide file tree
Showing 38 changed files with 126 additions and 116 deletions.
21 changes: 12 additions & 9 deletions ext/gl/gltestsrc.c
Expand Up @@ -166,7 +166,8 @@ _unbind_buffer (struct SrcShader *src)
}

static gboolean
_src_shader_init (gpointer impl, GstGLContext * context, GstVideoInfo * v_info)
_src_shader_init (gpointer impl, GstGLContext * context,
const GstVideoInfo * v_info)
{
struct SrcShader *src = impl;
const GstGLFuncs *gl = context->gl_vtable;
Expand Down Expand Up @@ -280,7 +281,7 @@ static const gchar *snow_vertex_src =
" out_uv = position.xy;\n"
"}";

static const gchar *snow_fragment_src =
static const gchar *snow_fragment_src =
"uniform float time;\n"
"varying vec2 out_uv;\n"
"\n"
Expand Down Expand Up @@ -314,7 +315,8 @@ _src_smpte_new (GstGLTestSrc * test)
}

static gboolean
_src_smpte_init (gpointer impl, GstGLContext * context, GstVideoInfo * v_info)
_src_smpte_init (gpointer impl, GstGLContext * context,
const GstVideoInfo * v_info)
{
struct SrcSMPTE *src = impl;
struct XYZWRGB *coord;
Expand Down Expand Up @@ -595,7 +597,7 @@ _src_uni_color_new (GstGLTestSrc * test)

static gboolean
_src_uni_color_init (gpointer impl, GstGLContext * context,
GstVideoInfo * v_info)
const GstVideoInfo * v_info)
{
struct SrcUniColor *src = impl;

Expand Down Expand Up @@ -712,7 +714,7 @@ struct SrcCheckers

static gboolean
_src_checkers_init (gpointer impl, GstGLContext * context,
GstVideoInfo * v_info)
const GstVideoInfo * v_info)
{
struct SrcCheckers *src = impl;
GError *error = NULL;
Expand Down Expand Up @@ -813,7 +815,8 @@ SRC_CHECKERS (4);
SRC_CHECKERS (8);

static gboolean
_src_snow_init (gpointer impl, GstGLContext * context, GstVideoInfo * v_info)
_src_snow_init (gpointer impl, GstGLContext * context,
const GstVideoInfo * v_info)
{
struct SrcShader *src = impl;
GError *error = NULL;
Expand Down Expand Up @@ -918,7 +921,7 @@ static const gchar *mandelbrot_vertex_src = "attribute vec4 position;\n"
" fractal_position *= 2.5;\n"
"}";

static const gchar *mandelbrot_fragment_src =
static const gchar *mandelbrot_fragment_src =
"uniform float time;\n"
"varying vec2 fractal_position;\n"
"const vec4 K = vec4(1.0, 0.66, 0.33, 3.0);\n"
Expand Down Expand Up @@ -952,7 +955,7 @@ static const gchar *mandelbrot_fragment_src =

static gboolean
_src_mandelbrot_init (gpointer impl, GstGLContext * context,
GstVideoInfo * v_info)
const GstVideoInfo * v_info)
{
struct SrcShader *src = impl;
GError *error = NULL;
Expand Down Expand Up @@ -1080,7 +1083,7 @@ static const gchar *circular_fragment_src =

static gboolean
_src_circular_init (gpointer impl, GstGLContext * context,
GstVideoInfo * v_info)
const GstVideoInfo * v_info)
{
struct SrcShader *src = impl;
GError *error = NULL;
Expand Down
2 changes: 1 addition & 1 deletion ext/gl/gltestsrc.h
Expand Up @@ -71,7 +71,7 @@ struct SrcFuncs
{
GstGLTestSrcPattern pattern;
gpointer (*new) (GstGLTestSrc * src);
gboolean (*init) (gpointer impl, GstGLContext * context, GstVideoInfo * v_info);
gboolean (*init) (gpointer impl, GstGLContext * context, const GstVideoInfo * v_info);
gboolean (*fill_bound_fbo) (gpointer impl);
void (*free) (gpointer impl);
};
Expand Down
2 changes: 1 addition & 1 deletion ext/gl/gstglimagesink.c
Expand Up @@ -1426,7 +1426,7 @@ gst_glimage_sink_get_caps (GstBaseSink * bsink, GstCaps * filter)

static gboolean
configure_display_from_info (GstGLImageSink * glimage_sink,
GstVideoInfo * vinfo)
const GstVideoInfo * vinfo)
{
gint width;
gint height;
Expand Down
12 changes: 6 additions & 6 deletions gst-libs/gst/gl/egl/gsteglimage.c
Expand Up @@ -460,7 +460,7 @@ gst_egl_image_from_texture (GstGLContext * context, GstGLMemory * gl_mem,
* target.
*/
static int
_drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane,
_drm_rgba_fourcc_from_info (const GstVideoInfo * info, int plane,
GstGLFormat * out_format)
{
GstVideoFormat format = GST_VIDEO_INFO_FORMAT (info);
Expand Down Expand Up @@ -571,7 +571,7 @@ _drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane,
*/
GstEGLImage *
gst_egl_image_from_dmabuf (GstGLContext * context,
gint dmabuf, GstVideoInfo * in_info, gint plane, gsize offset)
gint dmabuf, const GstVideoInfo * in_info, gint plane, gsize offset)
{
GstGLFormat format = 0;
guintptr attribs[13];
Expand Down Expand Up @@ -621,7 +621,7 @@ gst_egl_image_from_dmabuf (GstGLContext * context,
* YUV->RGB conversion matrices etc.)
*/
static int
_drm_direct_fourcc_from_info (GstVideoInfo * info)
_drm_direct_fourcc_from_info (const GstVideoInfo * info)
{
GstVideoFormat format = GST_VIDEO_INFO_FORMAT (info);

Expand Down Expand Up @@ -729,7 +729,7 @@ _drm_direct_fourcc_from_info (GstVideoInfo * info)
*/
gboolean
gst_egl_image_check_dmabuf_direct (GstGLContext * context,
GstVideoInfo * in_info, GstGLTextureTarget target)
const GstVideoInfo * in_info, GstGLTextureTarget target)
{
EGLDisplay egl_display = EGL_DEFAULT_DISPLAY;
GstGLDisplayEGL *display_egl;
Expand Down Expand Up @@ -857,7 +857,7 @@ gst_egl_image_check_dmabuf_direct (GstGLContext * context,
*/
GstEGLImage *
gst_egl_image_from_dmabuf_direct_target (GstGLContext * context,
gint * fd, gsize * offset, GstVideoInfo * in_info,
gint * fd, const gsize * offset, const GstVideoInfo * in_info,
GstGLTextureTarget target)
{

Expand Down Expand Up @@ -1022,7 +1022,7 @@ gst_egl_image_from_dmabuf_direct_target (GstGLContext * context,
*/
GstEGLImage *
gst_egl_image_from_dmabuf_direct (GstGLContext * context,
gint * fd, gsize * offset, GstVideoInfo * in_info)
gint * fd, const gsize * offset, const GstVideoInfo * in_info)
{
return gst_egl_image_from_dmabuf_direct_target (context, fd, offset, in_info,
GST_GL_TEXTURE_TARGET_2D);
Expand Down
10 changes: 5 additions & 5 deletions gst-libs/gst/gl/egl/gsteglimage.h
Expand Up @@ -85,19 +85,19 @@ GstEGLImage * gst_egl_image_from_texture (GstGLContext *
GST_GL_API
GstEGLImage * gst_egl_image_from_dmabuf (GstGLContext * context,
gint dmabuf,
GstVideoInfo * in_info,
const GstVideoInfo * in_info,
gint plane,
gsize offset);
GST_GL_API
GstEGLImage * gst_egl_image_from_dmabuf_direct (GstGLContext * context,
gint *fd,
gsize *offset,
GstVideoInfo * in_info);
const gsize *offset,
const GstVideoInfo * in_info);
GST_GL_API
GstEGLImage * gst_egl_image_from_dmabuf_direct_target (GstGLContext * context,
gint *fd,
gsize *offset,
GstVideoInfo * in_info,
const gsize *offset,
const GstVideoInfo * in_info,
GstGLTextureTarget target);

GST_GL_API
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/egl/gsteglimage_private.h
Expand Up @@ -28,7 +28,7 @@ G_BEGIN_DECLS

G_GNUC_INTERNAL
gboolean gst_egl_image_check_dmabuf_direct (GstGLContext * context,
GstVideoInfo * in_info,
const GstVideoInfo * in_info,
GstGLTextureTarget target);


Expand Down
7 changes: 4 additions & 3 deletions gst-libs/gst/gl/gstglbasememory.c
Expand Up @@ -128,8 +128,9 @@ _mem_create_gl (GstGLContext * context, struct create_data *transfer)
*/
void
gst_gl_base_memory_init (GstGLBaseMemory * mem, GstAllocator * allocator,
GstMemory * parent, GstGLContext * context, GstAllocationParams * params,
gsize size, gpointer user_data, GDestroyNotify notify)
GstMemory * parent, GstGLContext * context,
const GstAllocationParams * params, gsize size, gpointer user_data,
GDestroyNotify notify)
{
gsize align = gst_memory_alignment, offset = 0, maxsize;
GstMemoryFlags flags = 0;
Expand Down Expand Up @@ -631,7 +632,7 @@ gboolean
gst_gl_allocation_params_init (GstGLAllocationParams * params,
gsize struct_size, guint alloc_flags, GstGLAllocationParamsCopyFunc copy,
GstGLAllocationParamsFreeFunc free, GstGLContext * context,
gsize alloc_size, GstAllocationParams * alloc_params,
gsize alloc_size, const GstAllocationParams * alloc_params,
gpointer wrapped_data, gpointer gl_handle, gpointer user_data,
GDestroyNotify notify)
{
Expand Down
4 changes: 2 additions & 2 deletions gst-libs/gst/gl/gstglbasememory.h
Expand Up @@ -227,7 +227,7 @@ gboolean gst_gl_allocation_params_init (GstGLAllocationPara
GstGLAllocationParamsFreeFunc free,
GstGLContext * context,
gsize alloc_size,
GstAllocationParams * alloc_params,
const GstAllocationParams * alloc_params,
gpointer wrapped_data,
gpointer gl_handle,
gpointer user_data,
Expand Down Expand Up @@ -398,7 +398,7 @@ void gst_gl_base_memory_init (GstGLBaseMemory * mem,
GstAllocator * allocator,
GstMemory * parent,
GstGLContext * context,
GstAllocationParams * params,
const GstAllocationParams * params,
gsize size,
gpointer user_data,
GDestroyNotify notify);
Expand Down
6 changes: 3 additions & 3 deletions gst-libs/gst/gl/gstglbuffer.c
Expand Up @@ -97,7 +97,7 @@ struct create_data
static void
_gl_buffer_init (GstGLBuffer * mem, GstAllocator * allocator,
GstMemory * parent, GstGLContext * context, guint gl_target, guint gl_usage,
GstAllocationParams * params, gsize size)
const GstAllocationParams * params, gsize size)
{
mem->target = gl_target;
mem->usage_hints = gl_usage;
Expand All @@ -112,7 +112,7 @@ _gl_buffer_init (GstGLBuffer * mem, GstAllocator * allocator,
static GstGLBuffer *
_gl_buffer_new (GstAllocator * allocator, GstMemory * parent,
GstGLContext * context, guint gl_target, guint gl_usage,
GstAllocationParams * params, gsize size)
const GstAllocationParams * params, gsize size)
{
GstGLBuffer *ret = g_new0 (GstGLBuffer, 1);
_gl_buffer_init (ret, allocator, parent, context, gl_target, gl_usage,
Expand Down Expand Up @@ -371,7 +371,7 @@ G_DEFINE_BOXED_TYPE (GstGLBufferAllocationParams,
*/
GstGLBufferAllocationParams *
gst_gl_buffer_allocation_params_new (GstGLContext * context, gsize alloc_size,
GstAllocationParams * alloc_params, guint gl_target, guint gl_usage)
const GstAllocationParams * alloc_params, guint gl_target, guint gl_usage)
{
GstGLBufferAllocationParams *params;

Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglbuffer.h
Expand Up @@ -87,7 +87,7 @@ struct _GstGLBufferAllocationParams
GST_GL_API
GstGLBufferAllocationParams * gst_gl_buffer_allocation_params_new (GstGLContext * context,
gsize alloc_size,
GstAllocationParams * alloc_params,
const GstAllocationParams * alloc_params,
guint gl_target,
guint gl_usage);

Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglbufferpool.c
Expand Up @@ -406,7 +406,7 @@ gst_buffer_pool_config_get_gl_allocation_params (GstStructure * config)
*/
void
gst_buffer_pool_config_set_gl_allocation_params (GstStructure * config,
GstGLAllocationParams * params)
const GstGLAllocationParams * params)
{
g_return_if_fail (config != NULL);
g_return_if_fail (params != NULL);
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglbufferpool.h
Expand Up @@ -73,7 +73,7 @@ GST_GL_API
GstGLAllocationParams * gst_buffer_pool_config_get_gl_allocation_params (GstStructure * config);
GST_GL_API
void gst_buffer_pool_config_set_gl_allocation_params (GstStructure * config,
GstGLAllocationParams * params);
const GstGLAllocationParams * params);

G_END_DECLS

Expand Down
4 changes: 2 additions & 2 deletions gst-libs/gst/gl/gstglcolorconvert.c
Expand Up @@ -658,8 +658,8 @@ gst_gl_color_convert_reset (GstGLColorConvert * convert)
}

static gboolean
_gst_gl_color_convert_can_passthrough_info (GstVideoInfo * in,
GstVideoInfo * out)
_gst_gl_color_convert_can_passthrough_info (const GstVideoInfo * in,
const GstVideoInfo * out)
{
gint i;

Expand Down
4 changes: 2 additions & 2 deletions gst-libs/gst/gl/gstglformat.c
Expand Up @@ -148,8 +148,8 @@ gst_gl_format_type_n_bytes (guint format, guint type)
* Returns: the #GstGLFormat necessary for holding the data in @plane of @vinfo
*/
GstGLFormat
gst_gl_format_from_video_info (GstGLContext * context, GstVideoInfo * vinfo,
guint plane)
gst_gl_format_from_video_info (GstGLContext * context,
const GstVideoInfo * vinfo, guint plane)
{
gboolean texture_rg =
gst_gl_context_check_feature (context, "GL_EXT_texture_rg")
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglformat.h
Expand Up @@ -140,7 +140,7 @@ guint gst_gl_format_type_n_bytes (guint forma
guint type);
GST_GL_API
GstGLFormat gst_gl_format_from_video_info (GstGLContext * context,
GstVideoInfo * vinfo,
const GstVideoInfo * vinfo,
guint plane);
GST_GL_API
guint gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context,
Expand Down

0 comments on commit abb026e

Please sign in to comment.