diff options
author | wm4 <wm4@nowhere> | 2014-09-18 19:22:39 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-18 19:35:23 +0200 |
commit | 5c8549ac68c1a8a4921e5f0ea842969aa8072a18 (patch) | |
tree | b06856b4e7197a05c38bac56f1cd80a7de60d524 /player/video.c | |
parent | e37ad620aa324939ce15ec4a6898b87e1e23d643 (diff) | |
download | mpv-5c8549ac68c1a8a4921e5f0ea842969aa8072a18.tar.bz2 mpv-5c8549ac68c1a8a4921e5f0ea842969aa8072a18.tar.xz |
video: separate calling decoder/filter
Rename video_decode_and_filter to video_filter, and add a new
video_decode_and_filter function. This function now calls the decoder.
This is done so that we can check filters a second time after decoding,
which avoids a useless playloop iteration.
(This and the previous commits are really just microoptimizations, which
simply reduce the number of times the playloop has to recheck
everything.)
Diffstat (limited to 'player/video.c')
-rw-r--r-- | player/video.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/player/video.c b/player/video.c index 16bbb172e6..5b7048e2b4 100644 --- a/player/video.c +++ b/player/video.c @@ -404,11 +404,9 @@ static void init_filter_params(struct MPContext *mpctx) mp_property_do("deinterlace", M_PROPERTY_SET, &opts->deinterlace, mpctx); } -// Make sure at least 1 filtered image is available. -// returns VD_* code -// A return value of VD_PROGRESS doesn't necessarily output a frame, but makes -// the promise that calling this function again will eventually do something. -static int video_decode_and_filter(struct MPContext *mpctx) +// Feed newly decoded frames to the filter, take care of format changes. +// If eof=true, drain the filter chain, and return VD_EOF if empty. +static int video_filter(struct MPContext *mpctx, bool eof) { struct dec_video *d_video = mpctx->d_video; struct vf_chain *vf = d_video->vfilter; @@ -417,7 +415,7 @@ static int video_decode_and_filter(struct MPContext *mpctx) return VD_ERROR; // There is already a filtered frame available. - if (vf_output_frame(vf, false) > 0) + if (vf_output_frame(vf, eof) > 0) return VD_PROGRESS; // Decoder output is different from filter input? @@ -447,22 +445,32 @@ static int video_decode_and_filter(struct MPContext *mpctx) return VD_PROGRESS; } + return eof ? VD_EOF : VD_PROGRESS; +} + +// Make sure at least 1 filtered image is available, decode new video if needed. +// returns VD_* code +// A return value of VD_PROGRESS doesn't necessarily output a frame, but makes +// the promise that calling this function again will eventually do something. +static int video_decode_and_filter(struct MPContext *mpctx) +{ + struct dec_video *d_video = mpctx->d_video; + + int r = video_filter(mpctx, false); + if (r < 0) + return r; + if (!d_video->waiting_decoded_mpi) { // Decode a new image, or at least feed the decoder a packet. - int r = decode_image(mpctx); + r = decode_image(mpctx); if (r == VD_WAIT) return r; if (d_video->waiting_decoded_mpi) d_video->decoder_output = d_video->waiting_decoded_mpi->params; - if (!d_video->waiting_decoded_mpi && (r == VD_EOF || r < 0)) { - if (vf_output_frame(vf, true) > 0) - return VD_PROGRESS; - return VD_EOF; // true EOF - } } - // Image will be filtered on the next iteration. - return VD_PROGRESS; + bool eof = !d_video->waiting_decoded_mpi && (r == VD_EOF || r < 0); + return video_filter(mpctx, eof); } /* Modify video timing to match the audio timeline. There are two main |