This repository has been archived by the owner on Jun 15, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ExtlTest.cpp
executable file
·140 lines (117 loc) · 4.67 KB
/
ExtlTest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
//#include "stdio.h"
#define EXTL_NEW_PLATFORM_ENABLE
#define EXTL_DEBUG
#define EXTL_UNICODE
//#include "extl/intelligence/intelligence.h"
//#include "extl/counter/counter.h"
//#include "extl/extl.h"
//#include "extl/media/media.h"
//#include "extl/test/test.h"
#include "extl/prefix.h"
//#include "fstream"
EXTL_NS_USING_NAMESPACE(extl)
//using namespace extl::media;
int hamming_d(int v1, int v2, int bit_n)
{
int count = 0;
for (int i = 0; i < bit_n; ++i)
{
int v1_i = (int(0x1) == ((v1 >> i) & int(0x1)));
int v2_i = (int(0x1) == ((v2 >> i) & int(0x1)));
if (v1_i != v2_i) count++;
}
return count;
}
int main()
{
printf("%d\n", hamming_d(5, 10, 5));
/*std::ifstream fin("data/test.ts", std::ios::in | std::ios::binary);
e_byte_t buf[188];
ts::packet pck;
for (int i = 0; i < 10; i++)
{
fin.read((char*)buf, 188);
pck.decode(buf);
// transport header
printf("transport header:\n" );
printf("sync_byte: %#x\n", pck.header().sync_byte() );
printf("transport_error_indicator: %u\n", pck.header().transport_error_indicator() );
printf("payload_unit_start_indicator: %u\n", pck.header().payload_unit_start_indicator() );
printf("transport_priority: %u\n", pck.header().transport_priority() );
printf("pid: %#x\n", pck.header().pid() );
printf("transport_scrambling_control: %u\n", pck.header().transport_scrambling_control() );
printf("adaptation_field_control: %u\n", pck.header().adaptation_field_control() );
printf("continuity_counter: %u\n", pck.header().continuity_counter() );
// the end
if (pck.is_null()) break;
// cannot be analyzed
if ( pck.is_scrambling()
|| pck.exists_error()
|| !pck.is_valid()
)
{
printf("this packet cannot be analyzed!");
break;
}
// adaptation field
if (pck.adaptation().exists())
{
printf("\t adaptation_field header:\n" );
printf("\t adaptation_field_length: %u\n", pck.adaptation().header().adaptation_length() );
printf("\t discontinuity_indicator: %u\n", pck.adaptation().header().discontinuity_indicator() );
printf("\t random_access_indicator: %u\n", pck.adaptation().header().random_access_indicator() );
printf("\t elementary_stream_priority_indicator: %u\n", pck.adaptation().header().elementary_stream_priority_indicator());
printf("\t pcr_flag: %u\n", pck.adaptation().header().pcr_flag() );
printf("\t opcr_flag: %u\n", pck.adaptation().header().opcr_flag() );
printf("\t splicing_point_flag: %u\n", pck.adaptation().header().splicing_point_flag() );
printf("\t transport_private_data_flag: %u\n", pck.adaptation().header().private_data_flag() );
printf("\t extension_flag: %u\n", pck.adaptation().header().extension_flag() );
if (pck.adaptation().pcr().exists())
{
printf("\t pcr: %I64u\n", pck.adaptation().pcr().value() );
printf("\t pcr_base: %I64u\n", pck.adaptation().pcr().base() );
printf("\t pcr_extension: %u\n", pck.adaptation().pcr().extension() );
}
if (pck.adaptation().opcr().exists())
{
printf("\t pcr: %I64u\n", pck.adaptation().opcr().value() );
printf("\t pcr_base: %I64u\n", pck.adaptation().opcr().base() );
printf("\t pcr_extension: %u\n", pck.adaptation().opcr().extension() );
}
if (pck.adaptation().splicing().exists())
{
printf("\t splice_countdown: %u\n", pck.adaptation().splicing().countdown() );
}
if (pck.adaptation().private_data().exists())
{
printf("\t private_data_length: %u\n", pck.adaptation().private_data().size() );
for (int i = 0; i < (int)pck.adaptation().private_data().size(); ++i)
{
printf("\t private_data: %02x\n", pck.adaptation().private_data().data()[i] );
}
}
if (pck.adaptation().extension().exists())
{
printf("\t\t adaptation_extension_length: %u\n", pck.adaptation().extension().size() );
if (pck.adaptation().extension().exists_ltw())
{
printf("\t\t ltw_valid_flag: %u\n", pck.adaptation().extension().ltw().ltw_valid_flag );
printf("\t\t ltw_offset: %u\n", pck.adaptation().extension().ltw().ltw_offset );
}
if (pck.adaptation().extension().exists_piecewise_rate())
{
printf("\t\t piecewise_rate: %u\n", pck.adaptation().extension().piecewise_rate() );
}
if (pck.adaptation().extension().exists_seamless_splice())
{
printf("\t\t splice_type: %u\n", pck.adaptation().extension().seamless_splice().splice_type );
}
}
}
printf("\n");
pck.encode();
}
fin.close();*/
getchar();
return 0;
}