[vlc-devel] [PATCH 11/28] packetizer: mpeg4video: use vlc_rational_t internally

Steve Lhomme robux4 at videolabs.io
Fri Mar 31 18:14:26 CEST 2017


---
 modules/packetizer/mpeg4video.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/modules/packetizer/mpeg4video.c b/modules/packetizer/mpeg4video.c
index 6932660c30..9a9e8441a2 100644
--- a/modules/packetizer/mpeg4video.c
+++ b/modules/packetizer/mpeg4video.c
@@ -80,8 +80,7 @@ struct decoder_sys_t
 
     unsigned int i_flags;
 
-    int         i_fps_num;
-    int         i_fps_den;
+    vlc_rational_t fps;
     int         i_last_incr;
     int         i_last_incr_diff;
 
@@ -427,18 +426,18 @@ static int ParseVOL( decoder_t *p_dec, es_format_t *fmt,
 
     if( !bs_read1( &s ) ) return VLC_EGENERIC; /* Marker */
 
-    p_sys->i_fps_num = bs_read( &s, 16 ); /* Time increment resolution*/
-    if( !p_sys->i_fps_num ) p_sys->i_fps_num = 1;
+    p_sys->fps.num = bs_read( &s, 16 ); /* Time increment resolution*/
+    if( !p_sys->fps.num ) p_sys->fps.num = 1;
 
     if( !bs_read1( &s ) ) return VLC_EGENERIC; /* Marker */
 
     if( bs_read1( &s ) )
     {
-        int i_time_increment_bits = vlc_log2( p_sys->i_fps_num - 1 ) + 1;
+        int i_time_increment_bits = vlc_log2( p_sys->fps.num - 1 ) + 1;
 
         if( i_time_increment_bits < 1 ) i_time_increment_bits = 1;
 
-        p_sys->i_fps_den = bs_read( &s, i_time_increment_bits );
+        p_sys->fps.den = bs_read( &s, i_time_increment_bits );
     }
     if( i_shape == 0 )
     {
@@ -521,7 +520,7 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
     if( !bs_read1( &s ) ) return VLC_EGENERIC; /* Marker */
 
     /* VOP time increment */
-    i_time_increment_bits = vlc_log2(p_dec->p_sys->i_fps_num - 1) + 1;
+    i_time_increment_bits = vlc_log2(p_dec->p_sys->fps.num - 1) + 1;
     if( i_time_increment_bits < 1 ) i_time_increment_bits = 1;
     i_time_increment = bs_read( &s, i_time_increment_bits );
 
@@ -529,14 +528,13 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
     if( !(p_sys->i_flags & BLOCK_FLAG_TYPE_B) )
     {
         p_sys->i_last_time_ref = p_sys->i_time_ref;
-        p_sys->i_time_ref +=
-            (i_modulo_time_base * p_dec->p_sys->i_fps_num);
+        p_sys->i_time_ref += i_modulo_time_base * p_dec->p_sys->fps.num;
         i_time_ref = p_sys->i_time_ref;
     }
     else
     {
         i_time_ref = p_sys->i_last_time_ref +
-            (i_modulo_time_base * p_dec->p_sys->i_fps_num);
+            (i_modulo_time_base * p_dec->p_sys->fps.num);
     }
 
 #if 0
@@ -545,7 +543,7 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
              p_vop->i_pts, p_vop->i_dts );
 #endif
 
-    if( p_dec->p_sys->i_fps_num < 5 && /* Work-around buggy streams */
+    if( p_dec->p_sys->fps.num < 5 && /* Work-around buggy streams */
         p_dec->fmt_in.video.i_frame_rate > 0 &&
         p_dec->fmt_in.video.i_frame_rate_base > 0 )
     {
@@ -553,11 +551,11 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
         p_dec->fmt_in.video.i_frame_rate_base /
         p_dec->fmt_in.video.i_frame_rate;
     }
-    else if( p_dec->p_sys->i_fps_num )
+    else if( p_dec->p_sys->fps.num )
         p_sys->i_interpolated_pts +=
             ( CLOCK_FREQ * (i_time_ref + i_time_increment -
               p_sys->i_last_time - p_sys->i_last_timeincr) /
-              p_dec->p_sys->i_fps_num );
+              p_dec->p_sys->fps.num );
 
     p_sys->i_last_time = i_time_ref;
     p_sys->i_last_timeincr = i_time_increment;
-- 
2.11.1



More information about the vlc-devel mailing list