[vlc-commits] [Git][videolan/vlc][master] 7 commits: mpeg4video: make vlc_log2() unsigned
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Aug 4 06:22:08 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
84ba3883 by Steve Lhomme at 2026-08-04T05:55:21+00:00
mpeg4video: make vlc_log2() unsigned
We start from 0 and potential add 16+8+4+3.
The result + 1 can never be smaller than 1.
- - - - -
774a5ce9 by Steve Lhomme at 2026-08-04T05:55:21+00:00
mpeg4video: restrict the size of time increments
It is read from 1 to 32 bits.
- - - - -
8e6fc030 by Steve Lhomme at 2026-08-04T05:55:21+00:00
mpeg4video: make i_modulo_time_base uint64_t
It's always increment with positive values, up to 64 bits.
- - - - -
1c98cce8 by Steve Lhomme at 2026-08-04T05:55:21+00:00
mpeg4video: remove write-only i_fps_den
- - - - -
3f8e4cd9 by Steve Lhomme at 2026-08-04T05:55:21+00:00
mpeg4video: make i_fps_num unsigned
It's read from 16 bits as unsigned and can never be 0 when it's read.
- - - - -
c457861c by Steve Lhomme at 2026-08-04T05:55:21+00:00
mpeg4video: make i_time_ref/i_last_time_ref unsigned
It's always the result of i_modulo_time_base, i_fps_num and i_last_timeincr
which are all unsigned.
- - - - -
1642302f by Steve Lhomme at 2026-08-04T05:55:21+00:00
mpeg4video: restrict the size of i_fps_num
i_fps_num is read from 16 bits.
- - - - -
1 changed file:
- modules/packetizer/mpeg4video.c
Changes:
=====================================
modules/packetizer/mpeg4video.c
=====================================
@@ -71,15 +71,14 @@ typedef struct
vlc_tick_t i_interpolated_pts;
vlc_tick_t i_interpolated_dts;
vlc_tick_t i_last_ref_pts;
- int64_t i_last_time_ref;
- int64_t i_time_ref;
+ uint64_t i_last_time_ref;
+ uint64_t i_time_ref;
int64_t i_last_time;
- int64_t i_last_timeincr;
+ uint32_t i_last_timeincr;
unsigned int i_flags;
- int i_fps_num;
- int i_fps_den;
+ uint16_t i_fps_num;
bool b_frame;
@@ -99,7 +98,7 @@ static block_t *ParseMPEGBlock( decoder_t *, block_t * );
static int ParseVOL( decoder_t *, es_format_t *, uint8_t *, int );
static int ParseVO( decoder_t *, block_t * );
static int ParseVOP( decoder_t *, block_t * );
-static int vlc_log2( unsigned int );
+static unsigned vlc_log2( unsigned int );
#define VIDEO_OBJECT_MASK 0x01f
#define VIDEO_OBJECT_LAYER_MASK 0x00f
@@ -438,11 +437,9 @@ static int ParseVOL( decoder_t *p_dec, es_format_t *fmt,
if( bs_read1( &s ) )
{
- int i_time_increment_bits = vlc_log2( p_sys->i_fps_num - 1 ) + 1;
+ unsigned i_time_increment_bits = vlc_log2( p_sys->i_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 );
+ bs_skip( &s, i_time_increment_bits ); /* i_fps_den */
}
if( i_shape == 0 )
{
@@ -502,8 +499,9 @@ static int ParseVO( decoder_t *p_dec, block_t *p_vo )
static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
{
decoder_sys_t *p_sys = p_dec->p_sys;
- int64_t i_time_increment, i_time_ref;
- int i_modulo_time_base = 0, i_time_increment_bits;
+ uint64_t i_time_ref;
+ uint32_t i_time_increment;
+ uint64_t i_modulo_time_base = 0;
bs_t s;
if( p_sys->i_fps_num == 0 )
@@ -532,8 +530,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_sys->i_fps_num - 1) + 1;
- if( i_time_increment_bits < 1 ) i_time_increment_bits = 1;
+ unsigned i_time_increment_bits = vlc_log2(p_sys->i_fps_num - 1) + 1;
i_time_increment = bs_read( &s, i_time_increment_bits );
/* Interpolate PTS/DTS */
@@ -614,10 +611,10 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
}
/* look at libavutil av_log2 ;) */
-static int vlc_log2( unsigned int v )
+static unsigned vlc_log2( unsigned int v )
{
- int n = 0;
- static const int vlc_log2_table[16] =
+ unsigned n = 0;
+ static const unsigned vlc_log2_table[16] =
{
0,0,1,1,2,2,2,2, 3,3,3,3,3,3,3,3
};
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2601ab775855f20bb6ce5a097b7805742ca1139f...1642302f9092b52e072ab615233d5d652b141636
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2601ab775855f20bb6ce5a097b7805742ca1139f...1642302f9092b52e072ab615233d5d652b141636
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list