Index: trunk/source/Lib/libmd5/MD5.h
===================================================================
--- trunk/source/Lib/libmd5/MD5.h	(revision 56)
+++ trunk/source/Lib/libmd5/MD5.h	(revision 608)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -37,5 +37,6 @@
 //! \{
 
-class MD5 {
+class MD5
+{
 public:
   /**
@@ -68,19 +69,27 @@
 };
 
+
 /**
- * Produce an ascii(hex) representation of the 128bit digest.
+ * Produce an ascii(hex) representation of picture digest.
  *
  * Returns: a statically allocated null-terminated string.  DO NOT FREE.
  */
 inline const char*
-digestToString(unsigned char digest[16])
+digestToString(const unsigned char digest[3][16], int numChar)
 {
   const char* hex = "0123456789abcdef";
-  static char string[33];
-  for (int i = 0; i < 16; i++)
+  static char string[99];
+  int cnt=0;
+  for(int yuvIdx=0; yuvIdx<3; yuvIdx++)
   {
-    string[i*2+0] = hex[digest[i] >> 4];
-    string[i*2+1] = hex[digest[i] & 0xf];
+    for (int i = 0; i < numChar; i++)
+    {
+      string[cnt++] = hex[digest[yuvIdx][i] >> 4];
+      string[cnt++] = hex[digest[yuvIdx][i] & 0xf];
+    }
+    string[cnt++] = ',';
   }
+
+  string[cnt-1] = '\0';
   return string;
 }
Index: trunk/source/Lib/libmd5/libmd5.c
===================================================================
--- trunk/source/Lib/libmd5/libmd5.c	(revision 56)
+++ trunk/source/Lib/libmd5/libmd5.c	(revision 608)
@@ -26,17 +26,18 @@
 # define byteReverse(buf, len)    /* Nothing */
 #else
-void byteReverse(unsigned char *buf, unsigned longs);
+void byteReverse(uint32_t *buf, unsigned len);
 /*
  * Note: this code is harmless on little-endian machines.
  */
-void byteReverse(unsigned char *buf, unsigned longs)
+void byteReverse(uint32_t *buf, unsigned len)
 {
   uint32_t t;
   do {
-    t = (uint32_t) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
-        ((unsigned) buf[1] << 8 | buf[0]);
-    *(uint32_t *) buf = t;
-    buf += 4;
-  } while (--longs);
+    char* bytes = (char *) buf;
+    t = ((unsigned) bytes[3] << 8 | bytes[2]) << 16 |
+        ((unsigned) bytes[1] << 8 | bytes[0]);
+    *buf = t;
+    buf++;
+  } while (--len);
 }
 #endif
@@ -77,5 +78,5 @@
 
   if (t) {
-    unsigned char *p = (unsigned char *) ctx->in + t;
+    unsigned char *p = ctx->in.b8 + t;
 
     t = 64 - t;
@@ -85,6 +86,6 @@
     }
     memcpy(p, buf, t);
-    byteReverse(ctx->in, 16);
-    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+    byteReverse(ctx->in.b32, 16);
+    MD5Transform(ctx->buf, ctx->in.b32);
     buf += t;
     len -= t;
@@ -93,7 +94,7 @@
 
   while (len >= 64) {
-    memcpy(ctx->in, buf, 64);
-    byteReverse(ctx->in, 16);
-    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+    memcpy(ctx->in.b8, buf, 64);
+    byteReverse(ctx->in.b32, 16);
+    MD5Transform(ctx->buf, ctx->in.b32);
     buf += 64;
     len -= 64;
@@ -102,5 +103,5 @@
     /* Handle any remaining bytes of data. */
 
-  memcpy(ctx->in, buf, len);
+  memcpy(ctx->in.b8, buf, len);
 }
 
@@ -119,5 +120,5 @@
   /* Set the first char of padding to 0x80.  This is safe since there is
      always at least one byte free */
-  p = ctx->in + count;
+  p = ctx->in.b8 + count;
   *p++ = 0x80;
 
@@ -129,21 +130,21 @@
     /* Two lots of padding:  Pad the first block to 64 bytes */
     memset(p, 0, count);
-    byteReverse(ctx->in, 16);
-    MD5Transform(ctx->buf, (uint32_t *) ctx->in);
+    byteReverse(ctx->in.b32, 16);
+    MD5Transform(ctx->buf, ctx->in.b32);
 
     /* Now fill the next block with 56 bytes */
-    memset(ctx->in, 0, 56);
+    memset(ctx->in.b8, 0, 56);
   } else {
     /* Pad block to 56 bytes */
     memset(p, 0, count - 8);
   }
-  byteReverse(ctx->in, 14);
+  byteReverse(ctx->in.b32, 14);
 
   /* Append length in bits and transform */
-  ((uint32_t *) ctx->in)[14] = ctx->bits[0];
-  ((uint32_t *) ctx->in)[15] = ctx->bits[1];
-
-  MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-  byteReverse((unsigned char *) ctx->buf, 4);
+  ctx->in.b32[14] = ctx->bits[0];
+  ctx->in.b32[15] = ctx->bits[1];
+
+  MD5Transform(ctx->buf, ctx->in.b32);
+  byteReverse((uint32_t *) ctx->buf, 4);
   memcpy(digest, ctx->buf, 16);
 
Index: trunk/source/Lib/libmd5/libmd5.h
===================================================================
--- trunk/source/Lib/libmd5/libmd5.h	(revision 56)
+++ trunk/source/Lib/libmd5/libmd5.h	(revision 608)
@@ -4,5 +4,5 @@
  * granted under this license.  
  *
- * Copyright (c) 2010-2012, ITU/ISO/IEC
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
  * All rights reserved.
  *
@@ -40,5 +40,8 @@
   uint32_t buf[4];
   uint32_t bits[2];
-  unsigned char in[64];
+  union {
+    unsigned char b8[64];
+    uint32_t b32[16];
+  } in;
 } context_md5_t;
 
