Use ftello/fseeko instead of ftell/fseek
[L-SMASH.git] / dts.h
blobfcb70dbabf49670966bc5301b74c741bf36cc20e
1 /*****************************************************************************
2 * dts.h:
3 *****************************************************************************
4 * Copyright (C) 2012 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 DTS_MAX_CORE_SIZE 16384
24 #define DTS_MAX_EXTENSION_SIZE 32768
26 typedef enum
28 DTS_SUBSTREAM_TYPE_NONE = 0,
29 DTS_SUBSTREAM_TYPE_CORE = 1,
30 DTS_SUBSTREAM_TYPE_EXTENSION = 2,
31 } dts_substream_type;
33 typedef struct
35 uint32_t sampling_frequency;
36 uint32_t frame_duration;
37 uint16_t frame_size;
38 uint16_t channel_layout;
39 uint8_t channel_arrangement;
40 uint8_t xxch_lower_planes;
41 uint8_t extension_audio_descriptor;
42 uint8_t pcm_resolution;
43 } dts_core_info_t;
45 typedef struct
47 uint32_t sampling_frequency;
48 uint32_t frame_duration;
49 uint16_t channel_layout;
50 uint8_t xxch_lower_planes;
51 uint8_t bStaticFieldsPresent;
52 uint8_t bMixMetadataEnbl;
53 uint8_t bOne2OneMapChannels2Speakers;
54 uint8_t nuNumMixOutConfigs;
55 uint8_t nNumMixOutCh[4];
56 uint8_t number_of_assets;
57 uint8_t stereo_downmix;
58 uint8_t representation_type;
59 uint8_t bit_resolution;
60 } dts_extension_info_t;
62 typedef struct
64 uint32_t sampling_frequency;
65 uint32_t frame_duration;
66 uint16_t channel_layout;
67 uint8_t bit_width;
68 } dts_lossless_info_t;
70 typedef struct
72 uint32_t sampling_frequency;
73 uint32_t frame_duration;
74 uint16_t channel_layout;
75 uint8_t stereo_downmix;
76 uint8_t lfe_present;
77 uint8_t duration_modifier;
78 uint8_t sample_size;
79 } dts_lbr_info_t;
81 typedef struct
83 dts_substream_type substream_type;
84 lsmash_dts_construction_flag flags;
85 lsmash_dts_specific_parameters_t ddts_param;
86 dts_core_info_t core;
87 dts_extension_info_t extension;
88 dts_lossless_info_t lossless;
89 dts_lbr_info_t lbr;
90 uint8_t ddts_param_initialized;
91 uint8_t no_more_read;
92 uint8_t extension_index;
93 uint8_t extension_substream_count;
94 uint32_t frame_duration;
95 uint32_t frame_size;
96 uint8_t buffer[2 * DTS_MAX_EXTENSION_SIZE];
97 uint8_t *buffer_pos;
98 uint8_t *buffer_end;
99 lsmash_bits_t *bits;
100 lsmash_multiple_buffers_t *au_buffers;
101 uint8_t *au;
102 uint32_t au_length;
103 uint8_t *incomplete_au;
104 uint32_t incomplete_au_length;
105 uint32_t au_number;
106 } dts_info_t;
108 int dts_parse_core_substream( dts_info_t *info, uint8_t *data, uint32_t data_length );
109 int dts_parse_extension_substream( dts_info_t *info, uint8_t *data, uint32_t data_length );
110 int dts_get_channel_count_from_channel_layout( uint16_t channel_layout );
111 dts_substream_type dts_get_substream_type( dts_info_t *info );
112 int dts_get_extension_index( dts_info_t *info, uint8_t *extension_index );
113 void dts_update_specific_param( dts_info_t *info );