diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-01-23 00:52:10 +0000 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-01-23 00:52:10 +0000 |
commit | 2f9b558e6ff6f599e4e6ef3422f48b17c44f178b (patch) | |
tree | edc508f1fbc1212a588b89d3bacbfe4acf8ca3e9 /src | |
parent | 0ca390809880469773d630963249a550ec3fa523 (diff) | |
parent | a5203938aa08ae901dc0383848afe13272d345d6 (diff) | |
download | xine-lib-2f9b558e6ff6f599e4e6ef3422f48b17c44f178b.tar.gz xine-lib-2f9b558e6ff6f599e4e6ef3422f48b17c44f178b.tar.bz2 |
Merge from 1.1.
--HG--
rename : src/libmad/xine_mad_decoder.c => src/audio_dec/xine_mad_decoder.c
Diffstat (limited to 'src')
-rw-r--r-- | src/audio_dec/xine_mad_decoder.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/audio_dec/xine_mad_decoder.c b/src/audio_dec/xine_mad_decoder.c index cf5f026d0..74c04924f 100644 --- a/src/audio_dec/xine_mad_decoder.c +++ b/src/audio_dec/xine_mad_decoder.c @@ -149,6 +149,7 @@ static int head_check(mad_decoder_t *this) { static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { mad_decoder_t *this = (mad_decoder_t *) this_gen; + int bytes_in_buffer_at_pts; lprintf ("decode data, size: %d, decoder_flags: %d\n", buf->size, buf->decoder_flags); @@ -170,6 +171,8 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->preview_mode = 1; } + bytes_in_buffer_at_pts = this->bytes_in_buffer; + xine_fast_memcpy (&this->buffer[this->bytes_in_buffer], buf->content, buf->size); this->bytes_in_buffer += buf->size; @@ -271,6 +274,8 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { struct mad_pcm *pcm = &this->synth.pcm; audio_buffer_t *audio_buffer; uint16_t *output; + int bitrate; + int pts_offset; audio_buffer = this->xstream->audio_out->get_buffer (this->xstream->audio_out); output = audio_buffer->mem; @@ -291,7 +296,22 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } audio_buffer->num_frames = pcm->length; - audio_buffer->vpts = buf->pts; + + /* pts computing */ + if (this->frame.header.bitrate > 0) { + bitrate = this->frame.header.bitrate; + } else { + bitrate = _x_stream_info_get(this->xstream, XINE_STREAM_INFO_AUDIO_BITRATE); + lprintf("offset %d bps\n", bitrate); + } + audio_buffer->vpts = buf->pts; + if (audio_buffer->vpts && (bitrate > 0)) { + pts_offset = (bytes_in_buffer_at_pts * 8 * 90) / (bitrate / 1000); + lprintf("pts: %"PRId64", offset: %d pts, %d bytes\n", buf->pts, pts_offset, bytes_in_buffer_at_pts); + if (audio_buffer->vpts < pts_offset) + pts_offset = audio_buffer->vpts; + audio_buffer->vpts -= pts_offset; + } this->xstream->audio_out->put_buffer (this->xstream->audio_out, audio_buffer, this->xstream); |