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/frame.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/frame.h')
-rw-r--r-- | lib/rbcodec/codecs/libmad/frame.h | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libmad/frame.h b/lib/rbcodec/codecs/libmad/frame.h new file mode 100644 index 0000000000..b1c6e0289d --- /dev/null +++ b/lib/rbcodec/codecs/libmad/frame.h | |||
@@ -0,0 +1,124 @@ | |||
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_FRAME_H | ||
23 | # define LIBMAD_FRAME_H | ||
24 | |||
25 | # include "fixed.h" | ||
26 | # include "timer.h" | ||
27 | # include "stream.h" | ||
28 | |||
29 | enum mad_layer { | ||
30 | MAD_LAYER_I = 1, /* Layer I */ | ||
31 | MAD_LAYER_II = 2, /* Layer II */ | ||
32 | MAD_LAYER_III = 3 /* Layer III */ | ||
33 | }; | ||
34 | |||
35 | enum mad_mode { | ||
36 | MAD_MODE_SINGLE_CHANNEL = 0, /* single channel */ | ||
37 | MAD_MODE_DUAL_CHANNEL = 1, /* dual channel */ | ||
38 | MAD_MODE_JOINT_STEREO = 2, /* joint (MS/intensity) stereo */ | ||
39 | MAD_MODE_STEREO = 3 /* normal LR stereo */ | ||
40 | }; | ||
41 | |||
42 | enum mad_emphasis { | ||
43 | MAD_EMPHASIS_NONE = 0, /* no emphasis */ | ||
44 | MAD_EMPHASIS_50_15_US = 1, /* 50/15 microseconds emphasis */ | ||
45 | MAD_EMPHASIS_CCITT_J_17 = 3, /* CCITT J.17 emphasis */ | ||
46 | MAD_EMPHASIS_RESERVED = 2 /* unknown emphasis */ | ||
47 | }; | ||
48 | |||
49 | struct mad_header { | ||
50 | enum mad_layer layer; /* audio layer (1, 2, or 3) */ | ||
51 | enum mad_mode mode; /* channel mode (see above) */ | ||
52 | int mode_extension; /* additional mode info */ | ||
53 | enum mad_emphasis emphasis; /* de-emphasis to use (see above) */ | ||
54 | |||
55 | unsigned long bitrate; /* stream bitrate (bps) */ | ||
56 | unsigned int samplerate; /* sampling frequency (Hz) */ | ||
57 | |||
58 | unsigned short crc_check; /* frame CRC accumulator */ | ||
59 | unsigned short crc_target; /* final target CRC checksum */ | ||
60 | |||
61 | int flags; /* flags (see below) */ | ||
62 | int private_bits; /* private bits (see below) */ | ||
63 | |||
64 | #if 0 /* rockbox: not used */ | ||
65 | mad_timer_t duration; /* audio playing time of frame */ | ||
66 | #endif | ||
67 | }; | ||
68 | |||
69 | struct mad_frame { | ||
70 | struct mad_header header; /* MPEG audio header */ | ||
71 | int options; /* decoding options (from stream) */ | ||
72 | |||
73 | mad_fixed_t (*sbsample)[2][36][32] MEM_ALIGN_ATTR; /* synthesis subband filter samples */ | ||
74 | mad_fixed_t (*sbsample_prev)[2][36][32] MEM_ALIGN_ATTR; /* synthesis subband filter samples | ||
75 | from previous frame only needed | ||
76 | when synthesis is on cop */ | ||
77 | |||
78 | mad_fixed_t (*overlap)[2][32][18] MEM_ALIGN_ATTR; /* Layer III block overlap data */ | ||
79 | }; | ||
80 | |||
81 | # define MAD_NCHANNELS(header) ((header)->mode ? 2 : 1) | ||
82 | # define MAD_NSBSAMPLES(header) \ | ||
83 | ((header)->layer == MAD_LAYER_I ? 12 : \ | ||
84 | (((header)->layer == MAD_LAYER_III && \ | ||
85 | ((header)->flags & MAD_FLAG_LSF_EXT)) ? 18 : 36)) | ||
86 | |||
87 | enum { | ||
88 | MAD_FLAG_NPRIVATE_III = 0x0007, /* number of Layer III private bits */ | ||
89 | MAD_FLAG_INCOMPLETE = 0x0008, /* header but not data is decoded */ | ||
90 | |||
91 | MAD_FLAG_PROTECTION = 0x0010, /* frame has CRC protection */ | ||
92 | MAD_FLAG_COPYRIGHT = 0x0020, /* frame is copyright */ | ||
93 | MAD_FLAG_ORIGINAL = 0x0040, /* frame is original (else copy) */ | ||
94 | MAD_FLAG_PADDING = 0x0080, /* frame has additional slot */ | ||
95 | |||
96 | MAD_FLAG_I_STEREO = 0x0100, /* uses intensity joint stereo */ | ||
97 | MAD_FLAG_MS_STEREO = 0x0200, /* uses middle/side joint stereo */ | ||
98 | MAD_FLAG_FREEFORMAT = 0x0400, /* uses free format bitrate */ | ||
99 | |||
100 | MAD_FLAG_LSF_EXT = 0x1000, /* lower sampling freq. extension */ | ||
101 | MAD_FLAG_MC_EXT = 0x2000, /* multichannel audio extension */ | ||
102 | MAD_FLAG_MPEG_2_5_EXT = 0x4000 /* MPEG 2.5 (unofficial) extension */ | ||
103 | }; | ||
104 | |||
105 | enum { | ||
106 | MAD_PRIVATE_HEADER = 0x0100, /* header private bit */ | ||
107 | MAD_PRIVATE_III = 0x001f /* Layer III private bits (up to 5) */ | ||
108 | }; | ||
109 | |||
110 | void mad_header_init(struct mad_header *); | ||
111 | |||
112 | # define mad_header_finish(header) /* nothing */ | ||
113 | |||
114 | int mad_header_decode(struct mad_header *, struct mad_stream *); | ||
115 | |||
116 | void mad_frame_init(struct mad_frame *); | ||
117 | /* rockbox: not used | ||
118 | void mad_frame_finish(struct mad_frame *);*/ | ||
119 | |||
120 | int mad_frame_decode(struct mad_frame *, struct mad_stream *); | ||
121 | |||
122 | void mad_frame_mute(struct mad_frame *); | ||
123 | |||
124 | # endif | ||