]> git.sesse.net Git - vlc/commitdiff
Fix the output pts; the code for doing so is smaller than the comment.
authorSteinar Gunderson <sgunderson@bigfoot.com>
Sun, 26 Sep 2010 00:24:28 +0000 (02:24 +0200)
committerSteinar Gunderson <sgunderson@bigfoot.com>
Sun, 26 Sep 2010 00:24:28 +0000 (02:24 +0200)
modules/codec/lpcm.c

index 908fb934fc663f04bbf72e9007ecb530a63de4bb..88eab2e85bdcefe7fa6f78eec846f72f81e77187 100644 (file)
@@ -493,6 +493,7 @@ static block_t *EncodeFrames( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
     const int i_leftover_samples = ( p_sys->i_buffer_used + p_aout_buf->i_nb_samples ) %
         p_sys->i_frame_samples;
     const int i_frame_size = p_sys->i_frame_samples * p_sys->i_channels * 2 + LPCM_VOB_HEADER_LEN;
+    const int i_start_offset = -p_sys->i_buffer_used;
 
     uint8_t i_freq_code = 0;
 
@@ -538,11 +539,8 @@ static block_t *EncodeFrames( encoder_t *p_enc, aout_buffer_t *p_aout_buf )
         p_sys->i_buffer_used = 0;
         i_bytes_consumed += i_consume_bytes;
 
-        /* 
-         * The pts is strictly not correct if we have samples kept from
-         * a previous buffer, but the frames are so small it should be OK.
-         */
-        p_block->i_dts = p_block->i_pts = p_aout_buf->i_pts + i * p_sys->i_frame_samples * CLOCK_FREQ / p_sys->i_rate;
+        p_block->i_dts = p_block->i_pts = p_aout_buf->i_pts +
+            (i * p_sys->i_frame_samples + i_start_offset) * CLOCK_FREQ / p_sys->i_rate;
         p_block->i_length = p_sys->i_frame_samples * CLOCK_FREQ / p_sys->i_rate;
     
         if( !p_first_block )