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/command.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/command.c')
-rw-r--r-- | player/command.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/player/command.c b/player/command.c index 809f859280..d1de5a86ff 100644 --- a/player/command.c +++ b/player/command.c @@ -36,6 +36,7 @@ #include "common/codecs.h" #include "common/msg.h" #include "common/msg_control.h" +#include "filters/f_decoder_wrapper.h" #include "command.h" #include "osdep/timer.h" #include "common/common.h" @@ -50,13 +51,12 @@ #include "options/m_option.h" #include "options/m_property.h" #include "options/m_config.h" -#include "video/decode/vd.h" #include "video/out/vo.h" #include "video/csputils.h" +#include "video/hwdec.h" #include "audio/aframe.h" #include "audio/format.h" #include "audio/out/ao.h" -#include "video/decode/dec_video.h" #include "audio/decode/dec_audio.h" #include "video/out/bitmap_packer.h" #include "options/path.h" @@ -675,10 +675,12 @@ static int mp_property_frame_drop_dec(void *ctx, struct m_property *prop, int action, void *arg) { MPContext *mpctx = ctx; - if (!mpctx->vo_chain) + struct mp_decoder_wrapper *dec = mpctx->vo_chain && mpctx->vo_chain->track + ? mpctx->vo_chain->track->dec : NULL; + if (!dec) return M_PROPERTY_UNAVAILABLE; - return m_property_int_ro(action, arg, mpctx->vo_chain->video_src->dropped_frames); + return m_property_int_ro(action, arg, dec->dropped_frames); } static int mp_property_mistimed_frame_count(void *ctx, struct m_property *prop, @@ -2182,8 +2184,8 @@ static int get_track_entry(int item, int action, void *arg, void *ctx) track->stream ? *track->stream->codec : (struct mp_codec_params){0}; const char *decoder_desc = NULL; - if (track->d_video) - decoder_desc = track->d_video->decoder_desc; + if (track->dec) + decoder_desc = track->dec->decoder_desc; if (track->d_audio) decoder_desc = track->d_audio->decoder_desc; @@ -2367,7 +2369,7 @@ static int mp_property_hwdec(void *ctx, struct m_property *prop, { MPContext *mpctx = ctx; struct track *track = mpctx->current_track[0][STREAM_VIDEO]; - struct dec_video *vd = track ? track->d_video : NULL; + struct mp_decoder_wrapper *dec = track ? track->dec : NULL; struct MPOpts *opts = mpctx->opts; if (action == M_PROPERTY_SET) { @@ -2379,10 +2381,10 @@ static int mp_property_hwdec(void *ctx, struct m_property *prop, talloc_free(opts->hwdec_api); opts->hwdec_api = talloc_strdup(NULL, new); - if (!vd) + if (!dec) return M_PROPERTY_OK; - video_vd_control(vd, VDCTRL_REINIT, NULL); + mp_decoder_wrapper_control(dec, VDCTRL_REINIT, NULL); double last_pts = mpctx->last_vo_pts; if (last_pts != MP_NOPTS_VALUE) queue_seek(mpctx, MPSEEK_ABSOLUTE, last_pts, MPSEEK_EXACT, 0); @@ -2397,13 +2399,13 @@ static int mp_property_hwdec_current(void *ctx, struct m_property *prop, { MPContext *mpctx = ctx; struct track *track = mpctx->current_track[0][STREAM_VIDEO]; - struct dec_video *vd = track ? track->d_video : NULL; + struct mp_decoder_wrapper *dec = track ? track->dec : NULL; - if (!vd) + if (!dec) return M_PROPERTY_UNAVAILABLE; char *current = NULL; - video_vd_control(vd, VDCTRL_GET_HWDEC, ¤t); + mp_decoder_wrapper_control(dec, VDCTRL_GET_HWDEC, ¤t); if (!current) current = "no"; return m_property_strdup_ro(action, arg, current); @@ -2547,7 +2549,7 @@ static int mp_property_video_codec(void *ctx, struct m_property *prop, { MPContext *mpctx = ctx; struct track *track = mpctx->current_track[0][STREAM_VIDEO]; - const char *c = track && track->d_video ? track->d_video->decoder_desc : NULL; + const char *c = track && track->dec ? track->dec->decoder_desc : NULL; return m_property_strdup_ro(action, arg, c); } @@ -2620,8 +2622,8 @@ static int mp_property_dec_imgparams(void *ctx, struct m_property *prop, MPContext *mpctx = ctx; struct mp_image_params p = {0}; struct vo_chain *vo_c = mpctx->vo_chain; - if (vo_c && vo_c->video_src) - video_get_dec_params(vo_c->video_src, &p); + if (vo_c && vo_c->track) + mp_decoder_wrapper_get_video_dec_params(vo_c->track->dec, &p); if (!p.imgfmt) return M_PROPERTY_UNAVAILABLE; return property_imgparams(p, action, arg); @@ -2984,9 +2986,8 @@ static int mp_property_aspect(void *ctx, struct m_property *prop, } } struct track *track = mpctx->current_track[0][STREAM_VIDEO]; - if (track && track->d_video && aspect <= 0) { - struct dec_video *d_video = track->d_video; - struct mp_codec_params *c = d_video->header->codec; + if (track && track->stream && aspect <= 0) { + struct mp_codec_params *c = track->stream->codec; if (c->disp_w && c->disp_h) aspect = (float)c->disp_w / c->disp_h; } @@ -5807,8 +5808,8 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags) if (flags & UPDATE_IMGPAR) { struct track *track = mpctx->current_track[0][STREAM_VIDEO]; - if (track && track->d_video) { - video_reset_params(track->d_video); + if (track && track->dec) { + mp_decoder_wrapper_reset_params(track->dec); mp_force_video_refresh(mpctx); } } |