From 2cb2a3951b1e615174beeb7155075d4c02cda519 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Thu, 14 Nov 2013 15:08:47 +1100 Subject: [PATCH] [844/906] mixer: give access to the pads at render time allows us to move the video frame mapping somewhere else --- gst-libs/gst/gl/gstglmixer.c | 27 +++++++++++++++++++-------- gst-libs/gst/gl/gstglmixer.h | 11 +++++++++-- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/gst-libs/gst/gl/gstglmixer.c b/gst-libs/gst/gl/gstglmixer.c index c31e50d6f..0143fd4a6 100644 --- a/gst-libs/gst/gl/gstglmixer.c +++ b/gst-libs/gst/gl/gstglmixer.c @@ -1476,6 +1476,11 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf) GstSegment *seg; guint in_tex; GstVideoFrame *in_frame; + GstGLMixerFrameData *frame; + + frame = g_ptr_array_index (mix->frames, array_index); + frame->pad = pad; + frame->texture = 0; seg = &mixcol->collect.segment; @@ -1537,13 +1542,12 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf) pad->mapped = TRUE; } - g_array_index (mix->array_textures, guint, array_index) = in_tex; + frame->texture = in_tex; } ++array_index; } - mix_class->process_textures (mix, mix->array_textures, mix->in_frames, - out_tex); + mix_class->process_textures (mix, mix->frames, out_tex); if (out_gl_wrapped) { if (gst_gl_download_perform_with_data (mix->download, out_tex, @@ -2127,15 +2131,18 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition) mix->array_buffers = g_ptr_array_new_full (mix->numpads, NULL); mix->in_frames = g_ptr_array_new_full (mix->numpads, NULL); - mix->array_textures = - g_array_sized_new (FALSE, TRUE, sizeof (guint), mix->numpads); + mix->frames = g_ptr_array_new_full (mix->numpads, NULL); g_ptr_array_set_size (mix->array_buffers, mix->numpads); g_ptr_array_set_size (mix->in_frames, mix->numpads); - g_array_set_size (mix->array_textures, mix->numpads); + g_ptr_array_set_size (mix->frames, mix->numpads); + + for (i = 0; i < mix->numpads; i++) { + mix->in_frames->pdata[i] = g_slice_new0 (GstVideoFrame); + } for (i = 0; i < mix->numpads; i++) { - mix->in_frames->pdata[i] = g_slice_alloc (sizeof (GstVideoFrame)); + mix->frames->pdata[i] = g_slice_new0 (GstGLMixerFrameData); } GST_LOG_OBJECT (mix, "starting collectpads"); @@ -2154,9 +2161,13 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition) g_slice_free1 (sizeof (GstVideoFrame), mix->in_frames->pdata[i]); } + for (i = 0; i < mix->numpads; i++) { + g_slice_free1 (sizeof (GstGLMixerFrameData), mix->in_frames->pdata[i]); + } + g_ptr_array_free (mix->array_buffers, TRUE); g_ptr_array_free (mix->in_frames, TRUE); - g_array_free (mix->array_textures, TRUE); + g_ptr_array_free (mix->frames, TRUE); if (mixer_class->reset) mixer_class->reset (mix); diff --git a/gst-libs/gst/gl/gstglmixer.h b/gst-libs/gst/gl/gstglmixer.h index 92fb00c9b..7a1435749 100644 --- a/gst-libs/gst/gl/gstglmixer.h +++ b/gst-libs/gst/gl/gstglmixer.h @@ -43,6 +43,7 @@ G_BEGIN_DECLS typedef struct _GstGLMixer GstGLMixer; typedef struct _GstGLMixerClass GstGLMixerClass; typedef struct _GstGLMixerPrivate GstGLMixerPrivate; +typedef struct _GstGLMixerFrameData GstGLMixerFrameData; typedef gboolean (*GstGLMixerSetCaps) (GstGLMixer* mixer, GstCaps* outcaps); @@ -50,7 +51,7 @@ typedef void (*GstGLMixerReset) (GstGLMixer *mixer); typedef gboolean (*GstGLMixerProcessFunc) (GstGLMixer *mix, GPtrArray *buffers, GstBuffer *outbuf); typedef gboolean (*GstGLMixerProcessTextures) (GstGLMixer *mix, - GArray *in_textures, GPtrArray *in_frames, guint out_tex); + GPtrArray *frames, guint out_tex); struct _GstGLMixer { @@ -73,8 +74,8 @@ struct _GstGLMixer gint next_sinkpad; GPtrArray *array_buffers; - GArray *array_textures; GPtrArray *in_frames; + GPtrArray *frames; GstVideoInfo out_info; GLuint out_tex_id; @@ -108,6 +109,12 @@ struct _GstGLMixerClass GstGLMixerProcessTextures process_textures; }; +struct _GstGLMixerFrameData +{ + GstGLMixerPad *pad; + guint texture; +}; + GType gst_gl_mixer_get_type(void); gboolean gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf); -- 2.34.1