From 766461e8927820d7f81e3c31967a043503e59d5a Mon Sep 17 00:00:00 2001
From: Martin Vignali <martin.vignali@gmail.com>
Date: Thu, 14 Mar 2019 21:23:34 +0100
Subject: [PATCH 2/2] avcodec/qtrle : use the previous way to decode rle and
 raw for 24bpp on sparc64

---
 libavcodec/qtrle.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c
index aca7ec2f40..257e6ec86f 100644
--- a/libavcodec/qtrle.c
+++ b/libavcodec/qtrle.c
@@ -297,11 +297,16 @@ static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change
 
 static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change)
 {
-    int rle_code, rle_code_half;
+    int rle_code;
+#if !ARCH_SPARC64
+    int rle_code_half;
+    uint16_t rg;
+#else
+    uint8_t r, g;
+#endif
     int pixel_ptr;
     int row_inc = s->frame->linesize[0];
     uint8_t b;
-    uint16_t rg;
     uint8_t *rgb = s->frame->data[0];
     int pixel_limit = s->frame->linesize[0] * s->avctx->height;
 
@@ -319,19 +324,35 @@ static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change
             } else if (rle_code < 0) {
                 /* decode the run length code */
                 rle_code = -rle_code;
+#if ARCH_SPARC64
+                r = bytestream2_get_byte(&s->g);
+                g = bytestream2_get_byte(&s->g);
+#else
                 rg = bytestream2_get_ne16(&s->g);
+#endif
                 b = bytestream2_get_byte(&s->g);
 
                 CHECK_PIXEL_PTR(rle_code * 3);
 
                 while (rle_code--) {
+#if ARCH_SPARC64
+                    rgb[pixel_ptr    ] = r;
+                    rgb[pixel_ptr + 1] = g;
+#else
                     AV_WN16A(rgb + pixel_ptr, rg);
+#endif
                     rgb[pixel_ptr + 2] = b;
                     pixel_ptr += 3;
                 }
             } else {
                 CHECK_PIXEL_PTR(rle_code * 3);
-
+#if ARCH_SPARC64
+                while (rle_code--) {
+                    rgb[pixel_ptr++] = bytestream2_get_byte(&s->g);
+                    rgb[pixel_ptr++] = bytestream2_get_byte(&s->g);
+                    rgb[pixel_ptr++] = bytestream2_get_byte(&s->g);
+                }
+#else
                 rle_code_half = rle_code / 2;
 
                 while (rle_code_half--) { /* copy 2 raw rgb value at the same time */
@@ -345,6 +366,7 @@ static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change
                     rgb[pixel_ptr + 2] = bytestream2_get_byte(&s->g);
                     pixel_ptr += 3;
                 }
+#endif
             }
         }
         row_ptr += row_inc;
-- 
2.17.2 (Apple Git-113)

