Skip to content

Commit fb53458

Browse files
committed
sub/sd_ass: fix animated state indexing for reordered packets
1 parent c1c047f commit fb53458

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

sub/sd_ass.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,13 @@ struct sd_ass_priv {
6060
struct mp_osd_res osd;
6161
struct seen_packet *seen_packets;
6262
int num_seen_packets;
63-
int *packets_animated;
64-
int num_packets_animated;
6563
bool check_animated;
6664
};
6765

6866
struct seen_packet {
6967
int64_t pos;
7068
double pts;
69+
int animated; // -1 is unknown
7170
};
7271

7372
#undef OPT_BASE_STRUCT
@@ -402,18 +401,18 @@ static void filter_and_add(struct sd *sd, struct demux_packet *pkt)
402401
if (ctx->check_animated && pkt->animated != 1)
403402
pkt->animated = is_animated(event->Text);
404403
}
405-
MP_TARRAY_APPEND(ctx, ctx->packets_animated, ctx->num_packets_animated, pkt->animated);
404+
ctx->seen_packets[pkt->seen_pos].animated = pkt->animated;
406405
} else {
407-
if (ctx->check_animated && ctx->packets_animated[pkt->seen_pos] == -1) {
406+
if (ctx->check_animated && ctx->seen_packets[pkt->seen_pos].animated == -1) {
408407
for (int n = track->n_events - 1; n >= 0; n--) {
409408
if (n + 1 == old_n_events || pkt->animated == 1)
410409
break;
411410
ASS_Event *event = &track->events[n];
412-
ctx->packets_animated[pkt->seen_pos] = is_animated(event->Text);
413-
pkt->animated = ctx->packets_animated[pkt->seen_pos];
411+
ctx->seen_packets[pkt->seen_pos].animated = is_animated(event->Text);
412+
pkt->animated = ctx->seen_packets[pkt->seen_pos].animated;
414413
}
415414
} else {
416-
pkt->animated = ctx->packets_animated[pkt->seen_pos];
415+
pkt->animated = ctx->seen_packets[pkt->seen_pos].animated;
417416
}
418417
}
419418
}
@@ -446,7 +445,7 @@ static bool check_packet_seen(struct sd *sd, struct demux_packet *packet)
446445
}
447446
packet->seen_pos = a;
448447
MP_TARRAY_INSERT_AT(priv, priv->seen_packets, priv->num_seen_packets, a,
449-
(struct seen_packet){packet->pos, packet->pts});
448+
(struct seen_packet){packet->pos, packet->pts, -1});
450449
return false;
451450
}
452451

@@ -998,7 +997,6 @@ static void reset(struct sd *sd)
998997
if (sd->opts->sub_clear_on_seek || ctx->clear_once) {
999998
ass_flush_events(ctx->ass_track);
1000999
ctx->num_seen_packets = 0;
1001-
ctx->num_packets_animated = 0;
10021000
sd->preload_ok = false;
10031001
ctx->clear_once = false;
10041002
}

0 commit comments

Comments
 (0)