minor formatting
[flac.git] / src / libFLAC / md5.c
index cfbe862..70fdedb 100644 (file)
 
 #include "private/md5.h"
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #ifndef FLaC__INLINE
 #define FLaC__INLINE
 #endif
@@ -161,9 +165,9 @@ byteSwap(FLAC__uint32 *buf, unsigned words)
 void
 MD5Init(struct MD5Context *ctx)
 {
-    FLAC__uint32 test = 1;
+       FLAC__uint32 test = 1;
 
-    is_big_endian_host_ = (*((FLAC__byte*)(&test)))? false : true;
+       is_big_endian_host_ = (*((FLAC__byte*)(&test)))? false : true;
 
        ctx->buf[0] = 0x67452301;
        ctx->buf[1] = 0xefcdab89;
@@ -229,10 +233,10 @@ FLAC__MD5Accumulate(struct MD5Context *ctx, const FLAC__int32 * const signal[],
        const unsigned bytes_needed = channels * samples * bytes_per_sample;
 
        if(ctx->capacity < bytes_needed) {
-               FLAC__byte *tmp = realloc(ctx->internal_buf, bytes_needed);
+               FLAC__byte *tmp = (FLAC__byte*)realloc(ctx->internal_buf, bytes_needed);
                if(0 == tmp) {
                        free(ctx->internal_buf);
-                       if(0 == (ctx->internal_buf = malloc(bytes_needed)))
+                       if(0 == (ctx->internal_buf = (FLAC__byte*)malloc(bytes_needed)))
                                return false;
                }
                ctx->internal_buf = tmp;
@@ -241,6 +245,19 @@ FLAC__MD5Accumulate(struct MD5Context *ctx, const FLAC__int32 * const signal[],
 
        buf_ = ctx->internal_buf;
 
+#ifdef FLAC__CPU_IA32
+       if(channels == 2 && bytes_per_sample == 2) {
+               memcpy(buf_, signal[0], sizeof(FLAC__int32) * samples);
+               buf_ += sizeof(FLAC__int16);
+               for(sample = 0; sample < samples; sample++)
+                       ((FLAC__int16 *)buf_)[2 * sample] = (FLAC__int16)signal[1][sample];
+       }
+       else if(channels == 1 && bytes_per_sample == 2) {
+               for(sample = 0; sample < samples; sample++)
+                       ((FLAC__int16 *)buf_)[sample] = (FLAC__int16)signal[0][sample];
+       }
+       else
+#endif
        for(sample = 0; sample < samples; sample++) {
                for(channel = 0; channel < channels; channel++) {
                        a_word = signal[channel][sample];