1 /* 2 * 3 * This library is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU Library General Public 5 * License as published by the Free Software Foundation; either 6 * version 2 of the License, or (at your option) any later version. 7 * 8 * This library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * Library General Public License for more details. 12 * 13 * You should have received a copy of the GNU Library General Public 14 * License along with this library; if not, write to the 15 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 16 * Boston, MA 02110-1301, USA. 17 * 18 * The Original Code is Fluendo MPEG Demuxer plugin. 19 * 20 * The Initial Developer of the Original Code is Fluendo, S.L. 21 * Portions created by Fluendo, S.L. are Copyright (C) 2005 22 * Fluendo, S.L. All Rights Reserved. 23 * 24 * Contributor(s): Wim Taymans <wim@fluendo.com> 25 */ 26 27 #ifndef __GST_MPEG_DEFS_H__ 28 #define __GST_MPEG_DEFS_H__ 29 #include <glib/gprintf.h> 30 31 #define SAFE_FOURCC_FORMAT "02x%02x%02x%02x (%c%c%c%c)" 32 #define SAFE_CHAR(a) (g_ascii_isalnum((gchar) (a)) ? ((gchar)(a)) : '.') 33 #define SAFE_FOURCC_ARGS(a) \ 34 ((guint8) ((a)>>24)), \ 35 ((guint8) ((a) >> 16 & 0xff)), \ 36 ((guint8) ((a) >> 8 & 0xff)), \ 37 ((guint8) ((a) & 0xff)), \ 38 SAFE_CHAR((a)>>24), \ 39 SAFE_CHAR((a) >> 16 & 0xff), \ 40 SAFE_CHAR((a) >> 8 & 0xff), \ 41 SAFE_CHAR(a & 0xff) 42 43 /* Stream type assignments */ 44 /* FIXME: Put these in mpegts lib separate stream type enums */ 45 /* Un-official Dirac extension */ 46 #define ST_VIDEO_DIRAC 0xd1 47 48 /* private stream types */ 49 #define ST_PS_VIDEO_MPEG2_DCII 0x80 50 #define ST_PS_AUDIO_AC3 0x81 51 #define ST_PS_AUDIO_EAC3 0x87 52 #define ST_PS_AUDIO_LPCM2 0x83 53 #define ST_PS_AUDIO_DTS 0x8a 54 #define ST_PS_AUDIO_LPCM 0x8b 55 #define ST_PS_DVD_SUBPICTURE 0xff 56 57 /* Blu-ray related (registration: 'HDMV'*/ 58 #define ST_BD_AUDIO_LPCM 0x80 59 #define ST_BD_AUDIO_AC3 0x81 60 #define ST_BD_AUDIO_DTS 0x82 61 #define ST_BD_AUDIO_AC3_TRUE_HD 0x83 62 #define ST_BD_AUDIO_AC3_PLUS 0x84 63 #define ST_BD_AUDIO_DTS_HD 0x85 64 #define ST_BD_AUDIO_DTS_HD_MASTER_AUDIO 0x86 65 #define ST_BD_AUDIO_EAC3 0x87 66 #define ST_BD_PGS_SUBPICTURE 0x90 67 #define ST_BD_IGS 0x91 68 #define ST_BD_SUBTITLE 0x92 69 #define ST_BD_SECONDARY_AC3_PLUS 0xa1 70 #define ST_BD_SECONDARY_DTS_HD 0xa2 71 72 /* defined for VC1 extension in RP227 */ 73 #define ST_PRIVATE_EA 0xea 74 75 /* Following only apply for streams identified as HDV, 76 * According to specification 61834-11 the PMT will use 77 * a registration descriptor with values TSMV or TSHV */ 78 /* HDV AUX stream mapping 79 * 0xA0 ISO/IEC 61834-11 80 * 0xA1 ISO/IEC 61834-11 81 */ 82 #define ST_HDV_AUX_A 0xa0 83 #define ST_HDV_AUX_V 0xa1 84 85 #define CLOCK_BASE 9LL 86 #define CLOCK_FREQ (CLOCK_BASE * 10000) 87 88 /* Numerical values for second/millisecond in PCR units */ 89 #define PCR_SECOND 27000000 90 #define PCR_MSECOND 27000 91 92 /* PCR_TO_GST calculation requires at least 10 extra bits. 93 * Since maximum PCR value is coded with 42 bits, we are 94 * safe to use direct calculation (10+42 < 63)*/ 95 #define PCRTIME_TO_GSTTIME(t) (((t) * (guint64)1000) / 27) 96 97 /* MPEG_TO_GST calculation requires at least 17 extra bits (100000) 98 * Since maximum PTS/DTS value is coded with 33bits, we are 99 * safe to use direct calculation (17+33 < 63) */ 100 #define MPEGTIME_TO_GSTTIME(t) ((t) * (guint64)100000 / 9) 101 102 #define GSTTIME_TO_MPEGTIME(time) (gst_util_uint64_scale ((time), \ 103 CLOCK_BASE, GST_MSECOND/10)) 104 #define GSTTIME_TO_PCRTIME(time) (gst_util_uint64_scale ((time), \ 105 300 * CLOCK_BASE, GST_MSECOND/10)) 106 107 #define MPEG_MUX_RATE_MULT 50 108 109 /* sync:4 == 00xx ! pts:3 ! 1 ! pts:15 ! 1 | pts:15 ! 1 */ 110 #define READ_TS(data, target, lost_sync_label) \ 111 if ((*data & 0x01) != 0x01) goto lost_sync_label; \ 112 target = ((guint64) (*data++ & 0x0E)) << 29; \ 113 target |= ((guint64) (*data++ )) << 22; \ 114 if ((*data & 0x01) != 0x01) goto lost_sync_label; \ 115 target |= ((guint64) (*data++ & 0xFE)) << 14; \ 116 target |= ((guint64) (*data++ )) << 7; \ 117 if ((*data & 0x01) != 0x01) goto lost_sync_label; \ 118 target |= ((guint64) (*data++ & 0xFE)) >> 1; 119 120 #endif /* __GST_MPEG_DEFS_H__ */ 121