summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-12-12 12:36:56 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-16 06:22:19 +0200
commitc11757c5afa53c3556252ec32a18f1fa88aa5d5b (patch)
tree7dbf8db46bde2d31b6fbe7ade701a8be4e46d033
parentfbd28ae9398beab022815fcc84f3b0dd47ee3372 (diff)
downloadmpv-c11757c5afa53c3556252ec32a18f1fa88aa5d5b.tar.bz2
mpv-c11757c5afa53c3556252ec32a18f1fa88aa5d5b.tar.xz
ad_speex: improve timestamp handling
Improve speex codec pts handling, make audio timestamps work reasonably even with the native demuxer as long as seeking is not done. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32704 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpcodecs/ad_speex.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libmpcodecs/ad_speex.c b/libmpcodecs/ad_speex.c
index a8d0bf4036..f8ddc2f336 100644
--- a/libmpcodecs/ad_speex.c
+++ b/libmpcodecs/ad_speex.c
@@ -140,6 +140,7 @@ static void uninit(sh_audio_t *sh) {
static int decode_audio(sh_audio_t *sh, unsigned char *buf,
int minlen, int maxlen) {
+ double pts;
context_t *ctx = sh->context;
int len, framelen, framesamples;
char *packet;
@@ -150,8 +151,14 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf,
mp_msg(MSGT_DECAUDIO, MSGL_V, "maxlen too small in decode_audio\n");
return -1;
}
- len = ds_get_packet(sh->ds, (unsigned char **)&packet);
+ len = ds_get_packet_pts(sh->ds, (unsigned char **)&packet, &pts);
if (len <= 0) return -1;
+ if (sh->pts == MP_NOPTS_VALUE)
+ sh->pts = 0;
+ if (pts != MP_NOPTS_VALUE) {
+ sh->pts = pts;
+ sh->pts_bytes = 0;
+ }
speex_bits_read_from(&ctx->bits, packet, len);
i = ctx->hdr->frames_per_packet;
do {
@@ -162,6 +169,7 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf,
speex_decode_stereo_int((short *)buf, framesamples, &ctx->stereo);
buf = &buf[framelen];
} while (--i > 0);
+ sh->pts_bytes += ctx->hdr->frames_per_packet * framelen;
return ctx->hdr->frames_per_packet * framelen;
}