mask xy scale, mask boundary only overlay, fix 8 char mask nm bug, rework maskgui...
[goodguy/cinelerra.git] / cinelerra-5.1 / libzmpeg3 / title.C
1 #include "libzmpeg3.h"
2
3 ztitle_t::
4 title_t(zmpeg3_t *zsrc, char *fpath)
5 {
6   fs = new fs_t(zsrc, fpath);
7   src = zsrc;
8 }
9
10 ztitle_t::
11 title_t(zmpeg3_t *zsrc)
12 {
13   fs = new fs_t(*zsrc->fs);
14   src = zsrc;
15 }
16
17 ztitle_t::
18 ~title_t()
19 {
20   delete fs;
21   if( cell_table_allocation )
22     delete [] cell_table;
23 }
24
25 ztitle_t::
26 title_t(ztitle_t &title)
27 {
28   src = title.src;
29   fs = new fs_t(*title.fs);
30   total_bytes = title.total_bytes;
31   start_byte = title.start_byte;
32   end_byte = title.end_byte;
33
34   if( title.cell_table_size && title.cell_table ) {
35     cell_table_allocation = title.cell_table_allocation;
36     cell_table = new cell_t[cell_table_allocation];
37     cell_table_size = title.cell_table_size;
38     for( int i=0; i<cell_table_size; ++i ) {
39       cell_table[i] = title.cell_table[i];
40     }
41   }
42 }
43
44 int ztitle_t::
45 dump_title()
46 {
47   printf("path %s 0x%jx-0x%jx cell_table_size %d\n", 
48     fs->path, start_byte, end_byte, cell_table_size);
49   for( int i=0; i<cell_table_size; ++i ) {
50     printf("0x%jx-0x%jx 0x%jx-0x%jx\n", 
51       cell_table[i].title_start, cell_table[i].title_end, 
52       cell_table[i].program_start, cell_table[i].program_end);
53   }
54   return 0;
55 }
56
57 void ztitle_t::
58 extend_cell_table()
59 {
60   if( !cell_table || cell_table_allocation <= cell_table_size ) {
61     long new_allocation = cell_table_allocation ?
62        2*cell_table_size : 64;
63     cell_t *new_table = new cell_t[new_allocation];
64     for( int i=0; i<cell_table_size; ++i )
65       new_table[i] = cell_table[i];
66     delete [] cell_table;
67     cell_table = new_table;
68     cell_table_allocation = new_allocation;
69   }
70 }
71
72 void ztitle_t::
73 new_cell(int cell_no, int64_t title_start, int64_t title_end,
74   int64_t program_start, int64_t program_end, int discontinuity)
75 {
76   extend_cell_table();
77   cell_t *cell = &cell_table[cell_table_size];
78   cell->cell_no = cell_no;
79   cell->title_start = title_start;
80   cell->title_end = title_end;
81   cell->program_start = program_start;
82   cell->program_end = program_end;
83   cell->cell_time = -1.;
84   cell->discontinuity = discontinuity;
85   ++cell_table_size;
86 }
87
88 int ztitle_t::
89 print_cells(FILE *output)
90 {
91   if( cell_table ) {
92     for( int i=0; i<cell_table_size; ++i ) {
93       cell_t *cell = &cell_table[i];
94       fprintf(output, "REGION: 0x%jx-0x%jx 0x%jx-0x%jx\n",
95         cell->program_start, cell->program_end,
96         cell->title_start, cell->title_end);
97     }
98   }
99   return 0;
100 }
101