mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 16:33:02 +00:00
player: refactor: some more minor decoder/output decoupling
These changes don't make too much sense without context, but are preparation for later. Then the audio_src/video_src fields will be actually be NULL under circumstances.
This commit is contained in:
parent
c00dc5c5c6
commit
526d578bee
@ -171,14 +171,15 @@ static void ao_chain_reset_state(struct ao_chain *ao_c)
|
|||||||
ao_c->input_frame = NULL;
|
ao_c->input_frame = NULL;
|
||||||
af_seek_reset(ao_c->af);
|
af_seek_reset(ao_c->af);
|
||||||
mp_audio_buffer_clear(ao_c->ao_buffer);
|
mp_audio_buffer_clear(ao_c->ao_buffer);
|
||||||
|
|
||||||
|
if (ao_c->audio_src)
|
||||||
|
audio_reset_decoding(ao_c->audio_src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_audio_state(struct MPContext *mpctx)
|
void reset_audio_state(struct MPContext *mpctx)
|
||||||
{
|
{
|
||||||
if (mpctx->ao_chain) {
|
if (mpctx->ao_chain)
|
||||||
audio_reset_decoding(mpctx->ao_chain->audio_src);
|
|
||||||
ao_chain_reset_state(mpctx->ao_chain);
|
ao_chain_reset_state(mpctx->ao_chain);
|
||||||
}
|
|
||||||
mpctx->audio_status = mpctx->ao_chain ? STATUS_SYNCING : STATUS_EOF;
|
mpctx->audio_status = mpctx->ao_chain ? STATUS_SYNCING : STATUS_EOF;
|
||||||
mpctx->delay = 0;
|
mpctx->delay = 0;
|
||||||
mpctx->audio_drop_throttle = 0;
|
mpctx->audio_drop_throttle = 0;
|
||||||
@ -238,6 +239,9 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
|
|||||||
assert(ao_c);
|
assert(ao_c);
|
||||||
struct af_stream *afs = ao_c->af;
|
struct af_stream *afs = ao_c->af;
|
||||||
|
|
||||||
|
if (ao_c->input_frame)
|
||||||
|
mp_audio_copy_config(&ao_c->input_format, ao_c->input_frame);
|
||||||
|
|
||||||
struct mp_audio in_format = ao_c->input_format;
|
struct mp_audio in_format = ao_c->input_format;
|
||||||
|
|
||||||
if (!mp_audio_config_valid(&in_format)) {
|
if (!mp_audio_config_valid(&in_format)) {
|
||||||
@ -307,7 +311,7 @@ static void reinit_audio_filters_and_output(struct MPContext *mpctx)
|
|||||||
|
|
||||||
if (!mpctx->ao) {
|
if (!mpctx->ao) {
|
||||||
// If spdif was used, try to fallback to PCM.
|
// If spdif was used, try to fallback to PCM.
|
||||||
if (spdif_fallback) {
|
if (spdif_fallback && ao_c->audio_src) {
|
||||||
MP_VERBOSE(mpctx, "Falling back to PCM output.\n");
|
MP_VERBOSE(mpctx, "Falling back to PCM output.\n");
|
||||||
ao_c->spdif_passthrough = false;
|
ao_c->spdif_passthrough = false;
|
||||||
ao_c->spdif_failed = true;
|
ao_c->spdif_failed = true;
|
||||||
@ -579,9 +583,6 @@ static int decode_new_frame(struct ao_chain *ao_c)
|
|||||||
res = audio_get_frame(ao_c->audio_src, &ao_c->input_frame);
|
res = audio_get_frame(ao_c->audio_src, &ao_c->input_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ao_c->input_frame)
|
|
||||||
mp_audio_copy_config(&ao_c->input_format, ao_c->input_frame);
|
|
||||||
|
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case AUDIO_OK: return AD_OK;
|
case AUDIO_OK: return AD_OK;
|
||||||
case AUDIO_WAIT: return AD_WAIT;
|
case AUDIO_WAIT: return AD_WAIT;
|
||||||
|
@ -246,7 +246,8 @@ static void print_status(struct MPContext *mpctx)
|
|||||||
talloc_free(r);
|
talloc_free(r);
|
||||||
}
|
}
|
||||||
int64_t c = vo_get_drop_count(mpctx->video_out);
|
int64_t c = vo_get_drop_count(mpctx->video_out);
|
||||||
int dropped_frames = mpctx->vo_chain->video_src->dropped_frames;
|
struct dec_video *d_video = mpctx->vo_chain->video_src;
|
||||||
|
int dropped_frames = d_video ? d_video->dropped_frames : 0;
|
||||||
if (c > 0 || dropped_frames > 0) {
|
if (c > 0 || dropped_frames > 0) {
|
||||||
saddf(&line, " Dropped: %"PRId64, c);
|
saddf(&line, " Dropped: %"PRId64, c);
|
||||||
if (dropped_frames)
|
if (dropped_frames)
|
||||||
|
@ -237,14 +237,15 @@ static void vo_chain_reset_state(struct vo_chain *vo_c)
|
|||||||
if (vo_c->vf->initialized == 1)
|
if (vo_c->vf->initialized == 1)
|
||||||
vf_seek_reset(vo_c->vf);
|
vf_seek_reset(vo_c->vf);
|
||||||
vo_seek_reset(vo_c->vo);
|
vo_seek_reset(vo_c->vo);
|
||||||
|
|
||||||
|
if (vo_c->video_src)
|
||||||
|
video_reset(vo_c->video_src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_video_state(struct MPContext *mpctx)
|
void reset_video_state(struct MPContext *mpctx)
|
||||||
{
|
{
|
||||||
if (mpctx->vo_chain) {
|
if (mpctx->vo_chain)
|
||||||
video_reset(mpctx->vo_chain->video_src);
|
|
||||||
vo_chain_reset_state(mpctx->vo_chain);
|
vo_chain_reset_state(mpctx->vo_chain);
|
||||||
}
|
|
||||||
|
|
||||||
for (int n = 0; n < mpctx->num_next_frames; n++)
|
for (int n = 0; n < mpctx->num_next_frames; n++)
|
||||||
mp_image_unrefp(&mpctx->next_frames[n]);
|
mp_image_unrefp(&mpctx->next_frames[n]);
|
||||||
@ -422,7 +423,8 @@ static bool check_framedrop(struct MPContext *mpctx, struct vo_chain *vo_c)
|
|||||||
struct MPOpts *opts = mpctx->opts;
|
struct MPOpts *opts = mpctx->opts;
|
||||||
// check for frame-drop:
|
// check for frame-drop:
|
||||||
if (mpctx->video_status == STATUS_PLAYING && !mpctx->paused &&
|
if (mpctx->video_status == STATUS_PLAYING && !mpctx->paused &&
|
||||||
mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao))
|
mpctx->audio_status == STATUS_PLAYING && !ao_untimed(mpctx->ao) &&
|
||||||
|
vo_c->video_src)
|
||||||
{
|
{
|
||||||
float fps = vo_c->container_fps;
|
float fps = vo_c->container_fps;
|
||||||
double frame_time = fps > 0 ? 1.0 / fps : 0;
|
double frame_time = fps > 0 ? 1.0 / fps : 0;
|
||||||
@ -453,8 +455,6 @@ static int decode_image(struct MPContext *mpctx)
|
|||||||
|
|
||||||
assert(!vo_c->input_mpi);
|
assert(!vo_c->input_mpi);
|
||||||
int st = video_get_frame(d_video, &vo_c->input_mpi);
|
int st = video_get_frame(d_video, &vo_c->input_mpi);
|
||||||
if (vo_c->input_mpi)
|
|
||||||
vo_c->input_format = vo_c->input_mpi->params;
|
|
||||||
switch (st) {
|
switch (st) {
|
||||||
case VIDEO_WAIT: return VD_WAIT;
|
case VIDEO_WAIT: return VD_WAIT;
|
||||||
case VIDEO_EOF: return VD_EOF;
|
case VIDEO_EOF: return VD_EOF;
|
||||||
@ -510,7 +510,7 @@ static int video_filter(struct MPContext *mpctx, bool eof)
|
|||||||
|
|
||||||
// Most video filters don't work with hardware decoding, so this
|
// Most video filters don't work with hardware decoding, so this
|
||||||
// might be the reason why filter reconfig failed.
|
// might be the reason why filter reconfig failed.
|
||||||
if (vf->initialized < 0 &&
|
if (vf->initialized < 0 && vo_c->video_src &&
|
||||||
video_vd_control(vo_c->video_src, VDCTRL_FORCE_HWDEC_FALLBACK, NULL)
|
video_vd_control(vo_c->video_src, VDCTRL_FORCE_HWDEC_FALLBACK, NULL)
|
||||||
== CONTROL_OK)
|
== CONTROL_OK)
|
||||||
{
|
{
|
||||||
@ -558,6 +558,8 @@ static int video_decode_and_filter(struct MPContext *mpctx)
|
|||||||
if (r == VD_WAIT)
|
if (r == VD_WAIT)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
if (vo_c->input_mpi)
|
||||||
|
vo_c->input_format = vo_c->input_mpi->params;
|
||||||
|
|
||||||
bool eof = !vo_c->input_mpi && (r == VD_EOF || r < 0);
|
bool eof = !vo_c->input_mpi && (r == VD_EOF || r < 0);
|
||||||
r = video_filter(mpctx, eof);
|
r = video_filter(mpctx, eof);
|
||||||
@ -636,7 +638,9 @@ static void handle_new_frame(struct MPContext *mpctx)
|
|||||||
mpctx->time_frame += frame_time / mpctx->video_speed;
|
mpctx->time_frame += frame_time / mpctx->video_speed;
|
||||||
adjust_sync(mpctx, pts, frame_time);
|
adjust_sync(mpctx, pts, frame_time);
|
||||||
}
|
}
|
||||||
mpctx->dropped_frames_start = mpctx->vo_chain->video_src->dropped_frames;
|
struct dec_video *d_video = mpctx->vo_chain->video_src;
|
||||||
|
if (d_video)
|
||||||
|
mpctx->dropped_frames_start = d_video->dropped_frames;
|
||||||
MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time);
|
MP_TRACE(mpctx, "frametime=%5.3f\n", frame_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user