[vlc-commits] [Git][videolan/vlc][3.0.x] 10 commits: demux:asf: the preroll start is in mtime_t
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Feb 22 07:52:02 UTC 2025
Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC
Commits:
3341555e by Steve Lhomme at 2025-02-22T07:15:36+00:00
demux:asf: the preroll start is in mtime_t
(cherry picked from commit 96d5784c855aa3ab52446453472d9654c0086c84)
- - - - -
fa5ecdd0 by Steve Lhomme at 2025-02-22T07:15:36+00:00
rename mtime_t to vlc_tick_t
Keep a copy of vlc_tick_tfor backward compatibility.
- - - - -
5ef2ed12 by Steve Lhomme at 2025-02-22T07:15:36+00:00
vlc_tick: add helper macros to convert milliseconds to/from vlc_tick_t
(cherry picked from commit 505182d874273dcbfdc10184f450469ee63a96df) (edited)
edited:
- the header is still called vlc_mtime.h in 3.0
- - - - -
eb9e6c0e by Steve Lhomme at 2025-02-22T07:15:36+00:00
demux:asf: remove write-only i_extension_pts
(cherry picked from commit c3fbff8aa4e313d8dc6af645f216c949e88dcd26) (rebased)
rebased:
- i_payload_pts is already a vlc_tick_t on 3.0 since 3f9fc44176cc5505132977885799fa988c5e7701
- - - - -
66c2e24f by Steve Lhomme at 2025-02-22T07:15:36+00:00
demux:asf: store the send_time as an vlc_tick_t rather than milliseconds
Divide all the uses by 1000 for now
(cherry picked from commit cac66afe7f52899bb6b6c7b1f615a6c752bf7e49) (rebased)
rebased:
- the code around is slightly different
- - - - -
44202c22 by Steve Lhomme at 2025-02-22T07:15:36+00:00
demux:asf: fix the i_preroll_start substracting milliseconds from an mtime
store the preroll in vlc_tick_t instead of milliseconds
Divide all uses by 1000 for now
SeekIndex was using the value in milliseconds substracted from the vlc_tick_t date.
(cherry picked from commit 120e2cb800da292077e80dc790f323b901a13ff2) (rebased)
rebased:
- 3.0 doesn't use msftime_t
- - - - -
1de0d6f8 by Steve Lhomme at 2025-02-22T07:15:36+00:00
demux:asf: handle the i_pkt_time_delta in vlc_tick_t instead of milliseconds
(cherry picked from commit 7d05ad592d0fc5a006c4bb3b7fcfe4402e3d7e43) (rebased)
rebased:
- 3.0 doesn't use VLC_TICK_FROM_MSFTIME
- - - - -
739a486c by Steve Lhomme at 2025-02-22T07:15:36+00:00
demux:asf: process the i_pkt_time in vlc_tick_t instead of milliseconds
(cherry picked from commit fe73d59ce50b98fa7256115de834538389299c52)
- - - - -
e701467d by Zhao Zhili at 2025-02-22T07:15:36+00:00
demux: asf: fix log format string
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
(cherry picked from commit 1438d0767c842812e502635c320cad4bd178ef62)
- - - - -
6895dc7f by Rémi Denis-Courmont at 2025-02-22T07:15:36+00:00
asf: improve log message
Peeking is an irrelevant implementation detail here.
(cherry picked from commit 788007c8f6a462376a5d9603f78dea3da20881d9)
- - - - -
7 changed files:
- include/vlc_mtime.h
- modules/demux/asf/asf.c
- modules/demux/asf/asfpacket.c
- modules/demux/asf/asfpacket.h
- modules/demux/asf/libasf.c
- modules/demux/asf/libasf.h
- modules/demux/mp4/mp4.c
Changes:
=====================================
include/vlc_mtime.h
=====================================
@@ -42,6 +42,20 @@
*****************************************************************************/
#define LAST_MDATE ((vlc_tick_t)((uint64_t)(-1)/2))
+/*
+ * vlc_tick_t <> milliseconds (ms) conversions
+ */
+#if (CLOCK_FREQ % 1000) == 0
+#define VLC_TICK_FROM_MS(ms) ((CLOCK_FREQ / INT64_C(1000)) * (ms))
+#define MS_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(1000)))
+#elif (1000 % CLOCK_FREQ) == 0
+#define VLC_TICK_FROM_MS(ms) ((ms) / (INT64_C(1000) / CLOCK_FREQ))
+#define MS_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000) / CLOCK_FREQ))
+#else /* rounded overflowing conversion */
+#define VLC_TICK_FROM_MS(ms) (CLOCK_FREQ * (ms) / 1000)
+#define MS_FROM_VLC_TICK(vtk) ((vtk) * 1000 / CLOCK_FREQ)
+#endif /* CLOCK_FREQ / 1000 */
+
/*****************************************************************************
* MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
*****************************************************************************
=====================================
modules/demux/asf/asf.c
=====================================
@@ -214,8 +214,8 @@ static int Demux( demux_t *p_demux )
}
while( !p_sys->b_eos && ( p_sys->i_sendtime - p_sys->i_time - CHUNK < 0 ||
- ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
- UINT64_C( 1000 ) < p_sys->p_fp->i_preroll ) )
+ ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) <
+ p_sys->p_fp->i_preroll ) )
{
/* Read and demux a packet */
if( DemuxASFPacket( &p_sys->packet_sys,
@@ -252,8 +252,8 @@ static int Demux( demux_t *p_demux )
}
if( p_sys->b_eos || ( p_sys->i_sendtime - p_sys->i_time - CHUNK >= 0 &&
- ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) /
- UINT64_C( 1000 ) >= p_sys->p_fp->i_preroll ) )
+ ( p_sys->i_sendtime - p_sys->i_time - CHUNK ) >=
+ p_sys->p_fp->i_preroll ) )
{
bool b_data = Block_Dequeue( p_demux, p_sys->i_time + CHUNK );
@@ -379,7 +379,7 @@ static int SeekIndex( demux_t *p_demux, vlc_tick_t i_date, float f_pos )
if( i_date < 0 )
i_date = p_sys->i_length * f_pos;
- p_sys->i_preroll_start = i_date - (int64_t) p_sys->p_fp->i_preroll;
+ p_sys->i_preroll_start = i_date - p_sys->p_fp->i_preroll;
if ( p_sys->i_preroll_start < 0 ) p_sys->i_preroll_start = 0;
p_index = ASF_FindObject( p_sys->p_root, &asf_object_simple_index_guid, 0 );
@@ -1256,7 +1256,7 @@ static int DemuxInit( demux_t *p_demux )
/* calculate the time duration in micro-s */
p_sys->i_length = (vlc_tick_t)p_sys->p_fp->i_play_duration / 10 *
(vlc_tick_t)i_count /
- (vlc_tick_t)p_sys->p_fp->i_data_packets_count - p_sys->p_fp->i_preroll * 1000;
+ (vlc_tick_t)p_sys->p_fp->i_data_packets_count - p_sys->p_fp->i_preroll;
if( p_sys->i_length < 0 )
p_sys->i_length = 0;
=====================================
modules/demux/asf/asfpacket.c
=====================================
@@ -35,7 +35,7 @@ typedef struct asf_packet_t
uint32_t property;
uint32_t length;
uint32_t padding_length;
- uint32_t send_time;
+ vlc_tick_t send_time;
bool multiple;
int length_type;
@@ -106,8 +106,7 @@ static int DemuxSubPayload( asf_packet_sys_t *p_packetsys,
static void ParsePayloadExtensions( asf_packet_sys_t *p_packetsys,
const asf_track_info_t *p_tkinfo,
const uint8_t *p_data, size_t i_data,
- bool *b_keyframe,
- int64_t *pi_extension_pts )
+ bool *b_keyframe )
{
demux_t *p_demux = p_packetsys->p_demux;
@@ -166,9 +165,7 @@ static void ParsePayloadExtensions( asf_packet_sys_t *p_packetsys,
else if ( guidcmp( &p_ext->i_extension_id, &asf_dvr_sampleextension_timing_rep_data_guid ) )
{
if ( i_payload_extensions_size != 48 ) goto sizeerror;
- const int64_t i_pts = GetQWLE(&p_data[8]);
- if(i_pts != -1)
- *pi_extension_pts = i_pts / 10000;
+ /* const int64_t i_pts = GetQWLE(&p_data[8]); */
}
#if 0
else
@@ -210,16 +207,15 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
if (GetValue2b(&i_replicated_data_length, pkt->p_peek, &pkt->i_skip, pkt->left - pkt->i_skip, pkt->property) < 0)
return -1;
- int64_t i_pkt_time;
- uint8_t i_pkt_time_delta = 0;
- int64_t i_extension_pts = -1;
+ vlc_tick_t i_pkt_time;
+ vlc_tick_t i_pkt_time_delta = 0;
uint32_t i_payload_data_length = 0;
uint32_t i_temp_payload_length = 0;
*p_packetsys->pi_preroll = __MIN( *p_packetsys->pi_preroll, INT64_MAX );
/* First packet, in case we do not have index to guess preroll start time */
if ( *p_packetsys->pi_preroll_start == ASFPACKET_PREROLL_FROM_CURRENT )
- *p_packetsys->pi_preroll_start = pkt->send_time * 1000;
+ *p_packetsys->pi_preroll_start = pkt->send_time;
asf_track_info_t *p_tkinfo = p_packetsys->pf_gettrackinfo( p_packetsys, i_stream_number );
if ( !p_tkinfo )
@@ -234,32 +230,29 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
if( i_replicated_data_length > 7 ) // should be at least 8 bytes
{
/* Followed by 2 optional DWORDS, offset in media and *media* presentation time */
- i_pkt_time = (vlc_tick_t)GetDWLE( pkt->p_peek + pkt->i_skip + 4 );
+ i_pkt_time = VLC_TICK_FROM_MS(GetDWLE( pkt->p_peek + pkt->i_skip + 4 ));
/* Parsing extensions, See 7.3.1 */
ParsePayloadExtensions( p_packetsys, p_tkinfo,
&pkt->p_peek[pkt->i_skip + 8],
i_replicated_data_length - 8,
- &b_packet_keyframe,
- &i_extension_pts );
+ &b_packet_keyframe );
i_pkt_time -= *p_packetsys->pi_preroll;
- if(i_extension_pts != -1)
- i_extension_pts -= *p_packetsys->pi_preroll;
pkt->i_skip += i_replicated_data_length;
}
else if ( i_replicated_data_length == 0 )
{
/* optional DWORDS missing */
- i_pkt_time = (vlc_tick_t)pkt->send_time;
+ i_pkt_time = pkt->send_time;
}
/* Compressed payload */
else if( i_replicated_data_length == 1 )
{
/* i_media_object_offset is *media* presentation time */
/* Next byte is *media* Presentation Time Delta */
- i_pkt_time_delta = pkt->p_peek[pkt->i_skip];
+ i_pkt_time_delta = VLC_TICK_FROM_MS(pkt->p_peek[pkt->i_skip]);
b_ignore_pts = false;
- i_pkt_time = (vlc_tick_t)i_media_object_offset;
+ i_pkt_time = VLC_TICK_FROM_MS(i_media_object_offset);
i_pkt_time -= *p_packetsys->pi_preroll;
pkt->i_skip++;
i_media_object_offset = 0;
@@ -278,10 +271,9 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
if( ! pkt->left || pkt->i_skip >= pkt->left )
return -1;
- bool b_preroll_done = ( pkt->send_time > (*p_packetsys->pi_preroll_start/1000 + *p_packetsys->pi_preroll) );
+ bool b_preroll_done = ( pkt->send_time > (*p_packetsys->pi_preroll_start + *p_packetsys->pi_preroll) );
if (i_pkt_time < 0) i_pkt_time = 0; // FIXME?
- i_pkt_time *= 1000;
if( pkt->multiple ) {
if (GetValue2b(&i_temp_payload_length, pkt->p_peek, &pkt->i_skip, pkt->left - pkt->i_skip, pkt->length_type) < 0)
@@ -302,8 +294,8 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
i_payload + 1, i_stream_number, i_media_object_number,
i_media_object_offset, i_replicated_data_length, i_payload_data_length );
msg_Dbg( p_demux,
- " extpts=%"PRId64" pkttime=%"PRId64" st=%"PRIu32,
- (i_extension_pts >= 0) ? i_extension_pts * 1000 : -1, i_pkt_time, pkt->send_time );
+ " pkttime=%"PRId64" st=%"PRId64,
+ i_pkt_time, MS_FROM_VLC_TICK(pkt->send_time) );
#endif
if( ! i_payload_data_length || i_payload_data_length > pkt->left )
@@ -325,7 +317,7 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
}
if( p_packetsys->pf_updatesendtime )
- p_packetsys->pf_updatesendtime( p_packetsys, INT64_C(1000) * pkt->send_time );
+ p_packetsys->pf_updatesendtime( p_packetsys, pkt->send_time );
uint32_t i_subpayload_count = 0;
while (i_payload_data_length && pkt->i_skip < pkt->left )
@@ -342,19 +334,9 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
SkipBytes( p_demux->s, pkt->i_skip );
vlc_tick_t i_payload_pts;
-#if 0
- if( i_extension_pts != -1 )
- {
- i_payload_pts = i_extension_pts * 1000;
- b_ignore_pts = false;
- }
- else
-#endif
- {
- i_payload_pts = i_pkt_time + (vlc_tick_t)i_pkt_time_delta * i_subpayload_count * 1000;
- if ( p_tkinfo->p_sp )
- i_payload_pts -= p_tkinfo->p_sp->i_time_offset * 10;
- }
+ i_payload_pts = i_pkt_time + i_pkt_time_delta * i_subpayload_count;
+ if ( p_tkinfo->p_sp )
+ i_payload_pts -= p_tkinfo->p_sp->i_time_offset * 10;
vlc_tick_t i_payload_dts = i_pkt_time;
@@ -377,8 +359,8 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
ssize_t i_return = vlc_stream_Peek( p_demux->s, &pkt->p_peek, pkt->left );
if ( i_return <= 0 || (size_t) i_return < pkt->left )
{
- msg_Warn( p_demux, "cannot peek, EOF ?" );
- return -1;
+ msg_Warn( p_demux, "unexpected end of file" );
+ return -1;
}
}
@@ -413,7 +395,7 @@ int DemuxASFPacket( asf_packet_sys_t *p_packetsys,
ssize_t i_return = vlc_stream_Peek( p_demux->s, &p_peek,i_data_packet_min );
if( i_return <= 0 || (size_t) i_return < i_data_packet_min )
{
- msg_Warn( p_demux, "cannot peek while getting new packet, EOF ?" );
+ msg_Warn( p_demux, "unexpected end of file" );
return 0;
}
unsigned int i_skip = 0;
@@ -474,7 +456,7 @@ int DemuxASFPacket( asf_packet_sys_t *p_packetsys,
if( i_skip + 4 > i_data_packet_min )
goto loop_error_recovery;
- pkt.send_time = GetDWLE( p_peek + i_skip ); i_skip += 4;
+ pkt.send_time = VLC_TICK_FROM_MS(GetDWLE( p_peek + i_skip )); i_skip += 4;
/* uint16_t i_packet_duration = GetWLE( p_peek + i_skip ); */ i_skip += 2;
if( i_data_end &&
@@ -489,7 +471,7 @@ int DemuxASFPacket( asf_packet_sys_t *p_packetsys,
i_return = vlc_stream_Peek( p_demux->s, &p_peek, pkt.length );
if( i_return <= 0 || pkt.length == 0 || (size_t)i_return < pkt.length )
{
- msg_Warn( p_demux, "cannot peek, EOF ?" );
+ msg_Warn( p_demux, "unexpected end of file" );
return 0;
}
=====================================
modules/demux/asf/asfpacket.h
=====================================
@@ -43,8 +43,8 @@ struct asf_packet_sys_s
demux_t *p_demux;
/* global stream info */
- uint64_t *pi_preroll;
- int64_t *pi_preroll_start;
+ vlc_tick_t *pi_preroll;
+ vlc_tick_t *pi_preroll_start;
/* callbacks */
void (*pf_send)(asf_packet_sys_t *, uint8_t, block_t **);
=====================================
modules/demux/asf/libasf.c
=====================================
@@ -323,7 +323,7 @@ static int ASF_ReadObject_file_properties( stream_t *s, asf_object_t *p_obj )
p_fp->i_data_packets_count = GetQWLE( p_peek + 56 );
p_fp->i_play_duration = GetQWLE( p_peek + 64 );
p_fp->i_send_duration = GetQWLE( p_peek + 72 );
- p_fp->i_preroll = GetQWLE( p_peek + 80 );
+ p_fp->i_preroll = VLC_TICK_FROM_MS(GetQWLE( p_peek + 80 ));
p_fp->i_flags = GetDWLE( p_peek + 88 );
p_fp->i_min_data_packet_size = __MAX( GetDWLE( p_peek + 92 ), (uint32_t) 1 );
p_fp->i_max_data_packet_size = __MAX( GetDWLE( p_peek + 96 ), (uint32_t) 1 );
@@ -339,7 +339,7 @@ static int ASF_ReadObject_file_properties( stream_t *s, asf_object_t *p_obj )
GUID_PRINT( p_fp->i_file_id ), p_fp->i_file_size,
p_fp->i_creation_date, p_fp->i_data_packets_count,
p_fp->i_play_duration, p_fp->i_send_duration,
- p_fp->i_preroll, p_fp->i_flags,
+ MS_FROM_VLC_TICK(p_fp->i_preroll), p_fp->i_flags,
p_fp->i_min_data_packet_size, p_fp->i_max_data_packet_size,
p_fp->i_max_bitrate );
#endif
=====================================
modules/demux/asf/libasf.h
=====================================
@@ -106,7 +106,7 @@ typedef struct
uint64_t i_data_packets_count;
uint64_t i_play_duration;
uint64_t i_send_duration;
- uint64_t i_preroll;
+ vlc_tick_t i_preroll;
uint32_t i_flags;
uint32_t i_min_data_packet_size;
uint32_t i_max_data_packet_size;
=====================================
modules/demux/mp4/mp4.c
=====================================
@@ -113,8 +113,8 @@ struct demux_sys_t
/* ASF in MP4 */
asf_packet_sys_t asfpacketsys;
- uint64_t i_preroll; /* foobar */
- int64_t i_preroll_start;
+ vlc_tick_t i_preroll; /* foobar */
+ vlc_tick_t i_preroll_start;
struct
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0c0430b699c05d26eb867ef78a4d37a17d5493e3...6895dc7f3d2e5e9d86da47107a81f72e8da0f619
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0c0430b699c05d26eb867ef78a4d37a17d5493e3...6895dc7f3d2e5e9d86da47107a81f72e8da0f619
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list