[vlc-devel] [PATCH 14/16] demux:asf: fix the i_preroll_start substracting milliseconds from an mtime
Steve Lhomme
robux4 at ycbcr.xyz
Thu Jun 7 11:59:58 CEST 2018
store the preroll in mtime_t instead of milliseconds
Divide all uses by 1000 for now
---
modules/demux/asf/asf.c | 14 +++++++-------
modules/demux/asf/asfpacket.c | 7 +++----
modules/demux/asf/asfpacket.h | 2 +-
modules/demux/asf/libasf.c | 2 +-
modules/demux/asf/libasf.h | 2 +-
modules/demux/mp4/mp4.c | 2 +-
6 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/modules/demux/asf/asf.c b/modules/demux/asf/asf.c
index 2454fb31cd..d8bed67f8e 100644
--- a/modules/demux/asf/asf.c
+++ b/modules/demux/asf/asf.c
@@ -213,8 +213,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,
@@ -242,8 +242,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 );
@@ -361,7 +361,7 @@ static int SeekIndex( demux_t *p_demux, mtime_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 );
@@ -1250,10 +1250,10 @@ static int DemuxInit( demux_t *p_demux )
p_sys->i_length = MSFTIME_TO_MTIME(p_sys->p_fp->i_play_duration) *
(mtime_t)i_count /
(mtime_t)p_sys->p_fp->i_data_packets_count;
- if( p_sys->i_length <= p_sys->p_fp->i_preroll * 1000 )
+ if( p_sys->i_length <= p_sys->p_fp->i_preroll )
p_sys->i_length = 0;
else
- p_sys->i_length -= p_sys->p_fp->i_preroll * 1000;
+ p_sys->i_length -= p_sys->p_fp->i_preroll;
if( p_sys->i_length != 0 )
{
diff --git a/modules/demux/asf/asfpacket.c b/modules/demux/asf/asfpacket.c
index a1ccae73d1..b80fc9bc3c 100644
--- a/modules/demux/asf/asfpacket.c
+++ b/modules/demux/asf/asfpacket.c
@@ -211,7 +211,6 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
uint8_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 )
@@ -237,7 +236,7 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
&pkt->p_peek[pkt->i_skip + 8],
i_replicated_data_length - 8,
&b_packet_keyframe );
- i_pkt_time -= *p_packetsys->pi_preroll;
+ i_pkt_time -= *p_packetsys->pi_preroll/1000;
pkt->i_skip += i_replicated_data_length;
}
else if ( i_replicated_data_length == 0 )
@@ -253,7 +252,7 @@ static int DemuxPayload(asf_packet_sys_t *p_packetsys, asf_packet_t *pkt, int i_
i_pkt_time_delta = pkt->p_peek[pkt->i_skip];
b_ignore_pts = false;
i_pkt_time = (mtime_t)i_media_object_offset;
- i_pkt_time -= *p_packetsys->pi_preroll;
+ i_pkt_time -= *p_packetsys->pi_preroll/1000;
pkt->i_skip++;
i_media_object_offset = 0;
}
@@ -271,7 +270,7 @@ 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/1000 > (*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;
diff --git a/modules/demux/asf/asfpacket.h b/modules/demux/asf/asfpacket.h
index 445e34bfb5..0455556006 100644
--- a/modules/demux/asf/asfpacket.h
+++ b/modules/demux/asf/asfpacket.h
@@ -43,7 +43,7 @@ struct asf_packet_sys_s
demux_t *p_demux;
/* global stream info */
- uint64_t *pi_preroll;
+ mtime_t *pi_preroll;
mtime_t *pi_preroll_start;
/* callbacks */
diff --git a/modules/demux/asf/libasf.c b/modules/demux/asf/libasf.c
index 119ef4d0e3..37d713b1b6 100644
--- a/modules/demux/asf/libasf.c
+++ b/modules/demux/asf/libasf.c
@@ -317,7 +317,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 = MS_TO_MTIME(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 );
diff --git a/modules/demux/asf/libasf.h b/modules/demux/asf/libasf.h
index 9f2cb9f356..d6c9708fb5 100644
--- a/modules/demux/asf/libasf.h
+++ b/modules/demux/asf/libasf.h
@@ -106,7 +106,7 @@ typedef struct
uint64_t i_data_packets_count;
msftime_t i_play_duration;
msftime_t i_send_duration;
- uint64_t i_preroll;
+ mtime_t i_preroll;
uint32_t i_flags;
uint32_t i_min_data_packet_size;
uint32_t i_max_data_packet_size;
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 1885e93840..87751e990a 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -132,7 +132,7 @@ typedef struct
/* ASF in MP4 */
asf_packet_sys_t asfpacketsys;
- uint64_t i_preroll; /* foobar */
+ mtime_t i_preroll; /* foobar */
mtime_t i_preroll_start;
struct
--
2.17.0
More information about the vlc-devel
mailing list