This repository was archived by the owner on May 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmov_mp4.cpp
More file actions
63 lines (55 loc) · 1.35 KB
/
mov_mp4.cpp
File metadata and controls
63 lines (55 loc) · 1.35 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
#include "mov_mp4.h"
// copied from quicktime driver
#define bswap32(x) \
{ unsigned long eax = *((unsigned long *)&(x)); \
*((unsigned long *)&(x)) = (eax >> 24) | ((eax >> 8) & 0x0000FF00UL) | ((eax << 8) & 0x00FF0000UL) | (eax << 24); \
}
#define bswap64(x) \
{ unsigned long eax = *((unsigned long *)&(x) + 0); \
unsigned long edx = *((unsigned long *)&(x) + 1); \
*((unsigned long *)&(x) + 0) = (edx >> 24) | ((edx >> 8) & 0x0000FF00UL) | ((edx << 8) & 0x00FF0000UL) | (edx << 24); \
*((unsigned long *)&(x) + 1) = (eax >> 24) | ((eax >> 8) & 0x0000FF00UL) | ((eax << 8) & 0x00FF0000UL) | (eax << 24); \
}
unsigned long MovParser::read4(){
unsigned long r;
if(hfile){
unsigned long w;
ReadFile(hfile,&r,4,&w,0);
} else {
r = *(unsigned long*)p; p+=4;
}
offset+=4;
bswap32(r);
return r;
}
__int64 MovParser::read8(){
__int64 r;
if(hfile){
unsigned long w;
ReadFile(hfile,&r,8,&w,0);
} else {
r = *(__int64*)p; p+=8;
}
offset+=8;
bswap64(r);
return r;
}
bool MovParser::read(MovAtom& a)
{
if(!can_read(8)) return false;
a.pos = offset;
a.sz = read4();
a.t = read4();
a.hsize = 8;
if(a.sz==0){
a.sz = fileSize;
} else if(a.sz==1){
if(!can_read(8)) return false;
a.sz = read8();
if(a.sz<16) return false;
a.hsize = 16;
} else if(a.sz<8){
return false;
}
return true;
}