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
b8de14bc
Commit
b8de14bc
authored
May 11, 2016
by
Diego Biurrun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: Port to codec parameters API
parent
393596f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
46 deletions
+47
-46
ismindex.c
tools/ismindex.c
+30
-30
sidxindex.c
tools/sidxindex.c
+17
-16
No files found.
tools/ismindex.c
View file @
b8de14bc
...
...
@@ -450,40 +450,40 @@ fail:
return
err
;
}
static
int
get_private_data
(
struct
Track
*
track
,
AVCodec
Context
*
codec
)
static
int
get_private_data
(
struct
Track
*
track
,
AVCodec
Parameters
*
codecpar
)
{
track
->
codec_private_size
=
codec
->
extradata_size
;
track
->
codec_private
=
av_mallocz
(
codec
->
extradata_size
);
track
->
codec_private_size
=
codec
par
->
extradata_size
;
track
->
codec_private
=
av_mallocz
(
codec
par
->
extradata_size
);
if
(
!
track
->
codec_private
)
return
AVERROR
(
ENOMEM
);
memcpy
(
track
->
codec_private
,
codec
->
extradata
,
codec
->
extradata_size
);
memcpy
(
track
->
codec_private
,
codec
par
->
extradata
,
codecpar
->
extradata_size
);
return
0
;
}
static
int
get_video_private_data
(
struct
Track
*
track
,
AVCodec
Context
*
codec
)
static
int
get_video_private_data
(
struct
Track
*
track
,
AVCodec
Parameters
*
codecpar
)
{
AVIOContext
*
io
=
NULL
;
uint16_t
sps_size
,
pps_size
;
int
err
;
if
(
codec
->
codec_id
==
AV_CODEC_ID_VC1
)
return
get_private_data
(
track
,
codec
);
if
(
codec
par
->
codec_id
==
AV_CODEC_ID_VC1
)
return
get_private_data
(
track
,
codec
par
);
if
((
err
=
avio_open_dyn_buf
(
&
io
))
<
0
)
goto
fail
;
err
=
AVERROR
(
EINVAL
);
if
(
codec
->
extradata_size
<
11
||
codec
->
extradata
[
0
]
!=
1
)
if
(
codec
par
->
extradata_size
<
11
||
codecpar
->
extradata
[
0
]
!=
1
)
goto
fail
;
sps_size
=
AV_RB16
(
&
codec
->
extradata
[
6
]);
if
(
11
+
sps_size
>
codec
->
extradata_size
)
sps_size
=
AV_RB16
(
&
codec
par
->
extradata
[
6
]);
if
(
11
+
sps_size
>
codec
par
->
extradata_size
)
goto
fail
;
avio_wb32
(
io
,
0x00000001
);
avio_write
(
io
,
&
codec
->
extradata
[
8
],
sps_size
);
pps_size
=
AV_RB16
(
&
codec
->
extradata
[
9
+
sps_size
]);
if
(
11
+
sps_size
+
pps_size
>
codec
->
extradata_size
)
avio_write
(
io
,
&
codec
par
->
extradata
[
8
],
sps_size
);
pps_size
=
AV_RB16
(
&
codec
par
->
extradata
[
9
+
sps_size
]);
if
(
11
+
sps_size
+
pps_size
>
codec
par
->
extradata_size
)
goto
fail
;
avio_wb32
(
io
,
0x00000001
);
avio_write
(
io
,
&
codec
->
extradata
[
11
+
sps_size
],
pps_size
);
avio_write
(
io
,
&
codec
par
->
extradata
[
11
+
sps_size
],
pps_size
);
err
=
0
;
fail:
...
...
@@ -523,7 +523,7 @@ static int handle_file(struct Tracks *tracks, const char *file, int split,
struct
Track
**
temp
;
AVStream
*
st
=
ctx
->
streams
[
i
];
if
(
st
->
codec
->
bit_rate
==
0
)
{
if
(
st
->
codec
par
->
bit_rate
==
0
)
{
fprintf
(
stderr
,
"Skipping track %d in %s as it has zero bitrate
\n
"
,
st
->
id
,
file
);
continue
;
...
...
@@ -548,12 +548,12 @@ static int handle_file(struct Tracks *tracks, const char *file, int split,
if
((
ptr
=
strrchr
(
file
,
'/'
)))
track
->
name
=
ptr
+
1
;
track
->
bitrate
=
st
->
codec
->
bit_rate
;
track
->
bitrate
=
st
->
codec
par
->
bit_rate
;
track
->
track_id
=
st
->
id
;
track
->
timescale
=
st
->
time_base
.
den
;
track
->
duration
=
st
->
duration
;
track
->
is_audio
=
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
;
track
->
is_video
=
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_VIDEO
;
track
->
is_audio
=
st
->
codec
par
->
codec_type
==
AVMEDIA_TYPE_AUDIO
;
track
->
is_video
=
st
->
codec
par
->
codec_type
==
AVMEDIA_TYPE_VIDEO
;
if
(
!
track
->
is_audio
&&
!
track
->
is_video
)
{
fprintf
(
stderr
,
...
...
@@ -571,30 +571,30 @@ static int handle_file(struct Tracks *tracks, const char *file, int split,
if
(
tracks
->
audio_track
<
0
)
tracks
->
audio_track
=
tracks
->
nb_tracks
;
tracks
->
nb_audio_tracks
++
;
track
->
channels
=
st
->
codec
->
channels
;
track
->
sample_rate
=
st
->
codec
->
sample_rate
;
if
(
st
->
codec
->
codec_id
==
AV_CODEC_ID_AAC
)
{
track
->
channels
=
st
->
codec
par
->
channels
;
track
->
sample_rate
=
st
->
codec
par
->
sample_rate
;
if
(
st
->
codec
par
->
codec_id
==
AV_CODEC_ID_AAC
)
{
track
->
fourcc
=
"AACL"
;
track
->
tag
=
255
;
track
->
blocksize
=
4
;
}
else
if
(
st
->
codec
->
codec_id
==
AV_CODEC_ID_WMAPRO
)
{
}
else
if
(
st
->
codec
par
->
codec_id
==
AV_CODEC_ID_WMAPRO
)
{
track
->
fourcc
=
"WMAP"
;
track
->
tag
=
st
->
codec
->
codec_tag
;
track
->
blocksize
=
st
->
codec
->
block_align
;
track
->
tag
=
st
->
codec
par
->
codec_tag
;
track
->
blocksize
=
st
->
codec
par
->
block_align
;
}
get_private_data
(
track
,
st
->
codec
);
get_private_data
(
track
,
st
->
codec
par
);
}
if
(
track
->
is_video
)
{
if
(
tracks
->
video_track
<
0
)
tracks
->
video_track
=
tracks
->
nb_tracks
;
tracks
->
nb_video_tracks
++
;
track
->
width
=
st
->
codec
->
width
;
track
->
height
=
st
->
codec
->
height
;
if
(
st
->
codec
->
codec_id
==
AV_CODEC_ID_H264
)
track
->
width
=
st
->
codec
par
->
width
;
track
->
height
=
st
->
codec
par
->
height
;
if
(
st
->
codec
par
->
codec_id
==
AV_CODEC_ID_H264
)
track
->
fourcc
=
"H264"
;
else
if
(
st
->
codec
->
codec_id
==
AV_CODEC_ID_VC1
)
else
if
(
st
->
codec
par
->
codec_id
==
AV_CODEC_ID_VC1
)
track
->
fourcc
=
"WVC1"
;
get_video_private_data
(
track
,
st
->
codec
);
get_video_private_data
(
track
,
st
->
codec
par
);
}
tracks
->
nb_tracks
++
;
...
...
tools/sidxindex.c
View file @
b8de14bc
...
...
@@ -52,22 +52,23 @@ struct Tracks {
int
multiple_tracks_per_file
;
};
static
void
set_codec_str
(
AVCodec
Context
*
codec
,
char
*
str
,
int
size
)
static
void
set_codec_str
(
AVCodec
Parameters
*
codecpar
,
char
*
str
,
int
size
)
{
switch
(
codec
->
codec_id
)
{
switch
(
codec
par
->
codec_id
)
{
case
AV_CODEC_ID_H264
:
snprintf
(
str
,
size
,
"avc1"
);
if
(
codec
->
extradata_size
>=
4
&&
codec
->
extradata
[
0
]
==
1
)
{
if
(
codec
par
->
extradata_size
>=
4
&&
codecpar
->
extradata
[
0
]
==
1
)
{
av_strlcatf
(
str
,
size
,
".%02x%02x%02x"
,
codec
->
extradata
[
1
],
codec
->
extradata
[
2
],
codec
->
extradata
[
3
]);
codecpar
->
extradata
[
1
],
codecpar
->
extradata
[
2
],
codecpar
->
extradata
[
3
]);
}
break
;
case
AV_CODEC_ID_AAC
:
snprintf
(
str
,
size
,
"mp4a.40"
);
// 0x40 is the mp4 object type for AAC
if
(
codec
->
extradata_size
>=
2
)
{
int
aot
=
codec
->
extradata
[
0
]
>>
3
;
if
(
codec
par
->
extradata_size
>=
2
)
{
int
aot
=
codec
par
->
extradata
[
0
]
>>
3
;
if
(
aot
==
31
)
aot
=
((
AV_RB16
(
codec
->
extradata
)
>>
5
)
&
0x3f
)
+
32
;
aot
=
((
AV_RB16
(
codec
par
->
extradata
)
>>
5
)
&
0x3f
)
+
32
;
av_strlcatf
(
str
,
size
,
".%d"
,
aot
);
}
break
;
...
...
@@ -145,7 +146,7 @@ static int handle_file(struct Tracks *tracks, const char *file)
struct
Track
**
temp
;
AVStream
*
st
=
ctx
->
streams
[
i
];
if
(
st
->
codec
->
bit_rate
==
0
)
{
if
(
st
->
codec
par
->
bit_rate
==
0
)
{
fprintf
(
stderr
,
"Skipping track %d in %s as it has zero bitrate
\n
"
,
st
->
id
,
file
);
continue
;
...
...
@@ -170,12 +171,12 @@ static int handle_file(struct Tracks *tracks, const char *file)
if
((
ptr
=
strrchr
(
file
,
'/'
)))
track
->
name
=
ptr
+
1
;
track
->
bitrate
=
st
->
codec
->
bit_rate
;
track
->
bitrate
=
st
->
codec
par
->
bit_rate
;
track
->
track_id
=
st
->
id
;
track
->
timescale
=
st
->
time_base
.
den
;
track
->
duration
=
st
->
duration
;
track
->
is_audio
=
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
;
track
->
is_video
=
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_VIDEO
;
track
->
is_audio
=
st
->
codec
par
->
codec_type
==
AVMEDIA_TYPE_AUDIO
;
track
->
is_video
=
st
->
codec
par
->
codec_type
==
AVMEDIA_TYPE_VIDEO
;
if
(
!
track
->
is_audio
&&
!
track
->
is_video
)
{
fprintf
(
stderr
,
...
...
@@ -190,14 +191,14 @@ static int handle_file(struct Tracks *tracks, const char *file)
track
->
timescale
,
AV_ROUND_UP
));
if
(
track
->
is_audio
)
{
track
->
channels
=
st
->
codec
->
channels
;
track
->
sample_rate
=
st
->
codec
->
sample_rate
;
track
->
channels
=
st
->
codec
par
->
channels
;
track
->
sample_rate
=
st
->
codec
par
->
sample_rate
;
}
if
(
track
->
is_video
)
{
track
->
width
=
st
->
codec
->
width
;
track
->
height
=
st
->
codec
->
height
;
track
->
width
=
st
->
codec
par
->
width
;
track
->
height
=
st
->
codec
par
->
height
;
}
set_codec_str
(
st
->
codec
,
track
->
codec_str
,
sizeof
(
track
->
codec_str
));
set_codec_str
(
st
->
codec
par
,
track
->
codec_str
,
sizeof
(
track
->
codec_str
));
tracks
->
nb_tracks
++
;
}
...
...
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