/src/vlc/modules/packetizer/a52.h
Line | Count | Source (jump to first uncovered line) |
1 | | /***************************************************************************** |
2 | | * a52.h |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2001-2016 Laurent Aimar |
5 | | * |
6 | | * Authors: Stéphane Borel <stef@via.ecp.fr> |
7 | | * Christophe Massiot <massiot@via.ecp.fr> |
8 | | * Gildas Bazin <gbazin@videolan.org> |
9 | | * Laurent Aimar <fenrir@via.ecp.fr> |
10 | | * Thomas Guillem <thomas@gllm.fr> |
11 | | * |
12 | | * This program is free software; you can redistribute it and/or modify it |
13 | | * under the terms of the GNU Lesser General Public License as published by |
14 | | * the Free Software Foundation; either version 2.1 of the License, or |
15 | | * (at your option) any later version. |
16 | | * |
17 | | * This program is distributed in the hope that it will be useful, |
18 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | | * GNU Lesser General Public License for more details. |
21 | | * |
22 | | * You should have received a copy of the GNU Lesser General Public License |
23 | | * along with this program; if not, write to the Free Software Foundation, |
24 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
25 | | *****************************************************************************/ |
26 | | |
27 | | #ifndef VLC_A52_H_ |
28 | | #define VLC_A52_H_ |
29 | | |
30 | | #include <vlc_bits.h> |
31 | | |
32 | | /** |
33 | | * Minimum AC3 header size that vlc_a52_header_Parse needs. |
34 | | */ |
35 | 683k | #define VLC_A52_MIN_HEADER_SIZE (8) |
36 | | #define VLC_A52_EAC3_BSI_SIZE ((532 + 7)/8) |
37 | | #define VLC_A52_EAC3_HEADER_SIZE (VLC_A52_EAC3_BSI_SIZE + 2) |
38 | | |
39 | 537 | #define VLC_A52_PROFILE_EAC3_DEPENDENT 1 |
40 | | |
41 | | /** |
42 | | * AC3 header information. |
43 | | */ |
44 | | struct vlc_a52_bitstream_info |
45 | | { |
46 | | uint8_t i_fscod; |
47 | | uint8_t i_frmsizcod; |
48 | | uint8_t i_bsid; |
49 | | uint8_t i_bsmod; |
50 | | uint8_t i_acmod; |
51 | | uint8_t i_lfeon; |
52 | | union |
53 | | { |
54 | | struct { |
55 | | enum { |
56 | | EAC3_STRMTYP_INDEPENDENT = 0, |
57 | | EAC3_STRMTYP_DEPENDENT = 1, |
58 | | EAC3_STRMTYP_AC3_CONVERT = 2, |
59 | | EAC3_STRMTYP_RESERVED, |
60 | | } strmtyp; |
61 | | uint16_t i_frmsiz; |
62 | | uint8_t i_fscod2; |
63 | | uint8_t i_numblkscod; |
64 | | uint8_t i_substreamid; |
65 | | } eac3; |
66 | | struct |
67 | | { |
68 | | uint8_t i_dsurmod; |
69 | | } ac3; |
70 | | }; |
71 | | }; |
72 | | |
73 | | typedef struct |
74 | | { |
75 | | bool b_eac3; |
76 | | |
77 | | unsigned int i_channels; |
78 | | unsigned int i_channels_conf; |
79 | | unsigned int i_chan_mode; |
80 | | unsigned int i_rate; |
81 | | unsigned int i_bitrate; |
82 | | |
83 | | unsigned int i_size; |
84 | | unsigned int i_samples; |
85 | | |
86 | | struct vlc_a52_bitstream_info bs; |
87 | | |
88 | | uint8_t i_blocks_per_sync_frame; |
89 | | } vlc_a52_header_t; |
90 | | |
91 | | /** |
92 | | * It parse AC3 sync info. |
93 | | * |
94 | | * cf. AC3 spec |
95 | | */ |
96 | | static inline int vlc_a52_ParseAc3BitstreamInfo( struct vlc_a52_bitstream_info *bs, |
97 | | const uint8_t *p_buf, size_t i_buf ) |
98 | 6.07k | { |
99 | 6.07k | bs_t s; |
100 | 6.07k | bs_init( &s, p_buf, i_buf ); |
101 | | |
102 | | /* cf. 5.3.2 */ |
103 | 6.07k | bs->i_fscod = bs_read( &s, 2 ); |
104 | 6.07k | if( bs->i_fscod == 3 ) |
105 | 206 | return VLC_EGENERIC; |
106 | 5.86k | bs->i_frmsizcod = bs_read( &s, 6 ); |
107 | 5.86k | if( bs->i_frmsizcod >= 38 ) |
108 | 1.07k | return VLC_EGENERIC; |
109 | 4.79k | bs->i_bsid = bs_read( &s, 5 ); |
110 | 4.79k | bs->i_bsmod = bs_read( &s, 3 ); |
111 | 4.79k | bs->i_acmod = bs_read( &s, 3 ); |
112 | 4.79k | if( ( bs->i_acmod & 0x1 ) && ( bs->i_acmod != 0x1 ) ) |
113 | 3.78k | { |
114 | | /* if 3 front channels */ |
115 | 3.78k | bs_skip( &s, 2 ); /* i_cmixlev */ |
116 | 3.78k | } |
117 | 4.79k | if( bs->i_acmod & 0x4 ) |
118 | 3.42k | { |
119 | | /* if a surround channel exists */ |
120 | 3.42k | bs_skip( &s, 2 ); /* i_surmixlev */ |
121 | 3.42k | } |
122 | | /* if in 2/0 mode */ |
123 | 4.79k | bs->ac3.i_dsurmod = bs->i_acmod == 0x2 ? bs_read( &s, 2 ) : 0; |
124 | 4.79k | bs->i_lfeon = bs_read( &s, 1 ); |
125 | | |
126 | 4.79k | return VLC_SUCCESS; |
127 | 5.86k | } Unexecuted instantiation: es.c:vlc_a52_ParseAc3BitstreamInfo a52.c:vlc_a52_ParseAc3BitstreamInfo Line | Count | Source | 98 | 190 | { | 99 | 190 | bs_t s; | 100 | 190 | bs_init( &s, p_buf, i_buf ); | 101 | | | 102 | | /* cf. 5.3.2 */ | 103 | 190 | bs->i_fscod = bs_read( &s, 2 ); | 104 | 190 | if( bs->i_fscod == 3 ) | 105 | 5 | return VLC_EGENERIC; | 106 | 185 | bs->i_frmsizcod = bs_read( &s, 6 ); | 107 | 185 | if( bs->i_frmsizcod >= 38 ) | 108 | 25 | return VLC_EGENERIC; | 109 | 160 | bs->i_bsid = bs_read( &s, 5 ); | 110 | 160 | bs->i_bsmod = bs_read( &s, 3 ); | 111 | 160 | bs->i_acmod = bs_read( &s, 3 ); | 112 | 160 | if( ( bs->i_acmod & 0x1 ) && ( bs->i_acmod != 0x1 ) ) | 113 | 85 | { | 114 | | /* if 3 front channels */ | 115 | 85 | bs_skip( &s, 2 ); /* i_cmixlev */ | 116 | 85 | } | 117 | 160 | if( bs->i_acmod & 0x4 ) | 118 | 37 | { | 119 | | /* if a surround channel exists */ | 120 | 37 | bs_skip( &s, 2 ); /* i_surmixlev */ | 121 | 37 | } | 122 | | /* if in 2/0 mode */ | 123 | 160 | bs->ac3.i_dsurmod = bs->i_acmod == 0x2 ? bs_read( &s, 2 ) : 0; | 124 | 160 | bs->i_lfeon = bs_read( &s, 1 ); | 125 | | | 126 | 160 | return VLC_SUCCESS; | 127 | 185 | } |
mlp.c:vlc_a52_ParseAc3BitstreamInfo Line | Count | Source | 98 | 5.88k | { | 99 | 5.88k | bs_t s; | 100 | 5.88k | bs_init( &s, p_buf, i_buf ); | 101 | | | 102 | | /* cf. 5.3.2 */ | 103 | 5.88k | bs->i_fscod = bs_read( &s, 2 ); | 104 | 5.88k | if( bs->i_fscod == 3 ) | 105 | 201 | return VLC_EGENERIC; | 106 | 5.68k | bs->i_frmsizcod = bs_read( &s, 6 ); | 107 | 5.68k | if( bs->i_frmsizcod >= 38 ) | 108 | 1.04k | return VLC_EGENERIC; | 109 | 4.63k | bs->i_bsid = bs_read( &s, 5 ); | 110 | 4.63k | bs->i_bsmod = bs_read( &s, 3 ); | 111 | 4.63k | bs->i_acmod = bs_read( &s, 3 ); | 112 | 4.63k | if( ( bs->i_acmod & 0x1 ) && ( bs->i_acmod != 0x1 ) ) | 113 | 3.69k | { | 114 | | /* if 3 front channels */ | 115 | 3.69k | bs_skip( &s, 2 ); /* i_cmixlev */ | 116 | 3.69k | } | 117 | 4.63k | if( bs->i_acmod & 0x4 ) | 118 | 3.38k | { | 119 | | /* if a surround channel exists */ | 120 | 3.38k | bs_skip( &s, 2 ); /* i_surmixlev */ | 121 | 3.38k | } | 122 | | /* if in 2/0 mode */ | 123 | 4.63k | bs->ac3.i_dsurmod = bs->i_acmod == 0x2 ? bs_read( &s, 2 ) : 0; | 124 | 4.63k | bs->i_lfeon = bs_read( &s, 1 ); | 125 | | | 126 | 4.63k | return VLC_SUCCESS; | 127 | 5.68k | } |
|
128 | | |
129 | | static inline int vlc_a52_header_ParseAc3( vlc_a52_header_t *p_header, |
130 | | const uint8_t *p_buf, |
131 | | const uint32_t *p_acmod, |
132 | | const unsigned *pi_fscod_samplerates ) |
133 | 6.07k | { |
134 | 6.07k | if( vlc_a52_ParseAc3BitstreamInfo( &p_header->bs, |
135 | 6.07k | &p_buf[4], /* start code + CRC */ |
136 | 6.07k | VLC_A52_MIN_HEADER_SIZE - 4 ) != VLC_SUCCESS ) |
137 | 1.27k | return VLC_EGENERIC; |
138 | | |
139 | | /* cf. Table 5.18 Frame Size Code Table */ |
140 | 4.79k | static const uint16_t ppi_frmsizcod_fscod_sizes[][3] = { |
141 | | /* 32K, 44.1K, 48K */ |
142 | 4.79k | { 96, 69, 64 }, |
143 | 4.79k | { 96, 70, 64 }, |
144 | 4.79k | { 120, 87, 80 }, |
145 | 4.79k | { 120, 88, 80 }, |
146 | 4.79k | { 144, 104, 96 }, |
147 | 4.79k | { 144, 105, 96 }, |
148 | 4.79k | { 168, 121, 112 }, |
149 | 4.79k | { 168, 122, 112 }, |
150 | 4.79k | { 192, 139, 128 }, |
151 | 4.79k | { 192, 140, 128 }, |
152 | 4.79k | { 240, 174, 160 }, |
153 | 4.79k | { 240, 175, 160 }, |
154 | 4.79k | { 288, 208, 192 }, |
155 | 4.79k | { 288, 209, 192 }, |
156 | 4.79k | { 336, 243, 224 }, |
157 | 4.79k | { 336, 244, 224 }, |
158 | 4.79k | { 384, 278, 256 }, |
159 | 4.79k | { 384, 279, 256 }, |
160 | 4.79k | { 480, 348, 320 }, |
161 | 4.79k | { 480, 349, 320 }, |
162 | 4.79k | { 576, 417, 384 }, |
163 | 4.79k | { 576, 418, 384 }, |
164 | 4.79k | { 672, 487, 448 }, |
165 | 4.79k | { 672, 488, 448 }, |
166 | 4.79k | { 768, 557, 512 }, |
167 | 4.79k | { 768, 558, 512 }, |
168 | 4.79k | { 960, 696, 640 }, |
169 | 4.79k | { 960, 697, 640 }, |
170 | 4.79k | { 1152, 835, 768 }, |
171 | 4.79k | { 1152, 836, 768 }, |
172 | 4.79k | { 1344, 975, 896 }, |
173 | 4.79k | { 1344, 976, 896 }, |
174 | 4.79k | { 1536, 1114, 1024 }, |
175 | 4.79k | { 1536, 1115, 1024 }, |
176 | 4.79k | { 1728, 1253, 1152 }, |
177 | 4.79k | { 1728, 1254, 1152 }, |
178 | 4.79k | { 1920, 1393, 1280 }, |
179 | 4.79k | { 1920, 1394, 1280 } |
180 | 4.79k | }; |
181 | 4.79k | static const uint16_t pi_frmsizcod_bitrates[] = { |
182 | 4.79k | 32, 40, 48, 56, |
183 | 4.79k | 64, 80, 96, 112, |
184 | 4.79k | 128, 160, 192, 224, |
185 | 4.79k | 256, 320, 384, 448, |
186 | 4.79k | 512, 576, 640 |
187 | 4.79k | }; |
188 | | |
189 | 4.79k | const struct vlc_a52_bitstream_info *bs = &p_header->bs; |
190 | | |
191 | 4.79k | p_header->i_channels_conf = p_acmod[bs->i_acmod]; |
192 | 4.79k | p_header->i_chan_mode = 0; |
193 | 4.79k | if( bs->ac3.i_dsurmod == 2 ) |
194 | 4 | p_header->i_chan_mode |= AOUT_CHANMODE_DOLBYSTEREO; |
195 | 4.79k | if( bs->i_acmod == 0 ) |
196 | 694 | p_header->i_chan_mode |= AOUT_CHANMODE_DUALMONO; |
197 | | |
198 | 4.79k | if( bs->i_lfeon ) |
199 | 3.92k | p_header->i_channels_conf |= AOUT_CHAN_LFE; |
200 | | |
201 | 4.79k | p_header->i_channels = vlc_popcount(p_header->i_channels_conf); |
202 | | |
203 | 4.79k | const unsigned i_rate_shift = VLC_CLIP(bs->i_bsid, 8, 11) - 8; |
204 | 4.79k | p_header->i_bitrate = (pi_frmsizcod_bitrates[bs->i_frmsizcod >> 1] * 1000) |
205 | 4.79k | >> i_rate_shift; |
206 | 4.79k | p_header->i_rate = pi_fscod_samplerates[bs->i_fscod] >> i_rate_shift; |
207 | | |
208 | 4.79k | p_header->i_size = ppi_frmsizcod_fscod_sizes[bs->i_frmsizcod] |
209 | 4.79k | [2 - bs->i_fscod] * 2; |
210 | 4.79k | p_header->i_blocks_per_sync_frame = 6; |
211 | 4.79k | p_header->i_samples = p_header->i_blocks_per_sync_frame * 256; |
212 | | |
213 | 4.79k | p_header->b_eac3 = false; |
214 | 4.79k | return VLC_SUCCESS; |
215 | 6.07k | } Unexecuted instantiation: es.c:vlc_a52_header_ParseAc3 a52.c:vlc_a52_header_ParseAc3 Line | Count | Source | 133 | 190 | { | 134 | 190 | if( vlc_a52_ParseAc3BitstreamInfo( &p_header->bs, | 135 | 190 | &p_buf[4], /* start code + CRC */ | 136 | 190 | VLC_A52_MIN_HEADER_SIZE - 4 ) != VLC_SUCCESS ) | 137 | 30 | return VLC_EGENERIC; | 138 | | | 139 | | /* cf. Table 5.18 Frame Size Code Table */ | 140 | 160 | static const uint16_t ppi_frmsizcod_fscod_sizes[][3] = { | 141 | | /* 32K, 44.1K, 48K */ | 142 | 160 | { 96, 69, 64 }, | 143 | 160 | { 96, 70, 64 }, | 144 | 160 | { 120, 87, 80 }, | 145 | 160 | { 120, 88, 80 }, | 146 | 160 | { 144, 104, 96 }, | 147 | 160 | { 144, 105, 96 }, | 148 | 160 | { 168, 121, 112 }, | 149 | 160 | { 168, 122, 112 }, | 150 | 160 | { 192, 139, 128 }, | 151 | 160 | { 192, 140, 128 }, | 152 | 160 | { 240, 174, 160 }, | 153 | 160 | { 240, 175, 160 }, | 154 | 160 | { 288, 208, 192 }, | 155 | 160 | { 288, 209, 192 }, | 156 | 160 | { 336, 243, 224 }, | 157 | 160 | { 336, 244, 224 }, | 158 | 160 | { 384, 278, 256 }, | 159 | 160 | { 384, 279, 256 }, | 160 | 160 | { 480, 348, 320 }, | 161 | 160 | { 480, 349, 320 }, | 162 | 160 | { 576, 417, 384 }, | 163 | 160 | { 576, 418, 384 }, | 164 | 160 | { 672, 487, 448 }, | 165 | 160 | { 672, 488, 448 }, | 166 | 160 | { 768, 557, 512 }, | 167 | 160 | { 768, 558, 512 }, | 168 | 160 | { 960, 696, 640 }, | 169 | 160 | { 960, 697, 640 }, | 170 | 160 | { 1152, 835, 768 }, | 171 | 160 | { 1152, 836, 768 }, | 172 | 160 | { 1344, 975, 896 }, | 173 | 160 | { 1344, 976, 896 }, | 174 | 160 | { 1536, 1114, 1024 }, | 175 | 160 | { 1536, 1115, 1024 }, | 176 | 160 | { 1728, 1253, 1152 }, | 177 | 160 | { 1728, 1254, 1152 }, | 178 | 160 | { 1920, 1393, 1280 }, | 179 | 160 | { 1920, 1394, 1280 } | 180 | 160 | }; | 181 | 160 | static const uint16_t pi_frmsizcod_bitrates[] = { | 182 | 160 | 32, 40, 48, 56, | 183 | 160 | 64, 80, 96, 112, | 184 | 160 | 128, 160, 192, 224, | 185 | 160 | 256, 320, 384, 448, | 186 | 160 | 512, 576, 640 | 187 | 160 | }; | 188 | | | 189 | 160 | const struct vlc_a52_bitstream_info *bs = &p_header->bs; | 190 | | | 191 | 160 | p_header->i_channels_conf = p_acmod[bs->i_acmod]; | 192 | 160 | p_header->i_chan_mode = 0; | 193 | 160 | if( bs->ac3.i_dsurmod == 2 ) | 194 | 4 | p_header->i_chan_mode |= AOUT_CHANMODE_DOLBYSTEREO; | 195 | 160 | if( bs->i_acmod == 0 ) | 196 | 58 | p_header->i_chan_mode |= AOUT_CHANMODE_DUALMONO; | 197 | | | 198 | 160 | if( bs->i_lfeon ) | 199 | 81 | p_header->i_channels_conf |= AOUT_CHAN_LFE; | 200 | | | 201 | 160 | p_header->i_channels = vlc_popcount(p_header->i_channels_conf); | 202 | | | 203 | 160 | const unsigned i_rate_shift = VLC_CLIP(bs->i_bsid, 8, 11) - 8; | 204 | 160 | p_header->i_bitrate = (pi_frmsizcod_bitrates[bs->i_frmsizcod >> 1] * 1000) | 205 | 160 | >> i_rate_shift; | 206 | 160 | p_header->i_rate = pi_fscod_samplerates[bs->i_fscod] >> i_rate_shift; | 207 | | | 208 | 160 | p_header->i_size = ppi_frmsizcod_fscod_sizes[bs->i_frmsizcod] | 209 | 160 | [2 - bs->i_fscod] * 2; | 210 | 160 | p_header->i_blocks_per_sync_frame = 6; | 211 | 160 | p_header->i_samples = p_header->i_blocks_per_sync_frame * 256; | 212 | | | 213 | 160 | p_header->b_eac3 = false; | 214 | 160 | return VLC_SUCCESS; | 215 | 190 | } |
mlp.c:vlc_a52_header_ParseAc3 Line | Count | Source | 133 | 5.88k | { | 134 | 5.88k | if( vlc_a52_ParseAc3BitstreamInfo( &p_header->bs, | 135 | 5.88k | &p_buf[4], /* start code + CRC */ | 136 | 5.88k | VLC_A52_MIN_HEADER_SIZE - 4 ) != VLC_SUCCESS ) | 137 | 1.24k | return VLC_EGENERIC; | 138 | | | 139 | | /* cf. Table 5.18 Frame Size Code Table */ | 140 | 4.63k | static const uint16_t ppi_frmsizcod_fscod_sizes[][3] = { | 141 | | /* 32K, 44.1K, 48K */ | 142 | 4.63k | { 96, 69, 64 }, | 143 | 4.63k | { 96, 70, 64 }, | 144 | 4.63k | { 120, 87, 80 }, | 145 | 4.63k | { 120, 88, 80 }, | 146 | 4.63k | { 144, 104, 96 }, | 147 | 4.63k | { 144, 105, 96 }, | 148 | 4.63k | { 168, 121, 112 }, | 149 | 4.63k | { 168, 122, 112 }, | 150 | 4.63k | { 192, 139, 128 }, | 151 | 4.63k | { 192, 140, 128 }, | 152 | 4.63k | { 240, 174, 160 }, | 153 | 4.63k | { 240, 175, 160 }, | 154 | 4.63k | { 288, 208, 192 }, | 155 | 4.63k | { 288, 209, 192 }, | 156 | 4.63k | { 336, 243, 224 }, | 157 | 4.63k | { 336, 244, 224 }, | 158 | 4.63k | { 384, 278, 256 }, | 159 | 4.63k | { 384, 279, 256 }, | 160 | 4.63k | { 480, 348, 320 }, | 161 | 4.63k | { 480, 349, 320 }, | 162 | 4.63k | { 576, 417, 384 }, | 163 | 4.63k | { 576, 418, 384 }, | 164 | 4.63k | { 672, 487, 448 }, | 165 | 4.63k | { 672, 488, 448 }, | 166 | 4.63k | { 768, 557, 512 }, | 167 | 4.63k | { 768, 558, 512 }, | 168 | 4.63k | { 960, 696, 640 }, | 169 | 4.63k | { 960, 697, 640 }, | 170 | 4.63k | { 1152, 835, 768 }, | 171 | 4.63k | { 1152, 836, 768 }, | 172 | 4.63k | { 1344, 975, 896 }, | 173 | 4.63k | { 1344, 976, 896 }, | 174 | 4.63k | { 1536, 1114, 1024 }, | 175 | 4.63k | { 1536, 1115, 1024 }, | 176 | 4.63k | { 1728, 1253, 1152 }, | 177 | 4.63k | { 1728, 1254, 1152 }, | 178 | 4.63k | { 1920, 1393, 1280 }, | 179 | 4.63k | { 1920, 1394, 1280 } | 180 | 4.63k | }; | 181 | 4.63k | static const uint16_t pi_frmsizcod_bitrates[] = { | 182 | 4.63k | 32, 40, 48, 56, | 183 | 4.63k | 64, 80, 96, 112, | 184 | 4.63k | 128, 160, 192, 224, | 185 | 4.63k | 256, 320, 384, 448, | 186 | 4.63k | 512, 576, 640 | 187 | 4.63k | }; | 188 | | | 189 | 4.63k | const struct vlc_a52_bitstream_info *bs = &p_header->bs; | 190 | | | 191 | 4.63k | p_header->i_channels_conf = p_acmod[bs->i_acmod]; | 192 | 4.63k | p_header->i_chan_mode = 0; | 193 | 4.63k | if( bs->ac3.i_dsurmod == 2 ) | 194 | 0 | p_header->i_chan_mode |= AOUT_CHANMODE_DOLBYSTEREO; | 195 | 4.63k | if( bs->i_acmod == 0 ) | 196 | 636 | p_header->i_chan_mode |= AOUT_CHANMODE_DUALMONO; | 197 | | | 198 | 4.63k | if( bs->i_lfeon ) | 199 | 3.84k | p_header->i_channels_conf |= AOUT_CHAN_LFE; | 200 | | | 201 | 4.63k | p_header->i_channels = vlc_popcount(p_header->i_channels_conf); | 202 | | | 203 | 4.63k | const unsigned i_rate_shift = VLC_CLIP(bs->i_bsid, 8, 11) - 8; | 204 | 4.63k | p_header->i_bitrate = (pi_frmsizcod_bitrates[bs->i_frmsizcod >> 1] * 1000) | 205 | 4.63k | >> i_rate_shift; | 206 | 4.63k | p_header->i_rate = pi_fscod_samplerates[bs->i_fscod] >> i_rate_shift; | 207 | | | 208 | 4.63k | p_header->i_size = ppi_frmsizcod_fscod_sizes[bs->i_frmsizcod] | 209 | 4.63k | [2 - bs->i_fscod] * 2; | 210 | 4.63k | p_header->i_blocks_per_sync_frame = 6; | 211 | 4.63k | p_header->i_samples = p_header->i_blocks_per_sync_frame * 256; | 212 | | | 213 | 4.63k | p_header->b_eac3 = false; | 214 | 4.63k | return VLC_SUCCESS; | 215 | 5.88k | } |
|
216 | | |
217 | | /** |
218 | | * It parse E-AC3 sync info |
219 | | */ |
220 | | static inline int vlc_a52_ParseEac3BitstreamInfo( struct vlc_a52_bitstream_info *bs, |
221 | | const uint8_t *p_buf, size_t i_buf ) |
222 | 196k | { |
223 | 196k | bs_t s; |
224 | 196k | bs_init( &s, p_buf, i_buf ); |
225 | 196k | bs->eac3.strmtyp = bs_read( &s, 2 ); /* Stream Type */ |
226 | 196k | bs->eac3.i_substreamid = bs_read( &s, 3 );/* Substream Identification */ |
227 | | |
228 | 196k | bs->eac3.i_frmsiz = bs_read( &s, 11 ); |
229 | 196k | if( bs->eac3.i_frmsiz < 2 ) |
230 | 217 | return VLC_EGENERIC; |
231 | | |
232 | 196k | bs->i_fscod = bs_read( &s, 2 ); |
233 | 196k | if( bs->i_fscod == 0x03 ) |
234 | 94.1k | { |
235 | 94.1k | bs->eac3.i_fscod2 = bs_read( &s, 2 ); |
236 | 94.1k | if( bs->eac3.i_fscod2 == 0x03 ) |
237 | 0 | return VLC_EGENERIC; |
238 | 94.1k | bs->eac3.i_numblkscod = 0x03; |
239 | 94.1k | } |
240 | 102k | else bs->eac3.i_numblkscod = bs_read( &s, 2 ); |
241 | | |
242 | 196k | bs->i_acmod = bs_read( &s, 3 ); |
243 | 196k | bs->i_lfeon = bs_read1( &s ); |
244 | 196k | bs->i_bsid = bs_read( &s, 5 ); |
245 | | |
246 | 196k | if( i_buf <= VLC_A52_MIN_HEADER_SIZE ) |
247 | 196k | { |
248 | 196k | bs->i_bsmod = 0; |
249 | 196k | return VLC_SUCCESS; |
250 | 196k | } |
251 | | |
252 | 0 | bs_skip( &s, 5 ); /* dialnorm */ |
253 | 0 | if(bs_read1( &s )) |
254 | 0 | bs_skip( &s, 8 ); /* compr */ |
255 | |
|
256 | 0 | if( bs->i_acmod == 0x00 ) |
257 | 0 | { |
258 | 0 | bs_skip( &s, 5 ); |
259 | 0 | if(bs_read1( &s )) |
260 | 0 | bs_skip( &s, 8 ); /* compr2 */ |
261 | 0 | } |
262 | |
|
263 | 0 | if( bs->eac3.strmtyp == 0x01 && bs_read1( &s ) ) |
264 | 0 | bs_skip( &s, 16 ); /* chanmap */ |
265 | |
|
266 | 0 | if( bs_read1( &s ) ) /* mixmdate */ |
267 | 0 | { |
268 | 0 | if( bs->i_acmod > 0x02 ) |
269 | 0 | { |
270 | 0 | bs_skip( &s, 2 ); /* dmixmod */ |
271 | 0 | if( bs->i_acmod & 0x01 ) |
272 | 0 | bs_skip( &s, 6 ); /* ltrtcmixlev + lorocmixlev */ |
273 | 0 | if( bs->i_acmod & 0x04 ) |
274 | 0 | bs_skip( &s, 6 ); /* ltrtsurmixlev + lorosurmixlev */ |
275 | 0 | } |
276 | |
|
277 | 0 | if( bs->i_lfeon && bs_read1( &s ) ) |
278 | 0 | bs_skip( &s, 5 ); /* (lfemixlevcode) */ |
279 | |
|
280 | 0 | if( bs->eac3.strmtyp == 0x00 ) |
281 | 0 | { |
282 | 0 | if( bs_read1( &s ) ) |
283 | 0 | bs_skip( &s, 6 ); /* pgmscl */ |
284 | 0 | if( bs->i_acmod == 0x00 && bs_read1( &s ) ) |
285 | 0 | bs_skip( &s, 6 ); /* pgmscl2 */ |
286 | 0 | if(bs_read1( &s )) |
287 | 0 | bs_skip( &s, 6 ); /* extpgmscl */ |
288 | 0 | const uint8_t i_mixdef = bs_read( &s, 2 ); |
289 | 0 | if( i_mixdef == 0x01 ) |
290 | 0 | bs_skip( &s, 5 ); /* premixcmpsel + drcsrc + premixcmpscl */ |
291 | 0 | else if( i_mixdef == 0x02 ) |
292 | 0 | bs_skip( &s, 12 ); /* mixdata */ |
293 | 0 | else if( i_mixdef == 0x03 ) |
294 | 0 | { |
295 | 0 | const unsigned mixdeflen = bs_read( &s, 5 ) + 2; |
296 | 0 | for(size_t i=0; i<mixdeflen; i++) |
297 | 0 | bs_skip( &s, 8 ); |
298 | 0 | bs_align( &s ); |
299 | 0 | } |
300 | 0 | if( bs->i_acmod < 0x02 ) |
301 | 0 | { |
302 | 0 | if( bs_read1( &s ) ) |
303 | 0 | bs_skip( &s, 14 ); /* panmean + paninfo */ |
304 | 0 | if( bs->i_acmod == 0x00 && bs_read1( &s ) ) |
305 | 0 | bs_skip( &s, 14 ); /* panmean2 + paninfo2 */ |
306 | 0 | } |
307 | 0 | if( bs_read1( &s ) ) |
308 | 0 | { |
309 | 0 | const uint8_t blkspersyncframe[] = { 0+1, 1, 2, 6 }; |
310 | 0 | const size_t nb = blkspersyncframe[bs->eac3.i_numblkscod]; |
311 | 0 | for(size_t i=0; i<nb; i++) |
312 | 0 | { |
313 | 0 | if( bs->eac3.i_numblkscod == 0x00 ) |
314 | 0 | bs_skip( &s, 5 ); /* blkmixcfginfo[N] */ |
315 | 0 | } |
316 | 0 | } |
317 | 0 | } |
318 | 0 | } |
319 | |
|
320 | 0 | if( bs_read1( &s ) ) /* infomdate */ |
321 | 0 | { |
322 | 0 | bs->i_bsmod = bs_read( &s, 3 ); |
323 | | // ... |
324 | 0 | } |
325 | 0 | else bs->i_bsmod = 0; |
326 | |
|
327 | 0 | return VLC_SUCCESS; |
328 | 196k | } es.c:vlc_a52_ParseEac3BitstreamInfo Line | Count | Source | 222 | 9 | { | 223 | 9 | bs_t s; | 224 | 9 | bs_init( &s, p_buf, i_buf ); | 225 | 9 | bs->eac3.strmtyp = bs_read( &s, 2 ); /* Stream Type */ | 226 | 9 | bs->eac3.i_substreamid = bs_read( &s, 3 );/* Substream Identification */ | 227 | | | 228 | 9 | bs->eac3.i_frmsiz = bs_read( &s, 11 ); | 229 | 9 | if( bs->eac3.i_frmsiz < 2 ) | 230 | 0 | return VLC_EGENERIC; | 231 | | | 232 | 9 | bs->i_fscod = bs_read( &s, 2 ); | 233 | 9 | if( bs->i_fscod == 0x03 ) | 234 | 0 | { | 235 | 0 | bs->eac3.i_fscod2 = bs_read( &s, 2 ); | 236 | 0 | if( bs->eac3.i_fscod2 == 0x03 ) | 237 | 0 | return VLC_EGENERIC; | 238 | 0 | bs->eac3.i_numblkscod = 0x03; | 239 | 0 | } | 240 | 9 | else bs->eac3.i_numblkscod = bs_read( &s, 2 ); | 241 | | | 242 | 9 | bs->i_acmod = bs_read( &s, 3 ); | 243 | 9 | bs->i_lfeon = bs_read1( &s ); | 244 | 9 | bs->i_bsid = bs_read( &s, 5 ); | 245 | | | 246 | 9 | if( i_buf <= VLC_A52_MIN_HEADER_SIZE ) | 247 | 9 | { | 248 | 9 | bs->i_bsmod = 0; | 249 | 9 | return VLC_SUCCESS; | 250 | 9 | } | 251 | | | 252 | 0 | bs_skip( &s, 5 ); /* dialnorm */ | 253 | 0 | if(bs_read1( &s )) | 254 | 0 | bs_skip( &s, 8 ); /* compr */ | 255 | |
| 256 | 0 | if( bs->i_acmod == 0x00 ) | 257 | 0 | { | 258 | 0 | bs_skip( &s, 5 ); | 259 | 0 | if(bs_read1( &s )) | 260 | 0 | bs_skip( &s, 8 ); /* compr2 */ | 261 | 0 | } | 262 | |
| 263 | 0 | if( bs->eac3.strmtyp == 0x01 && bs_read1( &s ) ) | 264 | 0 | bs_skip( &s, 16 ); /* chanmap */ | 265 | |
| 266 | 0 | if( bs_read1( &s ) ) /* mixmdate */ | 267 | 0 | { | 268 | 0 | if( bs->i_acmod > 0x02 ) | 269 | 0 | { | 270 | 0 | bs_skip( &s, 2 ); /* dmixmod */ | 271 | 0 | if( bs->i_acmod & 0x01 ) | 272 | 0 | bs_skip( &s, 6 ); /* ltrtcmixlev + lorocmixlev */ | 273 | 0 | if( bs->i_acmod & 0x04 ) | 274 | 0 | bs_skip( &s, 6 ); /* ltrtsurmixlev + lorosurmixlev */ | 275 | 0 | } | 276 | |
| 277 | 0 | if( bs->i_lfeon && bs_read1( &s ) ) | 278 | 0 | bs_skip( &s, 5 ); /* (lfemixlevcode) */ | 279 | |
| 280 | 0 | if( bs->eac3.strmtyp == 0x00 ) | 281 | 0 | { | 282 | 0 | if( bs_read1( &s ) ) | 283 | 0 | bs_skip( &s, 6 ); /* pgmscl */ | 284 | 0 | if( bs->i_acmod == 0x00 && bs_read1( &s ) ) | 285 | 0 | bs_skip( &s, 6 ); /* pgmscl2 */ | 286 | 0 | if(bs_read1( &s )) | 287 | 0 | bs_skip( &s, 6 ); /* extpgmscl */ | 288 | 0 | const uint8_t i_mixdef = bs_read( &s, 2 ); | 289 | 0 | if( i_mixdef == 0x01 ) | 290 | 0 | bs_skip( &s, 5 ); /* premixcmpsel + drcsrc + premixcmpscl */ | 291 | 0 | else if( i_mixdef == 0x02 ) | 292 | 0 | bs_skip( &s, 12 ); /* mixdata */ | 293 | 0 | else if( i_mixdef == 0x03 ) | 294 | 0 | { | 295 | 0 | const unsigned mixdeflen = bs_read( &s, 5 ) + 2; | 296 | 0 | for(size_t i=0; i<mixdeflen; i++) | 297 | 0 | bs_skip( &s, 8 ); | 298 | 0 | bs_align( &s ); | 299 | 0 | } | 300 | 0 | if( bs->i_acmod < 0x02 ) | 301 | 0 | { | 302 | 0 | if( bs_read1( &s ) ) | 303 | 0 | bs_skip( &s, 14 ); /* panmean + paninfo */ | 304 | 0 | if( bs->i_acmod == 0x00 && bs_read1( &s ) ) | 305 | 0 | bs_skip( &s, 14 ); /* panmean2 + paninfo2 */ | 306 | 0 | } | 307 | 0 | if( bs_read1( &s ) ) | 308 | 0 | { | 309 | 0 | const uint8_t blkspersyncframe[] = { 0+1, 1, 2, 6 }; | 310 | 0 | const size_t nb = blkspersyncframe[bs->eac3.i_numblkscod]; | 311 | 0 | for(size_t i=0; i<nb; i++) | 312 | 0 | { | 313 | 0 | if( bs->eac3.i_numblkscod == 0x00 ) | 314 | 0 | bs_skip( &s, 5 ); /* blkmixcfginfo[N] */ | 315 | 0 | } | 316 | 0 | } | 317 | 0 | } | 318 | 0 | } | 319 | |
| 320 | 0 | if( bs_read1( &s ) ) /* infomdate */ | 321 | 0 | { | 322 | 0 | bs->i_bsmod = bs_read( &s, 3 ); | 323 | | // ... | 324 | 0 | } | 325 | 0 | else bs->i_bsmod = 0; | 326 | |
| 327 | 0 | return VLC_SUCCESS; | 328 | 9 | } |
a52.c:vlc_a52_ParseEac3BitstreamInfo Line | Count | Source | 222 | 3.49k | { | 223 | 3.49k | bs_t s; | 224 | 3.49k | bs_init( &s, p_buf, i_buf ); | 225 | 3.49k | bs->eac3.strmtyp = bs_read( &s, 2 ); /* Stream Type */ | 226 | 3.49k | bs->eac3.i_substreamid = bs_read( &s, 3 );/* Substream Identification */ | 227 | | | 228 | 3.49k | bs->eac3.i_frmsiz = bs_read( &s, 11 ); | 229 | 3.49k | if( bs->eac3.i_frmsiz < 2 ) | 230 | 1 | return VLC_EGENERIC; | 231 | | | 232 | 3.49k | bs->i_fscod = bs_read( &s, 2 ); | 233 | 3.49k | if( bs->i_fscod == 0x03 ) | 234 | 537 | { | 235 | 537 | bs->eac3.i_fscod2 = bs_read( &s, 2 ); | 236 | 537 | if( bs->eac3.i_fscod2 == 0x03 ) | 237 | 0 | return VLC_EGENERIC; | 238 | 537 | bs->eac3.i_numblkscod = 0x03; | 239 | 537 | } | 240 | 2.95k | else bs->eac3.i_numblkscod = bs_read( &s, 2 ); | 241 | | | 242 | 3.49k | bs->i_acmod = bs_read( &s, 3 ); | 243 | 3.49k | bs->i_lfeon = bs_read1( &s ); | 244 | 3.49k | bs->i_bsid = bs_read( &s, 5 ); | 245 | | | 246 | 3.49k | if( i_buf <= VLC_A52_MIN_HEADER_SIZE ) | 247 | 3.49k | { | 248 | 3.49k | bs->i_bsmod = 0; | 249 | 3.49k | return VLC_SUCCESS; | 250 | 3.49k | } | 251 | | | 252 | 0 | bs_skip( &s, 5 ); /* dialnorm */ | 253 | 0 | if(bs_read1( &s )) | 254 | 0 | bs_skip( &s, 8 ); /* compr */ | 255 | |
| 256 | 0 | if( bs->i_acmod == 0x00 ) | 257 | 0 | { | 258 | 0 | bs_skip( &s, 5 ); | 259 | 0 | if(bs_read1( &s )) | 260 | 0 | bs_skip( &s, 8 ); /* compr2 */ | 261 | 0 | } | 262 | |
| 263 | 0 | if( bs->eac3.strmtyp == 0x01 && bs_read1( &s ) ) | 264 | 0 | bs_skip( &s, 16 ); /* chanmap */ | 265 | |
| 266 | 0 | if( bs_read1( &s ) ) /* mixmdate */ | 267 | 0 | { | 268 | 0 | if( bs->i_acmod > 0x02 ) | 269 | 0 | { | 270 | 0 | bs_skip( &s, 2 ); /* dmixmod */ | 271 | 0 | if( bs->i_acmod & 0x01 ) | 272 | 0 | bs_skip( &s, 6 ); /* ltrtcmixlev + lorocmixlev */ | 273 | 0 | if( bs->i_acmod & 0x04 ) | 274 | 0 | bs_skip( &s, 6 ); /* ltrtsurmixlev + lorosurmixlev */ | 275 | 0 | } | 276 | |
| 277 | 0 | if( bs->i_lfeon && bs_read1( &s ) ) | 278 | 0 | bs_skip( &s, 5 ); /* (lfemixlevcode) */ | 279 | |
| 280 | 0 | if( bs->eac3.strmtyp == 0x00 ) | 281 | 0 | { | 282 | 0 | if( bs_read1( &s ) ) | 283 | 0 | bs_skip( &s, 6 ); /* pgmscl */ | 284 | 0 | if( bs->i_acmod == 0x00 && bs_read1( &s ) ) | 285 | 0 | bs_skip( &s, 6 ); /* pgmscl2 */ | 286 | 0 | if(bs_read1( &s )) | 287 | 0 | bs_skip( &s, 6 ); /* extpgmscl */ | 288 | 0 | const uint8_t i_mixdef = bs_read( &s, 2 ); | 289 | 0 | if( i_mixdef == 0x01 ) | 290 | 0 | bs_skip( &s, 5 ); /* premixcmpsel + drcsrc + premixcmpscl */ | 291 | 0 | else if( i_mixdef == 0x02 ) | 292 | 0 | bs_skip( &s, 12 ); /* mixdata */ | 293 | 0 | else if( i_mixdef == 0x03 ) | 294 | 0 | { | 295 | 0 | const unsigned mixdeflen = bs_read( &s, 5 ) + 2; | 296 | 0 | for(size_t i=0; i<mixdeflen; i++) | 297 | 0 | bs_skip( &s, 8 ); | 298 | 0 | bs_align( &s ); | 299 | 0 | } | 300 | 0 | if( bs->i_acmod < 0x02 ) | 301 | 0 | { | 302 | 0 | if( bs_read1( &s ) ) | 303 | 0 | bs_skip( &s, 14 ); /* panmean + paninfo */ | 304 | 0 | if( bs->i_acmod == 0x00 && bs_read1( &s ) ) | 305 | 0 | bs_skip( &s, 14 ); /* panmean2 + paninfo2 */ | 306 | 0 | } | 307 | 0 | if( bs_read1( &s ) ) | 308 | 0 | { | 309 | 0 | const uint8_t blkspersyncframe[] = { 0+1, 1, 2, 6 }; | 310 | 0 | const size_t nb = blkspersyncframe[bs->eac3.i_numblkscod]; | 311 | 0 | for(size_t i=0; i<nb; i++) | 312 | 0 | { | 313 | 0 | if( bs->eac3.i_numblkscod == 0x00 ) | 314 | 0 | bs_skip( &s, 5 ); /* blkmixcfginfo[N] */ | 315 | 0 | } | 316 | 0 | } | 317 | 0 | } | 318 | 0 | } | 319 | |
| 320 | 0 | if( bs_read1( &s ) ) /* infomdate */ | 321 | 0 | { | 322 | 0 | bs->i_bsmod = bs_read( &s, 3 ); | 323 | | // ... | 324 | 0 | } | 325 | 0 | else bs->i_bsmod = 0; | 326 | |
| 327 | 0 | return VLC_SUCCESS; | 328 | 3.49k | } |
mlp.c:vlc_a52_ParseEac3BitstreamInfo Line | Count | Source | 222 | 193k | { | 223 | 193k | bs_t s; | 224 | 193k | bs_init( &s, p_buf, i_buf ); | 225 | 193k | bs->eac3.strmtyp = bs_read( &s, 2 ); /* Stream Type */ | 226 | 193k | bs->eac3.i_substreamid = bs_read( &s, 3 );/* Substream Identification */ | 227 | | | 228 | 193k | bs->eac3.i_frmsiz = bs_read( &s, 11 ); | 229 | 193k | if( bs->eac3.i_frmsiz < 2 ) | 230 | 216 | return VLC_EGENERIC; | 231 | | | 232 | 193k | bs->i_fscod = bs_read( &s, 2 ); | 233 | 193k | if( bs->i_fscod == 0x03 ) | 234 | 93.6k | { | 235 | 93.6k | bs->eac3.i_fscod2 = bs_read( &s, 2 ); | 236 | 93.6k | if( bs->eac3.i_fscod2 == 0x03 ) | 237 | 0 | return VLC_EGENERIC; | 238 | 93.6k | bs->eac3.i_numblkscod = 0x03; | 239 | 93.6k | } | 240 | 99.6k | else bs->eac3.i_numblkscod = bs_read( &s, 2 ); | 241 | | | 242 | 193k | bs->i_acmod = bs_read( &s, 3 ); | 243 | 193k | bs->i_lfeon = bs_read1( &s ); | 244 | 193k | bs->i_bsid = bs_read( &s, 5 ); | 245 | | | 246 | 193k | if( i_buf <= VLC_A52_MIN_HEADER_SIZE ) | 247 | 193k | { | 248 | 193k | bs->i_bsmod = 0; | 249 | 193k | return VLC_SUCCESS; | 250 | 193k | } | 251 | | | 252 | 0 | bs_skip( &s, 5 ); /* dialnorm */ | 253 | 0 | if(bs_read1( &s )) | 254 | 0 | bs_skip( &s, 8 ); /* compr */ | 255 | |
| 256 | 0 | if( bs->i_acmod == 0x00 ) | 257 | 0 | { | 258 | 0 | bs_skip( &s, 5 ); | 259 | 0 | if(bs_read1( &s )) | 260 | 0 | bs_skip( &s, 8 ); /* compr2 */ | 261 | 0 | } | 262 | |
| 263 | 0 | if( bs->eac3.strmtyp == 0x01 && bs_read1( &s ) ) | 264 | 0 | bs_skip( &s, 16 ); /* chanmap */ | 265 | |
| 266 | 0 | if( bs_read1( &s ) ) /* mixmdate */ | 267 | 0 | { | 268 | 0 | if( bs->i_acmod > 0x02 ) | 269 | 0 | { | 270 | 0 | bs_skip( &s, 2 ); /* dmixmod */ | 271 | 0 | if( bs->i_acmod & 0x01 ) | 272 | 0 | bs_skip( &s, 6 ); /* ltrtcmixlev + lorocmixlev */ | 273 | 0 | if( bs->i_acmod & 0x04 ) | 274 | 0 | bs_skip( &s, 6 ); /* ltrtsurmixlev + lorosurmixlev */ | 275 | 0 | } | 276 | |
| 277 | 0 | if( bs->i_lfeon && bs_read1( &s ) ) | 278 | 0 | bs_skip( &s, 5 ); /* (lfemixlevcode) */ | 279 | |
| 280 | 0 | if( bs->eac3.strmtyp == 0x00 ) | 281 | 0 | { | 282 | 0 | if( bs_read1( &s ) ) | 283 | 0 | bs_skip( &s, 6 ); /* pgmscl */ | 284 | 0 | if( bs->i_acmod == 0x00 && bs_read1( &s ) ) | 285 | 0 | bs_skip( &s, 6 ); /* pgmscl2 */ | 286 | 0 | if(bs_read1( &s )) | 287 | 0 | bs_skip( &s, 6 ); /* extpgmscl */ | 288 | 0 | const uint8_t i_mixdef = bs_read( &s, 2 ); | 289 | 0 | if( i_mixdef == 0x01 ) | 290 | 0 | bs_skip( &s, 5 ); /* premixcmpsel + drcsrc + premixcmpscl */ | 291 | 0 | else if( i_mixdef == 0x02 ) | 292 | 0 | bs_skip( &s, 12 ); /* mixdata */ | 293 | 0 | else if( i_mixdef == 0x03 ) | 294 | 0 | { | 295 | 0 | const unsigned mixdeflen = bs_read( &s, 5 ) + 2; | 296 | 0 | for(size_t i=0; i<mixdeflen; i++) | 297 | 0 | bs_skip( &s, 8 ); | 298 | 0 | bs_align( &s ); | 299 | 0 | } | 300 | 0 | if( bs->i_acmod < 0x02 ) | 301 | 0 | { | 302 | 0 | if( bs_read1( &s ) ) | 303 | 0 | bs_skip( &s, 14 ); /* panmean + paninfo */ | 304 | 0 | if( bs->i_acmod == 0x00 && bs_read1( &s ) ) | 305 | 0 | bs_skip( &s, 14 ); /* panmean2 + paninfo2 */ | 306 | 0 | } | 307 | 0 | if( bs_read1( &s ) ) | 308 | 0 | { | 309 | 0 | const uint8_t blkspersyncframe[] = { 0+1, 1, 2, 6 }; | 310 | 0 | const size_t nb = blkspersyncframe[bs->eac3.i_numblkscod]; | 311 | 0 | for(size_t i=0; i<nb; i++) | 312 | 0 | { | 313 | 0 | if( bs->eac3.i_numblkscod == 0x00 ) | 314 | 0 | bs_skip( &s, 5 ); /* blkmixcfginfo[N] */ | 315 | 0 | } | 316 | 0 | } | 317 | 0 | } | 318 | 0 | } | 319 | |
| 320 | 0 | if( bs_read1( &s ) ) /* infomdate */ | 321 | 0 | { | 322 | 0 | bs->i_bsmod = bs_read( &s, 3 ); | 323 | | // ... | 324 | 0 | } | 325 | 0 | else bs->i_bsmod = 0; | 326 | |
| 327 | 0 | return VLC_SUCCESS; | 328 | 193k | } |
|
329 | | |
330 | | static inline int vlc_a52_header_ParseEac3( vlc_a52_header_t *p_header, |
331 | | const uint8_t *p_buf, |
332 | | const uint32_t *p_acmod, |
333 | | const unsigned *pi_fscod_samplerates ) |
334 | 196k | { |
335 | 196k | if( vlc_a52_ParseEac3BitstreamInfo( &p_header->bs, |
336 | 196k | &p_buf[2], /* start code */ |
337 | 196k | VLC_A52_MIN_HEADER_SIZE - 2 ) != VLC_SUCCESS ) |
338 | 217 | return VLC_EGENERIC; |
339 | | |
340 | 196k | const struct vlc_a52_bitstream_info *bs = &p_header->bs; |
341 | | |
342 | 196k | p_header->i_size = 2 * (bs->eac3.i_frmsiz + 1 ); |
343 | | |
344 | 196k | if( bs->i_fscod == 0x03 ) |
345 | 94.1k | { |
346 | 94.1k | p_header->i_rate = pi_fscod_samplerates[bs->eac3.i_fscod2] / 2; |
347 | 94.1k | p_header->i_blocks_per_sync_frame = 6; |
348 | 94.1k | } |
349 | 102k | else |
350 | 102k | { |
351 | 102k | static const int pi_numblkscod [4] = { 1, 2, 3, 6 }; |
352 | 102k | p_header->i_rate = pi_fscod_samplerates[bs->i_fscod]; |
353 | 102k | p_header->i_blocks_per_sync_frame = pi_numblkscod[bs->eac3.i_numblkscod]; |
354 | 102k | } |
355 | | |
356 | 196k | p_header->i_channels_conf = p_acmod[bs->i_acmod]; |
357 | 196k | p_header->i_chan_mode = 0; |
358 | 196k | if( bs->i_acmod == 0 ) |
359 | 2.48k | p_header->i_chan_mode |= AOUT_CHANMODE_DUALMONO; |
360 | 196k | if( bs->i_lfeon ) |
361 | 194k | p_header->i_channels_conf |= AOUT_CHAN_LFE; |
362 | 196k | p_header->i_channels = vlc_popcount( p_header->i_channels_conf ); |
363 | 196k | p_header->i_bitrate = 8 * p_header->i_size * p_header->i_rate |
364 | 196k | / (p_header->i_blocks_per_sync_frame * 256); |
365 | 196k | p_header->i_samples = p_header->i_blocks_per_sync_frame * 256; |
366 | | |
367 | 196k | p_header->b_eac3 = true; |
368 | 196k | return VLC_SUCCESS; |
369 | 196k | } es.c:vlc_a52_header_ParseEac3 Line | Count | Source | 334 | 9 | { | 335 | 9 | if( vlc_a52_ParseEac3BitstreamInfo( &p_header->bs, | 336 | 9 | &p_buf[2], /* start code */ | 337 | 9 | VLC_A52_MIN_HEADER_SIZE - 2 ) != VLC_SUCCESS ) | 338 | 0 | return VLC_EGENERIC; | 339 | | | 340 | 9 | const struct vlc_a52_bitstream_info *bs = &p_header->bs; | 341 | | | 342 | 9 | p_header->i_size = 2 * (bs->eac3.i_frmsiz + 1 ); | 343 | | | 344 | 9 | if( bs->i_fscod == 0x03 ) | 345 | 0 | { | 346 | 0 | p_header->i_rate = pi_fscod_samplerates[bs->eac3.i_fscod2] / 2; | 347 | 0 | p_header->i_blocks_per_sync_frame = 6; | 348 | 0 | } | 349 | 9 | else | 350 | 9 | { | 351 | 9 | static const int pi_numblkscod [4] = { 1, 2, 3, 6 }; | 352 | 9 | p_header->i_rate = pi_fscod_samplerates[bs->i_fscod]; | 353 | 9 | p_header->i_blocks_per_sync_frame = pi_numblkscod[bs->eac3.i_numblkscod]; | 354 | 9 | } | 355 | | | 356 | 9 | p_header->i_channels_conf = p_acmod[bs->i_acmod]; | 357 | 9 | p_header->i_chan_mode = 0; | 358 | 9 | if( bs->i_acmod == 0 ) | 359 | 6 | p_header->i_chan_mode |= AOUT_CHANMODE_DUALMONO; | 360 | 9 | if( bs->i_lfeon ) | 361 | 6 | p_header->i_channels_conf |= AOUT_CHAN_LFE; | 362 | 9 | p_header->i_channels = vlc_popcount( p_header->i_channels_conf ); | 363 | 9 | p_header->i_bitrate = 8 * p_header->i_size * p_header->i_rate | 364 | 9 | / (p_header->i_blocks_per_sync_frame * 256); | 365 | 9 | p_header->i_samples = p_header->i_blocks_per_sync_frame * 256; | 366 | | | 367 | 9 | p_header->b_eac3 = true; | 368 | 9 | return VLC_SUCCESS; | 369 | 9 | } |
a52.c:vlc_a52_header_ParseEac3 Line | Count | Source | 334 | 3.49k | { | 335 | 3.49k | if( vlc_a52_ParseEac3BitstreamInfo( &p_header->bs, | 336 | 3.49k | &p_buf[2], /* start code */ | 337 | 3.49k | VLC_A52_MIN_HEADER_SIZE - 2 ) != VLC_SUCCESS ) | 338 | 1 | return VLC_EGENERIC; | 339 | | | 340 | 3.49k | const struct vlc_a52_bitstream_info *bs = &p_header->bs; | 341 | | | 342 | 3.49k | p_header->i_size = 2 * (bs->eac3.i_frmsiz + 1 ); | 343 | | | 344 | 3.49k | if( bs->i_fscod == 0x03 ) | 345 | 537 | { | 346 | 537 | p_header->i_rate = pi_fscod_samplerates[bs->eac3.i_fscod2] / 2; | 347 | 537 | p_header->i_blocks_per_sync_frame = 6; | 348 | 537 | } | 349 | 2.95k | else | 350 | 2.95k | { | 351 | 2.95k | static const int pi_numblkscod [4] = { 1, 2, 3, 6 }; | 352 | 2.95k | p_header->i_rate = pi_fscod_samplerates[bs->i_fscod]; | 353 | 2.95k | p_header->i_blocks_per_sync_frame = pi_numblkscod[bs->eac3.i_numblkscod]; | 354 | 2.95k | } | 355 | | | 356 | 3.49k | p_header->i_channels_conf = p_acmod[bs->i_acmod]; | 357 | 3.49k | p_header->i_chan_mode = 0; | 358 | 3.49k | if( bs->i_acmod == 0 ) | 359 | 2.20k | p_header->i_chan_mode |= AOUT_CHANMODE_DUALMONO; | 360 | 3.49k | if( bs->i_lfeon ) | 361 | 2.27k | p_header->i_channels_conf |= AOUT_CHAN_LFE; | 362 | 3.49k | p_header->i_channels = vlc_popcount( p_header->i_channels_conf ); | 363 | 3.49k | p_header->i_bitrate = 8 * p_header->i_size * p_header->i_rate | 364 | 3.49k | / (p_header->i_blocks_per_sync_frame * 256); | 365 | 3.49k | p_header->i_samples = p_header->i_blocks_per_sync_frame * 256; | 366 | | | 367 | 3.49k | p_header->b_eac3 = true; | 368 | 3.49k | return VLC_SUCCESS; | 369 | 3.49k | } |
mlp.c:vlc_a52_header_ParseEac3 Line | Count | Source | 334 | 193k | { | 335 | 193k | if( vlc_a52_ParseEac3BitstreamInfo( &p_header->bs, | 336 | 193k | &p_buf[2], /* start code */ | 337 | 193k | VLC_A52_MIN_HEADER_SIZE - 2 ) != VLC_SUCCESS ) | 338 | 216 | return VLC_EGENERIC; | 339 | | | 340 | 193k | const struct vlc_a52_bitstream_info *bs = &p_header->bs; | 341 | | | 342 | 193k | p_header->i_size = 2 * (bs->eac3.i_frmsiz + 1 ); | 343 | | | 344 | 193k | if( bs->i_fscod == 0x03 ) | 345 | 93.6k | { | 346 | 93.6k | p_header->i_rate = pi_fscod_samplerates[bs->eac3.i_fscod2] / 2; | 347 | 93.6k | p_header->i_blocks_per_sync_frame = 6; | 348 | 93.6k | } | 349 | 99.6k | else | 350 | 99.6k | { | 351 | 99.6k | static const int pi_numblkscod [4] = { 1, 2, 3, 6 }; | 352 | 99.6k | p_header->i_rate = pi_fscod_samplerates[bs->i_fscod]; | 353 | 99.6k | p_header->i_blocks_per_sync_frame = pi_numblkscod[bs->eac3.i_numblkscod]; | 354 | 99.6k | } | 355 | | | 356 | 193k | p_header->i_channels_conf = p_acmod[bs->i_acmod]; | 357 | 193k | p_header->i_chan_mode = 0; | 358 | 193k | if( bs->i_acmod == 0 ) | 359 | 280 | p_header->i_chan_mode |= AOUT_CHANMODE_DUALMONO; | 360 | 193k | if( bs->i_lfeon ) | 361 | 192k | p_header->i_channels_conf |= AOUT_CHAN_LFE; | 362 | 193k | p_header->i_channels = vlc_popcount( p_header->i_channels_conf ); | 363 | 193k | p_header->i_bitrate = 8 * p_header->i_size * p_header->i_rate | 364 | 193k | / (p_header->i_blocks_per_sync_frame * 256); | 365 | 193k | p_header->i_samples = p_header->i_blocks_per_sync_frame * 256; | 366 | | | 367 | 193k | p_header->b_eac3 = true; | 368 | 193k | return VLC_SUCCESS; | 369 | 193k | } |
|
370 | | |
371 | | /** |
372 | | * It will parse the header AC3 frame and fill vlc_a52_header_t* if |
373 | | * it is valid or return VLC_EGENERIC. |
374 | | * |
375 | | * XXX It will only recognize big endian bitstream ie starting with 0x0b, 0x77 |
376 | | */ |
377 | | static inline int vlc_a52_header_Parse( vlc_a52_header_t *p_header, |
378 | | const uint8_t *p_buffer, int i_buffer ) |
379 | 275k | { |
380 | 275k | static const uint32_t p_acmod[8] = { |
381 | 275k | AOUT_CHANS_2_0, |
382 | 275k | AOUT_CHAN_CENTER, |
383 | 275k | AOUT_CHANS_2_0, |
384 | 275k | AOUT_CHANS_3_0, |
385 | 275k | AOUT_CHANS_FRONT | AOUT_CHAN_REARCENTER, /* 2F1R */ |
386 | 275k | AOUT_CHANS_FRONT | AOUT_CHANS_CENTER, /* 3F1R */ |
387 | 275k | AOUT_CHANS_4_0, |
388 | 275k | AOUT_CHANS_5_0, |
389 | 275k | }; |
390 | 275k | static const unsigned pi_fscod_samplerates[] = { |
391 | 275k | 48000, 44100, 32000 |
392 | 275k | }; |
393 | | |
394 | 275k | if( i_buffer < VLC_A52_MIN_HEADER_SIZE ) |
395 | 0 | return VLC_EGENERIC; |
396 | | |
397 | | /* Check synword */ |
398 | 275k | if( p_buffer[0] != 0x0b || p_buffer[1] != 0x77 ) |
399 | 70.6k | return VLC_EGENERIC; |
400 | | |
401 | | /* Check bsid */ |
402 | 204k | const int bsid = p_buffer[5] >> 3; |
403 | | |
404 | | /* cf. Annex E 2.3.1.6 of AC3 spec */ |
405 | 204k | if( bsid <= 10 ) |
406 | 6.07k | return vlc_a52_header_ParseAc3( p_header, p_buffer, |
407 | 6.07k | p_acmod, pi_fscod_samplerates ); |
408 | 198k | else if( bsid <= 16 ) |
409 | 196k | return vlc_a52_header_ParseEac3( p_header, p_buffer, |
410 | 196k | p_acmod, pi_fscod_samplerates ); |
411 | 1.61k | else |
412 | 1.61k | return VLC_EGENERIC; |
413 | 204k | } es.c:vlc_a52_header_Parse Line | Count | Source | 379 | 81 | { | 380 | 81 | static const uint32_t p_acmod[8] = { | 381 | 81 | AOUT_CHANS_2_0, | 382 | 81 | AOUT_CHAN_CENTER, | 383 | 81 | AOUT_CHANS_2_0, | 384 | 81 | AOUT_CHANS_3_0, | 385 | 81 | AOUT_CHANS_FRONT | AOUT_CHAN_REARCENTER, /* 2F1R */ | 386 | 81 | AOUT_CHANS_FRONT | AOUT_CHANS_CENTER, /* 3F1R */ | 387 | 81 | AOUT_CHANS_4_0, | 388 | 81 | AOUT_CHANS_5_0, | 389 | 81 | }; | 390 | 81 | static const unsigned pi_fscod_samplerates[] = { | 391 | 81 | 48000, 44100, 32000 | 392 | 81 | }; | 393 | | | 394 | 81 | if( i_buffer < VLC_A52_MIN_HEADER_SIZE ) | 395 | 0 | return VLC_EGENERIC; | 396 | | | 397 | | /* Check synword */ | 398 | 81 | if( p_buffer[0] != 0x0b || p_buffer[1] != 0x77 ) | 399 | 72 | return VLC_EGENERIC; | 400 | | | 401 | | /* Check bsid */ | 402 | 9 | const int bsid = p_buffer[5] >> 3; | 403 | | | 404 | | /* cf. Annex E 2.3.1.6 of AC3 spec */ | 405 | 9 | if( bsid <= 10 ) | 406 | 0 | return vlc_a52_header_ParseAc3( p_header, p_buffer, | 407 | 0 | p_acmod, pi_fscod_samplerates ); | 408 | 9 | else if( bsid <= 16 ) | 409 | 9 | return vlc_a52_header_ParseEac3( p_header, p_buffer, | 410 | 9 | p_acmod, pi_fscod_samplerates ); | 411 | 0 | else | 412 | 0 | return VLC_EGENERIC; | 413 | 9 | } |
a52.c:vlc_a52_header_Parse Line | Count | Source | 379 | 3.72k | { | 380 | 3.72k | static const uint32_t p_acmod[8] = { | 381 | 3.72k | AOUT_CHANS_2_0, | 382 | 3.72k | AOUT_CHAN_CENTER, | 383 | 3.72k | AOUT_CHANS_2_0, | 384 | 3.72k | AOUT_CHANS_3_0, | 385 | 3.72k | AOUT_CHANS_FRONT | AOUT_CHAN_REARCENTER, /* 2F1R */ | 386 | 3.72k | AOUT_CHANS_FRONT | AOUT_CHANS_CENTER, /* 3F1R */ | 387 | 3.72k | AOUT_CHANS_4_0, | 388 | 3.72k | AOUT_CHANS_5_0, | 389 | 3.72k | }; | 390 | 3.72k | static const unsigned pi_fscod_samplerates[] = { | 391 | 3.72k | 48000, 44100, 32000 | 392 | 3.72k | }; | 393 | | | 394 | 3.72k | if( i_buffer < VLC_A52_MIN_HEADER_SIZE ) | 395 | 0 | return VLC_EGENERIC; | 396 | | | 397 | | /* Check synword */ | 398 | 3.72k | if( p_buffer[0] != 0x0b || p_buffer[1] != 0x77 ) | 399 | 0 | return VLC_EGENERIC; | 400 | | | 401 | | /* Check bsid */ | 402 | 3.72k | const int bsid = p_buffer[5] >> 3; | 403 | | | 404 | | /* cf. Annex E 2.3.1.6 of AC3 spec */ | 405 | 3.72k | if( bsid <= 10 ) | 406 | 190 | return vlc_a52_header_ParseAc3( p_header, p_buffer, | 407 | 190 | p_acmod, pi_fscod_samplerates ); | 408 | 3.53k | else if( bsid <= 16 ) | 409 | 3.49k | return vlc_a52_header_ParseEac3( p_header, p_buffer, | 410 | 3.49k | p_acmod, pi_fscod_samplerates ); | 411 | 34 | else | 412 | 34 | return VLC_EGENERIC; | 413 | 3.72k | } |
mlp.c:vlc_a52_header_Parse Line | Count | Source | 379 | 271k | { | 380 | 271k | static const uint32_t p_acmod[8] = { | 381 | 271k | AOUT_CHANS_2_0, | 382 | 271k | AOUT_CHAN_CENTER, | 383 | 271k | AOUT_CHANS_2_0, | 384 | 271k | AOUT_CHANS_3_0, | 385 | 271k | AOUT_CHANS_FRONT | AOUT_CHAN_REARCENTER, /* 2F1R */ | 386 | 271k | AOUT_CHANS_FRONT | AOUT_CHANS_CENTER, /* 3F1R */ | 387 | 271k | AOUT_CHANS_4_0, | 388 | 271k | AOUT_CHANS_5_0, | 389 | 271k | }; | 390 | 271k | static const unsigned pi_fscod_samplerates[] = { | 391 | 271k | 48000, 44100, 32000 | 392 | 271k | }; | 393 | | | 394 | 271k | if( i_buffer < VLC_A52_MIN_HEADER_SIZE ) | 395 | 0 | return VLC_EGENERIC; | 396 | | | 397 | | /* Check synword */ | 398 | 271k | if( p_buffer[0] != 0x0b || p_buffer[1] != 0x77 ) | 399 | 70.5k | return VLC_EGENERIC; | 400 | | | 401 | | /* Check bsid */ | 402 | 200k | const int bsid = p_buffer[5] >> 3; | 403 | | | 404 | | /* cf. Annex E 2.3.1.6 of AC3 spec */ | 405 | 200k | if( bsid <= 10 ) | 406 | 5.88k | return vlc_a52_header_ParseAc3( p_header, p_buffer, | 407 | 5.88k | p_acmod, pi_fscod_samplerates ); | 408 | 195k | else if( bsid <= 16 ) | 409 | 193k | return vlc_a52_header_ParseEac3( p_header, p_buffer, | 410 | 193k | p_acmod, pi_fscod_samplerates ); | 411 | 1.58k | else | 412 | 1.58k | return VLC_EGENERIC; | 413 | 200k | } |
|
414 | | |
415 | | #endif |