mirror of https://github.com/mpv-player/mpv
sub/sd_ass: handle subs with unknown durations on a per packet basis
A packet with an unknown duration flagged the entire context and then
this was saved forever throughout the entire lifetime of the object.
This inherently doesn't work with the redecoding sub logic which will go
through all the packets again. So the second time around, packets with
known durations get treated as if they were unknown and things go awry.
Rework this so it is per packet like it should be and not a global
state. Note that f9cefbfec4
originally
added this for specifically eia-608 subtitles but their packets are all
detected as unknown anyway due to the durations so this is not needed
anymore and interferes with other things.
This commit is contained in:
parent
0721b87237
commit
77239b87f1
11
sub/sd_ass.c
11
sub/sd_ass.c
|
@ -60,7 +60,6 @@ struct sd_ass_priv {
|
||||||
int *packets_animated;
|
int *packets_animated;
|
||||||
int num_packets_animated;
|
int num_packets_animated;
|
||||||
bool check_animated;
|
bool check_animated;
|
||||||
bool duration_unknown;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct seen_packet {
|
struct seen_packet {
|
||||||
|
@ -275,9 +274,6 @@ static int init(struct sd *sd)
|
||||||
ctx->converter = lavc_conv_create(sd);
|
ctx->converter = lavc_conv_create(sd);
|
||||||
if (!ctx->converter)
|
if (!ctx->converter)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (strcmp(sd->codec->codec, "eia_608") == 0)
|
|
||||||
ctx->duration_unknown = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assobjects_init(sd);
|
assobjects_init(sd);
|
||||||
|
@ -433,10 +429,7 @@ static void decode(struct sd *sd, struct demux_packet *packet)
|
||||||
&sub_duration);
|
&sub_duration);
|
||||||
if (sd->opts->sub_stretch_durations ||
|
if (sd->opts->sub_stretch_durations ||
|
||||||
packet->duration < 0 || sub_duration == UINT32_MAX) {
|
packet->duration < 0 || sub_duration == UINT32_MAX) {
|
||||||
if (!ctx->duration_unknown) {
|
MP_VERBOSE(sd, "Subtitle with unknown duration.\n");
|
||||||
MP_VERBOSE(sd, "Subtitle with unknown duration.\n");
|
|
||||||
ctx->duration_unknown = true;
|
|
||||||
}
|
|
||||||
sub_duration = UNKNOWN_DURATION;
|
sub_duration = UNKNOWN_DURATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +442,7 @@ static void decode(struct sd *sd, struct demux_packet *packet)
|
||||||
};
|
};
|
||||||
filter_and_add(sd, &pkt2);
|
filter_and_add(sd, &pkt2);
|
||||||
}
|
}
|
||||||
if (ctx->duration_unknown) {
|
if (sub_duration == UNKNOWN_DURATION) {
|
||||||
for (int n = track->n_events - 2; n >= 0; n--) {
|
for (int n = track->n_events - 2; n >= 0; n--) {
|
||||||
if (track->events[n].Duration == UNKNOWN_DURATION * 1000) {
|
if (track->events[n].Duration == UNKNOWN_DURATION * 1000) {
|
||||||
if (track->events[n].Start != track->events[n + 1].Start) {
|
if (track->events[n].Start != track->events[n + 1].Start) {
|
||||||
|
|
Loading…
Reference in New Issue