⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpeg_descriptor.c

📁 dvbsnoop is a DVB/MPEG stream analyzer program. The program can be used to sniff, monitor, debug, d
💻 C
📖 第 1 页 / 共 3 页
字号:
/*$Id: mpeg_descriptor.c,v 1.26 2004/11/03 21:00:52 rasc Exp $ DVBSNOOP a dvb sniffer  and mpeg2 stream analyzer tool http://dvbsnoop.sourceforge.net/ (c) 2001-2004   Rainer.Scherg@gmx.de (rasc) -- MPEG Descriptors  ISO/IEC 13818-1/6 -- all descriptors are returning their length used in buffer$Log: mpeg_descriptor.c,v $Revision 1.26  2004/11/03 21:00:52  rasc - New: "premiere.de" private tables and descriptors (tnx to Peter.Pavlov, Premiere) - New: cmd option "-privateprovider <provider name>" - New: Private provider sections and descriptors decoding - Changed: complete restructuring of private descriptors and sectionsRevision 1.25  2004/08/13 11:05:29  rascMetadata_STD_descriptorRevision 1.24  2004/08/12 22:57:18  rasc - New: MPEG Content Labeling descriptor  (H.222.0 AMD1) - New: PES update ITU-T H.222.0 AMD2H.222.0 AMD3 updates startedRevision 1.23  2004/08/01 21:33:08  rascminor TVA stuff (TS 102 323)Revision 1.22  2004/07/26 20:58:03  rascRNT completed..  (TS 102 323)Revision 1.21  2004/07/25 20:12:58  rasc - New: content_identifier_descriptor (TS 102 323) - New: TVA_id_descriptor (TS 102 323) - New: related_content_descriptor (TS 102 323) - New: default_authority_descriptor (TS 102 323)Revision 1.20  2004/07/24 11:44:44  rascEN 301 192 update - New: ECM_repetition_rate_descriptor (EN 301 192 v1.4.1) - New: time_slice_fec_identifier_descriptor (EN 301 192 v1.4.1) - New: Section MPE_FEC  EN 301 192 v1.4 - BugfixesRevision 1.19  2004/03/31 21:14:23  rascNew: Spider section pids  (snoop referenced section pids),some minor changesRevision 1.18  2004/02/24 23:03:05  rascprivate data of DSMCC::DSIBIOP::ServiceGatewayInformation()IOP::IOR()Revision 1.17  2004/02/20 22:18:39  rascDII complete (hopefully)BIOP::ModuleInfo  (damned, who is spreading infos over several standards???)maybe someone give me a hint on the selector_byte info!!!some minor changes...Revision 1.16  2004/01/17 23:06:08  rascminor stuff, some restructs in outputRevision 1.15  2004/01/15 21:27:22  rascDSM-CC stream descriptorsRevision 1.14  2004/01/12 23:05:25  rascno messageRevision 1.13  2004/01/02 16:40:34  rascDSM-CC  INT/UNT descriptors completeminor changes and fixesRevision 1.12  2004/01/01 20:35:26  rascPES program stream map, minor descriptor cleanupRevision 1.11  2004/01/01 20:31:22  rascPES program stream map, minor descriptor cleanupRevision 1.10  2004/01/01 20:09:20  rascDSM-CC INT/UNT descriptorsPES-sync changed, TS sync changed,descriptor scopeother changesRevision 1.9  2003/11/26 16:27:45  rasc- mpeg4 descriptors- simplified bit decoding and output functionRevision 1.8  2003/10/27 22:43:49  rasccarousel info descriptor and moreRevision 1.7  2003/10/26 19:06:27  rascno messageRevision 1.6  2003/10/25 19:11:49  rascno messageRevision 1.5  2003/10/24 22:45:04  rasccode reorg...Revision 1.4  2003/10/24 22:17:17  rasccode reorg...Revision 1.3  2003/10/17 18:16:54  rasc- started more work on newer ISO 13818  descriptors- some reorg work startedRevision 1.2  2003/09/09 05:12:45  obiprint format identifier of registration descriptor in ascii.looks quite strange but is nice to see :)Revision 1.1  2003/07/08 19:59:50  rascrestructuring... some new, some fixes,trying to include DSM-CC, Well someone a ISO13818-6 and latest version of ISO 18313-1 to spare?*/#include "dvbsnoop.h"#include "descriptor.h"#include "mpeg_descriptor.h"#include "descriptor_misc.h"#include "private/userdefs.h"#include "strings/dvb_str.h"#include "strings/dsmcc_str.h"#include "misc/hexprint.h"#include "misc/output.h"#include "misc/pid_mem.h"/*  determine MPEG descriptor type and print it...  return byte length  2004-08-11  updated H.222.0 AMD1*/int  descriptorMPEG  (u_char *b){ int len; int id;  id  =  (int) b[0];  len = ((int) b[1]) + 2;  out_NL (4);  out_S2B_NL (4,"MPEG-DescriptorTag: ",id, dvbstrMPEGDescriptorTAG(id));  out_SB_NL  (5,"Descriptor_length: ",b[1]);  // empty ??  len = ((int)b[1]) + 2;  if (b[1] == 0)	 return len;  // print hex buf of descriptor  printhex_buf (9, b,len);  switch (b[0]) {     case 0x02:  descriptorMPEG_VideoStream  (b);  break;     case 0x03:  descriptorMPEG_AudioStream  (b);  break;     case 0x04:  descriptorMPEG_Hierarchy  (b);  break;     case 0x05:  descriptorMPEG_Registration  (b);  break;     case 0x06:  descriptorMPEG_DataStreamAlignment (b);  break;     case 0x07:  descriptorMPEG_TargetBackgroundGrid (b);  break;     case 0x08:  descriptorMPEG_VideoWindow (b);  break;     case 0x09:  descriptorMPEG_CA  (b);  break;     case 0x0A:  descriptorMPEG_ISO639_Lang  (b);  break;     case 0x0B:  descriptorMPEG_SystemClock (b);  break;     case 0x0C:  descriptorMPEG_MultiplexBufUtil (b);  break;     case 0x0D:  descriptorMPEG_Copyright  (b);  break;     case 0x0E:  descriptorMPEG_MaxBitrate  (b);  break;     case 0x0F:  descriptorMPEG_PrivateDataIndicator  (b);  break;     case 0x10:  descriptorMPEG_SmoothingBuf  (b);  break;      case 0x11:  descriptorMPEG_STD  (b);  break;      case 0x12:  descriptorMPEG_IBP  (b);  break;      /* 0x13 - 0x1A  DSM-CC ISO13818-6,  TR 102 006 */     case 0x13:  descriptorMPEG_Carousel_Identifier (b);  break;      case 0x14:  descriptorMPEG_Association_tag (b);  break;      case 0x15:  descriptorMPEG_Deferred_Association_tags (b);  break;      /* DSM-CC stream descriptors */     // case 0x16: reserved....     case 0x17:  descriptorMPEG_NPT_reference (b);  break;      case 0x18:  descriptorMPEG_NPT_endpoint (b);  break;      case 0x19:  descriptorMPEG_stream_mode (b);  break;      case 0x1A:  descriptorMPEG_stream_event (b);  break;      /* MPEG 4 */     case 0x1B:  descriptorMPEG_MPEG4_video (b);  break;      case 0x1C:  descriptorMPEG_MPEG4_audio (b);  break;      case 0x1D:  descriptorMPEG_IOD (b);  break;      case 0x1E:  descriptorMPEG_SL (b);  break;      case 0x1F:  descriptorMPEG_FMC (b);  break;      case 0x20:  descriptorMPEG_External_ES_ID (b);  break;      case 0x21:  descriptorMPEG_MuxCode (b);  break;      case 0x22:  descriptorMPEG_FMXBufferSize (b);  break;      case 0x23:  descriptorMPEG_MultiplexBuffer (b);  break;      // case 0x24:  descriptorMPEG_FlexMuxTiming (b);  break;  // collision with content_labeling desc.  H.222.0 (obsolete??)     case 0x24:  descriptorMPEG_ContentLabeling(b);  break;     /* TV ANYTIME, TS 102 323 */     case 0x25:  descriptorMPEG_TVA_metadata_pointer (b);  break;      case 0x26:  descriptorMPEG_TVA_metadata (b);  break;      case 0x27:  descriptorMPEG_TVA_metadata_STD (b);  break;      /* H.222.0 AMD 3 */     case 0x28:  descriptorMPEG_AVC_video (b);  break;      case 0x29:  descriptorMPEG_IPMP (b);  break;      case 0x2A:  descriptorMPEG_AVC_timing_and_HRD (b);  break;      default: 	if (b[0] < 0x80) {	   out_nl (0,"  ----> ERROR: unimplemented descriptor (mpeg context), Report!");	}	// descriptor_any (b);	descriptor_PRIVATE (b,MPEG);	break;  }   return len;   // (descriptor total length)}/* ---------------------------------------------------------------   well known MPEG descriptors   --------------------------------------------------------------- *//*  0x02  VideoStream  descriptor   ISO 13818-1   2.6.xx*/void descriptorMPEG_VideoStream (u_char *b){ typedef struct  _descVidStream {    u_int      descriptor_tag;    u_int      descriptor_length;		    u_int      multiple_frame_rate_flag;    u_int      frame_rate_code;    u_int      MPEG_1_only_flag;    u_int      constrained_parameter_flag;    u_int      still_picture_flag;    // if MPEG_1_only_flag == 1    u_int	profile_and_level_indication;    u_int	chroma_format;    u_int	frame_rate_extension_flag;    u_int	reserved_1; } descVidStream; descVidStream  d; d.descriptor_tag		 = b[0]; d.descriptor_length       	 = b[1]; d.multiple_frame_rate_flag	 = getBits (b, 0, 16, 1); d.frame_rate_code		 = getBits (b, 0, 17, 4); d.MPEG_1_only_flag		 = getBits (b, 0, 21, 1); d.constrained_parameter_flag	 = getBits (b, 0, 22, 1); d.still_picture_flag		 = getBits (b, 0, 23, 1);  out_SB_NL (4,"multiple_frame_rate_flag: ",d.multiple_frame_rate_flag); out_SW_NL (4,"frame_rate_code: ",d.frame_rate_code); out_SB_NL (4,"MPEG_1_only_flag: ",d.MPEG_1_only_flag); out_SB_NL (4,"constrained_parameter_flag: ",d.constrained_parameter_flag); out_SB_NL (4,"still_picture_flag: ",d.still_picture_flag); if (d.MPEG_1_only_flag == 1) {    d.profile_and_level_indication	= getBits (b, 0, 24, 8);    d.chroma_format			= getBits (b, 0, 32, 2);    d.frame_rate_extension_flag		= getBits (b, 0, 34, 1);    d.reserved_1			= getBits (b, 0, 35, 5);    out_SB_NL (4,"profile_and_level_indication: ",d.profile_and_level_indication);    out_SB_NL (4,"chroma_format: ",d.chroma_format);    out_SB_NL (4,"frame_rate_extension_flag: ",d.frame_rate_extension_flag);    out_SB_NL (6,"reserved_1: ",d.reserved_1); } }/*  0x03  AudioStream  descriptor   ISO 13818-1   2.6.4*/void descriptorMPEG_AudioStream (u_char *b){ typedef struct  _descAudioStream {    u_int      descriptor_tag;    u_int      descriptor_length;		    u_int      free_format_flag;    u_int      ID;    u_int      layer;    u_int      variable_rate_audio_indicator;    u_int      reserved_1; } descAudioStream; descAudioStream  d; d.descriptor_tag		 = b[0]; d.descriptor_length       	 = b[1]; d.free_format_flag		 = getBits (b, 0, 16, 1); d.ID				 = getBits (b, 0, 17, 1); d.layer			 = getBits (b, 0, 18, 2); d.variable_rate_audio_indicator = getBits (b, 0, 20, 1); d.reserved_1			 = getBits (b, 0, 21, 3);  out_SB_NL (4,"free_format_flag: ",d.free_format_flag); out_SB_NL (4,"ID: ",d.ID); out_SB_NL (4,"layer: ",d.layer); out_SB_NL (4,"variable_rate_audio_indicator: ",d.variable_rate_audio_indicator); out_SB_NL (6,"reserved_1: ",d.reserved_1);}/*  0x04 Hierarchy  descriptor  ISO 13818-1 2.6.6*/void descriptorMPEG_Hierarchy (u_char *b){ typedef struct  _descHierarchy {    u_int      descriptor_tag;    u_int      descriptor_length;		    u_int      reserved_1;    u_int      hierarchy_type;    u_int      reserved_2;    u_int      hierarchy_layer_index;    u_int      reserved_3;    u_int      hierarchy_embedded_layer_index;    u_int      reserved_4;    u_int      hierarchy_channel; } descHierarchy; descHierarchy  d; d.descriptor_tag		 = b[0]; d.descriptor_length       	 = b[1]; d.reserved_1			 = getBits (b, 0, 16, 4); d.hierarchy_type 		 = getBits (b, 0, 20, 4); d.reserved_2			 = getBits (b, 0, 24, 2); d.hierarchy_layer_index	 = getBits (b, 0, 26, 6); d.reserved_3			 = getBits (b, 0, 32, 2); d.hierarchy_embedded_layer_index = getBits (b, 0, 34, 6); d.reserved_4			 = getBits (b, 0, 40, 2); d.hierarchy_channel		 = getBits (b, 0, 42, 6); out_SB_NL (6,"reserved_1: ",d.reserved_1); out_S2B_NL (4,"hierarchy_type: ",d.hierarchy_type,	dvbstrHierarchy_TYPE(d.hierarchy_type)); out_SB_NL (6,"reserved_2: ",d.reserved_2); out_SB_NL (4,"hierarchy_layer_index: ",d.hierarchy_layer_index); out_SB_NL (6,"reserved_3: ",d.reserved_3); out_SB_NL (4,"hierarchy_embedded_layer_index: ",d.hierarchy_embedded_layer_index); out_SB_NL (6,"reserved_4: ",d.reserved_4); out_SB_NL (4,"hierarchy_channel: ",d.hierarchy_channel);}/*  0x05 Registration  descriptor  ISO 13818-1 2.6.8*/void descriptorMPEG_Registration (u_char *b){ typedef struct  _descRegistration {    u_int      descriptor_tag;    u_int      descriptor_length;		    u_long      format_identifier;    // N   add. info } descRegistration; descRegistration  d; d.descriptor_tag		 = b[0]; d.descriptor_length       	 = b[1]; d.format_identifier		 = getBits (b, 0, 16, 32); out_S2L_NL (4,"format_identifier: ",d.format_identifier,"see: SC29"); indent(+1); printasciiline_buf (4, b+2, 4); indent(-1); print_databytes (4,"add. info:", b+6, d.descriptor_length -4);}/*  0x06  DataStreamAlignment descriptor   ISO 13818-1   2.6.11*/void descriptorMPEG_DataStreamAlignment (u_char *b){ typedef struct  _descDataStreamAlignment {    u_int      descriptor_tag;    u_int      descriptor_length;		    u_int      alignment_type; } descDataStreamAlignment; descDataStreamAlignment d; d.descriptor_tag		 = b[0]; d.descriptor_length       	 = b[1]; d.alignment_type		 = b[2];  out_SB_NL (4,"alignment_type: ",d.alignment_type); out (4,"   as VideoStream:  (= %s)",	dvbstrDataStreamVIDEOAlignment_TYPE(d.alignment_type)); out (4,"   as AudioStream:  (= %s)",	dvbstrDataStreamAUDIOAlignment_TYPE(d.alignment_type)); out_NL (4);}/*  0x07 Target Background Grid  descriptor  ISO 13818-1 2.6.12*/void descriptorMPEG_TargetBackgroundGrid (u_char *b){ typedef struct  _descTBGG {    u_int      descriptor_tag;    u_int      descriptor_length;		    u_int      horizontal_size;    u_int      vertical_size;    u_int      aspect_ratio_information; } descTBGG; descTBGG  d; d.descriptor_tag		 = b[0]; d.descriptor_length       	 = b[1]; d.horizontal_size		 = getBits (b, 0, 16, 14); d.vertical_size		 = getBits (b, 0, 30, 14); d.aspect_ratio_information	 = getBits (b, 0, 44, 4); out_S2W_NL (4,"horizontal_size: ",d.horizontal_size,"pixel"); out_S2W_NL (4,"vertical_size: ",d.vertical_size,"pixel"); out_S2B_NL  (4,"aspect_ratio_information: ",	d.aspect_ratio_information,	dvbstrAspectRatioInfo_FLAG(d.aspect_ratio_information));}/*  0x08 Video Window  descriptor  ISO 13818-1 2.6.14*/void descriptorMPEG_VideoWindow (u_char *b){ typedef struct  _descVidWin {    u_int      descriptor_tag;    u_int      descriptor_length;		    u_int      horizontal_offset;    u_int      vertical_offset;    u_int      window_priority; } descVidWin; descVidWin  d; d.descriptor_tag		 = b[0]; d.descriptor_length       	 = b[1]; d.horizontal_offset		 = getBits (b, 0, 16, 14); d.vertical_offset		 = getBits (b, 0, 30, 14); d.window_priority		 = getBits (b, 0, 44, 4); out_S2W_NL (4,"horizontal_offset: ",d.horizontal_offset,"pixel"); out_S2W_NL (4,"vertical_offset: ",d.vertical_offset,"pixel"); out_S2B_NL (4,"window_priority: ",d.window_priority,"(15 = highest)");}/*  0x09 CA descriptor  (condition access)*/void descriptorMPEG_CA (u_char *b){ /* IS13818-1  2.6.1 */ typedef struct  _descCA {    u_int      descriptor_tag;    u_int      descriptor_length;		    u_int      CA_system_ID;    u_int      reserved;    u_int      CA_PID;    // private data bytes } descCA; descCA  d; int     len; d.descriptor_tag		 = b[0]; d.descriptor_length       	 = b[1]; d.CA_system_ID			 = getBits (b, 0, 16, 16); d.reserved			 = getBits (b, 0, 32, 3); d.CA_PID			 = getBits (b, 0, 35, 13);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -