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/demac/libdemac/parser.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/demac/libdemac/parser.h')
-rw-r--r-- | lib/rbcodec/codecs/demac/libdemac/parser.h | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/demac/libdemac/parser.h b/lib/rbcodec/codecs/demac/libdemac/parser.h new file mode 100644 index 0000000000..6f07deac12 --- /dev/null +++ b/lib/rbcodec/codecs/demac/libdemac/parser.h | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | |||
3 | libdemac - A Monkey's Audio decoder | ||
4 | |||
5 | $Id$ | ||
6 | |||
7 | Copyright (C) Dave Chapman 2007 | ||
8 | |||
9 | This program is free software; you can redistribute it and/or modify | ||
10 | it under the terms of the GNU General Public License as published by | ||
11 | the Free Software Foundation; either version 2 of the License, or | ||
12 | (at your option) any later version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, | ||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | ||
18 | |||
19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program; if not, write to the Free Software | ||
21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA | ||
22 | |||
23 | */ | ||
24 | |||
25 | #ifndef _APE_PARSER_H | ||
26 | #define _APE_PARSER_H | ||
27 | |||
28 | #include <inttypes.h> | ||
29 | #include "demac_config.h" | ||
30 | |||
31 | /* The earliest and latest file formats supported by this library */ | ||
32 | #define APE_MIN_VERSION 3970 | ||
33 | #define APE_MAX_VERSION 3990 | ||
34 | |||
35 | #define MAC_FORMAT_FLAG_8_BIT 1 // is 8-bit [OBSOLETE] | ||
36 | #define MAC_FORMAT_FLAG_CRC 2 // uses the new CRC32 error detection [OBSOLETE] | ||
37 | #define MAC_FORMAT_FLAG_HAS_PEAK_LEVEL 4 // uint32 nPeakLevel after the header [OBSOLETE] | ||
38 | #define MAC_FORMAT_FLAG_24_BIT 8 // is 24-bit [OBSOLETE] | ||
39 | #define MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS 16 // has the number of seek elements after the peak level | ||
40 | #define MAC_FORMAT_FLAG_CREATE_WAV_HEADER 32 // create the wave header on decompression (not stored) | ||
41 | |||
42 | |||
43 | /* Special frame codes: | ||
44 | |||
45 | MONO_SILENCE - All PCM samples in frame are zero (mono streams only) | ||
46 | LEFT_SILENCE - All PCM samples for left channel in frame are zero (stereo streams) | ||
47 | RIGHT_SILENCE - All PCM samples for left channel in frame are zero (stereo streams) | ||
48 | PSEUDO_STEREO - Left and Right channels are identical | ||
49 | |||
50 | */ | ||
51 | |||
52 | #define APE_FRAMECODE_MONO_SILENCE 1 | ||
53 | #define APE_FRAMECODE_LEFT_SILENCE 1 /* same as mono */ | ||
54 | #define APE_FRAMECODE_RIGHT_SILENCE 2 | ||
55 | #define APE_FRAMECODE_STEREO_SILENCE 3 /* combined */ | ||
56 | #define APE_FRAMECODE_PSEUDO_STEREO 4 | ||
57 | |||
58 | #define PREDICTOR_ORDER 8 | ||
59 | /* Total size of all predictor histories - 50 * sizeof(int32_t) */ | ||
60 | #define PREDICTOR_SIZE 50 | ||
61 | |||
62 | |||
63 | /* NOTE: This struct is used in predictor-arm.S - any updates need to | ||
64 | be reflected there. */ | ||
65 | |||
66 | struct predictor_t | ||
67 | { | ||
68 | /* Filter histories */ | ||
69 | int32_t* buf; | ||
70 | |||
71 | int32_t YlastA; | ||
72 | int32_t XlastA; | ||
73 | |||
74 | /* NOTE: The order of the next four fields is important for | ||
75 | predictor-arm.S */ | ||
76 | int32_t YfilterB; | ||
77 | int32_t XfilterA; | ||
78 | int32_t XfilterB; | ||
79 | int32_t YfilterA; | ||
80 | |||
81 | /* Adaption co-efficients */ | ||
82 | int32_t YcoeffsA[4]; | ||
83 | int32_t XcoeffsA[4]; | ||
84 | int32_t YcoeffsB[5]; | ||
85 | int32_t XcoeffsB[5]; | ||
86 | int32_t historybuffer[PREDICTOR_HISTORY_SIZE + PREDICTOR_SIZE]; | ||
87 | }; | ||
88 | |||
89 | struct ape_ctx_t | ||
90 | { | ||
91 | /* Derived fields */ | ||
92 | uint32_t junklength; | ||
93 | uint32_t firstframe; | ||
94 | uint32_t totalsamples; | ||
95 | |||
96 | /* Info from Descriptor Block */ | ||
97 | char magic[4]; | ||
98 | int16_t fileversion; | ||
99 | int16_t padding1; | ||
100 | uint32_t descriptorlength; | ||
101 | uint32_t headerlength; | ||
102 | uint32_t seektablelength; | ||
103 | uint32_t wavheaderlength; | ||
104 | uint32_t audiodatalength; | ||
105 | uint32_t audiodatalength_high; | ||
106 | uint32_t wavtaillength; | ||
107 | uint8_t md5[16]; | ||
108 | |||
109 | /* Info from Header Block */ | ||
110 | uint16_t compressiontype; | ||
111 | uint16_t formatflags; | ||
112 | uint32_t blocksperframe; | ||
113 | uint32_t finalframeblocks; | ||
114 | uint32_t totalframes; | ||
115 | uint16_t bps; | ||
116 | uint16_t channels; | ||
117 | uint32_t samplerate; | ||
118 | |||
119 | /* Seektable */ | ||
120 | uint32_t* seektable; /* Seektable buffer */ | ||
121 | uint32_t maxseekpoints; /* Max seekpoints we can store (size of seektable buffer) */ | ||
122 | uint32_t numseekpoints; /* Number of seekpoints */ | ||
123 | int seektablefilepos; /* Location in .ape file of seektable */ | ||
124 | |||
125 | /* Decoder state */ | ||
126 | uint32_t CRC; | ||
127 | int frameflags; | ||
128 | int currentframeblocks; | ||
129 | int blocksdecoded; | ||
130 | struct predictor_t predictor; | ||
131 | }; | ||
132 | |||
133 | int ape_parseheader(int fd, struct ape_ctx_t* ape_ctx); | ||
134 | int ape_parseheaderbuf(unsigned char* buf, struct ape_ctx_t* ape_ctx); | ||
135 | void ape_dumpinfo(struct ape_ctx_t* ape_ctx); | ||
136 | |||
137 | #endif | ||