2 * This library is licensed under 2 different licenses and you
3 * can choose to use it under the terms of either one of them. The
4 * two licenses are the MPL 1.1 and the LGPL.
8 * The contents of this file are subject to the Mozilla Public License
9 * Version 1.1 (the "License"); you may not use this file except in
10 * compliance with the License. You may obtain a copy of the License at
11 * http://www.mozilla.org/MPL/.
13 * Software distributed under the License is distributed on an "AS IS"
14 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
15 * License for the specific language governing rights and limitations
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Library General Public
22 * License as published by the Free Software Foundation; either
23 * version 2 of the License, or (at your option) any later version.
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Library General Public License for more details.
30 * You should have received a copy of the GNU Library General Public
31 * License along with this library; if not, write to the
32 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
33 * Boston, MA 02111-1307, USA.
35 * The Original Code is Fluendo MPEG Demuxer plugin.
37 * The Initial Developer of the Original Code is Fluendo, S.L.
38 * Portions created by Fluendo, S.L. are Copyright (C) 2005
39 * Fluendo, S.L. All Rights Reserved.
41 * Contributor(s): Wim Taymans <wim@fluendo.com>
44 #ifndef __GST_MPEG_DEFS_H__
45 #define __GST_MPEG_DEFS_H__
48 * 1011 1100 program_stream_map
49 * 1011 1101 private_stream_1
50 * 1011 1110 padding_stream
51 * 1011 1111 private_stream_2
52 * 110x xxxx ISO/IEC 13818-3 or ISO/IEC 11172-3 audio stream number x xxxx
53 * 1110 xxxx ITU-T Rec. H.262 | ISO/IEC 13818-2 or ISO/IEC 11172-2 video stream number xxxx
54 * 1111 0000 ECM_stream
55 * 1111 0001 EMM_stream
56 * 1111 0010 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A or ISO/IEC 13818-6_DSMCC_stream
57 * 1111 0011 ISO/IEC_13522_stream
58 * 1111 0100 ITU-T Rec. H.222.1 type A
59 * 1111 0101 ITU-T Rec. H.222.1 type B
60 * 1111 0110 ITU-T Rec. H.222.1 type C
61 * 1111 0111 ITU-T Rec. H.222.1 type D
62 * 1111 1000 ITU-T Rec. H.222.1 type E
63 * 1111 1001 ancillary_stream
64 * 1111 1010 E 1111 1110 reserved data stream
65 * 1111 1111 program_stream_directory
68 #define ID_PS_END_CODE 0x000001B9
69 #define ID_PS_PACK_START_CODE 0x000001BA
70 #define ID_PS_SYSTEM_HEADER_START_CODE 0x000001BB
71 #define ID_PS_PROGRAM_STREAM_MAP 0x000001BC
72 #define ID_PRIVATE_STREAM_1 0x000001BD
73 #define ID_PADDING_STREAM 0x000001BE
74 #define ID_PRIVATE_STREAM_2 0x000001BF
75 #define ID_ISO_IEC_MPEG12_AUDIO_STREAM_0 0x000001C0
76 #define ID_ISO_IEC_MPEG12_AUDIO_STREAM_32 0x000001DF
77 #define ID_ISO_IEC_MPEG12_VIDEO_STREAM_0 0x000001E0
78 #define ID_ISO_IEC_MPEG12_VIDEO_STREAM_16 0x000001EF
79 #define ID_ECM_STREAM 0x000001F0
80 #define ID_EMM_STREAM 0x000001F1
81 #define ID_DSMCC_STREAM 0x000001F2
82 #define ID_ISO_IEC_13522_STREAM 0x000001F3
83 #define ID_ITU_TREC_H222_TYPE_A_STREAM 0x000001F4
84 #define ID_ITU_TREC_H222_TYPE_B_STREAM 0x000001F5
85 #define ID_ITU_TREC_H222_TYPE_C_STREAM 0x000001F6
86 #define ID_ITU_TREC_H222_TYPE_D_STREAM 0x000001F7
87 #define ID_ITU_TREC_H222_TYPE_E_STREAM 0x000001F8
88 #define ID_ANCILLARY_STREAM 0x000001F9
89 #define ID_RESERVED_STREAM_1 0x000001FA
90 #define ID_RESERVED_STREAM_2 0x000001FB
91 #define ID_EXTENDED_METADATA 0x000001FC
92 #define ID_EXTENDED_STREAM_ID 0x000001FD
93 #define ID_RESERVED_STREAM_3 0x000001FE
94 #define ID_PROGRAM_STREAM_DIRECTORY 0x000001FF
96 #define PACKET_VIDEO_START_CODE 0x000001E0
97 #define PACKET_AUDIO_START_CODE 0x000001C0
98 #define PICTURE_START_CODE 0x00000100
99 #define USER_DATA_START_CODE 0x000001B2
100 #define SEQUENCE_HEADER_CODE 0x000001B3
101 #define SEQUENCE_ERROR_CODE 0x000001B4
102 #define EXTENSION_START_CODE 0x000001B5
103 #define SEQUENCE_END_CODE 0x000001B7
104 #define GROUP_START_CODE 0x000001B8
106 #define AC3_SYNC_WORD 0x0b770000
108 #define MPEG_TS_SYNC_BYTE 0x00000047
110 #define PID_PROGRAM_ASSOCIATION_TABLE 0x0000
111 #define PID_CONDITIONAL_ACCESS_TABLE 0x0001
112 #define PID_RESERVED_FIRST 0x0002
113 #define PID_RESERVED_LAST 0x0010
114 #define PID_NULL_PACKET 0x1FFF
116 #define PID_TYPE_UNKNOWN 0
117 #define PID_TYPE_RESERVED 1
118 #define PID_TYPE_PROGRAM_ASSOCIATION 2
119 #define PID_TYPE_CONDITIONAL_ACCESS 3
120 #define PID_TYPE_PROGRAM_MAP 4
121 #define PID_TYPE_ELEMENTARY 5
122 #define PID_TYPE_NULL_PACKET 6
123 #define PID_TYPE_PRIVATE_SECTION 7
125 /* Stream type assignments
127 * 0x00 ITU-T | ISO/IEC Reserved
128 * 0x01 ISO/IEC 11172 Video
129 * 0x02 ITU-T Rec. H.262 | ISO/IEC 13818-2 Video or
130 * ISO/IEC 11172-2 constrained parameter video
132 * 0x03 ISO/IEC 11172 Audio
133 * 0x04 ISO/IEC 13818-3 Audio
134 * 0x05 ITU-T Rec. H.222.0 | ISO/IEC 13818-1
136 * 0x06 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES
137 * packets containing private data
138 * 0x07 ISO/IEC 13522 MHEG
139 * 0x08 ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Annex A
141 * 0x09 ITU-T Rec. H.222.1
142 * 0x0A ISO/IEC 13818-6 type A
143 * 0x0B ISO/IEC 13818-6 type B
144 * 0x0C ISO/IEC 13818-6 type C
145 * 0x0D ISO/IEC 13818-6 type D
146 * 0x0E ISO/IEC 13818-1 auxiliary
147 * 0x0F-0x7F ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved
148 * 0x80-0xFF User Private
150 #define ST_RESERVED 0x00
151 #define ST_VIDEO_MPEG1 0x01
152 #define ST_VIDEO_MPEG2 0x02
153 #define ST_AUDIO_MPEG1 0x03
154 #define ST_AUDIO_MPEG2 0x04
155 #define ST_PRIVATE_SECTIONS 0x05
156 #define ST_PRIVATE_DATA 0x06
158 #define ST_DSMCC 0x08
159 #define ST_H222_1 0x09
161 /* later extensions */
162 #define ST_AUDIO_AAC_ADTS 0x0f
163 /* LATM/LOAS AAC syntax */
164 #define ST_AUDIO_AAC_LOAS 0x11
165 #define ST_VIDEO_MPEG4 0x10
166 #define ST_VIDEO_H264 0x1b
168 /* Un-official Dirac extension */
169 #define ST_VIDEO_DIRAC 0xd1
171 /* private stream types */
172 #define ST_PS_AUDIO_AC3 0x81
173 #define ST_PS_AUDIO_DTS 0x8a
174 #define ST_PS_AUDIO_LPCM 0x8b
175 #define ST_PS_DVD_SUBPICTURE 0xff
176 /* Blu-ray related */
177 #define ST_BD_AUDIO_LPCM 0x80
178 #define ST_BD_AUDIO_AC3 0x81
179 #define ST_BD_AUDIO_DTS 0x82
180 #define ST_BD_AUDIO_AC3_TRUE_HD 0x83
181 #define ST_BD_AUDIO_AC3_PLUS 0x84
182 #define ST_BD_AUDIO_DTS_HD 0x85
183 #define ST_BD_AUDIO_DTS_HD_MASTER_AUDIO 0x86
184 #define ST_BD_AUDIO_EAC3 0x87
185 #define ST_BD_PGS_SUBPICTURE 0x90
186 #define ST_BD_IGS 0x91
187 #define ST_BD_SUBTITLE 0x92
188 #define ST_BD_SECONDARY_AC3_PLUS 0xa1
189 #define ST_BD_SECONDARY_DTS_HD 0xa2
191 /* defined for VC1 extension in RP227 */
192 #define ST_PRIVATE_EA 0xea
194 /* HDV AUX stream mapping
195 * 0xA0 ISO/IEC 61834-11
196 * 0xA1 ISO/IEC 61834-11
198 #define ST_HDV_AUX_A 0xa0
199 #define ST_HDV_AUX_V 0xa1
201 /* Un-official time-code stream */
202 #define ST_PS_TIMECODE 0xd2
204 /* Internal stream types >= 0x100 */
205 #define ST_GST_AUDIO_RAWA52 0x181
206 /* Used when we don't yet know which stream type it will be in a PS stream */
207 #define ST_GST_VIDEO_MPEG1_OR_2 0x102
209 #define CLOCK_BASE 9LL
210 #define CLOCK_FREQ (CLOCK_BASE * 10000)
212 #define MPEGTIME_TO_GSTTIME(time) (gst_util_uint64_scale ((time), \
213 GST_MSECOND/10, CLOCK_BASE))
214 #define GSTTIME_TO_MPEGTIME(time) (gst_util_uint64_scale ((time), \
215 CLOCK_BASE, GST_MSECOND/10))
217 #define MPEG_MUX_RATE_MULT 50
219 /* sync:4 == 00xx ! pts:3 ! 1 ! pts:15 ! 1 | pts:15 ! 1 */
220 #define READ_TS(data, target, lost_sync_label) \
221 if ((*data & 0x01) != 0x01) goto lost_sync_label; \
222 target = ((guint64) (*data++ & 0x0E)) << 29; \
223 target |= ((guint64) (*data++ )) << 22; \
224 if ((*data & 0x01) != 0x01) goto lost_sync_label; \
225 target |= ((guint64) (*data++ & 0xFE)) << 14; \
226 target |= ((guint64) (*data++ )) << 7; \
227 if ((*data & 0x01) != 0x01) goto lost_sync_label; \
228 target |= ((guint64) (*data++ & 0xFE)) >> 1;
230 /* some extra GstFlowReturn values used internally */
231 #define GST_FLOW_NEED_MORE_DATA GST_FLOW_CUSTOM_SUCCESS
232 #define GST_FLOW_LOST_SYNC GST_FLOW_CUSTOM_SUCCESS_1
234 #endif /* __GST_MPEG_DEFS_H__ */