]> git.sesse.net Git - vlc/commitdiff
avcodec: use VLC_TS_INVALID and CLOCK_FREQ on encoding
authorIlkka Ollakka <ileoo@videolan.org>
Tue, 27 May 2014 17:07:01 +0000 (20:07 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Tue, 15 Jul 2014 13:07:19 +0000 (16:07 +0300)
modules/codec/avcodec/encoder.c

index b35c9fca3842a86e3cc59e35f6d9363199e2b94c..9b93278b342116c39ab0448bb75412de14507e1a 100644 (file)
@@ -1068,7 +1068,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
         frame->top_field_first = !!p_pict->b_top_field_first;
 
         /* Set the pts of the frame being encoded */
-        frame->pts = p_pict->date ? p_pict->date : AV_NOPTS_VALUE;
+        frame->pts = (p_pict->date == VLC_TS_INVALID) ? AV_NOPTS_VALUE : p_pict->date;
 
         if ( p_sys->b_hurry_up && frame->pts != AV_NOPTS_VALUE )
         {
@@ -1107,7 +1107,7 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
             }
         }
 
-        if ( frame->pts != AV_NOPTS_VALUE && frame->pts != 0 )
+        if ( ( frame->pts != AV_NOPTS_VALUE ) && ( frame->pts != VLC_TS_INVALID ) )
         {
             if ( p_sys->i_last_pts == frame->pts )
             {
@@ -1193,7 +1193,7 @@ static block_t *encode_audio_buffer( encoder_t *p_enc, encoder_sys_t *p_sys,  AV
     }
     p_block->i_buffer = packet.size;
 
-    p_block->i_length = (mtime_t)1000000 *
+    p_block->i_length = (mtime_t)CLOCK_FREQ *
      (mtime_t)p_sys->i_frame_size /
      (mtime_t)p_sys->p_context->sample_rate;