1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-29 18:42:09 +00:00
mpv/audio
wm4 33e5755c23 video, audio: always read all frames before getting next packet
The old code tried to make sure at all times to try to read a new
packet. Only once that was read, it tried to retrieve new video or audio
frames the decoder might already have decoded.

Change this to strictly read frames from the decoder until it signals
that it wants a new packet, and only then read and feed a new packet.
This is in theory nicer, follows the libavcodec recommended data flow,
and and reduces the minimum latency by 1 frame.

This merely requires switching the order in which those calls are done.
Normally, the decoder will return only 1 frame until a new packet is
required. If we would just feed it 1 packet, return DATA_AGAIN, and wait
until the next frame is decoded, we would run the playloop 1 time too
often for no reason (which is fine but might have some overhead). To
avoid this, try to read a frame again after possibly feeding a packet.
For this reason, move the feed/read code to its own functions each,
instead of merely moving the code.

The audio and video code for this particular thing is basically
duplicated. The idea is to unify them one day, so make the change to
both. (Doing this for video is the real motivation for this change, see
below.)

The video code change is slightly more complicated, because we have to
care about the framedrop counting (which is just a heuristic, but for
now considered better than nothing, and possibly considered required to
warn the user of framedrops happening - maybe).

Apparently this change helps with stalling streams on Android with the
mediacodec wrapper and mpeg2 decoder implementations which deinterlace on
decoding (and return 2 frames per packet).

Based on an idea and observations by tmm1.
2018-01-01 23:17:56 -08:00
..
decode video, audio: always read all frames before getting next packet 2018-01-01 23:17:56 -08:00
filter Fix various typos in log messages 2017-12-03 21:24:18 +01:00
out Fix various typos in log messages 2017-12-03 21:24:18 +01:00
aconverter.c Fix various typos in log messages 2017-12-03 21:24:18 +01:00
aconverter.h audio: move libswresample wrapper out of audio filter code 2017-09-21 12:42:09 +02:00
aframe.c aframe: fix logically dead code 2017-10-18 12:11:37 +02:00
aframe.h audio: move libswresample wrapper out of audio filter code 2017-09-21 12:42:09 +02:00
audio_buffer.c audio_buffer: remove dependency on mp_audio 2017-09-21 04:10:19 +02:00
audio_buffer.h audio_buffer: remove dependency on mp_audio 2017-09-21 04:10:19 +02:00
audio.c Get rid of deprecated AVFrame accessors 2017-10-30 13:36:44 +01:00
audio.h audio: make libaf derived code optional 2017-09-21 12:48:30 +02:00
chmap_sel.c audio: use --audio-channels=auto behavior, except on ALSA 2016-08-04 20:49:20 +02:00
chmap_sel.h audio: use --audio-channels=auto behavior, except on ALSA 2016-08-04 20:49:20 +02:00
chmap.c chmap: remove misleading "downmix" channel layout name 2017-06-24 11:36:10 +02:00
chmap.h player: remove special-case for DL/DR speakers 2016-08-04 19:14:35 +02:00
fmt-conversion.c audio/fmt-conversion: change license to LGPL 2017-05-05 07:25:55 +02:00
fmt-conversion.h audio/fmt-conversion: change license to LGPL 2017-05-05 07:25:55 +02:00
format.c audio: make libaf derived code optional 2017-09-21 12:48:30 +02:00
format.h audio: drop AF_FORMAT_S24 2017-07-07 17:56:22 +02:00