Fix RGBA and ABGR pack/unpack on big endian cpu
authorWim Taymans <wtaymans@redhat.com>
Thu, 1 Jun 2017 15:45:41 +0000 (17:45 +0200)
committerWim Taymans <wtaymans@redhat.com>
Thu, 1 Jun 2017 15:45:41 +0000 (17:45 +0200)
The pack and unpack functions for RGBA and ABGR only work for little
endian cpus. Add variants for big endian as well.

gst-libs/gst/video/video-format.c
gst-libs/gst/video/video-orc.orc

index 6117e7e..58176df 100644 (file)
@@ -1328,7 +1328,11 @@ unpack_ABGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
 
   s += x * 4;
 
-  video_orc_unpack_ABGR (dest, s, width);
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+  video_orc_unpack_ABGR_le (dest, s, width);
+#else
+  video_orc_unpack_ABGR_be (dest, s, width);
+#endif
 }
 
 static void
@@ -1339,7 +1343,11 @@ pack_ABGR (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
 {
   guint8 *restrict d = GET_LINE (y);
 
-  video_orc_pack_ABGR (d, src, width);
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+  video_orc_pack_ABGR_le (d, src, width);
+#else
+  video_orc_pack_ABGR_be (d, src, width);
+#endif
 }
 
 #define PACK_RGBA GST_VIDEO_FORMAT_ARGB, unpack_RGBA, 1, pack_RGBA
@@ -1352,7 +1360,11 @@ unpack_RGBA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
 
   s += x * 4;
 
-  video_orc_unpack_RGBA (dest, s, width);
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+  video_orc_unpack_RGBA_le (dest, s, width);
+#else
+  video_orc_unpack_RGBA_be (dest, s, width);
+#endif
 }
 
 static void
@@ -1363,7 +1375,11 @@ pack_RGBA (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
 {
   guint8 *restrict d = GET_LINE (y);
 
-  video_orc_pack_RGBA (d, src, width);
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+  video_orc_pack_RGBA_le (d, src, width);
+#else
+  video_orc_pack_RGBA_be (d, src, width);
+#endif
 }
 
 #define PACK_RGB GST_VIDEO_FORMAT_ARGB, unpack_RGB, 1, pack_RGB
index 3399c81..f855fd7 100644 (file)
@@ -333,7 +333,7 @@ swapl argb, bgra
 
 swapl bgra, argb
 
-.function video_orc_pack_RGBA
+.function video_orc_pack_RGBA_le
 .dest 4 rgba guint8
 .source 4 argb guint8
 .temp 4 a
@@ -344,7 +344,7 @@ shrul a, r, 8
 shll r, r, 24
 orl rgba, r, a
 
-.function video_orc_unpack_RGBA
+.function video_orc_unpack_RGBA_le
 .dest 4 argb guint8
 .source 4 rgba guint8
 .temp 4 a
@@ -355,7 +355,30 @@ shll a, r, 8
 shrul r, r, 24
 orl argb, r, a
 
-.function video_orc_unpack_ABGR
+.function video_orc_pack_RGBA_be
+.dest 4 rgba guint8
+.source 4 argb guint8
+.temp 4 a
+.temp 4 r
+
+loadl r, argb
+shrul a, r, 24
+shll r, r, 8
+orl rgba, r, a
+
+.function video_orc_unpack_RGBA_be
+.dest 4 argb guint8
+.source 4 rgba guint8
+.temp 4 a
+.temp 4 r
+
+loadl r, rgba
+shll a, r, 24
+shrul r, r, 8
+orl argb, r, a
+
+
+.function video_orc_unpack_ABGR_le
 .dest 4 argb guint8
 .source 4 abgr guint8
 .temp 4 a
@@ -366,7 +389,7 @@ shll a, r, 8
 shrul r, r, 24
 orl argb, r, a
 
-.function video_orc_pack_ABGR
+.function video_orc_pack_ABGR_le
 .dest 4 abgr guint8
 .source 4 argb guint8
 .temp 4 a
@@ -377,6 +400,29 @@ shll a, r, 8
 shrul r, r, 24
 orl abgr, r, a
 
+.function video_orc_unpack_ABGR_be
+.dest 4 argb guint8
+.source 4 abgr guint8
+.temp 4 a
+.temp 4 r
+
+swapl r, abgr
+shll a, r, 24
+shrul r, r, 8
+orl argb, r, a
+
+.function video_orc_pack_ABGR_be
+.dest 4 abgr guint8
+.source 4 argb guint8
+.temp 4 a
+.temp 4 r
+
+swapl r, argb
+shll a, r, 24
+shrul r, r, 8
+orl abgr, r, a
+
+
 .function video_orc_unpack_NV12
 .dest 8 d guint8
 .source 2 y guint8