-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmoovfaststart.cpp
More file actions
58 lines (49 loc) · 1.27 KB
/
moovfaststart.cpp
File metadata and controls
58 lines (49 loc) · 1.27 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
#include "moovfaststart.h"
#include <QDataStream>
#include <QFile>
#include <QDebug>
moovFastStart::moovFastStart(QByteArray *moov, QObject *parent)
: QObject(parent), moov(moov)
{
}
QVector<quint64> moovFastStart::findStcos()
{
QVector<quint64> ret;
QDataStream ds(*moov);
qDebug() << "finding stcos";
for (int i=0; !ds.atEnd(); i++)
{
ds.device()->seek(i);
if (ds.device()->read(4) == "stco")
{
qint64 pos = ds.device()->pos() - 8;
qDebug() << "found stco @" << hex << pos;
ret.append(pos);
}
}
return ret;
}
QByteArray* moovFastStart::offsetStcos()
{
QDataStream ds(moov, QIODevice::ReadWrite);
QVector<quint64> offsets = findStcos();
qDebug() << "changing" << offsets.length() << "offsets";
for (QVector<quint64>::Iterator ofst = offsets.begin(); ofst != offsets.end(); ++ofst)
{
ds.device()->reset();
ds.skipRawData(*ofst + 12); // size + name + version
quint32 entries = 0;
ds >> entries;
for (quint32 i=0; i<entries; i++)
{
quint32 sz = 0;
ds >> sz;
ds.skipRawData(-4);
ds << sz + moov->length();
}
}
return moov;
}
moovFastStart::~moovFastStart()
{
}