Mercurial > audlegacy
diff src/libSAD/libSAD.h @ 4234:b293ce14a01a
partially works...
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Thu, 31 Jan 2008 12:04:13 +0300 |
parents | 74c6f3d3cf1d |
children |
line wrap: on
line diff
--- a/src/libSAD/libSAD.h Wed Jan 30 03:36:22 2008 +0300 +++ b/src/libSAD/libSAD.h Thu Jan 31 12:04:13 2008 +0300 @@ -20,134 +20,7 @@ #ifndef LIBSAD_H #define LIBSAD_H -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <math.h> - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#include "../../config.h" - -typedef int SAD_error; - -typedef enum { - SAD_SAMPLE_S8, - SAD_SAMPLE_U8, - SAD_SAMPLE_S16, - SAD_SAMPLE_S16_LE, - SAD_SAMPLE_S16_BE, - SAD_SAMPLE_U16, - SAD_SAMPLE_U16_LE, - SAD_SAMPLE_U16_BE, - SAD_SAMPLE_S24, - SAD_SAMPLE_S24_LE, - SAD_SAMPLE_S24_BE, - SAD_SAMPLE_U24, - SAD_SAMPLE_U24_LE, - SAD_SAMPLE_U24_BE, - SAD_SAMPLE_S32, - SAD_SAMPLE_S32_LE, - SAD_SAMPLE_S32_BE, - SAD_SAMPLE_U32, - SAD_SAMPLE_U32_LE, - SAD_SAMPLE_U32_BE, - SAD_SAMPLE_FIXED32, - SAD_SAMPLE_FLOAT, - SAD_SAMPLE_MAX /*EOF*/ -} SAD_sample_format; - -/* sample format -> sample size */ -static inline unsigned sf2ss(SAD_sample_format fmt) { - switch(fmt) { - case SAD_SAMPLE_S8: - 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(int16_t); - case SAD_SAMPLE_S24: - case SAD_SAMPLE_S24_LE: - case SAD_SAMPLE_S24_BE: - case SAD_SAMPLE_U24: - case SAD_SAMPLE_U24_LE: - case SAD_SAMPLE_U24_BE: - case SAD_SAMPLE_S32: - case SAD_SAMPLE_S32_LE: - case SAD_SAMPLE_S32_BE: - case SAD_SAMPLE_U32: - case SAD_SAMPLE_U32_LE: - case SAD_SAMPLE_U32_BE: - case SAD_SAMPLE_FIXED32: return sizeof(int32_t); - case SAD_SAMPLE_FLOAT: return sizeof(float); - default: return 0; - } -} - -typedef enum { - SAD_CHORDER_INTERLEAVED, - SAD_CHORDER_SEPARATED, - SAD_CHORDER_MAX /*EOF*/ -} SAD_channels_order; - -typedef struct { - SAD_sample_format sample_format; - int fracbits; /* for fixed-point only */ - int channels; - SAD_channels_order channels_order; - int samplerate; -} SAD_buffer_format; - -static inline unsigned bytes2frames(SAD_buffer_format *fmt, unsigned bytes) { - return bytes / sf2ss(fmt->sample_format) / fmt->channels; -} - -static inline unsigned frames2bytes(SAD_buffer_format *fmt, unsigned frames) { - return frames * sf2ss(fmt->sample_format) * fmt->channels; -} - -static inline float db2scale(float db) { - return pow(10, db / 20); -} - -enum { - SAD_RG_NONE, - SAD_RG_TRACK, - SAD_RG_ALBUM -}; - -#define SAD_ERROR_OK 0 -#define SAD_ERROR_FAIL -1 - -#ifdef DEBUG -#define DEBUG_MSG(f,x) {printf("debug: "f, x);} -#else -#define DEBUG_MSG(f,x) {} -#endif - -typedef struct { - int present; - float track_gain; // in dB !!! - float track_peak; - float album_gain; - float album_peak; -} SAD_replaygain_info; - -typedef struct { - int mode; - int clipping_prevention; - int hard_limit; - float preamp; -} SAD_replaygain_mode; - +#include "common.h" +#include "dither.h" #endif /* LIBSAD_H */ -