FS#8961 - Anti-Aliased Fonts.
[kugel-rb/myfork.git] / apps / codecs / demac / libdemac / parser.h
blob6f07deac12de70bd2402d4bf7b98d7eadba229ca
1 /*
3 libdemac - A Monkey's Audio decoder
5 $Id$
7 Copyright (C) Dave Chapman 2007
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.
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.
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
25 #ifndef _APE_PARSER_H
26 #define _APE_PARSER_H
28 #include <inttypes.h>
29 #include "demac_config.h"
31 /* The earliest and latest file formats supported by this library */
32 #define APE_MIN_VERSION 3970
33 #define APE_MAX_VERSION 3990
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)
43 /* Special frame codes:
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
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
58 #define PREDICTOR_ORDER 8
59 /* Total size of all predictor histories - 50 * sizeof(int32_t) */
60 #define PREDICTOR_SIZE 50
63 /* NOTE: This struct is used in predictor-arm.S - any updates need to
64 be reflected there. */
66 struct predictor_t
68 /* Filter histories */
69 int32_t* buf;
71 int32_t YlastA;
72 int32_t XlastA;
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;
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];
89 struct ape_ctx_t
91 /* Derived fields */
92 uint32_t junklength;
93 uint32_t firstframe;
94 uint32_t totalsamples;
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];
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;
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 */
125 /* Decoder state */
126 uint32_t CRC;
127 int frameflags;
128 int currentframeblocks;
129 int blocksdecoded;
130 struct predictor_t predictor;
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);
137 #endif