| 1 | /******************************************************************** |
| 2 | * * |
| 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * |
| 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
| 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
| 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
| 7 | * * |
| 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * |
| 9 | * by the Xiph.Org Foundation https://xiph.org/ * |
| 10 | * * |
| 11 | ******************************************************************** |
| 12 | |
| 13 | function: stdio-based convenience library for opening/seeking/decoding |
| 14 | |
| 15 | ********************************************************************/ |
| 16 | |
| 17 | #include "vorbis_codec.h"cxx . . $ `<file>/external/vorbis/vorbis_codec.h`/ |
| 18 | |
| 19 | /* we don't need or want the static callback symbols here */ |
| 20 | #define OV_EXCLUDE_STATIC_CALLBACKScxx . . $ `external/vorbis/vorbisfile.cpp:20:9`! |
| 21 | #include "vorbisfile.h"cxx . . $ `<file>/external/vorbis/vorbisfile.h`/ |
| 22 | |
| 23 | #include "vorbis_os.h"cxx . . $ `<file>/external/vorbis/vorbis_os.h`/ |
| 24 | #include "vorbis_misc.h"cxx . . $ `<file>/external/vorbis/vorbis_misc.h`/ |
| 25 | |
| 26 | /* A 'chained bitstream' is a Vorbis bitstream that contains more than |
| 27 | one logical bitstream arranged end to end (the only form of Ogg |
| 28 | multiplexing allowed in a Vorbis bitstream; grouping [parallel |
| 29 | multiplexing] is not allowed in Vorbis) */ |
| 30 | |
| 31 | /* A Vorbis file can be played beginning to end (streamed) without |
| 32 | worrying ahead of time about chaining (see decoder_example.c). If |
| 33 | we have the whole file, however, and want random access |
| 34 | (seeking/scrubbing) or desire to know the total length/time of a |
| 35 | file, we need to account for the possibility of chaining. */ |
| 36 | |
| 37 | /* We can handle things a number of ways; we can determine the entire |
| 38 | bitstream structure right off the bat, or find pieces on demand. |
| 39 | This example determines and caches structure for the entire |
| 40 | bitstream, but builds a virtual decoder on the fly when moving |
| 41 | between links in the chain. */ |
| 42 | |
| 43 | /* There are also different ways to implement seeking. Enough |
| 44 | information exists in an Ogg bitstream to seek to |
| 45 | sample-granularity positions in the output. Or, one can seek by |
| 46 | picking some portion of the stream roughly in the desired area if |
| 47 | we only want coarse navigation through the stream. */ |
| 48 | |
| 49 | /************************************************************************* |
| 50 | * Many, many internal helpers. The intention is not to be confusing; |
| 51 | * rampant duplication and monolithic function implementation would be |
| 52 | * harder to understand anyway. The high level functions are last. Begin |
| 53 | * grokking near the end of the file */ |
| 54 | |
| 55 | /* read a little more data from the file/pipe into the ogg_sync framer |
| 56 | */ |
| 57 | #define CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`! 65536 /* greater-than-page-size granularity seeking */ |
| 58 | #define READSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:58:9`! 2048 /* a smaller read size is needed for low-rate streaming. */ |
| 59 | |
| 60 | static long _get_datacxx . . $ _get_data(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 61 | errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!=0; |
| 62 | if(!(vf->callbackscxx . . $ OggVorbis_File#callbacks..read_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#read_func.))return(-1); |
| 63 | if(vf->datasourcecxx . . $ OggVorbis_File#datasource.){ |
| 64 | char *buffer=ogg_sync_buffercxx . . $ ogg_sync_buffer(16ea7c6d847c120d).(&vf->oycxx . . $ OggVorbis_File#oy.,READSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:58:9`!); |
| 65 | long bytes=(vf->callbackscxx . . $ OggVorbis_File#callbacks..read_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#read_func.)(buffer,1,READSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:58:9`!,vf->datasourcecxx . . $ OggVorbis_File#datasource.); |
| 66 | if(bytes>0)ogg_sync_wrotecxx . . $ ogg_sync_wrote(7ecdafb9a73216e5).(&vf->oycxx . . $ OggVorbis_File#oy.,bytes); |
| 67 | if(bytes==0 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)return(-1); |
| 68 | return(bytes); |
| 69 | }else |
| 70 | return(0); |
| 71 | } |
| 72 | |
| 73 | /* save a tiny smidge of verbosity to make the code more readable */ |
| 74 | static int _seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# offset){ |
| 75 | if(vf->datasourcecxx . . $ OggVorbis_File#datasource.){ |
| 76 | /* only seek if the file position isn't already there */ |
| 77 | if(vf->offsetcxx . . $ OggVorbis_File#offset. != offset){ |
| 78 | if(!(vf->callbackscxx . . $ OggVorbis_File#callbacks..seek_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#seek_func.)|| |
| 79 | (vf->callbackscxx . . $ OggVorbis_File#callbacks..seek_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#seek_func.)(vf->datasourcecxx . . $ OggVorbis_File#datasource., offset, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!) == -1) |
| 80 | return OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!; |
| 81 | vf->offsetcxx . . $ OggVorbis_File#offset.=offset; |
| 82 | ogg_sync_resetcxx . . $ ogg_sync_reset(4d079e1537bb6e53).(&vf->oycxx . . $ OggVorbis_File#oy.); |
| 83 | } |
| 84 | }else{ |
| 85 | /* shouldn't happen unless someone writes a broken callback */ |
| 86 | return OV_EFAULTcxx . . $ `external/vorbis/vorbis_codec.h:221:9`!; |
| 87 | } |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | /* The read/seek functions track absolute position within the stream */ |
| 92 | |
| 93 | /* from the head of the stream, get the next page. boundary specifies |
| 94 | if the function is allowed to fetch more data from the stream (and |
| 95 | how much) or only use internally buffered data. |
| 96 | |
| 97 | boundary: -1) unbounded search |
| 98 | 0) read no additional data; use cached only |
| 99 | n) search for a new page beginning for n bytes |
| 100 | |
| 101 | return: <0) did not find a page (OV_FALSE, OV_EOF, OV_EREAD) |
| 102 | n) found a page at absolute offset n */ |
| 103 | |
| 104 | static ogg_int64_tcxx . . $ ogg_int64_t# _get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_pagecxx . . $ ogg_page# *og, |
| 105 | ogg_int64_tcxx . . $ ogg_int64_t# boundary){ |
| 106 | if(boundary>0)boundary+=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 107 | while(1){ |
| 108 | long more; |
| 109 | |
| 110 | if(boundary>0 && vf->offsetcxx . . $ OggVorbis_File#offset.>=boundary)return(OV_FALSEcxx . . $ `external/vorbis/vorbis_codec.h:216:9`!); |
| 111 | more=ogg_sync_pageseekcxx . . $ ogg_sync_pageseek(6fecd6648e8334e5).(&vf->oycxx . . $ OggVorbis_File#oy.,og); |
| 112 | |
| 113 | if(more<0){ |
| 114 | /* skipped n bytes */ |
| 115 | vf->offsetcxx . . $ OggVorbis_File#offset.-=more; |
| 116 | }else{ |
| 117 | if(more==0){ |
| 118 | /* send more paramedics */ |
| 119 | if(!boundary)return(OV_FALSEcxx . . $ `external/vorbis/vorbis_codec.h:216:9`!); |
| 120 | { |
| 121 | long ret=_get_datacxx . . $ _get_data(cc66401103655b07).(vf); |
| 122 | if(ret==0)return(OV_EOFcxx . . $ `external/vorbis/vorbis_codec.h:217:9`!); |
| 123 | if(ret<0)return(OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!); |
| 124 | } |
| 125 | }else{ |
| 126 | /* got a page. Return the offset at the page beginning, |
| 127 | advance the internal offset past the page end */ |
| 128 | ogg_int64_tcxx . . $ ogg_int64_t# ret=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 129 | vf->offsetcxx . . $ OggVorbis_File#offset.+=more; |
| 130 | return(ret); |
| 131 | |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | /* find the latest page beginning before the passed in position. Much |
| 138 | dirtier than the above as Ogg doesn't have any backward search |
| 139 | linkage. no 'readp' as it will certainly have to read. */ |
| 140 | /* returns offset or OV_EREAD, OV_FAULT */ |
| 141 | static ogg_int64_tcxx . . $ ogg_int64_t# _get_prev_pagecxx . . $ _get_prev_page(1a1b99d6be8dbf6f).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# begin,ogg_pagecxx . . $ ogg_page# *og){ |
| 142 | ogg_int64_tcxx . . $ ogg_int64_t# end = begin; |
| 143 | ogg_int64_tcxx . . $ ogg_int64_t# ret; |
| 144 | ogg_int64_tcxx . . $ ogg_int64_t# offset=-1; |
| 145 | |
| 146 | while(offset==-1){ |
| 147 | begin-=CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!; |
| 148 | if(begin<0) |
| 149 | begin=0; |
| 150 | |
| 151 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,begin); |
| 152 | if(ret)return(ret); |
| 153 | |
| 154 | while(vf->offsetcxx . . $ OggVorbis_File#offset.<end){ |
| 155 | memset(og,0,sizeof(*og)); |
| 156 | ret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,og,end-vf->offsetcxx . . $ OggVorbis_File#offset.); |
| 157 | if(ret==OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!)return(OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!); |
| 158 | if(ret<0){ |
| 159 | break; |
| 160 | }else{ |
| 161 | offset=ret; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /* In a fully compliant, non-multiplexed stream, we'll still be |
| 167 | holding the last page. In multiplexed (or noncompliant streams), |
| 168 | we will probably have to re-read the last page we saw */ |
| 169 | if(og->header_lencxx . . $ $anonymous_type_d401cdaf801be98c_2#header_len.==0){ |
| 170 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,offset); |
| 171 | if(ret)return(ret); |
| 172 | |
| 173 | ret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,og,CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!); |
| 174 | if(ret<0) |
| 175 | /* this shouldn't be possible */ |
| 176 | return(OV_EFAULTcxx . . $ `external/vorbis/vorbis_codec.h:221:9`!); |
| 177 | } |
| 178 | |
| 179 | return(offset); |
| 180 | } |
| 181 | |
| 182 | static void _add_serialnocxx . . $ _add_serialno(9ae7a8d159595342).(ogg_pagecxx . . $ ogg_page# *og,long **serialno_list, int *n){ |
| 183 | long s = ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og); |
| 184 | (*n)++; |
| 185 | |
| 186 | if(*serialno_list){ |
| 187 | *serialno_list = (long *) Melder_realloccxx . . $ Melder_realloc(d42fd80046fa8ace). (*serialno_list, sizeof(**serialno_list)*(*n)); |
| 188 | }else{ |
| 189 | *serialno_list = (long *) _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(sizeof(**serialno_list)); |
| 190 | } |
| 191 | |
| 192 | (*serialno_list)[(*n)-1] = s; |
| 193 | } |
| 194 | |
| 195 | /* returns nonzero if found */ |
| 196 | static int _lookup_serialnocxx . . $ _lookup_serialno(f2dc718a5a5eeab1).(long s, long *serialno_list, int n){ |
| 197 | if(serialno_list){ |
| 198 | while(n--){ |
| 199 | if(*serialno_list == s) return 1; |
| 200 | serialno_list++; |
| 201 | } |
| 202 | } |
| 203 | return 0; |
| 204 | } |
| 205 | |
| 206 | static int _lookup_page_serialnocxx . . $ _lookup_page_serialno(afa8961b0de29137).(ogg_pagecxx . . $ ogg_page# *og, long *serialno_list, int n){ |
| 207 | long s = ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og); |
| 208 | return _lookup_serialnocxx . . $ _lookup_serialno(f2dc718a5a5eeab1).(s,serialno_list,n); |
| 209 | } |
| 210 | |
| 211 | /* performs the same search as _get_prev_page, but prefers pages of |
| 212 | the specified serial number. If a page of the specified serialno is |
| 213 | spotted during the seek-back-and-read-forward, it will return the |
| 214 | info of last page of the matching serial number instead of the very |
| 215 | last page. If no page of the specified serialno is seen, it will |
| 216 | return the info of last page and alter *serialno. */ |
| 217 | static ogg_int64_tcxx . . $ ogg_int64_t# _get_prev_page_serialcxx . . $ _get_prev_page_serial(dca12cb43b82d89c).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf, ogg_int64_tcxx . . $ ogg_int64_t# begin, |
| 218 | long *serial_list, int serial_n, |
| 219 | int *serialno, ogg_int64_tcxx . . $ ogg_int64_t# *granpos){ |
| 220 | ogg_pagecxx . . $ ogg_page# og; |
| 221 | ogg_int64_tcxx . . $ ogg_int64_t# end=begin; |
| 222 | ogg_int64_tcxx . . $ ogg_int64_t# ret; |
| 223 | |
| 224 | ogg_int64_tcxx . . $ ogg_int64_t# prefoffset=-1; |
| 225 | ogg_int64_tcxx . . $ ogg_int64_t# offset=-1; |
| 226 | ogg_int64_tcxx . . $ ogg_int64_t# ret_serialno=-1; |
| 227 | ogg_int64_tcxx . . $ ogg_int64_t# ret_gran=-1; |
| 228 | |
| 229 | while(offset==-1){ |
| 230 | begin-=CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!; |
| 231 | if(begin<0) |
| 232 | begin=0; |
| 233 | |
| 234 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,begin); |
| 235 | if(ret)return(ret); |
| 236 | |
| 237 | while(vf->offsetcxx . . $ OggVorbis_File#offset.<end){ |
| 238 | ret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,end-vf->offsetcxx . . $ OggVorbis_File#offset.); |
| 239 | if(ret==OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!)return(OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!); |
| 240 | if(ret<0){ |
| 241 | break; |
| 242 | }else{ |
| 243 | ret_serialno=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 244 | ret_gran=ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og); |
| 245 | offset=ret; |
| 246 | |
| 247 | if(ret_serialno == *serialno){ |
| 248 | prefoffset=ret; |
| 249 | *granpos=ret_gran; |
| 250 | } |
| 251 | |
| 252 | if(!_lookup_serialnocxx . . $ _lookup_serialno(f2dc718a5a5eeab1).(ret_serialno,serial_list,serial_n)){ |
| 253 | /* we fell off the end of the link, which means we seeked |
| 254 | back too far and shouldn't have been looking in that link |
| 255 | to begin with. If we found the preferred serial number, |
| 256 | forget that we saw it. */ |
| 257 | prefoffset=-1; |
| 258 | } |
| 259 | } |
| 260 | } |
| 261 | /*We started from the beginning of the stream and found nothing. |
| 262 | This should be impossible unless the contents of the stream changed out |
| 263 | from under us after we read from it.*/ |
| 264 | if(!begin&&vf->offsetcxx . . $ OggVorbis_File#offset.<0)return OV_EBADLINKcxx . . $ `external/vorbis/vorbis_codec.h:229:9`!; |
| 265 | } |
| 266 | |
| 267 | /* we're not interested in the page... just the serialno and granpos. */ |
| 268 | if(prefoffset>=0)return(prefoffset); |
| 269 | |
| 270 | *serialno = ret_serialno; |
| 271 | *granpos = ret_gran; |
| 272 | return(offset); |
| 273 | |
| 274 | } |
| 275 | |
| 276 | /* uses the local ogg_stream storage in vf; this is important for |
| 277 | non-streaming input sources */ |
| 278 | static int _fetch_headerscxx . . $ _fetch_headers(65a05cfc26cdb7e0).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,vorbis_infocxx . . $ vorbis_info# *vi,vorbis_commentcxx . . $ vorbis_comment# *vc, |
| 279 | long **serialno_list, int *serialno_n, |
| 280 | ogg_pagecxx . . $ ogg_page# *og_ptr){ |
| 281 | ogg_pagecxx . . $ ogg_page# og; |
| 282 | ogg_packetcxx . . $ ogg_packet# op; |
| 283 | int i,ret; |
| 284 | int allbos=0; |
| 285 | |
| 286 | if(!og_ptr){ |
| 287 | ogg_int64_tcxx . . $ ogg_int64_t# llret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!); |
| 288 | if(llret==OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!)return(OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!); |
| 289 | if(llret<0)return(OV_ENOTVORBIScxx . . $ `external/vorbis/vorbis_codec.h:224:9`!); |
| 290 | og_ptr=&og; |
| 291 | } |
| 292 | |
| 293 | vorbis_info_initcxx . . $ vorbis_info_init(d534a068b27cdae4).(vi); |
| 294 | vorbis_comment_initcxx . . $ vorbis_comment_init(93d47bffb8aa4dc6).(vc); |
| 295 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!; |
| 296 | |
| 297 | /* extract the serialnos of all BOS pages + the first set of vorbis |
| 298 | headers we see in the link */ |
| 299 | |
| 300 | while(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(og_ptr)){ |
| 301 | if(serialno_list){ |
| 302 | if(_lookup_page_serialnocxx . . $ _lookup_page_serialno(afa8961b0de29137).(og_ptr,*serialno_list,*serialno_n)){ |
| 303 | /* a dupe serialnumber in an initial header packet set == invalid stream */ |
| 304 | if(*serialno_list)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(*serialno_list); |
| 305 | *serialno_list=0; |
| 306 | *serialno_n=0; |
| 307 | ret=OV_EBADHEADERcxx . . $ `external/vorbis/vorbis_codec.h:225:9`!; |
| 308 | goto bail_header; |
| 309 | } |
| 310 | |
| 311 | _add_serialnocxx . . $ _add_serialno(9ae7a8d159595342).(og_ptr,serialno_list,serialno_n); |
| 312 | } |
| 313 | |
| 314 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 315 | /* we don't have a vorbis stream in this link yet, so begin |
| 316 | prospective stream setup. We need a stream to get packets */ |
| 317 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og_ptr)); |
| 318 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,og_ptr); |
| 319 | |
| 320 | if(ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op) > 0 && |
| 321 | vorbis_synthesis_idheadercxx . . $ vorbis_synthesis_idheader(93d9f7a6e445c2aa).(&op)){ |
| 322 | /* vorbis header; continue setup */ |
| 323 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!; |
| 324 | if((ret=vorbis_synthesis_headerincxx . . $ vorbis_synthesis_headerin(3ae6e73fba03d214).(vi,vc,&op))){ |
| 325 | ret=OV_EBADHEADERcxx . . $ `external/vorbis/vorbis_codec.h:225:9`!; |
| 326 | goto bail_header; |
| 327 | } |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | /* get next page */ |
| 332 | { |
| 333 | ogg_int64_tcxx . . $ ogg_int64_t# llret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,og_ptr,CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!); |
| 334 | if(llret==OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!){ |
| 335 | ret=OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!; |
| 336 | goto bail_header; |
| 337 | } |
| 338 | if(llret<0){ |
| 339 | ret=OV_ENOTVORBIScxx . . $ `external/vorbis/vorbis_codec.h:224:9`!; |
| 340 | goto bail_header; |
| 341 | } |
| 342 | |
| 343 | /* if this page also belongs to our vorbis stream, submit it and break */ |
| 344 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`! && |
| 345 | vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_d401cdaf801be98c_3#serialno. == ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og_ptr)){ |
| 346 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,og_ptr); |
| 347 | break; |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.!=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 353 | ret = OV_ENOTVORBIScxx . . $ `external/vorbis/vorbis_codec.h:224:9`!; |
| 354 | goto bail_header; |
| 355 | } |
| 356 | |
| 357 | while(1){ |
| 358 | |
| 359 | i=0; |
| 360 | while(i<2){ /* get a page loop */ |
| 361 | |
| 362 | while(i<2){ /* get a packet loop */ |
| 363 | |
| 364 | int result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op); |
| 365 | if(result==0)break; |
| 366 | if(result==-1){ |
| 367 | ret=OV_EBADHEADERcxx . . $ `external/vorbis/vorbis_codec.h:225:9`!; |
| 368 | goto bail_header; |
| 369 | } |
| 370 | |
| 371 | if((ret=vorbis_synthesis_headerincxx . . $ vorbis_synthesis_headerin(3ae6e73fba03d214).(vi,vc,&op))) |
| 372 | goto bail_header; |
| 373 | |
| 374 | i++; |
| 375 | } |
| 376 | |
| 377 | while(i<2){ |
| 378 | if(_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,og_ptr,CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!)<0){ |
| 379 | ret=OV_EBADHEADERcxx . . $ `external/vorbis/vorbis_codec.h:225:9`!; |
| 380 | goto bail_header; |
| 381 | } |
| 382 | |
| 383 | /* if this page belongs to the correct stream, go parse it */ |
| 384 | if(vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_d401cdaf801be98c_3#serialno. == ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(og_ptr)){ |
| 385 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,og_ptr); |
| 386 | break; |
| 387 | } |
| 388 | |
| 389 | /* if we never see the final vorbis headers before the link |
| 390 | ends, abort */ |
| 391 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(og_ptr)){ |
| 392 | if(allbos){ |
| 393 | ret = OV_EBADHEADERcxx . . $ `external/vorbis/vorbis_codec.h:225:9`!; |
| 394 | goto bail_header; |
| 395 | }else |
| 396 | allbos=1; |
| 397 | } |
| 398 | |
| 399 | /* otherwise, keep looking */ |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | return 0; |
| 404 | } |
| 405 | |
| 406 | bail_header: |
| 407 | vorbis_info_clearcxx . . $ vorbis_info_clear(d534a068b27cdae4).(vi); |
| 408 | vorbis_comment_clearcxx . . $ vorbis_comment_clear(93d47bffb8aa4dc6).(vc); |
| 409 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!; |
| 410 | |
| 411 | return ret; |
| 412 | } |
| 413 | |
| 414 | /* Starting from current cursor position, get initial PCM offset of |
| 415 | next page. Consumes the page in the process without decoding |
| 416 | audio, however this is only called during stream parsing upon |
| 417 | seekable open. */ |
| 418 | static ogg_int64_tcxx . . $ ogg_int64_t# _initial_pcmoffsetcxx . . $ _initial_pcmoffset(3d36dd850c0dca84).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf, vorbis_infocxx . . $ vorbis_info# *vi){ |
| 419 | ogg_pagecxx . . $ ogg_page# og; |
| 420 | ogg_int64_tcxx . . $ ogg_int64_t# accumulated=0; |
| 421 | long lastblock=-1; |
| 422 | int result; |
| 423 | int serialno = vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_d401cdaf801be98c_3#serialno.; |
| 424 | |
| 425 | while(1){ |
| 426 | ogg_packetcxx . . $ ogg_packet# op; |
| 427 | if(_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1)<0) |
| 428 | break; /* should not be possible unless the file is truncated/mangled */ |
| 429 | |
| 430 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(&og)) break; |
| 431 | if(ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)!=serialno) continue; |
| 432 | |
| 433 | /* count blocksizes of all frames in the page */ |
| 434 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 435 | while((result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op))){ |
| 436 | if(result>0){ /* ignore holes */ |
| 437 | long thisblock=vorbis_packet_blocksizecxx . . $ vorbis_packet_blocksize(5c730016bfddf4b1).(vi,&op); |
| 438 | if(thisblock>=0){ |
| 439 | if(lastblock!=-1) |
| 440 | accumulated+=(lastblock+thisblock)>>2; |
| 441 | lastblock=thisblock; |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | if(ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og)!=-1){ |
| 447 | /* pcm offset of last packet on the first audio page */ |
| 448 | accumulated= ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og)-accumulated; |
| 449 | break; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | /* less than zero? Either a corrupt file or a stream with samples |
| 454 | trimmed off the beginning, a normal occurrence; in both cases set |
| 455 | the offset to zero */ |
| 456 | if(accumulated<0)accumulated=0; |
| 457 | |
| 458 | return accumulated; |
| 459 | } |
| 460 | |
| 461 | /* finds each bitstream link one at a time using a bisection search |
| 462 | (has to begin by knowing the offset of the lb's initial page). |
| 463 | Recurses for each link so it can alloc the link storage after |
| 464 | finding them all, then unroll and fill the cache at the same time */ |
| 465 | static int _bisect_forward_serialnocxx . . $ _bisect_forward_serialno(680785c34c039759).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf, |
| 466 | ogg_int64_tcxx . . $ ogg_int64_t# begin, |
| 467 | ogg_int64_tcxx . . $ ogg_int64_t# searched, |
| 468 | ogg_int64_tcxx . . $ ogg_int64_t# end, |
| 469 | ogg_int64_tcxx . . $ ogg_int64_t# endgran, |
| 470 | int endserial, |
| 471 | long *currentno_list, |
| 472 | int currentnos, |
| 473 | long m){ |
| 474 | ogg_int64_tcxx . . $ ogg_int64_t# pcmoffset; |
| 475 | ogg_int64_tcxx . . $ ogg_int64_t# dataoffset=searched; |
| 476 | ogg_int64_tcxx . . $ ogg_int64_t# endsearched=end; |
| 477 | ogg_int64_tcxx . . $ ogg_int64_t# next=end; |
| 478 | ogg_int64_tcxx . . $ ogg_int64_t# searchgran=-1; |
| 479 | ogg_pagecxx . . $ ogg_page# og; |
| 480 | ogg_int64_tcxx . . $ ogg_int64_t# ret,last; |
| 481 | int serialno = vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_d401cdaf801be98c_3#serialno.; |
| 482 | |
| 483 | /* invariants: |
| 484 | we have the headers and serialnos for the link beginning at 'begin' |
| 485 | we have the offset and granpos of the last page in the file (potentially |
| 486 | not a page we care about) |
| 487 | */ |
| 488 | |
| 489 | /* Is the last page in our list of current serialnumbers? */ |
| 490 | if(_lookup_serialnocxx . . $ _lookup_serialno(f2dc718a5a5eeab1).(endserial,currentno_list,currentnos)){ |
| 491 | |
| 492 | /* last page is in the starting serialno list, so we've bisected |
| 493 | down to (or just started with) a single link. Now we need to |
| 494 | find the last vorbis page belonging to the first vorbis stream |
| 495 | for this link. */ |
| 496 | searched = end; |
| 497 | while(endserial != serialno){ |
| 498 | endserial = serialno; |
| 499 | searched=_get_prev_page_serialcxx . . $ _get_prev_page_serial(dca12cb43b82d89c).(vf,searched,currentno_list,currentnos,&endserial,&endgran); |
| 500 | } |
| 501 | |
| 502 | vf->linkscxx . . $ OggVorbis_File#links.=m+1; |
| 503 | if(vf->offsetscxx . . $ OggVorbis_File#offsets.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(vf->offsets); |
| 504 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(vf->serialnos); |
| 505 | if(vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(vf->dataoffsets); |
| 506 | |
| 507 | vf->offsetscxx . . $ OggVorbis_File#offsets.=(ogg_int64_tcxx . . $ ogg_int64_t# *)_Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).((vf->linkscxx . . $ OggVorbis_File#links.+1)*sizeof(*vf->offsetscxx . . $ OggVorbis_File#offsets.)); |
| 508 | vf->vicxx . . $ OggVorbis_File#vi.=(vorbis_infocxx . . $ vorbis_info# *)Melder_realloccxx . . $ Melder_realloc(d42fd80046fa8ace).(vf->vicxx . . $ OggVorbis_File#vi.,vf->linkscxx . . $ OggVorbis_File#links.*sizeof(*vf->vicxx . . $ OggVorbis_File#vi.)); |
| 509 | vf->vccxx . . $ OggVorbis_File#vc.=(vorbis_commentcxx . . $ vorbis_comment# *)Melder_realloccxx . . $ Melder_realloc(d42fd80046fa8ace).(vf->vccxx . . $ OggVorbis_File#vc.,vf->linkscxx . . $ OggVorbis_File#links.*sizeof(*vf->vccxx . . $ OggVorbis_File#vc.)); |
| 510 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.=(long *)_Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(vf->linkscxx . . $ OggVorbis_File#links.*sizeof(*vf->serialnoscxx . . $ OggVorbis_File#serialnos.)); |
| 511 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.=(ogg_int64_tcxx . . $ ogg_int64_t# *)_Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(vf->linkscxx . . $ OggVorbis_File#links.*sizeof(*vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.)); |
| 512 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.=(ogg_int64_tcxx . . $ ogg_int64_t# *)_Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(vf->linkscxx . . $ OggVorbis_File#links.*2*sizeof(*vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.)); |
| 513 | |
| 514 | vf->offsetscxx . . $ OggVorbis_File#offsets.[m+1]=end; |
| 515 | vf->offsetscxx . . $ OggVorbis_File#offsets.[m]=begin; |
| 516 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+1]=(endgran<0?0:endgran); |
| 517 | |
| 518 | }else{ |
| 519 | |
| 520 | /* last page is not in the starting stream's serial number list, |
| 521 | so we have multiple links. Find where the stream that begins |
| 522 | our bisection ends. */ |
| 523 | |
| 524 | long *next_serialno_list=nullptr; |
| 525 | int next_serialnos=0; |
| 526 | vorbis_infocxx . . $ vorbis_info# vi; |
| 527 | vorbis_commentcxx . . $ vorbis_comment# vc; |
| 528 | int testserial = serialno+1; |
| 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 . . $ `external/vorbis/vorbisfile.cpp:57:9`!){ |
| 536 | bisect=searched; |
| 537 | }else{ |
| 538 | bisect=(searched+endsearched)/2; |
| 539 | } |
| 540 | |
| 541 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,bisect); |
| 542 | if(ret)return(ret); |
| 543 | |
| 544 | last=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1); |
| 545 | if(last==OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!)return(OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!); |
| 546 | if(last<0 || !_lookup_page_serialnocxx . . $ _lookup_page_serialno(afa8961b0de29137).(&og,currentno_list,currentnos)){ |
| 547 | endsearched=bisect; |
| 548 | if(last>=0)next=last; |
| 549 | }else{ |
| 550 | searched=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | /* Bisection point found */ |
| 555 | /* for the time being, fetch end PCM offset the simple way */ |
| 556 | searched = next; |
| 557 | while(testserial != serialno){ |
| 558 | testserial = serialno; |
| 559 | searched = _get_prev_page_serialcxx . . $ _get_prev_page_serial(dca12cb43b82d89c).(vf,searched,currentno_list,currentnos,&testserial,&searchgran); |
| 560 | } |
| 561 | |
| 562 | ret=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,next); |
| 563 | if(ret)return(ret); |
| 564 | |
| 565 | ret=_fetch_headerscxx . . $ _fetch_headers(65a05cfc26cdb7e0).(vf,&vi,&vc,&next_serialno_list,&next_serialnos,nullptr); |
| 566 | if(ret)return(ret); |
| 567 | serialno = vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_d401cdaf801be98c_3#serialno.; |
| 568 | dataoffset = vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 569 | |
| 570 | /* this will consume a page, however the next bisection always |
| 571 | starts with a raw seek */ |
| 572 | pcmoffset = _initial_pcmoffsetcxx . . $ _initial_pcmoffset(3d36dd850c0dca84).(vf,&vi); |
| 573 | |
| 574 | ret=_bisect_forward_serialnocxx . . $ _bisect_forward_serialno(680785c34c039759).(vf,next,vf->offsetcxx . . $ OggVorbis_File#offset.,end,endgran,endserial, |
| 575 | next_serialno_list,next_serialnos,m+1); |
| 576 | if(ret)return(ret); |
| 577 | |
| 578 | if(next_serialno_list)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(next_serialno_list); |
| 579 | |
| 580 | vf->offsetscxx . . $ OggVorbis_File#offsets.[m+1]=next; |
| 581 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.[m+1]=serialno; |
| 582 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[m+1]=dataoffset; |
| 583 | |
| 584 | vf->vicxx . . $ OggVorbis_File#vi.[m+1]=cxx . . $ vorbis_info#`operator=`(405e5f5d9cf66c7e).vi; |
| 585 | vf->vccxx . . $ OggVorbis_File#vc.[m+1]=cxx . . $ vorbis_comment#`operator=`(73facc5ed6d3ae6a).vc; |
| 586 | |
| 587 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+1]=searchgran; |
| 588 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+2]=pcmoffset; |
| 589 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+3]-=pcmoffset; |
| 590 | if(vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+3]<0)vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[m*2+3]=0; |
| 591 | } |
| 592 | return(0); |
| 593 | } |
| 594 | |
| 595 | static int _make_decode_readycxx . . $ _make_decode_ready(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 596 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!)return 0; |
| 597 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!)return OV_EFAULTcxx . . $ `external/vorbis/vorbis_codec.h:221:9`!; |
| 598 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 599 | 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.)) |
| 600 | return OV_EBADLINKcxx . . $ `external/vorbis/vorbis_codec.h:229:9`!; |
| 601 | }else{ |
| 602 | if(vorbis_synthesis_initcxx . . $ vorbis_synthesis_init(eac5c897194134f0).(&vf->vdcxx . . $ OggVorbis_File#vd.,vf->vicxx . . $ OggVorbis_File#vi.)) |
| 603 | return OV_EBADLINKcxx . . $ `external/vorbis/vorbis_codec.h:229:9`!; |
| 604 | } |
| 605 | vorbis_block_initcxx . . $ vorbis_block_init(c8f1c0cf9c31dd14).(&vf->vdcxx . . $ OggVorbis_File#vd.,&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 606 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=INITSETcxx . . $ `external/vorbis/vorbisfile.h:69:10`!; |
| 607 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0.f; |
| 608 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0.f; |
| 609 | return 0; |
| 610 | } |
| 611 | |
| 612 | static int _open_seekable2cxx . . $ _open_seekable2(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 613 | ogg_int64_tcxx . . $ ogg_int64_t# dataoffset=vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[0],end,endgran=-1; |
| 614 | int endserial=vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_d401cdaf801be98c_3#serialno.; |
| 615 | int serialno=vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_d401cdaf801be98c_3#serialno.; |
| 616 | |
| 617 | /* we're partially open and have a first link header state in |
| 618 | storage in vf */ |
| 619 | |
| 620 | /* fetch initial PCM offset */ |
| 621 | ogg_int64_tcxx . . $ ogg_int64_t# pcmoffset = _initial_pcmoffsetcxx . . $ _initial_pcmoffset(3d36dd850c0dca84).(vf,vf->vicxx . . $ OggVorbis_File#vi.); |
| 622 | |
| 623 | /* we can seek, so set out learning all about this file */ |
| 624 | if(vf->callbackscxx . . $ OggVorbis_File#callbacks..seek_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#seek_func. && vf->callbackscxx . . $ OggVorbis_File#callbacks..tell_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#tell_func.){ |
| 625 | (vf->callbackscxx . . $ OggVorbis_File#callbacks..seek_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#seek_func.)(vf->datasourcecxx . . $ OggVorbis_File#datasource.,0,SEEK_ENDcxx . . $ `<external>/232824719582829767/stdio.h:112:9`!); |
| 626 | vf->offsetcxx . . $ OggVorbis_File#offset.=vf->endcxx . . $ OggVorbis_File#end.=(vf->callbackscxx . . $ OggVorbis_File#callbacks..tell_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#tell_func.)(vf->datasourcecxx . . $ OggVorbis_File#datasource.); |
| 627 | }else{ |
| 628 | vf->offsetcxx . . $ OggVorbis_File#offset.=vf->endcxx . . $ OggVorbis_File#end.=-1; |
| 629 | } |
| 630 | |
| 631 | /* If seek_func is implemented, tell_func must also be implemented */ |
| 632 | if(vf->endcxx . . $ OggVorbis_File#end.==-1) return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 633 | |
| 634 | /* Get the offset of the last page of the physical bitstream, or, if |
| 635 | we're lucky the last vorbis page of this link as most OggVorbis |
| 636 | files will contain a single logical bitstream */ |
| 637 | end=_get_prev_page_serialcxx . . $ _get_prev_page_serial(dca12cb43b82d89c).(vf,vf->endcxx . . $ OggVorbis_File#end.,vf->serialnoscxx . . $ OggVorbis_File#serialnos.+2,vf->serialnoscxx . . $ OggVorbis_File#serialnos.[1],&endserial,&endgran); |
| 638 | if(end<0)return(end); |
| 639 | |
| 640 | /* now determine bitstream structure recursively */ |
| 641 | if(_bisect_forward_serialnocxx . . $ _bisect_forward_serialno(680785c34c039759).(vf,0,dataoffset,end,endgran,endserial, |
| 642 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.+2,vf->serialnoscxx . . $ OggVorbis_File#serialnos.[1],0)<0)return(OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!); |
| 643 | |
| 644 | vf->offsetscxx . . $ OggVorbis_File#offsets.[0]=0; |
| 645 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.[0]=serialno; |
| 646 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[0]=dataoffset; |
| 647 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[0]=pcmoffset; |
| 648 | vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[1]-=pcmoffset; |
| 649 | if(vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[1]<0)vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[1]=0; |
| 650 | |
| 651 | return(ov_raw_seekcxx . . $ ov_raw_seek(2602c1e715810f3a).(vf,dataoffset)); |
| 652 | } |
| 653 | |
| 654 | /* clear out the current logical bitstream decoder */ |
| 655 | static void _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 656 | vorbis_dsp_clearcxx . . $ vorbis_dsp_clear(1841c7801a59e076).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 657 | vorbis_block_clearcxx . . $ vorbis_block_clear(e7ca6336a14cf342).(&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 658 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!; |
| 659 | } |
| 660 | |
| 661 | /* fetch and process a packet. Handles the case where we're at a |
| 662 | bitstream boundary and dumps the decoding machine. If the decoding |
| 663 | machine is unloaded, it loads it. It also keeps pcm_offset up to |
| 664 | date (seek and read both use this. seek uses a special hack with |
| 665 | readp). |
| 666 | |
| 667 | return: <0) error, OV_HOLE (lost packet) or OV_EOF |
| 668 | 0) need more data (only if readp==0) |
| 669 | 1) got a packet |
| 670 | */ |
| 671 | |
| 672 | static int _fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf, |
| 673 | ogg_packetcxx . . $ ogg_packet# *op_in, |
| 674 | int readp, |
| 675 | int spanp){ |
| 676 | ogg_pagecxx . . $ ogg_page# og; |
| 677 | |
| 678 | /* handle one packet. Try to fetch it from current stream state */ |
| 679 | /* extract packets from page */ |
| 680 | while(1){ |
| 681 | |
| 682 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 683 | int ret=_make_decode_readycxx . . $ _make_decode_ready(231cee6479b09f2b).(vf); |
| 684 | if(ret<0)return ret; |
| 685 | } |
| 686 | |
| 687 | /* process a packet if we can. */ |
| 688 | |
| 689 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==INITSETcxx . . $ `external/vorbis/vorbisfile.h:69:10`!){ |
| 690 | int hs=vorbis_synthesis_halfrate_pcxx . . $ vorbis_synthesis_halfrate_p(8afef93073a461ef).(vf->vicxx . . $ OggVorbis_File#vi.); |
| 691 | |
| 692 | while(1) { |
| 693 | ogg_packetcxx . . $ ogg_packet# op; |
| 694 | ogg_packetcxx . . $ ogg_packet# *op_ptr=(op_in?op_in:&op); |
| 695 | int result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,op_ptr); |
| 696 | ogg_int64_tcxx . . $ ogg_int64_t# granulepos; |
| 697 | |
| 698 | op_in=nullptr; |
| 699 | if(result==-1)return(OV_HOLEcxx . . $ `external/vorbis/vorbis_codec.h:218:9`!); /* hole in the data. */ |
| 700 | if(result>0){ |
| 701 | /* got a packet. process it */ |
| 702 | granulepos=op_ptr->granuleposcxx . . $ $anonymous_type_d401cdaf801be98c_4#granulepos.; |
| 703 | if(!vorbis_synthesiscxx . . $ vorbis_synthesis(e9de88148c52a299).(&vf->vbcxx . . $ OggVorbis_File#vb.,op_ptr)){ /* lazy check for lazy |
| 704 | header handling. The |
| 705 | header packets aren't |
| 706 | audio, so if/when we |
| 707 | submit them, |
| 708 | vorbis_synthesis will |
| 709 | reject them */ |
| 710 | |
| 711 | /* suck in the synthesis data and track bitrate */ |
| 712 | { |
| 713 | int oldsamples=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(fd400e10b261aeec).(&vf->vdcxx . . $ OggVorbis_File#vd.,nullptr); |
| 714 | /* for proper use of libvorbis within libvorbisfile, |
| 715 | oldsamples will always be zero. */ |
| 716 | if(oldsamples)return(OV_EFAULTcxx . . $ `external/vorbis/vorbis_codec.h:221:9`!); |
| 717 | |
| 718 | vorbis_synthesis_blockincxx . . $ vorbis_synthesis_blockin(c8f1c0cf9c31dd14).(&vf->vdcxx . . $ OggVorbis_File#vd.,&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 719 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.+=(vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(fd400e10b261aeec).(&vf->vdcxx . . $ OggVorbis_File#vd.,nullptr)<<hs); |
| 720 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.+=op_ptr->bytescxx . . $ $anonymous_type_d401cdaf801be98c_4#bytes.*8; |
| 721 | } |
| 722 | |
| 723 | /* update the pcm offset. */ |
| 724 | if(granulepos!=-1 && !op_ptr->e_o_scxx . . $ $anonymous_type_d401cdaf801be98c_4#e_o_s.){ |
| 725 | int link=(vf->seekablecxx . . $ OggVorbis_File#seekable.?vf->current_linkcxx . . $ OggVorbis_File#current_link.:0); |
| 726 | int i,samples; |
| 727 | |
| 728 | /* this packet has a pcm_offset on it (the last packet |
| 729 | completed on a page carries the offset) After processing |
| 730 | (above), we know the pcm position of the *last* sample |
| 731 | ready to be returned. Find the offset of the *first* |
| 732 | |
| 733 | As an aside, this trick is inaccurate if we begin |
| 734 | reading anew right at the last page; the end-of-stream |
| 735 | granulepos declares the last frame in the stream, and the |
| 736 | last packet of the last page may be a partial frame. |
| 737 | So, we need a previous granulepos from an in-sequence page |
| 738 | to have a reference point. Thus the !op_ptr->e_o_s clause |
| 739 | above */ |
| 740 | |
| 741 | if(vf->seekablecxx . . $ OggVorbis_File#seekable. && link>0) |
| 742 | granulepos-=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2]; |
| 743 | if(granulepos<0)granulepos=0; /* actually, this |
| 744 | shouldn't be possible |
| 745 | here unless the stream |
| 746 | is very broken */ |
| 747 | |
| 748 | samples=(vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(fd400e10b261aeec).(&vf->vdcxx . . $ OggVorbis_File#vd.,nullptr)<<hs); |
| 749 | |
| 750 | granulepos-=samples; |
| 751 | for(i=0;i<link;i++) |
| 752 | granulepos+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1]; |
| 753 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=granulepos; |
| 754 | } |
| 755 | return(1); |
| 756 | } |
| 757 | } |
| 758 | else |
| 759 | break; |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!){ |
| 764 | ogg_int64_tcxx . . $ ogg_int64_t# ret; |
| 765 | |
| 766 | while(1){ |
| 767 | /* the loop is not strictly necessary, but there's no sense in |
| 768 | doing the extra checks of the larger loop for the common |
| 769 | case in a multiplexed bistream where the page is simply |
| 770 | part of a different logical bitstream; keep reading until |
| 771 | we get one with the correct serialno */ |
| 772 | |
| 773 | if(!readp)return(0); |
| 774 | if((ret=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1))<0){ |
| 775 | return(OV_EOFcxx . . $ `external/vorbis/vorbis_codec.h:217:9`!); /* eof. leave unitialized */ |
| 776 | } |
| 777 | |
| 778 | /* bitrate tracking; add the header's bytes here, the body bytes |
| 779 | are done by packet above */ |
| 780 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.+=og.header_lencxx . . $ $anonymous_type_d401cdaf801be98c_2#header_len.*8; |
| 781 | |
| 782 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==INITSETcxx . . $ `external/vorbis/vorbisfile.h:69:10`!){ |
| 783 | if(vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.!=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)){ |
| 784 | |
| 785 | /* two possibilities: |
| 786 | 1) our decoding just traversed a bitstream boundary |
| 787 | 2) another stream is multiplexed into this logical section */ |
| 788 | |
| 789 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(&og)){ |
| 790 | /* boundary case */ |
| 791 | if(!spanp) |
| 792 | return(OV_EOFcxx . . $ `external/vorbis/vorbis_codec.h:217:9`!); |
| 793 | |
| 794 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 795 | |
| 796 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 797 | vorbis_info_clearcxx . . $ vorbis_info_clear(d534a068b27cdae4).(vf->vicxx . . $ OggVorbis_File#vi.); |
| 798 | vorbis_comment_clearcxx . . $ vorbis_comment_clear(93d47bffb8aa4dc6).(vf->vccxx . . $ OggVorbis_File#vc.); |
| 799 | } |
| 800 | break; |
| 801 | |
| 802 | }else |
| 803 | continue; /* possibility #2 */ |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | break; |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | /* Do we need to load a new machine before submitting the page? */ |
| 812 | /* This is different in the seekable and non-seekable cases. |
| 813 | |
| 814 | In the seekable case, we already have all the header |
| 815 | information loaded and cached; we just initialize the machine |
| 816 | with it and continue on our merry way. |
| 817 | |
| 818 | In the non-seekable (streaming) case, we'll only be at a |
| 819 | boundary if we just left the previous logical bitstream and |
| 820 | we're now nominally at the header of the next bitstream |
| 821 | */ |
| 822 | |
| 823 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.!=INITSETcxx . . $ `external/vorbis/vorbisfile.h:69:10`!){ |
| 824 | int link; |
| 825 | |
| 826 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 827 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 828 | long serialno = ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 829 | |
| 830 | /* match the serialno to bitstream section. We use this rather than |
| 831 | offset positions to avoid problems near logical bitstream |
| 832 | boundaries */ |
| 833 | |
| 834 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++) |
| 835 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]==serialno)break; |
| 836 | |
| 837 | if(link==vf->linkscxx . . $ OggVorbis_File#links.) continue; /* not the desired Vorbis |
| 838 | bitstream section; keep |
| 839 | trying */ |
| 840 | |
| 841 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=serialno; |
| 842 | vf->current_linkcxx . . $ OggVorbis_File#current_link.=link; |
| 843 | |
| 844 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); |
| 845 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!; |
| 846 | |
| 847 | }else{ |
| 848 | /* we're streaming */ |
| 849 | /* fetch the three header packets, build the info struct */ |
| 850 | |
| 851 | int ret=_fetch_headerscxx . . $ _fetch_headers(65a05cfc26cdb7e0).(vf,vf->vicxx . . $ OggVorbis_File#vi.,vf->vccxx . . $ OggVorbis_File#vc.,nullptr,nullptr,&og); |
| 852 | if(ret)return(ret); |
| 853 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_d401cdaf801be98c_3#serialno.; |
| 854 | vf->current_linkcxx . . $ OggVorbis_File#current_link.++; |
| 855 | link=0; |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | |
| 860 | /* the buffered page is the data we want, and we're ready for it; |
| 861 | add it to the stream state */ |
| 862 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 863 | |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | /* if, eg, 64 bit stdio is configured by default, this will build with |
| 868 | fseek64 */ |
| 869 | static int _fseek64_wrapcxx . . $ _fseek64_wrap(543fae30d249f6b1).(FILE *f,ogg_int64_tcxx . . $ ogg_int64_t# off,int whence){ |
| 870 | if(f==nullptr)return(-1); |
| 871 | return fseek(f,off,whence); |
| 872 | } |
| 873 | |
| 874 | static int _ov_open1cxx . . $ _ov_open1(80dfd33e0e406a85).(void *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf,const char *initial, |
| 875 | long ibytes, ov_callbackscxx . . $ ov_callbacks# callbacks){ |
| 876 | int offsettest=((f && callbacks.seek_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#seek_func.)?callbacks.seek_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#seek_func.(f,0,SEEK_CURcxx . . $ `<external>/232824719582829767/stdio.h:111:9`!):-1); |
| 877 | long *serialno_list=nullptr; |
| 878 | int serialno_list_size=0; |
| 879 | int ret; |
| 880 | |
| 881 | memset(vf,0,sizeof(*vf)); |
| 882 | vf->datasourcecxx . . $ OggVorbis_File#datasource.=f; |
| 883 | vf->callbackscxx . . $ OggVorbis_File#callbacks. =cxx . . $ $anonymous_type_611a44db95ee9eb6_0#`operator=`(517a35f0d5a5f143). callbacks; |
| 884 | |
| 885 | /* init the framing state */ |
| 886 | ogg_sync_initcxx . . $ ogg_sync_init(4d079e1537bb6e53).(&vf->oycxx . . $ OggVorbis_File#oy.); |
| 887 | |
| 888 | /* perhaps some data was previously read into a buffer for testing |
| 889 | against other stream types. Allow initialization from this |
| 890 | previously read data (especially as we may be reading from a |
| 891 | non-seekable stream) */ |
| 892 | if(initial){ |
| 893 | char *buffer=ogg_sync_buffercxx . . $ ogg_sync_buffer(16ea7c6d847c120d).(&vf->oycxx . . $ OggVorbis_File#oy.,ibytes); |
| 894 | memcpy(buffer,initial,ibytes); |
| 895 | ogg_sync_wrotecxx . . $ ogg_sync_wrote(7ecdafb9a73216e5).(&vf->oycxx . . $ OggVorbis_File#oy.,ibytes); |
| 896 | } |
| 897 | |
| 898 | /* can we seek? Stevens suggests the seek test was portable */ |
| 899 | if(offsettest!=-1)vf->seekablecxx . . $ OggVorbis_File#seekable.=1; |
| 900 | |
| 901 | /* No seeking yet; Set up a 'single' (current) logical bitstream |
| 902 | entry for partial open */ |
| 903 | vf->linkscxx . . $ OggVorbis_File#links.=1; |
| 904 | vf->vicxx . . $ OggVorbis_File#vi.=(vorbis_infocxx . . $ vorbis_info# *)_Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb).(vf->linkscxx . . $ OggVorbis_File#links.,sizeof(*vf->vicxx . . $ OggVorbis_File#vi.)); |
| 905 | vf->vccxx . . $ OggVorbis_File#vc.=(vorbis_commentcxx . . $ vorbis_comment# *)_Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb).(vf->linkscxx . . $ OggVorbis_File#links.,sizeof(*vf->vccxx . . $ OggVorbis_File#vc.)); |
| 906 | ogg_stream_initcxx . . $ ogg_stream_init(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,-1); /* fill in the serialno later */ |
| 907 | |
| 908 | /* Fetch all BOS pages, store the vorbis header and all seen serial |
| 909 | numbers, load subsequent vorbis setup headers */ |
| 910 | if((ret=_fetch_headerscxx . . $ _fetch_headers(65a05cfc26cdb7e0).(vf,vf->vicxx . . $ OggVorbis_File#vi.,vf->vccxx . . $ OggVorbis_File#vc.,&serialno_list,&serialno_list_size,nullptr))<0){ |
| 911 | vf->datasourcecxx . . $ OggVorbis_File#datasource.=nullptr; |
| 912 | ov_clearcxx . . $ ov_clear(231cee6479b09f2b).(vf); |
| 913 | }else{ |
| 914 | /* serial number list for first link needs to be held somewhere |
| 915 | for second stage of seekable stream open; this saves having to |
| 916 | seek/reread first link's serialnumber data then. */ |
| 917 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.=(long *)_Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb).(serialno_list_size+2,sizeof(*vf->serialnoscxx . . $ OggVorbis_File#serialnos.)); |
| 918 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.[0]=vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=vf->oscxx . . $ OggVorbis_File#os..serialnocxx . . $ $anonymous_type_d401cdaf801be98c_3#serialno.; |
| 919 | vf->serialnoscxx . . $ OggVorbis_File#serialnos.[1]=serialno_list_size; |
| 920 | memcpy(vf->serialnoscxx . . $ OggVorbis_File#serialnos.+2,serialno_list,serialno_list_size*sizeof(*vf->serialnoscxx . . $ OggVorbis_File#serialnos.)); |
| 921 | |
| 922 | vf->offsetscxx . . $ OggVorbis_File#offsets.=(ogg_int64_tcxx . . $ ogg_int64_t# *)_Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb).(1,sizeof(*vf->offsetscxx . . $ OggVorbis_File#offsets.)); |
| 923 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.=(ogg_int64_tcxx . . $ ogg_int64_t# *)_Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb).(1,sizeof(*vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.)); |
| 924 | vf->offsetscxx . . $ OggVorbis_File#offsets.[0]=0; |
| 925 | vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[0]=vf->offsetcxx . . $ OggVorbis_File#offset.; |
| 926 | |
| 927 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=PARTOPENcxx . . $ `external/vorbis/vorbisfile.h:66:10`!; |
| 928 | } |
| 929 | if(serialno_list)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(serialno_list); |
| 930 | return(ret); |
| 931 | } |
| 932 | |
| 933 | static int _ov_open2cxx . . $ _ov_open2(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 934 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state. != PARTOPENcxx . . $ `external/vorbis/vorbisfile.h:66:10`!) return OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!; |
| 935 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!; |
| 936 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 937 | int ret=_open_seekable2cxx . . $ _open_seekable2(231cee6479b09f2b).(vf); |
| 938 | if(ret){ |
| 939 | vf->datasourcecxx . . $ OggVorbis_File#datasource.=nullptr; |
| 940 | ov_clearcxx . . $ ov_clear(231cee6479b09f2b).(vf); |
| 941 | } |
| 942 | return(ret); |
| 943 | }else |
| 944 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!; |
| 945 | |
| 946 | return 0; |
| 947 | } |
| 948 | |
| 949 | |
| 950 | /* clear out the OggVorbis_File struct */ |
| 951 | int ov_clearcxx . . $ ov_clear(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 952 | if(vf){ |
| 953 | vorbis_block_clearcxx . . $ vorbis_block_clear(e7ca6336a14cf342).(&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 954 | vorbis_dsp_clearcxx . . $ vorbis_dsp_clear(1841c7801a59e076).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 955 | ogg_stream_clearcxx . . $ ogg_stream_clear(d9e3535bee9e7016).(&vf->oscxx . . $ OggVorbis_File#os.); |
| 956 | |
| 957 | if(vf->vicxx . . $ OggVorbis_File#vi. && vf->linkscxx . . $ OggVorbis_File#links.){ |
| 958 | int i; |
| 959 | for(i=0;i<vf->linkscxx . . $ OggVorbis_File#links.;i++){ |
| 960 | vorbis_info_clearcxx . . $ vorbis_info_clear(d534a068b27cdae4).(vf->vicxx . . $ OggVorbis_File#vi.+i); |
| 961 | vorbis_comment_clearcxx . . $ vorbis_comment_clear(93d47bffb8aa4dc6).(vf->vccxx . . $ OggVorbis_File#vc.+i); |
| 962 | } |
| 963 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(vf->vi); |
| 964 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(vf->vc); |
| 965 | } |
| 966 | if(vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(vf->dataoffsets); |
| 967 | if(vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(vf->pcmlengths); |
| 968 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(vf->serialnos); |
| 969 | if(vf->offsetscxx . . $ OggVorbis_File#offsets.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(vf->offsets); |
| 970 | ogg_sync_clearcxx . . $ ogg_sync_clear(4d079e1537bb6e53).(&vf->oycxx . . $ OggVorbis_File#oy.); |
| 971 | if(vf->datasourcecxx . . $ OggVorbis_File#datasource. && vf->callbackscxx . . $ OggVorbis_File#callbacks..close_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#close_func.) |
| 972 | (vf->callbackscxx . . $ OggVorbis_File#callbacks..close_funccxx . . $ $anonymous_type_611a44db95ee9eb6_0#close_func.)(vf->datasourcecxx . . $ OggVorbis_File#datasource.); |
| 973 | memset(vf,0,sizeof(*vf)); |
| 974 | } |
| 975 | #ifdef DEBUG_LEAKS |
| 976 | _VDBG_dump(); |
| 977 | #endif |
| 978 | return(0); |
| 979 | } |
| 980 | |
| 981 | /* inspects the OggVorbis file and finds/documents all the logical |
| 982 | bitstreams contained in it. Tries to be tolerant of logical |
| 983 | bitstream sections that are truncated/woogie. |
| 984 | |
| 985 | return: -1) error |
| 986 | 0) OK |
| 987 | */ |
| 988 | |
| 989 | int ov_open_callbackscxx . . $ ov_open_callbacks(80dfd33e0e406a85).(void *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf, |
| 990 | const char *initial,long ibytes,ov_callbackscxx . . $ ov_callbacks# callbacks){ |
| 991 | int ret=_ov_open1cxx . . $ _ov_open1(80dfd33e0e406a85).(f,vf,initial,ibytes,callbacks); |
| 992 | if(ret)return ret; |
| 993 | return _ov_open2cxx . . $ _ov_open2(231cee6479b09f2b).(vf); |
| 994 | } |
| 995 | |
| 996 | int ov_opencxx . . $ ov_open(14abe1420fd41867).(FILE *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf,const char *initial,long ibytes){ |
| 997 | ov_callbackscxx . . $ ov_callbacks# callbacks = { |
| 998 | (size_t (*)(void *, size_t, size_t, void *)) fread, |
| 999 | (int (*)(void *, ogg_int64_tcxx . . $ ogg_int64_t#, int)) _fseek64_wrapcxx . . $ _fseek64_wrap(543fae30d249f6b1)., |
| 1000 | (int (*)(void *)) fclose, |
| 1001 | (long (*)(void *)) ftell |
| 1002 | }; |
| 1003 | |
| 1004 | return ov_open_callbackscxx . . $ ov_open_callbacks(80dfd33e0e406a85).((void *)f, vf, initial, ibytes, callbacks); |
| 1005 | } |
| 1006 | |
| 1007 | int ov_fopencxx . . $ ov_fopen(b3b59e4e0121f5e7).(const char *path,OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1008 | int ret; |
| 1009 | FILE *f = fopen(path,"rb"); |
| 1010 | if(!f) return -1; |
| 1011 | |
| 1012 | ret = ov_opencxx . . $ ov_open(14abe1420fd41867).(f,vf,nullptr,0); |
| 1013 | if(ret) fclose(f); |
| 1014 | return ret; |
| 1015 | } |
| 1016 | |
| 1017 | |
| 1018 | /* cheap hack for game usage where downsampling is desirable; there's |
| 1019 | no need for SRC as we can just do it cheaply in libvorbis. */ |
| 1020 | |
| 1021 | int ov_halfratecxx . . $ ov_halfrate(dc3d5f1026a70579).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int flag){ |
| 1022 | int i; |
| 1023 | if(vf->vicxx . . $ OggVorbis_File#vi.==nullptr)return OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!; |
| 1024 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 1025 | /* clear out stream state; dumping the decode machine is needed to |
| 1026 | reinit the MDCT lookups. */ |
| 1027 | vorbis_dsp_clearcxx . . $ vorbis_dsp_clear(1841c7801a59e076).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 1028 | vorbis_block_clearcxx . . $ vorbis_block_clear(e7ca6336a14cf342).(&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 1029 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!; |
| 1030 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.>=0){ |
| 1031 | ogg_int64_tcxx . . $ ogg_int64_t# pos=vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.; |
| 1032 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; /* make sure the pos is dumped if unseekable */ |
| 1033 | ov_pcm_seekcxx . . $ ov_pcm_seek(2602c1e715810f3a).(vf,pos); |
| 1034 | } |
| 1035 | } |
| 1036 | |
| 1037 | for(i=0;i<vf->linkscxx . . $ OggVorbis_File#links.;i++){ |
| 1038 | if(vorbis_synthesis_halfratecxx . . $ vorbis_synthesis_halfrate(567c21d5828d03ac).(vf->vicxx . . $ OggVorbis_File#vi.+i,flag)){ |
| 1039 | if(flag) ov_halfratecxx . . $ ov_halfrate(dc3d5f1026a70579).(vf,0); |
| 1040 | return OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!; |
| 1041 | } |
| 1042 | } |
| 1043 | return 0; |
| 1044 | } |
| 1045 | |
| 1046 | int ov_halfrate_pcxx . . $ ov_halfrate_p(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1047 | if(vf->vicxx . . $ OggVorbis_File#vi.==nullptr)return OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!; |
| 1048 | return vorbis_synthesis_halfrate_pcxx . . $ vorbis_synthesis_halfrate_p(8afef93073a461ef).(vf->vicxx . . $ OggVorbis_File#vi.); |
| 1049 | } |
| 1050 | |
| 1051 | /* Only partially open the vorbis file; test for Vorbisness, and load |
| 1052 | the headers for the first chain. Do not seek (although test for |
| 1053 | seekability). Use ov_test_open to finish opening the file, else |
| 1054 | ov_clear to close/free it. Same return codes as open. |
| 1055 | |
| 1056 | Note that vorbisfile does _not_ take ownership of the file if the |
| 1057 | call fails; the calling applicaiton is responsible for closing the file |
| 1058 | if this call returns an error. */ |
| 1059 | |
| 1060 | int ov_test_callbackscxx . . $ ov_test_callbacks(80dfd33e0e406a85).(void *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf, |
| 1061 | const char *initial,long ibytes,ov_callbackscxx . . $ ov_callbacks# callbacks) |
| 1062 | { |
| 1063 | return _ov_open1cxx . . $ _ov_open1(80dfd33e0e406a85).(f,vf,initial,ibytes,callbacks); |
| 1064 | } |
| 1065 | |
| 1066 | int ov_testcxx . . $ ov_test(14abe1420fd41867).(FILE *f,OggVorbis_Filecxx . . $ OggVorbis_File# *vf,const char *initial,long ibytes){ |
| 1067 | ov_callbackscxx . . $ ov_callbacks# callbacks = { |
| 1068 | (size_t (*)(void *, size_t, size_t, void *)) fread, |
| 1069 | (int (*)(void *, ogg_int64_tcxx . . $ ogg_int64_t#, int)) _fseek64_wrapcxx . . $ _fseek64_wrap(543fae30d249f6b1)., |
| 1070 | (int (*)(void *)) fclose, |
| 1071 | (long (*)(void *)) ftell |
| 1072 | }; |
| 1073 | |
| 1074 | return ov_test_callbackscxx . . $ ov_test_callbacks(80dfd33e0e406a85).((void *)f, vf, initial, ibytes, callbacks); |
| 1075 | } |
| 1076 | |
| 1077 | int ov_test_opencxx . . $ ov_test_open(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1078 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.!=PARTOPENcxx . . $ `external/vorbis/vorbisfile.h:66:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1079 | return _ov_open2cxx . . $ _ov_open2(231cee6479b09f2b).(vf); |
| 1080 | } |
| 1081 | |
| 1082 | /* How many logical bitstreams in this physical bitstream? */ |
| 1083 | long ov_streamscxx . . $ ov_streams(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1084 | return vf->linkscxx . . $ OggVorbis_File#links.; |
| 1085 | } |
| 1086 | |
| 1087 | /* Is the FILE * associated with vf seekable? */ |
| 1088 | long ov_seekablecxx . . $ ov_seekable(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1089 | return vf->seekablecxx . . $ OggVorbis_File#seekable.; |
| 1090 | } |
| 1091 | |
| 1092 | /* returns the bitrate for a given logical bitstream or the entire |
| 1093 | physical bitstream. If the file is open for random access, it will |
| 1094 | find the *actual* average bitrate. If the file is streaming, it |
| 1095 | returns the nominal bitrate (if set) else the average of the |
| 1096 | upper/lower bounds (if set) else -1 (unset). |
| 1097 | |
| 1098 | If you want the actual bitrate field settings, get them from the |
| 1099 | vorbis_info structs */ |
| 1100 | |
| 1101 | long ov_bitratecxx . . $ ov_bitrate(848dcfd6565c9c04).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1102 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1103 | if(i>=vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1104 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. && i!=0)return(ov_bitratecxx . . $ ov_bitrate(848dcfd6565c9c04).(vf,0)); |
| 1105 | if(i<0){ |
| 1106 | ogg_int64_tcxx . . $ ogg_int64_t# bits=0; |
| 1107 | //int i; |
| 1108 | float br; |
| 1109 | for(integercxx . . $ integer# k=0;k<vf->linkscxx . . $ OggVorbis_File#links.;k++) |
| 1110 | bits+=(vf->offsetscxx . . $ OggVorbis_File#offsets.[k+1]-vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[k])*8; |
| 1111 | /* This once read: return(rint(bits/ov_time_total(vf,-1))); |
| 1112 | * gcc 3.x on x86 miscompiled this at optimisation level 2 and above, |
| 1113 | * so this is slightly transformed to make it work. |
| 1114 | */ |
| 1115 | br = bits/ov_time_totalcxx . . $ ov_time_total(51460286bd79cdc2).(vf,-1); |
| 1116 | return(rintcxx . . $ rint(fbcf3211dfe1bfd1).(br)); |
| 1117 | }else{ |
| 1118 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 1119 | /* return the actual bitrate */ |
| 1120 | return(rintcxx . . $ rint(fee4f1d22bc8e617).((vf->offsetscxx . . $ OggVorbis_File#offsets.[i+1]-vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[i])*8/ov_time_totalcxx . . $ ov_time_total(51460286bd79cdc2).(vf,i))); |
| 1121 | }else{ |
| 1122 | /* return nominal if set */ |
| 1123 | if(vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_nominalcxx . . $ vorbis_info#bitrate_nominal.>0){ |
| 1124 | return vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_nominalcxx . . $ vorbis_info#bitrate_nominal.; |
| 1125 | }else{ |
| 1126 | if(vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_uppercxx . . $ vorbis_info#bitrate_upper.>0){ |
| 1127 | if(vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_lowercxx . . $ vorbis_info#bitrate_lower.>0){ |
| 1128 | 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; |
| 1129 | }else{ |
| 1130 | return vf->vicxx . . $ OggVorbis_File#vi.[i].bitrate_uppercxx . . $ vorbis_info#bitrate_upper.; |
| 1131 | } |
| 1132 | } |
| 1133 | return(OV_FALSEcxx . . $ `external/vorbis/vorbis_codec.h:216:9`!); |
| 1134 | } |
| 1135 | } |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | /* returns the actual bitrate since last call. returns -1 if no |
| 1140 | additional data to offer since last call (or at beginning of stream), |
| 1141 | EINVAL if stream is only partially open |
| 1142 | */ |
| 1143 | long ov_bitrate_instantcxx . . $ ov_bitrate_instant(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1144 | int link=(vf->seekablecxx . . $ OggVorbis_File#seekable.?vf->current_linkcxx . . $ OggVorbis_File#current_link.:0); |
| 1145 | long ret; |
| 1146 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1147 | if(vf->samptrackcxx . . $ OggVorbis_File#samptrack.==0)return(OV_FALSEcxx . . $ `external/vorbis/vorbis_codec.h:216:9`!); |
| 1148 | ret=vf->bittrackcxx . . $ OggVorbis_File#bittrack./vf->samptrackcxx . . $ OggVorbis_File#samptrack.*vf->vicxx . . $ OggVorbis_File#vi.[link].ratecxx . . $ vorbis_info#rate.+.5; |
| 1149 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0.f; |
| 1150 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0.f; |
| 1151 | return(ret); |
| 1152 | } |
| 1153 | |
| 1154 | /* Guess */ |
| 1155 | long ov_serialnumbercxx . . $ ov_serialnumber(848dcfd6565c9c04).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1156 | if(i>=vf->linkscxx . . $ OggVorbis_File#links.)return(ov_serialnumbercxx . . $ ov_serialnumber(848dcfd6565c9c04).(vf,vf->linkscxx . . $ OggVorbis_File#links.-1)); |
| 1157 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. && i>=0)return(ov_serialnumbercxx . . $ ov_serialnumber(848dcfd6565c9c04).(vf,-1)); |
| 1158 | if(i<0){ |
| 1159 | return(vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); |
| 1160 | }else{ |
| 1161 | return(vf->serialnoscxx . . $ OggVorbis_File#serialnos.[i]); |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1165 | /* returns: total raw (compressed) length of content if i==-1 |
| 1166 | raw (compressed) length of that logical bitstream for i==0 to n |
| 1167 | OV_EINVAL if the stream is not seekable (we can't know the length) |
| 1168 | or if stream is only partially open |
| 1169 | */ |
| 1170 | ogg_int64_tcxx . . $ ogg_int64_t# ov_raw_totalcxx . . $ ov_raw_total(848dcfd6565c9c04).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1171 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1172 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. || i>=vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1173 | if(i<0){ |
| 1174 | ogg_int64_tcxx . . $ ogg_int64_t# acc=0; |
| 1175 | //int i; |
| 1176 | for(integercxx . . $ integer# k=0;k<vf->linkscxx . . $ OggVorbis_File#links.;k++) |
| 1177 | acc+=ov_raw_totalcxx . . $ ov_raw_total(848dcfd6565c9c04).(vf,k); |
| 1178 | return(acc); |
| 1179 | }else{ |
| 1180 | return(vf->offsetscxx . . $ OggVorbis_File#offsets.[i+1]-vf->offsetscxx . . $ OggVorbis_File#offsets.[i]); |
| 1181 | } |
| 1182 | } |
| 1183 | |
| 1184 | /* returns: total PCM length (samples) of content if i==-1 PCM length |
| 1185 | (samples) of that logical bitstream for i==0 to n |
| 1186 | OV_EINVAL if the stream is not seekable (we can't know the |
| 1187 | length) or only partially open |
| 1188 | */ |
| 1189 | ogg_int64_tcxx . . $ ogg_int64_t# ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1190 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1191 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. || i>=vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1192 | if(i<0){ |
| 1193 | ogg_int64_tcxx . . $ ogg_int64_t# acc=0; |
| 1194 | //int i; |
| 1195 | for(integercxx . . $ integer# k=0;k<vf->linkscxx . . $ OggVorbis_File#links.;k++) |
| 1196 | acc+=ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,k); |
| 1197 | return(acc); |
| 1198 | }else{ |
| 1199 | return(vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1]); |
| 1200 | } |
| 1201 | } |
| 1202 | |
| 1203 | /* returns: total seconds of content if i==-1 |
| 1204 | seconds in that logical bitstream for i==0 to n |
| 1205 | OV_EINVAL if the stream is not seekable (we can't know the |
| 1206 | length) or only partially open |
| 1207 | */ |
| 1208 | double ov_time_totalcxx . . $ ov_time_total(51460286bd79cdc2).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int i){ |
| 1209 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1210 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable. || i>=vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1211 | if(i<0){ |
| 1212 | double acc=0; |
| 1213 | //int i; |
| 1214 | for(integercxx . . $ integer# k=0;k<vf->linkscxx . . $ OggVorbis_File#links.;k++) |
| 1215 | acc+=ov_time_totalcxx . . $ ov_time_total(51460286bd79cdc2).(vf,k); |
| 1216 | return(acc); |
| 1217 | }else{ |
| 1218 | return((double)(vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1])/vf->vicxx . . $ OggVorbis_File#vi.[i].ratecxx . . $ vorbis_info#rate.); |
| 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | /* seek to an offset relative to the *compressed* data. This also |
| 1223 | scans packets to update the PCM cursor. It will cross a logical |
| 1224 | bitstream boundary, but only if it can't get any packets out of the |
| 1225 | tail of the bitstream we seek to (so no surprises). |
| 1226 | |
| 1227 | returns zero on success, nonzero on failure */ |
| 1228 | |
| 1229 | int ov_raw_seekcxx . . $ ov_raw_seek(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# pos){ |
| 1230 | ogg_stream_statecxx . . $ ogg_stream_state# work_os; |
| 1231 | |
| 1232 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1233 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.) |
| 1234 | return(OV_ENOSEEKcxx . . $ `external/vorbis/vorbis_codec.h:230:9`!); /* don't dump machine if we can't seek */ |
| 1235 | |
| 1236 | if(pos<0 || pos>vf->endcxx . . $ OggVorbis_File#end.)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1237 | |
| 1238 | /* is the seek position outside our current link [if any]? */ |
| 1239 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 1240 | 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]) |
| 1241 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); /* clear out stream state */ |
| 1242 | } |
| 1243 | |
| 1244 | /* don't yet clear out decoding machine (if it's initialized), in |
| 1245 | the case we're in the same link. Restart the decode lapping, and |
| 1246 | let _fetch_and_process_packet deal with a potential bitstream |
| 1247 | boundary */ |
| 1248 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1249 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os., |
| 1250 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); /* must set serialno */ |
| 1251 | vorbis_synthesis_restartcxx . . $ vorbis_synthesis_restart(6cb399ae167b2de8).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 1252 | |
| 1253 | if(_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,pos)) { |
| 1254 | /* dump the machine so we're in a known state */ |
| 1255 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1256 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 1257 | return OV_EBADLINKcxx . . $ `external/vorbis/vorbis_codec.h:229:9`!; |
| 1258 | } |
| 1259 | |
| 1260 | /* we need to make sure the pcm_offset is set, but we don't want to |
| 1261 | advance the raw cursor past good packets just to get to the first |
| 1262 | with a granulepos. That's not equivalent behavior to beginning |
| 1263 | decoding as immediately after the seek position as possible. |
| 1264 | |
| 1265 | So, a hack. We use two stream states; a local scratch state and |
| 1266 | the shared vf->os stream state. We use the local state to |
| 1267 | scan, and the shared state as a buffer for later decode. |
| 1268 | |
| 1269 | Unfortuantely, on the last page we still advance to last packet |
| 1270 | because the granulepos on the last page is not necessarily on a |
| 1271 | packet boundary, and we need to make sure the granpos is |
| 1272 | correct. |
| 1273 | */ |
| 1274 | |
| 1275 | { |
| 1276 | ogg_pagecxx . . $ ogg_page# og; |
| 1277 | ogg_packetcxx . . $ ogg_packet# op; |
| 1278 | int lastblock=0; |
| 1279 | int accblock=0; |
| 1280 | int thisblock=0; |
| 1281 | int lastflag=0; |
| 1282 | int firstflag=0; |
| 1283 | ogg_int64_tcxx . . $ ogg_int64_t# pagepos=-1; |
| 1284 | |
| 1285 | ogg_stream_initcxx . . $ ogg_stream_init(99ed4282c68df03).(&work_os,vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); /* get the memory ready */ |
| 1286 | ogg_stream_resetcxx . . $ ogg_stream_reset(d9e3535bee9e7016).(&work_os); /* eliminate the spurious OV_HOLE |
| 1287 | return from not necessarily |
| 1288 | starting from the beginning */ |
| 1289 | |
| 1290 | while(1){ |
| 1291 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 1292 | /* snarf/scan a packet if we can */ |
| 1293 | int result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&work_os,&op); |
| 1294 | |
| 1295 | if(result>0){ |
| 1296 | |
| 1297 | if(vf->vicxx . . $ OggVorbis_File#vi.[vf->current_linkcxx . . $ OggVorbis_File#current_link.].codec_setupcxx . . $ vorbis_info#codec_setup.){ |
| 1298 | thisblock=vorbis_packet_blocksizecxx . . $ vorbis_packet_blocksize(5c730016bfddf4b1).(vf->vicxx . . $ OggVorbis_File#vi.+vf->current_linkcxx . . $ OggVorbis_File#current_link.,&op); |
| 1299 | if(thisblock<0){ |
| 1300 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,nullptr); |
| 1301 | thisblock=0; |
| 1302 | }else{ |
| 1303 | |
| 1304 | /* We can't get a guaranteed correct pcm position out of the |
| 1305 | last page in a stream because it might have a 'short' |
| 1306 | granpos, which can only be detected in the presence of a |
| 1307 | preceding page. However, if the last page is also the first |
| 1308 | page, the granpos rules of a first page take precedence. Not |
| 1309 | only that, but for first==last, the EOS page must be treated |
| 1310 | as if its a normal first page for the stream to open/play. */ |
| 1311 | if(lastflag && !firstflag) |
| 1312 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,nullptr); |
| 1313 | else |
| 1314 | if(lastblock)accblock+=(lastblock+thisblock)>>2; |
| 1315 | } |
| 1316 | |
| 1317 | if(op.granuleposcxx . . $ $anonymous_type_d401cdaf801be98c_4#granulepos.!=-1){ |
| 1318 | int i,link=vf->current_linkcxx . . $ OggVorbis_File#current_link.; |
| 1319 | ogg_int64_tcxx . . $ ogg_int64_t# granulepos=op.granuleposcxx . . $ $anonymous_type_d401cdaf801be98c_4#granulepos.-vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2]; |
| 1320 | if(granulepos<0)granulepos=0; |
| 1321 | |
| 1322 | for(i=0;i<link;i++) |
| 1323 | granulepos+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1]; |
| 1324 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=granulepos-accblock; |
| 1325 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.<0)vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=0; |
| 1326 | break; |
| 1327 | } |
| 1328 | lastblock=thisblock; |
| 1329 | continue; |
| 1330 | }else |
| 1331 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,nullptr); |
| 1332 | } |
| 1333 | } |
| 1334 | |
| 1335 | if(!lastblock){ |
| 1336 | pagepos=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1); |
| 1337 | if(pagepos<0){ |
| 1338 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,-1); |
| 1339 | break; |
| 1340 | } |
| 1341 | }else{ |
| 1342 | /* huh? Bogus stream with packets but no granulepos */ |
| 1343 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1344 | break; |
| 1345 | } |
| 1346 | |
| 1347 | /* has our decoding just traversed a bitstream boundary? */ |
| 1348 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 1349 | if(vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.!=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)){ |
| 1350 | |
| 1351 | /* two possibilities: |
| 1352 | 1) our decoding just traversed a bitstream boundary |
| 1353 | 2) another stream is multiplexed into this logical section? */ |
| 1354 | |
| 1355 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(&og)){ |
| 1356 | /* we traversed */ |
| 1357 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); /* clear out stream state */ |
| 1358 | ogg_stream_clearcxx . . $ ogg_stream_clear(d9e3535bee9e7016).(&work_os); |
| 1359 | } /* else, do nothing; next loop will scoop another page */ |
| 1360 | } |
| 1361 | } |
| 1362 | |
| 1363 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 1364 | int link; |
| 1365 | long serialno = ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 1366 | |
| 1367 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++) |
| 1368 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]==serialno)break; |
| 1369 | |
| 1370 | if(link==vf->linkscxx . . $ OggVorbis_File#links.) continue; /* not the desired Vorbis |
| 1371 | bitstream section; keep |
| 1372 | trying */ |
| 1373 | vf->current_linkcxx . . $ OggVorbis_File#current_link.=link; |
| 1374 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=serialno; |
| 1375 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,serialno); |
| 1376 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&work_os,serialno); |
| 1377 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!; |
| 1378 | firstflag=(pagepos<=vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[link]); |
| 1379 | } |
| 1380 | |
| 1381 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 1382 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&work_os,&og); |
| 1383 | lastflag=ogg_page_eoscxx . . $ ogg_page_eos(2b497e90a9d5eca2).(&og); |
| 1384 | |
| 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | ogg_stream_clearcxx . . $ ogg_stream_clear(d9e3535bee9e7016).(&work_os); |
| 1389 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0.f; |
| 1390 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0.f; |
| 1391 | return(0); |
| 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 . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1406 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.)return(OV_ENOSEEKcxx . . $ `external/vorbis/vorbis_codec.h:230:9`!); |
| 1407 | |
| 1408 | if(pos<0 || pos>total)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223: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 pos. If we're looking for a position on the |
| 1418 | first page, bisection will halt without finding our position as |
| 1419 | it's before the first explicit granulepos fencepost. That case is |
| 1420 | handled separately below. |
| 1421 | |
| 1422 | There is a danger here; missing pages or incorrect frame number |
| 1423 | information in the bitstream could make our task impossible. |
| 1424 | Account for that (it would be an error condition) */ |
| 1425 | |
| 1426 | /* new search algorithm originally by HB (Nicholas Vinen) */ |
| 1427 | |
| 1428 | { |
| 1429 | ogg_int64_tcxx . . $ ogg_int64_t# end=vf->offsetscxx . . $ OggVorbis_File#offsets.[link+1]; |
| 1430 | ogg_int64_tcxx . . $ ogg_int64_t# begin=vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[link]; |
| 1431 | ogg_int64_tcxx . . $ ogg_int64_t# begintime = vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2]; |
| 1432 | ogg_int64_tcxx . . $ ogg_int64_t# endtime = vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2+1]+begintime; |
| 1433 | ogg_int64_tcxx . . $ ogg_int64_t# target=pos-total+begintime; |
| 1434 | ogg_int64_tcxx . . $ ogg_int64_t# best=-1; |
| 1435 | int got_page=0; |
| 1436 | |
| 1437 | ogg_pagecxx . . $ ogg_page# og; |
| 1438 | |
| 1439 | /* if we have only one page, there will be no bisection. Grab the page here */ |
| 1440 | if(begin==end){ |
| 1441 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,begin); |
| 1442 | if(result) goto seek_error; |
| 1443 | |
| 1444 | result=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,1); |
| 1445 | if(result<0) goto seek_error; |
| 1446 | |
| 1447 | got_page=1; |
| 1448 | } |
| 1449 | |
| 1450 | /* bisection loop */ |
| 1451 | while(begin<end){ |
| 1452 | ogg_int64_tcxx . . $ ogg_int64_t# bisect; |
| 1453 | |
| 1454 | if(end-begin<CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!){ |
| 1455 | bisect=begin; |
| 1456 | }else{ |
| 1457 | /* take a (pretty decent) guess. */ |
| 1458 | bisect=begin + |
| 1459 | (ogg_int64_tcxx . . $ ogg_int64_t#)((double)(target-begintime)*(end-begin)/(endtime-begintime)) |
| 1460 | - CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!; |
| 1461 | if(bisect<begin+CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!) |
| 1462 | bisect=begin; |
| 1463 | } |
| 1464 | |
| 1465 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,bisect); |
| 1466 | if(result) goto seek_error; |
| 1467 | |
| 1468 | /* read loop within the bisection loop */ |
| 1469 | while(begin<end){ |
| 1470 | result=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,end-vf->offsetcxx . . $ OggVorbis_File#offset.); |
| 1471 | if(result==OV_EREADcxx . . $ `external/vorbis/vorbis_codec.h:220:9`!) goto seek_error; |
| 1472 | if(result<0){ |
| 1473 | /* there is no next page! */ |
| 1474 | if(bisect<=begin+1) |
| 1475 | /* No bisection left to perform. We've either found the |
| 1476 | best candidate already or failed. Exit loop. */ |
| 1477 | end=begin; |
| 1478 | else{ |
| 1479 | /* We tried to load a fraction of the last page; back up a |
| 1480 | bit and try to get the whole last page */ |
| 1481 | if(bisect==0) goto seek_error; |
| 1482 | bisect-=CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!; |
| 1483 | |
| 1484 | /* don't repeat/loop on a read we've already performed */ |
| 1485 | if(bisect<=begin)bisect=begin+1; |
| 1486 | |
| 1487 | /* seek and cntinue bisection */ |
| 1488 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,bisect); |
| 1489 | if(result) goto seek_error; |
| 1490 | } |
| 1491 | }else{ |
| 1492 | ogg_int64_tcxx . . $ ogg_int64_t# granulepos; |
| 1493 | got_page=1; |
| 1494 | |
| 1495 | /* got a page. analyze it */ |
| 1496 | /* only consider pages from primary vorbis stream */ |
| 1497 | if(ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)!=vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]) |
| 1498 | continue; |
| 1499 | |
| 1500 | /* only consider pages with the granulepos set */ |
| 1501 | granulepos=ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og); |
| 1502 | if(granulepos==-1)continue; |
| 1503 | |
| 1504 | if(granulepos<target){ |
| 1505 | /* this page is a successful candidate! Set state */ |
| 1506 | |
| 1507 | best=result; /* raw offset of packet with granulepos */ |
| 1508 | begin=vf->offsetcxx . . $ OggVorbis_File#offset.; /* raw offset of next page */ |
| 1509 | begintime=granulepos; |
| 1510 | |
| 1511 | /* if we're before our target but within a short distance, |
| 1512 | don't bisect; read forward */ |
| 1513 | if(target-begintime>44100)break; |
| 1514 | |
| 1515 | bisect=begin; /* *not* begin + 1 as above */ |
| 1516 | }else{ |
| 1517 | |
| 1518 | /* This is one of our pages, but the granpos is |
| 1519 | post-target; it is not a bisection return |
| 1520 | candidate. (The only way we'd use it is if it's the |
| 1521 | first page in the stream; we handle that case later |
| 1522 | outside the bisection) */ |
| 1523 | if(bisect<=begin+1){ |
| 1524 | /* No bisection left to perform. We've either found the |
| 1525 | best candidate already or failed. Exit loop. */ |
| 1526 | end=begin; |
| 1527 | }else{ |
| 1528 | if(end==vf->offsetcxx . . $ OggVorbis_File#offset.){ |
| 1529 | /* bisection read to the end; use the known page |
| 1530 | boundary (result) to update bisection, back up a |
| 1531 | little bit, and try again */ |
| 1532 | end=result; |
| 1533 | bisect-=CHUNKSIZEcxx . . $ `external/vorbis/vorbisfile.cpp:57:9`!; |
| 1534 | if(bisect<=begin)bisect=begin+1; |
| 1535 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,bisect); |
| 1536 | if(result) goto seek_error; |
| 1537 | }else{ |
| 1538 | /* Normal bisection */ |
| 1539 | end=bisect; |
| 1540 | endtime=granulepos; |
| 1541 | break; |
| 1542 | } |
| 1543 | } |
| 1544 | } |
| 1545 | } |
| 1546 | } |
| 1547 | } |
| 1548 | |
| 1549 | /* Out of bisection: did it 'fail?' */ |
| 1550 | if(best == -1){ |
| 1551 | |
| 1552 | /* Check the 'looking for data in first page' special case; |
| 1553 | bisection would 'fail' because our search target was before the |
| 1554 | first PCM granule position fencepost. */ |
| 1555 | |
| 1556 | if(got_page && |
| 1557 | begin == vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[link] && |
| 1558 | ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)==vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]){ |
| 1559 | |
| 1560 | /* Yes, this is the beginning-of-stream case. We already have |
| 1561 | our page, right at the beginning of PCM data. Set state |
| 1562 | and return. */ |
| 1563 | |
| 1564 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=total; |
| 1565 | |
| 1566 | if(link!=vf->current_linkcxx . . $ OggVorbis_File#current_link.){ |
| 1567 | /* Different link; dump entire decode machine */ |
| 1568 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 1569 | |
| 1570 | vf->current_linkcxx . . $ OggVorbis_File#current_link.=link; |
| 1571 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]; |
| 1572 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!; |
| 1573 | |
| 1574 | }else{ |
| 1575 | vorbis_synthesis_restartcxx . . $ vorbis_synthesis_restart(6cb399ae167b2de8).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 1576 | } |
| 1577 | |
| 1578 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); |
| 1579 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 1580 | |
| 1581 | }else |
| 1582 | goto seek_error; |
| 1583 | |
| 1584 | }else{ |
| 1585 | |
| 1586 | /* Bisection found our page. seek to it, update pcm offset. Easier case than |
| 1587 | raw_seek, don't keep packets preceding granulepos. */ |
| 1588 | |
| 1589 | //ogg_page og; |
| 1590 | ogg_packetcxx . . $ ogg_packet# op; |
| 1591 | |
| 1592 | /* seek */ |
| 1593 | result=_seek_helpercxx . . $ _seek_helper(2602c1e715810f3a).(vf,best); |
| 1594 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1595 | if(result) goto seek_error; |
| 1596 | result=_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1); |
| 1597 | if(result<0) goto seek_error; |
| 1598 | |
| 1599 | if(link!=vf->current_linkcxx . . $ OggVorbis_File#current_link.){ |
| 1600 | /* Different link; dump entire decode machine */ |
| 1601 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 1602 | |
| 1603 | vf->current_linkcxx . . $ OggVorbis_File#current_link.=link; |
| 1604 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]; |
| 1605 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!; |
| 1606 | |
| 1607 | }else{ |
| 1608 | vorbis_synthesis_restartcxx . . $ vorbis_synthesis_restart(6cb399ae167b2de8).(&vf->vdcxx . . $ OggVorbis_File#vd.); |
| 1609 | } |
| 1610 | |
| 1611 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.); |
| 1612 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 1613 | |
| 1614 | /* pull out all but last packet; the one with granulepos */ |
| 1615 | while(1){ |
| 1616 | result=ogg_stream_packetpeekcxx . . $ ogg_stream_packetpeek(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op); |
| 1617 | if(result==0){ |
| 1618 | /* No packet returned; we exited the bisection with 'best' |
| 1619 | pointing to a page with a granule position, so the packet |
| 1620 | finishing this page ('best') originated on a preceding |
| 1621 | page. Keep fetching previous pages until we get one with |
| 1622 | a granulepos or without the 'continued' flag set. Then |
| 1623 | just use raw_seek for simplicity. */ |
| 1624 | /* Do not rewind past the beginning of link data; if we do, |
| 1625 | it's either a bug or a broken stream */ |
| 1626 | result=best; |
| 1627 | while(result>vf->dataoffsetscxx . . $ OggVorbis_File#dataoffsets.[link]){ |
| 1628 | result=_get_prev_pagecxx . . $ _get_prev_page(1a1b99d6be8dbf6f).(vf,result,&og); |
| 1629 | if(result<0) goto seek_error; |
| 1630 | if(ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og)==vf->current_serialnocxx . . $ OggVorbis_File#current_serialno. && |
| 1631 | (ogg_page_granuleposcxx . . $ ogg_page_granulepos(13b0e8880c30fe07).(&og)>-1 || |
| 1632 | !ogg_page_continuedcxx . . $ ogg_page_continued(2b497e90a9d5eca2).(&og))){ |
| 1633 | return ov_raw_seekcxx . . $ ov_raw_seek(2602c1e715810f3a).(vf,result); |
| 1634 | } |
| 1635 | } |
| 1636 | } |
| 1637 | if(result<0){ |
| 1638 | result = OV_EBADPACKETcxx . . $ `external/vorbis/vorbis_codec.h:228:9`!; |
| 1639 | goto seek_error; |
| 1640 | } |
| 1641 | if(op.granuleposcxx . . $ $anonymous_type_d401cdaf801be98c_4#granulepos.!=-1){ |
| 1642 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=op.granuleposcxx . . $ $anonymous_type_d401cdaf801be98c_4#granulepos.-vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[vf->current_linkcxx . . $ OggVorbis_File#current_link.*2]; |
| 1643 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.<0)vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=0; |
| 1644 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=total; |
| 1645 | break; |
| 1646 | }else |
| 1647 | result=ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,nullptr); |
| 1648 | } |
| 1649 | } |
| 1650 | } |
| 1651 | |
| 1652 | /* verify result */ |
| 1653 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.>pos || pos>ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,-1)){ |
| 1654 | result=OV_EFAULTcxx . . $ `external/vorbis/vorbis_codec.h:221:9`!; |
| 1655 | goto seek_error; |
| 1656 | } |
| 1657 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0.f; |
| 1658 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0.f; |
| 1659 | return(0); |
| 1660 | |
| 1661 | seek_error: |
| 1662 | /* dump machine so we're in a known state */ |
| 1663 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=-1; |
| 1664 | _decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 1665 | return (int)result; |
| 1666 | } |
| 1667 | |
| 1668 | /* seek to a sample offset relative to the decompressed pcm stream |
| 1669 | returns zero on success, nonzero on failure */ |
| 1670 | |
| 1671 | int ov_pcm_seekcxx . . $ ov_pcm_seek(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# pos){ |
| 1672 | int thisblock,lastblock=0; |
| 1673 | int ret=ov_pcm_seek_pagecxx . . $ ov_pcm_seek_page(2602c1e715810f3a).(vf,pos); |
| 1674 | if(ret<0)return(ret); |
| 1675 | if((ret=_make_decode_readycxx . . $ _make_decode_ready(231cee6479b09f2b).(vf)))return ret; |
| 1676 | |
| 1677 | /* discard leading packets we don't need for the lapping of the |
| 1678 | position we want; don't decode them */ |
| 1679 | |
| 1680 | while(1){ |
| 1681 | ogg_packetcxx . . $ ogg_packet# op; |
| 1682 | ogg_pagecxx . . $ ogg_page# og; |
| 1683 | |
| 1684 | /*int*/ ret=ogg_stream_packetpeekcxx . . $ ogg_stream_packetpeek(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,&op); |
| 1685 | if(ret>0){ |
| 1686 | thisblock=vorbis_packet_blocksizecxx . . $ vorbis_packet_blocksize(5c730016bfddf4b1).(vf->vicxx . . $ OggVorbis_File#vi.+vf->current_linkcxx . . $ OggVorbis_File#current_link.,&op); |
| 1687 | if(thisblock<0){ |
| 1688 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,nullptr); |
| 1689 | continue; /* non audio packet */ |
| 1690 | } |
| 1691 | if(lastblock)vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=(lastblock+thisblock)>>2; |
| 1692 | |
| 1693 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+((thisblock+ |
| 1694 | vorbis_info_blocksizecxx . . $ vorbis_info_blocksize(567c21d5828d03ac).(vf->vicxx . . $ OggVorbis_File#vi.,1))>>2)>=pos)break; |
| 1695 | |
| 1696 | /* remove the packet from packet queue and track its granulepos */ |
| 1697 | ogg_stream_packetoutcxx . . $ ogg_stream_packetout(fd2c2a9865ca08d).(&vf->oscxx . . $ OggVorbis_File#os.,nullptr); |
| 1698 | vorbis_synthesis_trackonlycxx . . $ vorbis_synthesis_trackonly(e9de88148c52a299).(&vf->vbcxx . . $ OggVorbis_File#vb.,&op); /* set up a vb with |
| 1699 | only tracking, no |
| 1700 | pcm_decode */ |
| 1701 | vorbis_synthesis_blockincxx . . $ vorbis_synthesis_blockin(c8f1c0cf9c31dd14).(&vf->vdcxx . . $ OggVorbis_File#vd.,&vf->vbcxx . . $ OggVorbis_File#vb.); |
| 1702 | |
| 1703 | /* end of logical stream case is hard, especially with exact |
| 1704 | length positioning. */ |
| 1705 | |
| 1706 | if(op.granuleposcxx . . $ $anonymous_type_d401cdaf801be98c_4#granulepos.>-1){ |
| 1707 | int i; |
| 1708 | /* always believe the stream markers */ |
| 1709 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=op.granuleposcxx . . $ $anonymous_type_d401cdaf801be98c_4#granulepos.-vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[vf->current_linkcxx . . $ OggVorbis_File#current_link.*2]; |
| 1710 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.<0)vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=0; |
| 1711 | for(i=0;i<vf->current_linkcxx . . $ OggVorbis_File#current_link.;i++) |
| 1712 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[i*2+1]; |
| 1713 | } |
| 1714 | |
| 1715 | lastblock=thisblock; |
| 1716 | |
| 1717 | }else{ |
| 1718 | if(ret<0 && ret!=OV_HOLEcxx . . $ `external/vorbis/vorbis_codec.h:218:9`!)break; |
| 1719 | |
| 1720 | /* suck in a new page */ |
| 1721 | if(_get_next_pagecxx . . $ _get_next_page(91cc24e39e54ae37).(vf,&og,-1)<0)break; |
| 1722 | if(ogg_page_boscxx . . $ ogg_page_bos(2b497e90a9d5eca2).(&og))_decode_clearcxx . . $ _decode_clear(7b5d65f541043e97).(vf); |
| 1723 | |
| 1724 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!){ |
| 1725 | long serialno=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 1726 | int link; |
| 1727 | |
| 1728 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++) |
| 1729 | if(vf->serialnoscxx . . $ OggVorbis_File#serialnos.[link]==serialno)break; |
| 1730 | if(link==vf->linkscxx . . $ OggVorbis_File#links.) continue; |
| 1731 | vf->current_linkcxx . . $ OggVorbis_File#current_link.=link; |
| 1732 | |
| 1733 | vf->ready_statecxx . . $ OggVorbis_File#ready_state.=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!; |
| 1734 | vf->current_serialnocxx . . $ OggVorbis_File#current_serialno.=ogg_page_serialnocxx . . $ ogg_page_serialno(2b497e90a9d5eca2).(&og); |
| 1735 | ogg_stream_reset_serialnocxx . . $ ogg_stream_reset_serialno(99ed4282c68df03).(&vf->oscxx . . $ OggVorbis_File#os.,serialno); |
| 1736 | ret=_make_decode_readycxx . . $ _make_decode_ready(231cee6479b09f2b).(vf); |
| 1737 | if(ret)return ret; |
| 1738 | lastblock=0; |
| 1739 | } |
| 1740 | |
| 1741 | ogg_stream_pageincxx . . $ ogg_stream_pagein(47b5742f7c1fe496).(&vf->oscxx . . $ OggVorbis_File#os.,&og); |
| 1742 | } |
| 1743 | } |
| 1744 | |
| 1745 | vf->bittrackcxx . . $ OggVorbis_File#bittrack.=0.f; |
| 1746 | vf->samptrackcxx . . $ OggVorbis_File#samptrack.=0.f; |
| 1747 | /* discard samples until we reach the desired position. Crossing a |
| 1748 | logical bitstream boundary with abandon is OK. */ |
| 1749 | { |
| 1750 | /* note that halfrate could be set differently in each link, but |
| 1751 | vorbisfile encoforces all links are set or unset */ |
| 1752 | int hs=vorbis_synthesis_halfrate_pcxx . . $ vorbis_synthesis_halfrate_p(8afef93073a461ef).(vf->vicxx . . $ OggVorbis_File#vi.); |
| 1753 | while(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.<((pos>>hs)<<hs)){ |
| 1754 | ogg_int64_tcxx . . $ ogg_int64_t# target=(pos-vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.)>>hs; |
| 1755 | long samples=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(fd400e10b261aeec).(&vf->vdcxx . . $ OggVorbis_File#vd.,nullptr); |
| 1756 | |
| 1757 | if(samples>target)samples=target; |
| 1758 | vorbis_synthesis_readcxx . . $ vorbis_synthesis_read(462060a1f4fafeae).(&vf->vdcxx . . $ OggVorbis_File#vd.,samples); |
| 1759 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=samples<<hs; |
| 1760 | |
| 1761 | if(samples<target) |
| 1762 | if(_fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(vf,nullptr,1,1)<=0) |
| 1763 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.=ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,-1); /* eof */ |
| 1764 | } |
| 1765 | } |
| 1766 | return 0; |
| 1767 | } |
| 1768 | |
| 1769 | /* seek to a playback time relative to the decompressed pcm stream |
| 1770 | returns zero on success, nonzero on failure */ |
| 1771 | int ov_time_seekcxx . . $ ov_time_seek(503e2689db2d7b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,double seconds){ |
| 1772 | /* translate time to PCM position and call ov_pcm_seek */ |
| 1773 | |
| 1774 | int link=-1; |
| 1775 | ogg_int64_tcxx . . $ ogg_int64_t# pcm_total=0; |
| 1776 | double time_total=0.; |
| 1777 | |
| 1778 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1779 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.)return(OV_ENOSEEKcxx . . $ `external/vorbis/vorbis_codec.h:230:9`!); |
| 1780 | if(seconds<0)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1781 | |
| 1782 | /* which bitstream section does this time offset occur in? */ |
| 1783 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++){ |
| 1784 | double addsec = ov_time_totalcxx . . $ ov_time_total(51460286bd79cdc2).(vf,link); |
| 1785 | if(seconds<time_total+addsec)break; |
| 1786 | time_total+=addsec; |
| 1787 | pcm_total+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2+1]; |
| 1788 | } |
| 1789 | |
| 1790 | if(link==vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1791 | |
| 1792 | /* enough information to convert time offset to pcm offset */ |
| 1793 | { |
| 1794 | ogg_int64_tcxx . . $ ogg_int64_t# target=pcm_total+(seconds-time_total)*vf->vicxx . . $ OggVorbis_File#vi.[link].ratecxx . . $ vorbis_info#rate.; |
| 1795 | return(ov_pcm_seekcxx . . $ ov_pcm_seek(2602c1e715810f3a).(vf,target)); |
| 1796 | } |
| 1797 | } |
| 1798 | |
| 1799 | /* page-granularity version of ov_time_seek |
| 1800 | returns zero on success, nonzero on failure */ |
| 1801 | int ov_time_seek_pagecxx . . $ ov_time_seek_page(503e2689db2d7b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,double seconds){ |
| 1802 | /* translate time to PCM position and call ov_pcm_seek */ |
| 1803 | |
| 1804 | int link=-1; |
| 1805 | ogg_int64_tcxx . . $ ogg_int64_t# pcm_total=0; |
| 1806 | double time_total=0.; |
| 1807 | |
| 1808 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1809 | if(!vf->seekablecxx . . $ OggVorbis_File#seekable.)return(OV_ENOSEEKcxx . . $ `external/vorbis/vorbis_codec.h:230:9`!); |
| 1810 | if(seconds<0)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1811 | |
| 1812 | /* which bitstream section does this time offset occur in? */ |
| 1813 | for(link=0;link<vf->linkscxx . . $ OggVorbis_File#links.;link++){ |
| 1814 | double addsec = ov_time_totalcxx . . $ ov_time_total(51460286bd79cdc2).(vf,link); |
| 1815 | if(seconds<time_total+addsec)break; |
| 1816 | time_total+=addsec; |
| 1817 | pcm_total+=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2+1]; |
| 1818 | } |
| 1819 | |
| 1820 | if(link==vf->linkscxx . . $ OggVorbis_File#links.)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1821 | |
| 1822 | /* enough information to convert time offset to pcm offset */ |
| 1823 | { |
| 1824 | ogg_int64_tcxx . . $ ogg_int64_t# target=pcm_total+(seconds-time_total)*vf->vicxx . . $ OggVorbis_File#vi.[link].ratecxx . . $ vorbis_info#rate.; |
| 1825 | return(ov_pcm_seek_pagecxx . . $ ov_pcm_seek_page(2602c1e715810f3a).(vf,target)); |
| 1826 | } |
| 1827 | } |
| 1828 | |
| 1829 | /* tell the current stream offset cursor. Note that seek followed by |
| 1830 | tell will likely not give the set offset due to caching */ |
| 1831 | ogg_int64_tcxx . . $ ogg_int64_t# ov_raw_tellcxx . . $ ov_raw_tell(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1832 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1833 | return(vf->offsetcxx . . $ OggVorbis_File#offset.); |
| 1834 | } |
| 1835 | |
| 1836 | /* return PCM offset (sample) of next PCM sample to be read */ |
| 1837 | ogg_int64_tcxx . . $ ogg_int64_t# ov_pcm_tellcxx . . $ ov_pcm_tell(cc66401103655b07).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1838 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1839 | return(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.); |
| 1840 | } |
| 1841 | |
| 1842 | /* return time offset (seconds) of next PCM sample to be read */ |
| 1843 | double ov_time_tellcxx . . $ ov_time_tell(48eb548637fa8094).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 1844 | int link=0; |
| 1845 | ogg_int64_tcxx . . $ ogg_int64_t# pcm_total=0; |
| 1846 | double time_total=0.f; |
| 1847 | |
| 1848 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1849 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 1850 | pcm_total=ov_pcm_totalcxx . . $ ov_pcm_total(848dcfd6565c9c04).(vf,-1); |
| 1851 | time_total=ov_time_totalcxx . . $ ov_time_total(51460286bd79cdc2).(vf,-1); |
| 1852 | |
| 1853 | /* which bitstream section does this time offset occur in? */ |
| 1854 | for(link=vf->linkscxx . . $ OggVorbis_File#links.-1;link>=0;link--){ |
| 1855 | pcm_total-=vf->pcmlengthscxx . . $ OggVorbis_File#pcmlengths.[link*2+1]; |
| 1856 | time_total-=ov_time_totalcxx . . $ ov_time_total(51460286bd79cdc2).(vf,link); |
| 1857 | if(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.>=pcm_total)break; |
| 1858 | } |
| 1859 | } |
| 1860 | |
| 1861 | return((double)time_total+(double)(vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.-pcm_total)/vf->vicxx . . $ OggVorbis_File#vi.[link].ratecxx . . $ vorbis_info#rate.); |
| 1862 | } |
| 1863 | |
| 1864 | /* link: -1) return the vorbis_info struct for the bitstream section |
| 1865 | currently being decoded |
| 1866 | 0-n) to request information for a specific bitstream section |
| 1867 | |
| 1868 | In the case of a non-seekable bitstream, any call returns the |
| 1869 | current bitstream. nullptr in the case that the machine is not |
| 1870 | initialized */ |
| 1871 | |
| 1872 | vorbis_infocxx . . $ vorbis_info# *ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int link){ |
| 1873 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 1874 | if(link<0) |
| 1875 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!) |
| 1876 | return vf->vicxx . . $ OggVorbis_File#vi.+vf->current_linkcxx . . $ OggVorbis_File#current_link.; |
| 1877 | else |
| 1878 | return vf->vicxx . . $ OggVorbis_File#vi.; |
| 1879 | else |
| 1880 | if(link>=vf->linkscxx . . $ OggVorbis_File#links.) |
| 1881 | return nullptr; |
| 1882 | else |
| 1883 | return vf->vicxx . . $ OggVorbis_File#vi.+link; |
| 1884 | }else{ |
| 1885 | return vf->vicxx . . $ OggVorbis_File#vi.; |
| 1886 | } |
| 1887 | } |
| 1888 | |
| 1889 | /* grr, strong typing, grr, no templates/inheritence, grr */ |
| 1890 | vorbis_commentcxx . . $ vorbis_comment# *ov_commentcxx . . $ ov_comment(5c593f69dba24d40).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,int link){ |
| 1891 | if(vf->seekablecxx . . $ OggVorbis_File#seekable.){ |
| 1892 | if(link<0) |
| 1893 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.>=STREAMSETcxx . . $ `external/vorbis/vorbisfile.h:68:10`!) |
| 1894 | return vf->vccxx . . $ OggVorbis_File#vc.+vf->current_linkcxx . . $ OggVorbis_File#current_link.; |
| 1895 | else |
| 1896 | return vf->vccxx . . $ OggVorbis_File#vc.; |
| 1897 | else |
| 1898 | if(link>=vf->linkscxx . . $ OggVorbis_File#links.) |
| 1899 | return nullptr; |
| 1900 | else |
| 1901 | return vf->vccxx . . $ OggVorbis_File#vc.+link; |
| 1902 | }else{ |
| 1903 | return vf->vccxx . . $ OggVorbis_File#vc.; |
| 1904 | } |
| 1905 | } |
| 1906 | |
| 1907 | static int host_is_big_endiancxx . . $ host_is_big_endian(b126dc7c1de90089).() { |
| 1908 | ogg_int32_tcxx . . $ ogg_int32_t# pattern = 0xfeedface; /* deadbeef */ |
| 1909 | unsigned char *bytewise = (unsigned char *)&pattern; |
| 1910 | if (bytewise[0] == 0xfe) return 1; |
| 1911 | return 0; |
| 1912 | } |
| 1913 | |
| 1914 | /* up to this point, everything could more or less hide the multiple |
| 1915 | logical bitstream nature of chaining from the toplevel application |
| 1916 | if the toplevel application didn't particularly care. However, at |
| 1917 | the point that we actually read audio back, the multiple-section |
| 1918 | nature must surface: Multiple bitstream sections do not necessarily |
| 1919 | have to have the same number of channels or sampling rate. |
| 1920 | |
| 1921 | ov_read returns the sequential logical bitstream number currently |
| 1922 | being decoded along with the PCM data in order that the toplevel |
| 1923 | application can take action on channel/sample rate changes. This |
| 1924 | number will be incremented even for streamed (non-seekable) streams |
| 1925 | (for seekable streams, it represents the actual logical bitstream |
| 1926 | index within the physical bitstream. Note that the accessor |
| 1927 | functions above are aware of this dichotomy). |
| 1928 | |
| 1929 | ov_read_filter is exactly the same as ov_read except that it processes |
| 1930 | the decoded audio data through a filter before packing it into the |
| 1931 | requested format. This gives greater accuracy than applying a filter |
| 1932 | after the audio has been converted into integral PCM. |
| 1933 | |
| 1934 | input values: buffer) a buffer to hold packed PCM data for return |
| 1935 | length) the byte length requested to be placed into buffer |
| 1936 | bigendianp) should the data be packed LSB first (0) or |
| 1937 | MSB first (1) |
| 1938 | word) word size for output. currently 1 (byte) or |
| 1939 | 2 (16 bit short) |
| 1940 | |
| 1941 | return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL) |
| 1942 | 0) EOF |
| 1943 | n) number of bytes of PCM actually returned. The |
| 1944 | below works on a packet-by-packet basis, so the |
| 1945 | return length is not related to the 'length' passed |
| 1946 | in, just guaranteed to fit. |
| 1947 | |
| 1948 | *section) set to the logical bitstream number */ |
| 1949 | |
| 1950 | long ov_read_filtercxx . . $ ov_read_filter(bc246da8bc138f62).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,char *buffer,int length, |
| 1951 | int bigendianp,int word,int sgned,int *bitstream, |
| 1952 | void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param){ |
| 1953 | int i,j; |
| 1954 | int host_endian = host_is_big_endiancxx . . $ host_is_big_endian(b126dc7c1de90089).(); |
| 1955 | int hs; |
| 1956 | |
| 1957 | float **pcm; |
| 1958 | long samples; |
| 1959 | |
| 1960 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1961 | if(word<=0)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1962 | |
| 1963 | while(1){ |
| 1964 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==INITSETcxx . . $ `external/vorbis/vorbisfile.h:69:10`!){ |
| 1965 | samples=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(fd400e10b261aeec).(&vf->vdcxx . . $ OggVorbis_File#vd.,&pcm); |
| 1966 | if(samples)break; |
| 1967 | } |
| 1968 | |
| 1969 | /* suck in another packet */ |
| 1970 | { |
| 1971 | int ret=_fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(vf,nullptr,1,1); |
| 1972 | if(ret==OV_EOFcxx . . $ `external/vorbis/vorbis_codec.h:217:9`!) |
| 1973 | return(0); |
| 1974 | if(ret<=0) |
| 1975 | return(ret); |
| 1976 | } |
| 1977 | |
| 1978 | } |
| 1979 | |
| 1980 | if(samples>0){ |
| 1981 | |
| 1982 | /* yay! proceed to pack data into the byte buffer */ |
| 1983 | |
| 1984 | long channels=ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(vf,-1)->channelscxx . . $ vorbis_info#channels.; |
| 1985 | long bytespersample=word * channels; |
| 1986 | // vorbis_fpu_control fpu; |
| 1987 | |
| 1988 | if(channels<1||channels>255)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 1989 | if(samples>length/bytespersample)samples=length/bytespersample; |
| 1990 | |
| 1991 | if(samples <= 0) |
| 1992 | return OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!; |
| 1993 | |
| 1994 | /* Here. */ |
| 1995 | if(filter) |
| 1996 | filter(pcm,channels,samples,filter_param); |
| 1997 | |
| 1998 | /* a tight loop to pack each size */ |
| 1999 | { |
| 2000 | int val; |
| 2001 | if(word==1){ |
| 2002 | int off=(sgned?0:128); |
| 2003 | vorbis_fpu_setroundcxx . . $ `external/vorbis/vorbis_os.h:60:11`!(&fpu); |
| 2004 | for(j=0;j<samples;j++) |
| 2005 | for(i=0;i<channels;i++){ |
| 2006 | val=vorbis_ftoicxx . . $ vorbis_ftoi(620b9ac44d2573a6).(pcm[i][j]*128.f); |
| 2007 | if(val>127)val=127; |
| 2008 | else if(val<-128)val=-128; |
| 2009 | *buffer++=val+off; |
| 2010 | } |
| 2011 | vorbis_fpu_restorecxx . . $ `external/vorbis/vorbis_os.h:61:11`!(fpu); |
| 2012 | }else{ |
| 2013 | int off=(sgned?0:32768); |
| 2014 | |
| 2015 | if(host_endian==bigendianp){ |
| 2016 | if(sgned){ |
| 2017 | |
| 2018 | vorbis_fpu_setroundcxx . . $ `external/vorbis/vorbis_os.h:60:11`!(&fpu); |
| 2019 | for(i=0;i<channels;i++) { /* It's faster in this order */ |
| 2020 | float *src=pcm[i]; |
| 2021 | short *dest=((short *)buffer)+i; |
| 2022 | for(j=0;j<samples;j++) { |
| 2023 | val=vorbis_ftoicxx . . $ vorbis_ftoi(620b9ac44d2573a6).(src[j]*32768.f); |
| 2024 | if(val>32767)val=32767; |
| 2025 | else if(val<-32768)val=-32768; |
| 2026 | *dest=val; |
| 2027 | dest+=channels; |
| 2028 | } |
| 2029 | } |
| 2030 | vorbis_fpu_restorecxx . . $ `external/vorbis/vorbis_os.h:61:11`!(fpu); |
| 2031 | |
| 2032 | }else{ |
| 2033 | |
| 2034 | vorbis_fpu_setroundcxx . . $ `external/vorbis/vorbis_os.h:60:11`!(&fpu); |
| 2035 | for(i=0;i<channels;i++) { |
| 2036 | float *src=pcm[i]; |
| 2037 | short *dest=((short *)buffer)+i; |
| 2038 | for(j=0;j<samples;j++) { |
| 2039 | val=vorbis_ftoicxx . . $ vorbis_ftoi(620b9ac44d2573a6).(src[j]*32768.f); |
| 2040 | if(val>32767)val=32767; |
| 2041 | else if(val<-32768)val=-32768; |
| 2042 | *dest=val+off; |
| 2043 | dest+=channels; |
| 2044 | } |
| 2045 | } |
| 2046 | vorbis_fpu_restorecxx . . $ `external/vorbis/vorbis_os.h:61:11`!(fpu); |
| 2047 | |
| 2048 | } |
| 2049 | }else if(bigendianp){ |
| 2050 | |
| 2051 | vorbis_fpu_setroundcxx . . $ `external/vorbis/vorbis_os.h:60:11`!(&fpu); |
| 2052 | for(j=0;j<samples;j++) |
| 2053 | for(i=0;i<channels;i++){ |
| 2054 | val=vorbis_ftoicxx . . $ vorbis_ftoi(620b9ac44d2573a6).(pcm[i][j]*32768.f); |
| 2055 | if(val>32767)val=32767; |
| 2056 | else if(val<-32768)val=-32768; |
| 2057 | val+=off; |
| 2058 | *buffer++=(val>>8); |
| 2059 | *buffer++=(val&0xff); |
| 2060 | } |
| 2061 | vorbis_fpu_restorecxx . . $ `external/vorbis/vorbis_os.h:61:11`!(fpu); |
| 2062 | |
| 2063 | }else{ |
| 2064 | //int val; |
| 2065 | vorbis_fpu_setroundcxx . . $ `external/vorbis/vorbis_os.h:60:11`!(&fpu); |
| 2066 | for(j=0;j<samples;j++) |
| 2067 | for(i=0;i<channels;i++){ |
| 2068 | val=vorbis_ftoicxx . . $ vorbis_ftoi(620b9ac44d2573a6).(pcm[i][j]*32768.f); |
| 2069 | if(val>32767)val=32767; |
| 2070 | else if(val<-32768)val=-32768; |
| 2071 | val+=off; |
| 2072 | *buffer++=(val&0xff); |
| 2073 | *buffer++=(val>>8); |
| 2074 | } |
| 2075 | vorbis_fpu_restorecxx . . $ `external/vorbis/vorbis_os.h:61:11`!(fpu); |
| 2076 | |
| 2077 | } |
| 2078 | } |
| 2079 | } |
| 2080 | |
| 2081 | vorbis_synthesis_readcxx . . $ vorbis_synthesis_read(462060a1f4fafeae).(&vf->vdcxx . . $ OggVorbis_File#vd.,samples); |
| 2082 | hs=vorbis_synthesis_halfrate_pcxx . . $ vorbis_synthesis_halfrate_p(8afef93073a461ef).(vf->vicxx . . $ OggVorbis_File#vi.); |
| 2083 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=(samples<<hs); |
| 2084 | if(bitstream)*bitstream=vf->current_linkcxx . . $ OggVorbis_File#current_link.; |
| 2085 | return(samples*bytespersample); |
| 2086 | }else{ |
| 2087 | return(samples); |
| 2088 | } |
| 2089 | } |
| 2090 | |
| 2091 | long ov_readcxx . . $ ov_read(4c1eed8e155d8bc6).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,char *buffer,int length, |
| 2092 | int bigendianp,int word,int sgned,int *bitstream){ |
| 2093 | return ov_read_filtercxx . . $ ov_read_filter(bc246da8bc138f62).(vf, buffer, length, bigendianp, word, sgned, bitstream, nullptr, nullptr); |
| 2094 | } |
| 2095 | |
| 2096 | /* input values: pcm_channels) a float vector per channel of output |
| 2097 | length) the sample length being read by the app |
| 2098 | |
| 2099 | return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL) |
| 2100 | 0) EOF |
| 2101 | n) number of samples of PCM actually returned. The |
| 2102 | below works on a packet-by-packet basis, so the |
| 2103 | return length is not related to the 'length' passed |
| 2104 | in, just guaranteed to fit. |
| 2105 | |
| 2106 | *section) set to the logical bitstream number */ |
| 2107 | |
| 2108 | |
| 2109 | |
| 2110 | long ov_read_floatcxx . . $ ov_read_float(8d354fe94c5278c9).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,float ***pcm_channels,int length, |
| 2111 | int *bitstream){ |
| 2112 | |
| 2113 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 2114 | |
| 2115 | while(1){ |
| 2116 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==INITSETcxx . . $ `external/vorbis/vorbisfile.h:69:10`!){ |
| 2117 | float **pcm; |
| 2118 | long samples=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(fd400e10b261aeec).(&vf->vdcxx . . $ OggVorbis_File#vd.,&pcm); |
| 2119 | if(samples){ |
| 2120 | int hs=vorbis_synthesis_halfrate_pcxx . . $ vorbis_synthesis_halfrate_p(8afef93073a461ef).(vf->vicxx . . $ OggVorbis_File#vi.); |
| 2121 | if(pcm_channels)*pcm_channels=pcm; |
| 2122 | if(samples>length)samples=length; |
| 2123 | vorbis_synthesis_readcxx . . $ vorbis_synthesis_read(462060a1f4fafeae).(&vf->vdcxx . . $ OggVorbis_File#vd.,samples); |
| 2124 | vf->pcm_offsetcxx . . $ OggVorbis_File#pcm_offset.+=samples<<hs; |
| 2125 | if(bitstream)*bitstream=vf->current_linkcxx . . $ OggVorbis_File#current_link.; |
| 2126 | return samples; |
| 2127 | |
| 2128 | } |
| 2129 | } |
| 2130 | |
| 2131 | /* suck in another packet */ |
| 2132 | { |
| 2133 | int ret=_fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(vf,nullptr,1,1); |
| 2134 | if(ret==OV_EOFcxx . . $ `external/vorbis/vorbis_codec.h:217:9`!)return(0); |
| 2135 | if(ret<=0)return(ret); |
| 2136 | } |
| 2137 | |
| 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | extern const float *vorbis_windowcxx . . $ vorbis_window(817ae43db252f106).(vorbis_dsp_statecxx . . $ vorbis_dsp_state# *v,int W); |
| 2142 | |
| 2143 | static void _ov_splicecxx . . $ _ov_splice(20d39c5a5bddc345).(float **pcm,float **lappcm, |
| 2144 | int n1, int n2, |
| 2145 | int ch1, int ch2, |
| 2146 | const float *w1, const float *w2){ |
| 2147 | int i,j; |
| 2148 | const float *w=w1; |
| 2149 | int n=n1; |
| 2150 | |
| 2151 | if(n1>n2){ |
| 2152 | n=n2; |
| 2153 | w=w2; |
| 2154 | } |
| 2155 | |
| 2156 | /* splice */ |
| 2157 | for(j=0;j<ch1 && j<ch2;j++){ |
| 2158 | float *s=lappcm[j]; |
| 2159 | float *d=pcm[j]; |
| 2160 | |
| 2161 | for(i=0;i<n;i++){ |
| 2162 | float wd=w[i]*w[i]; |
| 2163 | float ws=1.-wd; |
| 2164 | d[i]=d[i]*wd + s[i]*ws; |
| 2165 | } |
| 2166 | } |
| 2167 | /* window from zero */ |
| 2168 | for(;j<ch2;j++){ |
| 2169 | float *d=pcm[j]; |
| 2170 | for(i=0;i<n;i++){ |
| 2171 | float wd=w[i]*w[i]; |
| 2172 | d[i]=d[i]*wd; |
| 2173 | } |
| 2174 | } |
| 2175 | |
| 2176 | } |
| 2177 | |
| 2178 | /* make sure vf is INITSET */ |
| 2179 | static int _ov_initsetcxx . . $ _ov_initset(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 2180 | while(1){ |
| 2181 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==INITSETcxx . . $ `external/vorbis/vorbisfile.h:69:10`!)break; |
| 2182 | /* suck in another packet */ |
| 2183 | { |
| 2184 | int ret=_fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(vf,nullptr,1,0); |
| 2185 | if(ret<0 && ret!=OV_HOLEcxx . . $ `external/vorbis/vorbis_codec.h:218:9`!)return(ret); |
| 2186 | } |
| 2187 | } |
| 2188 | return 0; |
| 2189 | } |
| 2190 | |
| 2191 | /* make sure vf is INITSET and that we have a primed buffer; if |
| 2192 | we're crosslapping at a stream section boundary, this also makes |
| 2193 | sure we're sanity checking against the right stream information */ |
| 2194 | static int _ov_initprimecxx . . $ _ov_initprime(231cee6479b09f2b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf){ |
| 2195 | vorbis_dsp_statecxx . . $ vorbis_dsp_state# *vd=&vf->vdcxx . . $ OggVorbis_File#vd.; |
| 2196 | while(1){ |
| 2197 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.==INITSETcxx . . $ `external/vorbis/vorbisfile.h:69:10`!) |
| 2198 | if(vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(fd400e10b261aeec).(vd,nullptr))break; |
| 2199 | |
| 2200 | /* suck in another packet */ |
| 2201 | { |
| 2202 | int ret=_fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(vf,nullptr,1,0); |
| 2203 | if(ret<0 && ret!=OV_HOLEcxx . . $ `external/vorbis/vorbis_codec.h:218:9`!)return(ret); |
| 2204 | } |
| 2205 | } |
| 2206 | return 0; |
| 2207 | } |
| 2208 | |
| 2209 | /* grab enough data for lapping from vf; this may be in the form of |
| 2210 | unreturned, already-decoded pcm, remaining PCM we will need to |
| 2211 | decode, or synthetic postextrapolation from last packets. */ |
| 2212 | static void _ov_getlapcxx . . $ _ov_getlap(46e5f5acc22eae8).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,vorbis_infocxx . . $ vorbis_info# *vi,vorbis_dsp_statecxx . . $ vorbis_dsp_state# *vd, |
| 2213 | float **lappcm,int lapsize){ |
| 2214 | int lapcount=0,i; |
| 2215 | float **pcm; |
| 2216 | |
| 2217 | /* try first to decode the lapping data */ |
| 2218 | while(lapcount<lapsize){ |
| 2219 | int samples=vorbis_synthesis_pcmoutcxx . . $ vorbis_synthesis_pcmout(fd400e10b261aeec).(vd,&pcm); |
| 2220 | if(samples){ |
| 2221 | if(samples>lapsize-lapcount)samples=lapsize-lapcount; |
| 2222 | for(i=0;i<vi->channelscxx . . $ vorbis_info#channels.;i++) |
| 2223 | memcpy(lappcm[i]+lapcount,pcm[i],sizeof(**pcm)*samples); |
| 2224 | lapcount+=samples; |
| 2225 | vorbis_synthesis_readcxx . . $ vorbis_synthesis_read(462060a1f4fafeae).(vd,samples); |
| 2226 | }else{ |
| 2227 | /* suck in another packet */ |
| 2228 | int ret=_fetch_and_process_packetcxx . . $ _fetch_and_process_packet(7cff4728704fead3).(vf,nullptr,1,0); /* do *not* span */ |
| 2229 | if(ret==OV_EOFcxx . . $ `external/vorbis/vorbis_codec.h:217:9`!)break; |
| 2230 | } |
| 2231 | } |
| 2232 | if(lapcount<lapsize){ |
| 2233 | /* failed to get lapping data from normal decode; pry it from the |
| 2234 | postextrapolation buffering, or the second half of the MDCT |
| 2235 | from the last packet */ |
| 2236 | int samples=vorbis_synthesis_lapoutcxx . . $ vorbis_synthesis_lapout(fd400e10b261aeec).(&vf->vdcxx . . $ OggVorbis_File#vd.,&pcm); |
| 2237 | if(samples==0){ |
| 2238 | for(i=0;i<vi->channelscxx . . $ vorbis_info#channels.;i++) |
| 2239 | memset(lappcm[i]+lapcount,0,sizeof(**pcm)*lapsize-lapcount); |
| 2240 | lapcount=lapsize; |
| 2241 | }else{ |
| 2242 | if(samples>lapsize-lapcount)samples=lapsize-lapcount; |
| 2243 | for(i=0;i<vi->channelscxx . . $ vorbis_info#channels.;i++) |
| 2244 | memcpy(lappcm[i]+lapcount,pcm[i],sizeof(**pcm)*samples); |
| 2245 | lapcount+=samples; |
| 2246 | } |
| 2247 | } |
| 2248 | } |
| 2249 | |
| 2250 | /* this sets up crosslapping of a sample by using trailing data from |
| 2251 | sample 1 and lapping it into the windowing buffer of sample 2 */ |
| 2252 | int ov_crosslapcxx . . $ ov_crosslap(cc69377286883955).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf1, OggVorbis_Filecxx . . $ OggVorbis_File# *vf2){ |
| 2253 | vorbis_infocxx . . $ vorbis_info# *vi1,*vi2; |
| 2254 | float **lappcm; |
| 2255 | float **pcm; |
| 2256 | const float *w1,*w2; |
| 2257 | int n1,n2,i,ret,hs1,hs2; |
| 2258 | |
| 2259 | if(vf1==vf2)return(0); /* degenerate case */ |
| 2260 | if(vf1->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 2261 | if(vf2->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 2262 | |
| 2263 | /* the relevant overlap buffers must be pre-checked and pre-primed |
| 2264 | before looking at settings in the event that priming would cross |
| 2265 | a bitstream boundary. So, do it now */ |
| 2266 | |
| 2267 | ret=_ov_initsetcxx . . $ _ov_initset(231cee6479b09f2b).(vf1); |
| 2268 | if(ret)return(ret); |
| 2269 | ret=_ov_initprimecxx . . $ _ov_initprime(231cee6479b09f2b).(vf2); |
| 2270 | if(ret)return(ret); |
| 2271 | |
| 2272 | vi1=ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(vf1,-1); |
| 2273 | vi2=ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(vf2,-1); |
| 2274 | hs1=ov_halfrate_pcxx . . $ ov_halfrate_p(231cee6479b09f2b).(vf1); |
| 2275 | hs2=ov_halfrate_pcxx . . $ ov_halfrate_p(231cee6479b09f2b).(vf2); |
| 2276 | |
| 2277 | lappcm=(float **)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(*lappcm)*vi1->channels); |
| 2278 | n1=vorbis_info_blocksizecxx . . $ vorbis_info_blocksize(567c21d5828d03ac).(vi1,0)>>(1+hs1); |
| 2279 | n2=vorbis_info_blocksizecxx . . $ vorbis_info_blocksize(567c21d5828d03ac).(vi2,0)>>(1+hs2); |
| 2280 | w1=vorbis_windowcxx . . $ vorbis_window(817ae43db252f106).(&vf1->vdcxx . . $ OggVorbis_File#vd.,0); |
| 2281 | w2=vorbis_windowcxx . . $ vorbis_window(817ae43db252f106).(&vf2->vdcxx . . $ OggVorbis_File#vd.,0); |
| 2282 | |
| 2283 | for(i=0;i<vi1->channelscxx . . $ vorbis_info#channels.;i++) |
| 2284 | lappcm[i]=(float *)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(**lappcm)*n1); |
| 2285 | |
| 2286 | _ov_getlapcxx . . $ _ov_getlap(46e5f5acc22eae8).(vf1,vi1,&vf1->vdcxx . . $ OggVorbis_File#vd.,lappcm,n1); |
| 2287 | |
| 2288 | /* have a lapping buffer from vf1; now to splice it into the lapping |
| 2289 | buffer of vf2 */ |
| 2290 | /* consolidate and expose the buffer. */ |
| 2291 | vorbis_synthesis_lapoutcxx . . $ vorbis_synthesis_lapout(fd400e10b261aeec).(&vf2->vdcxx . . $ OggVorbis_File#vd.,&pcm); |
| 2292 | |
| 2293 | #if 0 |
| 2294 | _analysis_output_always("pcmL",0,pcm[0],n1*2,0,0,0); |
| 2295 | _analysis_output_always("pcmR",0,pcm[1],n1*2,0,0,0); |
| 2296 | #endif |
| 2297 | |
| 2298 | /* splice */ |
| 2299 | _ov_splicecxx . . $ _ov_splice(20d39c5a5bddc345).(pcm,lappcm,n1,n2,vi1->channelscxx . . $ vorbis_info#channels.,vi2->channelscxx . . $ vorbis_info#channels.,w1,w2); |
| 2300 | |
| 2301 | /* done */ |
| 2302 | return(0); |
| 2303 | } |
| 2304 | |
| 2305 | static int _ov_64_seek_lapcxx . . $ _ov_64_seek_lap(a8e9311a933e913c).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# pos, |
| 2306 | int (*localseek)(OggVorbis_Filecxx . . $ OggVorbis_File# *,ogg_int64_tcxx . . $ ogg_int64_t#)){ |
| 2307 | vorbis_infocxx . . $ vorbis_info# *vi; |
| 2308 | float **lappcm; |
| 2309 | float **pcm; |
| 2310 | const float *w1,*w2; |
| 2311 | int n1,n2,ch1,ch2,hs; |
| 2312 | int i,ret; |
| 2313 | |
| 2314 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 2315 | ret=_ov_initsetcxx . . $ _ov_initset(231cee6479b09f2b).(vf); |
| 2316 | if(ret)return(ret); |
| 2317 | vi=ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(vf,-1); |
| 2318 | hs=ov_halfrate_pcxx . . $ ov_halfrate_p(231cee6479b09f2b).(vf); |
| 2319 | |
| 2320 | ch1=vi->channelscxx . . $ vorbis_info#channels.; |
| 2321 | n1=vorbis_info_blocksizecxx . . $ vorbis_info_blocksize(567c21d5828d03ac).(vi,0)>>(1+hs); |
| 2322 | w1=vorbis_windowcxx . . $ vorbis_window(817ae43db252f106).(&vf->vdcxx . . $ OggVorbis_File#vd.,0); /* window arrays from libvorbis are |
| 2323 | persistent; even if the decode state |
| 2324 | from this link gets dumped, this |
| 2325 | window array continues to exist */ |
| 2326 | |
| 2327 | lappcm=(float **)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(*lappcm)*ch1); |
| 2328 | for(i=0;i<ch1;i++) |
| 2329 | lappcm[i]=(float *)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(**lappcm)*n1); |
| 2330 | _ov_getlapcxx . . $ _ov_getlap(46e5f5acc22eae8).(vf,vi,&vf->vdcxx . . $ OggVorbis_File#vd.,lappcm,n1); |
| 2331 | |
| 2332 | /* have lapping data; seek and prime the buffer */ |
| 2333 | ret=localseek(vf,pos); |
| 2334 | if(ret)return ret; |
| 2335 | ret=_ov_initprimecxx . . $ _ov_initprime(231cee6479b09f2b).(vf); |
| 2336 | if(ret)return(ret); |
| 2337 | |
| 2338 | /* Guard against cross-link changes; they're perfectly legal */ |
| 2339 | vi=ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(vf,-1); |
| 2340 | ch2=vi->channelscxx . . $ vorbis_info#channels.; |
| 2341 | n2=vorbis_info_blocksizecxx . . $ vorbis_info_blocksize(567c21d5828d03ac).(vi,0)>>(1+hs); |
| 2342 | w2=vorbis_windowcxx . . $ vorbis_window(817ae43db252f106).(&vf->vdcxx . . $ OggVorbis_File#vd.,0); |
| 2343 | |
| 2344 | /* consolidate and expose the buffer. */ |
| 2345 | vorbis_synthesis_lapoutcxx . . $ vorbis_synthesis_lapout(fd400e10b261aeec).(&vf->vdcxx . . $ OggVorbis_File#vd.,&pcm); |
| 2346 | |
| 2347 | /* splice */ |
| 2348 | _ov_splicecxx . . $ _ov_splice(20d39c5a5bddc345).(pcm,lappcm,n1,n2,ch1,ch2,w1,w2); |
| 2349 | |
| 2350 | /* done */ |
| 2351 | return(0); |
| 2352 | } |
| 2353 | |
| 2354 | int ov_raw_seek_lapcxx . . $ ov_raw_seek_lap(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# pos){ |
| 2355 | return _ov_64_seek_lapcxx . . $ _ov_64_seek_lap(a8e9311a933e913c).(vf,pos,ov_raw_seekcxx . . $ ov_raw_seek(2602c1e715810f3a).); |
| 2356 | } |
| 2357 | |
| 2358 | int ov_pcm_seek_lapcxx . . $ ov_pcm_seek_lap(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# pos){ |
| 2359 | return _ov_64_seek_lapcxx . . $ _ov_64_seek_lap(a8e9311a933e913c).(vf,pos,ov_pcm_seekcxx . . $ ov_pcm_seek(2602c1e715810f3a).); |
| 2360 | } |
| 2361 | |
| 2362 | int ov_pcm_seek_page_lapcxx . . $ ov_pcm_seek_page_lap(2602c1e715810f3a).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,ogg_int64_tcxx . . $ ogg_int64_t# pos){ |
| 2363 | return _ov_64_seek_lapcxx . . $ _ov_64_seek_lap(a8e9311a933e913c).(vf,pos,ov_pcm_seek_pagecxx . . $ ov_pcm_seek_page(2602c1e715810f3a).); |
| 2364 | } |
| 2365 | |
| 2366 | static int _ov_d_seek_lapcxx . . $ _ov_d_seek_lap(a5838e8f25874c40).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,double pos, |
| 2367 | int (*localseek)(OggVorbis_Filecxx . . $ OggVorbis_File# *,double)){ |
| 2368 | vorbis_infocxx . . $ vorbis_info# *vi; |
| 2369 | float **lappcm; |
| 2370 | float **pcm; |
| 2371 | const float *w1,*w2; |
| 2372 | int n1,n2,ch1,ch2,hs; |
| 2373 | int i,ret; |
| 2374 | |
| 2375 | if(vf->ready_statecxx . . $ OggVorbis_File#ready_state.<OPENEDcxx . . $ `external/vorbis/vorbisfile.h:67:10`!)return(OV_EINVALcxx . . $ `external/vorbis/vorbis_codec.h:223:9`!); |
| 2376 | ret=_ov_initsetcxx . . $ _ov_initset(231cee6479b09f2b).(vf); |
| 2377 | if(ret)return(ret); |
| 2378 | vi=ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(vf,-1); |
| 2379 | hs=ov_halfrate_pcxx . . $ ov_halfrate_p(231cee6479b09f2b).(vf); |
| 2380 | |
| 2381 | ch1=vi->channelscxx . . $ vorbis_info#channels.; |
| 2382 | n1=vorbis_info_blocksizecxx . . $ vorbis_info_blocksize(567c21d5828d03ac).(vi,0)>>(1+hs); |
| 2383 | w1=vorbis_windowcxx . . $ vorbis_window(817ae43db252f106).(&vf->vdcxx . . $ OggVorbis_File#vd.,0); /* window arrays from libvorbis are |
| 2384 | persistent; even if the decode state |
| 2385 | from this link gets dumped, this |
| 2386 | window array continues to exist */ |
| 2387 | |
| 2388 | lappcm=(float **)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(*lappcm)*ch1); |
| 2389 | for(i=0;i<ch1;i++) |
| 2390 | lappcm[i]=(float *)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(**lappcm)*n1); |
| 2391 | _ov_getlapcxx . . $ _ov_getlap(46e5f5acc22eae8).(vf,vi,&vf->vdcxx . . $ OggVorbis_File#vd.,lappcm,n1); |
| 2392 | |
| 2393 | /* have lapping data; seek and prime the buffer */ |
| 2394 | ret=localseek(vf,pos); |
| 2395 | if(ret)return ret; |
| 2396 | ret=_ov_initprimecxx . . $ _ov_initprime(231cee6479b09f2b).(vf); |
| 2397 | if(ret)return(ret); |
| 2398 | |
| 2399 | /* Guard against cross-link changes; they're perfectly legal */ |
| 2400 | vi=ov_infocxx . . $ ov_info(8f27ddcb17d7c056).(vf,-1); |
| 2401 | ch2=vi->channelscxx . . $ vorbis_info#channels.; |
| 2402 | n2=vorbis_info_blocksizecxx . . $ vorbis_info_blocksize(567c21d5828d03ac).(vi,0)>>(1+hs); |
| 2403 | w2=vorbis_windowcxx . . $ vorbis_window(817ae43db252f106).(&vf->vdcxx . . $ OggVorbis_File#vd.,0); |
| 2404 | |
| 2405 | /* consolidate and expose the buffer. */ |
| 2406 | vorbis_synthesis_lapoutcxx . . $ vorbis_synthesis_lapout(fd400e10b261aeec).(&vf->vdcxx . . $ OggVorbis_File#vd.,&pcm); |
| 2407 | |
| 2408 | /* splice */ |
| 2409 | _ov_splicecxx . . $ _ov_splice(20d39c5a5bddc345).(pcm,lappcm,n1,n2,ch1,ch2,w1,w2); |
| 2410 | |
| 2411 | /* done */ |
| 2412 | return(0); |
| 2413 | } |
| 2414 | |
| 2415 | int ov_time_seek_lapcxx . . $ ov_time_seek_lap(503e2689db2d7b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,double pos){ |
| 2416 | return _ov_d_seek_lapcxx . . $ _ov_d_seek_lap(a5838e8f25874c40).(vf,pos,ov_time_seekcxx . . $ ov_time_seek(503e2689db2d7b).); |
| 2417 | } |
| 2418 | |
| 2419 | int ov_time_seek_page_lapcxx . . $ ov_time_seek_page_lap(503e2689db2d7b).(OggVorbis_Filecxx . . $ OggVorbis_File# *vf,double pos){ |
| 2420 | return _ov_d_seek_lapcxx . . $ _ov_d_seek_lap(a5838e8f25874c40).(vf,pos,ov_time_seek_pagecxx . . $ ov_time_seek_page(503e2689db2d7b).); |
| 2421 | } |