Mercurial > audlegacy
changeset 4233:74c6f3d3cf1d
it buids successfully :)
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Wed, 30 Jan 2008 03:36:22 +0300 |
parents | 704607c1f858 |
children | b293ce14a01a |
files | configure.ac extra.mk.in src/Makefile src/audacious/Makefile src/libSAD/Makefile src/libSAD/dither.c src/libSAD/dither.h src/libSAD/dither_ops.c src/libSAD/dither_ops.h src/libSAD/libSAD.h src/libSAD/noicegen.c src/libSAD/noicegen.h src/libSAD/noisegen.h |
diffstat | 13 files changed, 206 insertions(+), 152 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.ac Wed Jan 30 01:22:37 2008 +0300 +++ b/configure.ac Wed Jan 30 03:36:22 2008 +0300 @@ -282,6 +282,54 @@ [AC_MSG_ERROR([Cannot find libmcs])] ) +dnl AltiVec support + +AC_ARG_ENABLE(altivec, + [ --disable-altivec disable AltiVec support. (default=enabled) ], + [enable_altivec=$enableval], + [enable_altivec=yes] +) +if test "x$enable_altivec" = "xyes"; then + AC_CHECK_HEADERS(altivec.h, + [AC_DEFINE(HAVE_ALTIVEC, 1, [Define to 1 if your system has AltiVec.]) + AC_DEFINE(HAVE_ALTIVEC_H, 1, [Define to 1 if your system has an altivec.h file.]) + AC_DEFINE(ARCH_POWERPC, 1, [Define to 1 if your system is a PowerPC.]) + SIMD_CFLAGS=-maltivec + AC_SUBST(SIMD_CFLAGS)], + [enable_altivec="no"] + ) +fi + +dnl SSE2 support + +AC_ARG_ENABLE(sse2, + [ --disable-sse2 disable SSE2 support. (default=enabled) ], + [enable_sse2=$enableval], + [enable_sse2=yes] +) +if test "x$enable_sse2" = "xyes"; then + AC_MSG_CHECKING(SSE2) + ac_save_CFLAGS="$CFLAGS" + CFLAGS="-msse2" + AC_TRY_RUN([ + #include <emmintrin.h> + int main() + { + _mm_setzero_pd(); + return 0; + } + ], + [AC_MSG_RESULT(SSE2 yes) + AC_DEFINE(HAVE_SSE2, 1, [Define to 1 if your system has SSE2]) + SIMD_CFLAGS=-msse2], + [AC_MSG_RESULT(SSE2 no) + enable_sse2="no"], + ) +fi +AC_SUBST(SIMD_CFLAGS) +CFLAGS="$ac_save_CFLAGS" + + AC_CHECK_HEADERS(unistd.h) AC_CHECK_HEADERS(fcntl.h) AC_CHECK_HEADERS(sys/ioctl.h) @@ -464,6 +512,9 @@ echo " Automatic character code detection: $enable_chardet" echo " Sample rate upconversion: $enable_samplerate" echo " D-Bus support: $enable_dbus" +echo +echo " SSE2: $enable_sse2" +echo " AltiVec: $enable_altivec" echo if test "$beep_cv_lib_xlibs_threadsafe" = "no"; then
--- a/extra.mk.in Wed Jan 30 01:22:37 2008 +0300 +++ b/extra.mk.in Wed Jan 30 03:36:22 2008 +0300 @@ -338,3 +338,4 @@ TRANSPORT_PLUGINS ?= @TRANSPORT_PLUGINS@ PCH ?= @PCH@ IMPLIB_LIBS = @IMPLIB_LIBS@ +SIMD_CFLAGS ?= @SIMD_CFLAGS@
--- a/src/Makefile Wed Jan 30 01:22:37 2008 +0300 +++ b/src/Makefile Wed Jan 30 03:36:22 2008 +0300 @@ -1,4 +1,4 @@ -SUBDIRS = libguess audacious libid3tag libSAD +SUBDIRS = libguess libSAD audacious libid3tag include ../extra.mk
--- a/src/audacious/Makefile Wed Jan 30 01:22:37 2008 +0300 +++ b/src/audacious/Makefile Wed Jan 30 03:36:22 2008 +0300 @@ -140,7 +140,8 @@ ui/carbon-menubar.ui CLEAN = build_stamp.c libaudacious.exe.a -EXT_DEPS = ../libguess/libguess.a +EXT_DEPS = ../libguess/libguess.a \ + ../libSAD/libSAD.a include ../../buildsys.mk @@ -161,7 +162,9 @@ ${samplerate_CFLAGS} \ ${REGEX_CFLAGS} \ ${LIBMCS_CFLAGS} \ + ${SIMD_CFLAGS} \ -D_AUDACIOUS_CORE \ + -I../libSAD \ -I.. -I../.. \ -I./intl @@ -169,6 +172,7 @@ ${LIBINTL} \ ${samplerate_LIBS} \ ../libguess/libguess.a \ + ../libSAD/libSAD.a \ ${GTK_LIBS} \ ${DBUS_LIBS} \ ${MOWGLI_LIBS} \
--- a/src/libSAD/Makefile Wed Jan 30 01:22:37 2008 +0300 +++ b/src/libSAD/Makefile Wed Jan 30 03:36:22 2008 +0300 @@ -1,7 +1,6 @@ STATIC_LIB_NOINST = libSAD.a SRCS = dither.c \ dither_ops.c \ - SFMT.c \ noicegen.c include ../../buildsys.mk
--- a/src/libSAD/dither.c Wed Jan 30 01:22:37 2008 +0300 +++ b/src/libSAD/dither.c Wed Jan 30 03:36:22 2008 +0300 @@ -1,7 +1,7 @@ /* Scale & Dither library (libSAD) * High-precision bit depth converter with ReplayGain support * - * (c)2007 by Eugene Zagidullin (e.asphyx@gmail.com) + * Copyright (c) 2007-2008 Eugene Zagidullin (e.asphyx@gmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,9 +18,9 @@ */ -#include "common.h" -#include "buffer.h" -#include "noisegen.h" +#include "libSAD.h" +#include "dither_ops.h" +#include "noicegen.h" #include <assert.h> #include <math.h> @@ -89,11 +89,11 @@ * samples < -1 and > 1 will be clipped */ -static inline sad_sint32 __dither_sample_fixed_to_int (sad_sint32 sample, int inbits, int fracbits, int outbits, float scale, int dither, +static inline int32_t __dither_sample_fixed_to_int (int32_t sample, int inbits, int fracbits, int outbits, float scale, int dither, int hardlimit) { int n_bits_to_loose, bitwidth, precision_loss; - sad_sint32 maxint = MAXINT(outbits); + int32_t maxint = MAXINT(outbits); n_bits_to_loose = 0; bitwidth = inbits; @@ -131,7 +131,7 @@ assert(n_bits_to_loose >=0 ); if (hardlimit) { - sample = (sad_sint32)(compute_hardlimit((double)sample/(double)MAXINT(bitwidth), scale) * (double)MAXINT(bitwidth)); + sample = (int32_t)(compute_hardlimit((double)sample/(double)MAXINT(bitwidth), scale) * (double)MAXINT(bitwidth)); #ifdef PRECISION_DEBUG printf("Precision loss, reason: hard limiter\n", inbits, outbits); #endif @@ -150,11 +150,11 @@ if (precision_loss && (n_bits_to_loose >= 1)) sample += (1L << (n_bits_to_loose - 1)); #ifdef DITHER_DEBUG - sad_sint32 val_wo_dither = sample, >> n_bits_to_loose; + int32_t val_wo_dither = sample, >> n_bits_to_loose; val_wo_dither = CLIP(val_wo_dither, maxint); #endif if (dither && precision_loss && (n_bits_to_loose >= 1)) { - sad_sint32 dither_num = triangular_dither_noise(n_bits_to_loose + 1); + int32_t dither_num = triangular_dither_noise(n_bits_to_loose + 1); sample += dither_num; } @@ -162,7 +162,7 @@ /* Clipping */ #ifdef CLIPPING_DEBUG - sad_sint32 val_wo_clip = sample; + int32_t val_wo_clip = sample; #endif sample = CLIP(sample, maxint); #ifdef CLIPPING_DEBUG @@ -180,13 +180,13 @@ * Dither floating-point normalized sample to n-bits integer * samples < -1 and > 1 will be clipped */ -static inline sad_sint32 __dither_sample_float_to_int (float sample, int nbits, float scale, int dither, int hardlimit) { +static inline int32_t __dither_sample_float_to_int (float sample, int nbits, float scale, int dither, int hardlimit) { #ifdef DEEP_DEBUG printf("f: __dither_sample_float_to_int\n"); #endif - sad_sint32 maxint = MAXINT(nbits); + int32_t maxint = MAXINT(nbits); if (hardlimit) { sample = compute_hardlimit((double)sample, scale); @@ -199,7 +199,7 @@ sample = (sample < 0 ? sample - 0.5 : sample + 0.5); #ifdef DITHER_DEBUG - sad_sint32 val_wo_dither = (sad_sint32) sample; + int32_t val_wo_dither = (int32_t) sample; val_wo_dither = CLIP(val_wo_dither, maxint); #endif if (dither) { @@ -208,9 +208,9 @@ } /* Round and clipping */ - sad_sint32 value = (sad_sint32) sample; + int32_t value = (int32_t) sample; #ifdef CLIPPING_DEBUG - sad_sint32 val_wo_clip = value; + int32_t val_wo_clip = value; #endif value = CLIP(value, maxint); #ifdef CLIPPING_DEBUG @@ -237,7 +237,7 @@ return sample; } -static inline float __dither_sample_fixed_to_float (sad_sint32 sample, int inbits, int fracbits, float scale, int hardlimit) { +static inline float __dither_sample_fixed_to_float (int32_t sample, int inbits, int fracbits, float scale, int hardlimit) { float fsample; #ifdef DEEP_DEBUG @@ -396,7 +396,7 @@ for(i=0; i<frames; i++) { for(ch=0; ch<channels; ch++) { float sample = GET_FLOAT_SAMPLE(inbuf, input_chorder, channels, ch ,i); - sad_sint32 isample = __dither_sample_float_to_int(sample, outbits, scale, dither, hardlimit); + int32_t isample = __dither_sample_float_to_int(sample, outbits, scale, dither, hardlimit); put_sample (outbuf, isample, channels, ch, i); } } @@ -407,7 +407,7 @@ /* process buffer */ for(i=0; i<frames; i++) { for(ch=0; ch<channels; ch++) { - sad_sint32 sample = get_sample (inbuf, channels, ch, i); + int32_t sample = get_sample (inbuf, channels, ch, i); float fsample = __dither_sample_fixed_to_float (sample, inbits, fracbits, scale, hardlimit); PUT_FLOAT_SAMPLE(outbuf, output_chorder, channels, ch ,i, fsample); } @@ -417,8 +417,8 @@ /* process buffer */ for(i=0; i<frames; i++) { for(ch=0; ch<channels; ch++){ - sad_sint32 sample = get_sample (inbuf, channels, ch, i); - sad_sint32 isample = __dither_sample_fixed_to_int (sample, inbits, fracbits, outbits, scale, dither, hardlimit); + int32_t sample = get_sample (inbuf, channels, ch, i); + int32_t isample = __dither_sample_fixed_to_int (sample, inbits, fracbits, outbits, scale, dither, hardlimit); put_sample (outbuf, isample, channels, ch, i); } }
--- a/src/libSAD/dither.h Wed Jan 30 01:22:37 2008 +0300 +++ b/src/libSAD/dither.h Wed Jan 30 03:36:22 2008 +0300 @@ -1,14 +1,33 @@ +/* Scale & Dither library (libSAD) + * High-precision bit depth converter with ReplayGain support + * + * Copyright (c) 2007-2008 Eugene Zagidullin (e.asphyx@gmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #ifndef DITHER_H #define DITHER_H -#include "common.h" +#include "libSAD.h" #define SAD_ERROR_INCORRECT_INPUT_SAMPLEFORMAT -2 #define SAD_ERROR_INCORRECT_OUTPUT_SAMPLEFORMAT -3 #define SAD_ERROR_CORRUPTED_PRIVATE_DATA -4 -typedef sad_sint32 (*SAD_get_sample_proc) (void *buf, int nch, int ch, int i); -typedef void (*SAD_put_sample_proc) (void *buf, sad_sint32 sample, int nch, int ch, int i); +typedef int32_t (*SAD_get_sample_proc) (void *buf, int nch, int ch, int i); +typedef void (*SAD_put_sample_proc) (void *buf, int32_t sample, int nch, int ch, int i); typedef struct { SAD_get_sample_proc get_sample;
--- a/src/libSAD/dither_ops.c Wed Jan 30 01:22:37 2008 +0300 +++ b/src/libSAD/dither_ops.c Wed Jan 30 03:36:22 2008 +0300 @@ -1,7 +1,7 @@ /* Scale & Dither library (libSAD) * High-precision bit depth converter with ReplayGain support * - * (c)2007 by Eugene Zagidullin (e.asphyx@gmail.com) + * Copyright (c) 2007-2008 Eugene Zagidullin (e.asphyx@gmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "common.h" -#include "buffer.h" +#include "libSAD.h" +#include "dither_ops.h" #include "dither.h" /* buffer ops: */ @@ -27,37 +27,37 @@ **********/ /* signed */ -static sad_sint32 get_s8_i_sample (void *buf, int nch, int ch, int i) { - return ((sad_sint8*)buf)[i*nch+ch]; +static int32_t get_s8_i_sample (void *buf, int nch, int ch, int i) { + return ((int8_t*)buf)[i*nch+ch]; } -static sad_sint32 get_s8_s_sample (void *buf, int nch, int ch, int i) { - return ((sad_sint8**)buf)[ch][i]; +static int32_t get_s8_s_sample (void *buf, int nch, int ch, int i) { + return ((int8_t**)buf)[ch][i]; } -static void put_s8_i_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_sint8*)buf)[i*nch+ch] = (sad_sint8)sample; +static void put_s8_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((int8_t*)buf)[i*nch+ch] = (int8_t)sample; } -static void put_s8_s_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_sint8**)buf)[ch][i] = (sad_sint8)sample; +static void put_s8_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((int8_t**)buf)[ch][i] = (int8_t)sample; } /* unsigned */ -static sad_sint32 get_u8_i_sample (void *buf, int nch, int ch, int i) { - return (sad_sint32)(((sad_uint8*)buf)[i*nch+ch]) - 128; +static int32_t get_u8_i_sample (void *buf, int nch, int ch, int i) { + return (int32_t)(((u_int8_t*)buf)[i*nch+ch]) - 128; } -static sad_sint32 get_u8_s_sample (void *buf, int nch, int ch, int i) { - return (sad_sint32)(((sad_uint8**)buf)[ch][i]) - 128; +static int32_t get_u8_s_sample (void *buf, int nch, int ch, int i) { + return (int32_t)(((u_int8_t**)buf)[ch][i]) - 128; } -static void put_u8_i_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_uint8*)buf)[i*nch+ch] = (sad_uint8)sample + 128; +static void put_u8_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((u_int8_t*)buf)[i*nch+ch] = (u_int8_t)sample + 128; } -static void put_u8_s_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_uint8**)buf)[ch][i] = (sad_uint8)sample + 128; +static void put_u8_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((u_int8_t**)buf)[ch][i] = (u_int8_t)sample + 128; } static SAD_buffer_ops buf_s8_i_ops = { @@ -85,43 +85,43 @@ **********/ /* signed */ -static sad_sint32 get_s16_i_sample (void *buf, int nch, int ch, int i) { - return (sad_sint32)(((sad_sint16*)buf)[i*nch+ch]); +static int32_t get_s16_i_sample (void *buf, int nch, int ch, int i) { + return (int32_t)(((int16_t*)buf)[i*nch+ch]); } -static sad_sint32 get_s16_s_sample (void *buf, int nch, int ch, int i) { - return (sad_sint32)(((sad_sint16**)buf)[ch][i]); +static int32_t get_s16_s_sample (void *buf, int nch, int ch, int i) { + return (int32_t)(((int16_t**)buf)[ch][i]); } -static void put_s16_i_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { +static void put_s16_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { /*#ifdef DEEP_DEBUG printf("f: put_s16_i_sample\n"); #endif*/ - ((sad_sint16*)buf)[i*nch+ch] = (sad_sint16)sample; + ((int16_t*)buf)[i*nch+ch] = (int16_t)sample; } -static void put_s16_s_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { +static void put_s16_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { /*#ifdef DEEP_DEBUG printf("f: put_s16_s_sample\n"); #endif*/ - ((sad_sint16**)buf)[ch][i] = (sad_sint16)sample; + ((int16_t**)buf)[ch][i] = (int16_t)sample; } /* unsigned */ -static sad_sint32 get_u16_i_sample (void *buf, int nch, int ch, int i) { - return ((sad_sint32)(((sad_uint16*)buf)[i*nch+ch])) - 32768; +static int32_t get_u16_i_sample (void *buf, int nch, int ch, int i) { + return ((int32_t)(((u_int16_t*)buf)[i*nch+ch])) - 32768; } -static sad_sint32 get_u16_s_sample (void *buf, int nch, int ch, int i) { - return ((sad_sint32)(((sad_uint16**)buf)[ch][i])) - 32768; +static int32_t get_u16_s_sample (void *buf, int nch, int ch, int i) { + return ((int32_t)(((u_int16_t**)buf)[ch][i])) - 32768; } -static void put_u16_i_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_uint16*)buf)[i*nch+ch] = (sad_uint16)(sample + 32768); +static void put_u16_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((u_int16_t*)buf)[i*nch+ch] = (u_int16_t)(sample + 32768); } -static void put_u16_s_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_uint16**)buf)[ch][i] = (sad_uint16)(sample + 32768); +static void put_u16_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((u_int16_t**)buf)[ch][i] = (u_int16_t)(sample + 32768); } static SAD_buffer_ops buf_s16_i_ops = { @@ -149,40 +149,40 @@ **********/ /*expand 24-bit signed value to 32-bit*/ -#define EXPAND_24_TO_32(x) (((sad_sint32)(((x) & 0x00ffffff) << 8)) >> 8) +#define EXPAND_24_TO_32(x) (((int32_t)(((x) & 0x00ffffff) << 8)) >> 8) /* signed */ -static sad_sint32 get_s24_i_sample (void *buf, int nch, int ch, int i) { - return (sad_sint32)EXPAND_24_TO_32(((sad_sint32*)buf)[i*nch+ch]); +static int32_t get_s24_i_sample (void *buf, int nch, int ch, int i) { + return (int32_t)EXPAND_24_TO_32(((int32_t*)buf)[i*nch+ch]); } -static sad_sint32 get_s24_s_sample (void *buf, int nch, int ch, int i) { - return (sad_sint32)EXPAND_24_TO_32(((sad_sint32**)buf)[ch][i]); +static int32_t get_s24_s_sample (void *buf, int nch, int ch, int i) { + return (int32_t)EXPAND_24_TO_32(((int32_t**)buf)[ch][i]); } -static void put_s24_i_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_sint32*)buf)[i*nch+ch] = (sad_sint32)sample & 0x00ffffff; +static void put_s24_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((int32_t*)buf)[i*nch+ch] = (int32_t)sample & 0x00ffffff; } -static void put_s24_s_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_sint32**)buf)[ch][i] = (sad_sint32)sample & 0x00ffffff; +static void put_s24_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((int32_t**)buf)[ch][i] = (int32_t)sample & 0x00ffffff; } /* unsigned */ -static sad_sint32 get_u24_i_sample (void *buf, int nch, int ch, int i) { - return (sad_sint32)EXPAND_24_TO_32(((sad_uint32*)buf)[i*nch+ch]) - 8388608; +static int32_t get_u24_i_sample (void *buf, int nch, int ch, int i) { + return (int32_t)EXPAND_24_TO_32(((u_int32_t*)buf)[i*nch+ch]) - 8388608; } -static sad_sint32 get_u24_s_sample (void *buf, int nch, int ch, int i) { - return (sad_sint32)EXPAND_24_TO_32(((sad_uint32**)buf)[ch][i]) - 8388608; +static int32_t get_u24_s_sample (void *buf, int nch, int ch, int i) { + return (int32_t)EXPAND_24_TO_32(((u_int32_t**)buf)[ch][i]) - 8388608; } -static void put_u24_i_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_uint32*)buf)[i*nch+ch] = ((sad_uint32)sample + 8388608) & 0x00ffffff; +static void put_u24_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((u_int32_t*)buf)[i*nch+ch] = ((u_int32_t)sample + 8388608) & 0x00ffffff; } -static void put_u24_s_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_uint32**)buf)[ch][i] = ((sad_uint32)sample + 8388608) & 0x00ffffff; +static void put_u24_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((u_int32_t**)buf)[ch][i] = ((u_int32_t)sample + 8388608) & 0x00ffffff; } static SAD_buffer_ops buf_s24_i_ops = { @@ -210,37 +210,37 @@ **********/ /* signed */ -static sad_sint32 get_s32_i_sample (void *buf, int nch, int ch, int i) { - return ((sad_sint32*)buf)[i*nch+ch]; +static int32_t get_s32_i_sample (void *buf, int nch, int ch, int i) { + return ((int32_t*)buf)[i*nch+ch]; } -static sad_sint32 get_s32_s_sample (void *buf, int nch, int ch, int i) { - return ((sad_sint32**)buf)[ch][i]; +static int32_t get_s32_s_sample (void *buf, int nch, int ch, int i) { + return ((int32_t**)buf)[ch][i]; } -static void put_s32_i_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_sint32*)buf)[i*nch+ch] = (sad_sint32)sample; +static void put_s32_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((int32_t*)buf)[i*nch+ch] = (int32_t)sample; } -static void put_s32_s_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_sint32**)buf)[ch][i] = (sad_sint32)sample; +static void put_s32_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((int32_t**)buf)[ch][i] = (int32_t)sample; } /* unsigned */ -static sad_sint32 get_u32_i_sample (void *buf, int nch, int ch, int i) { - return ((sad_sint32*)buf)[i*nch+ch] - (sad_sint32)(1L<<31); +static int32_t get_u32_i_sample (void *buf, int nch, int ch, int i) { + return ((int32_t*)buf)[i*nch+ch] - (int32_t)(1L<<31); } -static sad_sint32 get_u32_s_sample (void *buf, int nch, int ch, int i) { - return ((sad_sint32**)buf)[ch][i] - (sad_sint32)(1L<<31); +static int32_t get_u32_s_sample (void *buf, int nch, int ch, int i) { + return ((int32_t**)buf)[ch][i] - (int32_t)(1L<<31); } -static void put_u32_i_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_uint32*)buf)[i*nch+ch] = (sad_uint32)(sample + (sad_sint32)(1L<<31)); +static void put_u32_i_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((u_int32_t*)buf)[i*nch+ch] = (u_int32_t)(sample + (int32_t)(1L<<31)); } -static void put_u32_s_sample (void *buf, sad_sint32 sample, int nch, int ch, int i) { - ((sad_uint32**)buf)[ch][i] = (sad_uint32)(sample + (sad_sint32)(1L<<31)); +static void put_u32_s_sample (void *buf, int32_t sample, int nch, int ch, int i) { + ((u_int32_t**)buf)[ch][i] = (u_int32_t)(sample + (int32_t)(1L<<31)); } static SAD_buffer_ops buf_s32_i_ops = {
--- a/src/libSAD/dither_ops.h Wed Jan 30 01:22:37 2008 +0300 +++ b/src/libSAD/dither_ops.h Wed Jan 30 03:36:22 2008 +0300 @@ -1,7 +1,7 @@ /* Scale & Dither library (libSAD) * High-precision bit depth converter with ReplayGain support * - * (c)2007 by Eugene Zagidullin (e.asphyx@gmail.com) + * Copyright (c) 2007-2008 Eugene Zagidullin (e.asphyx@gmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,12 +17,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef BUFFER_H -#define BUFFER_H +#ifndef DITHER_OPS_H +#define DITHER_OPS_H -#include "common.h" +#include "libSAD.h" #include "dither.h" SAD_buffer_ops* SAD_assign_buf_ops (SAD_buffer_format *format); -#endif /*BUFFER_H*/ +#endif /*DITHER_OPS_H*/
--- a/src/libSAD/libSAD.h Wed Jan 30 01:22:37 2008 +0300 +++ b/src/libSAD/libSAD.h Wed Jan 30 03:36:22 2008 +0300 @@ -1,7 +1,7 @@ /* Scale & Dither library (libSAD) * High-precision bit depth converter with ReplayGain support * - * (c)2007 by Eugene Zagidullin (e.asphyx@gmail.com) + * Copyright (c) 2007-2008 Eugene Zagidullin (e.asphyx@gmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef COMMON_H -#define COMMON_H +#ifndef LIBSAD_H +#define LIBSAD_H #include <stdio.h> #include <stdlib.h> @@ -33,34 +33,7 @@ #define FALSE 0 #endif -#include "../config.h" - -#ifdef ENABLE_NLS -# include <libintl.h> -# include <locale.h> -# define _(String) dgettext(PACKAGE,String) -#else -# define _(String) (String) -#endif - -typedef u_int8_t sad_uint8; -typedef int8_t sad_sint8; - -#if SIZEOF_SHORT == 2 - typedef unsigned short sad_uint16; - typedef short sad_sint16; -#else -# error "Unsupported sizeof(short)" -#endif - -#if SIZEOF_INT == 4 - typedef unsigned int sad_uint32; - typedef int sad_sint32; -#else -# error "Unsupported sizeof(int)" -#endif - -typedef size_t sad_size_t; +#include "../../config.h" typedef int SAD_error; @@ -91,16 +64,16 @@ } SAD_sample_format; /* sample format -> sample size */ -static inline sad_size_t sf2ss(SAD_sample_format fmt) { +static inline unsigned sf2ss(SAD_sample_format fmt) { switch(fmt) { case SAD_SAMPLE_S8: - case SAD_SAMPLE_U8: return sizeof(sad_sint8); + case SAD_SAMPLE_U8: return sizeof(int8_t); case SAD_SAMPLE_S16: case SAD_SAMPLE_S16_LE: case SAD_SAMPLE_S16_BE: case SAD_SAMPLE_U16: case SAD_SAMPLE_U16_LE: - case SAD_SAMPLE_U16_BE: return sizeof(sad_sint16); + case SAD_SAMPLE_U16_BE: return sizeof(int16_t); case SAD_SAMPLE_S24: case SAD_SAMPLE_S24_LE: case SAD_SAMPLE_S24_BE: @@ -113,7 +86,7 @@ case SAD_SAMPLE_U32: case SAD_SAMPLE_U32_LE: case SAD_SAMPLE_U32_BE: - case SAD_SAMPLE_FIXED32: return sizeof(sad_sint32); + case SAD_SAMPLE_FIXED32: return sizeof(int32_t); case SAD_SAMPLE_FLOAT: return sizeof(float); default: return 0; } @@ -133,11 +106,11 @@ int samplerate; } SAD_buffer_format; -static inline sad_size_t bytes2frames(SAD_buffer_format *fmt, sad_size_t bytes) { +static inline unsigned bytes2frames(SAD_buffer_format *fmt, unsigned bytes) { return bytes / sf2ss(fmt->sample_format) / fmt->channels; } -static inline sad_size_t frames2bytes(SAD_buffer_format *fmt, sad_size_t frames) { +static inline unsigned frames2bytes(SAD_buffer_format *fmt, unsigned frames) { return frames * sf2ss(fmt->sample_format) * fmt->channels; } @@ -176,5 +149,5 @@ } SAD_replaygain_mode; -#endif /* COMMON_H */ +#endif /* LIBSAD_H */
--- a/src/libSAD/noicegen.c Wed Jan 30 01:22:37 2008 +0300 +++ b/src/libSAD/noicegen.c Wed Jan 30 03:36:22 2008 +0300 @@ -2,16 +2,17 @@ #include <assert.h> #include "../../config.h" +#ifdef HAVE_SSE2 +# define SSE2 1 +#endif + +#ifdef HAVE_ALTIVEC +# define ALTIVEC 1 +#endif + #define MEXP 19937 -#ifdef HAVE_SSE2 -#define SSE2 1 -#endif -#ifdef HAVE_ALTIVEC -#define ALTIVEC 1 -#endif - -#include "SFMT.h" +/*#include "SFMT.h"*/ #include "SFMT.c" #include "noicegen.h" @@ -33,3 +34,9 @@ return v; } + +float triangular_dither_noise_f() { + // Сonditionally assume we have 16 bits in fractional part + // Please, check it thoroughly: is this assumption correct in floatin-point arithmetic? + return (float) triangular_dither_noise(17) / 65536.0; +}