summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-01-28 10:08:45 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-30 03:10:27 -0800
commit6d36fad83c779936a012e85a1eb92ec94651c7c0 (patch)
tree76762208837d18545a4a315be890d7bffad7e47f /player/loadfile.c
parenteaced0ebb03a078394ed01bcbe641b5b7a4312aa (diff)
downloadmpv-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/loadfile.c')
-rw-r--r--player/loadfile.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index ad1b20ac8e..d35ae6ad6b 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -45,13 +45,13 @@
#include "audio/decode/dec_audio.h"
#include "audio/out/ao.h"
+#include "filters/f_decoder_wrapper.h"
#include "filters/f_lavfi.h"
#include "filters/filter_internal.h"
#include "demux/demux.h"
#include "stream/stream.h"
#include "sub/dec_sub.h"
#include "external_files.h"
-#include "video/decode/dec_video.h"
#include "video/out/vo.h"
#include "core.h"
@@ -984,9 +984,9 @@ static void cleanup_deassociated_complex_filters(struct MPContext *mpctx)
for (int n = 0; n < mpctx->num_tracks; n++) {
struct track *track = mpctx->tracks[n];
if (!(track->sink || track->vo_c || track->ao_c)) {
- if (track->d_video && !track->vo_c) {
- video_uninit(track->d_video);
- track->d_video = NULL;
+ if (track->dec && !track->vo_c) {
+ talloc_free(track->dec->f);
+ track->dec->f = NULL;
}
if (track->d_audio && !track->ao_c) {
audio_uninit(track->d_audio);
@@ -996,7 +996,7 @@ static void cleanup_deassociated_complex_filters(struct MPContext *mpctx)
}
}
- if (mpctx->vo_chain && !mpctx->vo_chain->video_src &&
+ if (mpctx->vo_chain && !mpctx->vo_chain->dec_src &&
!mpctx->vo_chain->filter_src)
{
uninit_video_chain(mpctx);
@@ -1079,18 +1079,16 @@ static int reinit_complex_filters(struct MPContext *mpctx, bool force_uninit)
struct mp_pin *pad = mp_filter_get_named_pin(mpctx->lavfi, "vo");
if (pad && mp_pin_get_dir(pad) == MP_PIN_OUT) {
if (mpctx->vo_chain) {
- if (mpctx->vo_chain->video_src) {
- MP_ERR(mpctx, "Pad vo tries to connect to already used VO.\n");
- goto done;
- }
+ MP_ERR(mpctx, "Pad vo tries to connect to already used VO.\n");
+ goto done;
} else {
reinit_video_chain_src(mpctx, NULL);
if (!mpctx->vo_chain)
goto done;
}
- mp_pin_set_manual_connection(pad, true);
struct vo_chain *vo_c = mpctx->vo_chain;
vo_c->filter_src = pad;
+ mp_pin_connect(vo_c->filter->f->pins[0], vo_c->filter_src);
}
pad = mp_filter_get_named_pin(mpctx->lavfi, "ao");
@@ -1112,8 +1110,9 @@ static int reinit_complex_filters(struct MPContext *mpctx, bool force_uninit)
for (int n = 0; n < mpctx->num_tracks; n++) {
struct track *track = mpctx->tracks[n];
if (track->sink && track->type == STREAM_VIDEO) {
- if (!track->d_video && !init_video_decoder(mpctx, track))
+ if (!track->dec && !init_video_decoder(mpctx, track))
goto done;
+ mp_pin_connect(track->sink, track->dec->f->pins[0]);
}
if (track->sink && track->type == STREAM_AUDIO) {
if (!track->d_audio && !init_audio_decoder(mpctx, track))
@@ -1587,8 +1586,8 @@ static void set_track_recorder_sink(struct track *track,
{
if (track->d_sub)
sub_set_recorder_sink(track->d_sub, sink);
- if (track->d_video)
- track->d_video->recorder_sink = sink;
+ if (track->dec)
+ track->dec->recorder_sink = sink;
if (track->d_audio)
track->d_audio->recorder_sink = sink;
track->remux_sink = sink;
@@ -1633,7 +1632,7 @@ void open_recorder(struct MPContext *mpctx, bool on_init)
for (int n = 0; n < mpctx->num_tracks; n++) {
struct track *track = mpctx->tracks[n];
if (track->stream && track->selected &&
- (track->d_sub || track->d_video || track->d_audio))
+ (track->d_sub || track->dec || track->d_audio))
{
MP_TARRAY_APPEND(NULL, streams, num_streams, track->stream);
}