Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions player/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,20 @@ void mp_switch_track_n(struct MPContext *mpctx, int order, enum stream_type type
reselect_demux_stream(mpctx, current, false);
}

// For the edge case of switching from no video to a still image, we need to
// flush the ass events of any sub track for potential animations.
if (type == STREAM_VIDEO && order == 0 && !current && track->image) {
for (int n = 0; n < num_ptracks[STREAM_SUB]; n++) {
struct track *sub_track = mpctx->current_track[n][STREAM_SUB];
if (sub_track && sub_track->d_sub) {
sub_control(sub_track->d_sub, SD_CTRL_RESET_SOFT, NULL);
sub_reset(sub_track->d_sub);
if (sub_track->selected)
reselect_demux_stream(mpctx, sub_track, true);
}
}
}

mpctx->current_track[order][type] = track;

if (track) {
Expand Down
1 change: 1 addition & 0 deletions sub/dec_sub.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum sd_ctrl {
SD_CTRL_SET_ANIMATED_CHECK,
SD_CTRL_SET_VIDEO_PARAMS,
SD_CTRL_SET_VIDEO_DEF_FPS,
SD_CTRL_RESET_SOFT,
SD_CTRL_UPDATE_OPTS,
};

Expand Down
5 changes: 5 additions & 0 deletions sub/sd_ass.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,7 @@ static void reset(struct sd *sd)
if (sd->opts->sub_clear_on_seek || ctx->clear_once) {
ass_flush_events(ctx->ass_track);
ctx->num_seen_packets = 0;
ctx->num_packets_animated = 0;
sd->preload_ok = false;
ctx->clear_once = false;
}
Expand Down Expand Up @@ -1033,6 +1034,10 @@ static int control(struct sd *sd, enum sd_ctrl cmd, void *arg)
case SD_CTRL_SET_ANIMATED_CHECK:
ctx->check_animated = *(bool *)arg;
return CONTROL_OK;
case SD_CTRL_RESET_SOFT:
ctx->clear_once = true;
reset(sd);
return CONTROL_OK;
case SD_CTRL_SET_VIDEO_PARAMS:
ctx->video_params = *(struct mp_image_params *)arg;
return CONTROL_OK;
Expand Down