mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
dvdspu: cache overlay composition
This avoids rendering the overlay buffer for each video frame. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5827>
This commit is contained in:
parent
5919bfec5e
commit
559c4b8429
2 changed files with 29 additions and 8 deletions
|
@ -189,6 +189,15 @@ gst_dvd_spu_init (GstDVDSpu * dvdspu)
|
||||||
gst_dvd_spu_clear (dvdspu);
|
gst_dvd_spu_clear (dvdspu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_dvd_spu_reset_composition (GstDVDSpu * dvdspu)
|
||||||
|
{
|
||||||
|
if (dvdspu->composition) {
|
||||||
|
gst_video_overlay_composition_unref (dvdspu->composition);
|
||||||
|
dvdspu->composition = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_dvd_spu_clear (GstDVDSpu * dvdspu)
|
gst_dvd_spu_clear (GstDVDSpu * dvdspu)
|
||||||
{
|
{
|
||||||
|
@ -279,6 +288,8 @@ gst_dvd_spu_flush_spu_info (GstDVDSpu * dvdspu, gboolean keep_events)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_dvd_spu_reset_composition (dvdspu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -1029,26 +1040,27 @@ gstspu_render (GstDVDSpu * dvdspu, GstBuffer * buf)
|
||||||
GstVideoOverlayComposition *composition;
|
GstVideoOverlayComposition *composition;
|
||||||
GstVideoFrame frame;
|
GstVideoFrame frame;
|
||||||
|
|
||||||
composition = gstspu_render_composition (dvdspu);
|
if (!dvdspu->composition) {
|
||||||
if (!composition)
|
dvdspu->composition = gstspu_render_composition (dvdspu);
|
||||||
return;
|
if (!dvdspu->composition)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
composition = dvdspu->composition;
|
||||||
|
|
||||||
if (dvdspu->attach_compo_to_buffer) {
|
if (dvdspu->attach_compo_to_buffer) {
|
||||||
gst_buffer_add_video_overlay_composition_meta (buf, composition);
|
gst_buffer_add_video_overlay_composition_meta (buf, composition);
|
||||||
goto done;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_video_frame_map (&frame, &dvdspu->spu_state.info, buf,
|
if (!gst_video_frame_map (&frame, &dvdspu->spu_state.info, buf,
|
||||||
GST_MAP_READWRITE)) {
|
GST_MAP_READWRITE)) {
|
||||||
GST_WARNING_OBJECT (dvdspu, "failed to map video frame for blending");
|
GST_WARNING_OBJECT (dvdspu, "failed to map video frame for blending");
|
||||||
goto done;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_video_overlay_composition_blend (composition, &frame);
|
gst_video_overlay_composition_blend (composition, &frame);
|
||||||
gst_video_frame_unmap (&frame);
|
gst_video_frame_unmap (&frame);
|
||||||
|
|
||||||
done:
|
|
||||||
gst_video_overlay_composition_unref (composition);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* With SPU LOCK */
|
/* With SPU LOCK */
|
||||||
|
@ -1117,6 +1129,9 @@ gst_dvd_spu_handle_dvd_event (GstDVDSpu * dvdspu, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hl_change)
|
||||||
|
gst_dvd_spu_reset_composition (dvdspu);
|
||||||
|
|
||||||
if (hl_change && (dvdspu->spu_state.flags & SPU_STATE_STILL_FRAME)) {
|
if (hl_change && (dvdspu->spu_state.flags & SPU_STATE_STILL_FRAME)) {
|
||||||
gst_dvd_spu_redraw_still (dvdspu, FALSE);
|
gst_dvd_spu_redraw_still (dvdspu, FALSE);
|
||||||
}
|
}
|
||||||
|
@ -1170,6 +1185,8 @@ gst_dvd_spu_advance_spu (GstDVDSpu * dvdspu, GstClockTime new_ts)
|
||||||
GST_TIME_ARGS (dvdspu->video_seg.position),
|
GST_TIME_ARGS (dvdspu->video_seg.position),
|
||||||
packet->buf ? "buffer" : "event");
|
packet->buf ? "buffer" : "event");
|
||||||
|
|
||||||
|
gst_dvd_spu_reset_composition (dvdspu);
|
||||||
|
|
||||||
if (packet->buf) {
|
if (packet->buf) {
|
||||||
switch (dvdspu->spu_input_type) {
|
switch (dvdspu->spu_input_type) {
|
||||||
case SPU_INPUT_TYPE_VOBSUB:
|
case SPU_INPUT_TYPE_VOBSUB:
|
||||||
|
@ -1288,6 +1305,9 @@ gst_dvd_spu_negotiate (GstDVDSpu * dvdspu, GstCaps * caps)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dvdspu, "performing negotiation");
|
GST_DEBUG_OBJECT (dvdspu, "performing negotiation");
|
||||||
|
|
||||||
|
/* Clear the cached composition */
|
||||||
|
gst_dvd_spu_reset_composition (dvdspu);
|
||||||
|
|
||||||
/* Clear any pending reconfigure to avoid negotiating twice */
|
/* Clear any pending reconfigure to avoid negotiating twice */
|
||||||
gst_pad_check_reconfigure (dvdspu->srcpad);
|
gst_pad_check_reconfigure (dvdspu->srcpad);
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,7 @@ struct _GstDVDSpu {
|
||||||
|
|
||||||
/* Overlay composition */
|
/* Overlay composition */
|
||||||
gboolean attach_compo_to_buffer;
|
gboolean attach_compo_to_buffer;
|
||||||
|
GstVideoOverlayComposition *composition;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstDVDSpuClass {
|
struct _GstDVDSpuClass {
|
||||||
|
|
Loading…
Reference in a new issue