rtpvraw: use plane pointers when needed
authorWim Taymans <wtaymans@redhat.com>
Mon, 28 Apr 2014 12:41:10 +0000 (14:41 +0200)
committerWim Taymans <wtaymans@redhat.com>
Mon, 28 Apr 2014 12:45:57 +0000 (14:45 +0200)
Pack/unpack planar formats to/from the first plane.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=729058

gst/rtp/gstrtpvrawdepay.c
gst/rtp/gstrtpvrawpay.c

index 7674122..9a28802 100644 (file)
@@ -309,7 +309,7 @@ static GstBuffer *
 gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
 {
   GstRtpVRawDepay *rtpvrawdepay;
-  guint8 *payload, *yp, *up, *vp, *headers;
+  guint8 *payload, *p0, *yp, *up, *vp, *headers;
   guint32 timestamp;
   guint cont, ystride, uvstride, pgroup, payload_len;
   gint width, height, xinc, yinc;
@@ -361,6 +361,7 @@ gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
     goto invalid_frame;
 
   /* get pointer and strides of the planes */
+  p0 = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0);
   yp = GST_VIDEO_FRAME_COMP_DATA (&frame, 0);
   up = GST_VIDEO_FRAME_COMP_DATA (&frame, 1);
   vp = GST_VIDEO_FRAME_COMP_DATA (&frame, 2);
@@ -452,7 +453,7 @@ gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
       case GST_VIDEO_FORMAT_UYVP:
         /* samples are packed just like gstreamer packs them */
         offs /= xinc;
-        datap = yp + (line * ystride) + (offs * pgroup);
+        datap = p0 + (line * ystride) + (offs * pgroup);
 
         memcpy (datap, payload, plen);
         break;
@@ -461,7 +462,7 @@ gst_rtp_vraw_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
         gint i;
         guint8 *p;
 
-        datap = yp + (line * ystride) + (offs * 4);
+        datap = p0 + (line * ystride) + (offs * 4);
         p = payload;
 
         /* samples are packed in order Cb-Y-Cr for both interlaced and
index 5df9c52..ca54bbb 100644 (file)
@@ -240,7 +240,7 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
   GstRtpVRawPay *rtpvrawpay;
   GstFlowReturn ret = GST_FLOW_OK;
   guint line, offset;
-  guint8 *yp, *up, *vp;
+  guint8 *p0, *yp, *up, *vp;
   guint ystride, uvstride;
   guint pgroup;
   guint mtu;
@@ -258,6 +258,7 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
       gst_buffer_get_size (buffer));
 
   /* get pointer and strides of the planes */
+  p0 = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0);
   yp = GST_VIDEO_FRAME_COMP_DATA (&frame, 0);
   up = GST_VIDEO_FRAME_COMP_DATA (&frame, 1);
   vp = GST_VIDEO_FRAME_COMP_DATA (&frame, 2);
@@ -412,7 +413,7 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
           case GST_VIDEO_FORMAT_UYVY:
           case GST_VIDEO_FORMAT_UYVP:
             offs /= rtpvrawpay->xinc;
-            memcpy (outdata, yp + (lin * ystride) + (offs * pgroup), length);
+            memcpy (outdata, p0 + (lin * ystride) + (offs * pgroup), length);
             outdata += length;
             break;
           case GST_VIDEO_FORMAT_AYUV:
@@ -420,7 +421,7 @@ gst_rtp_vraw_pay_handle_buffer (GstRTPBasePayload * payload, GstBuffer * buffer)
             gint i;
             guint8 *datap;
 
-            datap = yp + (lin * ystride) + (offs * 4);
+            datap = p0 + (lin * ystride) + (offs * 4);
 
             for (i = 0; i < pixels; i++) {
               *outdata++ = datap[2];