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
b75a1f98
Commit
b75a1f98
authored
Jun 06, 2014
by
Luca Barbato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
matroska: Factor out write_track from mkv_write_tracks
parent
f1f6156b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
193 additions
and
169 deletions
+193
-169
matroskaenc.c
libavformat/matroskaenc.c
+193
-169
No files found.
libavformat/matroskaenc.c
View file @
b75a1f98
...
...
@@ -535,6 +535,42 @@ static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec,
*
output_sample_rate
=
mp4ac
.
ext_sample_rate
;
}
static
int
mkv_write_native_codecprivate
(
AVFormatContext
*
s
,
AVCodecContext
*
codec
,
AVIOContext
*
dyn_cp
)
{
switch
(
codec
->
codec_id
)
{
case
AV_CODEC_ID_VORBIS
:
case
AV_CODEC_ID_THEORA
:
return
put_xiph_codecpriv
(
s
,
dyn_cp
,
codec
);
case
AV_CODEC_ID_FLAC
:
return
put_flac_codecpriv
(
s
,
dyn_cp
,
codec
);
case
AV_CODEC_ID_WAVPACK
:
return
put_wv_codecpriv
(
dyn_cp
,
codec
);
case
AV_CODEC_ID_H264
:
return
ff_isom_write_avcc
(
dyn_cp
,
codec
->
extradata
,
codec
->
extradata_size
);
case
AV_CODEC_ID_HEVC
:
return
ff_isom_write_hvcc
(
dyn_cp
,
codec
->
extradata
,
codec
->
extradata_size
,
0
);
case
AV_CODEC_ID_ALAC
:
if
(
codec
->
extradata_size
<
36
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid extradata found, ALAC expects a 36-byte "
"QuickTime atom."
);
return
AVERROR_INVALIDDATA
;
}
else
avio_write
(
dyn_cp
,
codec
->
extradata
+
12
,
codec
->
extradata_size
-
12
);
break
;
default:
if
(
codec
->
extradata_size
)
avio_write
(
dyn_cp
,
codec
->
extradata
,
codec
->
extradata_size
);
}
return
0
;
}
static
int
mkv_write_codecprivate
(
AVFormatContext
*
s
,
AVIOContext
*
pb
,
AVCodecContext
*
codec
,
int
native_id
,
int
qt_id
)
...
...
@@ -548,30 +584,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb,
return
ret
;
if
(
native_id
)
{
if
(
codec
->
codec_id
==
AV_CODEC_ID_VORBIS
||
codec
->
codec_id
==
AV_CODEC_ID_THEORA
)
ret
=
put_xiph_codecpriv
(
s
,
dyn_cp
,
codec
);
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_FLAC
)
ret
=
put_flac_codecpriv
(
s
,
dyn_cp
,
codec
);
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_WAVPACK
)
ret
=
put_wv_codecpriv
(
dyn_cp
,
codec
);
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_H264
)
ret
=
ff_isom_write_avcc
(
dyn_cp
,
codec
->
extradata
,
codec
->
extradata_size
);
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_HEVC
)
ret
=
ff_isom_write_hvcc
(
dyn_cp
,
codec
->
extradata
,
codec
->
extradata_size
,
0
);
else
if
(
codec
->
codec_id
==
AV_CODEC_ID_ALAC
)
{
if
(
codec
->
extradata_size
<
36
)
{
av_log
(
s
,
AV_LOG_ERROR
,
"Invalid extradata found, ALAC expects a 36-byte "
"QuickTime atom."
);
ret
=
AVERROR_INVALIDDATA
;
}
else
avio_write
(
dyn_cp
,
codec
->
extradata
+
12
,
codec
->
extradata_size
-
12
);
}
else
if
(
codec
->
extradata_size
)
avio_write
(
dyn_cp
,
codec
->
extradata
,
codec
->
extradata_size
);
ret
=
mkv_write_native_codecprivate
(
s
,
codec
,
dyn_cp
);
}
else
if
(
codec
->
codec_type
==
AVMEDIA_TYPE_VIDEO
)
{
if
(
qt_id
)
{
if
(
!
codec
->
codec_tag
)
...
...
@@ -611,19 +624,9 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb,
return
ret
;
}
static
int
mkv_write_tracks
(
AVFormatContext
*
s
)
static
int
mkv_write_track
(
AVFormatContext
*
s
,
MatroskaMuxContext
*
mkv
,
int
i
,
AVIOContext
*
pb
)
{
MatroskaMuxContext
*
mkv
=
s
->
priv_data
;
AVIOContext
*
pb
=
s
->
pb
;
ebml_master
tracks
;
int
i
,
j
,
ret
;
ret
=
mkv_add_seekhead_entry
(
mkv
->
main_seekhead
,
MATROSKA_ID_TRACKS
,
avio_tell
(
pb
));
if
(
ret
<
0
)
return
ret
;
tracks
=
start_ebml_master
(
pb
,
MATROSKA_ID_TRACKS
,
0
);
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
AVStream
*
st
=
s
->
streams
[
i
];
AVCodecContext
*
codec
=
st
->
codec
;
ebml_master
subinfo
,
track
;
...
...
@@ -632,6 +635,7 @@ static int mkv_write_tracks(AVFormatContext *s)
int
bit_depth
=
av_get_bits_per_sample
(
codec
->
codec_id
);
int
sample_rate
=
codec
->
sample_rate
;
int
output_sample_rate
=
0
;
int
j
,
ret
;
AVDictionaryEntry
*
tag
;
// ms precision is the de-facto standard timescale for mkv files
...
...
@@ -639,7 +643,7 @@ static int mkv_write_tracks(AVFormatContext *s)
if
(
codec
->
codec_type
==
AVMEDIA_TYPE_ATTACHMENT
)
{
mkv
->
have_attachments
=
1
;
continue
;
return
0
;
}
if
(
!
bit_depth
)
...
...
@@ -779,6 +783,26 @@ static int mkv_write_tracks(AVFormatContext *s)
return
ret
;
end_ebml_master
(
pb
,
track
);
return
0
;
}
static
int
mkv_write_tracks
(
AVFormatContext
*
s
)
{
MatroskaMuxContext
*
mkv
=
s
->
priv_data
;
AVIOContext
*
pb
=
s
->
pb
;
ebml_master
tracks
;
int
i
,
ret
;
ret
=
mkv_add_seekhead_entry
(
mkv
->
main_seekhead
,
MATROSKA_ID_TRACKS
,
avio_tell
(
pb
));
if
(
ret
<
0
)
return
ret
;
tracks
=
start_ebml_master
(
pb
,
MATROSKA_ID_TRACKS
,
0
);
for
(
i
=
0
;
i
<
s
->
nb_streams
;
i
++
)
{
ret
=
mkv_write_track
(
s
,
mkv
,
i
,
pb
);
if
(
ret
<
0
)
return
ret
;
}
end_ebml_master
(
pb
,
tracks
);
return
0
;
...
...
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