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