diff options
author | wm4 <wm4@nowhere> | 2019-10-24 18:40:46 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-10-24 18:50:28 +0200 |
commit | 5d5fdb77e990f95e0a51e16c7349a19e8cebc272 (patch) | |
tree | b18fefc9b2ac0a1c7656f849c12625363335fde9 /filters/f_decoder_wrapper.h | |
parent | 065c307e8e7dbfc15aea39b714f944a117e4916a (diff) | |
download | mpv-5d5fdb77e990f95e0a51e16c7349a19e8cebc272.tar.bz2 mpv-5d5fdb77e990f95e0a51e16c7349a19e8cebc272.tar.xz |
ad_lavc, vd_lavc: return full error codes to shared decoder loop
ad_lavc and vd_lavc use the lavc_process() helper to translate the
FFmpeg push/pull API to the internal filter API (which completely
mismatch, even though I'm responsible for both, just fucking kill me).
This interface was "slightly" too tight. It returned only a bool
indicating "progress", which was not enough to handle some cases (see
following commit).
While we're at it, move all state into a struct. This is only a single
bool, but we get the chance to add more if needed.
This fixes mpv falling asleep if decoding returns an error during
draining. If decoding fails when we already sent EOF, the state machine
stopped making progress. This left mpv just sitting around and doing
nothing.
A test case can be created with: echo $RANDOM >> image.png
This makes libavformat read a proper packet plus a packet of garbage.
libavcodec will decode a frame, and then return an error code. The
lavc_process() wrapper could not deal with this, because there was no
way to differentiate between "retry" and "send new packet". Normally, it
would send a new packet, so decoding would make progress anyway. If
there was "progress", we couldn't just retry, because it'd retry
forever.
This is made worse by the fact that it tries to decode at least two
frames before starting display, meaning it will "sit around and do
nothing" before the picture is displayed.
Change it so that on error return, "receiving" a frame is retried. This
will make it return the EOF, so everything works properly.
This is a high-risk change, because all these funny bullshit exceptions
for hardware decoding are in the way, and I didn't retest them. For
example, if hardware decoding is enabled, it keeps a list of packets,
that are fed into the decoder again if hardware decoding fails, and a
software fallback is performed. Another case of horrifying accidental
complexity.
Fixes: #6618
Diffstat (limited to 'filters/f_decoder_wrapper.h')
-rw-r--r-- | filters/f_decoder_wrapper.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/filters/f_decoder_wrapper.h b/filters/f_decoder_wrapper.h index b69c0c7680..28d9b5cb7b 100644 --- a/filters/f_decoder_wrapper.h +++ b/filters/f_decoder_wrapper.h @@ -109,11 +109,14 @@ extern const struct mp_decoder_fns vd_lavc; extern const struct mp_decoder_fns ad_lavc; extern const struct mp_decoder_fns ad_spdif; -// Convenience wrapper for lavc based decoders. eof_flag must be set to false -// on init and resets. -void lavc_process(struct mp_filter *f, bool *eof_flag, - bool (*send)(struct mp_filter *f, struct demux_packet *pkt), - bool (*receive)(struct mp_filter *f, struct mp_frame *res)); +// Convenience wrapper for lavc based decoders. Treat lavc_state as private; +// init to all-0 on init and resets. +struct lavc_state { + bool eof_returned; +}; +void lavc_process(struct mp_filter *f, struct lavc_state *state, + int (*send)(struct mp_filter *f, struct demux_packet *pkt), + int (*receive)(struct mp_filter *f, struct mp_frame *res)); // ad_spdif.c struct mp_decoder_list *select_spdif_codec(const char *codec, const char *pref); |