vlc | branch: master | Francois Cartegnie <[email protected]> | Mon Oct 27 22:48:30 2014 +0100| [5a9b7726e58f493b345401dff3dee37dc9d1b4fd] | committer: Francois Cartegnie
stream_filter: smooth: fix signedness > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5a9b7726e58f493b345401dff3dee37dc9d1b4fd --- modules/stream_filter/smooth/downloader.c | 27 ++++++++++++++++----------- modules/stream_filter/smooth/smooth.c | 15 ++++++++------- modules/stream_filter/smooth/smooth.h | 14 +++++++------- modules/stream_filter/smooth/utils.c | 6 +++--- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/modules/stream_filter/smooth/downloader.c b/modules/stream_filter/smooth/downloader.c index 2bfb536..d68851c 100644 --- a/modules/stream_filter/smooth/downloader.c +++ b/modules/stream_filter/smooth/downloader.c @@ -56,7 +56,7 @@ static char *ConstructUrl( const char *template, const char *base_url, return url; } -static chunk_t * chunk_Get( sms_stream_t *sms, const int64_t start_time ) +static chunk_t * chunk_Get( sms_stream_t *sms, const uint64_t start_time ) { int len = vlc_array_count( sms->chunks ); for( int i = 0; i < len; i++ ) @@ -116,8 +116,10 @@ static int sms_Download( stream_t *s, chunk_t *chunk, char *url ) return VLC_EGENERIC; int64_t size = stream_Size( p_ts ); + if ( size < 0 ) + return VLC_EGENERIC; - chunk->size = size; + chunk->size = (uint64_t) size; chunk->offset = p_sys->download.next_chunk_offset; p_sys->download.next_chunk_offset += chunk->size; @@ -255,8 +257,8 @@ static int get_new_chunks( stream_t *s, chunk_t *ck ) for( uint8_t i = 0; i < fragment_count; i++ ) { - int64_t dur = tfrf_df[i].i_fragment_duration; - int64_t stime = tfrf_df[i].i_fragment_abs_time; + uint64_t dur = tfrf_df[i].i_fragment_duration; + uint64_t stime = tfrf_df[i].i_fragment_abs_time; msg_Dbg( s, "\"tfrf\" fragment duration %"PRIu64", "\ "fragment abs time %"PRIu64, dur, stime); @@ -388,7 +390,7 @@ static int Download( stream_t *s, sms_stream_t *sms ) msg_Err( s, "invalid stream type" ); return VLC_EGENERIC; } - int64_t start_time = p_sys->download.lead[index]; + uint64_t start_time = p_sys->download.lead[index]; quality_level_t *qlevel = get_qlevel( sms, sms->download_qlvl ); if( unlikely( !qlevel ) ) @@ -529,12 +531,12 @@ static int Download( stream_t *s, sms_stream_t *sms ) return VLC_SUCCESS; } -static inline int64_t get_lead( stream_t *s ) +static inline uint64_t get_lead( stream_t *s ) { stream_sys_t *p_sys = s->p_sys; - int64_t lead = 0; - int64_t alead = p_sys->download.lead[es_cat_to_index( AUDIO_ES )]; - int64_t vlead = p_sys->download.lead[es_cat_to_index( VIDEO_ES )]; + uint64_t lead = 0; + uint64_t alead = p_sys->download.lead[es_cat_to_index( AUDIO_ES )]; + uint64_t vlead = p_sys->download.lead[es_cat_to_index( VIDEO_ES )]; bool video = SMS_GET_SELECTED_ST( VIDEO_ES ) ? true : false; bool audio = SMS_GET_SELECTED_ST( AUDIO_ES ) ? true : false; @@ -545,7 +547,10 @@ static inline int64_t get_lead( stream_t *s ) else lead = alead; - lead -= p_sys->playback.toffset; + if( p_sys->playback.toffset > lead ) + lead -= p_sys->playback.toffset; + else + lead = 0; return lead; } @@ -598,7 +603,7 @@ void* sms_Thread( void *p_this ) * and for some reason the n^th advertised video fragment is related to * the n+1^th advertised audio chunk or vice versa */ - int64_t start_time = 0, lead = 0; + uint64_t start_time = 0, lead = 0; for( int i = 0; i < 3; i++ ) { diff --git a/modules/stream_filter/smooth/smooth.c b/modules/stream_filter/smooth/smooth.c index e3be190..2c42e60 100644 --- a/modules/stream_filter/smooth/smooth.c +++ b/modules/stream_filter/smooth/smooth.c @@ -589,10 +589,10 @@ static chunk_t *get_chunk( stream_t *s, const bool wait ) return chunk; } -static int sms_Read( stream_t *s, uint8_t *p_read, int i_read ) +static unsigned int sms_Read( stream_t *s, uint8_t *p_read, unsigned int i_read ) { stream_sys_t *p_sys = s->p_sys; - int copied = 0; + unsigned int copied = 0; chunk_t *chunk = NULL; do @@ -601,7 +601,7 @@ static int sms_Read( stream_t *s, uint8_t *p_read, int i_read ) if( !chunk ) return copied; - if( chunk->read_pos >= (int)chunk->size ) + if( chunk->read_pos >= chunk->size ) { if( chunk->type == VIDEO_ES || ( !SMS_GET_SELECTED_ST( VIDEO_ES ) && chunk->type == AUDIO_ES ) ) @@ -638,7 +638,7 @@ static int sms_Read( stream_t *s, uint8_t *p_read, int i_read ) assert( type == ATOM_moof || type == ATOM_uuid ); } - int len = -1; + uint64_t len = 0; uint8_t *src = chunk->data + chunk->read_pos; if( i_read <= chunk->size - chunk->read_pos ) len = i_read; @@ -664,12 +664,13 @@ static int Read( stream_t *s, void *buffer, unsigned i_read ) { stream_sys_t *p_sys = s->p_sys; int length = 0; + i_read = __MIN(INT_MAX, i_read); if( p_sys->b_error ) return 0; length = sms_Read( s, (uint8_t*) buffer, i_read ); - if( length < 0 ) + if( length == 0 ) return 0; /* This call to sms_Read will increment p_sys->playback.index @@ -677,8 +678,8 @@ static int Read( stream_t *s, void *buffer, unsigned i_read ) sms_Read( s, NULL, 0 ); p_sys->playback.boffset += length; - if( (unsigned)length < i_read ) - msg_Warn( s, "could not read %i bytes, only %i!", i_read, length ); + if( length < (int)i_read ) + msg_Warn( s, "could not read %u bytes, only %u !", i_read, length ); return length; } diff --git a/modules/stream_filter/smooth/smooth.h b/modules/stream_filter/smooth/smooth.h index 34340d1..5a546d8 100644 --- a/modules/stream_filter/smooth/smooth.h +++ b/modules/stream_filter/smooth/smooth.h @@ -35,18 +35,18 @@ typedef struct item_s typedef struct sms_queue_s { - int length; + unsigned length; item_t *first; } sms_queue_t; typedef struct chunk_s { - int64_t duration; /* chunk duration (seconds / TimeScale) */ - int64_t start_time; /* PTS (seconds / TimeScale) */ - int size; /* chunk size in bytes */ + uint64_t duration; /* chunk duration (seconds / TimeScale) */ + uint64_t start_time; /* PTS (seconds / TimeScale) */ + uint64_t size; /* chunk size in bytes */ unsigned sequence; /* unique sequence number */ uint64_t offset; /* offset in the media */ - int read_pos; /* position in the chunk */ + uint64_t read_pos; /* position in the chunk */ int type; /* video, audio, or subtitles */ uint8_t *data; @@ -96,7 +96,7 @@ struct stream_sys_t unsigned i_tracks; /* Total number of tracks in the Manifest */ sms_queue_t *bws; /* Measured bandwidths of the N last chunks */ uint64_t vod_duration; /* total duration of the VOD media */ - int64_t time_pos; + uint64_t time_pos; unsigned timescale; /* Download */ @@ -167,7 +167,7 @@ struct stream_sys_t no_more_chunks( p_sys->download.ck_index, p_sys->selected_st ) ) void sms_queue_free( sms_queue_t* ); -sms_queue_t *sms_queue_init( const int ); +sms_queue_t *sms_queue_init( const unsigned int ); int sms_queue_put( sms_queue_t *, const uint64_t ); uint64_t sms_queue_avg( sms_queue_t *); quality_level_t *get_qlevel( sms_stream_t *, const unsigned ); diff --git a/modules/stream_filter/smooth/utils.c b/modules/stream_filter/smooth/utils.c index 7189d1a..3b17138 100644 --- a/modules/stream_filter/smooth/utils.c +++ b/modules/stream_filter/smooth/utils.c @@ -158,7 +158,7 @@ quality_level_t *get_qlevel( sms_stream_t *sms, const unsigned qid ) return NULL; } -sms_queue_t *sms_queue_init( const int length ) +sms_queue_t *sms_queue_init( const unsigned length ) { sms_queue_t *ret = malloc( sizeof( sms_queue_t ) ); if( unlikely( !ret ) ) @@ -184,7 +184,7 @@ int sms_queue_put( sms_queue_t *queue, const uint64_t value ) { /* Remove the last (and oldest) item */ item_t *item, *prev = NULL; - int count = 0; + unsigned int count = 0; for( item = queue->first; item != NULL; item = item->next ) { count++; @@ -216,7 +216,7 @@ uint64_t sms_queue_avg( sms_queue_t *queue ) if( last == NULL ) return 0; uint64_t sum = queue->first->value; - for( int i = 0; i < queue->length - 1; i++ ) + for( unsigned int i = 0; queue->length && i < queue->length - 1; i++ ) { if( last ) { _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
