summaryrefslogtreecommitdiff
path: root/gst/dvbsuboverlay
diff options
context:
space:
mode:
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2012-07-13 12:32:51 +0200
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2012-07-13 12:32:51 +0200
commit8712729a8c3dd3f048473325fe16a65641ca041a (patch)
tree602c986288887b969bb3586a8d7c549a2e85c605 /gst/dvbsuboverlay
parent2d0866ec285b5df72c40f9921011adaddb175552 (diff)
dvbsuboverlay: adaptively blend or attach video overlay composition
Conflicts: gst/dvbsuboverlay/gstdvbsuboverlay.c
Diffstat (limited to 'gst/dvbsuboverlay')
-rw-r--r--gst/dvbsuboverlay/gstdvbsuboverlay.c58
-rw-r--r--gst/dvbsuboverlay/gstdvbsuboverlay.h2
2 files changed, 56 insertions, 4 deletions
diff --git a/gst/dvbsuboverlay/gstdvbsuboverlay.c b/gst/dvbsuboverlay/gstdvbsuboverlay.c
index 1b3fadd66..546ce7191 100644
--- a/gst/dvbsuboverlay/gstdvbsuboverlay.c
+++ b/gst/dvbsuboverlay/gstdvbsuboverlay.c
@@ -456,6 +456,48 @@ gst_dvbsub_overlay_getcaps (GstPad * pad, GstCaps * filter)
return caps;
}
+/* only negotiate/query video overlay composition support for now */
+static gboolean
+gst_dvbsub_overlay_negotiate (GstDVBSubOverlay * overlay)
+{
+ GstCaps *target;
+ GstQuery *query;
+ gboolean attach = FALSE;
+
+ GST_DEBUG_OBJECT (overlay, "performing negotiation");
+
+ target = gst_pad_get_current_caps (overlay->srcpad);
+
+ if (!target || gst_caps_is_empty (target))
+ goto no_format;
+
+ /* find supported meta */
+ query = gst_query_new_allocation (target, TRUE);
+
+ if (!gst_pad_peer_query (overlay->srcpad, query)) {
+ /* no problem, we use the query defaults */
+ GST_DEBUG_OBJECT (overlay, "ALLOCATION query failed");
+ }
+
+ if (gst_query_find_allocation_meta (query,
+ GST_VIDEO_OVERLAY_COMPOSITION_META_API_TYPE, NULL))
+ attach = TRUE;
+
+ overlay->attach_compo_to_buffer = attach;
+
+ gst_query_unref (query);
+ gst_caps_unref (target);
+
+ return TRUE;
+
+no_format:
+ {
+ if (target)
+ gst_caps_unref (target);
+ return FALSE;
+ }
+}
+
static gboolean
gst_dvbsub_overlay_setcaps_video (GstPad * pad, GstCaps * caps)
{
@@ -472,6 +514,8 @@ gst_dvbsub_overlay_setcaps_video (GstPad * pad, GstCaps * caps)
if (!ret)
goto out;
+ gst_dvbsub_overlay_negotiate (render);
+
GST_DEBUG_OBJECT (render, "ass renderer setup complete");
out:
@@ -859,11 +903,17 @@ gst_dvbsub_overlay_chain_video (GstPad * pad, GstObject * parent,
GstVideoFrame frame;
buffer = gst_buffer_make_writable (buffer);
- gst_video_frame_map (&frame, &overlay->info, buffer, GST_MAP_WRITE);
g_assert (overlay->current_comp);
- buffer = gst_buffer_make_writable (buffer);
- gst_video_overlay_composition_blend (overlay->current_comp, &frame);
- gst_video_frame_unmap (&frame);
+ if (overlay->attach_compo_to_buffer) {
+ GST_DEBUG_OBJECT (overlay, "Attaching overlay image to video buffer");
+ gst_buffer_add_video_overlay_composition_meta (buffer,
+ overlay->current_comp);
+ } else {
+ GST_DEBUG_OBJECT (overlay, "Blending overlay image to video buffer");
+ gst_video_frame_map (&frame, &overlay->info, buffer, GST_MAP_WRITE);
+ gst_video_overlay_composition_blend (overlay->current_comp, &frame);
+ gst_video_frame_unmap (&frame);
+ }
}
g_mutex_unlock (&overlay->dvbsub_mutex);
diff --git a/gst/dvbsuboverlay/gstdvbsuboverlay.h b/gst/dvbsuboverlay/gstdvbsuboverlay.h
index af7a2eb68..4cf324273 100644
--- a/gst/dvbsuboverlay/gstdvbsuboverlay.h
+++ b/gst/dvbsuboverlay/gstdvbsuboverlay.h
@@ -66,6 +66,8 @@ struct _GstDVBSubOverlay
gboolean pending_sub;
/* last text pts */
GstClockTime last_text_pts;
+
+ gboolean attach_compo_to_buffer;
};
struct _GstDVBSubOverlayClass