1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2012-2014 L-SMASH project
6 * Authors: Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 *****************************************************************************/
21 /* This file is available under an ISC license. */
23 #define AC3_MIN_SYNCFRAME_LENGTH 128
24 #define AC3_MAX_SYNCFRAME_LENGTH 3840
25 #define EAC3_MAX_SYNCFRAME_LENGTH 4096
29 lsmash_ac3_specific_parameters_t dac3_param
;
35 lsmash_eac3_specific_parameters_t dec3_param
;
36 lsmash_eac3_substream_info_t independent_info
[8];
37 lsmash_eac3_substream_info_t dependent_info
;
38 uint8_t dec3_param_initialized
;
41 uint8_t current_independent_substream_id
;
44 uint8_t number_of_audio_blocks
;
45 uint8_t number_of_independent_substreams
;
46 uint32_t syncframe_count
;
51 static const uint32_t ac3_sample_rate_table
[4] = { 48000, 44100, 32000, 0 };
52 static const uint32_t ac3_channel_count_table
[8] = { 2, 1, 2, 3, 3, 4, 4, 5 };
53 static const uint8_t eac3_audio_block_table
[4] = { 1, 2, 3, 6 };
55 static inline uint32_t ac3_get_channel_count
57 lsmash_ac3_specific_parameters_t
*dac3_param
60 return ac3_channel_count_table
[ dac3_param
->acmod
] + dac3_param
->lfeon
;
63 uint32_t ac3_get_sample_rate
65 lsmash_ac3_specific_parameters_t
*dac3_param
68 int ac3_parse_syncframe_header
73 int eac3_parse_syncframe
78 void eac3_update_specific_param
83 void eac3_update_sample_rate
86 lsmash_eac3_specific_parameters_t
*dec3_param
,
90 void eac3_update_channel_count
93 lsmash_eac3_specific_parameters_t
*dec3_param