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
1e46c63e
Commit
1e46c63e
authored
Sep 30, 2012
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat: refactor avformat_write_header
Split away option settings, sanity checks and general setup.
parent
86bbdf86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
15 deletions
+38
-15
mux.c
libavformat/mux.c
+38
-15
No files found.
libavformat/mux.c
View file @
1e46c63e
...
...
@@ -135,7 +135,8 @@ static int validate_codec_tag(AVFormatContext *s, AVStream *st)
return
1
;
}
int
avformat_write_header
(
AVFormatContext
*
s
,
AVDictionary
**
options
)
static
int
init_muxer
(
AVFormatContext
*
s
,
AVDictionary
**
options
)
{
int
ret
=
0
,
i
;
AVStream
*
st
;
...
...
@@ -248,12 +249,23 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options)
av_dict_set
(
&
s
->
metadata
,
"encoder"
,
LIBAVFORMAT_IDENT
,
0
);
}
if
(
s
->
oformat
->
write_header
)
{
ret
=
s
->
oformat
->
write_header
(
s
);
if
(
ret
<
0
)
goto
fail
;
if
(
options
)
{
av_dict_free
(
options
);
*
options
=
tmp
;
}
return
0
;
fail:
av_dict_free
(
&
tmp
);
return
ret
;
}
static
int
init_pts
(
AVFormatContext
*
s
)
{
int
i
;
AVStream
*
st
;
/* init PTS generation */
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
int64_t
den
=
AV_NOPTS_VALUE
;
...
...
@@ -270,22 +282,33 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options)
break
;
}
if
(
den
!=
AV_NOPTS_VALUE
)
{
if
(
den
<=
0
)
{
ret
=
AVERROR_INVALIDDATA
;
goto
fail
;
}
if
(
den
<=
0
)
return
AVERROR_INVALIDDATA
;
frac_init
(
&
st
->
pts
,
0
,
0
,
den
);
}
}
if
(
options
)
{
av_dict_free
(
options
);
*
options
=
tmp
;
return
0
;
}
int
avformat_write_header
(
AVFormatContext
*
s
,
AVDictionary
**
options
)
{
int
ret
=
0
;
if
(
ret
=
init_muxer
(
s
,
options
))
return
ret
;
if
(
s
->
oformat
->
write_header
)
{
ret
=
s
->
oformat
->
write_header
(
s
);
if
(
ret
<
0
)
return
ret
;
}
if
((
ret
=
init_pts
(
s
)
<
0
))
return
ret
;
return
0
;
fail:
av_dict_free
(
&
tmp
);
return
ret
;
}
//FIXME merge with compute_pkt_fields
...
...
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