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
3c6e220a
Commit
3c6e220a
authored
Jul 24, 2014
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/matroskaenc: Factor mkv_start_new_cluster() out
Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
183bbc2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
matroskaenc.c
libavformat/matroskaenc.c
+25
-14
No files found.
libavformat/matroskaenc.c
View file @
3c6e220a
...
...
@@ -1668,6 +1668,28 @@ static void mkv_flush_dynbuf(AVFormatContext *s)
mkv
->
dyn_bc
=
NULL
;
}
static
void
mkv_start_new_cluster
(
AVFormatContext
*
s
,
AVPacket
*
pkt
)
{
MatroskaMuxContext
*
mkv
=
s
->
priv_data
;
AVIOContext
*
pb
;
if
(
s
->
pb
->
seekable
)
{
pb
=
s
->
pb
;
}
else
{
pb
=
mkv
->
dyn_bc
;
}
av_log
(
s
,
AV_LOG_DEBUG
,
"Starting new cluster at offset %"
PRIu64
" bytes, "
"pts %"
PRIu64
"dts %"
PRIu64
"
\n
"
,
avio_tell
(
pb
),
pkt
->
pts
,
pkt
->
dts
);
end_ebml_master
(
pb
,
mkv
->
cluster
);
mkv
->
cluster_pos
=
-
1
;
if
(
mkv
->
dyn_bc
)
mkv_flush_dynbuf
(
s
);
avio_flush
(
s
->
pb
);
}
static
int
mkv_write_packet_internal
(
AVFormatContext
*
s
,
AVPacket
*
pkt
,
int
add_cue
)
{
MatroskaMuxContext
*
mkv
=
s
->
priv_data
;
...
...
@@ -1755,7 +1777,6 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
int
keyframe
=
!!
(
pkt
->
flags
&
AV_PKT_FLAG_KEY
);
int
cluster_size
;
int64_t
cluster_time
;
AVIOContext
*
pb
;
int
ret
;
int
start_new_cluster
;
...
...
@@ -1768,11 +1789,9 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
// start a new cluster every 5 MB or 5 sec, or 32k / 1 sec for streaming or
// after 4k and on a keyframe
if
(
s
->
pb
->
seekable
)
{
pb
=
s
->
pb
;
cluster_size
=
avio_tell
(
pb
)
-
mkv
->
cluster_pos
;
cluster_size
=
avio_tell
(
s
->
pb
)
-
mkv
->
cluster_pos
;
}
else
{
pb
=
mkv
->
dyn_bc
;
cluster_size
=
avio_tell
(
pb
);
cluster_size
=
avio_tell
(
mkv
->
dyn_bc
);
}
if
(
mkv
->
is_dash
&&
codec_type
==
AVMEDIA_TYPE_VIDEO
)
{
...
...
@@ -1795,15 +1814,7 @@ static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
}
if
(
mkv
->
cluster_pos
!=
-
1
&&
start_new_cluster
)
{
av_log
(
s
,
AV_LOG_DEBUG
,
"Starting new cluster at offset %"
PRIu64
" bytes, "
"pts %"
PRIu64
"dts %"
PRIu64
"
\n
"
,
avio_tell
(
pb
),
pkt
->
pts
,
pkt
->
dts
);
end_ebml_master
(
pb
,
mkv
->
cluster
);
mkv
->
cluster_pos
=
-
1
;
if
(
mkv
->
dyn_bc
)
mkv_flush_dynbuf
(
s
);
avio_flush
(
s
->
pb
);
mkv_start_new_cluster
(
s
,
pkt
);
}
// check if we have an audio packet cached
...
...
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