[vlc-commits] [Git][videolan/vlc][3.0.x] 17 commits: Revert "mpeg4video: add early check on zero i_fps_num"
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Sep 1 14:10:48 UTC 2026
Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC
Commits:
82ad11bc by Steve Lhomme at 2026-09-01T13:47:28+00:00
Revert "mpeg4video: add early check on zero i_fps_num"
This reverts commit 7bbeddd4da3defa32cfbebfa3a0e5e312fda64c0.
Before this patch the code could (almost) reach the end normally.
- - - - -
e5216550 by Romain Vimont at 2026-09-01T13:47:28+00:00
core: replace decoder_sys_t* by void*
See #17078
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit b3b7f62ce15a3faae7a7c78c2d10b4bb49a6a009) (edited)
edited:
- only for mpeg4video.c
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
6a49a8d8 by Steve Lhomme at 2026-09-01T13:47:28+00:00
packetizer:mpeg4video: internal times are not mtime_t
(cherry picked from commit 3dd2140c7e0c2189b5d30b9092a99907bd9dab3c) (edited)
edited:
- VLC 3 switched to vlc_tick_t (3f9fc44176cc5505132977885799fa988c5e7701)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
aa67dc8f by François Cartegnie at 2026-09-01T13:47:28+00:00
packetizer: mpeg4video: update debug code
(cherry picked from commit f3a5cee5448e789a0b5437b0deb6c15b789cb33c)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
4c39ae2e by François Cartegnie at 2026-09-01T13:47:28+00:00
packetizer: mpeg4video: workaround missing modulo_time_base
(cherry picked from commit bc243c4db9d32bcc6d2af35f06d14880c738d79b)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
5b6403c8 by François Cartegnie at 2026-09-01T13:47:28+00:00
packetizer: mpeg4video: remove unused members
(cherry picked from commit eb028e98fe9cb8e45e9c38c0eaaa84e6757165bd)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
2eed9b23 by Steve Lhomme at 2026-09-01T13:47:28+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.
(cherry picked from commit 84ba3883abfa350a54cce10f1472d55ca421187e) (rebased)
rebased:
- the code around is slightly different
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
e88865d0 by Steve Lhomme at 2026-09-01T13:47:28+00:00
mpeg4video: restrict the size of time increments
It is read from 1 to 32 bits.
(cherry picked from commit 774a5ce992c660053337c77b6671abfb0d58836c)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
f868f5fb by Steve Lhomme at 2026-09-01T13:47:28+00:00
mpeg4video: make i_modulo_time_base uint64_t
It's always increment with positive values, up to 64 bits.
(cherry picked from commit 8e6fc030bd650ce56c616e0cd220d1e777266bd0) (rebased)
rebased:
- the code around is slightly different
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
aa0a621a by Steve Lhomme at 2026-09-01T13:47:28+00:00
mpeg4video: remove write-only i_fps_den
(cherry picked from commit 1c98cce82b5d84da96ff1146692ebe4dbc71cfef)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
d949f3f2 by Steve Lhomme at 2026-09-01T13:47:28+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.
(cherry picked from commit 3f8e4cd904477dbf21fd265bf016d9539ad508d7)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
ccb5ee70 by Steve Lhomme at 2026-09-01T13:47:28+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.
(cherry picked from commit c457861c404b078971e642a637b00677cf46bb32)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
c297912d by Steve Lhomme at 2026-09-01T13:47:28+00:00
mpeg4video: restrict the size of i_fps_num
i_fps_num is read from 16 bits.
(cherry picked from commit 1642302f9092b52e072ab615233d5d652b141636)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
556cf6a7 by Steve Lhomme at 2026-09-01T13:47:28+00:00
packetizer: mpeg4video: refactor i_fps_num testing
i_time_diff is only computed if it's going to be used.
And it's always when i_fps_num is not 0.
(cherry picked from commit 42a669afe37c4293bc5a3c23a87128403c114a4b) (rebased)
rebased:
- VLC 3 doesn't have vlc_tick_from_samples()
- VLC 3 doesn't use a pointer for p_dec->fmt_in
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
33a6af5b by Steve Lhomme at 2026-09-01T13:47:28+00:00
packetizer: mpeg4video: only compute i_time_increment when i_fps_num is not 0
It's uninitialized otherwise. And it's not used anyway in that case.
We don't store it in i_last_timeincr either when it's not set. The initial
value 0 until a valid (non zero) i_fps_num is set.
Fixes #29756
(cherry picked from commit 9b2eeb8cd5565ac78ad0e673d7455dd6cafaea96)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
653b801c by Steve Lhomme at 2026-09-01T13:47:28+00:00
packetizer: mpeg4video: remove always true test
i_fps_num is unsigned, so if it's not smaller than 5, it's a least 5.
(cherry picked from commit c2519c8e9d3239479e6cb140a938c5a479c41a28) (rebased)
rebased:
- VLC 3 doesn't have vlc_tick_from_samples()
- VLC 3 doesn't use a pointer for p_dec->fmt_in
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
afa94d7d by Steve Lhomme at 2026-09-01T13:47:28+00:00
packetizer: mpeg4video: add reference to the spec
(cherry picked from commit 30d249bf511fd9c2a6168866175fe3c8a6f89b1d)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>
- - - - -
1 changed file:
- modules/packetizer/mpeg4video.c
Changes:
=====================================
modules/packetizer/mpeg4video.c
=====================================
@@ -73,17 +73,14 @@ struct decoder_sys_t
vlc_tick_t i_interpolated_pts;
vlc_tick_t i_interpolated_dts;
vlc_tick_t i_last_ref_pts;
- vlc_tick_t i_last_time_ref;
- vlc_tick_t i_time_ref;
- vlc_tick_t i_last_time;
- vlc_tick_t i_last_timeincr;
+ uint64_t i_last_time_ref;
+ uint64_t i_time_ref;
+ int64_t i_last_time;
+ uint32_t i_last_timeincr;
unsigned int i_flags;
- int i_fps_num;
- int i_fps_den;
- int i_last_incr;
- int i_last_incr_diff;
+ uint16_t i_fps_num;
bool b_frame;
@@ -103,7 +100,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
@@ -345,6 +342,9 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
p_pic->i_pts = p_sys->i_interpolated_pts;
p_pic->i_dts = p_sys->i_interpolated_dts;
+#if 0
+ msg_Err( p_dec, "output dts/pts (%"PRId64",%"PRId64")", p_pic->i_dts, p_pic->i_pts );
+#endif
/* Reset context */
p_sys->p_frame = NULL;
p_sys->pp_last = &p_sys->p_frame;
@@ -427,11 +427,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;
-
- 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;
- 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 )
{
@@ -487,13 +485,11 @@ 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 )
- return VLC_EGENERIC;
-
bs_init( &s, &p_vop->p_buffer[4], p_vop->i_buffer - 4 );
switch( bs_read( &s, 2 ) )
@@ -508,7 +504,7 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
p_sys->i_flags = BLOCK_FLAG_TYPE_B;
p_sys->b_frame = true;
break;
- case 3: /* gni ? */
+ case 3: /* Sprite : ISO 14496-2 § 6.3.5 */
p_sys->i_flags = BLOCK_FLAG_TYPE_PB;
break;
}
@@ -516,32 +512,38 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
while( bs_read( &s, 1 ) ) i_modulo_time_base++;
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;
- if( i_time_increment_bits < 1 ) i_time_increment_bits = 1;
- i_time_increment = bs_read( &s, i_time_increment_bits );
-
/* Interpolate PTS/DTS */
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);
+ (i_modulo_time_base * p_sys->i_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_sys->i_fps_num);
}
-#if 0
- msg_Err( p_dec, "interp pts/dts (%lli,%lli), pts/dts (%lli,%lli)",
- p_sys->i_interpolated_pts, p_sys->i_interpolated_dts,
- p_vop->i_pts, p_vop->i_dts );
-#endif
+ if( p_sys->i_fps_num )
+ {
+ /* VOP time increment */
+ unsigned i_time_increment_bits = vlc_log2(p_sys->i_fps_num - 1) + 1;
+ i_time_increment = bs_read( &s, i_time_increment_bits );
- if( p_dec->p_sys->i_fps_num < 5 && /* Work-around buggy streams */
+ int64_t i_time_diff = (i_time_ref + i_time_increment) - (p_sys->i_last_time + p_sys->i_last_timeincr);
+ if( i_modulo_time_base == 0 && i_time_diff < 0 && -i_time_diff > p_sys->i_fps_num )
+ {
+ msg_Warn(p_dec, "missing modulo_time_base update");
+ i_modulo_time_base += -i_time_diff / p_sys->i_fps_num;
+ p_sys->i_time_ref += (i_modulo_time_base * p_sys->i_fps_num);
+ p_sys->i_time_ref += p_sys->i_last_timeincr % p_sys->i_fps_num;
+ i_time_ref = p_sys->i_time_ref;
+ }
+ }
+
+ if( p_sys->i_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 )
{
@@ -550,13 +552,20 @@ static int ParseVOP( decoder_t *p_dec, block_t *p_vop )
p_dec->fmt_in.video.i_frame_rate;
}
else
- 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 );
+ {
+ int64_t i_time_diff = (i_time_ref + i_time_increment) - (p_sys->i_last_time + p_sys->i_last_timeincr);
+ p_sys->i_interpolated_pts += ( CLOCK_FREQ * i_time_diff / p_sys->i_fps_num );
+ }
+
+#if 0
+ msg_Err( p_dec, "interp dts/pts (%"PRId64",%"PRId64"), dts/pts (%"PRId64",%"PRId64") %"PRId64" mod %d inc %"PRId64,
+ p_sys->i_interpolated_dts, p_sys->i_interpolated_pts,
+ p_vop->i_dts, p_vop->i_pts, p_sys->i_time_ref, i_modulo_time_base, i_time_increment );
+#endif
p_sys->i_last_time = i_time_ref;
- p_sys->i_last_timeincr = i_time_increment;
+ if( p_sys->i_fps_num )
+ p_sys->i_last_timeincr = i_time_increment;
/* Correct interpolated dts when we receive a new pts/dts */
if( p_vop->i_pts > VLC_TICK_INVALID )
@@ -589,10 +598,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/56dfd169bf5bcedf344d808faf9bd2ce523ef6c6...afa94d7d61005e634aaa70963beffb527ed44b27
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/56dfd169bf5bcedf344d808faf9bd2ce523ef6c6...afa94d7d61005e634aaa70963beffb527ed44b27
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