[vlc-commits] commit: x264: use libx264 with 0-started pts values and scale them back ( Ilkka Ollakka )

git at videolan.org git at videolan.org
Sun Jun 13 22:36:18 CEST 2010


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Sun Jun 13 15:23:23 2010 +0300| [2fffa228eaec9b00cd968d22a2834444fc3e4573] | committer: Ilkka Ollakka 

x264: use libx264 with 0-started pts values and scale them back

I'm not really sure why libx264 sometimes gives negative dts even if
given pts values are >> 0. So until I see why, I think this way works better

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2fffa228eaec9b00cd968d22a2834444fc3e4573
---

 modules/codec/x264.c |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/modules/codec/x264.c b/modules/codec/x264.c
index ab3c623..f96c221 100644
--- a/modules/codec/x264.c
+++ b/modules/codec/x264.c
@@ -699,9 +699,9 @@ struct encoder_sys_t
     x264_t          *h;
     x264_param_t    param;
 
-    int64_t  i_initial_delay;
+    mtime_t         i_initial_delay;
 
-    char *psz_stat_name;
+    char            *psz_stat_name;
 };
 
 #ifdef PTW32_STATIC_LIB
@@ -1276,6 +1276,12 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict )
 #endif
     if( likely(p_pict) ) {
        pic.i_pts = p_pict->date;
+       /* scale pts starting from 0 as libx264 seems to return dts values
+          assume that
+        */
+       if( unlikely( p_sys->i_initial_delay == 0 ) )
+           p_sys->i_initial_delay = p_pict->date;
+       pic.i_pts -= p_sys->i_initial_delay;
        pic.img.i_csp = X264_CSP_I420;
        pic.img.i_plane = p_pict->i_planes;
        for( i = 0; i < p_pict->i_planes; i++ )
@@ -1322,16 +1328,7 @@ static block_t *Encode( encoder_t *p_enc, picture_t *p_pict )
         p_enc->fmt_in.video.i_frame_rate_base /
             p_enc->fmt_in.video.i_frame_rate;
 
-    /* libx264 gives pts/dts values from >= 83 onward,
-     * also pts starts from 0 so dts can be negative,
-     * but vlc doesn't handle if dts is < VLC_TS_0 so we
-     * use that offset to get it right for vlc.
-     */
-    if( p_sys->i_initial_delay == 0 && pic.i_dts < VLC_TS_0 )
-    {
-        p_sys->i_initial_delay = -1* pic.i_dts;
-        msg_Dbg( p_enc, "Initial delay is set to %d", p_sys->i_initial_delay );
-    }
+    /* scale pts-values back*/
     p_block->i_pts = pic.i_pts + p_sys->i_initial_delay;
     p_block->i_dts = pic.i_dts + p_sys->i_initial_delay;
 



More information about the vlc-commits mailing list