visual: enable commented out code again.

Finish the last change and reenable the shader code.
This commit is contained in:
Stefan Sauer 2012-08-17 23:03:52 +02:00
parent d41504e804
commit 8222ba16c8
2 changed files with 18 additions and 16 deletions

View file

@ -646,9 +646,10 @@ gst_audio_visualizer_dispose (GObject * object)
gst_buffer_unref (scope->inbuf); gst_buffer_unref (scope->inbuf);
scope->inbuf = NULL; scope->inbuf = NULL;
} }
if (scope->pixelbuf) { if (scope->tempbuf) {
g_free (scope->pixelbuf); gst_video_frame_unmap (&scope->tempframe);
scope->pixelbuf = NULL; gst_buffer_unref (scope->tempbuf);
scope->tempbuf = NULL;
} }
if (scope->config_lock.p) { if (scope->config_lock.p) {
g_mutex_clear (&scope->config_lock); g_mutex_clear (&scope->config_lock);
@ -715,9 +716,14 @@ gst_audio_visualizer_src_setcaps (GstAudioVisualizer * scope, GstCaps * caps)
GST_VIDEO_INFO_FPS_D (&info), GST_VIDEO_INFO_FPS_N (&info)); GST_VIDEO_INFO_FPS_D (&info), GST_VIDEO_INFO_FPS_N (&info));
scope->req_spf = scope->spf; scope->req_spf = scope->spf;
if (scope->pixelbuf) if (scope->tempbuf) {
g_free (scope->pixelbuf); gst_video_frame_unmap (&scope->tempframe);
scope->pixelbuf = g_malloc0 (info.size); gst_buffer_unref (scope->tempbuf);
}
scope->tempbuf = gst_buffer_new_wrapped (g_malloc0 (scope->vinfo.size),
scope->vinfo.size);
gst_video_frame_map (&scope->tempframe, &scope->vinfo, scope->tempbuf,
GST_MAP_READWRITE);
if (klass->setup) if (klass->setup)
res = klass->setup (scope); res = klass->setup (scope);
@ -953,14 +959,12 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
gst_video_frame_map (&outframe, &scope->vinfo, outbuf, GST_MAP_READWRITE); gst_video_frame_map (&outframe, &scope->vinfo, outbuf, GST_MAP_READWRITE);
#if 0
/* FIXME? copy uninitialized memory into the destination buffer? */
if (scope->shader) { if (scope->shader) {
memcpy (map.data, scope->pixelbuf, scope->bpf); gst_video_frame_copy (&outframe, &scope->tempframe);
} else { } else {
memset (map.data, 0, scope->bpf); /* gst_video_frame_clear() or is output frame already cleared */
memset (outframe.data, 0, scope->vinfo.size);
} }
#endif
gst_buffer_replace_all_memory (inbuf, gst_buffer_replace_all_memory (inbuf,
gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, adata, sbpf, 0, gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, adata, sbpf, 0,
@ -971,13 +975,10 @@ gst_audio_visualizer_chain (GstPad * pad, GstObject * parent,
if (!klass->render (scope, inbuf, &outframe)) { if (!klass->render (scope, inbuf, &outframe)) {
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
} else { } else {
#if 0
/* FIXME, dest and source reversed? */
/* run various post processing (shading and geometri transformation */ /* run various post processing (shading and geometri transformation */
if (scope->shader) { if (scope->shader) {
scope->shader (scope, outframe, scope->pixelbuf); scope->shader (scope, &outframe, &scope->tempframe);
} }
#endif
} }
} }
gst_video_frame_unmap (&outframe); gst_video_frame_unmap (&outframe);

View file

@ -77,7 +77,8 @@ struct _GstAudioVisualizer
GstBufferPool *pool; GstBufferPool *pool;
GstAdapter *adapter; GstAdapter *adapter;
GstBuffer *inbuf; GstBuffer *inbuf;
guint8 *pixelbuf; GstBuffer *tempbuf;
GstVideoFrame tempframe;
GstAudioVisualizerShader shader_type; GstAudioVisualizerShader shader_type;
GstAudioVisualizerShaderFunc shader; GstAudioVisualizerShaderFunc shader;