pango: only map video buffer memory if actually needed

No need to map the video buffer if we're just going to attach
the meta; but if we map, we should do so in READWRITE mode.
This commit is contained in:
Tim-Philipp Müller 2012-07-02 18:54:55 +01:00
parent 52056653be
commit 1396f804be

View file

@ -1592,9 +1592,21 @@ gst_base_text_overlay_push_frame (GstBaseTextOverlay * overlay,
gint xpos, ypos; gint xpos, ypos;
GstVideoFrame frame; GstVideoFrame frame;
if (overlay->composition == NULL)
goto done;
video_frame = gst_buffer_make_writable (video_frame); video_frame = gst_buffer_make_writable (video_frame);
if (!gst_video_frame_map (&frame, &overlay->info, video_frame, GST_MAP_WRITE)) if (overlay->attach_compo_to_buffer) {
GST_DEBUG_OBJECT (overlay, "Attaching text overlay image to video buffer");
gst_video_buffer_set_overlay_composition (video_frame,
overlay->composition);
/* FIXME: emulate shaded background box if want_shading=true */
goto done;
}
if (!gst_video_frame_map (&frame, &overlay->info, video_frame,
GST_MAP_READWRITE))
goto invalid_frame; goto invalid_frame;
gst_base_text_overlay_get_pos (overlay, &xpos, &ypos); gst_base_text_overlay_get_pos (overlay, &xpos, &ypos);
@ -1660,18 +1672,12 @@ gst_base_text_overlay_push_frame (GstBaseTextOverlay * overlay,
} }
} }
if (overlay->composition) { gst_video_overlay_composition_blend (overlay->composition, &frame);
if (overlay->attach_compo_to_buffer) {
GST_DEBUG_OBJECT (overlay, "Attaching text to the buffer");
gst_video_buffer_set_overlay_composition (video_frame,
overlay->composition);
} else {
gst_video_overlay_composition_blend (overlay->composition, &frame);
}
}
gst_video_frame_unmap (&frame); gst_video_frame_unmap (&frame);
done:
return gst_pad_push (overlay->srcpad, video_frame); return gst_pad_push (overlay->srcpad, video_frame);
/* ERRORS */ /* ERRORS */