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
4f26c999
Commit
4f26c999
authored
Sep 10, 2015
by
Clément Bœsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avformat/subtitles: drop duplicated events
Fix Ticket #4843
parent
4f7189f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
subtitles.c
libavformat/subtitles.c
+29
-0
No files found.
libavformat/subtitles.c
View file @
4f26c999
...
...
@@ -166,6 +166,34 @@ static int cmp_pkt_sub_pos_ts(const void *a, const void *b)
return
s1
->
pos
>
s2
->
pos
?
1
:
-
1
;
}
static
void
drop_dups
(
FFDemuxSubtitlesQueue
*
q
)
{
int
i
,
drop
=
0
;
for
(
i
=
1
;
i
<
q
->
nb_subs
;
i
++
)
{
const
int
last_id
=
i
-
1
-
drop
;
const
AVPacket
*
last
=
&
q
->
subs
[
last_id
];
if
(
q
->
subs
[
i
].
pts
==
last
->
pts
&&
q
->
subs
[
i
].
duration
==
last
->
duration
&&
!
strcmp
(
q
->
subs
[
i
].
data
,
last
->
data
))
{
av_free_packet
(
&
q
->
subs
[
i
]);
drop
++
;
}
else
if
(
drop
)
{
q
->
subs
[
last_id
+
1
]
=
q
->
subs
[
i
];
memset
(
&
q
->
subs
[
i
],
0
,
sizeof
(
q
->
subs
[
i
]));
// for safety
}
}
if
(
drop
)
{
q
->
nb_subs
-=
drop
;
// TODO: forward log context down here
av_log
(
NULL
,
AV_LOG_WARNING
,
"Dropping %d duplicated subtitle events
\n
"
,
drop
);
}
}
void
ff_subtitles_queue_finalize
(
FFDemuxSubtitlesQueue
*
q
)
{
int
i
;
...
...
@@ -176,6 +204,7 @@ void ff_subtitles_queue_finalize(FFDemuxSubtitlesQueue *q)
for
(
i
=
0
;
i
<
q
->
nb_subs
;
i
++
)
if
(
q
->
subs
[
i
].
duration
==
-
1
&&
i
<
q
->
nb_subs
-
1
)
q
->
subs
[
i
].
duration
=
q
->
subs
[
i
+
1
].
pts
-
q
->
subs
[
i
].
pts
;
drop_dups
(
q
);
}
int
ff_subtitles_queue_read_packet
(
FFDemuxSubtitlesQueue
*
q
,
AVPacket
*
pkt
)
...
...
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