[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-cvs
Subject:    [gst-cvs] gst-plugins-bad: dvdspu: Fix rendering and add guards
From:       thaytan () kemper ! freedesktop ! org (Jan Schmidt)
Date:       2009-09-28 10:17:59
Message-ID: 20090928101759.22D7310053 () kemper ! freedesktop ! org
[Download RAW message or body]

Module: gst-plugins-bad
Branch: master
Commit: f248986ba4f2f979dc289e2a3593d010f5333397
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=f248986ba4f2f979dc289e2a3593d010f5333397


Author: Jan Schmidt <thaytan@noraisin.net>
Date:   Tue Sep 22 01:16:47 2009 +0100

dvdspu: Fix rendering and add guards

Fix the rendering when we hit the right hand side of the display
area, by resetting to the correct X coordinate, and add some more
guards against bad PGS data.

---

 gst/dvdspu/gstspu-pgs.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/gst/dvdspu/gstspu-pgs.c b/gst/dvdspu/gstspu-pgs.c
index 37d8023..fc5a0bb 100644
--- a/gst/dvdspu/gstspu-pgs.c
+++ b/gst/dvdspu/gstspu-pgs.c
@@ -176,7 +176,7 @@ pgs_composition_object_render (PgsCompositionObject * obj, \
SpuState * state,  guint8 *planes[3];            /* YUV frame pointers */
   guint8 *data, *end;
   guint16 obj_w, obj_h;
-  guint x, y, i, max_x;
+  guint x, y, i, min_x, max_x;
 
   if (G_UNLIKELY (obj->rle_data == NULL || obj->rle_data_size == 0
           || obj->rle_data_used != obj->rle_data_size))
@@ -201,8 +201,7 @@ pgs_composition_object_render (PgsCompositionObject * obj, \
SpuState * state,  g_return_if_fail (planes[2] + (state->UV_height * \
state->UV_stride) <=  GST_BUFFER_DATA (dest_buf) + GST_BUFFER_SIZE (dest_buf));
 
-  x = obj->x;
-  y = obj->y;
+  y = MIN (obj->y, state->Y_height);
 
   planes[0] += state->Y_stride * y;
   planes[1] += state->UV_stride * (y / 2);
@@ -213,9 +212,10 @@ pgs_composition_object_render (PgsCompositionObject * obj, \
SpuState * state,  obj_h = GST_READ_UINT16_BE (data + 2);
   data += 4;
 
-  max_x = x + obj_w;
+  min_x = MIN (obj->x, state->Y_stride);
+  max_x = MIN (obj->x + obj_w, state->Y_stride);
 
-  state->comp_left = x;
+  state->comp_left = x = min_x;
   state->comp_right = max_x;
 
   gstspu_clear_comp_buffers (state);
@@ -264,6 +264,8 @@ pgs_composition_object_render (PgsCompositionObject * obj, \
SpuState * state,  colour = &state->pgs.palette[pal_id];
     if (colour->A) {
       guint32 inv_A = 0xff - colour->A;
+      if (G_UNLIKELY (x + run_len > max_x))
+        run_len = (max_x - x);
 
       for (i = 0; i < run_len; i++) {
         planes[0][x] = (inv_A * planes[0][x] + colour->Y) / 0xff;
@@ -278,7 +280,7 @@ pgs_composition_object_render (PgsCompositionObject * obj, \
SpuState * state,  }
 
     if (!run_len || x > max_x) {
-      x = state->pgs.win_x;
+      x = min_x;
       planes[0] += state->Y_stride;
 
       if (y % 2) {
@@ -289,6 +291,8 @@ pgs_composition_object_render (PgsCompositionObject * obj, \
SpuState * state,  planes[2] += state->UV_stride;
       }
       y++;
+      if (y >= state->Y_height)
+        return;                 /* Hit the bottom */
     }
   }
 


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
gstreamer-cvs mailing list
gstreamer-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic