-
Notifications
You must be signed in to change notification settings - Fork 230
/
track.h
99 lines (73 loc) · 2.32 KB
/
track.h
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
//==================================================================//
/*
Untrunc - track.h
Untrunc is GPL software; you can freely distribute,
redistribute, modify & use under the terms of the GNU General
Public License; either version 2 or its successor.
Untrunc is distributed under the GPL "AS IS", without
any warranty; without the implied warranty of merchantability
or fitness for either an expressed or implied particular purpose.
Please see the included GNU General Public License (GPL) for
your rights and further details; see the file COPYING. If you
cannot, write to the Free Software Foundation, 59 Temple Place
Suite 330, Boston, MA 02111-1307, USA. Or www.fsf.org
Copyright 2010 Federico Ponchio
*/
//==================================================================//
#ifndef TRACK_H
#define TRACK_H
#include <vector>
#include <string>
#include "codec.h"
class Atom;
class Track {
public:
Atom *trak;
char type[5];
int timescale;
int duration;
int32_t id;
bool hint_track = false;
int32_t hinted_id = -1;
Codec codec;
int default_time = 0;
std::vector<int> times;
//if default size we work using chunks
int32_t nsamples;
int default_chunk_nsamples = 0;
int default_size = 0; //default SAMPLE size (number of samples!!!!)
std::vector<int32_t> sample_sizes; //SAMPLE sizes
//TODO use CHUNK instead!
std::vector<int32_t> chunk_sizes;
std::vector<int64_t> offsets; //CHUNK offsetspopulated only if not default size
std::vector<int> keyframes; // 0 based!
//std::vector<int> chunk_offsets;
//std::vector<int> sample_to_chunk;
struct Chunk {
uint64_t offset = 0;
int32_t size = 0;
int32_t nsamples = 0;
int32_t first_sample = 0;
};
std::vector<Chunk> chunks;
Track();
bool parse(Atom *trak);
void clear();
void writeToAtoms();
void fixTimes();
int getSize(size_t i) { if(sample_sizes.size()) return sample_sizes[i]; return default_size; }
int getTimes(size_t i) { if(times.size()) return times[i]; return default_time; }
protected:
void cleanUp();
void getSampleTimes (Atom *t);
void getSampleSizes (Atom *t);
void getKeyframes (Atom *t);
void getChunkOffsets (Atom *t);
void getSampleToChunk(Atom *t);
void saveSampleTimes();
void saveKeyframes();
void saveSampleSizes();
void saveSampleToChunk();
void saveChunkOffsets();
};
#endif // TRACK_H