changeset f66948658a36 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=f66948658a36
description:
        vnc: Add a conversion function for bgr888.

diffstat:

 src/base/vnc/convert.cc |  31 +++++++++++++++++++++++++++++--
 src/base/vnc/convert.hh |   7 +++++++
 2 files changed, 36 insertions(+), 2 deletions(-)

diffs (72 lines):

diff -r 049273bc03f6 -r f66948658a36 src/base/vnc/convert.cc
--- a/src/base/vnc/convert.cc   Mon Nov 17 01:00:53 2014 -0800
+++ b/src/base/vnc/convert.cc   Mon Nov 17 01:45:42 2014 -0800
@@ -52,8 +52,10 @@
     : inputMode(input_mode), outputMode(output_mode), width(_width),
     height(_height)
 {
-    if (inputMode != bgr565 && inputMode != rgb565 && inputMode != bgr8888)
-        fatal("Only support converting from bgr565, rdb565, and bgr8888\n");
+    if (inputMode != bgr565 && inputMode != rgb565 &&
+        inputMode != bgr8888 && inputMode != bgr888)
+        fatal("Only support converting from bgr565, rdb565, "
+              "bgr8888 and bgr888\n");
 
     if (outputMode != rgb8888)
         fatal("Only support converting to rgb8888\n");
@@ -76,6 +78,8 @@
         return m565rgb8888(fb, false);
       case bgr8888:
         return bgr8888rgb8888(fb);
+      case bgr888:
+        return bgr888rgb8888(fb);
       default:
         panic("Unimplemented Mode\n");
     }
@@ -136,6 +140,29 @@
 
     return out;
 }
+
+uint8_t*
+VideoConvert::bgr888rgb8888(const uint8_t *fb) const
+{
+    uint8_t *out = new uint8_t[area() * sizeof(uint32_t)];
+    uint32_t *out32 = (uint32_t*)out;
+
+    typedef uint8_t In24[3];
+    const In24 *in24 = (In24 *)fb;
+    for (int x = 0; x < area(); x++) {
+        Rgb8888 outpx = 0;
+
+        outpx.blue = in24[x][0];
+        outpx.green = in24[x][1];
+        outpx.red = in24[x][2];
+        outpx.alpha = 0xFF;
+
+        out32[x] = outpx;
+    }
+
+    return out;
+}
+
 /*
 uint64_t
 VideoConvert::getHash(const uint8_t *fb) const
diff -r 049273bc03f6 -r f66948658a36 src/base/vnc/convert.hh
--- a/src/base/vnc/convert.hh   Mon Nov 17 01:00:53 2014 -0800
+++ b/src/base/vnc/convert.hh   Mon Nov 17 01:45:42 2014 -0800
@@ -134,6 +134,13 @@
     uint8_t* bgr8888rgb8888(const uint8_t *fb) const;
 
     /**
+     * Convert a bgr888 input to rgb8888.
+     * @param fb the data to convert
+     * @return converted data
+     */
+    uint8_t* bgr888rgb8888(const uint8_t *fb) const;
+
+    /**
      * Convert a bgr565 or rgb565 input to rgb8888.
      * @param fb the data to convert
      * @param bgr true if the input data is bgr565
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to