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
6bcb1e1a
Commit
6bcb1e1a
authored
Jun 25, 2016
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavfi/subtitles: switch to codecpar
parent
0296b4b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
9 deletions
+27
-9
vf_subtitles.c
libavfilter/vf_subtitles.c
+27
-9
No files found.
libavfilter/vf_subtitles.c
View file @
6bcb1e1a
...
...
@@ -333,7 +333,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
ret
=
-
1
;
if
(
ass
->
stream_index
<
fmt
->
nb_streams
)
{
for
(
j
=
0
;
j
<
fmt
->
nb_streams
;
j
++
)
{
if
(
fmt
->
streams
[
j
]
->
codec
->
codec_type
==
AVMEDIA_TYPE_SUBTITLE
)
{
if
(
fmt
->
streams
[
j
]
->
codec
par
->
codec_type
==
AVMEDIA_TYPE_SUBTITLE
)
{
if
(
ass
->
stream_index
==
k
)
{
ret
=
j
;
break
;
...
...
@@ -355,7 +355,7 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
/* Load attached fonts */
for
(
j
=
0
;
j
<
fmt
->
nb_streams
;
j
++
)
{
AVStream
*
st
=
fmt
->
streams
[
j
];
if
(
st
->
codec
->
codec_type
==
AVMEDIA_TYPE_ATTACHMENT
&&
if
(
st
->
codec
par
->
codec_type
==
AVMEDIA_TYPE_ATTACHMENT
&&
attachment_is_font
(
st
))
{
const
AVDictionaryEntry
*
tag
=
NULL
;
tag
=
av_dict_get
(
st
->
metadata
,
"filename"
,
NULL
,
...
...
@@ -365,8 +365,8 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
av_log
(
ctx
,
AV_LOG_DEBUG
,
"Loading attached font: %s
\n
"
,
tag
->
value
);
ass_add_font
(
ass
->
library
,
tag
->
value
,
st
->
codec
->
extradata
,
st
->
codec
->
extradata_size
);
st
->
codec
par
->
extradata
,
st
->
codec
par
->
extradata_size
);
}
else
{
av_log
(
ctx
,
AV_LOG_WARNING
,
"Font attachment has no filename, ignored.
\n
"
);
...
...
@@ -378,14 +378,13 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
ass_set_fonts
(
ass
->
renderer
,
NULL
,
NULL
,
1
,
NULL
,
1
);
/* Open decoder */
dec_ctx
=
st
->
codec
;
dec
=
avcodec_find_decoder
(
dec_ctx
->
codec_id
);
dec
=
avcodec_find_decoder
(
st
->
codecpar
->
codec_id
);
if
(
!
dec
)
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Failed to find subtitle codec %s
\n
"
,
avcodec_get_name
(
dec_ctx
->
codec_id
));
avcodec_get_name
(
st
->
codecpar
->
codec_id
));
return
AVERROR
(
EINVAL
);
}
dec_desc
=
avcodec_descriptor_get
(
dec_ctx
->
codec_id
);
dec_desc
=
avcodec_descriptor_get
(
st
->
codecpar
->
codec_id
);
if
(
dec_desc
&&
!
(
dec_desc
->
props
&
AV_CODEC_PROP_TEXT_SUB
))
{
av_log
(
ctx
,
AV_LOG_ERROR
,
"Only text based subtitles are currently supported
\n
"
);
...
...
@@ -395,7 +394,26 @@ static av_cold int init_subtitles(AVFilterContext *ctx)
av_dict_set
(
&
codec_opts
,
"sub_charenc"
,
ass
->
charenc
,
0
);
if
(
LIBAVCODEC_VERSION_INT
>=
AV_VERSION_INT
(
57
,
26
,
100
))
av_dict_set
(
&
codec_opts
,
"sub_text_format"
,
"ass"
,
0
);
ret
=
avcodec_open2
(
dec_ctx
,
dec
,
&
codec_opts
);
dec_ctx
=
avcodec_alloc_context3
(
dec
);
if
(
!
dec_ctx
)
return
AVERROR
(
ENOMEM
);
ret
=
avcodec_parameters_to_context
(
dec_ctx
,
st
->
codecpar
);
if
(
ret
<
0
)
goto
end
;
/*
* This is required by the decoding process in order to rescale the
* timestamps: in the current API the decoded subtitles have their pts
* expressed in AV_TIME_BASE, and thus the lavc internals need to know the
* stream time base in order to achieve the rescaling.
*
* That API is old and needs to be reworked to match behaviour with A/V.
*/
av_codec_set_pkt_timebase
(
dec_ctx
,
st
->
time_base
);
ret
=
avcodec_open2
(
dec_ctx
,
NULL
,
&
codec_opts
);
if
(
ret
<
0
)
goto
end
;
...
...
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