[MPlayer-dev-eng] [PATCH 2/2] dec_audio: support explicitly requesting more input data.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Jul 12 00:28:50 EEST 2022


Fixes decoding of some MPEG-TS streams with DTS.
---
 libmpcodecs/ad_ffmpeg.c | 2 ++
 libmpcodecs/dec_audio.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c
index ca7bed56d..4786abfee 100644
--- a/libmpcodecs/ad_ffmpeg.c
+++ b/libmpcodecs/ad_ffmpeg.c
@@ -333,6 +333,8 @@ static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int m
 	    int in_size = x;
 	    int consumed = ds_parse(sh_audio->ds, &start, &x, pts, 0);
 	    sh_audio->ds->buffer_pos -= in_size - consumed;
+	    // Explicitly request more data if all was used up by parser
+	    if (x == 0 && consumed == in_size && len == -1) len = AVERROR(EAGAIN);
 	    // Note: hopefully the following x <= 0 handling is correct, it was only
 	    // added because FFmpeg broke the API and 0-sized
 	    // packets started to break e.g. AC3 decode.
diff --git a/libmpcodecs/dec_audio.c b/libmpcodecs/dec_audio.c
index 476f47a99..332c68cd1 100644
--- a/libmpcodecs/dec_audio.c
+++ b/libmpcodecs/dec_audio.c
@@ -410,7 +410,8 @@ static int filter_n_bytes(sh_audio_t *sh, int len)
 	int format_change = sh->samplerate != filter_input.rate ||
 	                    sh->channels != filter_input.nch ||
 	                    sh->sample_format != filter_input.format;
-	if (ret <= 0 || format_change) {
+	if (ret == AVERROR(EAGAIN)) ret = 0;
+	else if (ret <= 0 || format_change) {
 	    error = format_change ? -2 : -1;
 	    len = sh->a_buffer_len;
 	    break;
-- 
2.36.1



More information about the MPlayer-dev-eng mailing list