diff options
author | wm4 <wm4@nowhere> | 2018-01-28 10:08:45 +0100 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2018-01-30 03:10:27 -0800 |
commit | 6d36fad83c779936a012e85a1eb92ec94651c7c0 (patch) | |
tree | 76762208837d18545a4a315be890d7bffad7e47f /player/playloop.c | |
parent | eaced0ebb03a078394ed01bcbe641b5b7a4312aa (diff) | |
download | mpv-6d36fad83c779936a012e85a1eb92ec94651c7c0.tar.bz2 mpv-6d36fad83c779936a012e85a1eb92ec94651c7c0.tar.xz |
video: make decoder wrapper a filter
Move dec_video.c to filters/f_decoder_wrapper.c. It essentially becomes
a source filter. vd.h mostly disappears, because mp_filter takes care of
the dataflow, but its remains are in struct mp_decoder_fns.
One goal is to simplify dataflow by letting the filter framework handle
it (or more accurately, using its conventions). One result is that the
decode calls disappear from video.c, because we simply connect the
decoder wrapper and the filter chain with mp_pin_connect().
Another goal is to eventually remove the code duplication between the
audio and video paths for this. This commit prepares for this by trying
to make f_decoder_wrapper.c extensible, so it can be used for audio as
well later.
Decoder framedropping changes a bit. It doesn't seem to be worse than
before, and it's an obscure feature, so I'm content with its new state.
Some special code that was apparently meant to avoid dropping too many
frames in a row is removed, though.
I'm not sure how the source code tree should be organized. For one,
video/decode/vd_lavc.c is the only file in its directory, which is a bit
annoying.
Diffstat (limited to 'player/playloop.c')
-rw-r--r-- | player/playloop.c | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/player/playloop.c b/player/playloop.c index a75263cc5f..748469354d 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -29,6 +29,7 @@ #include "common/common.h" #include "common/encode.h" #include "common/recorder.h" +#include "filters/f_decoder_wrapper.h" #include "options/m_config.h" #include "options/m_property.h" #include "common/playlist.h" @@ -43,7 +44,6 @@ #include "demux/demux.h" #include "stream/stream.h" #include "sub/osd.h" -#include "video/decode/dec_video.h" #include "video/out/vo.h" #include "core.h" @@ -213,8 +213,6 @@ void add_step_frame(struct MPContext *mpctx, int dir) void reset_playback_state(struct MPContext *mpctx) { for (int n = 0; n < mpctx->num_tracks; n++) { - if (mpctx->tracks[n]->d_video) - video_reset(mpctx->tracks[n]->d_video); if (mpctx->tracks[n]->d_audio) audio_reset_decoding(mpctx->tracks[n]->d_audio); mpctx->tracks[n]->sink_eof = false; @@ -227,7 +225,6 @@ void reset_playback_state(struct MPContext *mpctx) reset_subtitle_state(mpctx); mpctx->hrseek_active = false; - mpctx->hrseek_framedrop = false; mpctx->hrseek_lastframe = false; mpctx->hrseek_backstep = false; mpctx->current_seek = (struct seek_params){0}; @@ -376,13 +373,22 @@ static void mp_seek(MPContext *mpctx, struct seek_params seek) if (hr_seek) { mpctx->hrseek_active = true; - mpctx->hrseek_framedrop = !hr_seek_very_exact && opts->hr_seek_framedrop; mpctx->hrseek_backstep = seek.type == MPSEEK_BACKSTEP; mpctx->hrseek_pts = seek_pts; + // allow decoder to drop frames before hrseek_pts + bool hrseek_framedrop = !hr_seek_very_exact && opts->hr_seek_framedrop; + MP_VERBOSE(mpctx, "hr-seek, skipping to %f%s%s\n", mpctx->hrseek_pts, - mpctx->hrseek_framedrop ? "" : " (no framedrop)", + hrseek_framedrop ? "" : " (no framedrop)", mpctx->hrseek_backstep ? " (backstep)" : ""); + + for (int n = 0; n < mpctx->num_tracks; n++) { + struct track *track = mpctx->tracks[n]; + struct mp_decoder_wrapper *dec = track->dec; + if (dec && hrseek_framedrop) + mp_decoder_wrapper_set_start_pts(dec, mpctx->hrseek_pts); + } } if (mpctx->stop_play == AT_END_OF_FILE) @@ -1079,9 +1085,9 @@ static void handle_complex_filter_decoders(struct MPContext *mpctx) struct track *track = mpctx->tracks[n]; if (!track->selected) continue; - if (!track->sink || !mp_pin_in_needs_data(track->sink)) - continue; if (track->d_audio) { + if (!track->sink || !mp_pin_in_needs_data(track->sink)) + continue; audio_work(track->d_audio); struct mp_aframe *fr; int res = audio_get_frame(track->d_audio, &fr); @@ -1096,21 +1102,6 @@ static void handle_complex_filter_decoders(struct MPContext *mpctx) mp_wakeup_core(mpctx); } } - if (track->d_video) { - video_work(track->d_video); - struct mp_image *fr; - int res = video_get_frame(track->d_video, &fr); - if (res == DATA_OK) { - mp_pin_in_write(track->sink, MAKE_FRAME(MP_FRAME_VIDEO, fr)); - track->sink_eof = false; - } else if (res == DATA_EOF) { - if (!track->sink_eof) - mp_pin_in_write(track->sink, MP_EOF_FRAME); - track->sink_eof = true; - } else if (res == DATA_AGAIN) { - mp_wakeup_core(mpctx); - } - } } } |