diff options
author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-06-25 21:32:25 -0400 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-04-25 22:13:20 +0200 |
commit | f40bfc9267b13b54e6379dfe7539447662879d24 (patch) | |
tree | 9b20069d5e62809ff434061ad730096836f916f2 /lib/rbcodec/codecs/libmad/stream.h | |
parent | a0009907de7a0107d49040d8a180f140e2eff299 (diff) | |
download | rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.gz rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.zip |
Add codecs to librbcodec.
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97
Reviewed-on: http://gerrit.rockbox.org/137
Reviewed-by: Nils Wallménius <nils@rockbox.org>
Tested-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'lib/rbcodec/codecs/libmad/stream.h')
-rw-r--r-- | lib/rbcodec/codecs/libmad/stream.h | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libmad/stream.h b/lib/rbcodec/codecs/libmad/stream.h new file mode 100644 index 0000000000..0aafb98787 --- /dev/null +++ b/lib/rbcodec/codecs/libmad/stream.h | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * libmad - MPEG audio decoder library | ||
3 | * Copyright (C) 2000-2004 Underbit Technologies, Inc. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License as published by | ||
7 | * the Free Software Foundation; either version 2 of the License, or | ||
8 | * (at your option) any later version. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | * | ||
19 | * $Id$ | ||
20 | */ | ||
21 | |||
22 | # ifndef LIBMAD_STREAM_H | ||
23 | # define LIBMAD_STREAM_H | ||
24 | |||
25 | # include "bit.h" | ||
26 | |||
27 | # define MAD_BUFFER_GUARD 8 | ||
28 | # define MAD_BUFFER_MDLEN (511 + 2048 + MAD_BUFFER_GUARD) | ||
29 | |||
30 | enum mad_error { | ||
31 | MAD_ERROR_NONE = 0x0000, /* no error */ | ||
32 | |||
33 | MAD_ERROR_BUFLEN = 0x0001, /* input buffer too small (or EOF) */ | ||
34 | MAD_ERROR_BUFPTR = 0x0002, /* invalid (null) buffer pointer */ | ||
35 | |||
36 | MAD_ERROR_NOMEM = 0x0031, /* not enough memory */ | ||
37 | |||
38 | MAD_ERROR_LOSTSYNC = 0x0101, /* lost synchronization */ | ||
39 | MAD_ERROR_BADLAYER = 0x0102, /* reserved header layer value */ | ||
40 | MAD_ERROR_BADBITRATE = 0x0103, /* forbidden bitrate value */ | ||
41 | MAD_ERROR_BADSAMPLERATE = 0x0104, /* reserved sample frequency value */ | ||
42 | MAD_ERROR_BADEMPHASIS = 0x0105, /* reserved emphasis value */ | ||
43 | |||
44 | MAD_ERROR_BADCRC = 0x0201, /* CRC check failed */ | ||
45 | MAD_ERROR_BADBITALLOC = 0x0211, /* forbidden bit allocation value */ | ||
46 | MAD_ERROR_BADSCALEFACTOR = 0x0221, /* bad scalefactor index */ | ||
47 | MAD_ERROR_BADMODE = 0x0222, /* bad bitrate/mode combination */ | ||
48 | MAD_ERROR_BADFRAMELEN = 0x0231, /* bad frame length */ | ||
49 | MAD_ERROR_BADBIGVALUES = 0x0232, /* bad big_values count */ | ||
50 | MAD_ERROR_BADBLOCKTYPE = 0x0233, /* reserved block_type */ | ||
51 | MAD_ERROR_BADSCFSI = 0x0234, /* bad scalefactor selection info */ | ||
52 | MAD_ERROR_BADDATAPTR = 0x0235, /* bad main_data_begin pointer */ | ||
53 | MAD_ERROR_BADPART3LEN = 0x0236, /* bad audio data length */ | ||
54 | MAD_ERROR_BADHUFFTABLE = 0x0237, /* bad Huffman table select */ | ||
55 | MAD_ERROR_BADHUFFDATA = 0x0238, /* Huffman data overrun */ | ||
56 | MAD_ERROR_BADSTEREO = 0x0239 /* incompatible block_type for JS */ | ||
57 | }; | ||
58 | |||
59 | # define MAD_RECOVERABLE(error) ((error) & 0xff00) | ||
60 | |||
61 | struct mad_stream { | ||
62 | unsigned char const *buffer; /* input bitstream buffer */ | ||
63 | unsigned char const *bufend; /* end of buffer */ | ||
64 | /* rockbox: not used | ||
65 | unsigned long skiplen; */ /* bytes to skip before next frame */ | ||
66 | |||
67 | int sync; /* stream sync found */ | ||
68 | unsigned long freerate; /* free bitrate (fixed) */ | ||
69 | |||
70 | unsigned char const *this_frame; /* start of current frame */ | ||
71 | unsigned char const *next_frame; /* start of next frame */ | ||
72 | struct mad_bitptr ptr; /* current processing bit pointer */ | ||
73 | |||
74 | struct mad_bitptr anc_ptr; /* ancillary bits pointer */ | ||
75 | unsigned int anc_bitlen; /* number of ancillary bits */ | ||
76 | |||
77 | unsigned char (*main_data)[MAD_BUFFER_MDLEN] MEM_ALIGN_ATTR; | ||
78 | /* Layer III main_data() */ | ||
79 | unsigned int md_len; /* bytes in main_data */ | ||
80 | |||
81 | int options; /* decoding options (see below) */ | ||
82 | enum mad_error error; /* error code (see above) */ | ||
83 | }; | ||
84 | |||
85 | enum { | ||
86 | MAD_OPTION_IGNORECRC = 0x0001, /* ignore CRC errors */ | ||
87 | # if 0 /* rockbox: unused */ | ||
88 | MAD_OPTION_HALFSAMPLERATE = 0x0002 /* generate PCM at 1/2 sample rate */ | ||
89 | # endif | ||
90 | # if 0 /* not yet implemented */ | ||
91 | MAD_OPTION_LEFTCHANNEL = 0x0010, /* decode left channel only */ | ||
92 | MAD_OPTION_RIGHTCHANNEL = 0x0020, /* decode right channel only */ | ||
93 | MAD_OPTION_SINGLECHANNEL = 0x0030 /* combine channels */ | ||
94 | # endif | ||
95 | }; | ||
96 | |||
97 | void mad_stream_init(struct mad_stream *); | ||
98 | /* rockbox: not used | ||
99 | void mad_stream_finish(struct mad_stream *); */ | ||
100 | |||
101 | # define mad_stream_options(stream, opts) \ | ||
102 | ((void) ((stream)->options = (opts))) | ||
103 | |||
104 | void mad_stream_buffer(struct mad_stream *, | ||
105 | unsigned char const *, unsigned long); | ||
106 | /* rockbox: not used | ||
107 | void mad_stream_skip(struct mad_stream *, unsigned long); */ | ||
108 | |||
109 | int mad_stream_sync(struct mad_stream *); | ||
110 | |||
111 | char const *mad_stream_errorstr(struct mad_stream const *); | ||
112 | |||
113 | # endif | ||