3 #define EXTL_NEW_PLATFORM_ENABLE
6 //#include "extl/intelligence/intelligence.h"
7 //#include "extl/counter/counter.h"
8 //#include "extl/extl.h"
9 //#include "extl/media/media.h"
10 //#include "extl/test/test.h"
11 #include "extl/prefix.h"
13 EXTL_NS_USING_NAMESPACE(extl
)
15 //using namespace extl::media;
18 int hamming_d(int v1
, int v2
, int bit_n
)
21 for (int i
= 0; i
< bit_n
; ++i
)
23 int v1_i
= (int(0x1) == ((v1
>> i
) & int(0x1)));
24 int v2_i
= (int(0x1) == ((v2
>> i
) & int(0x1)));
25 if (v1_i
!= v2_i
) count
++;
32 printf("%d\n", hamming_d(5, 10, 5));
33 /*std::ifstream fin("data/test.ts", std::ios::in | std::ios::binary);
38 for (int i = 0; i < 10; i++)
40 fin.read((char*)buf, 188);
44 printf("transport header:\n" );
45 printf("sync_byte: %#x\n", pck.header().sync_byte() );
46 printf("transport_error_indicator: %u\n", pck.header().transport_error_indicator() );
47 printf("payload_unit_start_indicator: %u\n", pck.header().payload_unit_start_indicator() );
48 printf("transport_priority: %u\n", pck.header().transport_priority() );
49 printf("pid: %#x\n", pck.header().pid() );
50 printf("transport_scrambling_control: %u\n", pck.header().transport_scrambling_control() );
51 printf("adaptation_field_control: %u\n", pck.header().adaptation_field_control() );
52 printf("continuity_counter: %u\n", pck.header().continuity_counter() );
55 if (pck.is_null()) break;
58 if ( pck.is_scrambling()
63 printf("this packet cannot be analyzed!");
68 if (pck.adaptation().exists())
70 printf("\t adaptation_field header:\n" );
71 printf("\t adaptation_field_length: %u\n", pck.adaptation().header().adaptation_length() );
72 printf("\t discontinuity_indicator: %u\n", pck.adaptation().header().discontinuity_indicator() );
73 printf("\t random_access_indicator: %u\n", pck.adaptation().header().random_access_indicator() );
74 printf("\t elementary_stream_priority_indicator: %u\n", pck.adaptation().header().elementary_stream_priority_indicator());
75 printf("\t pcr_flag: %u\n", pck.adaptation().header().pcr_flag() );
76 printf("\t opcr_flag: %u\n", pck.adaptation().header().opcr_flag() );
77 printf("\t splicing_point_flag: %u\n", pck.adaptation().header().splicing_point_flag() );
78 printf("\t transport_private_data_flag: %u\n", pck.adaptation().header().private_data_flag() );
79 printf("\t extension_flag: %u\n", pck.adaptation().header().extension_flag() );
81 if (pck.adaptation().pcr().exists())
83 printf("\t pcr: %I64u\n", pck.adaptation().pcr().value() );
84 printf("\t pcr_base: %I64u\n", pck.adaptation().pcr().base() );
85 printf("\t pcr_extension: %u\n", pck.adaptation().pcr().extension() );
88 if (pck.adaptation().opcr().exists())
90 printf("\t pcr: %I64u\n", pck.adaptation().opcr().value() );
91 printf("\t pcr_base: %I64u\n", pck.adaptation().opcr().base() );
92 printf("\t pcr_extension: %u\n", pck.adaptation().opcr().extension() );
95 if (pck.adaptation().splicing().exists())
97 printf("\t splice_countdown: %u\n", pck.adaptation().splicing().countdown() );
100 if (pck.adaptation().private_data().exists())
102 printf("\t private_data_length: %u\n", pck.adaptation().private_data().size() );
103 for (int i = 0; i < (int)pck.adaptation().private_data().size(); ++i)
105 printf("\t private_data: %02x\n", pck.adaptation().private_data().data()[i] );
109 if (pck.adaptation().extension().exists())
111 printf("\t\t adaptation_extension_length: %u\n", pck.adaptation().extension().size() );
113 if (pck.adaptation().extension().exists_ltw())
115 printf("\t\t ltw_valid_flag: %u\n", pck.adaptation().extension().ltw().ltw_valid_flag );
116 printf("\t\t ltw_offset: %u\n", pck.adaptation().extension().ltw().ltw_offset );
119 if (pck.adaptation().extension().exists_piecewise_rate())
121 printf("\t\t piecewise_rate: %u\n", pck.adaptation().extension().piecewise_rate() );
124 if (pck.adaptation().extension().exists_seamless_splice())
126 printf("\t\t splice_type: %u\n", pck.adaptation().extension().seamless_splice().splice_type );