| 1 | /******************************************************************** |
| 2 | * * |
| 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * |
| 4 | * * |
| 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
| 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
| 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
| 8 | * * |
| 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2009 * |
| 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * |
| 11 | * * |
| 12 | ******************************************************************** |
| 13 | |
| 14 | function: stdio-based convenience library for opening/seeking/decoding |
| 15 | last mod: $Id: vorbisfile.c,v 1.6 2003/03/30 23:40:56 xiphmont Exp $ |
| 16 | |
| 17 | ********************************************************************/ |
| 18 | |
| 19 | #include <stdlib.h> |
| 20 | #include <stdio.h> |
| 21 | #include <errno.h> |
| 22 | #include <string.h> |
| 23 | #include <math.h> |
| 24 | |
| 25 | #include "ivorbiscodec.h"cxx . . $ `<file>/mednafen/tremor/ivorbiscodec.h`/ |
| 26 | #include "ivorbisfile.h"cxx . . $ `<file>/mednafen/tremor/ivorbisfile.h`/ |
| 27 | |
| 28 | #include "os.h"cxx . . $ `<file>/mednafen/tremor/os.h`/ |
| 29 | #include "misc.h"cxx . . $ `<file>/mednafen/tremor/misc.h`/ |
| 30 | |
| 31 | /* A 'chained bitstream' is a Vorbis bitstream that contains more than |
| 32 | one logical bitstream arranged end to end (the only form of Ogg |
| 33 | multiplexing allowed in a Vorbis bitstream; grouping [parallel |
| 34 | multiplexing] is not allowed in Vorbis) */ |
| 35 | |
| 36 | /* A Vorbis file can be played beginning to end (streamed) without |
| 37 | worrying ahead of time about chaining (see decoder_example.c). If |
| 38 | we have the whole file, however, and want random access |
| 39 | (seeking/scrubbing) or desire to know the total length/time of a |
| 40 | file, we need to account for the possibility of chaining. */ |
| 41 | |
| 42 | /* We can handle things a number of ways; we can determine the entire |
| 43 | bitstream structure right off the bat, or find pieces on demand. |
| 44 | This example determines and caches structure for the entire |
| 45 | bitstream, but builds a virtual decoder on the fly when moving |
| 46 | between links in the chain. */ |
| 47 | |
| 48 | /* There are also different ways to implement seeking. Enough |
| 49 | information exists in an Ogg bitstream to seek to |
| 50 | sample-granularity positions in the output. Or, one can seek by |
| 51 | picking some portion of the stream roughly in the desired area if |
| 52 | we only want coarse navigation through the stream. */ |
| 53 | |
| 54 | /************************************************************************* |
| 55 | * Many, many internal helpers. The intention is not to be confusing; |
| 56 | * rampant duplication and monolithic function implementation would be |
| 57 | * harder to understand anyway. The high level functions are last. Begin |
| 58 | * grokking near the end of the file */ |
| 59 | |
| 60 | |
| 61 | /* read a little more data from the file/pipe into the ogg_sync framer */ |
| 62 | static long _get_datacxx . . $ _get_data(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 63 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!=0; |
| 64 | if(!(vf->callbackscxx . . $ OggVorbis_File#callbacks..read_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#read_func.))return(-1); |
| 65 | if(vf->datasourcecxx . . $ OggVorbis_File#datasource.){ |
| 66 | char *buffer=ogg_sync_buffercxx . . $ ogg_sync_buffer(16ea7c6d847c120d).(&vf->oycxx . . $ OggVorbis_File#oy.,CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!); |
| 67 | long bytes=(vf->callbackscxx . . $ OggVorbis_File#callbacks..read_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#read_func.)(buffer,1,CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!,vf->datasourcecxx . . $ OggVorbis_File#datasource.); |
| 68 | if(bytes>0)ogg_sync_wrotecxx . . $ ogg_sync_wrote(7ecdafb9a73216e5).(&vf->oycxx . . $ OggVorbis_File#oy.,bytes); |
| 69 | #ifdef GEKKO |
| 70 | // It seems that EOVERFLOW is set whenever |
| 71 | // we read to the end of the file on WII... |
| 72 | // Fix copied from WiiMednafen code. |
| 73 | if(bytes==0 && errno && errno != EOVERFLOW) |
| 74 | #else |
| 75 | if(bytes==0 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!) |
| 76 | #endif |
| 77 | { |
| 78 | return(-1); |
| 79 | } |
| 80 | return(bytes); |
| 81 | }else |
| 82 | return(0); |
| 83 | } |
| 84 | |
| 85 | /* save a tiny smidge of verbosity to make the code more readable */ |
| 86 | static int _seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# offset){ |
| 87 | if(vf->datasourcecxx . . $ OggVorbis_File#datasource.){ |
| 88 | if(!(vf->callbackscxx . . $ OggVorbis_File#callbacks..seek_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#seek_func.)|| |
| 89 | (vf->callbackscxx . . $ OggVorbis_File#callbacks..seek_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#seek_func.)(vf->datasourcecxx . . $ OggVorbis_File#datasource., offset, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!) == -1) |
| 90 | return OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!; |
| 91 | vf->offsetcxx . . $ OggVorbis_File#offset.=offset; |
| 92 | ogg_sync_resetcxx . . $ ogg_sync_reset(4d079e1537bb6e53).(&vf->oycxx . . $ OggVorbis_File#oy.); |
| 93 | }else{ |
| 94 | /* shouldn't happen unless someone writes a broken callback */ |
| 95 | return OV_EFAULTcxx . . $ `mednafen/tremor/ivorbiscodec.h:188:9`!; |
| 96 | } |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | /* The read/seek functions track absolute position within the stream */ |
| 101 | |
| 102 | /* from the head of the stream, get the next page. boundary specifies |
| 103 | if the function is allowed to fetch more data from the stream (and |
| 104 | how much) or only use internally buffered data. |
| 105 | |
| 106 | boundary: -1) unbounded search |
| 107 | 0) read no additional data; use cached only |
| 108 | n) search for a new page beginning for n bytes |
| 109 | |
| 110 | return: <0) did not find a page (OV_FALSE, OV_EOF, OV_EREAD) |
| 111 | n) found a page at absolute offset n */ |
| 112 | |
| 113 | static ogg_int64_tcxx . . $ ogg_int64_t# _get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_pagecxx . . $ ogg_page# *og, |
| 114 | ogg_int64_tcxx . . $ ogg_int64_t# boundary){ |
| 115 | if(boundary>0)boundary+=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 116 | while(1){ |
| 117 | long more; |
| 118 | |
| 119 | if(boundary>0 && vf->offsetcxx . . $ OggVorbis_File#offset.>=boundary)return(OV_FALSEcxx . . $ `mednafen/tremor/ivorbiscodec.h:183:9`!); |
| 120 | more=ogg_sync_pageseekcxx . . $ ogg_sync_pageseek(6fecd6648e8334e5).(&vf->oycxx . . $ OggVorbis_File#oy.,og); |
| 121 | |
| 122 | if(more<0){ |
| 123 | /* skipped n bytes */ |
| 124 | vf->offsetcxx . . $ OggVorbis_File#offset.-=more; |
| 125 | }else{ |
| 126 | if(more==0){ |
| 127 | /* send more paramedics */ |
| 128 | if(!boundary)return(OV_FALSEcxx . . $ `mednafen/tremor/ivorbiscodec.h:183:9`!); |
| 129 | { |
| 130 | long ret=_get_datacxx . . $ _get_data(cc66401103655b07).(vf); |
| 131 | if(ret==0)return(OV_EOFcxx . . $ `mednafen/tremor/ivorbiscodec.h:184:9`!); |
| 132 | if(ret<0)return(OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!); |
| 133 | } |
| 134 | }else{ |
| 135 | /* got a page. Return the offset at the page beginning, |
| 136 | advance the internal offset past the page end */ |
| 137 | ogg_int64_tcxx . . $ ogg_int64_t# ret=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 138 | vf->offsetcxx . . $ OggVorbis_File#offset.+=more; |
| 139 | return(ret); |
| 140 | |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /* find the latest page beginning before the current stream cursor |
| 147 | position. Much dirtier than the above as Ogg doesn't have any |
| 148 | backward search linkage. no 'readp' as it will certainly have to |
| 149 | read. */ |
| 150 | /* returns offset or OV_EREAD, OV_FAULT */ |
| 151 | static ogg_int64_tcxx . . $ ogg_int64_t# _get_prev_pagecxx . . $ _get_prev_page(a037b955d8f4f6eb).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_pagecxx . . $ ogg_page# *og){ |
| 152 | ogg_int64_tcxx . . $ ogg_int64_t# begin=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 153 | ogg_int64_tcxx . . $ ogg_int64_t# end=begin; |
| 154 | ogg_int64_tcxx . . $ ogg_int64_t# ret; |
| 155 | ogg_int64_tcxx . . $ ogg_int64_t# offset=-1; |
| 156 | |
| 157 | while(offset==-1){ |
| 158 | begin-=CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!; |
| 159 | if(begin<0) |
| 160 | begin=0; |
| 161 | |
| 162 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,begin); |
| 163 | if(ret)return(ret); |
| 164 | |
| 165 | while(vf->offsetcxx . . $ OggVorbis_File#offset.<end){ |
| 166 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(og,0,sizeof(*og)); |
| 167 | ret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,og,end-vf->offsetcxx . . $ OggVorbis_File#offset.); |
| 168 | if(ret==OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!)return(OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!); |
| 169 | if(ret<0){ |
| 170 | break; |
| 171 | }else{ |
| 172 | offset=ret; |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | /* In a fully compliant, non-multiplexed stream, we'll still be |
| 178 | holding the last page. In multiplexed (or noncompliant streams), |
| 179 | we will probably have to re-read the last page we saw */ |
| 180 | if(og->header_lencxx . . $ $anonymous_type_cccabde66011c92d_2#header_len.==0){ |
| 181 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,offset); |
| 182 | if(ret)return(ret); |
| 183 | |
| 184 | ret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,og,CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!); |
| 185 | if(ret<0) |
| 186 | /* this shouldn't be possible */ |
| 187 | return(OV_EFAULTcxx . . $ `mednafen/tremor/ivorbiscodec.h:188:9`!); |
| 188 | } |
| 189 | |
| 190 | return(offset); |
| 191 | } |
| 192 | |
| 193 | static void _add_serialnocxx . . $ _add_serialno(6eb8d6367eed44cf).(ogg_pagecxx . . $ ogg_page# *og,ogg_uint32_tcxx . . $ ogg_uint32_t# **serialno_list, int *n){ |
| 194 | ogg_uint32_tcxx . . $ ogg_uint32_t# s = ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og); |
| 195 | (*n)++; |
| 196 | |
| 197 | if(*serialno_list){ |
| 198 | *serialno_list = _ogg_realloccxx . . $ `mednafen/tremor/os_types.h:24:9`!(*serialno_list, sizeof(**serialno_list)*(*n)); |
| 199 | }else{ |
| 200 | *serialno_list = _ogg_malloccxx . . $ `mednafen/tremor/os_types.h:22:9`!(sizeof(**serialno_list)); |
| 201 | } |
| 202 | |
| 203 | (*serialno_list)[(*n)-1] = s; |
| 204 | } |
| 205 | |
| 206 | /* returns nonzero if found */ |
| 207 | static int _lookup_serialnocxx . . $ _lookup_serialno(ce67f49aceb987ce).(ogg_uint32_tcxx . . $ ogg_uint32_t# s, ogg_uint32_tcxx . . $ ogg_uint32_t# *serialno_list, int n){ |
| 208 | if(serialno_list){ |
| 209 | while(n--){ |
| 210 | if(*serialno_list == s) return 1; |
| 211 | serialno_list++; |
| 212 | } |
| 213 | } |
| 214 | return 0; |
| 215 | } |
| 216 | |
| 217 | static int _lookup_page_serialnocxx . . $ _lookup_page_serialno(61607cd81868850e).(ogg_pagecxx . . $ ogg_page# *og, ogg_uint32_tcxx . . $ ogg_uint32_t# *serialno_list, int n){ |
| 218 | ogg_uint32_tcxx . . $ ogg_uint32_t# s = ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og); |
| 219 | return _lookup_serialnocxx . . $ _lookup_serialno(ce67f49aceb987ce).(s,serialno_list,n); |
| 220 | } |
| 221 | |
| 222 | /* performs the same search as _get_prev_page, but prefers pages of |
| 223 | the specified serial number. If a page of the specified serialno is |
| 224 | spotted during the seek-back-and-read-forward, it will return the |
| 225 | info of last page of the matching serial number instead of the very |
| 226 | last page. If no page of the specified serialno is seen, it will |
| 227 | return the info of last page and alter *serialno. */ |
| 228 | static ogg_int64_tcxx . . $ ogg_int64_t# _get_prev_page_serialcxx . . $ _get_prev_page_serial(afd83aa911b253a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf, |
| 229 | ogg_uint32_tcxx . . $ ogg_uint32_t# *serial_list, int serial_n, |
| 230 | int *serialno, ogg_int64_tcxx . . $ ogg_int64_t# *granpos){ |
| 231 | ogg_pagecxx . . $ ogg_page# og; |
| 232 | ogg_int64_tcxx . . $ ogg_int64_t# begin=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 233 | ogg_int64_tcxx . . $ ogg_int64_t# end=begin; |
| 234 | ogg_int64_tcxx . . $ ogg_int64_t# ret; |
| 235 | |
| 236 | ogg_int64_tcxx . . $ ogg_int64_t# prefoffset=-1; |
| 237 | ogg_int64_tcxx . . $ ogg_int64_t# offset=-1; |
| 238 | ogg_int64_tcxx . . $ ogg_int64_t# ret_serialno=-1; |
| 239 | ogg_int64_tcxx . . $ ogg_int64_t# ret_gran=-1; |
| 240 | |
| 241 | while(offset==-1){ |
| 242 | begin-=CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!; |
| 243 | if(begin<0) |
| 244 | begin=0; |
| 245 | |
| 246 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,begin); |
| 247 | if(ret)return(ret); |
| 248 | |
| 249 | while(vf->offsetcxx . . $ OggVorbis_File#offset.<end){ |
| 250 | ret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,end-vf->offsetcxx . . $ OggVorbis_File#offset.); |
| 251 | if(ret==OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!)return(OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!); |
| 252 | if(ret<0){ |
| 253 | break; |
| 254 | }else{ |
| 255 | ret_serialno=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 256 | ret_gran=ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og); |
| 257 | offset=ret; |
| 258 | |
| 259 | if((ogg_uint32_tcxx . . $ ogg_uint32_t#)ret_serialno == *serialno){ |
| 260 | prefoffset=ret; |
| 261 | *granpos=ret_gran; |
| 262 | } |
| 263 | |
| 264 | if(!_lookup_serialnocxx . . $ _lookup_serialno(ce67f49aceb987ce).((ogg_uint32_tcxx . . $ ogg_uint32_t#)ret_serialno,serial_list,serial_n)){ |
| 265 | /* we fell off the end of the link, which means we seeked |
| 266 | back too far and shouldn't have been looking in that link |
| 267 | to begin with. If we found the preferred serial number, |
| 268 | forget that we saw it. */ |
| 269 | prefoffset=-1; |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | /* we're not interested in the page... just the serialno and granpos. */ |
| 276 | if(prefoffset>=0)return(prefoffset); |
| 277 | |
| 278 | *serialno = ret_serialno; |
| 279 | *granpos = ret_gran; |
| 280 | return(offset); |
| 281 | |
| 282 | } |
| 283 | |
| 284 | /* uses the local ogg_stream storage in vf; this is important for |
| 285 | non-streaming input sources */ |
| 286 | static int _fetch_headerscxx . . $ _fetch_headers(78967c9420ed470).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,vorbis_infocxx . . $ vorbis_info# *vi,vorbis_commentcxx . . $ vorbis_comment# *vc, |
| 287 | ogg_uint32_tcxx . . $ ogg_uint32_t# **serialno_list, int *serialno_n, |
| 288 | ogg_pagecxx . . $ ogg_page# *og_ptr){ |
| 289 | ogg_pagecxx . . $ ogg_page# og; |
| 290 | ogg_packetcxx . . $ ogg_packet# op; |
| 291 | int i,ret; |
| 292 | int allbos=0; |
| 293 | |
| 294 | if(!og_ptr){ |
| 295 | ogg_int64_tcxx . . $ ogg_int64_t# llret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!); |
| 296 | if(llret==OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!)return(OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!); |
| 297 | if(llret<0)return(OV_ENOTVORBIScxx . . $ `mednafen/tremor/ivorbiscodec.h:191:9`!); |
| 298 | og_ptr=&og; |
| 299 | } |
| 300 | |
| 301 | vorbis_info_initcxx . . $ vorbis_info_init(d534a068b27cdae4).(vi); |
| 302 | vorbis_comment_initcxx . . $ vorbis_comment_init(93d47bffb8aa4dc6).(vc); |
| 303 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!; |
| 304 | |
| 305 | /* extract the serialnos of all BOS pages + the first set of vorbis |
| 306 | headers we see in the link */ |
| 307 | |
| 308 | while(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(og_ptr)){ |
| 309 | if(serialno_list){ |
| 310 | if(_lookup_page_serialnocxx . . $ _lookup_page_serialno(61607cd81868850e).(og_ptr,*serialno_list,*serialno_n)){ |
| 311 | /* a dupe serialnumber in an initial header packet set == invalid stream */ |
| 312 | if(*serialno_list)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(*serialno_list); |
| 313 | *serialno_list=0; |
| 314 | *serialno_n=0; |
| 315 | ret=OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!; |
| 316 | goto bail_header; |
| 317 | } |
| 318 | |
| 319 | _add_serialnocxx . . $ _add_serialno(6eb8d6367eed44cf).(og_ptr,serialno_list,serialno_n); |
| 320 | } |
| 321 | |
| 322 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!){ |
| 323 | /* we don't have a vorbis stream in this link yet, so begin |
| 324 | prospective stream setup. We need a stream to get packets */ |
| 325 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og_ptr)); |
| 326 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,og_ptr); |
| 327 | |
| 328 | if(ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op) > 0 && |
| 329 | vorbis_synthesis_idheadercxx . . $ vorbis_synthesis_idheader(93d9f7a6e445c2aa).(&op)){ |
| 330 | /* vorbis header; continue setup */ |
| 331 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!; |
| 332 | if((ret=vorbis_synthesis_headerincxx . . $ vorbis_synthesis_headerin(3ae6e73fba03d214).(vi,vc,&op))){ |
| 333 | ret=OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!; |
| 334 | goto bail_header; |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | /* get next page */ |
| 340 | { |
| 341 | ogg_int64_tcxx . . $ ogg_int64_t# llret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,og_ptr,CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!); |
| 342 | if(llret==OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!){ |
| 343 | ret=OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!; |
| 344 | goto bail_header; |
| 345 | } |
| 346 | if(llret<0){ |
| 347 | ret=OV_ENOTVORBIScxx . . $ `mednafen/tremor/ivorbiscodec.h:191:9`!; |
| 348 | goto bail_header; |
| 349 | } |
| 350 | |
| 351 | /* if this page also belongs to our vorbis stream, submit it and break */ |
| 352 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`! && |
| 353 | vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_cccabde66011c92d_3#serialno. == ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og_ptr)){ |
| 354 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,og_ptr); |
| 355 | break; |
| 356 | } |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.!=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!){ |
| 361 | ret = OV_ENOTVORBIScxx . . $ `mednafen/tremor/ivorbiscodec.h:191:9`!; |
| 362 | goto bail_header; |
| 363 | } |
| 364 | |
| 365 | while(1){ |
| 366 | |
| 367 | i=0; |
| 368 | while(i<2){ /* get a page loop */ |
| 369 | |
| 370 | while(i<2){ /* get a packet loop */ |
| 371 | |
| 372 | int result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op); |
| 373 | if(result==0)break; |
| 374 | if(result==-1){ |
| 375 | ret=OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!; |
| 376 | goto bail_header; |
| 377 | } |
| 378 | |
| 379 | if((ret=vorbis_synthesis_headerincxx . . $ vorbis_synthesis_headerin(3ae6e73fba03d214).(vi,vc,&op))) |
| 380 | goto bail_header; |
| 381 | |
| 382 | i++; |
| 383 | } |
| 384 | |
| 385 | while(i<2){ |
| 386 | if(_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,og_ptr,CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!)<0){ |
| 387 | ret=OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!; |
| 388 | goto bail_header; |
| 389 | } |
| 390 | |
| 391 | /* if this page belongs to the correct stream, go parse it */ |
| 392 | if(vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_cccabde66011c92d_3#serialno. == ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og_ptr)){ |
| 393 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,og_ptr); |
| 394 | break; |
| 395 | } |
| 396 | |
| 397 | /* if we never see the final vorbis headers before the link |
| 398 | ends, abort */ |
| 399 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(og_ptr)){ |
| 400 | if(allbos){ |
| 401 | ret = OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!; |
| 402 | goto bail_header; |
| 403 | }else |
| 404 | allbos=1; |
| 405 | } |
| 406 | |
| 407 | /* otherwise, keep looking */ |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | return 0; |
| 412 | } |
| 413 | |
| 414 | bail_header: |
| 415 | vorbis_info_clearcxx . . $ vorbis_info_clear(d534a068b27cdae4).(vi); |
| 416 | vorbis_comment_clearcxx . . $ vorbis_comment_clear(93d47bffb8aa4dc6).(vc); |
| 417 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!; |
| 418 | |
| 419 | return ret; |
| 420 | } |
| 421 | |
| 422 | /* Starting from current cursor position, get initial PCM offset of |
| 423 | next page. Consumes the page in the process without decoding |
| 424 | audio, however this is only called during stream parsing upon |
| 425 | seekable open. */ |
| 426 | static ogg_int64_tcxx . . $ ogg_int64_t# _initial_pcmoffsetcxx . . $ _initial_pcmoffset(3d36dd850c0dca84).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf, vorbis_infocxx . . $ vorbis_info# *vi){ |
| 427 | ogg_pagecxx . . $ ogg_page# og; |
| 428 | ogg_int64_tcxx . . $ ogg_int64_t# accumulated=0; |
| 429 | long lastblock=-1; |
| 430 | int result; |
| 431 | int serialno = vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_cccabde66011c92d_3#serialno.; |
| 432 | |
| 433 | while(1){ |
| 434 | ogg_packetcxx . . $ ogg_packet# op; |
| 435 | if(_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1)<0) |
| 436 | break; /* should not be possible unless the file is truncated/mangled */ |
| 437 | |
| 438 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(&og)) break; |
| 439 | if(ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)!=serialno) continue; |
| 440 | |
| 441 | /* count blocksizes of all frames in the page */ |
| 442 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 443 | while((result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op))){ |
| 444 | if(result>0){ /* ignore holes */ |
| 445 | long thisblock=vorbis_packet_blocksizecxx . . $ vorbis_packet_blocksize(5c730016bfddf4b1).(vi,&op); |
| 446 | if(lastblock!=-1) |
| 447 | accumulated+=(lastblock+thisblock)>>2; |
| 448 | lastblock=thisblock; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | if(ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og)!=-1){ |
| 453 | /* pcm offset of last packet on the first audio page */ |
| 454 | accumulated= ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og)-accumulated; |
| 455 | break; |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | /* less than zero? This is a stream with samples trimmed off |
| 460 | the beginning, a normal occurrence; set the offset to zero */ |
| 461 | if(accumulated<0)accumulated=0; |
| 462 | |
| 463 | return accumulated; |
| 464 | } |
| 465 | |
| 466 | /* finds each bitstream link one at a time using a bisection search |
| 467 | (has to begin by knowing the offset of the lb's initial page). |
| 468 | Recurses for each link so it can alloc the link storage after |
| 469 | finding them all, then unroll and fill the cache at the same time */ |
| 470 | static int _bisect_forward_serialnocxx . . $ _bisect_forward_serialno(f9d1931309e3f5ce).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf, |
| 471 | ogg_int64_tcxx . . $ ogg_int64_t# begin, |
| 472 | ogg_int64_tcxx . . $ ogg_int64_t# searched, |
| 473 | ogg_int64_tcxx . . $ ogg_int64_t# end, |
| 474 | ogg_int64_tcxx . . $ ogg_int64_t# endgran, |
| 475 | int endserial, |
| 476 | ogg_uint32_tcxx . . $ ogg_uint32_t# *currentno_list, |
| 477 | int currentnos, |
| 478 | long m){ |
| 479 | ogg_int64_tcxx . . $ ogg_int64_t# pcmoffset; |
| 480 | ogg_int64_tcxx . . $ ogg_int64_t# dataoffset=searched; |
| 481 | ogg_int64_tcxx . . $ ogg_int64_t# endsearched=end; |
| 482 | ogg_int64_tcxx . . $ ogg_int64_t# next=end; |
| 483 | ogg_int64_tcxx . . $ ogg_int64_t# searchgran=-1; |
| 484 | ogg_pagecxx . . $ ogg_page# og; |
| 485 | ogg_int64_tcxx . . $ ogg_int64_t# ret,last; |
| 486 | int serialno = vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_cccabde66011c92d_3#serialno.; |
| 487 | |
| 488 | /* invariants: |
| 489 | we have the headers and serialnos for the link beginning at 'begin' |
| 490 | we have the offset and granpos of the last page in the file (potentially |
| 491 | not a page we care about) |
| 492 | */ |
| 493 | |
| 494 | /* Is the last page in our list of current serialnumbers? */ |
| 495 | if(_lookup_serialnocxx . . $ _lookup_serialno(ce67f49aceb987ce).(endserial,currentno_list,currentnos)){ |
| 496 | |
| 497 | /* last page is in the starting serialno list, so we've bisected |
| 498 | down to (or just started with) a single link. Now we need to |
| 499 | find the last vorbis page belonging to the first vorbis stream |
| 500 | for this link. */ |
| 501 | |
| 502 | while(endserial != serialno){ |
| 503 | endserial = serialno; |
| 504 | vf->offsetcxx . . $ OggVorbis_File#offset.=_get_prev_page_serialcxx . . $ _get_prev_page_serial(afd83aa911b253a).(vf,currentno_list,currentnos,&endserial,&endgran); |
| 505 | } |
| 506 | |
| 507 | vf->linkscxx . . $ OggVorbis_File#links.=m+1; |
| 508 | if(vf->offsetscxx . . $ OggVorbis_File#offsets.)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vf->offsetscxx . . $ OggVorbis_File#offsets.); |
| 509 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vf->serialnoscxx . . $ OggVorbis_File#serialnos.); |
| 510 | if(vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.); |
| 511 | |
| 512 | vf->offsetscxx . . $ OggVorbis_File#offsets.=_ogg_malloccxx . . $ `mednafen/tremor/os_types.h:22:9`!((vf->linkscxx . . $ OggVorbis_File#links.+1)*sizeof(*vf->offsetscxx . . $ OggVorbis_File#offsets.)); |
| 513 | vf->vicxx . . $ OggVorbis_File#vi.=_ogg_realloccxx . . $ `mednafen/tremor/os_types.h:24:9`!(vf->vicxx . . $ OggVorbis_File#vi.,vf->linkscxx . . $ OggVorbis_File#links.*sizeof(*vf->vicxx . . $ OggVorbis_File#vi.)); |
| 514 | vf->vccxx . . $ OggVorbis_File#vc.=_ogg_realloccxx . . $ `mednafen/tremor/os_types.h:24:9`!(vf->vccxx . . $ OggVorbis_File#vc.,vf->linkscxx . . $ OggVorbis_File#links.*sizeof(*vf->vccxx . . $ OggVorbis_File#vc.)); |
| 515 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.=_ogg_malloccxx . . $ `mednafen/tremor/os_types.h:22:9`!(vf->linkscxx . . $ OggVorbis_File#links.*sizeof(*vf->serialnoscxx . . $ OggVorbis_File#serialnos.)); |
| 516 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.=_ogg_malloccxx . . $ `mednafen/tremor/os_types.h:22:9`!(vf->linkscxx . . $ OggVorbis_File#links.*sizeof(*vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.)); |
| 517 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.=_ogg_malloccxx . . $ `mednafen/tremor/os_types.h:22:9`!(vf->linkscxx . . $ OggVorbis_File#links.*2*sizeof(*vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.)); |
| 518 | |
| 519 | vf->offsetscxx . . $ OggVorbis_File#offsets.[m+1]=end; |
| 520 | vf->offsetscxx . . $ OggVorbis_File#offsets.[m]=begin; |
| 521 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+1]=endgran; |
| 522 | |
| 523 | }else{ |
| 524 | |
| 525 | ogg_uint32_tcxx . . $ ogg_uint32_t# *next_serialno_list=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 526 | int next_serialnos=0; |
| 527 | vorbis_infocxx . . $ vorbis_info# vi; |
| 528 | vorbis_commentcxx . . $ vorbis_comment# vc; |
| 529 | |
| 530 | /* the below guards against garbage seperating the last and |
| 531 | first pages of two links. */ |
| 532 | while(searched<endsearched){ |
| 533 | ogg_int64_tcxx . . $ ogg_int64_t# bisect; |
| 534 | |
| 535 | if(endsearched-searched<CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!){ |
| 536 | bisect=searched; |
| 537 | }else{ |
| 538 | bisect=(searched+endsearched)/2; |
| 539 | } |
| 540 | |
| 541 | if(bisect != vf->offsetcxx . . $ OggVorbis_File#offset.){ |
| 542 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,bisect); |
| 543 | if(ret)return(ret); |
| 544 | } |
| 545 | |
| 546 | last=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1); |
| 547 | if(last==OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!)return(OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!); |
| 548 | if(last<0 || !_lookup_page_serialnocxx . . $ _lookup_page_serialno(61607cd81868850e).(&og,currentno_list,currentnos)){ |
| 549 | endsearched=bisect; |
| 550 | if(last>=0)next=last; |
| 551 | }else{ |
| 552 | searched=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 553 | } |
| 554 | } |
| 555 | |
| 556 | /* Bisection point found */ |
| 557 | |
| 558 | /* for the time being, fetch end PCM offset the simple way */ |
| 559 | { |
| 560 | int testserial = serialno+1; |
| 561 | vf->offsetcxx . . $ OggVorbis_File#offset. = next; |
| 562 | while(testserial != serialno){ |
| 563 | testserial = serialno; |
| 564 | vf->offsetcxx . . $ OggVorbis_File#offset.=_get_prev_page_serialcxx . . $ _get_prev_page_serial(afd83aa911b253a).(vf,currentno_list,currentnos,&testserial,&searchgran); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | if(vf->offsetcxx . . $ OggVorbis_File#offset.!=next){ |
| 569 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,next); |
| 570 | if(ret)return(ret); |
| 571 | } |
| 572 | |
| 573 | ret=_fetch_headerscxx . . $ _fetch_headers(78967c9420ed470).(vf,&vi,&vc,&next_serialno_list,&next_serialnos,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 574 | if(ret)return(ret); |
| 575 | serialno = vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_cccabde66011c92d_3#serialno.; |
| 576 | dataoffset = vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 577 | |
| 578 | /* this will consume a page, however the next bistection always |
| 579 | starts with a raw seek */ |
| 580 | pcmoffset = _initial_pcmoffsetcxx . . $ _initial_pcmoffset(3d36dd850c0dca84).(vf,&vi); |
| 581 | |
| 582 | ret=_bisect_forward_serialnocxx . . $ _bisect_forward_serialno(f9d1931309e3f5ce).(vf,next,vf->offsetcxx . . $ OggVorbis_File#offset.,end,endgran,endserial, |
| 583 | next_serialno_list,next_serialnos,m+1); |
| 584 | if(ret)return(ret); |
| 585 | |
| 586 | if(next_serialno_list)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(next_serialno_list); |
| 587 | |
| 588 | vf->offsetscxx . . $ OggVorbis_File#offsets.[m+1]=next; |
| 589 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.[m+1]=serialno; |
| 590 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[m+1]=dataoffset; |
| 591 | |
| 592 | vf->vicxx . . $ OggVorbis_File#vi.[m+1]=vi; |
| 593 | vf->vccxx . . $ OggVorbis_File#vc.[m+1]=vc; |
| 594 | |
| 595 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+1]=searchgran; |
| 596 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+2]=pcmoffset; |
| 597 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+3]-=pcmoffset; |
| 598 | |
| 599 | } |
| 600 | return(0); |
| 601 | } |
| 602 | |
| 603 | static int _make_decode_readycxx . . $ _make_decode_ready(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 604 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!)return 0; |
| 605 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!)return OV_EFAULTcxx . . $ `mednafen/tremor/ivorbiscodec.h:188:9`!; |
| 606 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 607 | if(vorbis_synthesis_initcxx . . $ vorbis_synthesis_init(eac5c897194134f0).(&vf->vdcxx . . $ OggVorbis_File#vd.,vf->vicxx . . $ OggVorbis_File#vi.+vf->current_linkcxx . . $ OggVorbis_File#current_link.)) |
| 608 | return OV_EBADLINKcxx . . $ `mednafen/tremor/ivorbiscodec.h:196:9`!; |
| 609 | }else{ |
| 610 | if(vorbis_synthesis_initcxx . . $ vorbis_synthesis_init(eac5c897194134f0).(&vf->vdcxx . . $ OggVorbis_File#vd.,vf->vicxx . . $ OggVorbis_File#vi.)) |
| 611 | return OV_EBADLINKcxx . . $ `mednafen/tremor/ivorbiscodec.h:196:9`!; |
| 612 | } |
| 613 | vorbis_block_initcxx . . $ vorbis_block_init(c8f1c0cf9c31dd14).(&vf->vdcxx . . $ OggVorbis_File#vd.,&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 614 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=INITSETcxx . . $ `mednafen/tremor/ivorbisfile.h:51:10`!; |
| 615 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0; |
| 616 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0; |
| 617 | return 0; |
| 618 | } |
| 619 | |
| 620 | static int _open_seekable2cxx . . $ _open_seekable2(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 621 | ogg_int64_tcxx . . $ ogg_int64_t# dataoffset=vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[0],end,endgran=-1; |
| 622 | int endserial=vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_cccabde66011c92d_3#serialno.; |
| 623 | int serialno=vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_cccabde66011c92d_3#serialno.; |
| 624 | |
| 625 | /* we're partially open and have a first link header state in |
| 626 | storage in vf */ |
| 627 | |
| 628 | /* fetch initial PCM offset */ |
| 629 | ogg_int64_tcxx . . $ ogg_int64_t# pcmoffset = _initial_pcmoffsetcxx . . $ _initial_pcmoffset(3d36dd850c0dca84).(vf,vf->vicxx . . $ OggVorbis_File#vi.); |
| 630 | |
| 631 | /* we can seek, so set out learning all about this file */ |
| 632 | if(vf->callbackscxx . . $ OggVorbis_File#callbacks..seek_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#seek_func. && vf->callbackscxx . . $ OggVorbis_File#callbacks..tell_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#tell_func.){ |
| 633 | (vf->callbackscxx . . $ OggVorbis_File#callbacks..seek_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#seek_func.)(vf->datasourcecxx . . $ OggVorbis_File#datasource.,0,SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:112:9`!); |
| 634 | vf->offsetcxx . . $ OggVorbis_File#offset.=vf->endcxx . . $ OggVorbis_File#end.=(vf->callbackscxx . . $ OggVorbis_File#callbacks..tell_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#tell_func.)(vf->datasourcecxx . . $ OggVorbis_File#datasource.); |
| 635 | }else{ |
| 636 | vf->offsetcxx . . $ OggVorbis_File#offset.=vf->endcxx . . $ OggVorbis_File#end.=-1; |
| 637 | } |
| 638 | |
| 639 | /* If seek_func is implemented, tell_func must also be implemented */ |
| 640 | if(vf->endcxx . . $ OggVorbis_File#end.==-1) return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 641 | |
| 642 | /* Get the offset of the last page of the physical bitstream, or, if |
| 643 | we're lucky the last vorbis page of this link as most OggVorbis |
| 644 | files will contain a single logical bitstream */ |
| 645 | end=_get_prev_page_serialcxx . . $ _get_prev_page_serial(afd83aa911b253a).(vf,vf->serialnoscxx . . $ OggVorbis_File#serialnos.+2,vf->serialnoscxx . . $ OggVorbis_File#serialnos.[1],&endserial,&endgran); |
| 646 | if(end<0)return(end); |
| 647 | |
| 648 | /* now determine bitstream structure recursively */ |
| 649 | if(_bisect_forward_serialnocxx . . $ _bisect_forward_serialno(f9d1931309e3f5ce).(vf,0,dataoffset,vf->offsetcxx . . $ OggVorbis_File#offset.,endgran,endserial, |
| 650 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.+2,vf->serialnoscxx . . $ OggVorbis_File#serialnos.[1],0)<0)return(OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!); |
| 651 | |
| 652 | vf->offsetscxx . . $ OggVorbis_File#offsets.[0]=0; |
| 653 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.[0]=serialno; |
| 654 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[0]=dataoffset; |
| 655 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[0]=pcmoffset; |
| 656 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[1]-=pcmoffset; |
| 657 | |
| 658 | return(ov_raw_seekcxx . . $ ov_raw_seek(2602c1e715810f3a).(vf,dataoffset)); |
| 659 | } |
| 660 | |
| 661 | /* clear out the current logical bitstream decoder */ |
| 662 | static void _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 663 | vorbis_dsp_clearcxx . . $ vorbis_dsp_clear(1841c7801a59e076).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 664 | vorbis_block_clearcxx . . $ vorbis_block_clear(e7ca6336a14cf342).(&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 665 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!; |
| 666 | } |
| 667 | |
| 668 | /* fetch and process a packet. Handles the case where we're at a |
| 669 | bitstream boundary and dumps the decoding machine. If the decoding |
| 670 | machine is unloaded, it loads it. It also keeps pcm_offset up to |
| 671 | date (seek and read both use this. seek uses a special hack with |
| 672 | readp). |
| 673 | |
| 674 | return: <0) error, OV_HOLE (lost packet) or OV_EOF |
| 675 | 0) need more data (only if readp==0) |
| 676 | 1) got a packet |
| 677 | */ |
| 678 | |
| 679 | static int _fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf, |
| 680 | ogg_packetcxx . . $ ogg_packet# *op_in, |
| 681 | int readp, |
| 682 | int spanp){ |
| 683 | ogg_pagecxx . . $ ogg_page# og; |
| 684 | |
| 685 | /* handle one packet. Try to fetch it from current stream state */ |
| 686 | /* extract packets from page */ |
| 687 | while(1){ |
| 688 | |
| 689 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!){ |
| 690 | int ret=_make_decode_readycxx . . $ _make_decode_ready(231cee6479b09f2b).(vf); |
| 691 | if(ret<0)return ret; |
| 692 | } |
| 693 | |
| 694 | /* process a packet if we can. If the machine isn't loaded, |
| 695 | neither is a page */ |
| 696 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==INITSETcxx . . $ `mednafen/tremor/ivorbisfile.h:51:10`!){ |
| 697 | while(1) { |
| 698 | ogg_packetcxx . . $ ogg_packet# op; |
| 699 | ogg_packetcxx . . $ ogg_packet# *op_ptr=(op_in?op_in:&op); |
| 700 | int result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,op_ptr); |
| 701 | ogg_int64_tcxx . . $ ogg_int64_t# granulepos; |
| 702 | |
| 703 | op_in=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 704 | if(result==-1)return(OV_HOLEcxx . . $ `mednafen/tremor/ivorbiscodec.h:185:9`!); /* hole in the data. */ |
| 705 | if(result>0){ |
| 706 | /* got a packet. process it */ |
| 707 | granulepos=op_ptr->granuleposcxx . . $ $anonymous_type_cccabde66011c92d_4#granulepos.; |
| 708 | if(!vorbis_synthesiscxx . . $ vorbis_synthesis(e9de88148c52a299).(&vf->vbcxx . . $ OggVorbis_File#vb.,op_ptr)){ /* lazy check for lazy |
| 709 | header handling. The |
| 710 | header packets aren't |
| 711 | audio, so if/when we |
| 712 | submit them, |
| 713 | vorbis_synthesis will |
| 714 | reject them */ |
| 715 | |
| 716 | /* suck in the synthesis data and track bitrate */ |
| 717 | { |
| 718 | int oldsamples=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(a5862dcc143b250).(&vf->vdcxx . . $ OggVorbis_File#vd.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 719 | /* for proper use of libvorbis within libvorbisfile, |
| 720 | oldsamples will always be zero. */ |
| 721 | if(oldsamples)return(OV_EFAULTcxx . . $ `mednafen/tremor/ivorbiscodec.h:188:9`!); |
| 722 | |
| 723 | vorbis_synthesis_blockincxx . . $ vorbis_synthesis_blockin(c8f1c0cf9c31dd14).(&vf->vdcxx . . $ OggVorbis_File#vd.,&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 724 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.+=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(a5862dcc143b250).(&vf->vdcxx . . $ OggVorbis_File#vd.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)-oldsamples; |
| 725 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.+=op_ptr->bytescxx . . $ $anonymous_type_cccabde66011c92d_4#bytes.*8; |
| 726 | } |
| 727 | |
| 728 | /* update the pcm offset. */ |
| 729 | if(granulepos!=-1 && !op_ptr->e_o_scxx . . $ $anonymous_type_cccabde66011c92d_4#e_o_s.){ |
| 730 | int link=(vf->seekablecxx . . $ OggVorbis_File#seekable.?vf->current_linkcxx . . $ OggVorbis_File#current_link.:0); |
| 731 | int i,samples; |
| 732 | |
| 733 | /* this packet has a pcm_offset on it (the last packet |
| 734 | completed on a page carries the offset) After processing |
| 735 | (above), we know the pcm position of the *last* sample |
| 736 | ready to be returned. Find the offset of the *first* |
| 737 | |
| 738 | As an aside, this trick is inaccurate if we begin |
| 739 | reading anew right at the last page; the end-of-stream |
| 740 | granulepos declares the last frame in the stream, and the |
| 741 | last packet of the last page may be a partial frame. |
| 742 | So, we need a previous granulepos from an in-sequence page |
| 743 | to have a reference point. Thus the !op_ptr->e_o_s clause |
| 744 | above */ |
| 745 | |
| 746 | if(vf->seekablecxx . . $ OggVorbis_File#seekable. && link>0) |
| 747 | granulepos-=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2]; |
| 748 | if(granulepos<0)granulepos=0; /* actually, this |
| 749 | shouldn't be possible |
| 750 | here unless the stream |
| 751 | is very broken */ |
| 752 | |
| 753 | samples=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(a5862dcc143b250).(&vf->vdcxx . . $ OggVorbis_File#vd.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 754 | |
| 755 | granulepos-=samples; |
| 756 | for(i=0;i<link;i++) |
| 757 | granulepos+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1]; |
| 758 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=granulepos; |
| 759 | } |
| 760 | return(1); |
| 761 | } |
| 762 | } |
| 763 | else |
| 764 | break; |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!){ |
| 769 | ogg_int64_tcxx . . $ ogg_int64_t# ret; |
| 770 | |
| 771 | while(1){ |
| 772 | /* the loop is not strictly necessary, but there's no sense in |
| 773 | doing the extra checks of the larger loop for the common |
| 774 | case in a multiplexed bistream where the page is simply |
| 775 | part of a different logical bitstream; keep reading until |
| 776 | we get one with the correct serialno */ |
| 777 | |
| 778 | if(!readp)return(0); |
| 779 | if((ret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1))<0){ |
| 780 | return(OV_EOFcxx . . $ `mednafen/tremor/ivorbiscodec.h:184:9`!); /* eof. leave unitialized */ |
| 781 | } |
| 782 | |
| 783 | /* bitrate tracking; add the header's bytes here, the body bytes |
| 784 | are done by packet above */ |
| 785 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.+=og.header_lencxx . . $ $anonymous_type_cccabde66011c92d_2#header_len.*8; |
| 786 | |
| 787 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==INITSETcxx . . $ `mednafen/tremor/ivorbisfile.h:51:10`!){ |
| 788 | if(vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.!=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)){ |
| 789 | |
| 790 | /* two possibilities: |
| 791 | 1) our decoding just traversed a bitstream boundary |
| 792 | 2) another stream is multiplexed into this logical section */ |
| 793 | |
| 794 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(&og)){ |
| 795 | /* boundary case */ |
| 796 | if(!spanp) |
| 797 | return(OV_EOFcxx . . $ `mednafen/tremor/ivorbiscodec.h:184:9`!); |
| 798 | |
| 799 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 800 | |
| 801 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 802 | vorbis_info_clearcxx . . $ vorbis_info_clear(d534a068b27cdae4).(vf->vicxx . . $ OggVorbis_File#vi.); |
| 803 | vorbis_comment_clearcxx . . $ vorbis_comment_clear(93d47bffb8aa4dc6).(vf->vccxx . . $ OggVorbis_File#vc.); |
| 804 | } |
| 805 | break; |
| 806 | |
| 807 | }else |
| 808 | continue; /* possibility #2 */ |
| 809 | } |
| 810 | } |
| 811 | |
| 812 | break; |
| 813 | } |
| 814 | } |
| 815 | |
| 816 | /* Do we need to load a new machine before submitting the page? */ |
| 817 | /* This is different in the seekable and non-seekable cases. |
| 818 | |
| 819 | In the seekable case, we already have all the header |
| 820 | information loaded and cached; we just initialize the machine |
| 821 | with it and continue on our merry way. |
| 822 | |
| 823 | In the non-seekable (streaming) case, we'll only be at a |
| 824 | boundary if we just left the previous logical bitstream and |
| 825 | we're now nominally at the header of the next bitstream |
| 826 | */ |
| 827 | |
| 828 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.!=INITSETcxx . . $ `mednafen/tremor/ivorbisfile.h:51:10`!){ |
| 829 | int link; |
| 830 | |
| 831 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!){ |
| 832 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 833 | ogg_uint32_tcxx . . $ ogg_uint32_t# serialno = ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 834 | |
| 835 | /* match the serialno to bitstream section. We use this rather than |
| 836 | offset positions to avoid problems near logical bitstream |
| 837 | boundaries */ |
| 838 | |
| 839 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++) |
| 840 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]==serialno)break; |
| 841 | |
| 842 | if(link==vf->linkscxx . . $ OggVorbis_File#links.) continue; /* not the desired Vorbis |
| 843 | bitstream section; keep |
| 844 | trying */ |
| 845 | |
| 846 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=serialno; |
| 847 | vf->current_linkcxx . . $ OggVorbis_File#current_link.=link; |
| 848 | |
| 849 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); |
| 850 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!; |
| 851 | |
| 852 | }else{ |
| 853 | /* we're streaming */ |
| 854 | /* fetch the three header packets, build the info struct */ |
| 855 | |
| 856 | int ret=_fetch_headerscxx . . $ _fetch_headers(78967c9420ed470).(vf,vf->vicxx . . $ OggVorbis_File#vi.,vf->vccxx . . $ OggVorbis_File#vc.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,&og); |
| 857 | if(ret)return(ret); |
| 858 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_cccabde66011c92d_3#serialno.; |
| 859 | vf->current_linkcxx . . $ OggVorbis_File#current_link.++; |
| 860 | link=0; |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | /* the buffered page is the data we want, and we're ready for it; |
| 866 | add it to the stream state */ |
| 867 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 868 | |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | /* if, eg, 64 bit stdio is configured by default, this will build with |
| 873 | fseek64 */ |
| 874 | static int _fseek64_wrapcxx . . $ _fseek64_wrap(543fae30d249f6b1).(FILEcxx . . $ FILE# *f,ogg_int64_tcxx . . $ ogg_int64_t# off,int whence){ |
| 875 | if(f==NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)return(-1); |
| 876 | return fseekcxx . . $ fseek(543fae30d249f6b1).(f,off,whence); |
| 877 | } |
| 878 | |
| 879 | static int _ov_open1cxx . . $ _ov_open1(80dfd33e0e406a85).(void *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf,const char *initial, |
| 880 | long ibytes, ov_callbackscxx . . $ ov_callbacks# callbacks){ |
| 881 | int offsettest=((f && callbacks.seek_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#seek_func.)?callbacks.seek_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#seek_func.(f,0,SEEK_CURcxx . . $ `<external>/232824719582829767/stdio.h:111:9`!):-1); |
| 882 | ogg_uint32_tcxx . . $ ogg_uint32_t# *serialno_list=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 883 | int serialno_list_size=0; |
| 884 | int ret; |
| 885 | |
| 886 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(vf,0,sizeof(*vf)); |
| 887 | vf->datasourcecxx . . $ OggVorbis_File#datasource.=f; |
| 888 | vf->callbackscxx . . $ OggVorbis_File#callbacks. = callbacks; |
| 889 | |
| 890 | /* init the framing state */ |
| 891 | ogg_sync_initcxx . . $ ogg_sync_init(4d079e1537bb6e53).(&vf->oycxx . . $ OggVorbis_File#oy.); |
| 892 | |
| 893 | /* perhaps some data was previously read into a buffer for testing |
| 894 | against other stream types. Allow initialization from this |
| 895 | previously read data (especially as we may be reading from a |
| 896 | non-seekable stream) */ |
| 897 | if(initial){ |
| 898 | char *buffer=ogg_sync_buffercxx . . $ ogg_sync_buffer(16ea7c6d847c120d).(&vf->oycxx . . $ OggVorbis_File#oy.,ibytes); |
| 899 | memcpycxx . . $ memcpy(cc817cb175f282d).(buffer,initial,ibytes); |
| 900 | ogg_sync_wrotecxx . . $ ogg_sync_wrote(7ecdafb9a73216e5).(&vf->oycxx . . $ OggVorbis_File#oy.,ibytes); |
| 901 | } |
| 902 | |
| 903 | /* can we seek? Stevens suggests the seek test was portable */ |
| 904 | if(offsettest!=-1)vf->seekablecxx . . $ OggVorbis_File#seekable.=1; |
| 905 | |
| 906 | /* No seeking yet; Set up a 'single' (current) logical bitstream |
| 907 | entry for partial open */ |
| 908 | vf->linkscxx . . $ OggVorbis_File#links.=1; |
| 909 | vf->vicxx . . $ OggVorbis_File#vi.=_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(vf->linkscxx . . $ OggVorbis_File#links.,sizeof(*vf->vicxx . . $ OggVorbis_File#vi.)); |
| 910 | vf->vccxx . . $ OggVorbis_File#vc.=_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(vf->linkscxx . . $ OggVorbis_File#links.,sizeof(*vf->vccxx . . $ OggVorbis_File#vc.)); |
| 911 | ogg_stream_initcxx . . $ ogg_stream_init(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,-1); /* fill in the serialno later */ |
| 912 | |
| 913 | /* Fetch all BOS pages, store the vorbis header and all seen serial |
| 914 | numbers, load subsequent vorbis setup headers */ |
| 915 | if((ret=_fetch_headerscxx . . $ _fetch_headers(78967c9420ed470).(vf,vf->vicxx . . $ OggVorbis_File#vi.,vf->vccxx . . $ OggVorbis_File#vc.,&serialno_list,&serialno_list_size,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))<0){ |
| 916 | vf->datasourcecxx . . $ OggVorbis_File#datasource.=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 917 | ov_clearcxx . . $ ov_clear(231cee6479b09f2b).(vf); |
| 918 | }else{ |
| 919 | /* serial number list for first link needs to be held somewhere |
| 920 | for second stage of seekable stream open; this saves having to |
| 921 | seek/reread first link's serialnumber data then. */ |
| 922 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.=_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(serialno_list_size+2,sizeof(*vf->serialnoscxx . . $ OggVorbis_File#serialnos.)); |
| 923 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.[0]=vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_cccabde66011c92d_3#serialno.; |
| 924 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.[1]=serialno_list_size; |
| 925 | memcpycxx . . $ memcpy(cc817cb175f282d).(vf->serialnoscxx . . $ OggVorbis_File#serialnos.+2,serialno_list,serialno_list_size*sizeof(*vf->serialnoscxx . . $ OggVorbis_File#serialnos.)); |
| 926 | |
| 927 | vf->offsetscxx . . $ OggVorbis_File#offsets.=_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(1,sizeof(*vf->offsetscxx . . $ OggVorbis_File#offsets.)); |
| 928 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.=_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(1,sizeof(*vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.)); |
| 929 | vf->offsetscxx . . $ OggVorbis_File#offsets.[0]=0; |
| 930 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[0]=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 931 | |
| 932 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=PARTOPENcxx . . $ `mednafen/tremor/ivorbisfile.h:48:10`!; |
| 933 | } |
| 934 | if(serialno_list)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(serialno_list); |
| 935 | return(ret); |
| 936 | } |
| 937 | |
| 938 | static int _ov_open2cxx . . $ _ov_open2(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 939 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state. != PARTOPENcxx . . $ `mednafen/tremor/ivorbisfile.h:48:10`!) return OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!; |
| 940 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!; |
| 941 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 942 | int ret=_open_seekable2cxx . . $ _open_seekable2(231cee6479b09f2b).(vf); |
| 943 | if(ret){ |
| 944 | vf->datasourcecxx . . $ OggVorbis_File#datasource.=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 945 | ov_clearcxx . . $ ov_clear(231cee6479b09f2b).(vf); |
| 946 | } |
| 947 | return(ret); |
| 948 | }else |
| 949 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!; |
| 950 | |
| 951 | return 0; |
| 952 | } |
| 953 | |
| 954 | |
| 955 | /* clear out the OggVorbis_File struct */ |
| 956 | int ov_clearcxx . . $ ov_clear(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 957 | if(vf){ |
| 958 | vorbis_block_clearcxx . . $ vorbis_block_clear(e7ca6336a14cf342).(&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 959 | vorbis_dsp_clearcxx . . $ vorbis_dsp_clear(1841c7801a59e076).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 960 | ogg_stream_clearcxx . . $ ogg_stream_clear(d9e3535bee9e7016).(&vf->oscxx . . $ OggVorbis_File#os.); |
| 961 | |
| 962 | if(vf->vicxx . . $ OggVorbis_File#vi. && vf->linkscxx . . $ OggVorbis_File#links.){ |
| 963 | int i; |
| 964 | for(i=0;i<vf->linkscxx . . $ OggVorbis_File#links.;i++){ |
| 965 | vorbis_info_clearcxx . . $ vorbis_info_clear(d534a068b27cdae4).(vf->vicxx . . $ OggVorbis_File#vi.+i); |
| 966 | vorbis_comment_clearcxx . . $ vorbis_comment_clear(93d47bffb8aa4dc6).(vf->vccxx . . $ OggVorbis_File#vc.+i); |
| 967 | } |
| 968 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vf->vicxx . . $ OggVorbis_File#vi.); |
| 969 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vf->vccxx . . $ OggVorbis_File#vc.); |
| 970 | } |
| 971 | if(vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.); |
| 972 | if(vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.); |
| 973 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vf->serialnoscxx . . $ OggVorbis_File#serialnos.); |
| 974 | if(vf->offsetscxx . . $ OggVorbis_File#offsets.)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vf->offsetscxx . . $ OggVorbis_File#offsets.); |
| 975 | ogg_sync_clearcxx . . $ ogg_sync_clear(4d079e1537bb6e53).(&vf->oycxx . . $ OggVorbis_File#oy.); |
| 976 | if(vf->datasourcecxx . . $ OggVorbis_File#datasource. && vf->callbackscxx . . $ OggVorbis_File#callbacks..close_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#close_func.) |
| 977 | (vf->callbackscxx . . $ OggVorbis_File#callbacks..close_funccxx . . $ $anonymous_type_350a0c348c81a5af_0#close_func.)(vf->datasourcecxx . . $ OggVorbis_File#datasource.); |
| 978 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(vf,0,sizeof(*vf)); |
| 979 | } |
| 980 | #ifdef DEBUG_LEAKS |
| 981 | _VDBG_dump(); |
| 982 | #endif |
| 983 | return(0); |
| 984 | } |
| 985 | |
| 986 | /* inspects the OggVorbis file and finds/documents all the logical |
| 987 | bitstreams contained in it. Tries to be tolerant of logical |
| 988 | bitstream sections that are truncated/woogie. |
| 989 | |
| 990 | return: -1) error |
| 991 | 0) OK |
| 992 | */ |
| 993 | |
| 994 | int ov_open_callbackscxx . . $ ov_open_callbacks(80dfd33e0e406a85).(void *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf, |
| 995 | const char *initial,long ibytes,ov_callbackscxx . . $ ov_callbacks# callbacks){ |
| 996 | int ret=_ov_open1cxx . . $ _ov_open1(80dfd33e0e406a85).(f,vf,initial,ibytes,callbacks); |
| 997 | if(ret)return ret; |
| 998 | return _ov_open2cxx . . $ _ov_open2(231cee6479b09f2b).(vf); |
| 999 | } |
| 1000 | |
| 1001 | int ov_opencxx . . $ ov_open(14abe1420fd41867).(FILEcxx . . $ FILE# *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf,const char *initial,long ibytes){ |
| 1002 | ov_callbackscxx . . $ ov_callbacks# callbacks = { |
| 1003 | (size_t (*)(void *, size_t, size_t, void *)) freadcxx . . $ fread(738fc8ac1d711e58)., |
| 1004 | (int (*)(void *, ogg_int64_tcxx . . $ ogg_int64_t#, int)) _fseek64_wrapcxx . . $ _fseek64_wrap(543fae30d249f6b1)., |
| 1005 | (int (*)(void *)) fclosecxx . . $ fclose(89bc1efcdac0ca22)., |
| 1006 | (long (*)(void *)) ftellcxx . . $ ftell(1dcafcd8ef4c6e6c). |
| 1007 | }; |
| 1008 | |
| 1009 | return ov_open_callbackscxx . . $ ov_open_callbacks(80dfd33e0e406a85).((void *)f, vf, initial, ibytes, callbacks); |
| 1010 | } |
| 1011 | |
| 1012 | int ov_fopencxx . . $ ov_fopen(b3b59e4e0121f5e7).(const char *path,OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1013 | int ret; |
| 1014 | FILEcxx . . $ FILE# *f = fopencxx . . $ fopen(82ec0787cd37e0a3).(path,"rb"); |
| 1015 | if(!f) return -1; |
| 1016 | |
| 1017 | ret = ov_opencxx . . $ ov_open(14abe1420fd41867).(f,vf,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,0); |
| 1018 | if(ret) fclosecxx . . $ fclose(89bc1efcdac0ca22).(f); |
| 1019 | return ret; |
| 1020 | } |
| 1021 | |
| 1022 | |
| 1023 | /* Only partially open the vorbis file; test for Vorbisness, and load |
| 1024 | the headers for the first chain. Do not seek (although test for |
| 1025 | seekability). Use ov_test_open to finish opening the file, else |
| 1026 | ov_clear to close/free it. Same return codes as open. */ |
| 1027 | |
| 1028 | int ov_test_callbackscxx . . $ ov_test_callbacks(80dfd33e0e406a85).(void *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf, |
| 1029 | const char *initial,long ibytes,ov_callbackscxx . . $ ov_callbacks# callbacks) |
| 1030 | { |
| 1031 | return _ov_open1cxx . . $ _ov_open1(80dfd33e0e406a85).(f,vf,initial,ibytes,callbacks); |
| 1032 | } |
| 1033 | |
| 1034 | int ov_testcxx . . $ ov_test(14abe1420fd41867).(FILEcxx . . $ FILE# *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf,const char *initial,long ibytes){ |
| 1035 | ov_callbackscxx . . $ ov_callbacks# callbacks = { |
| 1036 | (size_t (*)(void *, size_t, size_t, void *)) freadcxx . . $ fread(738fc8ac1d711e58)., |
| 1037 | (int (*)(void *, ogg_int64_tcxx . . $ ogg_int64_t#, int)) _fseek64_wrapcxx . . $ _fseek64_wrap(543fae30d249f6b1)., |
| 1038 | (int (*)(void *)) fclosecxx . . $ fclose(89bc1efcdac0ca22)., |
| 1039 | (long (*)(void *)) ftellcxx . . $ ftell(1dcafcd8ef4c6e6c). |
| 1040 | }; |
| 1041 | |
| 1042 | return ov_test_callbackscxx . . $ ov_test_callbacks(80dfd33e0e406a85).((void *)f, vf, initial, ibytes, callbacks); |
| 1043 | } |
| 1044 | |
| 1045 | int ov_test_opencxx . . $ ov_test_open(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1046 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.!=PARTOPENcxx . . $ `mednafen/tremor/ivorbisfile.h:48:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1047 | return _ov_open2cxx . . $ _ov_open2(231cee6479b09f2b).(vf); |
| 1048 | } |
| 1049 | |
| 1050 | /* How many logical bitstreams in this physical bitstream? */ |
| 1051 | long ov_streamscxx . . $ ov_streams(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1052 | return vf->linkscxx . . $ OggVorbis_File#links.; |
| 1053 | } |
| 1054 | |
| 1055 | /* Is the FILE * associated with vf seekable? */ |
| 1056 | long ov_seekablecxx . . $ ov_seekable(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1057 | return vf->seekablecxx . . $ OggVorbis_File#seekable.; |
| 1058 | } |
| 1059 | |
| 1060 | /* returns the bitrate for a given logical bitstream or the entire |
| 1061 | physical bitstream. If the file is open for random access, it will |
| 1062 | find the *actual* average bitrate. If the file is streaming, it |
| 1063 | returns the nominal bitrate (if set) else the average of the |
| 1064 | upper/lower bounds (if set) else -1 (unset). |
| 1065 | |
| 1066 | If you want the actual bitrate field settings, get them from the |
| 1067 | vorbis_info structs */ |
| 1068 | |
| 1069 | long ov_bitratecxx . . $ ov_bitrate(848dcfd6565c9c04).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1070 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1071 | if(i>=vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1072 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. && i!=0)return(ov_bitratecxx . . $ ov_bitrate(848dcfd6565c9c04).(vf,0)); |
| 1073 | if(i<0){ |
| 1074 | ogg_int64_tcxx . . $ ogg_int64_t# bits=0; |
| 1075 | int i; |
| 1076 | for(i=0;i<vf->linkscxx . . $ OggVorbis_File#links.;i++) |
| 1077 | bits+=(vf->offsetscxx . . $ OggVorbis_File#offsets.[i+1]-vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[i])*8; |
| 1078 | /* This once read: return(rint(bits/ov_time_total(vf,-1))); |
| 1079 | * gcc 3.x on x86 miscompiled this at optimisation level 2 and above, |
| 1080 | * so this is slightly transformed to make it work. |
| 1081 | */ |
| 1082 | return(bits*1000/ov_time_totalcxx . . $ ov_time_total(848dcfd6565c9c04).(vf,-1)); |
| 1083 | }else{ |
| 1084 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 1085 | /* return the actual bitrate */ |
| 1086 | return((vf->offsetscxx . . $ OggVorbis_File#offsets.[i+1]-vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[i])*8000/ov_time_totalcxx . . $ ov_time_total(848dcfd6565c9c04).(vf,i)); |
| 1087 | }else{ |
| 1088 | /* return nominal if set */ |
| 1089 | if(vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_nominalcxx . . $ vorbis_info#bitrate_nominal.>0){ |
| 1090 | return vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_nominalcxx . . $ vorbis_info#bitrate_nominal.; |
| 1091 | }else{ |
| 1092 | if(vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_uppercxx . . $ vorbis_info#bitrate_upper.>0){ |
| 1093 | if(vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_lowercxx . . $ vorbis_info#bitrate_lower.>0){ |
| 1094 | return (vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_uppercxx . . $ vorbis_info#bitrate_upper.+vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_lowercxx . . $ vorbis_info#bitrate_lower.)/2; |
| 1095 | }else{ |
| 1096 | return vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_uppercxx . . $ vorbis_info#bitrate_upper.; |
| 1097 | } |
| 1098 | } |
| 1099 | return(OV_FALSEcxx . . $ `mednafen/tremor/ivorbiscodec.h:183:9`!); |
| 1100 | } |
| 1101 | } |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | /* returns the actual bitrate since last call. returns -1 if no |
| 1106 | additional data to offer since last call (or at beginning of stream), |
| 1107 | EINVAL if stream is only partially open |
| 1108 | */ |
| 1109 | long ov_bitrate_instantcxx . . $ ov_bitrate_instant(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1110 | int link=(vf->seekablecxx . . $ OggVorbis_File#seekable.?vf->current_linkcxx . . $ OggVorbis_File#current_link.:0); |
| 1111 | long ret; |
| 1112 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1113 | if(vf->samptrackcxx . . $ OggVorbis_File#samptrack.==0)return(OV_FALSEcxx . . $ `mednafen/tremor/ivorbiscodec.h:183:9`!); |
| 1114 | ret=vf->bittrackcxx . . $ OggVorbis_File#bittrack./vf->samptrackcxx . . $ OggVorbis_File#samptrack.*vf->vicxx . . $ OggVorbis_File#vi.[link].ratecxx . . $ vorbis_info#rate.; |
| 1115 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0; |
| 1116 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0; |
| 1117 | return(ret); |
| 1118 | } |
| 1119 | |
| 1120 | /* Guess */ |
| 1121 | long ov_serialnumbercxx . . $ ov_serialnumber(848dcfd6565c9c04).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1122 | if(i>=vf->linkscxx . . $ OggVorbis_File#links.)return(ov_serialnumbercxx . . $ ov_serialnumber(848dcfd6565c9c04).(vf,vf->linkscxx . . $ OggVorbis_File#links.-1)); |
| 1123 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. && i>=0)return(ov_serialnumbercxx . . $ ov_serialnumber(848dcfd6565c9c04).(vf,-1)); |
| 1124 | if(i<0){ |
| 1125 | return(vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); |
| 1126 | }else{ |
| 1127 | return(vf->serialnoscxx . . $ OggVorbis_File#serialnos.[i]); |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | /* returns: total raw (compressed) length of content if i==-1 |
| 1132 | raw (compressed) length of that logical bitstream for i==0 to n |
| 1133 | OV_EINVAL if the stream is not seekable (we can't know the length) |
| 1134 | or if stream is only partially open |
| 1135 | */ |
| 1136 | ogg_int64_tcxx . . $ ogg_int64_t# ov_raw_totalcxx . . $ ov_raw_total(848dcfd6565c9c04).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1137 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1138 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. || i>=vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1139 | if(i<0){ |
| 1140 | ogg_int64_tcxx . . $ ogg_int64_t# acc=0; |
| 1141 | int i; |
| 1142 | for(i=0;i<vf->linkscxx . . $ OggVorbis_File#links.;i++) |
| 1143 | acc+=ov_raw_totalcxx . . $ ov_raw_total(848dcfd6565c9c04).(vf,i); |
| 1144 | return(acc); |
| 1145 | }else{ |
| 1146 | return(vf->offsetscxx . . $ OggVorbis_File#offsets.[i+1]-vf->offsetscxx . . $ OggVorbis_File#offsets.[i]); |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | /* returns: total PCM length (samples) of content if i==-1 PCM length |
| 1151 | (samples) of that logical bitstream for i==0 to n |
| 1152 | OV_EINVAL if the stream is not seekable (we can't know the |
| 1153 | length) or only partially open |
| 1154 | */ |
| 1155 | ogg_int64_tcxx . . $ ogg_int64_t# ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1156 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1157 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. || i>=vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1158 | if(i<0){ |
| 1159 | ogg_int64_tcxx . . $ ogg_int64_t# acc=0; |
| 1160 | int i; |
| 1161 | for(i=0;i<vf->linkscxx . . $ OggVorbis_File#links.;i++) |
| 1162 | acc+=ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,i); |
| 1163 | return(acc); |
| 1164 | }else{ |
| 1165 | return(vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1]); |
| 1166 | } |
| 1167 | } |
| 1168 | |
| 1169 | /* returns: total milliseconds of content if i==-1 |
| 1170 | milliseconds in that logical bitstream for i==0 to n |
| 1171 | OV_EINVAL if the stream is not seekable (we can't know the |
| 1172 | length) or only partially open |
| 1173 | */ |
| 1174 | ogg_int64_tcxx . . $ ogg_int64_t# ov_time_totalcxx . . $ ov_time_total(848dcfd6565c9c04).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1175 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1176 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. || i>=vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1177 | if(i<0){ |
| 1178 | ogg_int64_tcxx . . $ ogg_int64_t# acc=0; |
| 1179 | int i; |
| 1180 | for(i=0;i<vf->linkscxx . . $ OggVorbis_File#links.;i++) |
| 1181 | acc+=ov_time_totalcxx . . $ ov_time_total(848dcfd6565c9c04).(vf,i); |
| 1182 | return(acc); |
| 1183 | }else{ |
| 1184 | return(((ogg_int64_tcxx . . $ ogg_int64_t#)vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1])*1000/vf->vicxx . . $ OggVorbis_File#vi.[i].ratecxx . . $ vorbis_info#rate.); |
| 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | /* seek to an offset relative to the *compressed* data. This also |
| 1189 | scans packets to update the PCM cursor. It will cross a logical |
| 1190 | bitstream boundary, but only if it can't get any packets out of the |
| 1191 | tail of the bitstream we seek to (so no surprises). |
| 1192 | |
| 1193 | returns zero on success, nonzero on failure */ |
| 1194 | |
| 1195 | int ov_raw_seekcxx . . $ ov_raw_seek(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# pos){ |
| 1196 | ogg_stream_statecxx . . $ ogg_stream_state# work_os; |
| 1197 | int ret; |
| 1198 | |
| 1199 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1200 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.) |
| 1201 | return(OV_ENOSEEKcxx . . $ `mednafen/tremor/ivorbiscodec.h:197:9`!); /* don't dump machine if we can't seek */ |
| 1202 | |
| 1203 | if(pos<0 || pos>vf->endcxx . . $ OggVorbis_File#end.)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1204 | |
| 1205 | /* is the seek position outside our current link [if any]? */ |
| 1206 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!){ |
| 1207 | if(pos<vf->offsetscxx . . $ OggVorbis_File#offsets.[vf->current_linkcxx . . $ OggVorbis_File#current_link.] || pos>=vf->offsetscxx . . $ OggVorbis_File#offsets.[vf->current_linkcxx . . $ OggVorbis_File#current_link.+1]) |
| 1208 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); /* clear out stream state */ |
| 1209 | } |
| 1210 | |
| 1211 | /* don't yet clear out decoding machine (if it's initialized), in |
| 1212 | the case we're in the same link. Restart the decode lapping, and |
| 1213 | let _fetch_and_process_packet deal with a potential bitstream |
| 1214 | boundary */ |
| 1215 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1216 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os., |
| 1217 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); /* must set serialno */ |
| 1218 | vorbis_synthesis_restartcxx . . $ vorbis_synthesis_restart(6cb399ae167b2de8).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 1219 | |
| 1220 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,pos); |
| 1221 | if(ret)goto seek_error; |
| 1222 | |
| 1223 | /* we need to make sure the pcm_offset is set, but we don't want to |
| 1224 | advance the raw cursor past good packets just to get to the first |
| 1225 | with a granulepos. That's not equivalent behavior to beginning |
| 1226 | decoding as immediately after the seek position as possible. |
| 1227 | |
| 1228 | So, a hack. We use two stream states; a local scratch state and |
| 1229 | the shared vf->os stream state. We use the local state to |
| 1230 | scan, and the shared state as a buffer for later decode. |
| 1231 | |
| 1232 | Unfortuantely, on the last page we still advance to last packet |
| 1233 | because the granulepos on the last page is not necessarily on a |
| 1234 | packet boundary, and we need to make sure the granpos is |
| 1235 | correct. |
| 1236 | */ |
| 1237 | |
| 1238 | { |
| 1239 | ogg_pagecxx . . $ ogg_page# og; |
| 1240 | ogg_packetcxx . . $ ogg_packet# op; |
| 1241 | int lastblock=0; |
| 1242 | int accblock=0; |
| 1243 | int thisblock=0; |
| 1244 | int lastflag=0; |
| 1245 | int firstflag=0; |
| 1246 | ogg_int64_tcxx . . $ ogg_int64_t# pagepos=-1; |
| 1247 | |
| 1248 | ogg_stream_initcxx . . $ ogg_stream_init(99ed4282c68df03).(&work_os,vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); /* get the memory ready */ |
| 1249 | ogg_stream_resetcxx . . $ ogg_stream_reset(d9e3535bee9e7016).(&work_os); /* eliminate the spurious OV_HOLE |
| 1250 | return from not necessarily |
| 1251 | starting from the beginning */ |
| 1252 | |
| 1253 | while(1){ |
| 1254 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!){ |
| 1255 | /* snarf/scan a packet if we can */ |
| 1256 | int result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&work_os,&op); |
| 1257 | |
| 1258 | if(result>0){ |
| 1259 | |
| 1260 | if(vf->vicxx . . $ OggVorbis_File#vi.[vf->current_linkcxx . . $ OggVorbis_File#current_link.].codec_setupcxx . . $ vorbis_info#codec_setup.){ |
| 1261 | thisblock=vorbis_packet_blocksizecxx . . $ vorbis_packet_blocksize(5c730016bfddf4b1).(vf->vicxx . . $ OggVorbis_File#vi.+vf->current_linkcxx . . $ OggVorbis_File#current_link.,&op); |
| 1262 | if(thisblock<0){ |
| 1263 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1264 | thisblock=0; |
| 1265 | }else{ |
| 1266 | |
| 1267 | /* We can't get a guaranteed correct pcm position out of the |
| 1268 | last page in a stream because it might have a 'short' |
| 1269 | granpos, which can only be detected in the presence of a |
| 1270 | preceding page. However, if the last page is also the first |
| 1271 | page, the granpos rules of a first page take precedence. Not |
| 1272 | only that, but for first==last, the EOS page must be treated |
| 1273 | as if its a normal first page for the stream to open/play. */ |
| 1274 | if(lastflag && !firstflag) |
| 1275 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1276 | else |
| 1277 | if(lastblock)accblock+=(lastblock+thisblock)>>2; |
| 1278 | } |
| 1279 | |
| 1280 | if(op.granuleposcxx . . $ $anonymous_type_cccabde66011c92d_4#granulepos.!=-1){ |
| 1281 | int i,link=vf->current_linkcxx . . $ OggVorbis_File#current_link.; |
| 1282 | ogg_int64_tcxx . . $ ogg_int64_t# granulepos=op.granuleposcxx . . $ $anonymous_type_cccabde66011c92d_4#granulepos.-vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2]; |
| 1283 | if(granulepos<0)granulepos=0; |
| 1284 | |
| 1285 | for(i=0;i<link;i++) |
| 1286 | granulepos+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1]; |
| 1287 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=granulepos-accblock; |
| 1288 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.<0)vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=0; |
| 1289 | break; |
| 1290 | } |
| 1291 | lastblock=thisblock; |
| 1292 | continue; |
| 1293 | }else |
| 1294 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1295 | } |
| 1296 | } |
| 1297 | |
| 1298 | if(!lastblock){ |
| 1299 | pagepos=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1); |
| 1300 | if(pagepos<0){ |
| 1301 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,-1); |
| 1302 | break; |
| 1303 | } |
| 1304 | }else{ |
| 1305 | /* huh? Bogus stream with packets but no granulepos */ |
| 1306 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1307 | break; |
| 1308 | } |
| 1309 | |
| 1310 | /* has our decoding just traversed a bitstream boundary? */ |
| 1311 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!){ |
| 1312 | if(vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.!=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)){ |
| 1313 | |
| 1314 | /* two possibilities: |
| 1315 | 1) our decoding just traversed a bitstream boundary |
| 1316 | 2) another stream is multiplexed into this logical section? */ |
| 1317 | |
| 1318 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(&og)){ |
| 1319 | /* we traversed */ |
| 1320 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); /* clear out stream state */ |
| 1321 | ogg_stream_clearcxx . . $ ogg_stream_clear(d9e3535bee9e7016).(&work_os); |
| 1322 | } /* else, do nothing; next loop will scoop another page */ |
| 1323 | } |
| 1324 | } |
| 1325 | |
| 1326 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!){ |
| 1327 | int link; |
| 1328 | ogg_uint32_tcxx . . $ ogg_uint32_t# serialno = ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 1329 | |
| 1330 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++) |
| 1331 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]==serialno)break; |
| 1332 | |
| 1333 | if(link==vf->linkscxx . . $ OggVorbis_File#links.) continue; /* not the desired Vorbis |
| 1334 | bitstream section; keep |
| 1335 | trying */ |
| 1336 | vf->current_linkcxx . . $ OggVorbis_File#current_link.=link; |
| 1337 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=serialno; |
| 1338 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,serialno); |
| 1339 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&work_os,serialno); |
| 1340 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!; |
| 1341 | firstflag=(pagepos<=vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[link]); |
| 1342 | } |
| 1343 | |
| 1344 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 1345 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&work_os,&og); |
| 1346 | lastflag=ogg_page_eoscxx . . $ ogg_page_eos(2b497e90a9d5eca2).(&og); |
| 1347 | |
| 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | ogg_stream_clearcxx . . $ ogg_stream_clear(d9e3535bee9e7016).(&work_os); |
| 1352 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0; |
| 1353 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0; |
| 1354 | return(0); |
| 1355 | |
| 1356 | seek_error: |
| 1357 | /* dump the machine so we're in a known state */ |
| 1358 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1359 | ogg_stream_clearcxx . . $ ogg_stream_clear(d9e3535bee9e7016).(&work_os); |
| 1360 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 1361 | return OV_EBADLINKcxx . . $ `mednafen/tremor/ivorbiscodec.h:196:9`!; |
| 1362 | } |
| 1363 | |
| 1364 | /* rescales the number x from the range of [0,from] to [0,to] |
| 1365 | x is in the range [0,from] |
| 1366 | from, to are in the range [1, 1<<62-1] */ |
| 1367 | ogg_int64_tcxx . . $ ogg_int64_t# rescale64cxx . . $ rescale64(374fe82c592a17bc).(ogg_int64_tcxx . . $ ogg_int64_t# x, ogg_int64_tcxx . . $ ogg_int64_t# from, ogg_int64_tcxx . . $ ogg_int64_t# to){ |
| 1368 | ogg_int64_tcxx . . $ ogg_int64_t# frac=0; |
| 1369 | ogg_int64_tcxx . . $ ogg_int64_t# ret=0; |
| 1370 | int i; |
| 1371 | if(x >= from) return to; |
| 1372 | if(x <= 0) return 0; |
| 1373 | |
| 1374 | for(i=0;i<64;i++){ |
| 1375 | if(x>=from){ |
| 1376 | frac|=1; |
| 1377 | x-=from; |
| 1378 | } |
| 1379 | x<<=1; |
| 1380 | frac<<=1; |
| 1381 | } |
| 1382 | |
| 1383 | for(i=0;i<64;i++){ |
| 1384 | if(frac & 1){ |
| 1385 | ret+=to; |
| 1386 | } |
| 1387 | frac>>=1; |
| 1388 | ret>>=1; |
| 1389 | } |
| 1390 | |
| 1391 | return ret; |
| 1392 | } |
| 1393 | |
| 1394 | /* Page granularity seek (faster than sample granularity because we |
| 1395 | don't do the last bit of decode to find a specific sample). |
| 1396 | |
| 1397 | Seek to the last [granule marked] page preceding the specified pos |
| 1398 | location, such that decoding past the returned point will quickly |
| 1399 | arrive at the requested position. */ |
| 1400 | int ov_pcm_seek_pagecxx . . $ ov_pcm_seek_page(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# pos){ |
| 1401 | int link=-1; |
| 1402 | ogg_int64_tcxx . . $ ogg_int64_t# result=0; |
| 1403 | ogg_int64_tcxx . . $ ogg_int64_t# total=ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,-1); |
| 1404 | |
| 1405 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1406 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.)return(OV_ENOSEEKcxx . . $ `mednafen/tremor/ivorbiscodec.h:197:9`!); |
| 1407 | |
| 1408 | if(pos<0 || pos>total)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1409 | |
| 1410 | /* which bitstream section does this pcm offset occur in? */ |
| 1411 | for(link=vf->linkscxx . . $ OggVorbis_File#links.-1;link>=0;link--){ |
| 1412 | total-=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2+1]; |
| 1413 | if(pos>=total)break; |
| 1414 | } |
| 1415 | |
| 1416 | /* search within the logical bitstream for the page with the highest |
| 1417 | pcm_pos preceding (or equal to) pos. There is a danger here; |
| 1418 | missing pages or incorrect frame number information in the |
| 1419 | bitstream could make our task impossible. Account for that (it |
| 1420 | would be an error condition) */ |
| 1421 | |
| 1422 | /* new search algorithm by HB (Nicholas Vinen) */ |
| 1423 | { |
| 1424 | ogg_int64_tcxx . . $ ogg_int64_t# end=vf->offsetscxx . . $ OggVorbis_File#offsets.[link+1]; |
| 1425 | ogg_int64_tcxx . . $ ogg_int64_t# begin=vf->offsetscxx . . $ OggVorbis_File#offsets.[link]; |
| 1426 | ogg_int64_tcxx . . $ ogg_int64_t# begintime = vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2]; |
| 1427 | ogg_int64_tcxx . . $ ogg_int64_t# endtime = vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2+1]+begintime; |
| 1428 | ogg_int64_tcxx . . $ ogg_int64_t# target=pos-total+begintime; |
| 1429 | ogg_int64_tcxx . . $ ogg_int64_t# best=begin; |
| 1430 | |
| 1431 | ogg_pagecxx . . $ ogg_page# og; |
| 1432 | while(begin<end){ |
| 1433 | ogg_int64_tcxx . . $ ogg_int64_t# bisect; |
| 1434 | |
| 1435 | if(end-begin<CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!){ |
| 1436 | bisect=begin; |
| 1437 | }else{ |
| 1438 | /* take a (pretty decent) guess. */ |
| 1439 | bisect=begin + rescale64cxx . . $ rescale64(374fe82c592a17bc).(target-begintime, |
| 1440 | endtime-begintime, |
| 1441 | end-begin) - CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!; |
| 1442 | if(bisect<begin+CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!) |
| 1443 | bisect=begin; |
| 1444 | } |
| 1445 | |
| 1446 | if(bisect!=vf->offsetcxx . . $ OggVorbis_File#offset.){ |
| 1447 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,bisect); |
| 1448 | if(result) goto seek_error; |
| 1449 | } |
| 1450 | |
| 1451 | while(begin<end){ |
| 1452 | result=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,end-vf->offsetcxx . . $ OggVorbis_File#offset.); |
| 1453 | if(result==OV_EREADcxx . . $ `mednafen/tremor/ivorbiscodec.h:187:9`!) goto seek_error; |
| 1454 | if(result<0){ |
| 1455 | if(bisect<=begin+1) |
| 1456 | end=begin; /* found it */ |
| 1457 | else{ |
| 1458 | if(bisect==0) goto seek_error; |
| 1459 | bisect-=CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!; |
| 1460 | if(bisect<=begin)bisect=begin+1; |
| 1461 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,bisect); |
| 1462 | if(result) goto seek_error; |
| 1463 | } |
| 1464 | }else{ |
| 1465 | ogg_int64_tcxx . . $ ogg_int64_t# granulepos; |
| 1466 | |
| 1467 | if(ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)!=vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]) |
| 1468 | continue; |
| 1469 | |
| 1470 | granulepos=ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og); |
| 1471 | if(granulepos==-1)continue; |
| 1472 | |
| 1473 | if(granulepos<target){ |
| 1474 | best=result; /* raw offset of packet with granulepos */ |
| 1475 | begin=vf->offsetcxx . . $ OggVorbis_File#offset.; /* raw offset of next page */ |
| 1476 | begintime=granulepos; |
| 1477 | |
| 1478 | if(target-begintime>44100)break; |
| 1479 | bisect=begin; /* *not* begin + 1 */ |
| 1480 | }else{ |
| 1481 | if(bisect<=begin+1) |
| 1482 | end=begin; /* found it */ |
| 1483 | else{ |
| 1484 | if(end==vf->offsetcxx . . $ OggVorbis_File#offset.){ /* we're pretty close - we'd be stuck in */ |
| 1485 | end=result; |
| 1486 | bisect-=CHUNKSIZEcxx . . $ `mednafen/tremor/ivorbisfile.h:29:9`!; /* an endless loop otherwise. */ |
| 1487 | if(bisect<=begin)bisect=begin+1; |
| 1488 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,bisect); |
| 1489 | if(result) goto seek_error; |
| 1490 | }else{ |
| 1491 | end=bisect; |
| 1492 | endtime=granulepos; |
| 1493 | break; |
| 1494 | } |
| 1495 | } |
| 1496 | } |
| 1497 | } |
| 1498 | } |
| 1499 | } |
| 1500 | |
| 1501 | /* found our page. seek to it, update pcm offset. Easier case than |
| 1502 | raw_seek, don't keep packets preceding granulepos. */ |
| 1503 | { |
| 1504 | ogg_pagecxx . . $ ogg_page# og; |
| 1505 | ogg_packetcxx . . $ ogg_packet# op; |
| 1506 | |
| 1507 | /* seek */ |
| 1508 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,best); |
| 1509 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1510 | if(result) goto seek_error; |
| 1511 | result=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1); |
| 1512 | if(result<0) goto seek_error; |
| 1513 | |
| 1514 | if(link!=vf->current_linkcxx . . $ OggVorbis_File#current_link.){ |
| 1515 | /* Different link; dump entire decode machine */ |
| 1516 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 1517 | |
| 1518 | vf->current_linkcxx . . $ OggVorbis_File#current_link.=link; |
| 1519 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]; |
| 1520 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!; |
| 1521 | |
| 1522 | }else{ |
| 1523 | vorbis_synthesis_restartcxx . . $ vorbis_synthesis_restart(6cb399ae167b2de8).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 1524 | } |
| 1525 | |
| 1526 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); |
| 1527 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 1528 | |
| 1529 | /* pull out all but last packet; the one with granulepos */ |
| 1530 | while(1){ |
| 1531 | result=ogg_stream_packetpeekcxx . . $ ogg_stream_packetpeek(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op); |
| 1532 | if(result==0){ |
| 1533 | /* !!! the packet finishing this page originated on a |
| 1534 | preceding page. Keep fetching previous pages until we |
| 1535 | get one with a granulepos or without the 'continued' flag |
| 1536 | set. Then just use raw_seek for simplicity. */ |
| 1537 | |
| 1538 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,best); |
| 1539 | if(result<0) goto seek_error; |
| 1540 | |
| 1541 | while(1){ |
| 1542 | result=_get_prev_pagecxx . . $ _get_prev_page(a037b955d8f4f6eb).(vf,&og); |
| 1543 | if(result<0) goto seek_error; |
| 1544 | if(ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)==vf->current_serialnocxx . . $ OggVorbis_File#current_serialno. && |
| 1545 | (ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og)>-1 || |
| 1546 | !ogg_page_continuedcxx . . $ ogg_page_continued(2b497e90a9d5eca2).(&og))){ |
| 1547 | return ov_raw_seekcxx . . $ ov_raw_seek(2602c1e715810f3a).(vf,result); |
| 1548 | } |
| 1549 | vf->offsetcxx . . $ OggVorbis_File#offset.=result; |
| 1550 | } |
| 1551 | } |
| 1552 | if(result<0){ |
| 1553 | result = OV_EBADPACKETcxx . . $ `mednafen/tremor/ivorbiscodec.h:195:9`!; |
| 1554 | goto seek_error; |
| 1555 | } |
| 1556 | if(op.granuleposcxx . . $ $anonymous_type_cccabde66011c92d_4#granulepos.!=-1){ |
| 1557 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=op.granuleposcxx . . $ $anonymous_type_cccabde66011c92d_4#granulepos.-vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[vf->current_linkcxx . . $ OggVorbis_File#current_link.*2]; |
| 1558 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.<0)vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=0; |
| 1559 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=total; |
| 1560 | break; |
| 1561 | }else |
| 1562 | result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1563 | } |
| 1564 | } |
| 1565 | } |
| 1566 | |
| 1567 | /* verify result */ |
| 1568 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.>pos || pos>ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,-1)){ |
| 1569 | result=OV_EFAULTcxx . . $ `mednafen/tremor/ivorbiscodec.h:188:9`!; |
| 1570 | goto seek_error; |
| 1571 | } |
| 1572 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0; |
| 1573 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0; |
| 1574 | return(0); |
| 1575 | |
| 1576 | seek_error: |
| 1577 | /* dump machine so we're in a known state */ |
| 1578 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1579 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 1580 | return (int)result; |
| 1581 | } |
| 1582 | |
| 1583 | /* seek to a sample offset relative to the decompressed pcm stream |
| 1584 | returns zero on success, nonzero on failure */ |
| 1585 | |
| 1586 | int ov_pcm_seekcxx . . $ ov_pcm_seek(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# pos){ |
| 1587 | int thisblock,lastblock=0; |
| 1588 | int ret=ov_pcm_seek_pagecxx . . $ ov_pcm_seek_page(2602c1e715810f3a).(vf,pos); |
| 1589 | if(ret<0)return(ret); |
| 1590 | if((ret=_make_decode_readycxx . . $ _make_decode_ready(231cee6479b09f2b).(vf)))return ret; |
| 1591 | |
| 1592 | /* discard leading packets we don't need for the lapping of the |
| 1593 | position we want; don't decode them */ |
| 1594 | |
| 1595 | while(1){ |
| 1596 | ogg_packetcxx . . $ ogg_packet# op; |
| 1597 | ogg_pagecxx . . $ ogg_page# og; |
| 1598 | |
| 1599 | int ret=ogg_stream_packetpeekcxx . . $ ogg_stream_packetpeek(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op); |
| 1600 | if(ret>0){ |
| 1601 | thisblock=vorbis_packet_blocksizecxx . . $ vorbis_packet_blocksize(5c730016bfddf4b1).(vf->vicxx . . $ OggVorbis_File#vi.+vf->current_linkcxx . . $ OggVorbis_File#current_link.,&op); |
| 1602 | if(thisblock<0){ |
| 1603 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1604 | continue; /* non audio packet */ |
| 1605 | } |
| 1606 | if(lastblock)vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=(lastblock+thisblock)>>2; |
| 1607 | |
| 1608 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+((thisblock+ |
| 1609 | vorbis_info_blocksizecxx . . $ vorbis_info_blocksize(567c21d5828d03ac).(vf->vicxx . . $ OggVorbis_File#vi.,1))>>2)>=pos)break; |
| 1610 | |
| 1611 | /* remove the packet from packet queue and track its granulepos */ |
| 1612 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1613 | vorbis_synthesis_trackonlycxx . . $ vorbis_synthesis_trackonly(e9de88148c52a299).(&vf->vbcxx . . $ OggVorbis_File#vb.,&op); /* set up a vb with |
| 1614 | only tracking, no |
| 1615 | pcm_decode */ |
| 1616 | vorbis_synthesis_blockincxx . . $ vorbis_synthesis_blockin(c8f1c0cf9c31dd14).(&vf->vdcxx . . $ OggVorbis_File#vd.,&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 1617 | |
| 1618 | /* end of logical stream case is hard, especially with exact |
| 1619 | length positioning. */ |
| 1620 | |
| 1621 | if(op.granuleposcxx . . $ $anonymous_type_cccabde66011c92d_4#granulepos.>-1){ |
| 1622 | int i; |
| 1623 | /* always believe the stream markers */ |
| 1624 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=op.granuleposcxx . . $ $anonymous_type_cccabde66011c92d_4#granulepos.-vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[vf->current_linkcxx . . $ OggVorbis_File#current_link.*2]; |
| 1625 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.<0)vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=0; |
| 1626 | for(i=0;i<vf->current_linkcxx . . $ OggVorbis_File#current_link.;i++) |
| 1627 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1]; |
| 1628 | } |
| 1629 | |
| 1630 | lastblock=thisblock; |
| 1631 | |
| 1632 | }else{ |
| 1633 | if(ret<0 && ret!=OV_HOLEcxx . . $ `mednafen/tremor/ivorbiscodec.h:185:9`!)break; |
| 1634 | |
| 1635 | /* suck in a new page */ |
| 1636 | if(_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1)<0)break; |
| 1637 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(&og))_decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 1638 | |
| 1639 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!){ |
| 1640 | ogg_uint32_tcxx . . $ ogg_uint32_t# serialno=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 1641 | int link; |
| 1642 | |
| 1643 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++) |
| 1644 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]==serialno)break; |
| 1645 | if(link==vf->linkscxx . . $ OggVorbis_File#links.) continue; |
| 1646 | vf->current_linkcxx . . $ OggVorbis_File#current_link.=link; |
| 1647 | |
| 1648 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!; |
| 1649 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 1650 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,serialno); |
| 1651 | ret=_make_decode_readycxx . . $ _make_decode_ready(231cee6479b09f2b).(vf); |
| 1652 | if(ret)return ret; |
| 1653 | lastblock=0; |
| 1654 | } |
| 1655 | |
| 1656 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 1657 | } |
| 1658 | } |
| 1659 | |
| 1660 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0; |
| 1661 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0; |
| 1662 | /* discard samples until we reach the desired position. Crossing a |
| 1663 | logical bitstream boundary with abandon is OK. */ |
| 1664 | while(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.<pos){ |
| 1665 | ogg_int64_tcxx . . $ ogg_int64_t# target=pos-vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.; |
| 1666 | long samples=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(a5862dcc143b250).(&vf->vdcxx . . $ OggVorbis_File#vd.,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1667 | |
| 1668 | if(samples>target)samples=target; |
| 1669 | vorbis_synthesis_readcxx . . $ vorbis_synthesis_read(462060a1f4fafeae).(&vf->vdcxx . . $ OggVorbis_File#vd.,samples); |
| 1670 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=samples; |
| 1671 | |
| 1672 | if(samples<target) |
| 1673 | if(_fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(vf,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,1,1)<=0) |
| 1674 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,-1); /* eof */ |
| 1675 | } |
| 1676 | return 0; |
| 1677 | } |
| 1678 | |
| 1679 | /* seek to a playback time relative to the decompressed pcm stream |
| 1680 | returns zero on success, nonzero on failure */ |
| 1681 | int ov_time_seekcxx . . $ ov_time_seek(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# milliseconds){ |
| 1682 | /* translate time to PCM position and call ov_pcm_seek */ |
| 1683 | |
| 1684 | int link=-1; |
| 1685 | ogg_int64_tcxx . . $ ogg_int64_t# pcm_total=0; |
| 1686 | ogg_int64_tcxx . . $ ogg_int64_t# time_total=0; |
| 1687 | |
| 1688 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1689 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.)return(OV_ENOSEEKcxx . . $ `mednafen/tremor/ivorbiscodec.h:197:9`!); |
| 1690 | if(milliseconds<0)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1691 | |
| 1692 | /* which bitstream section does this time offset occur in? */ |
| 1693 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++){ |
| 1694 | ogg_int64_tcxx . . $ ogg_int64_t# addsec = ov_time_totalcxx . . $ ov_time_total(848dcfd6565c9c04).(vf,link); |
| 1695 | if(milliseconds<time_total+addsec)break; |
| 1696 | time_total+=addsec; |
| 1697 | pcm_total+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2+1]; |
| 1698 | } |
| 1699 | |
| 1700 | if(link==vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1701 | |
| 1702 | /* enough information to convert time offset to pcm offset */ |
| 1703 | { |
| 1704 | ogg_int64_tcxx . . $ ogg_int64_t# target=pcm_total+(milliseconds-time_total)*vf->vicxx . . $ OggVorbis_File#vi.[link].ratecxx . . $ vorbis_info#rate./1000; |
| 1705 | return(ov_pcm_seekcxx . . $ ov_pcm_seek(2602c1e715810f3a).(vf,target)); |
| 1706 | } |
| 1707 | } |
| 1708 | |
| 1709 | /* page-granularity version of ov_time_seek |
| 1710 | returns zero on success, nonzero on failure */ |
| 1711 | int ov_time_seek_pagecxx . . $ ov_time_seek_page(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# milliseconds){ |
| 1712 | /* translate time to PCM position and call ov_pcm_seek */ |
| 1713 | |
| 1714 | int link=-1; |
| 1715 | ogg_int64_tcxx . . $ ogg_int64_t# pcm_total=0; |
| 1716 | ogg_int64_tcxx . . $ ogg_int64_t# time_total=0; |
| 1717 | |
| 1718 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1719 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.)return(OV_ENOSEEKcxx . . $ `mednafen/tremor/ivorbiscodec.h:197:9`!); |
| 1720 | if(milliseconds<0)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1721 | |
| 1722 | /* which bitstream section does this time offset occur in? */ |
| 1723 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++){ |
| 1724 | ogg_int64_tcxx . . $ ogg_int64_t# addsec = ov_time_totalcxx . . $ ov_time_total(848dcfd6565c9c04).(vf,link); |
| 1725 | if(milliseconds<time_total+addsec)break; |
| 1726 | time_total+=addsec; |
| 1727 | pcm_total+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2+1]; |
| 1728 | } |
| 1729 | |
| 1730 | if(link==vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1731 | |
| 1732 | /* enough information to convert time offset to pcm offset */ |
| 1733 | { |
| 1734 | ogg_int64_tcxx . . $ ogg_int64_t# target=pcm_total+(milliseconds-time_total)*vf->vicxx . . $ OggVorbis_File#vi.[link].ratecxx . . $ vorbis_info#rate./1000; |
| 1735 | return(ov_pcm_seek_pagecxx . . $ ov_pcm_seek_page(2602c1e715810f3a).(vf,target)); |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | /* tell the current stream offset cursor. Note that seek followed by |
| 1740 | tell will likely not give the set offset due to caching */ |
| 1741 | ogg_int64_tcxx . . $ ogg_int64_t# ov_raw_tellcxx . . $ ov_raw_tell(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1742 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1743 | return(vf->offsetcxx . . $ OggVorbis_File#offset.); |
| 1744 | } |
| 1745 | |
| 1746 | /* return PCM offset (sample) of next PCM sample to be read */ |
| 1747 | ogg_int64_tcxx . . $ ogg_int64_t# ov_pcm_tellcxx . . $ ov_pcm_tell(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1748 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1749 | return(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.); |
| 1750 | } |
| 1751 | |
| 1752 | /* return time offset (milliseconds) of next PCM sample to be read */ |
| 1753 | ogg_int64_tcxx . . $ ogg_int64_t# ov_time_tellcxx . . $ ov_time_tell(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1754 | int link=0; |
| 1755 | ogg_int64_tcxx . . $ ogg_int64_t# pcm_total=0; |
| 1756 | ogg_int64_tcxx . . $ ogg_int64_t# time_total=0; |
| 1757 | |
| 1758 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1759 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 1760 | pcm_total=ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,-1); |
| 1761 | time_total=ov_time_totalcxx . . $ ov_time_total(848dcfd6565c9c04).(vf,-1); |
| 1762 | |
| 1763 | /* which bitstream section does this time offset occur in? */ |
| 1764 | for(link=vf->linkscxx . . $ OggVorbis_File#links.-1;link>=0;link--){ |
| 1765 | pcm_total-=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2+1]; |
| 1766 | time_total-=ov_time_totalcxx . . $ ov_time_total(848dcfd6565c9c04).(vf,link); |
| 1767 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.>=pcm_total)break; |
| 1768 | } |
| 1769 | } |
| 1770 | |
| 1771 | return(time_total+(1000*vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.-pcm_total)/vf->vicxx . . $ OggVorbis_File#vi.[link].ratecxx . . $ vorbis_info#rate.); |
| 1772 | } |
| 1773 | |
| 1774 | /* link: -1) return the vorbis_info struct for the bitstream section |
| 1775 | currently being decoded |
| 1776 | 0-n) to request information for a specific bitstream section |
| 1777 | |
| 1778 | In the case of a non-seekable bitstream, any call returns the |
| 1779 | current bitstream. NULL in the case that the machine is not |
| 1780 | initialized */ |
| 1781 | |
| 1782 | vorbis_infocxx . . $ vorbis_info# *ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int link){ |
| 1783 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 1784 | if(link<0) |
| 1785 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!) |
| 1786 | return vf->vicxx . . $ OggVorbis_File#vi.+vf->current_linkcxx . . $ OggVorbis_File#current_link.; |
| 1787 | else |
| 1788 | return vf->vicxx . . $ OggVorbis_File#vi.; |
| 1789 | else |
| 1790 | if(link>=vf->linkscxx . . $ OggVorbis_File#links.) |
| 1791 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1792 | else |
| 1793 | return vf->vicxx . . $ OggVorbis_File#vi.+link; |
| 1794 | }else{ |
| 1795 | return vf->vicxx . . $ OggVorbis_File#vi.; |
| 1796 | } |
| 1797 | } |
| 1798 | |
| 1799 | /* grr, strong typing, grr, no templates/inheritence, grr */ |
| 1800 | vorbis_commentcxx . . $ vorbis_comment# *ov_commentcxx . . $ ov_comment(5c593f69dba24d40).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int link){ |
| 1801 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 1802 | if(link<0) |
| 1803 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `mednafen/tremor/ivorbisfile.h:50:10`!) |
| 1804 | return vf->vccxx . . $ OggVorbis_File#vc.+vf->current_linkcxx . . $ OggVorbis_File#current_link.; |
| 1805 | else |
| 1806 | return vf->vccxx . . $ OggVorbis_File#vc.; |
| 1807 | else |
| 1808 | if(link>=vf->linkscxx . . $ OggVorbis_File#links.) |
| 1809 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1810 | else |
| 1811 | return vf->vccxx . . $ OggVorbis_File#vc.+link; |
| 1812 | }else{ |
| 1813 | return vf->vccxx . . $ OggVorbis_File#vc.; |
| 1814 | } |
| 1815 | } |
| 1816 | |
| 1817 | /* up to this point, everything could more or less hide the multiple |
| 1818 | logical bitstream nature of chaining from the toplevel application |
| 1819 | if the toplevel application didn't particularly care. However, at |
| 1820 | the point that we actually read audio back, the multiple-section |
| 1821 | nature must surface: Multiple bitstream sections do not necessarily |
| 1822 | have to have the same number of channels or sampling rate. |
| 1823 | |
| 1824 | ov_read returns the sequential logical bitstream number currently |
| 1825 | being decoded along with the PCM data in order that the toplevel |
| 1826 | application can take action on channel/sample rate changes. This |
| 1827 | number will be incremented even for streamed (non-seekable) streams |
| 1828 | (for seekable streams, it represents the actual logical bitstream |
| 1829 | index within the physical bitstream. Note that the accessor |
| 1830 | functions above are aware of this dichotomy). |
| 1831 | |
| 1832 | input values: buffer) a buffer to hold packed PCM data for return |
| 1833 | bytes_req) the byte length requested to be placed into buffer |
| 1834 | |
| 1835 | return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL) |
| 1836 | 0) EOF |
| 1837 | n) number of bytes of PCM actually returned. The |
| 1838 | below works on a packet-by-packet basis, so the |
| 1839 | return length is not related to the 'length' passed |
| 1840 | in, just guaranteed to fit. |
| 1841 | |
| 1842 | *section) set to the logical bitstream number */ |
| 1843 | |
| 1844 | long ov_readcxx . . $ ov_read(fecdd0574488f6f9).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,char *buffer,int bytes_req,int *bitstream){ |
| 1845 | int i,j; |
| 1846 | |
| 1847 | ogg_int32_tcxx . . $ ogg_int32_t# **pcm; |
| 1848 | long samples; |
| 1849 | |
| 1850 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `mednafen/tremor/ivorbisfile.h:49:10`!)return(OV_EINVALcxx . . $ `mednafen/tremor/ivorbiscodec.h:190:9`!); |
| 1851 | |
| 1852 | while(1){ |
| 1853 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==INITSETcxx . . $ `mednafen/tremor/ivorbisfile.h:51:10`!){ |
| 1854 | samples=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(a5862dcc143b250).(&vf->vdcxx . . $ OggVorbis_File#vd.,&pcm); |
| 1855 | if(samples)break; |
| 1856 | } |
| 1857 | |
| 1858 | /* suck in another packet */ |
| 1859 | { |
| 1860 | int ret=_fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(vf,NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,1,1); |
| 1861 | if(ret==OV_EOFcxx . . $ `mednafen/tremor/ivorbiscodec.h:184:9`!) |
| 1862 | return(0); |
| 1863 | if(ret<=0) |
| 1864 | return(ret); |
| 1865 | } |
| 1866 | |
| 1867 | } |
| 1868 | |
| 1869 | if(samples>0){ |
| 1870 | |
| 1871 | /* yay! proceed to pack data into the byte buffer */ |
| 1872 | |
| 1873 | long channels=ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(vf,-1)->channelscxx . . $ vorbis_info#channels.; |
| 1874 | |
| 1875 | if(samples>(bytes_req/(2*channels))) |
| 1876 | samples=bytes_req/(2*channels); |
| 1877 | |
| 1878 | for(i=0;i<channels;i++) { /* It's faster in this order */ |
| 1879 | ogg_int32_tcxx . . $ ogg_int32_t# *src=pcm[i]; |
| 1880 | short *dest=((short *)buffer)+i; |
| 1881 | for(j=0;j<samples;j++) { |
| 1882 | *dest=CLIP_TO_15cxx . . $ CLIP_TO_15(7864480464b09eea).(src[j]>>9); |
| 1883 | dest+=channels; |
| 1884 | } |
| 1885 | } |
| 1886 | |
| 1887 | vorbis_synthesis_readcxx . . $ vorbis_synthesis_read(462060a1f4fafeae).(&vf->vdcxx . . $ OggVorbis_File#vd.,samples); |
| 1888 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=samples; |
| 1889 | if(bitstream)*bitstream=vf->current_linkcxx . . $ OggVorbis_File#current_link.; |
| 1890 | return(samples*2*channels); |
| 1891 | }else{ |
| 1892 | return(samples); |
| 1893 | } |
| 1894 | } |