printf("\t\tcompressed length: %ld bytes ",ov_raw_total(&ov,i));
printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
}
-
+
ov_clear(&ov);
return 0;
}
extern int ogg_stream_init(ogg_stream_state *os,int serialno);
extern int ogg_stream_clear(ogg_stream_state *os);
-extern int ogg_stream_reset(ogg_stream_state *os);
+extern int ogg_stream_reset(ogg_stream_state *os,long expected_pageno);
extern int ogg_stream_destroy(ogg_stream_state *os);
extern int ogg_stream_eof(ogg_stream_state *os);
for(vals=0;vals<maxvals;vals++){
if(acc>4096)break;
acc+=os->lacing_vals[vals]&0x0ff;
- if((os->lacing_vals[vals]&0x0ff)<255)pcm_pos=os->pcm_vals[vals];
+ pcm_pos=os->pcm_vals[vals];
}
}
return(0);
}
-int ogg_stream_reset(ogg_stream_state *os){
+int ogg_stream_reset(ogg_stream_state *os,long expected_pageno){
os->body_fill=0;
os->body_returned=0;
os->e_o_s=0;
os->b_o_s=0;
- os->pageno=0;
+ os->pageno=expected_pageno;
os->packetno=0;
os->pcmpos=0;
int eosflag=0;
int bosflag=0;
- ogg_stream_reset(&os_en);
- ogg_stream_reset(&os_de);
+ ogg_stream_reset(&os_en,0);
+ ogg_stream_reset(&os_de,0);
ogg_sync_reset(&oy);
for(packets=0;;packets++)if(pl[packets]==-1)break;
int inptr=0,i,j;
ogg_page og[5];
- ogg_stream_reset(&os_en);
+ ogg_stream_reset(&os_en,0);
for(i=0;pl[i]!=-1;i++){
ogg_packet op;
fprintf(stderr,"Testing loss of pages... ");
ogg_sync_reset(&oy);
- ogg_stream_reset(&os_de);
+ ogg_stream_reset(&os_de,0);
for(i=0;i<5;i++){
memcpy(ogg_sync_buffer(&oy,og[i].header_len),og[i].header,
og[i].header_len);
fprintf(stderr,"Testing loss of pages (rollback required)... ");
ogg_sync_reset(&oy);
- ogg_stream_reset(&os_de);
+ ogg_stream_reset(&os_de,0);
for(i=0;i<5;i++){
memcpy(ogg_sync_buffer(&oy,og[i].header_len),og[i].header,
og[i].header_len);
/* reload */
ogg_stream_init(&vf->os,vf->current_serialno);
+ ogg_stream_reset(&vf->os,ogg_page_pageno(&og));
vorbis_synthesis_init(&vf->vd,vf->vi+link);
vorbis_block_init(&vf->vd,&vf->vb);
vf->decode_ready=1;
if(pos>=total)break;
}
- /* seach within the logical bitstream for the page with the highest
+ /* search within the logical bitstream for the page with the highest
pcm_pos preceeding (or equal to) pos. There is a danger here;
missing pages or incorrect frame number information in the
bitstream could make our task impossible. Account for that (it
ogg_page og;
while(begin<end){
long bisect;
- long ret,acc;
+ long ret;
if(end-begin<CHUNKSIZE){
bisect=begin;
}
_seek_helper(vf,bisect);
-
- acc=0;
- while(1){
- ret=_get_next_page(vf,&og,-1);
-
- if(ret==-1){
- end=bisect;
+ ret=_get_next_page(vf,&og,-1);
+
+ if(ret==-1){
+ end=bisect;
+ }else{
+ size64 frameno=ogg_page_frameno(&og);
+ if(ogg_page_serialno(&og)==vf->serialnos[link] && frameno<target){
+ best=ret; /* raw offset of packet with frameno */
+ begin=vf->offset; /* raw offset of next packet */
}else{
- size64 frameno=ogg_page_frameno(&og);
- acc+=ret;
- if(frameno==-1)continue;
- if(frameno<target){
- best=bisect+acc; /* raw offset of packet with frameno */
- begin=vf->offset; /* raw offset of next packet */
- }else{
- end=bisect;
- }
+ end=bisect;
}
- break;
}
}