4 #include "newpacket.hpp"
6 int real_main(int argc
, char** argv
)
9 std::map
<std::pair
<uint32_t, uint32_t>, uint64_t> res_time
;
10 uint32_t current_width
= 0, current_height
= 0;
11 uint64_t last_timestamp
= 0;
12 uint64_t last_timestamp2
= 0;
13 uint64_t time_correction
= 0;
16 std::cerr
<< "Syntax: guessresolution.exe <files>..." << std::endl
;
19 for(int i
= 1; i
< argc
; i
++) {
20 read_channel
in(argv
[i
]);
21 time_correction
= last_timestamp
;
23 while((p
= in
.read())) {
24 p
->rp_timestamp
+= time_correction
;
25 last_timestamp
= p
->rp_timestamp
;
26 if(current_width
!= 0 && current_height
!= 0) {
27 std::pair
<uint32_t, uint32_t> res
= std::make_pair(current_width
, current_height
);
28 if(!res_time
.count(res
))
30 res_time
[res
] = res_time
[res
] + (p
->rp_timestamp
- last_timestamp2
);
31 last_timestamp2
= p
->rp_timestamp
;
33 na_time
= na_time
+ (p
->rp_timestamp
- last_timestamp2
);
34 last_timestamp2
= p
->rp_timestamp
;
36 if(p
->rp_major
== 0 && p
->rp_payload
.size() >= 4) {
37 current_width
= ((uint32_t)p
->rp_payload
[0] << 8) | p
->rp_payload
[1];
38 current_height
= ((uint32_t)p
->rp_payload
[2] << 8) | p
->rp_payload
[3];
43 uint32_t gwidth
= 0, gheight
= 0;
45 std::cout
<< "<no video data> for " << (na_time
+ 500000) / 1000000 << "ms." << std::endl
;
46 for(std::map
<std::pair
<uint32_t, uint32_t>, uint64_t>::iterator j
= res_time
.begin(); j
!= res_time
.end(); ++j
) {
47 std::cout
<< j
->first
.first
<< "*" << j
->first
.second
<< " for " << (j
->second
+ 500000) / 1000000 << "ms."
49 if(j
->second
> gtime
) {
50 gwidth
= j
->first
.first
;
51 gheight
= j
->first
.second
;
56 std::cout
<< "Guessed resolution is " << gwidth
<< "*" << gheight
<< "." << std::endl
;
58 std::cout
<< "Warning: No video data available." << std::endl
;