Added TI patches, generated from commit 04f9d72 of the following tree:
[ubuntu-omap:gst-plugins-bad1-0.git] / debian / patches / 0025-25-30-dri2videosink-fix-cropping-with-software-decod.patch
1 From 9813c77f9a8862efa363f66211e188d67720b518 Mon Sep 17 00:00:00 2001
2 From: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk>
3 Date: Wed, 3 Oct 2012 14:02:18 +0100
4 Subject: [PATCH 025/100] [25/30] dri2videosink: fix cropping with software
5  decoders
6
7 Normal elements send a crop event, but ducati has another
8 per-buffer system to attach a crop rectangle. When a buffer
9 has no crop rectangle, but we received a crop event, use
10 the crop event data instead.
11
12 This fixes borders being wrongly displayed with software
13 decoders.
14 ---
15  sys/dri2/gstdri2videosink.c |   56 +++++++++++++++++++++++++++++++++++++++++++
16  sys/dri2/gstdri2videosink.h |    2 ++
17  2 files changed, 58 insertions(+)
18
19 diff --git a/sys/dri2/gstdri2videosink.c b/sys/dri2/gstdri2videosink.c
20 index 8996ba8..5326b29 100644
21 --- a/sys/dri2/gstdri2videosink.c
22 +++ b/sys/dri2/gstdri2videosink.c
23 @@ -642,6 +642,14 @@ gst_dri2videosink_show_frame (GstBaseSink * bsink, GstBuffer * buf)
24    if (newbuf)
25      buf = newbuf;
26  
27 +  /* If there is no crop attached to this buffer, but we received a crop
28 +     event previously, attach our crop event. This will ensure that software
29 +     decoders that do not know about the crop API will still properly work
30 +     with dri2videosink's use of crop. Test crop_rect first as it's faster. */
31 +  if (self->crop_rect && !gst_buffer_get_video_crop (buf)) {
32 +    gst_buffer_set_video_crop (buf, self->crop_rect);
33 +  }
34 +
35    ret = gst_dri2window_buffer_show (xwindow, buf);
36  
37    if (ret == GST_FLOW_OK) {
38 @@ -956,6 +964,48 @@ gst_dri2videosink_get_property (GObject * object, guint prop_id,
39    }
40  }
41  
42 +static gboolean
43 +gst_dri2videosink_event (GstBaseSink * bsink, GstEvent * event)
44 +{
45 +  gboolean res;
46 +  GstDRI2VideoSink *dri2videosink = GST_DRI2VIDEOSINK (bsink);
47 +  GstStructure *structure;
48 +  GstMessage *message;
49 +
50 +  switch (GST_EVENT_TYPE (event)) {
51 +    case GST_EVENT_CROP:
52 +    {
53 +      gint left, top, width, height;
54 +
55 +      gst_event_parse_crop (event, &top, &left, &width, &height);
56 +      GST_DEBUG_OBJECT (bsink, "Got crop event: %d %d %d %d", top, left, width,
57 +          height);
58 +      if (width < 0) {
59 +        width = GST_VIDEO_SINK_WIDTH (dri2videosink) - left;
60 +      }
61 +      if (height < 0) {
62 +        height = GST_VIDEO_SINK_HEIGHT (dri2videosink) - top;
63 +      }
64 +
65 +      if (dri2videosink->crop_rect)
66 +        gst_video_crop_unref (dri2videosink->crop_rect);
67 +      dri2videosink->crop_rect = gst_video_crop_new (top, left, width, height);
68 +
69 +      structure = gst_structure_new ("video-size-crop", "width", G_TYPE_INT,
70 +          width, "height", G_TYPE_INT, height, NULL);
71 +      message = gst_message_new_application (GST_OBJECT (dri2videosink),
72 +          structure);
73 +      gst_bus_post (gst_element_get_bus (GST_ELEMENT (dri2videosink)), message);
74 +
75 +      break;
76 +    }
77 +    default:
78 +      res = TRUE;
79 +  }
80 +
81 +  return res;
82 +}
83 +
84  static void
85  gst_dri2videosink_reset (GstDRI2VideoSink * self)
86  {
87 @@ -978,6 +1028,11 @@ gst_dri2videosink_reset (GstDRI2VideoSink * self)
88    self->render_rect.w = self->render_rect.h = 0;
89    self->have_render_rect = FALSE;
90  
91 +  if (self->crop_rect) {
92 +    gst_video_crop_unref (self->crop_rect);
93 +    self->crop_rect = NULL;
94 +  }
95 +
96    if (self->xwindow) {
97      gst_dri2window_delete (self->xwindow);
98      self->xwindow = NULL;
99 @@ -1074,6 +1129,7 @@ gst_dri2videosink_class_init (GstDRI2VideoSinkClass * klass)
100    gstbasesink_class->get_times = GST_DEBUG_FUNCPTR (gst_dri2videosink_get_times);
101  
102    gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_dri2videosink_show_frame);
103 +  gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_dri2videosink_event);
104  }
105  
106  GType
107 diff --git a/sys/dri2/gstdri2videosink.h b/sys/dri2/gstdri2videosink.h
108 index c2cd061..4cb364a 100644
109 --- a/sys/dri2/gstdri2videosink.h
110 +++ b/sys/dri2/gstdri2videosink.h
111 @@ -26,6 +26,7 @@
112  #ifndef __GST_DRI2VIDEOSINK_H__
113  #define __GST_DRI2VIDEOSINK_H__
114  
115 +#include <gst/video/video-crop.h>
116  #include <gst/video/gstvideosink.h>
117  
118  #include "gstdri2util.h"
119 @@ -71,6 +72,7 @@ struct _GstDRI2VideoSink
120  
121    GstVideoRectangle render_rect;
122    gboolean have_render_rect;
123 +  GstVideoCrop *crop_rect;
124  
125    GValue *display_par;
126    gint video_par_n;
127 -- 
128 1.7.9.5
129