Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cineform-sdk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Grant Kim
cineform-sdk
Commits
c3923dd7
Commit
c3923dd7
authored
7 years ago
by
David
Browse files
Options
Downloads
Patches
Plain Diff
Fix for 64-bit MOV with stsc atoms
parent
b6152c2c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Example/mp4reader.cpp
+68
-9
68 additions, 9 deletions
Example/mp4reader.cpp
with
68 additions
and
9 deletions
Example/mp4reader.cpp
+
68
−
9
View file @
c3923dd7
...
...
@@ -46,6 +46,8 @@ uint32_t GetNumberPayloads(void *handle)
{
return
mp4
->
indexcount
;
}
return
0
;
}
...
...
@@ -86,6 +88,8 @@ uint32_t GetPayloadSize(void *handle, uint32_t index)
if
(
mp4
->
metasizes
&&
mp4
->
metasize_count
>
index
)
return
mp4
->
metasizes
[
index
];
return
0
;
}
...
...
@@ -422,17 +426,72 @@ void *OpenMP4Source(char *filename, uint32_t traktype, uint32_t traksubtype) //
len
=
fread
(
&
skip
,
1
,
4
,
mp4
->
mediafp
);
len
+=
fread
(
&
num
,
1
,
4
,
mp4
->
mediafp
);
num
=
BYTESWAP32
(
num
);
mp4
->
indexcount
=
num
;
if
(
mp4
->
metaoffsets
)
free
(
mp4
->
metaoffsets
);
mp4
->
metaoffsets
=
(
uint64_t
*
)
malloc
(
num
*
8
);
if
(
mp4
->
metaoffsets
)
if
(
mp4
->
metastsc_count
>
0
&&
num
!=
mp4
->
metasize_count
)
{
len
+=
fread
(
mp4
->
metaoffsets
,
1
,
num
*
8
,
mp4
->
mediafp
);
do
mp4
->
indexcount
=
mp4
->
metasize_count
;
if
(
mp4
->
metaoffsets
)
free
(
mp4
->
metaoffsets
);
mp4
->
metaoffsets
=
(
uint64_t
*
)
malloc
(
mp4
->
metasize_count
*
8
);
if
(
mp4
->
metaoffsets
)
{
num
--
;
mp4
->
metaoffsets
[
num
]
=
BYTESWAP64
(
mp4
->
metaoffsets
[
num
]);
}
while
(
num
>
0
);
uint64_t
*
metaoffsets64
=
NULL
;
metaoffsets64
=
(
uint64_t
*
)
malloc
(
num
*
8
);
if
(
metaoffsets64
)
{
uint64_t
fileoffset
=
0
;
int
stsc_pos
=
0
;
int
stco_pos
=
0
;
len
+=
fread
(
metaoffsets64
,
1
,
num
*
8
,
mp4
->
mediafp
);
do
{
num
--
;
metaoffsets64
[
num
]
=
BYTESWAP64
(
metaoffsets64
[
num
]);
}
while
(
num
>
0
);
fileoffset
=
metaoffsets64
[
0
];
mp4
->
metaoffsets
[
0
]
=
fileoffset
;
//printf("%3d:%08x, delta = %08x\n", 0, (int)fileoffset, 0);
num
=
1
;
while
(
num
<
mp4
->
metasize_count
)
{
if
(
num
!=
mp4
->
metastsc
[
stsc_pos
].
chunk_num
-
1
&&
0
==
(
num
-
(
mp4
->
metastsc
[
stsc_pos
].
chunk_num
-
1
))
%
mp4
->
metastsc
[
stsc_pos
].
samples
)
{
stco_pos
++
;
fileoffset
=
(
uint64_t
)
metaoffsets64
[
stco_pos
];
}
else
{
fileoffset
+=
(
uint64_t
)
mp4
->
metasizes
[
num
-
1
];
}
mp4
->
metaoffsets
[
num
]
=
fileoffset
;
//int delta = metaoffsets[num] - metaoffsets[num - 1];
//printf("%3d:%08x, delta = %08x\n", num, (int)fileoffset, delta);
num
++
;
}
if
(
mp4
->
metastsc
)
free
(
mp4
->
metastsc
);
mp4
->
metastsc_count
=
0
;
free
(
metaoffsets64
);
}
}
}
else
{
mp4
->
indexcount
=
num
;
if
(
mp4
->
metaoffsets
)
free
(
mp4
->
metaoffsets
);
mp4
->
metaoffsets
=
(
uint64_t
*
)
malloc
(
num
*
8
);
if
(
mp4
->
metaoffsets
)
{
len
+=
fread
(
mp4
->
metaoffsets
,
1
,
num
*
8
,
mp4
->
mediafp
);
do
{
num
--
;
mp4
->
metaoffsets
[
num
]
=
BYTESWAP64
(
mp4
->
metaoffsets
[
num
]);
}
while
(
num
>
0
);
}
}
LONGSEEK
(
mp4
->
mediafp
,
qtsize
-
8
-
len
,
SEEK_CUR
);
// skip over stco
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment