diff options
Diffstat (limited to 'apps/codecs/libpcm/pcm_common.h')
-rw-r--r-- | apps/codecs/libpcm/pcm_common.h | 77 |
1 files changed, 72 insertions, 5 deletions
diff --git a/apps/codecs/libpcm/pcm_common.h b/apps/codecs/libpcm/pcm_common.h index 757d0ad5d9..d490a85e9f 100644 --- a/apps/codecs/libpcm/pcm_common.h +++ b/apps/codecs/libpcm/pcm_common.h | |||
@@ -18,8 +18,8 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #ifndef CODEC_LIBPCMS_PCM_COMMON_H | 21 | #ifndef CODEC_LIBPCM_PCM_COMMON_H |
22 | #define CODEC_LIBPCMS_PCM_COMMON_H | 22 | #define CODEC_LIBPCM_PCM_COMMON_H |
23 | 23 | ||
24 | #include <sys/types.h> | 24 | #include <sys/types.h> |
25 | #include <stdbool.h> | 25 | #include <stdbool.h> |
@@ -38,6 +38,19 @@ | |||
38 | /* Macro that shift to -0x80. (0 .. 127 to -128 .. -1, 128 .. 255 to 0 .. 127) */ | 38 | /* Macro that shift to -0x80. (0 .. 127 to -128 .. -1, 128 .. 255 to 0 .. 127) */ |
39 | #define SFT(x) ((int32_t)x-0x80) | 39 | #define SFT(x) ((int32_t)x-0x80) |
40 | 40 | ||
41 | /* Macro that clipping data */ | ||
42 | #define CLIP(data, min, max) \ | ||
43 | if ((data) > (max)) data = max; \ | ||
44 | else if ((data) < (min)) data = min; | ||
45 | |||
46 | /* nums of msadpcm coeffs | ||
47 | * In many case, nNumCoef is 7. | ||
48 | * Depending upon the encoder, as for this value there is a possibility | ||
49 | * of increasing more. | ||
50 | * If you found the file where this value exceeds 7, please report. | ||
51 | */ | ||
52 | #define MSADPCM_NUM_COEFF 7 | ||
53 | |||
41 | struct pcm_format { | 54 | struct pcm_format { |
42 | /* | 55 | /* |
43 | * RIFF: wFormatTag (in 'fmt ' chunk) | 56 | * RIFF: wFormatTag (in 'fmt ' chunk) |
@@ -103,13 +116,67 @@ struct pcm_format { | |||
103 | * true: signed, false: unsigned | 116 | * true: signed, false: unsigned |
104 | */ | 117 | */ |
105 | bool is_signed; | 118 | bool is_signed; |
119 | |||
120 | /* the following values are format speciffic parameters */ | ||
121 | |||
122 | /* microsoft adpcm: aCoeff */ | ||
123 | int16_t coeffs[MSADPCM_NUM_COEFF][2]; | ||
124 | }; | ||
125 | |||
126 | struct pcm_pos { | ||
127 | uint32_t pos; | ||
128 | uint32_t samples; | ||
106 | }; | 129 | }; |
107 | 130 | ||
108 | struct pcm_codec { | 131 | struct pcm_codec { |
109 | bool (*set_format)(struct pcm_format *format, const unsigned char *fmtpos); | 132 | /* |
110 | uint32_t (*get_seek_pos)(long seek_time); | 133 | * sets the format speciffic RIFF/AIFF header information and checks the pcm_format. |
134 | * | ||
135 | * [In/Out] format | ||
136 | * the structure which supplies RIFF/AIFF header information. | ||
137 | * | ||
138 | * return | ||
139 | * true: RIFF/AIFF header check OK | ||
140 | * false: RIFF/AIFF header check NG | ||
141 | */ | ||
142 | bool (*set_format)(struct pcm_format *format); | ||
143 | |||
144 | /* | ||
145 | * get seek position | ||
146 | * | ||
147 | * [In] seek_time | ||
148 | * seek time [ms] | ||
149 | * | ||
150 | * [In] read_buffer | ||
151 | * the function which reads the data from the file (chunksize bytes read). | ||
152 | * | ||
153 | * return | ||
154 | * position after the seeking. | ||
155 | */ | ||
156 | struct pcm_pos *(*get_seek_pos)(long seek_time, | ||
157 | uint8_t *(*read_buffer)(size_t *realsize)); | ||
158 | |||
159 | /* | ||
160 | * decode wave data. | ||
161 | * | ||
162 | * [In] inbuf | ||
163 | * the start pointer of wave data buffer. | ||
164 | * | ||
165 | * [In] inbufsize | ||
166 | * wave data buffer size (bytes). | ||
167 | * | ||
168 | * [Out] outbuf | ||
169 | * the start pointer of the buffer which supplies decoded pcm data. | ||
170 | * | ||
171 | * [Out] outbufcount | ||
172 | * decoded pcm data count. | ||
173 | * | ||
174 | * return | ||
175 | * CODEC_OK: decode succeed. | ||
176 | * CODEC_ERROR: decode failure. | ||
177 | */ | ||
111 | int (*decode)(const uint8_t *inbuf, size_t inbufsize, | 178 | int (*decode)(const uint8_t *inbuf, size_t inbufsize, |
112 | int32_t *outbuf, int *outbufsize); | 179 | int32_t *outbuf, int *outbufcount); |
113 | }; | 180 | }; |
114 | 181 | ||
115 | struct pcm_entry { | 182 | struct pcm_entry { |