-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmem_alloc.cpp
More file actions
550 lines (468 loc) · 18 KB
/
mem_alloc.cpp
File metadata and controls
550 lines (468 loc) · 18 KB
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
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include "windows.h"
#include <conio.h>
#endif
#include "xdma_dev.h"
#include "cfile.h"
#include "hp_structs.h"
#include "mem_alloc.h"
double adc_card_t::adc_rate = 34406400.;
int adc_card_t::chans = 16;
int adc_card_t::samples = 131072;
int adc_card_t::pages = 1;
unsigned int adc_card_t::block_num = 4;
unsigned int adc_card_t::block_size = SIZE_4M;
int adc_card_t::blk_in_page = 8;
#ifdef __linux__
#include "pmem_common.h"
#define ADDR (void *) (0x0UL) //starting address of the page
int allocate_hugepage(const char *fname, hupa_t *page)
{
int pmem = open("/dev/pmem", O_RDWR);
if (pmem == -1) {
printf("error open /dev/pmem");
return -1;
}
//page.fname = fname;
page->fd = open(fname, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO);
if (page->fd < 0) {
printf("error: can not open %s\n", fname);
return -1;
}
if (fchmod(page->fd, S_IRWXU | S_IRWXG | S_IRWXO) != 0) {
printf("error: chmod %s\n", fname);
return -1;
}
// page->virt = mmap(nullptr, hpage_size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_HUGETLB, page->fd, 0);
page->virt = mmap(ADDR, SIZE_1G, PROT_READ | PROT_WRITE, MAP_SHARED, page->fd, 0);
if (page->virt == MAP_FAILED) {
printf("error: mmap %s, errno%d: %s\n", fname, errno, strerror(errno));
return -1;
}
pmem_address_t a;
a.virt = (unsigned long int)page->virt;
a.phys = 0;
ioctl(pmem, CONVERT_ADDRESS, &a);
page->phys = (void*)a.phys;
printf("page: virt 0x%02lX, phys 0x%02lX\n", (uint64_t)page->virt, (uint64_t)page->phys);
close(pmem);
return 0;
}
int free_hugepage(hupa_t page)
{
munmap(page.virt, SIZE_1G);
close(page.fd);
return 0;
}
#else
// считать из файла информацию о данных
void* read_metainfo_from_file(const char *fname, size_t info_size)
{
FILE *fp = fopen(fname, "rb");
if (NULL == fp)
{
printf("\n\tERROR: Can't open file '%s'\n\n", fname);
return NULL;
}
//fpos_t pos;
//fseek(fp, -SIZE_8M, SEEK_END);
fseek(fp, -(static_cast<long>(info_size)), SEEK_END);
printf("Allocating memory... \r");
// Выделяем память
void *virt = virtAlloc(info_size);
if (!virt)
{
printf("error: can not alloc %zd Mbytes\n", info_size / SIZE_1M);
return NULL;
}
printf("Reading file... \r");
size_t readsize = info_size;
size_t ret = fread(virt, 1, readsize, fp);
if (ret != readsize)
{
printf("error: can not read %s\n", fname);
return NULL;
}
//fgetpos(fp, &pos);
//fseek(fp, 0, SEEK_SET);
fclose(fp);
return virt;
}
#endif
const uint16_t g_sample_size = sizeof(uint16_t); // размер отсчета в байтах
const int g_num_chan = 16; // число каналов ЦАП
static vector<hupa_t> g_pages;
#include "mem_alloc.h"
//static vector<frame_t> g_frames;
// host2card (DAC) buffers
void* alloc_h2c_buffers(CXdmaDevice *pDev, const char* fname, int page_num, uint16_t chan)
{
int status = 0;
void* buffers = NULL;
unsigned int blk_size = SIZE_128M;
unsigned int blk_num = 1;
uint16_t dir = DIR_H2C;
char hpfname[128];
//sprintf(hpfname, "%s_%03d", fname, 0);
//sprintf(hpfname, "%s%01d", fname, 0);
unsigned int hupa_num = page_num;
#ifdef __linux__
unsigned int mem_type = PHYS_MEMORY_TYPE;
//hupa_t page0;
//if (allocate_hugepage(hpfname, &page0) < 0)
// return nullptr;
//uint32_t root_info_offset = *(uint32_t *)((char *)page0.virt + ROOT_INFO_OFFSET_ADR);
//root_info_t *ri = (root_info_t *)((char *)page0.virt + root_info_offset);
//printf("root_info: MARKER %X, hp %d, blocks %d, nsmpl %d, data type %d, item width %d\n\n",
// ri->marker, ri->hp_curr, ri->block_count, ri->n_smpl, ri->data_type, ri->item_width);
//blk_num = ri->block_count * hupa_num;
//blk_size = ri->n_smpl * g_sample_size * g_num_chan;
//free_hugepage(page0);
//int blk_in_page = SIZE_1G / blk_size;
//unsigned int hupa_num = blk_num / blk_in_page;
//if (blk_num % blk_in_page) hupa_num++;
root_info_t *ri = nullptr;
void** data_buf = nullptr;
for (unsigned int ipage = 0; ipage < hupa_num; ipage++)
{
hupa_t page;
sprintf(hpfname, "%s%01d", fname, ipage);
if (allocate_hugepage(hpfname, &page) < 0)
return nullptr;
g_pages.push_back(page);
uint32_t root_info_offset = *(uint32_t *)((uint8_t*)page.virt + ROOT_INFO_OFFSET_ADR);
ri = (root_info_t *)((char *)page.virt + root_info_offset);
printf("root_info: MARKER %X, hp %d, blocks %d, nsmpl %d, data type %d, item width %d\n\n",
ri->marker, ri->hp_curr, ri->block_count, ri->n_smpl, ri->data_type, ri->item_width);
if(ipage == 0)
{
blk_num = ri->block_count * hupa_num;
blk_size = ri->n_smpl * g_sample_size * g_num_chan;
data_buf = new void*[blk_num];
}
//uint32_t cur_root_info_offset = *(uint32_t *)((char *)page.virt + ROOT_INFO_OFFSET_ADR);
//root_info_t *cur_ri = (root_info_t *)((char *)page.virt + root_info_offset);
//uint32_t offset;
for (int iblk = 0; iblk < ri->block_count; iblk++)
{
uint32_t block_info_offset = ri->block_info_offset[iblk];
block_info_t *bi = (block_info_t *)((char *)page.virt + block_info_offset);
printf("block_info %d: MARKER %X, nsmpl %d, nframe %d, sec %d, nsec %d \n",
iblk, bi->marker, bi->n_smpl, bi->nframe, bi->sec, bi->nsec);
if(iblk == 0 && ipage == 0)
{
blk_size = bi->n_smpl * g_sample_size * g_num_chan;
}
sig_offsets_t signal_offset = ri->sig_offsets[iblk];
data_buf[ipage * ri->block_count + iblk] = (uint8_t*)page.phys + signal_offset.offset;
printf(" page%d blk%d phys=0x%lX (offset=0x%08X)\n", ipage, iblk, (u_long)data_buf[ipage * ri->block_count + iblk], signal_offset.offset);
}
}
status = pDev->alloc_dma_buf(data_buf, blk_size, &blk_num, mem_type, dir, chan);
for (unsigned int ipage = 0; ipage < hupa_num; ipage++)
{
hupa_t page = g_pages[ipage];
//uint32_t offset;
for (unsigned int iblk = 0; iblk < blk_num; iblk++)
{
sig_offsets_t signal_offset = ri->sig_offsets[iblk];
data_buf[ipage * ri->block_count + iblk] = (uint8_t*)page.virt + signal_offset.offset;
}
}
buffers = data_buf;
//data_buf[ipage] = (uint8_t*)page.virt;
//buffers = data_buf;
//blk_num = 8 * hupa_num;
//status = pDev->alloc_dma_hupa(hpfname, &buffers, blk_size, hupa_num, &blk_num, dir, chan);
#else
sprintf(hpfname, "%s%01d", fname, 0);
size_t info_size = SIZE_256M;
void* virt = read_metainfo_from_file(hpfname, info_size);
uint32_t offset_correcting = SIZE_1G - static_cast<uint32_t>(info_size);
uint32_t root_info_offset = *(uint32_t *)((uint8_t*)virt + (info_size-4));
root_info_offset -= offset_correcting;
root_info_t *ri = (root_info_t *)((uint8_t*)virt + root_info_offset);
printf("root_info: MARKER %X, hp %d, blocks %d, nsmpl %d, data type %d, item width %d\n\n",
ri->marker, ri->hp_curr, ri->block_count, ri->n_smpl, ri->data_type, ri->item_width);
blk_num = ri->block_count * hupa_num;
blk_size = ri->n_smpl * g_sample_size * g_num_chan;
uint32_t* bi_offset = new uint32_t[blk_num];;
for (unsigned int ipage = 0; ipage < hupa_num; ipage++)
{
for (int iblk = 0; iblk < ri->block_count; iblk++)
{
uint32_t block_info_offset = ri->block_info_offset[iblk];
block_info_offset -= offset_correcting;
block_info_t *bi = (block_info_t *)((char *)virt + block_info_offset);
printf("block_info %d: MARKER %X, nsmpl %d, nframe %d, sec %d, nsec %d \n",
iblk, bi->marker, bi->n_smpl, bi->nframe, bi->sec, bi->nsec);
if (iblk == 0 && ipage == 0)
{
blk_size = bi->n_smpl * g_sample_size * g_num_chan;
}
sig_offsets_t signal_offset = ri->sig_offsets[iblk];
bi_offset[ipage * ri->block_count + iblk] = signal_offset.offset;
printf(" blk%d offset = 0x%08X ( 0x%08X )\n", iblk, bi_offset[ipage * ri->block_count + iblk], signal_offset.offset - offset_correcting);
}
}
unsigned int mem_type = KERNEL_MEMORY_TYPE;
status = pDev->alloc_dma_buf(&buffers, blk_size, &blk_num, mem_type, dir, chan);
#endif // __linux__
if ((status < 0) || (blk_size < SIZE_4K))
{
printf(" C2H_%d ERROR by allocation buffer for DMA: %d bytes \n", chan, blk_size);
return NULL;
}
else
{
printf(" C2H_%d Allocation buffer for DMA: %dkb (%dkb * %d) ", chan,
(blk_size*blk_num) / 1024, blk_size / 1024, blk_num);
if (mem_type == PHYS_MEMORY_TYPE) printf(" PHYSICAL MEMORY\n");
else printf(" KERNEL MEMORY\n");
#ifdef _WIN32
int16_t **pBufferZ = (int16_t **)buffers;
for (unsigned int ipage = 0; ipage < hupa_num; ipage++)
{
sprintf(hpfname, "%s%01d", fname, ipage);
FILE *fp = fopen(hpfname, "rb");
printf("Reading file %s ... \r", hpfname);
for (unsigned int iBlock = 0; iBlock < blk_num; iBlock++)
{
fseek(fp, bi_offset[ipage * ri->block_count + iBlock], SEEK_SET);
fread(pBufferZ[iBlock], 1, blk_size, fp);
}
fclose(fp);
}
virtFree(virt);
#endif
return buffers;
}
}
void free_buffers(void *buf)
{
#ifdef __linux__
for (auto &page : g_pages)
free_hugepage(page);
delete (void**)buf;
#endif
}
#ifdef __linux__
// card2host (ADC) buffers
//void* alloc_c2h_buffers(CXdmaDevice *pDev, const char* fname, int ndev, int chans, int samples, int page_num,
// uint32_t blk_size, uint32_t blk_num, uint16_t dma_chan)
void* alloc_c2h_buffers(struct adc_card_t *pDev, int ndev)
{
int status = 0;
void* buffers = NULL;
int hupa_num = pDev->pages; // page_num;
//int blk_in_page = SIZE_1G / pDev->block_size - 1;
uint32_t root_info_offset = SIZE_1G - (sizeof(root_info_t) + pDev->blk_in_page * SIZE_4K);
//printf(" root_info_offset 0x%X, root_info_t %ld, block_info_t %ld, block_info_t_all %ld\n", root_info_offset, sizeof(root_info_t), sizeof(block_info_t), blk_in_page * sizeof(block_info_t));
root_info_offset = 4096 * (root_info_offset / 4096);
//uint32_t root_info_offset = SIZE_1G - pDev->block_size; // ri находится в начале последнего блока
uint32_t bi_offset0 = 4096 * ((root_info_offset + sizeof(root_info_t)) / 4096);
printf(" root_info_offset 0x%X, blocks_info_offset 0x%X\n", root_info_offset, bi_offset0);
vector<hupa_t> pages;
char hpfname[320];
void** data_buf = new void*[hupa_num * pDev->blk_in_page];
for (int ipage = 0; ipage < hupa_num; ipage++)
{
hupa_t page;
//sprintf(hpfname, "%s%02d_%03d", fname, pDev->get_instance(), ipage);
sprintf(hpfname, "%s_%02d", pDev->fpath, ipage);
if (allocate_hugepage(hpfname, &page) < 0)
return nullptr;
pages.push_back(page);
uint32_t *ro = (uint32_t *)((char *)page.virt + ROOT_INFO_OFFSET_ADR);
*ro = root_info_offset;
root_info_t *ri = (root_info_t *)((char *)page.virt + root_info_offset);
//printf(" ri_offset 0x%X, ri 0x%02lX\n", root_info_offset, (uint64_t)ri);
memset(ri, 0, sizeof(struct root_info_t));
ri->marker = ROOT_MARKER;
ri->bacos_total = ndev; // всего устройств
ri->bacos_curr = pDev->pAdc->get_instance(); // номер устройства
ri->hp_total = hupa_num; // всего hugepage`й
ri->hp_curr = ipage; // номер hugepage
ri->ach_total = pDev->chans * ndev; // всего каналов
ri->ach_start = 0;
ri->ach_count = pDev->chans; // каналов на одном устройстве
ri->block_count = pDev->blk_in_page; // количество блоков на hugepage
ri->n_smpl = pDev->samples; // количество отсчетов на канал в блоке (фрейме)
ri->data_type = DATA_TYPE_SIG_TIME; // тип данных - времянной сигнал
ri->n_lines_per_block = 1;
ri->mips = -1; // количество масштабов для DATA_TYPE_PANO_ReImDAQPw
uint32_t blk_offset, bi_offset;
for (int iblk = 0; iblk < pDev->blk_in_page; iblk++)
{
blk_offset = iblk * pDev->block_size;
bi_offset = bi_offset0 + iblk * SIZE_4K;
int idx_blk = ipage * pDev->blk_in_page + iblk;
ri->sig_offsets[iblk].offset = blk_offset;
ri->block_info_offset[iblk] = bi_offset;
data_buf[idx_blk] = (uint8_t*)page.phys + blk_offset;
printf(" page%d blk%d phys=0x%lX, blk_offset 0x%X, bi_offset 0x%X\n", ipage, iblk, (u_long)data_buf[idx_blk], blk_offset, bi_offset);
block_info_t* blk_info = (block_info_t*)((uint8_t*)page.virt + bi_offset);
blk_info->marker = BLOCK_MARKER;
blk_info->nframe = 0;
blk_info->sec = 0;
blk_info->nsec = 0;
blk_info->l_freq_Hz = 0;
blk_info->bin_Hz = 0;
blk_info->n_smpl = pDev->samples;
blk_info->ach_total = ri->ach_total; // всего каналов
blk_info->status = DATA_EMPTY;
blk_info->hw_nframe = -1;
blk_info->block_idx = idx_blk;
blk_info->block_idx_dst = -1;
frame_t frame;
frame.n = idx_blk;
frame.physaddr = (char*)page.phys + blk_offset;
frame.virtaddr = (char*)page.virt + blk_offset;
frame.root_info = ri;
frame.block_info = blk_info;
pDev->frames.push_back(frame);
}
}
unsigned int mem_type = PHYS_MEMORY_TYPE;
uint16_t dir = DIR_C2H;
status = pDev->pAdc->alloc_dma_buf(data_buf, pDev->block_size, &pDev->block_num, mem_type, dir, pDev->dma_chan);
for (int ipage = 0; ipage < hupa_num; ipage++)
{
hupa_t page = pages[ipage];
uint32_t offset;
for (int iblk = 0; iblk < pDev->blk_in_page; iblk++)
{
offset = iblk * pDev->block_size;
data_buf[ipage * pDev->blk_in_page + iblk] = (uint8_t*)page.virt + offset;
}
}
buffers = data_buf;
if ((status < 0) || (pDev->block_size < SIZE_4K))
{
printf(" C2H_%d ERROR by allocation buffer for DMA: %d bytes \n", pDev->dma_chan, pDev->block_size);
return nullptr;
}
else
{
printf(" C2H_%d Allocation buffer for DMA: %dkb (%dkb * %d) ", pDev->dma_chan,
(pDev->block_size*pDev->block_num) / 1024, pDev->block_size / 1024, pDev->block_num);
if (mem_type == USER_MEMORY_TYPE) printf(" USER MEMORY\n");
else printf(" KERNEL MEMORY\n");
return buffers;
}
}
#else
// card2host (ADC) buffers
//void* alloc_c2h_buffers(CXdmaDevice *pDev, const char* fname, int ndev, int chans, int samples, int page_num,
// uint32_t blk_size, uint32_t blk_num, uint16_t dma_chan)
void* alloc_c2h_buffers(struct adc_card_t *pDev, int ndev)
{
int status = 0;
void* buffers = NULL;
//char hpfname[128];
int hupa_num = pDev->pages; // page_num;
//int blk_in_page = SIZE_1G / pDev->block_size - 1;
//void** root_info_ptr = new void*[g_pages];
root_info_t** root_info = new struct root_info_t*[hupa_num];
for (int ipage = 0; ipage < hupa_num; ipage++)
{
//struct root_info_t* root_info = new root_info_t;
//root_info_ptr[ipage] = root_info;
root_info[ipage] = new root_info_t;
memset(root_info[ipage], 0, sizeof(struct root_info_t));
root_info[ipage]->marker = ROOT_MARKER;
root_info[ipage]->bacos_total = ndev;
root_info[ipage]->bacos_curr = pDev->pAdc->get_instance();
root_info[ipage]->hp_total = hupa_num; // всего hugepage`й
root_info[ipage]->hp_curr = ipage; // номер hugepage
root_info[ipage]->ach_total = pDev->chans * ndev; // всего каналов
root_info[ipage]->ach_start = 0;
root_info[ipage]->ach_count = pDev->chans;
root_info[ipage]->block_count = pDev->blk_in_page; // количество блоков на hugepage
root_info[ipage]->n_smpl = pDev->samples; // количество отсчетов в блоке (фрейме)
root_info[ipage]->data_type = DATA_TYPE_SIG_TIME;
root_info[ipage]->n_lines_per_block = 1;
root_info[ipage]->mips = -1; // количество масштабов для DATA_TYPE_PANO_ReImDAQPw
}
unsigned int mem_type = KERNEL_MEMORY_TYPE;
uint16_t dir = DIR_C2H;
block_info_t** blk_info = new block_info_t*[hupa_num * pDev->blk_in_page];
for (int ipage = 0; ipage < hupa_num; ipage++)
{
//struct root_info_t* root_info = (struct root_info_t*)root_info_ptr[ipage];
for (int iblk = 0; iblk < pDev->blk_in_page; iblk++)
{
root_info[ipage]->sig_offsets[iblk].offset = iblk * pDev->block_size;
//block_info_t *bi = (block_info_t *)virtAlloc(SIZE_4K);
int idx_blk = ipage * pDev->blk_in_page + iblk;
blk_info[idx_blk] = (block_info_t *)virtAlloc(SIZE_4K);
root_info[ipage]->block_info_offset[iblk] = iblk * SIZE_4K;
blk_info[idx_blk]->marker = BLOCK_MARKER;
blk_info[idx_blk]->nframe = 0;
blk_info[idx_blk]->sec = 0;
blk_info[idx_blk]->nsec = 0;
blk_info[idx_blk]->l_freq_Hz = 0;
blk_info[idx_blk]->bin_Hz = 0;
blk_info[idx_blk]->n_smpl = pDev->samples;
blk_info[idx_blk]->ach_total = root_info[ipage]->ach_total; // всего каналов
blk_info[idx_blk]->status = DATA_EMPTY;
blk_info[idx_blk]->hw_nframe = -1;
blk_info[idx_blk]->block_idx = idx_blk;
blk_info[idx_blk]->block_idx_dst = -1;
//info_buf[ipage * blk_in_page + iblk] = bi;
frame_t frame;
frame.n = idx_blk;
//frame.physaddr = (char*)page.phys + blk_offset;
//frame.virtaddr = (char*)page.virt + blk_offset;
frame.root_info = root_info[ipage];
frame.block_info = blk_info[idx_blk];
pDev->frames.push_back(frame);
}
}
status = pDev->pAdc->alloc_dma_buf(&buffers, pDev->block_size, &pDev->block_num, mem_type, dir, pDev->dma_chan);
if ((status < 0) || (pDev->block_size < SIZE_4K))
{
printf(" C2H_%d ERROR by allocation buffer for DMA: %d bytes \n", pDev->dma_chan, pDev->block_size);
return nullptr;
}
else
{
printf(" C2H_%d Allocation buffer for DMA: %dkb (%dkb * %d) ", pDev->dma_chan,
(pDev->block_size*pDev->block_num) / 1024, pDev->block_size / 1024, pDev->block_num);
if (mem_type == USER_MEMORY_TYPE) printf(" USER MEMORY\n");
else printf(" KERNEL MEMORY\n");
return buffers;
}
}
#endif
void set_block_info(struct frame_t *frame, uint32_t iframe, int32_t sec, int32_t nsec)
{
frame->block_info->nframe = iframe;
frame->block_info->sec = sec;
frame->block_info->nsec = nsec;
//printf(" block_info[%d] : nframe = %d, sec = %d, nsec = %d\n",
// idx,
// g_frames[idx].block_info->nframe,
// g_frames[idx].block_info->sec,
// g_frames[idx].block_info->nsec);
}
void* get_block_info(struct frame_t *frame)
{
return frame->block_info;
}
#include <time.h>
void print_block_info(struct frame_t *frame, int idx)
{
time_t utc_time_t = static_cast<time_t>(frame->block_info->sec);
char* str_time = ctime(&utc_time_t);
str_time[strlen(str_time) - 1] = 0;
printf(" block_info[%d] : nframe = %d, %s (sec = %d, nsec = %d)\n",
idx,
frame->block_info->nframe, str_time,
frame->block_info->sec,
frame->block_info->nsec);
}