mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-26 21:00:21 +00:00
player: use different variable to indicate coverart
Slightly better.
This commit is contained in:
@@ -525,7 +525,7 @@ static bool get_sync_samples(struct MPContext *mpctx, int *skip)
|
||||
!mp_audio_buffer_samples(mpctx->ao_chain->ao_buffer))
|
||||
return false; // no audio read yet
|
||||
|
||||
bool sync_to_video = mpctx->vo_chain && mpctx->sync_audio_to_video &&
|
||||
bool sync_to_video = mpctx->vo_chain && !mpctx->vo_chain->is_coverart &&
|
||||
mpctx->video_status != STATUS_EOF;
|
||||
|
||||
double sync_pts = MP_NOPTS_VALUE;
|
||||
@@ -815,8 +815,8 @@ void fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
|
||||
|
||||
// Even if we're done decoding and syncing, let video start first - this is
|
||||
// required, because sending audio to the AO already starts playback.
|
||||
if (mpctx->audio_status == STATUS_FILLING && mpctx->sync_audio_to_video &&
|
||||
mpctx->video_status <= STATUS_READY)
|
||||
if (mpctx->audio_status == STATUS_FILLING && mpctx->vo_chain &&
|
||||
!mpctx->vo_chain->is_coverart && mpctx->video_status <= STATUS_READY)
|
||||
{
|
||||
mpctx->audio_status = STATUS_READY;
|
||||
return;
|
||||
|
||||
@@ -171,6 +171,10 @@ struct vo_chain {
|
||||
struct mp_image_params input_format;
|
||||
|
||||
struct dec_video *video_src;
|
||||
|
||||
// - video consists of a single picture, which should be shown only once
|
||||
// - do not sync audio to video in any way
|
||||
bool is_coverart;
|
||||
};
|
||||
|
||||
// Like vo_chain, for audio.
|
||||
@@ -325,9 +329,6 @@ typedef struct MPContext {
|
||||
double audio_drop_throttle;
|
||||
// Number of mistimed frames.
|
||||
int mistimed_frames_total;
|
||||
/* Set if audio should be timed to start with video frame after seeking,
|
||||
* not set when e.g. playing cover art */
|
||||
bool sync_audio_to_video;
|
||||
bool hrseek_active; // skip all data until hrseek_pts
|
||||
bool hrseek_framedrop; // allow decoder to drop frames before hrseek_pts
|
||||
bool hrseek_lastframe; // drop everything until last frame reached
|
||||
|
||||
@@ -217,7 +217,7 @@ static void print_status(struct MPContext *mpctx)
|
||||
saddf(&line, " x%4.2f", opts->playback_speed);
|
||||
|
||||
// A-V sync
|
||||
if (mpctx->ao_chain && mpctx->vo_chain && mpctx->sync_audio_to_video) {
|
||||
if (mpctx->ao_chain && mpctx->vo_chain && !mpctx->vo_chain->is_coverart) {
|
||||
saddf(&line, " A-V:%7.3f", mpctx->last_av_difference);
|
||||
if (fabs(mpctx->total_avsync_change) > 0.05)
|
||||
saddf(&line, " ct:%7.3f", mpctx->total_avsync_change);
|
||||
|
||||
@@ -301,7 +301,6 @@ void uninit_video_chain(struct MPContext *mpctx)
|
||||
vo_chain_uninit(mpctx->vo_chain);
|
||||
mpctx->vo_chain = NULL;
|
||||
mpctx->video_status = STATUS_EOF;
|
||||
mpctx->sync_audio_to_video = false;
|
||||
reselect_demux_streams(mpctx);
|
||||
remove_deint_filter(mpctx);
|
||||
mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL);
|
||||
@@ -361,6 +360,7 @@ int reinit_video_chain(struct MPContext *mpctx)
|
||||
}
|
||||
|
||||
vo_c->container_fps = d_video->fps;
|
||||
vo_c->is_coverart = !!sh->attached_picture;
|
||||
vo_c->video_src = d_video;
|
||||
|
||||
#if HAVE_ENCODING
|
||||
@@ -379,8 +379,6 @@ int reinit_video_chain(struct MPContext *mpctx)
|
||||
|
||||
vo_set_paused(vo_c->vo, mpctx->paused);
|
||||
|
||||
mpctx->sync_audio_to_video = !sh->attached_picture;
|
||||
|
||||
// If we switch on video again, ensure audio position matches up.
|
||||
if (mpctx->ao_chain)
|
||||
mpctx->audio_status = STATUS_SYNCING;
|
||||
@@ -697,11 +695,10 @@ static bool have_new_frame(struct MPContext *mpctx, bool eof)
|
||||
// returns VD_* code
|
||||
static int video_output_image(struct MPContext *mpctx, double endpts)
|
||||
{
|
||||
struct vo_chain *vo_c = mpctx->vo_chain;
|
||||
bool hrseek = mpctx->hrseek_active && mpctx->video_status == STATUS_SYNCING;
|
||||
|
||||
struct track *track = mpctx->current_track[0][STREAM_VIDEO];
|
||||
bool is_coverart = track && track->stream && track->stream->attached_picture;
|
||||
if (is_coverart) {
|
||||
if (vo_c->is_coverart) {
|
||||
if (vo_has_frame(mpctx->video_out))
|
||||
return VD_EOF;
|
||||
hrseek = false;
|
||||
@@ -717,7 +714,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
|
||||
r = video_decode_and_filter(mpctx);
|
||||
if (r < 0)
|
||||
return r; // error
|
||||
struct mp_image *img = vf_read_output_frame(mpctx->vo_chain->vf);
|
||||
struct mp_image *img = vf_read_output_frame(vo_c->vf);
|
||||
if (img) {
|
||||
if (endpts != MP_NOPTS_VALUE && img->pts >= endpts) {
|
||||
r = VD_EOF;
|
||||
@@ -731,7 +728,7 @@ static int video_output_image(struct MPContext *mpctx, double endpts)
|
||||
mp_image_setrefp(&mpctx->saved_frame, img);
|
||||
} else if (mpctx->video_status == STATUS_SYNCING &&
|
||||
mpctx->playback_pts != MP_NOPTS_VALUE &&
|
||||
img->pts < mpctx->playback_pts && !is_coverart)
|
||||
img->pts < mpctx->playback_pts && !vo_c->is_coverart)
|
||||
{
|
||||
/* skip after stream-switching */
|
||||
} else {
|
||||
@@ -769,7 +766,7 @@ static void update_avsync_before_frame(struct MPContext *mpctx)
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
struct vo *vo = mpctx->video_out;
|
||||
|
||||
if (!mpctx->sync_audio_to_video || mpctx->video_status < STATUS_READY) {
|
||||
if (mpctx->vo_chain->is_coverart || mpctx->video_status < STATUS_READY) {
|
||||
mpctx->time_frame = 0;
|
||||
} else if (mpctx->display_sync_active || opts->video_sync == VS_NONE) {
|
||||
// don't touch the timing
|
||||
@@ -1345,7 +1342,7 @@ void write_video(struct MPContext *mpctx, double endpts)
|
||||
|
||||
mp_notify(mpctx, MPV_EVENT_TICK, NULL);
|
||||
|
||||
if (!mpctx->sync_audio_to_video)
|
||||
if (mpctx->vo_chain->is_coverart)
|
||||
mpctx->video_status = STATUS_EOF;
|
||||
|
||||
if (mpctx->video_status != STATUS_EOF) {
|
||||
|
||||
Reference in New Issue
Block a user