From 103d265cf09e1ea73d5553ab11820aa89d7e2796 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 1 Jun 2017 17:45:41 +0200 Subject: [PATCH] Fix RGBA and ABGR pack/unpack on big endian cpu 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 | 24 +++++++++++--- gst-libs/gst/video/video-orc.orc | 54 ++++++++++++++++++++++++++++--- 2 files changed, 70 insertions(+), 8 deletions(-) diff --git a/gst-libs/gst/video/video-format.c b/gst-libs/gst/video/video-format.c index 6117e7e2f5..58176dfff7 100644 --- a/gst-libs/gst/video/video-format.c +++ b/gst-libs/gst/video/video-format.c @@ -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 diff --git a/gst-libs/gst/video/video-orc.orc b/gst-libs/gst/video/video-orc.orc index 3399c8157a..f855fd7e78 100644 --- a/gst-libs/gst/video/video-orc.orc +++ b/gst-libs/gst/video/video-orc.orc @@ -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