Ignore:
Timestamp:
10/06/06 17:14:05 (18 years ago)
Author:
zorg
Message:

Separated public interface from private headers
Use opaque objects whenever possible
Some (useless?) cosmetics on libmpcdec
Remove sv5-6 outdated support
Added libwavformat for upcoming mpcdec
New layout
Work in progress...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpcdec/branches/zorg/src/requant.c

    r10 r68  
    3232  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3333*/
    34 
    3534/// \file requant.c
    3635/// Requantization function implementations.
    3736/// \todo document me
     37#include <mpcdec/mpcdec.h>
    3838
    39 #include <mpcdec/mpcdec.h>
    40 #include <mpcdec/internal.h>
     39#include "requant.h"
     40#include "math.h"
     41#include "decoder.h"
    4142
    4243/* C O N S T A N T S */
    43 // bits per sample for chosen quantizer
     44// Bits per sample for chosen quantizer
    4445const mpc_uint32_t  Res_bit [18] = {
    4546    0,  0,  0,  0,  0,  0,  0,  0,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16
    4647};
    4748
    48 // coefficients for requantization
     49// Requantization coefficients
    4950// 65536/step bzw. 65536/(2*D+1)
    5051
     
    5253
    5354const MPC_SAMPLE_FORMAT  __Cc [1 + 18] = {
    54       _(111.285962475327f),                                        // 32768/2/255*sqrt(3)
     55    _(111.285962475327f),   // 32768/2/255*sqrt(3)
    5556    _(65536.000000000000f), _(21845.333333333332f), _(13107.200000000001f), _(9362.285714285713f),
    56     _(7281.777777777777f),  _(4369.066666666666f),  _(2114.064516129032f), _(1040.253968253968f),
    57      _(516.031496062992f),  _(257.003921568627f),   _(128.250489236790f),   _(64.062561094819f),
    58        _(32.015632633121f),    _(16.003907203907f),     _(8.000976681723f),    _(4.000244155527f),
    59         _(2.000061037018f),     _(1.000015259021f)
     57    _(7281.777777777777f),  _(4369.066666666666f),  _(2114.064516129032f),  _(1040.253968253968f),
     58    _(516.031496062992f),   _(257.003921568627f),   _(128.250489236790f),   _(64.062561094819f),
     59    _(32.015632633121f),    _(16.003907203907f),    _(8.000976681723f),     _(4.000244155527f),
     60    _(2.000061037018f),     _(1.000015259021f)
    6061};
    6162
    6263#undef _
    6364
    64 // offset for requantization
     65// Requantization offset
    6566// 2*D+1 = steps of quantizer
    6667const mpc_int32_t  __Dc [1 + 18] = {
     
    7374static mpc_uint32_t find_shift(double fval)
    7475{
    75         mpc_int64_t  val = (mpc_int64_t)fval;
     76        mpc_int64_t  val = (mpc_int64_t) fval;
    7677        mpc_uint32_t ptr = 0;
    77         if (val<0) val = -val;
    78         while(val) {val>>=1;ptr++;}
    79 
     78        if(val<0)
     79        val = -val;
     80        while(val)
     81    {
     82        val >>= 1;
     83        ptr++;
     84    }
    8085        return ptr > 31 ? 0 : 31 - ptr;
    8186}
     
    8489/* F U N C T I O N S */
    8590
    86 #define SET_SCF(N,X) d->SCF[N] = MAKE_MPC_SAMPLE_EX(X,d->SCF_shift[N] = (unsigned char)find_shift(X));
     91#define SET_SCF(N,X) d->SCF[N] = MAKE_MPC_SAMPLE_EX(X,d->SCF_shift[N] = (mpc_uint8_t) find_shift(X));
    8792
    8893void
    8994mpc_decoder_scale_output(mpc_decoder *d, double factor)
    9095{
    91     mpc_int32_t     n;
    92     double  f1;
    93     double  f2;
     96    mpc_int32_t n; double f1, f2;
     97
    9498#ifndef MPC_FIXED_POINT
    95         factor *= 1.0 / (double)(1<<(MPC_FIXED_POINT_SHIFT-1));
     99        factor *= 1.0 / (double) (1<<(MPC_FIXED_POINT_SHIFT-1));
    96100#else
    97         factor *= 1.0 / (double)(1<<(16 - MPC_FIXED_POINT_SHIFT));
     101        factor *= 1.0 / (double) (1<<(16-MPC_FIXED_POINT_SHIFT));
    98102#endif
    99103    f1 = f2 = factor;
     
    107111
    108112    for ( n = 1; n <= 128; n++ ) {
    109                 SET_SCF((unsigned char)(1+n),f1);
    110                 SET_SCF((unsigned char)(1-n),f2);
     113                SET_SCF((mpc_uint8_t)(1+n),f1);
     114                SET_SCF((mpc_uint8_t)(1-n),f2);
    111115        f1 *=   0.83298066476582673961;
    112116        f2 *= 1/0.83298066476582673961;
Note: See TracChangeset for help on using the changeset viewer.