summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sub/dec_sub.c7
-rw-r--r--sub/sd.h4
-rw-r--r--sub/sd_ass.c12
3 files changed, 17 insertions, 6 deletions
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index ec9af94abb..7e4427a40f 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -121,6 +121,10 @@ static void read_sub_data(struct dec_sub *sub, struct sub_data *subdata)
assert(sub_accept_packets_in_advance(sub));
char *temp = NULL;
+ struct sd *sd = sub_get_last_sd(sub);
+
+ sd->no_remove_duplicates = true;
+
for (int i = 0; i < subdata->sub_num; i++) {
subtitle *st = &subdata->subtitles[i];
// subdata is in 10 ms ticks, pts is in seconds
@@ -161,7 +165,6 @@ static void read_sub_data(struct dec_sub *sub, struct sub_data *subdata)
sub_decode(sub, &pkt);
}
- struct sd *sd = sub_get_last_sd(sub);
// Hack for broken FFmpeg packet format: make sd_ass keep the subtitle
// events on reset(), even though broken FFmpeg ASS packets were received
// (from sd_lavc_conv.c). Normally, these events are removed on seek/reset,
@@ -169,6 +172,8 @@ static void read_sub_data(struct dec_sub *sub, struct sub_data *subdata)
if (sd && sd->driver->fix_events)
sd->driver->fix_events(sd);
+ sd->no_remove_duplicates = false;
+
talloc_free(temp);
}
diff --git a/sub/sd.h b/sub/sd.h
index 20dce8003d..fc1085f8ed 100644
--- a/sub/sd.h
+++ b/sub/sd.h
@@ -27,6 +27,10 @@ struct sd {
struct ass_library *ass_library;
struct ass_renderer *ass_renderer;
+ // If false, try to remove multiple subtitles.
+ // (Only for decoders which have accept_packets_in_advance set.)
+ bool no_remove_duplicates;
+
// Set by sub converter
const char *output_codec;
char *output_extradata;
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 21d941933c..7e863a2844 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -132,11 +132,13 @@ static void decode(struct sd *sd, struct demux_packet *packet)
return;
}
not_all_whitespace:;
- for (int i = 0; i < track->n_events; i++)
- if (track->events[i].Start == ipts
- && (duration <= 0 || track->events[i].Duration == iduration)
- && strcmp(track->events[i].Text, text) == 0)
- return; // We've already added this subtitle
+ if (!sd->no_remove_duplicates) {
+ for (int i = 0; i < track->n_events; i++)
+ if (track->events[i].Start == ipts
+ && (duration <= 0 || track->events[i].Duration == iduration)
+ && strcmp(track->events[i].Text, text) == 0)
+ return; // We've already added this subtitle
+ }
if (duration <= 0) {
iduration = 10000;
ctx->incomplete_event = true;