fixes from 64-bit compile
authorJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 17 Nov 2006 06:52:19 +0000 (06:52 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 17 Nov 2006 06:52:19 +0000 (06:52 +0000)
src/libFLAC/lpc.c
src/libFLAC/memory.c

index ab73d0b..174c3e0 100644 (file)
@@ -257,7 +257,7 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients(const FLAC__int32 *data, u
                                fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%I64d\n",i,j,qlp_coeff[j],*history,sumo);
 #else
                        if(sumo > 2147483647ll || sumo < -2147483648ll)
-                               fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,sumo);
+                               fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,(long long)sumo);
 #endif
 #endif
                }
@@ -295,11 +295,11 @@ void FLAC__lpc_compute_residual_from_qlp_coefficients_wide(const FLAC__int32 *da
                        sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
 #ifdef FLAC__OVERFLOW_DETECT
                if(FLAC__bitmath_silog2_wide(sum >> lp_quantization) > 32) {
-                       fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, sum=%lld\n", i, sum >> lp_quantization);
+                       fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, sum=%lld\n", i, (long long)(sum >> lp_quantization));
                        break;
                }
                if(FLAC__bitmath_silog2_wide((FLAC__int64)(*data) - (sum >> lp_quantization)) > 32) {
-                       fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%lld, residual=%lld\n", i, *data, sum >> lp_quantization, (FLAC__int64)(*data) - (sum >> lp_quantization));
+                       fprintf(stderr,"FLAC__lpc_compute_residual_from_qlp_coefficients_wide: OVERFLOW, i=%u, data=%d, sum=%lld, residual=%lld\n", i, *data, (long long)(sum >> lp_quantization), (long long)((FLAC__int64)(*data) - (sum >> lp_quantization)));
                        break;
                }
 #endif
@@ -341,7 +341,7 @@ void FLAC__lpc_restore_signal(const FLAC__int32 residual[], unsigned data_len, c
                                fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%I64d\n",i,j,qlp_coeff[j],*history,sumo);
 #else
                        if(sumo > 2147483647ll || sumo < -2147483648ll)
-                               fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,sumo);
+                               fprintf(stderr,"FLAC__lpc_restore_signal: OVERFLOW, i=%u, j=%u, c=%d, d=%d, sumo=%lld\n",i,j,qlp_coeff[j],*history,(long long)sumo);
 #endif
 #endif
                }
@@ -379,11 +379,11 @@ void FLAC__lpc_restore_signal_wide(const FLAC__int32 residual[], unsigned data_l
                        sum += (FLAC__int64)qlp_coeff[j] * (FLAC__int64)(*(--history));
 #ifdef FLAC__OVERFLOW_DETECT
                if(FLAC__bitmath_silog2_wide(sum >> lp_quantization) > 32) {
-                       fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, sum=%lld\n", i, sum >> lp_quantization);
+                       fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, sum=%lld\n", i, (long long)(sum >> lp_quantization));
                        break;
                }
                if(FLAC__bitmath_silog2_wide((FLAC__int64)(*residual) + (sum >> lp_quantization)) > 32) {
-                       fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%lld, data=%lld\n", i, *residual, sum >> lp_quantization, (FLAC__int64)(*residual) + (sum >> lp_quantization));
+                       fprintf(stderr,"FLAC__lpc_restore_signal_wide: OVERFLOW, i=%u, residual=%d, sum=%lld, data=%lld\n", i, *residual, (long long)(sum >> lp_quantization), (long long)((FLAC__int64)(*residual) + (sum >> lp_quantization)));
                        break;
                }
 #endif
index 956cb29..dbed76b 100644 (file)
@@ -45,7 +45,13 @@ void *FLAC__memory_alloc_aligned(size_t bytes, void **aligned_address)
 #ifdef FLAC__ALIGN_MALLOC_DATA
        /* align on 32-byte (256-bit) boundary */
        x = malloc(bytes+31);
-       *aligned_address = (void*)(((unsigned)x + 31) & -32);
+       /* there's got to be a better way to do this right for all archs */
+       if(sizeof(void*) == sizeof(unsigned))
+               *aligned_address = (void*)(((unsigned)x + 31) & -32);
+       else if(sizeof(void*) == sizeof(FLAC__uint64))
+               *aligned_address = (void*)(((FLAC__uint64)x + 31) & (FLAC__uint64)(-((FLAC__int64)32)));
+       else
+               return 0;
 #else
        x = malloc(bytes);
        *aligned_address = x;