mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 11:10:37 +00:00
[844/906] mixer: give access to the pads at render time
allows us to move the video frame mapping somewhere else
This commit is contained in:
parent
4322266b97
commit
63ccd94d1a
6 changed files with 52 additions and 42 deletions
|
@ -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_alloc (sizeof (GstVideoFrame));
|
||||
mix->in_frames->pdata[i] = g_slice_new0 (GstVideoFrame);
|
||||
}
|
||||
|
||||
for (i = 0; i < mix->numpads; i++) {
|
||||
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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -65,7 +65,7 @@ static gboolean gst_gl_mosaic_init_shader (GstGLMixer * mixer,
|
|||
GstCaps * outcaps);
|
||||
|
||||
static gboolean gst_gl_mosaic_process_textures (GstGLMixer * mixer,
|
||||
GArray * in_textures, GPtrArray * in_frames, guint out_tex);
|
||||
GPtrArray * frames, guint out_tex);
|
||||
static void gst_gl_mosaic_callback (gpointer stuff);
|
||||
|
||||
//vertex source
|
||||
|
@ -135,7 +135,6 @@ static void
|
|||
gst_gl_mosaic_init (GstGLMosaic * mosaic)
|
||||
{
|
||||
mosaic->shader = NULL;
|
||||
mosaic->input_textures = NULL;
|
||||
mosaic->input_frames = NULL;
|
||||
}
|
||||
|
||||
|
@ -170,7 +169,6 @@ gst_gl_mosaic_reset (GstGLMixer * mixer)
|
|||
{
|
||||
GstGLMosaic *mosaic = GST_GL_MOSAIC (mixer);
|
||||
|
||||
mosaic->input_textures = NULL;
|
||||
mosaic->input_frames = NULL;
|
||||
|
||||
//blocking call, wait the opengl thread has destroyed the shader
|
||||
|
@ -190,13 +188,12 @@ gst_gl_mosaic_init_shader (GstGLMixer * mixer, GstCaps * outcaps)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_mosaic_process_textures (GstGLMixer * mix, GArray * in_textures,
|
||||
GPtrArray * in_frames, guint out_tex)
|
||||
gst_gl_mosaic_process_textures (GstGLMixer * mix, GPtrArray * frames,
|
||||
guint out_tex)
|
||||
{
|
||||
GstGLMosaic *mosaic = GST_GL_MOSAIC (mix);
|
||||
|
||||
mosaic->input_textures = in_textures;
|
||||
mosaic->input_frames = in_frames;
|
||||
mosaic->input_frames = frames;
|
||||
|
||||
//blocking call, use a FBO
|
||||
gst_gl_context_use_fbo_v2 (mix->context,
|
||||
|
@ -251,20 +248,20 @@ gst_gl_mosaic_callback (gpointer stuff)
|
|||
attr_texture_loc =
|
||||
gst_gl_shader_get_attribute_location (mosaic->shader, "a_texCoord");
|
||||
|
||||
while (count < mosaic->input_textures->len && count < 6) {
|
||||
GstVideoFrame *in_frame;
|
||||
while (count < mosaic->input_frames->len && count < 6) {
|
||||
GstGLMixerFrameData *frame;
|
||||
GLfloat *v_vertices;
|
||||
guint in_tex;
|
||||
guint width, height;
|
||||
|
||||
in_frame = g_ptr_array_index (mosaic->input_frames, count);
|
||||
in_tex = g_array_index (mosaic->input_textures, guint, count);
|
||||
width = GST_VIDEO_FRAME_WIDTH (in_frame);
|
||||
height = GST_VIDEO_FRAME_HEIGHT (in_frame);
|
||||
frame = g_ptr_array_index (mosaic->input_frames, count);
|
||||
in_tex = frame->texture;
|
||||
width = GST_VIDEO_INFO_WIDTH (&frame->pad->in_info);
|
||||
height = GST_VIDEO_INFO_HEIGHT (&frame->pad->in_info);
|
||||
|
||||
if (!in_frame || !in_tex || width <= 0 || height <= 0) {
|
||||
if (!frame || !in_tex || width <= 0 || height <= 0) {
|
||||
GST_DEBUG ("skipping texture:%u frame:%p width:%u height %u",
|
||||
in_tex, in_frame, width, height);
|
||||
in_tex, frame, width, height);
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ struct _GstGLMosaic
|
|||
GstGLMixer mixer;
|
||||
|
||||
GstGLShader *shader;
|
||||
GArray *input_textures;
|
||||
GPtrArray *input_frames;
|
||||
};
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ static gboolean gst_gl_video_mixer_init_shader (GstGLMixer * mixer,
|
|||
GstCaps * outcaps);
|
||||
|
||||
static gboolean gst_gl_video_mixer_process_textures (GstGLMixer * mixer,
|
||||
GArray * in_textures, GPtrArray * in_frames, guint out_tex);
|
||||
GPtrArray * in_frames, guint out_tex);
|
||||
static void gst_gl_video_mixer_callback (gpointer stuff);
|
||||
|
||||
/* vertex source */
|
||||
|
@ -116,7 +116,6 @@ static void
|
|||
gst_gl_video_mixer_init (GstGLVideoMixer * video_mixer)
|
||||
{
|
||||
video_mixer->shader = NULL;
|
||||
video_mixer->input_textures = NULL;
|
||||
video_mixer->input_frames = NULL;
|
||||
}
|
||||
|
||||
|
@ -147,7 +146,6 @@ gst_gl_video_mixer_reset (GstGLMixer * mixer)
|
|||
{
|
||||
GstGLVideoMixer *video_mixer = GST_GL_VIDEO_MIXER (mixer);
|
||||
|
||||
video_mixer->input_textures = NULL;
|
||||
video_mixer->input_frames = NULL;
|
||||
|
||||
if (video_mixer->shader)
|
||||
|
@ -165,13 +163,12 @@ gst_gl_video_mixer_init_shader (GstGLMixer * mixer, GstCaps * outcaps)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_gl_video_mixer_process_textures (GstGLMixer * mix, GArray * in_textures,
|
||||
GPtrArray * in_frames, guint out_tex)
|
||||
gst_gl_video_mixer_process_textures (GstGLMixer * mix, GPtrArray * frames,
|
||||
guint out_tex)
|
||||
{
|
||||
GstGLVideoMixer *video_mixer = GST_GL_VIDEO_MIXER (mix);
|
||||
|
||||
video_mixer->input_textures = in_textures;
|
||||
video_mixer->input_frames = in_frames;
|
||||
video_mixer->input_frames = frames;
|
||||
|
||||
gst_gl_context_use_fbo_v2 (mix->context,
|
||||
GST_VIDEO_INFO_WIDTH (&mix->out_info),
|
||||
|
@ -222,21 +219,21 @@ gst_gl_video_mixer_callback (gpointer stuff)
|
|||
|
||||
gl->Enable (GL_BLEND);
|
||||
|
||||
while (count < video_mixer->input_textures->len) {
|
||||
GstVideoFrame *in_frame;
|
||||
while (count < video_mixer->input_frames->len) {
|
||||
GstGLMixerFrameData *frame;
|
||||
GLfloat *v_vertices;
|
||||
guint in_tex;
|
||||
guint in_width, in_height;
|
||||
gfloat w, h;
|
||||
|
||||
in_frame = g_ptr_array_index (video_mixer->input_frames, count);
|
||||
in_tex = g_array_index (video_mixer->input_textures, guint, count);
|
||||
in_width = GST_VIDEO_FRAME_WIDTH (in_frame);
|
||||
in_height = GST_VIDEO_FRAME_HEIGHT (in_frame);
|
||||
frame = g_ptr_array_index (video_mixer->input_frames, count);
|
||||
in_tex = frame->texture;
|
||||
in_width = GST_VIDEO_INFO_WIDTH (&frame->pad->in_info);
|
||||
in_height = GST_VIDEO_INFO_HEIGHT (&frame->pad->in_info);
|
||||
|
||||
if (!in_frame || !in_tex || in_width <= 0 || in_height <= 0) {
|
||||
if (!frame || !in_tex || in_width <= 0 || in_height <= 0) {
|
||||
GST_DEBUG ("skipping texture:%u frame:%p width:%u height %u",
|
||||
in_tex, in_frame, in_width, in_height);
|
||||
in_tex, frame, in_width, in_height);
|
||||
count++;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ struct _GstGLVideoMixer
|
|||
GstGLMixer mixer;
|
||||
|
||||
GstGLShader *shader;
|
||||
GArray *input_textures;
|
||||
GPtrArray *input_frames;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue