diff options
author | Arnaud Vrac <avrac@freebox.fr> | 2013-09-02 17:48:50 +0200 |
---|---|---|
committer | Jan Schmidt <jan@centricular.com> | 2015-09-26 23:22:44 +1000 |
commit | aabb8a1a68372f750c63b9b6586e18e829745774 (patch) | |
tree | e96145c5506f9b3f70d2aa6593f79947e2190e73 /gst/dvdspu | |
parent | 46aaaa6c309b8a8f6e218142fd5944f5d24f095c (diff) |
dvdspu: cache overlay composition
This avoids rendering the overlay buffer for each video frame.
https://bugzilla.gnome.org/show_bug.cgi?id=663750
Diffstat (limited to 'gst/dvdspu')
-rw-r--r-- | gst/dvdspu/gstdvdspu.c | 35 | ||||
-rw-r--r-- | gst/dvdspu/gstdvdspu.h | 1 |
2 files changed, 28 insertions, 8 deletions
diff --git a/gst/dvdspu/gstdvdspu.c b/gst/dvdspu/gstdvdspu.c index 2bf5a91fe..cf0a63b93 100644 --- a/gst/dvdspu/gstdvdspu.c +++ b/gst/dvdspu/gstdvdspu.c @@ -180,6 +180,15 @@ gst_dvd_spu_init (GstDVDSpu * 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 gst_dvd_spu_clear (GstDVDSpu * dvdspu) { gst_dvd_spu_flush_spu_info (dvdspu, FALSE); @@ -269,6 +278,8 @@ gst_dvd_spu_flush_spu_info (GstDVDSpu * dvdspu, gboolean keep_events) default: break; } + + gst_dvd_spu_reset_composition (dvdspu); } static gboolean @@ -799,26 +810,27 @@ gstspu_render (GstDVDSpu * dvdspu, GstBuffer * buf) GstVideoOverlayComposition *composition; GstVideoFrame frame; - composition = gstspu_render_composition (dvdspu); - if (!composition) - return; + if (!dvdspu->composition) { + dvdspu->composition = gstspu_render_composition (dvdspu); + if (!dvdspu->composition) + return; + } + + composition = dvdspu->composition; if (dvdspu->attach_compo_to_buffer) { gst_buffer_add_video_overlay_composition_meta (buf, composition); - goto done; + return; } if (!gst_video_frame_map (&frame, &dvdspu->spu_state.info, buf, GST_MAP_READWRITE)) { GST_WARNING_OBJECT (dvdspu, "failed to map video frame for blending"); - goto done; + return; } gst_video_overlay_composition_blend (composition, &frame); gst_video_frame_unmap (&frame); - -done: - gst_video_overlay_composition_unref (composition); } /* With SPU LOCK */ @@ -887,6 +899,9 @@ gst_dvd_spu_handle_dvd_event (GstDVDSpu * dvdspu, GstEvent * event) break; } + if (hl_change) + gst_dvd_spu_reset_composition (dvdspu); + if (hl_change && (dvdspu->spu_state.flags & SPU_STATE_STILL_FRAME)) { gst_dvd_spu_redraw_still (dvdspu, FALSE); } @@ -940,6 +955,8 @@ gst_dvd_spu_advance_spu (GstDVDSpu * dvdspu, GstClockTime new_ts) GST_TIME_ARGS (dvdspu->video_seg.position), packet->buf ? "buffer" : "event"); + gst_dvd_spu_reset_composition (dvdspu); + if (packet->buf) { switch (dvdspu->spu_input_type) { case SPU_INPUT_TYPE_VOBSUB: @@ -1051,6 +1068,8 @@ gst_dvd_spu_negotiate (GstDVDSpu * dvdspu) GstCaps *caps; gboolean attach = FALSE; + gst_dvd_spu_reset_composition (dvdspu); + GST_DEBUG_OBJECT (dvdspu, "performing negotiation"); caps = gst_pad_get_current_caps (dvdspu->srcpad); diff --git a/gst/dvdspu/gstdvdspu.h b/gst/dvdspu/gstdvdspu.h index 051208243..6fa700cb3 100644 --- a/gst/dvdspu/gstdvdspu.h +++ b/gst/dvdspu/gstdvdspu.h @@ -115,6 +115,7 @@ struct _GstDVDSpu { /* Overlay composition */ gboolean attach_compo_to_buffer; + GstVideoOverlayComposition *composition; }; struct _GstDVDSpuClass { |