Changeset 2107:2dafbf9739f2 in roaraudio


Ignore:
Timestamp:
07/21/09 16:55:27 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support for 8/16/32 bit vorbis encoding

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/codecfilter_vorbis.c

    r2087 r2107  
    2929#ifdef ROAR_HAVE_LIBVORBISFILE 
    3030 
     31#define FIFAC ((float)((uint64_t)1<<(ROAR_VORBIS_BITS-1))) 
     32 
    3133int _g_cf_vorbis_vfvio_return_err (void) { 
    3234 return -1; 
     
    99101 } 
    100102*/ 
     103 s->info.bits  = ROAR_VORBIS_BITS; 
    101104#else 
    102105 free(self); 
     
    141144 int chans; 
    142145 int end; 
     146#if ROAR_VORBIS_BITS == 8 
     147 int8_t  * data = (int8_t  *) buf; 
     148#elif ROAR_VORBIS_BITS == 16 
    143149 int16_t * data = (int16_t *) buf; 
     150#elif ROAR_VORBIS_BITS == 32 
     151 int32_t * data = (int32_t *) buf; 
     152#else 
     153#error value of ROAR_VORBIS_BITS not supported 
     154#endif 
    144155 
    145156 if ( ! self->opened ) { 
     
    169180  encbuf = vorbis_analysis_buffer(&(self->encoder.vd), len /* TODO: need to lookup the menaing of this */); 
    170181  chans  = s->info.channels; 
    171   end    = len/(2*chans); 
     182  end    = len*8/(ROAR_VORBIS_BITS*chans); 
    172183 
    173184  if ( chans == 1 ) { // use optimized code 
    174185   for (i = 0; i < end; i++) 
    175     encbuf[0][i] = data[i]/32768.0; 
     186    encbuf[0][i] = data[i]/FIFAC; 
    176187 
    177188  } else if ( chans == 2 ) { // use optimized code 
    178189   for (i = 0; i < end; i++) { 
    179     encbuf[0][i] = data[2*i  ]/32768.0; 
    180     encbuf[1][i] = data[2*i+1]/32768.0; 
     190    encbuf[0][i] = data[2*i  ]/FIFAC; 
     191    encbuf[1][i] = data[2*i+1]/FIFAC; 
    181192   } 
    182193  } else { // use generic multi channel code 
    183194   for (i = 0; i < end; i++) { 
    184195    for (c = 0; c < chans; c++) { 
    185      encbuf[c][i] = data[chans*i+c]/32768.0; 
     196     encbuf[c][i] = data[chans*i+c]/FIFAC; 
    186197    } 
    187198   } 
Note: See TracChangeset for help on using the changeset viewer.