[BACK]Return to headers.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / aucat

Diff for /src/usr.bin/aucat/Attic/headers.c between version 1.5 and 1.6

version 1.5, 2009/04/11 10:24:21 version 1.6, 2009/04/22 10:57:33
Line 25 
Line 25 
   
 #include "conf.h"  #include "conf.h"
 #include "aparams.h"  #include "aparams.h"
   #include "wav.h"
   
   /*
    * encoding IDs used in .wav headers
    */
   #define WAV_ENC_PCM     1
   #define WAV_ENC_ALAW    6
   #define WAV_ENC_ULAW    7
   
 struct wavriff {  struct wavriff {
         char magic[4];          char magic[4];
         uint32_t size;          uint32_t size;
Line 52 
Line 60 
 char wav_id_fmt[4] = { 'f', 'm', 't', ' ' };  char wav_id_fmt[4] = { 'f', 'm', 't', ' ' };
   
 int  int
 wav_readfmt(int fd, unsigned csize, struct aparams *par, int *renc)  wav_readfmt(int fd, unsigned csize, struct aparams *par, short **map)
 {  {
         struct wavfmt fmt;          struct wavfmt fmt;
         unsigned nch, cmax, rate, bits, enc;          unsigned nch, cmax, rate, bits, enc;
Line 66 
Line 74 
                 return 0;                  return 0;
         }          }
         enc = letoh16(fmt.fmt);          enc = letoh16(fmt.fmt);
         if (renc == NULL && enc != 1) {          switch (enc) {
                 warnx("%u: only \"pcm\" encoding supported", enc);          case WAV_ENC_PCM:
                 return 0;                  *map = NULL;
                   break;
           case WAV_ENC_ALAW:
                   *map = wav_alawmap;
                   break;
           case WAV_ENC_ULAW:
                   *map = wav_ulawmap;
                   break;
           default:
                   errx(1, "%u: unsupported encoding in .wav file", enc);
         }          }
         nch = letoh16(fmt.nch);          nch = letoh16(fmt.nch);
         if (nch == 0) {          if (nch == 0) {
Line 90 
Line 107 
                 warnx("%u: bad number of bits", bits);                  warnx("%u: bad number of bits", bits);
                 return 0;                  return 0;
         }          }
         par->bps = (bits + 7) / 8;          if (enc == WAV_ENC_PCM) {
         par->bits = bits;                  par->bps = (bits + 7) / 8;
         par->le = 1;                  par->bits = bits;
         par->sig = (bits <= 8) ? 0 : 1; /* ask microsoft why... */                  par->le = 1;
                   par->sig = (bits <= 8) ? 0 : 1; /* ask microsoft why... */
           } else {
                   if (bits != 8) {
                           warnx("%u: mulaw/alaw encoding not 8-bit", bits);
                           return 0;
                   }
                   par->bits = 8 * sizeof(short);
                   par->bps = sizeof(short);
                   par->le = NATIVE_LE;
                   par->sig = 1;
           }
         par->msb = 1;          par->msb = 1;
         par->cmax = cmax;          par->cmax = cmax;
         par->rate = rate;          par->rate = rate;
         if (renc)  
                 *renc = enc;  
 #ifdef DEBUG  #ifdef DEBUG
         if (debug_level > 0) {          if (debug_level > 0) {
                 fprintf(stderr, "wav_readfmt: using ");                  fprintf(stderr, "wav_readfmt: using ");
Line 110 
Line 136 
 }  }
   
 int  int
 wav_readhdr(int fd, struct aparams *par, off_t *datasz, int *renc)  wav_readhdr(int fd, struct aparams *par, off_t *datasz, short **map)
 {  {
         struct wavriff riff;          struct wavriff riff;
         struct wavchunk chunk;          struct wavchunk chunk;
Line 138 
Line 164 
                 }                  }
                 csize = letoh32(chunk.size);                  csize = letoh32(chunk.size);
                 if (memcmp(chunk.id, wav_id_fmt, 4) == 0) {                  if (memcmp(chunk.id, wav_id_fmt, 4) == 0) {
                         if (!wav_readfmt(fd, csize, par, renc))                          if (!wav_readfmt(fd, csize, par, map))
                                 return 0;                                  return 0;
                         fmt_done = 1;                          fmt_done = 1;
                 } else if (memcmp(chunk.id, wav_id_data, 4) == 0) {                  } else if (memcmp(chunk.id, wav_id_data, 4) == 0) {

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6