Mercurial > audlegacy-plugins
comparison src/shnplug/shn.h @ 1305:51bf0e431e02
Add SHNplug.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 20 Jul 2007 10:29:54 -0500 |
parents | |
children | 194c2f8c2a92 |
comparison
equal
deleted
inserted
replaced
1300:c198ae31bb74 | 1305:51bf0e431e02 |
---|---|
1 /* xmms-shn - a shorten (.shn) plugin for XMMS | |
2 * Copyright (C) 2000-2007 Jason Jordan <shnutils@freeshell.org> | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 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 General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU 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 /* | |
20 * $Id: shn.h,v 1.27 2007/03/23 05:49:48 jason Exp $ | |
21 */ | |
22 | |
23 #ifndef _SHN_H | |
24 #define _SHN_H | |
25 | |
26 #include <pthread.h> | |
27 | |
28 #include <stdlib.h> | |
29 #include <string.h> | |
30 #include <stdio.h> | |
31 #include <unistd.h> | |
32 #include <sys/stat.h> | |
33 | |
34 #include <audacious/plugin.h> | |
35 #include <audacious/vfs.h> | |
36 | |
37 #ifdef HAVE_CONFIG_H | |
38 #include "config.h" | |
39 #endif | |
40 | |
41 #define shn_vsnprintf(a,b,c,d) vsnprintf(a,b,c,d) | |
42 | |
43 #define min(a,b) (((a)<(b))?(a):(b)) | |
44 | |
45 #define XMMS_SHN_VERSION_TAG "xmms-shn_v2" | |
46 | |
47 /* surely no headers will be this large. right? RIGHT? */ | |
48 #define OUT_BUFFER_SIZE 16384 | |
49 | |
50 #define BUF_SIZE 4096 | |
51 | |
52 #define ERROR_OUTPUT_DEVNULL 0 | |
53 #define ERROR_OUTPUT_STDERR 1 | |
54 #define ERROR_OUTPUT_WINDOW 2 | |
55 | |
56 #define SEEK_SUFFIX "skt" | |
57 | |
58 #define NO_SEEK_TABLE -1 | |
59 | |
60 #define SEEK_HEADER_SIGNATURE "SEEK" | |
61 #define SEEK_TRAILER_SIGNATURE "SHNAMPSK" | |
62 | |
63 #define SEEK_HEADER_SIZE 12 | |
64 #define SEEK_TRAILER_SIZE 12 | |
65 #define SEEK_ENTRY_SIZE 80 | |
66 #define SEEK_RESOLUTION 25600 | |
67 | |
68 #define WAVE_RIFF (0x46464952) /* 'RIFF' in little-endian */ | |
69 #define WAVE_WAVE (0x45564157) /* 'WAVE' in little-endian */ | |
70 #define WAVE_FMT (0x20746d66) /* ' fmt' in little-endian */ | |
71 #define WAVE_DATA (0x61746164) /* 'data' in little-endian */ | |
72 | |
73 #define AIFF_FORM (0x4D524F46) /* 'FORM' in little-endian */ | |
74 | |
75 #define WAVE_FORMAT_UNKNOWN (0x0000) | |
76 #define WAVE_FORMAT_PCM (0x0001) | |
77 #define WAVE_FORMAT_ADPCM (0x0002) | |
78 #define WAVE_FORMAT_IEEE_FLOAT (0x0003) | |
79 #define WAVE_FORMAT_ALAW (0x0006) | |
80 #define WAVE_FORMAT_MULAW (0x0007) | |
81 #define WAVE_FORMAT_OKI_ADPCM (0x0010) | |
82 #define WAVE_FORMAT_IMA_ADPCM (0x0011) | |
83 #define WAVE_FORMAT_DIGISTD (0x0015) | |
84 #define WAVE_FORMAT_DIGIFIX (0x0016) | |
85 #define WAVE_FORMAT_DOLBY_AC2 (0x0030) | |
86 #define WAVE_FORMAT_GSM610 (0x0031) | |
87 #define WAVE_FORMAT_ROCKWELL_ADPCM (0x003b) | |
88 #define WAVE_FORMAT_ROCKWELL_DIGITALK (0x003c) | |
89 #define WAVE_FORMAT_G721_ADPCM (0x0040) | |
90 #define WAVE_FORMAT_G728_CELP (0x0041) | |
91 #define WAVE_FORMAT_MPEG (0x0050) | |
92 #define WAVE_FORMAT_MPEGLAYER3 (0x0055) | |
93 #define WAVE_FORMAT_G726_ADPCM (0x0064) | |
94 #define WAVE_FORMAT_G722_ADPCM (0x0065) | |
95 | |
96 #define CD_BLOCK_SIZE (2352) | |
97 #define CD_BLOCKS_PER_SEC (75) | |
98 #define CD_MIN_BURNABLE_SIZE (705600) | |
99 #define CD_CHANNELS (2) | |
100 #define CD_SAMPLES_PER_SEC (44100) | |
101 #define CD_BITS_PER_SAMPLE (16) | |
102 #define CD_RATE (176400) | |
103 | |
104 #define CANONICAL_HEADER_SIZE (44) | |
105 | |
106 #define PROBLEM_NOT_CD_QUALITY (0x00000001) | |
107 #define PROBLEM_CD_BUT_BAD_BOUND (0x00000002) | |
108 #define PROBLEM_CD_BUT_TOO_SHORT (0x00000004) | |
109 #define PROBLEM_HEADER_NOT_CANONICAL (0x00000008) | |
110 #define PROBLEM_EXTRA_CHUNKS (0x00000010) | |
111 #define PROBLEM_HEADER_INCONSISTENT (0x00000020) | |
112 | |
113 #define PROB_NOT_CD(f) ((f.problems) & (PROBLEM_NOT_CD_QUALITY)) | |
114 #define PROB_BAD_BOUND(f) ((f.problems) & (PROBLEM_CD_BUT_BAD_BOUND)) | |
115 #define PROB_TOO_SHORT(f) ((f.problems) & (PROBLEM_CD_BUT_TOO_SHORT)) | |
116 #define PROB_HDR_NOT_CANONICAL(f) ((f.problems) & (PROBLEM_HEADER_NOT_CANONICAL)) | |
117 #define PROB_EXTRA_CHUNKS(f) ((f.problems) & (PROBLEM_EXTRA_CHUNKS)) | |
118 #define PROB_HDR_INCONSISTENT(f) ((f.problems) & (PROBLEM_HEADER_INCONSISTENT)) | |
119 | |
120 typedef struct _shn_config | |
121 { | |
122 gint error_output_method; | |
123 gchar *error_output_method_config_name; | |
124 gchar *seek_tables_path; | |
125 gchar *seek_tables_path_config_name; | |
126 gchar *relative_seek_tables_path; | |
127 gchar *relative_seek_tables_path_config_name; | |
128 gboolean verbose; | |
129 gchar *verbose_config_name; | |
130 gboolean swap_bytes; | |
131 gchar *swap_bytes_config_name; | |
132 gboolean load_textfiles; | |
133 gchar *load_textfiles_config_name; | |
134 gchar *textfile_extensions; | |
135 gchar *textfile_extensions_config_name; | |
136 } shn_config; | |
137 | |
138 typedef struct _shn_decode_state | |
139 { | |
140 uchar *getbuf; | |
141 uchar *getbufp; | |
142 int nbitget; | |
143 int nbyteget; | |
144 ulong gbuffer; | |
145 schar *writebuf; | |
146 schar *writefub; | |
147 int nwritebuf; | |
148 } shn_decode_state; | |
149 | |
150 typedef struct _shn_seek_header | |
151 { | |
152 uchar data[SEEK_HEADER_SIZE]; | |
153 slong version; | |
154 ulong shnFileSize; | |
155 } shn_seek_header; | |
156 | |
157 typedef struct _shn_seek_trailer | |
158 { | |
159 uchar data[SEEK_TRAILER_SIZE]; | |
160 ulong seekTableSize; | |
161 } shn_seek_trailer; | |
162 | |
163 typedef struct _shn_seek_entry | |
164 { | |
165 uchar data[SEEK_ENTRY_SIZE]; | |
166 } shn_seek_entry; | |
167 | |
168 /* old way, kept for reference. | |
169 (changed because some compilers apparently don't support #pragma pack(1)) | |
170 | |
171 typedef struct _shn_seek_header | |
172 { | |
173 char signature[4]; | |
174 unsigned long version; | |
175 unsigned long shnFileSize; | |
176 } shn_seek_header; | |
177 | |
178 typedef struct _shn_seek_trailer | |
179 { | |
180 unsigned long seekTableSize; | |
181 char signature[8]; | |
182 } shn_seek_trailer; | |
183 | |
184 typedef struct _shn_seek_entry | |
185 { | |
186 unsigned long shnSample; | |
187 unsigned long shnByteOffset; | |
188 unsigned long shnLastPosition; | |
189 unsigned short shnByteGet; | |
190 unsigned short shnBufferOffset; | |
191 unsigned short shnBitOffset; | |
192 unsigned long shnGBuffer; | |
193 unsigned short shnBitShift; | |
194 long cbuf0[3]; | |
195 long cbuf1[3]; | |
196 long offset0[4]; | |
197 long offset1[4]; | |
198 } shn_seek_entry; | |
199 */ | |
200 | |
201 typedef struct _shn_wave_header | |
202 { | |
203 char *filename, | |
204 m_ss[16]; | |
205 | |
206 uint header_size; | |
207 | |
208 ushort channels, | |
209 block_align, | |
210 bits_per_sample, | |
211 wave_format; | |
212 | |
213 ulong samples_per_sec, | |
214 avg_bytes_per_sec, | |
215 rate, | |
216 length, | |
217 data_size, | |
218 total_size, | |
219 chunk_size, | |
220 actual_size; | |
221 | |
222 double exact_length; | |
223 | |
224 int file_has_id3v2_tag; | |
225 long id3v2_tag_size; | |
226 | |
227 ulong problems; | |
228 } shn_wave_header; | |
229 | |
230 typedef struct _shn_vars | |
231 { | |
232 VFSFile *fd; | |
233 int seek_to; | |
234 int eof; | |
235 int going; | |
236 slong seek_table_entries; | |
237 ulong seek_resolution; | |
238 int bytes_in_buf; | |
239 uchar buffer[OUT_BUFFER_SIZE]; | |
240 int bytes_in_header; | |
241 uchar header[OUT_BUFFER_SIZE]; | |
242 int fatal_error; | |
243 schar fatal_error_msg[BUF_SIZE]; | |
244 int reading_function_code; | |
245 ulong last_file_position; | |
246 ulong last_file_position_no_really; | |
247 ulong initial_file_position; | |
248 ulong bytes_read; | |
249 unsigned short actual_bitshift; | |
250 int actual_maxnlpc; | |
251 int actual_nmean; | |
252 int actual_nchan; | |
253 long seek_offset; | |
254 InputPlayback *playback; | |
255 } shn_vars; | |
256 | |
257 typedef struct _shn_file | |
258 { | |
259 shn_vars vars; | |
260 shn_decode_state *decode_state; | |
261 shn_wave_header wave_header; | |
262 shn_seek_header seek_header; | |
263 shn_seek_trailer seek_trailer; | |
264 shn_seek_entry *seek_table; | |
265 } shn_file; | |
266 | |
267 extern InputPlugin shn_ip; | |
268 extern shn_file *shnfile; | |
269 extern shn_config shn_cfg; | |
270 | |
271 extern shn_seek_entry *shn_seek_entry_search(shn_seek_entry *,ulong,ulong,ulong,ulong); | |
272 extern void shn_load_seek_table(shn_file *,char *); | |
273 extern void shn_unload(shn_file *); | |
274 extern void shn_display_about(void); | |
275 extern void shn_display_configure(void); | |
276 extern void shn_display_info(shn_file *); | |
277 extern int shn_verify_header(shn_file *); | |
278 extern int shn_filename_contains_a_dot(char *); | |
279 extern char *shn_get_base_filename(char *); | |
280 extern char *shn_get_base_directory(char *); | |
281 extern void shn_length_to_str(shn_file *); | |
282 extern ulong shn_uchar_to_ulong_le(uchar *); | |
283 extern slong shn_uchar_to_slong_le(uchar *); | |
284 extern ushort shn_uchar_to_ushort_le(uchar *); | |
285 extern char *shn_format_to_str(ushort); | |
286 extern void shn_message_box(char *); | |
287 extern void shn_debug(char *, ...); | |
288 extern void shn_error(char *, ...); | |
289 extern void shn_error_fatal(shn_file *,char *, ...); | |
290 extern void shn_snprintf(char *,int,char *, ...); | |
291 extern VFSFile *shn_open_and_discard_id3v2_tag(char *,int *,long *); | |
292 | |
293 #endif |