-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source.cpp
708 lines (528 loc) · 18.4 KB
/
Source.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
#include <iostream>
#include <sstream>
#include <fstream>
#include <ctime>
#include <iomanip>
#include <windows.h>
#include <time.h>
#include <sql.h>
#include <sqltypes.h>
#include <sqlext.h>
#include <stdio.h>
#include "sqlite3.h"
#include "sqlite3.c"
#define __CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
//namespace fs = std::experimental::filesystem;
using namespace std;
#define _CRT_SECURE_NO_WARNINGS
#ifdef _MSC_VER
#define fwrite_unlocked _fwrite_nolock
#endif
//èìåíà êàìåð
string camers_name[14];
//êîäû êàìåð
string camers_code[14];
//òåêóùàÿ êàìåðà (äëÿ èìåíè ôàéëà)
string current_camera_name = "none";
//øòàìï äàòû âðåìåíè (äëÿ èìåíè ôàéëà)
string current_datetime_stamp = "nether";
string current_date_dir = "nether";
string current_hour_dir = "nether";
//îãðàíè÷èòåëü ðàçìåðà êàäðà äëÿ îòñåâà çàòåðòûõ äàííûõ
unsigned int max_cadre_size = 5000000;
//êîä îïîðíîãî êàäðà
//unsigned char peer0_0[] = { 0xc1, 0x02, 0x06, 0x08, 0x00, 0x5e, 0x84 };
unsigned char i_code[] = { 0x68,0x32,0x36,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x49 };
//êîä ðàçíîñòíîãî êàäðà
unsigned char p_code[] = { 0x68,0x32,0x36,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70 };
//êîä ðàçíîñòíîãî êàäðà
unsigned char p2_code[] = { 0x68,0x32,0x36,0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50 };
//áîëüøîé áóôåð
BYTE* large_buffer = NULL;
time_t now ;
// èçìåðÿåì ñêîðîñòü öèêëà
time_t t_gauge1;
time_t t_gauge2;
struct tm ltm;
const char* SQL = "CREATE TABLE IF NOT EXISTS foo(a,b,c); INSERT INTO FOO VALUES(1,2,3); INSERT INTO FOO SELECT * FROM FOO;";
bool find_camera(__int64 i)
{
//ïåðåáèðàåì âñå êàìåðû
for (int j = 0; j < 14; j++)
{
//ñâåðÿåì âñå ñèìâîëû
for (int k = 0; k < 8; k++)
{
if (camers_code[j][k] != large_buffer[i + k])
{
break;
}
if (k == 7)
{
current_camera_name = camers_name[j];
return true;
}
}
}
return false;
}
bool find_i(__int64 i)
{
//ñâåðÿåì âñå ñèìâîëû
for (int k = 0; k < sizeof(i_code); k++)
{
if (i_code[k] != large_buffer[i + k])
{
break;
}
if (k == sizeof(i_code) - 1)
{
return true;
}
}
return false;
}
bool find_p(__int64 i)
{
//ñâåðÿåì âñå ñèìâîëû
for (int k = 0; k < sizeof(p_code); k++)
{
if (!(p_code[k] == large_buffer[i + k] || p2_code[k] == large_buffer[i + k]))
{
break;
}
if (k == sizeof(p_code) - 1)
{
return true;
}
}
return false;
}
bool find_datetime_stamp(__int64 i)
{
unsigned int year;
std::string s_year;
std::stringstream out_year;
unsigned int month;
std::string s_month;
std::stringstream out_month;
unsigned int day;
std::string s_day;
std::stringstream out_day;
unsigned int hour;
std::string s_hour;
std::stringstream out_hour;
unsigned int minute;
std::string s_minute;
std::stringstream out_minute;
unsigned int second;
std::string s_second;
std::stringstream out_second;
unsigned int msecond;
std::string s_msecond;
std::stringstream out_msecond;
//unsigned int year;
year = large_buffer[i - 16] + large_buffer[i - 15]*256;
out_year << year;
s_year = out_year.str();
month = large_buffer[i - 14];
out_month << std::setw(2) << std::setfill('0') << month;
s_month = out_month.str();
day = large_buffer[i - 13];
out_day << std::setw(2) << std::setfill('0') << day;
s_day = out_day.str();
hour = large_buffer[i - 12];
out_hour << std::setw(2) << std::setfill('0') << hour;
s_hour = out_hour.str();
minute = large_buffer[i - 11];
out_minute << std::setw(2) << std::setfill('0') << minute;
s_minute = out_minute.str();
second = large_buffer[i - 10];
out_second << std::setw(2) << std::setfill('0') << second;
s_second = out_second.str();
msecond = large_buffer[i - 21];
out_msecond << std::setw(2) << std::setfill('0') << msecond;
s_msecond = out_msecond.str();
current_datetime_stamp = s_hour + "-" + s_minute + "-" + s_second + " " + s_day + "-" + s_month + "-" + s_year;
current_date_dir = s_day + "-" + s_month + "-" + s_year;
current_hour_dir = s_hour;
//std::cout << std::setw(2) << std::setfill('0') << 1;
return false;
}
string datetime_stamp()
{
std::string ss;
std::stringstream s_out;
now = time(0);
localtime_s(<m ,&now );
// print various components of tm structure.
//cout << "Year" << 1970 + ltm->tm_year << endl;
//cout << "Month: " << 1 + ltm->tm_mon << endl;
//cout << "Day: " << ltm->tm_mday << endl;
//cout << "Time: " << 1 + ltm->tm_hour << ":";
//cout << 1 + ltm->tm_min << ":";
//cout << 1 + ltm->tm_sec << endl;
s_out << 1900 + ltm.tm_year << "-" << 1 + ltm.tm_mon << "-" << ltm.tm_mday << " " << ltm.tm_hour << "-" << ltm.tm_min << "-" << ltm.tm_sec;
ss = s_out.str();
return ss;
}
int main()
{
// Äåñêðèïòîð ôàéëîâîãî óñòðîéñòâà (ðàçäåëà äèñêà).
HANDLE partition = INVALID_HANDLE_VALUE;
// Ñâåäåíèÿ î ðàçäåëå.
PARTITION_INFORMATION partitionInfo = { 0 };
// Ñâåäåíèÿ î ãåîìåòðèè äèñêà, íà êîòîðîì ðàñïîëîæåí ðàçäåë.
DISK_GEOMETRY diskGeometry = { 0 };
// Äåñêðèïòîð ôàéëà äëÿ ñîõðàíåíèÿ îáðàçà ðàçäåëà.
HANDLE file = INVALID_HANDLE_VALUE;
// Áóôåð äëÿ ÷òåíèÿ.
BYTE* buffer = NULL;
// Ðàçìåð áóôåðà.
DWORD bufferSize = 0;
// Êîëè÷åñòâî âîçâðàùåííûõ áàéò.
DWORD bytesReturned = 0;
// Êîëè÷åñòâî çàïèñàííûõ áàéò.
DWORD bytesWritten = 0;
// Ðåçóëüòàò âûïîëíåíèÿ.
BOOL result; BOOL result1;
//ôëàã âûõîäà ïî íàéäåííîé êàìåðå
bool camera_found = false;
bool need_to_open_file = false;
__int64 sectors;
// Îòêðûâàåì ðàçäåë äèñêà ÷èòàåì.
partition = CreateFile("\\\\.\\I:",
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL);
if (partition == INVALID_HANDLE_VALUE)
{
cout << "read disk (H) dont open" << endl;
cout << "Error: " << GetLastError() << endl;
}
// Ñîçäàíèå ôàéëà äëÿ ñîõðàíåíèÿ ïèøåì.
std::ofstream out; // ïîòîê äëÿ çàïèñè
std::ofstream out1; // ïîòîê äëÿ çàïèñè
std::ofstream out2; // ïîòîê äëÿ çàïèñè
string logfile;
string outfile;
string s_outdatedir;
string s_outhourdir;
logfile = "U:\\" + datetime_stamp() + ".log";
out2.open(logfile, ios::binary); // îêðûâàåì ôàéë äëÿ çàïèñè
if (!out.is_open())
{
cout << "write disk (F) dont open" << endl;
cout << "Error: " << GetLastError() << endl;
}
// Çàïðàøèâàåì ñâåäåíèÿ î ãåîìåòðèè äèñêà, íà êîòîðîì ðàñïîëîæåí ðàçäåë.
if (!DeviceIoControl(partition,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL,
0,
&diskGeometry,
sizeof(DISK_GEOMETRY),
&bytesReturned,
(LPOVERLAPPED)NULL))
{
cout << "Error: " << GetLastError() << endl;
CloseHandle(partition);
}
// Ðàçìåð ðàçäåëà.
//cout << "Partition's size (in bytes): " << partitionInfo.PartitionLength.QuadPart << endl;
// Ðàçìåð äèñêà îòëè÷àåòñÿ îò ðàçìåðà ðàçäåëà (ïðè÷åì, ìîæåò çíà÷èòåëüíî îòëè÷àòüñÿ).
cout << "Disk's size (in bytes): " << (diskGeometry.Cylinders.QuadPart) *
diskGeometry.TracksPerCylinder * diskGeometry.SectorsPerTrack *
diskGeometry.BytesPerSector << endl;
cout << "Num of cylinders: " << diskGeometry.Cylinders.QuadPart << endl;
cout << "Tracks per cylinder: " << diskGeometry.TracksPerCylinder << endl;
cout << "Sectors per track: " << diskGeometry.SectorsPerTrack << endl;
cout << "Bytes per sector: " << diskGeometry.BytesPerSector << endl;
//system("PAUSE");
// Óñòàíàâëèâàåì ðàçìåð áóôåðà.
bufferSize = diskGeometry.BytesPerSector * diskGeometry.SectorsPerTrack;
//ìàêñèìàëüíûé ðàçìåð äèñêà â ñåêòîðàõ
__int64 max_sector = (diskGeometry.Cylinders.QuadPart)*diskGeometry.TracksPerCylinder* diskGeometry.SectorsPerTrack;
//íî ýòî ðàçìåð äèñêà à ó íàñ ïàðòèöèÿ, ñ íåé ïî ìóðçèëêå íå ïîëó÷èëîñü ñíÿòü äàííûå ìá èççà òîãî ÷òî îíà åêñò4
max_sector = 7814014976;
//íà÷àëüíûé ñåêòîð
//Ïåðåìåííûå èñïîëüçóåìûå äëÿ îòîáðàæåíèÿ ïðîöåññà êîïèðîâàíèÿ.
//int sector_size = 512;
__int64 from_sector = 6448250880; //íà÷àëüíûé ñåêòîð
//21 ïðîöåíò äèñêà çàíÿò
from_sector = 0.25 * max_sector;
//from_sector = 6448250915;
//from_sector = 4448328494;
//from_sector = 7813644216;1869661822
from_sector = 1772257280;
from_sector = 2148799741;
//1772257280 íà÷àëî ïî íå ñòåðòîìó ôàêòó
unsigned long scoup_size = 100000000; //ðàçìåð ñêàíèðóåìîé îáëàñòè
//scoup_size = 10000000; //ðàçìåð ñêàíèðóåìîé îáëàñòè
//double double_buffersize = bufferSize;
//int_buffersize = bufferSize;
//ìàêñèìàëüíûé ðàçìåð äèñêà ïðèåìíèêà
unsigned long max_bytes_on_u = 1900000000 ;
float delenie = (double) scoup_size / bufferSize;
//ðàçìåð ñêàíèðóåìîé îáëàñòè â áóôåðàõ
unsigned long scoup_buffer_size = ceil(delenie);
//ïåðåêðûòèå äëÿ ïîâòîðíîãî ÷òåíèÿ
unsigned long scoup_sector_size = scoup_buffer_size * diskGeometry.SectorsPerTrack;
//ïåðåêðûòèå äëÿ ïîâòîðíîãî ÷òåíèÿ
delenie = (double)3000000 / diskGeometry.BytesPerSector;
unsigned long scoup_overlap = ceil(delenie); //
//delenie = 0.56;
cout << "scoup_sector_size: " << scoup_sector_size << endl;
__int64 scoup_max_size = bufferSize * scoup_buffer_size; //ðàçìåð ñêàíèðóåìîé îáëàñòè ñ îêëóãëåíèåì â áîëüøóþ ñòîðîíó
camers_name[0] = "DS - 2CD2622FWD - IS_1";
camers_code[0] = "pOUKpl96";
camers_name[1] = "DS - 2CD2T55FWD - I5_1";
camers_code[1] = "GLSDMzDm";
camers_name[2] = "DS - 2CD2523G0 - IS_1";
camers_code[2] = "xxa15omi";
camers_name[3] = "DS - 2CD2523G0 - IS_2";
camers_code[3] = "HX9CxQMz";
camers_name[4] = "DS - 2CD2523G0 - IS_3";
camers_code[4] = "xLviweM6";
camers_name[5] = "DS - 2CD2523G0 - IS_4";
camers_code[5] = "g68Kfmvu";
camers_name[6] = "DS - 2CD2643G0 - IZS_1";
camers_code[6] = "TzfTx8os";
camers_name[7] = "DS - 2CD2643G0 - IZS_2";
camers_code[7] = "LKpfLS6y";
camers_name[8] = "DS - 2CD2643G0 - IZS_3";
camers_code[8] = "yZVksUjO";
camers_name[9] = "DS - 2CD2822F(B)20170822AAWR_1";
camers_code[9] = "aVfW98lt";
camers_name[10] = "DS - 2CD2822F(B)20170822AAWR_2"; //0
camers_code[10] = "M0TqsWQF";
camers_name[11] = "DS - 2CD2822F(B)20170822AAWR_3";
camers_code[11] = "cuVGjH0S";
camers_name[12] = "DS - 2CD2822F(B)20170822AAWR_4";
camers_code[12] = "vxfqcGE2";
camers_name[13] = "DS - 2CD2822F(B)20170822AAWR_5";
camers_code[13] = "KVkHcRYJ";
int i_shift = 36; // îæèäàåìàÿ ïîçèöèÿ îïîðíîãî êàäðà ïîñëå ïîïàäàíèÿ êîäà êàìåðû
int c_num_bytes = 15; //ìóñîð ïîñëå îïîðíîãî êàäðà
unsigned long s; //ñ÷åò÷èê ñ÷èòàííûõ áàéò
unsigned long cadre_size;
bool disk_space_on_u_off;
bool max_sector_on_i_exceed = false;
unsigned long n = 0;
disk_space_on_u_off = false;
bool i_found = false;
bool p_found = false;
unsigned int i_size = 100000;
unsigned int p_size = 1000;
//std::thread::hardware_concurrency();
sqlite3 * db = 0; // õýíäë îáúåêòà ñîåäèíåíèå ê ÁÄ
char* err = 0;
// îòêðûâàåì ñîåäèíåíèå
if (sqlite3_open("my_cosy_database.dblite", &db))
fprintf(stderr, "Îøèáêà îòêðûòèÿ/ñîçäàíèÿ ÁÄ: %s\n", sqlite3_errmsg(db));
// âûïîëíÿåì SQL
else if (sqlite3_exec(db, SQL, 0, 0, &err))
{
fprintf(stderr, "Îøèáêà SQL: %sn", err);
sqlite3_free(err);
}
// çàêðûâàåì ñîåäèíåíèå
sqlite3_close(db);
do
{
s = 0;
t_gauge1 = time(0);
//áóôåð êóäà êîïèðóåòñÿ îáëàñòü
large_buffer = new BYTE[scoup_max_size];
// Âûäåëåíèå ïàìÿòè äëÿ áóôåðà óêàçàííîãî ðàçìåðà.
buffer = new BYTE[bufferSize];
stringstream sn;
sn << n;
string strn = sn.str();
outfile = "U:\\out-" + strn;
outfile = outfile + ".hex";
out2 << "[" << datetime_stamp() << "]" <<"step: " << outfile <<" from sector: " << from_sector << " s: " << s << endl;
LARGE_INTEGER qPosition;
qPosition.QuadPart = from_sector * diskGeometry.BytesPerSector; //!!!!!!!!!!!!! 128
//ïåðåìàòûâàåì íà ñåêòîð ÷òåíèÿ
SetFilePointer(partition, qPosition.LowPart, &qPosition.HighPart, FILE_BEGIN);
// Êîïèðîâàíèå ðàçäåëà â ôàéë.
do
{
// ×òåíèå ñåêòîðîâ ðàçäåëà.
result = ReadFile(partition, &large_buffer[s], bufferSize, &bytesReturned, NULL);
if (!result)
{
cout << "Error: " << GetLastError() << endl;
delete[] buffer;
CloseHandle(file);
CloseHandle(partition);
return (-7);
}
//for (int i = 0; i < bufferSize; i++)
//{
// large_buffer[i + s] = buffer[i];
//}
s += bufferSize;
max_bytes_on_u -= bufferSize;
if (max_bytes_on_u <= 0)
{
disk_space_on_u_off = true;
out2 << "[" << datetime_stamp() << "]" << "max disk size on u exceeded, max sector: " << from_sector + scoup_sector_size << endl;
}
} while (result && bytesReturned && (s < scoup_max_size) && !disk_space_on_u_off);
//out.open(outfile, ios::binary); // îêðûâàåì ôàéë äëÿ çàïèñè
//s = 0;
//do
//{
// out << large_buffer[s];
// s += 1;
//} while (result && bytesReturned && (s < scoup_max_size));
n++;
//out2 << "[" << datetime_stamp() << "]" << " buffer out size: " << out.tellp() << endl;
//out.close(); // çàêðûâàåì ôàéë
//out.flush();
//ïîèíòåð íà òåêóùèé êàäð àíàëèçà
//BYTE* current_frame;
//BYTE* current_string;
//ïåðåáèðàåì âñþ îáëàñòü
for (unsigned long i = 0; i < scoup_max_size; i++) //=0
{
//èùåì êàìåðó
if (find_camera(i))
{
need_to_open_file = true; //çäåñü ìû åùå íå çíàåì ïîïàäåòñÿ ëè îïîðíûé êàäð èëè êîä âñòðåòèëñÿ â èíäåêñå
out2 << "[" << datetime_stamp() << "]" << "camera code: " << current_camera_name << "camera dt: " << current_datetime_stamp << " begin of camera code: " << i << endl;
//ïåðåìàòûâàåì ê îæèäàåìîìó ðàñïîëîæåíèþ êàäðà
i += i_shift;
if (find_i(i))
{
out2 << "[" << datetime_stamp() << "]" << "begin of i frame: " << i << endl;
//âûñîêèé ïðîöåíò ïîòåðü
if (need_to_open_file)
{
find_datetime_stamp(i);
s_outdatedir = "U:\\" + current_date_dir;
CreateDirectory(TEXT(s_outdatedir.c_str()), NULL);
s_outhourdir = "U:\\" + current_date_dir + "/" + current_hour_dir;
CreateDirectory(TEXT(s_outhourdir.c_str()), NULL);
s_outhourdir = "U:\\" + current_date_dir + "/" + current_hour_dir + "/" + current_camera_name;
CreateDirectory(TEXT(s_outhourdir.c_str()), NULL);
//out1.open("U:\\" + current_date_dir + "/" + current_hour_dir + "/" + current_camera_name + "/" + current_datetime_stamp + " "+ current_camera_name+ ".h264", ios::binary); // îêðûâàåì ôàéë äëÿ çàïèñè
need_to_open_file = false;
}
cadre_size = 0;
//ïåðåìàòûâàåì ê ôðåéìó
i += sizeof(i_code) + c_num_bytes;
camera_found = false;
//i_found = true;
do
{
//ñêèäûâàåì
//out1 << large_buffer[i];
//ìîòàåì íà ñëåä. ïîçèöèþ
i++;
cadre_size++;
//ïîïûòêà óñêîðåíèÿ îáðàáîòêè
//if (i_found)
//{
// for (unsigned int j = 0; j < i_size; j++)
// {
// out1 << large_buffer[i];
// //ìîòàåì íà ñëåä. ïîçèöèþ
// i++;
// cadre_size++;
// i_found = false;
// }
//}
//if (p_found)
////{
//for (unsigned int j = 0; j < p_size; j++)
//{
// out1 << large_buffer[i];
// //ìîòàåì íà ñëåä. ïîçèöèþ
// i++;
// cadre_size++;
// p_found = false;
// }
///}
//íàøëè p êàäð - ïåðåìîòàëè
if (find_p(i))
{
out2 << "[" << datetime_stamp() << "]" << "begin of p frame: " << i << endl;
out2 << "[" << datetime_stamp() << "]" << "cadre_size: " << cadre_size << endl;
i += sizeof(p_code) + c_num_bytes;
p_found = true;
cadre_size = 0;
}
//íàøëè I êàäð - ïåðåìîòàëè
if (find_i(i))
{
// ïðîâåðèì íå íà÷àëî ëè ýòî íîâîé êàìåðû
if (find_camera(i - i_shift))
{
//out1.close(); // çàêðûâàåì ôàéë
//break;
camera_found = true;
out2 << "[" << datetime_stamp() << "]" << "begin of new camera: " << i << endl;
i = i - i_shift - 1; //i++ â öèêëå ïðèáàâèò åäèíèöó
}
else
{
out2 << "[" << datetime_stamp() << "]" << "begin of i frame: " << i << endl;
out2 << "[" << datetime_stamp() << "]" << "cadre_size: " << cadre_size << endl;
//îñòàåìñÿ â ýòîé æå êàìåðå
i += sizeof(i_code) + c_num_bytes;
i_found = true;
cadre_size = 0;
}
}
//èùåì ëèáî îïîðíûé ëèáî ðàçíîñòíûé êàäð,
// ïðîâåðêó íà ñëèøêîì áîëüøîé ôðåéì, êîä äðóãîé êàìåðû èëè TRASSIR
//ãîíèì ïî îáùåìó óñëîâèþ , âûõîä ïî áðåêó
} while (!camera_found && i < scoup_max_size && cadre_size < max_cadre_size);
out2 << "[" << datetime_stamp() << "]" << " file out size: " << out1.tellp() << endl;
//out1.close(); // çàêðûâàåì ôàéë
//out1.flush();
}
else
{
out2 << "[" << datetime_stamp() << "]" << "unseccesseful i cadr of new camera: " << i << endl;
}
//åñëè íå ñëåäóåò îïîðíûé êàäð
}
}
from_sector = from_sector + scoup_sector_size - scoup_overlap;
if (from_sector + scoup_sector_size > max_sector)
{
max_sector_on_i_exceed = true;
out2 << "[" << datetime_stamp() << "]" << "max sector size on I exceeded, max sector: " << from_sector << "scoup_sector_size: " << scoup_sector_size << endl;
}
delete[] buffer;
delete[] large_buffer;
delenie = 100.0*((double) from_sector / (double) max_sector);
system("cls");
cout << "% : " << delenie<<" "<< from_sector << "/" << max_sector << endl;
t_gauge2 = time(0);
cout << "took:" << t_gauge2 - t_gauge1 << endl;
}while (!disk_space_on_u_off && !max_sector_on_i_exceed);
CloseHandle(file);
CloseHandle(partition);
out2.close(); // çàêðûâàåì ôàéë
_CrtDumpMemoryLeaks();
return 0;
}
//ïîäîáðàòü ó÷àñòîê ñåêòîðîâ ñ êàìåðîé
// åñëè åñòü ñèãíàòóðà îïîðíîãî êàäðà òî ïðîäîëæàåì, åñëè íåò, òî ïåðåìàòûâàåì íà åå ìåñòî è äàëåå èùåì
//Ïîñëå íàõîæäåíèÿ êîäà êàìåðû
//Èùåì êîä îïîðíîãî êàäðà ïî ñìåùåíèþ
//Ïåðåìàòûâàåì ñ êîïèðîâàíèåì íà 130 ÊÁ
//Èùåì õ264, ïðîâåðÿåì ïî ñìåùåíèþ òèï êàäðà âûðåçàåì 11áàéò ïåðåìîòêîé áåç êîïèð
//åñëè ï ïåðåìàòûâàåì ñ êîïèð10êá åñëè è ïåðåìàòûâàåì ñ êîïèð130 êá.È ïðîâåðÿåì íàçàä íå êàìåðà êîä ëè, åñëè îí, òî ñ÷¸ò÷èê â ìèíóñ èâûõîäèì.Çàêðûòüçàïèñü ôàéëà
//Ïîñëå