Skip to content

Commit

Permalink
Modified to output 8.24 fixed point samples
Browse files Browse the repository at this point in the history
  • Loading branch information
kode54 committed Aug 31, 2012
1 parent 46ff556 commit c0497ee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libFDK/include/common_fix.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ amm-info@iis.fraunhofer.de

/* Fixpoint equivalent type fot PCM audio time domain data. */
#if defined(SAMPLE_BITS)
#if (SAMPLE_BITS == DFRACT_BITS)
#if (SAMPLE_BITS > FRACT_BITS)
#define FIXP_PCM FIXP_DBL
#define FX_PCM2FX_DBL(x) ((FIXP_DBL)(x))
#define FX_DBL2FX_PCM(x) ((INT_PCM)(x))
Expand Down
6 changes: 4 additions & 2 deletions libSBRenc/src/resampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static inline INT_PCM AdvanceFilter(LP_FILTER *downFilter, /*!< pointer to iir
#elif (SAMPLE_BITS == 32)
input = pInput[n*inStride] >> BIQUAD_SCALE;
#else
#error NOT IMPLEMENTED
input = ((FIXP_DBL)pInput[n*inStride]) >> -(DFRACT_BITS-SAMPLE_BITS-BIQUAD_SCALE);
#endif

#ifndef RS_BIQUAD_SCATTERGAIN /* Merged Direct form I */
Expand Down Expand Up @@ -465,8 +465,10 @@ static inline INT_PCM AdvanceFilter(LP_FILTER *downFilter, /*!< pointer to iir
#if (SAMPLE_BITS == 16)
output = (INT_PCM) SATURATE_RIGHT_SHIFT(y+(FIXP_DBL)(1<<(DFRACT_BITS-SAMPLE_BITS-BIQUAD_SCALE-1)), DFRACT_BITS-SAMPLE_BITS-BIQUAD_SCALE, SAMPLE_BITS);
//output = (INT_PCM) SATURATE_RIGHT_SHIFT(y, DFRACT_BITS-SAMPLE_BITS-BIQUAD_SCALE, SAMPLE_BITS);
#else
#elif (SAMPLE_BITS == 32)
output = SATURATE_LEFT_SHIFT(y, BIQUAD_SCALE, SAMPLE_BITS);
#else
output = SATURATE_LEFT_SHIFT(y, -(DFRACT_BITS-SAMPLE_BITS-BIQUAD_SCALE), SAMPLE_BITS);
#endif


Expand Down
11 changes: 9 additions & 2 deletions libSYS/include/machine_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,19 @@ amm-info@iis.fraunhofer.de
#define FDK_ASSERT(ignore)
#endif

typedef SHORT INT_PCM;
typedef LONG INT_PCM;
#define WAV_BITS 16
#define SAMPLE_BITS 16
#define SAMPLE_BITS 29
#define SAMPLE_MAX (((LONG)1<<(SAMPLE_BITS-1))-1)
#define SAMPLE_MIN (~SAMPLE_MAX)

/* Since we want fixed point with a whole part, not just integer PCM, we disable clipping by defining these: */
#define SATURATE_RIGHT_SHIFT(src, scale, dBits) ((LONG)(src) >> (scale))
#define SATURATE_LEFT_SHIFT(src, scale, dBits) ((LONG)(src) << (scale))

#define SATURATE_RIGHT_SHIFT_ALT(src, scale, dBits) ((LONG)(src) >> (scale))
#define SATURATE_LEFT_SHIFT_ALT(src, scale, dBits) ((LONG)(src) << (scale))

/*!
* \def RAM_ALIGN
* Used to align memory as prefix before memory declaration. For example:
Expand Down

0 comments on commit c0497ee

Please sign in to comment.