1305
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
1 /******************************************************************************
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
2 * *
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
3 * Copyright (C) 1992-1995 Tony Robinson *
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
4 * *
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
5 * See the file doc/LICENSE.shorten for conditions on distribution and usage *
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
6 * *
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
7 ******************************************************************************/
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
8
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
9 /*
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
10 * $Id: shorten.c,v 1.7 2003/08/26 05:34:04 jason Exp $
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
11 */
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
12
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
13 #include <math.h>
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
14 #include <stdio.h>
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
15 #include <stdlib.h>
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
16 #include <string.h>
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
17 #include <unistd.h>
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
18 #include <errno.h>
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
19 #include <setjmp.h>
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
20 #include "shorten.h"
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
21
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
22 void init_offset(slong **offset,int nchan,int nblock,int ftype)
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
23 {
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
24 slong mean = 0;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
25 int chan, i;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
26
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
27 /* initialise offset */
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
28 switch(ftype)
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
29 {
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
30 case TYPE_AU1:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
31 case TYPE_S8:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
32 case TYPE_S16HL:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
33 case TYPE_S16LH:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
34 case TYPE_ULAW:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
35 case TYPE_AU2:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
36 case TYPE_AU3:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
37 case TYPE_ALAW:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
38 mean = 0;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
39 break;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
40 case TYPE_U8:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
41 mean = 0x80;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
42 break;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
43 case TYPE_U16HL:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
44 case TYPE_U16LH:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
45 mean = 0x8000;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
46 break;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
47 default:
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
48 shn_debug("Unknown file type: %d", ftype);
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
49 }
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
50
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
51 for(chan = 0; chan < nchan; chan++)
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
52 for(i = 0; i < nblock; i++)
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
53 offset[chan][i] = mean;
|
William Pitcock <nenolod@atheme-project.org>
parents:
diff
changeset
|
54 }
|