From a5224836293ac02bd13f688cfc848aae6818e963 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 11 Jul 2013 19:10:33 +0200 Subject: demux: remove facility for partial packet reads Partial packet reads were needed because the video/audio parsers were working on top of them. So it could happen that a parser read a part of a packet, and returned that to the decoder. With libavformat/libavcodec, packets are already parsed, and everything is much simpler. Most of the simplifications in ad_spdif could have been done earlier. Remove some other stuff as well, like the questionable slave mode start time reporting (could be replaced by proper code, but we don't bother). Remove the unused skip_audio_frame() functionality as well (it was used by old demuxers). Some functions become private to demux.c, like demux_fill_buffer(). Introduce new packet read functions, which have simpler semantics. Packets returned from them are owned by the caller, and all packets in the demux.c packet queue are considered unread. Remove special code that dropped subtitle packets with size 0. This used to be needed because it caused special cases in the old code. --- audio/decode/ad_mpg123.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'audio/decode/ad_mpg123.c') diff --git a/audio/decode/ad_mpg123.c b/audio/decode/ad_mpg123.c index 08739b7f4b..8d97468e06 100644 --- a/audio/decode/ad_mpg123.c +++ b/audio/decode/ad_mpg123.c @@ -217,27 +217,25 @@ static int decode_a_bit(sh_audio_t *sh, unsigned char *buf, int count) /* Feed the decoder. This will only fire from the second round on. */ if (ret == MPG123_NEED_MORE) { - int incount; - double pts; - unsigned char *inbuf; /* Feed more input data. */ - incount = ds_get_packet_pts(sh->ds, &inbuf, &pts); - if (incount <= 0) + struct demux_packet *pkt = demux_read_packet(sh->gsh); + if (!pkt) break; /* Apparently that's it. EOF. */ /* Next bytes from that presentation time. */ - if (pts != MP_NOPTS_VALUE) { - sh->pts = pts; + if (pkt->pts != MP_NOPTS_VALUE) { + sh->pts = pkt->pts; sh->pts_bytes = 0; } #ifdef AD_MPG123_FRAMEWISE /* Have to use mpg123_feed() to avoid decoding here. */ - ret = mpg123_feed(con->handle, inbuf, incount); + ret = mpg123_feed(con->handle, pkt->buffer, pkt->len); #else /* Do not use mpg123_feed(), added in later libmpg123 versions. */ - ret = mpg123_decode(con->handle, inbuf, incount, NULL, 0, NULL); + ret = mpg123_decode(con->handle, pkt->buffer, pkt->len, NULL, 0, NULL); #endif + talloc_free(pkt); if (ret == MPG123_ERR) break; } -- cgit v1.2.3