e5dc49e2ff4230d5e8c34545287e1fe0e9407c6b
[Faustine.git] / interpretor / lib / src / libsndfile-1.0.25 / src / raw.c
1 /*
2 ** Copyright (C) 1999-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
3 **
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU Lesser General Public License as published by
6 ** the Free Software Foundation; either version 2.1 of the License, or
7 ** (at your option) any later version.
8 **
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include "sfconfig.h"
20
21 #include <stdio.h>
22
23 #include "sndfile.h"
24 #include "common.h"
25
26 /*------------------------------------------------------------------------------
27 ** Public function.
28 */
29
30 int
31 raw_open (SF_PRIVATE *psf)
32 { int subformat, error = SFE_NO_ERROR ;
33
34 subformat = SF_CODEC (psf->sf.format) ;
35
36 psf->endian = SF_ENDIAN (psf->sf.format) ;
37
38 if (CPU_IS_BIG_ENDIAN && (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU))
39 psf->endian = SF_ENDIAN_BIG ;
40 else if (CPU_IS_LITTLE_ENDIAN && (psf->endian == 0 || psf->endian == SF_ENDIAN_CPU))
41 psf->endian = SF_ENDIAN_LITTLE ;
42
43 psf->blockwidth = psf->bytewidth * psf->sf.channels ;
44 psf->dataoffset = 0 ;
45 psf->datalength = psf->filelength ;
46
47 switch (subformat)
48 { case SF_FORMAT_PCM_S8 :
49 error = pcm_init (psf) ;
50 break ;
51
52 case SF_FORMAT_PCM_U8 :
53 error = pcm_init (psf) ;
54 break ;
55
56 case SF_FORMAT_PCM_16 :
57 case SF_FORMAT_PCM_24 :
58 case SF_FORMAT_PCM_32 :
59 error = pcm_init (psf) ;
60 break ;
61
62 case SF_FORMAT_ULAW :
63 error = ulaw_init (psf) ;
64 break ;
65
66 case SF_FORMAT_ALAW :
67 error = alaw_init (psf) ;
68 break ;
69
70 case SF_FORMAT_GSM610 :
71 error = gsm610_init (psf) ;
72 break ;
73
74 /* Lite remove start */
75 case SF_FORMAT_FLOAT :
76 error = float32_init (psf) ;
77 break ;
78
79 case SF_FORMAT_DOUBLE :
80 error = double64_init (psf) ;
81 break ;
82
83 case SF_FORMAT_DWVW_12 :
84 error = dwvw_init (psf, 12) ;
85 break ;
86
87 case SF_FORMAT_DWVW_16 :
88 error = dwvw_init (psf, 16) ;
89 break ;
90
91 case SF_FORMAT_DWVW_24 :
92 error = dwvw_init (psf, 24) ;
93 break ;
94
95 case SF_FORMAT_VOX_ADPCM :
96 error = vox_adpcm_init (psf) ;
97 break ;
98 /* Lite remove end */
99
100 default : return SFE_BAD_OPEN_FORMAT ;
101 } ;
102
103 return error ;
104 } /* raw_open */