Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
403 results
Show changes
Commits on Source (8)
......@@ -14,7 +14,7 @@ libogg_plugin_la_SOURCES = demux/ogg.c demux/ogg.h demux/oggseek.c demux/oggseek
demux/xiph.h demux/opus.h
libogg_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBVORBIS_CFLAGS) $(OGG_CFLAGS)
libogg_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(demuxdir)'
libogg_plugin_la_LIBADD = $(LIBVORBIS_LIBS) $(OGG_LIBS) libxiph_metadata.la
libogg_plugin_la_LIBADD = $(LIBVORBIS_LIBS) $(OGG_LIBS) $(LIBM) libxiph_metadata.la
EXTRA_LTLIBRARIES += libogg_plugin.la
demux_LTLIBRARIES += $(LTLIBogg)
......
......@@ -229,7 +229,7 @@ static int Open( vlc_object_t * p_this )
if( !p_sys )
return VLC_ENOMEM;
p_sys->i_length = -1;
p_sys->i_length = 0;
p_sys->b_preparsing_done = false;
vlc_stream_Control( p_demux->s, STREAM_GET_PTS_DELAY,
......@@ -843,8 +843,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
pf = va_arg( args, double * );
if( p_sys->i_length > 0 && p_sys->i_pcr > VLC_TS_INVALID )
{
*pf = (double) p_sys->i_pcr /
(double) ( p_sys->i_length * (mtime_t)1000000 );
*pf = (double) p_sys->i_pcr / (double) p_sys->i_length;
}
else if( stream_Size( p_demux->s ) > 0 )
{
......@@ -882,9 +881,9 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
}
assert( p_sys->i_length > 0 );
i64 = CLOCK_FREQ * p_sys->i_length * f;
i64 = p_sys->i_length * f;
Ogg_ResetStreamsHelper( p_sys );
if ( Oggseek_SeektoAbsolutetime( p_demux, p_stream, i64 ) >= 0 )
if ( Oggseek_SeektoAbsolutetime( p_demux, p_stream, VLC_TS_0 + i64 ) >= 0 )
{
if( acc )
es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME,
......@@ -898,8 +897,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if ( p_sys->i_length < 0 )
return demux_vaControlHelper( p_demux->s, 0, -1, p_sys->i_bitrate,
1, i_query, args );
pi64 = va_arg( args, int64_t * );
*pi64 = p_sys->i_length * 1000000;
*va_arg( args, int64_t * ) = p_sys->i_length;
return VLC_SUCCESS;
case DEMUX_GET_TITLE_INFO:
......@@ -1580,8 +1578,8 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
demux_sys_t *p_ogg = p_demux->p_sys ;
ogg_packet oggpacket;
p_ogg->i_total_length = stream_Size ( p_demux->s );
msg_Dbg( p_demux, "File length is %"PRId64" bytes", p_ogg->i_total_length );
p_ogg->i_total_bytes = stream_Size ( p_demux->s );
msg_Dbg( p_demux, "File length is %"PRId64" bytes", p_ogg->i_total_bytes );
while( Ogg_ReadPage( p_demux, &p_ogg->current_page ) == VLC_SUCCESS )
......
......@@ -202,7 +202,7 @@ struct demux_sys_t
int64_t i_total_frames;
/* length of file in bytes */
int64_t i_total_length;
int64_t i_total_bytes;
/* offset position in file (for reading) */
int64_t i_input_position;
......@@ -230,7 +230,7 @@ struct demux_sys_t
bool b_preparsing_done;
bool b_es_created;
/* Length, if available. */
/* Time length, if available. 0 otherwise. */
int64_t i_length;
bool b_slave;
......
......@@ -35,7 +35,7 @@
#include <ogg/ogg.h>
#include <limits.h>
#include <math.h>
#include <assert.h>
#include "ogg.h"
......@@ -85,12 +85,18 @@ void oggseek_index_entries_free ( demux_index_entry_t *idx )
/* internal function to create a new list member */
static demux_index_entry_t *index_entry_new( void )
static demux_index_entry_t *index_entry_new( int64_t i_timestamp, int64_t i_pagepos )
{
demux_index_entry_t *idx = xmalloc( sizeof( demux_index_entry_t ) );
if ( !idx ) return NULL;
idx->p_next = idx->p_prev = NULL;
idx->i_pagepos_end = -1;
if ( i_timestamp == VLC_TS_INVALID || i_pagepos < 1 )
return NULL;
demux_index_entry_t *idx = malloc( sizeof(*idx) );
if ( idx )
{
idx->i_value = i_timestamp;
idx->i_pagepos = i_pagepos;
idx->p_next = NULL;
}
return idx;
}
......@@ -100,60 +106,31 @@ const demux_index_entry_t *OggSeek_IndexAdd ( logical_stream_t *p_stream,
int64_t i_timestamp,
int64_t i_pagepos )
{
demux_index_entry_t *idx;
demux_index_entry_t *last_idx = NULL;
if ( p_stream == NULL ) return NULL;
idx = p_stream->idx;
if ( i_timestamp < 1 || i_pagepos < 1 ) return NULL;
if ( idx == NULL )
{
demux_index_entry_t *ie = index_entry_new();
if ( !ie ) return NULL;
ie->i_value = i_timestamp;
ie->i_pagepos = i_pagepos;
p_stream->idx = ie;
return ie;
}
while ( idx != NULL )
{
if ( idx->i_pagepos > i_pagepos ) break;
last_idx = idx;
idx = idx->p_next;
}
/* new entry; insert after last_idx */
idx = index_entry_new();
if ( !idx ) return NULL;
if ( last_idx != NULL )
{
idx->p_next = last_idx->p_next;
last_idx->p_next = idx;
idx->p_prev = last_idx;
}
else
demux_index_entry_t **pp_next = &p_stream->idx;
for( ; *pp_next; )
{
idx->p_next = p_stream->idx;
p_stream->idx = idx;
if( (*pp_next)->i_pagepos >= i_pagepos )
{
if( (*pp_next)->i_pagepos == i_pagepos )
return NULL;
break;
}
pp_next = &((*pp_next)->p_next);
}
if ( idx->p_next != NULL )
demux_index_entry_t *ie = index_entry_new( i_timestamp, i_pagepos );
if ( ie )
{
idx->p_next->p_prev = idx;
ie->p_next = *pp_next;
*pp_next = ie;
}
idx->i_value = i_timestamp;
idx->i_pagepos = i_pagepos;
return idx;
return ie;
}
static bool OggSeekIndexFind ( logical_stream_t *p_stream, int64_t i_timestamp,
int64_t *pi_pos_lower, int64_t *pi_pos_upper )
int64_t *pi_pos_lower, int64_t *pi_pos_upper,
int64_t *pi_lower_timestamp )
{
demux_index_entry_t *idx = p_stream->idx;
......@@ -164,11 +141,13 @@ static bool OggSeekIndexFind ( logical_stream_t *p_stream, int64_t i_timestamp,
if ( !idx->p_next ) /* found on last index */
{
*pi_pos_lower = idx->i_pagepos;
*pi_lower_timestamp = idx->i_value;
return true;
}
if ( idx->p_next->i_value > i_timestamp )
{
*pi_pos_lower = idx->i_pagepos;
*pi_lower_timestamp = idx->i_value;
*pi_pos_upper = idx->p_next->i_pagepos;
return true;
}
......@@ -209,11 +188,11 @@ static int64_t get_data( demux_t *p_demux, int64_t i_bytes_to_read )
char *buf;
int64_t i_result;
if ( p_sys->i_total_length > 0 )
if ( p_sys->i_total_bytes > 0 )
{
if ( p_sys->i_input_position + i_bytes_to_read > p_sys->i_total_length )
if ( p_sys->i_input_position + i_bytes_to_read > p_sys->i_total_bytes )
{
i_bytes_to_read = p_sys->i_total_length - p_sys->i_input_position;
i_bytes_to_read = p_sys->i_total_bytes - p_sys->i_input_position;
if ( i_bytes_to_read <= 0 ) {
return 0;
}
......@@ -291,7 +270,7 @@ void Oggseek_ProbeEnd( demux_t *p_demux )
continue;
i_length = Oggseek_GranuleToAbsTimestamp( p_sys->pp_stream[i], i_granule, false );
p_sys->i_length = __MAX( p_sys->i_length, i_length / 1000000 );
p_sys->i_length = __MAX( p_sys->i_length, i_length );
break;
}
}
......@@ -342,9 +321,6 @@ static int64_t find_first_page_granule( demux_t *p_demux,
seek_byte( p_demux, i_pos1 );
if ( i_pos1 == p_stream->i_data_start )
return p_sys->i_input_position;
if ( i_bytes_to_read > OGGSEEK_BYTES_TO_READ ) i_bytes_to_read = OGGSEEK_BYTES_TO_READ;
while ( 1 )
......@@ -752,7 +728,7 @@ int64_t Oggseek_GranuleToAbsTimestamp( logical_stream_t *p_stream,
/* returns pos */
static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stream,
int64_t i_targettime, int64_t i_pos_lower, int64_t i_pos_upper)
int64_t i_targettime, int64_t i_pos_lower, int64_t i_pos_upper, int64_t *pi_seek_time)
{
int64_t i_start_pos;
int64_t i_end_pos;
......@@ -770,8 +746,8 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
demux_sys_t *p_sys = p_demux->p_sys;
i_pos_lower = __MAX( i_pos_lower, p_stream->i_data_start );
i_pos_upper = __MIN( i_pos_upper, p_sys->i_total_length );
if ( i_pos_upper < 0 ) i_pos_upper = p_sys->i_total_length;
i_pos_upper = __MIN( i_pos_upper, p_sys->i_total_bytes );
if ( i_pos_upper < 0 ) i_pos_upper = p_sys->i_total_bytes;
i_start_pos = i_pos_lower;
i_end_pos = i_pos_upper;
......@@ -782,6 +758,21 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
OggDebug( msg_Dbg(p_demux, "Bisecting for time=%"PRId64" between %"PRId64" and %"PRId64,
i_targettime, i_pos_lower, i_pos_upper ) );
/* Check lowest possible bound that will never be checked in bisection */
current.i_pos = find_first_page_granule( p_demux,
i_pos_lower,
__MIN(i_start_pos + PAGE_HEADER_BYTES, i_end_pos),
p_stream,
&current.i_granule );
if( current.i_granule != -1 )
{
current.i_timestamp = Oggseek_GranuleToAbsTimestamp( p_stream, current.i_granule, false );
if( current.i_timestamp <= i_targettime )
bestlower = current;
else
lowestupper = current;
}
do
{
/* see if the frame lies in current segment */
......@@ -850,7 +841,7 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
i_segsize = ( i_end_pos - i_start_pos + 1 ) >> 1;
i_start_pos += i_segsize;
} while ( i_segsize > 64 );
} while ( i_segsize > PAGE_HEADER_BYTES );
if ( bestlower.i_granule == -1 )
{
......@@ -866,6 +857,7 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
__MAX ( bestlower.i_pos - OGGSEEK_BYTES_TO_READ, p_stream->i_data_start ),
bestlower.i_pos,
p_stream, bestlower.i_granule /* unused */ );
*pi_seek_time = bestlower.i_timestamp;
return a;
}
/* If not each packet is usable as keyframe, query the codec for keyframe */
......@@ -884,9 +876,11 @@ static int64_t OggBisectSearchByTime( demux_t *p_demux, logical_stream_t *p_stre
int64_t a = OggBackwardSeekToFrame( p_demux,
__MAX ( bestlower.i_pos - OGGSEEK_BYTES_TO_READ, p_stream->i_data_start ),
stream_Size( p_demux->s ), p_stream, i_keyframegranule );
*pi_seek_time = Oggseek_GranuleToAbsTimestamp(p_stream, i_keyframegranule, false);
return a;
}
*pi_seek_time = bestlower.i_timestamp;
return bestlower.i_pos;
}
......@@ -908,7 +902,8 @@ int Oggseek_BlindSeektoAbsoluteTime( demux_t *p_demux, logical_stream_t *p_strea
if ( i_lowerpos != -1 ) b_found = true;
/* And also search in our own index */
if ( !b_found && OggSeekIndexFind( p_stream, i_time, &i_lowerpos, &i_upperpos ) )
int64_t foo;
if ( !b_found && OggSeekIndexFind( p_stream, i_time, &i_lowerpos, &i_upperpos, &foo ) )
{
b_found = true;
}
......@@ -926,14 +921,16 @@ int Oggseek_BlindSeektoAbsoluteTime( demux_t *p_demux, logical_stream_t *p_strea
/* or search */
if ( !b_found && b_fastseek )
{
int64_t i_sync_time;
i_lowerpos = OggBisectSearchByTime( p_demux, p_stream, i_time,
p_stream->i_data_start, p_sys->i_total_length );
p_stream->i_data_start, p_sys->i_total_bytes,
&i_sync_time );
b_found = ( i_lowerpos != -1 );
}
if ( !b_found ) return -1;
if ( i_lowerpos < p_stream->i_data_start || i_upperpos > p_sys->i_total_length )
if ( i_lowerpos < p_stream->i_data_start || i_upperpos > p_sys->i_total_bytes )
return -1;
/* And really do seek */
......@@ -974,7 +971,7 @@ int Oggseek_BlindSeektoPosition( demux_t *p_demux, logical_stream_t *p_stream,
* final seek time */
i_pagepos = OggBackwardSeekToFrame( p_demux,
__MAX ( i_size - MAX_PAGE_SIZE, p_stream->i_data_start ),
__MIN ( i_size + MAX_PAGE_SIZE, p_demux->p_sys->i_total_length ),
__MIN ( i_size + MAX_PAGE_SIZE, p_demux->p_sys->i_total_bytes ),
p_stream, i_granule );
}
else
......@@ -1011,15 +1008,17 @@ int Oggseek_SeektoAbsolutetime( demux_t *p_demux, logical_stream_t *p_stream,
}
OggDebug( msg_Dbg( p_demux, "Search bounds set to %"PRId64" %"PRId64" using skeleton index", i_offset_lower, i_offset_upper ) );
OggNoDebug(
OggSeekIndexFind( p_stream, i_time, &i_offset_lower, &i_offset_upper )
);
int64_t i_lower_index;
if(!OggSeekIndexFind( p_stream, i_time, &i_offset_lower, &i_offset_upper, &i_lower_index ))
i_lower_index = 0;
i_offset_lower = __MAX( i_offset_lower, p_stream->i_data_start );
i_offset_upper = __MIN( i_offset_upper, p_sys->i_total_length );
i_offset_upper = __MIN( i_offset_upper, p_sys->i_total_bytes );
int64_t i_sync_time;
int64_t i_pagepos = OggBisectSearchByTime( p_demux, p_stream, i_time,
i_offset_lower, i_offset_upper);
i_offset_lower, i_offset_upper, &i_sync_time );
if ( i_pagepos >= 0 )
{
/* be sure to clear any state or read+pagein() will fail on same # */
......@@ -1027,11 +1026,13 @@ int Oggseek_SeektoAbsolutetime( demux_t *p_demux, logical_stream_t *p_stream,
p_sys->i_input_position = i_pagepos;
seek_byte( p_demux, p_sys->i_input_position );
}
/* Insert keyframe position into index */
OggNoDebug(
if ( i_pagepos >= p_stream->i_data_start )
OggSeek_IndexAdd( p_stream, i_time, i_pagepos )
);
int64_t index_interval = p_sys->i_length
? CLOCK_FREQ * ceil( sqrt( p_sys->i_length / CLOCK_FREQ ) / 2 )
: CLOCK_FREQ * 5;
if ( i_pagepos >= p_stream->i_data_start && ( i_sync_time - i_lower_index >= index_interval ) )
OggSeek_IndexAdd( p_stream, i_sync_time, i_pagepos );
OggDebug( msg_Dbg( p_demux, "=================== Seeked To %"PRId64" time %"PRId64, i_pagepos, i_time ) );
return i_pagepos;
......
......@@ -30,23 +30,13 @@
#define OGGSEEK_BYTES_TO_READ 8500
/* index entries are structured as follows:
* - for theora, highest granulepos -> pagepos (bytes) where keyframe begins
* - for dirac, kframe (sync point) -> pagepos of sequence start (?)
*/
/* this is typedefed to demux_index_entry_t in ogg.h */
struct oggseek_index_entry
{
demux_index_entry_t *p_next;
demux_index_entry_t *p_prev;
/* value is highest granulepos for theora, sync frame for dirac */
int64_t i_value;
int64_t i_pagepos;
/* not used for theora because the granulepos tells us this */
int64_t i_pagepos_end;
};
int64_t Ogg_GetKeyframeGranule ( logical_stream_t *p_stream, int64_t i_granule );
......