Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
681d1726
Commit
681d1726
authored
Feb 26, 2012
by
Justin Ruggles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
movenc: factorize calculation of cluster duration into a separate function
parent
f5f5b154
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
movenc.c
libavformat/movenc.c
+18
-11
No files found.
libavformat/movenc.c
View file @
681d1726
...
...
@@ -551,6 +551,21 @@ static int mov_get_lpcm_flags(enum CodecID codec_id)
}
}
static
int
get_cluster_duration
(
MOVTrack
*
track
,
int
cluster_idx
)
{
int64_t
next_dts
;
if
(
cluster_idx
>=
track
->
entry
)
return
0
;
if
(
cluster_idx
+
1
==
track
->
entry
)
next_dts
=
track
->
track_duration
+
track
->
start_dts
;
else
next_dts
=
track
->
cluster
[
cluster_idx
+
1
].
dts
;
return
next_dts
-
track
->
cluster
[
cluster_idx
].
dts
;
}
static
int
mov_write_audio_tag
(
AVIOContext
*
pb
,
MOVTrack
*
track
)
{
int64_t
pos
=
avio_tell
(
pb
);
...
...
@@ -1107,9 +1122,7 @@ static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track)
av_malloc
(
track
->
entry
*
sizeof
(
*
stts_entries
))
:
/* worst case */
NULL
;
for
(
i
=
0
;
i
<
track
->
entry
;
i
++
)
{
int64_t
duration
=
i
+
1
==
track
->
entry
?
track
->
track_duration
-
track
->
cluster
[
i
].
dts
+
track
->
start_dts
:
/* readjusting */
track
->
cluster
[
i
+
1
].
dts
-
track
->
cluster
[
i
].
dts
;
int
duration
=
get_cluster_duration
(
track
,
i
);
if
(
i
&&
duration
==
stts_entries
[
entries
].
duration
)
{
stts_entries
[
entries
].
count
++
;
/* compress */
}
else
{
...
...
@@ -2235,10 +2248,7 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVTrack *track)
int
i
;
for
(
i
=
0
;
i
<
track
->
entry
;
i
++
)
{
int64_t
duration
=
i
+
1
==
track
->
entry
?
track
->
track_duration
-
track
->
cluster
[
i
].
dts
+
track
->
start_dts
:
track
->
cluster
[
i
+
1
].
dts
-
track
->
cluster
[
i
].
dts
;
if
(
duration
!=
track
->
default_duration
)
if
(
get_cluster_duration
(
track
,
i
)
!=
track
->
default_duration
)
flags
|=
MOV_TRUN_SAMPLE_DURATION
;
if
(
track
->
cluster
[
i
].
size
!=
track
->
default_size
)
flags
|=
MOV_TRUN_SAMPLE_SIZE
;
...
...
@@ -2262,11 +2272,8 @@ static int mov_write_trun_tag(AVIOContext *pb, MOVTrack *track)
avio_wb32
(
pb
,
get_sample_flags
(
track
,
&
track
->
cluster
[
0
]));
for
(
i
=
0
;
i
<
track
->
entry
;
i
++
)
{
int64_t
duration
=
i
+
1
==
track
->
entry
?
track
->
track_duration
-
track
->
cluster
[
i
].
dts
+
track
->
start_dts
:
track
->
cluster
[
i
+
1
].
dts
-
track
->
cluster
[
i
].
dts
;
if
(
flags
&
MOV_TRUN_SAMPLE_DURATION
)
avio_wb32
(
pb
,
duration
);
avio_wb32
(
pb
,
get_cluster_duration
(
track
,
i
)
);
if
(
flags
&
MOV_TRUN_SAMPLE_SIZE
)
avio_wb32
(
pb
,
track
->
cluster
[
i
].
size
);
if
(
flags
&
MOV_TRUN_SAMPLE_FLAGS
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment