| 1 | /******************************************************************** |
| 2 | * * |
| 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * |
| 4 | * * |
| 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
| 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
| 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
| 8 | * * |
| 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 * |
| 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * |
| 11 | * * |
| 12 | ******************************************************************** |
| 13 | |
| 14 | function: maintain the info structure, info <-> header packets |
| 15 | |
| 16 | ********************************************************************/ |
| 17 | |
| 18 | /* general handling of the header and the vorbis_info structure (and |
| 19 | substructures) */ |
| 20 | |
| 21 | #include <stdlib.h> |
| 22 | #include <string.h> |
| 23 | #include <ctype.h> |
| 24 | #include <limits.h> |
| 25 | #include "ogg.h"cxx . . $ `<file>/mednafen/tremor/ogg.h`/ |
| 26 | #include "ivorbiscodec.h"cxx . . $ `<file>/mednafen/tremor/ivorbiscodec.h`/ |
| 27 | #include "codec_internal.h"cxx . . $ `<file>/mednafen/tremor/codec_internal.h`/ |
| 28 | #include "codebook.h"cxx . . $ `<file>/mednafen/tremor/codebook.h`/ |
| 29 | #include "registry.h"cxx . . $ `<file>/mednafen/tremor/registry.h`/ |
| 30 | #include "window.h"cxx . . $ `<file>/mednafen/tremor/window.h`/ |
| 31 | #include "misc.h"cxx . . $ `<file>/mednafen/tremor/misc.h`/ |
| 32 | |
| 33 | /* helpers */ |
| 34 | static void _v_readstringcxx . . $ _v_readstring(c44b9a41977e793f).(oggpack_buffercxx . . $ oggpack_buffer# *o,char *buf,int bytes){ |
| 35 | while(bytes--){ |
| 36 | *buf++=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(o,8); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | void vorbis_comment_initcxx . . $ vorbis_comment_init(93d47bffb8aa4dc6).(vorbis_commentcxx . . $ vorbis_comment# *vc){ |
| 41 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(vc,0,sizeof(*vc)); |
| 42 | } |
| 43 | |
| 44 | /* This is more or less the same as strncasecmp - but that doesn't exist |
| 45 | * everywhere, and this is a fairly trivial function, so we include it */ |
| 46 | static int tagcomparecxx . . $ tagcompare(f0be30763a490cce).(const char *s1, const char *s2, int n){ |
| 47 | int c=0; |
| 48 | while(c < n){ |
| 49 | if(touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!(s1[c]) != touppercxx . . $ `<external>/17904084882347303253/ctype.h:221:11`!(s2[c])) |
| 50 | return !0; |
| 51 | c++; |
| 52 | } |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | char *vorbis_comment_querycxx . . $ vorbis_comment_query(f76539686bec7ac2).(vorbis_commentcxx . . $ vorbis_comment# *vc, char *tag, int count){ |
| 57 | long i; |
| 58 | int found = 0; |
| 59 | int taglen = strlencxx . . $ strlen(751346f8406fd082).(tag)+1; /* +1 for the = we append */ |
| 60 | char *fulltag = (char *)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(taglen+ 1); |
| 61 | |
| 62 | strcpycxx . . $ strcpy(b7b3a83273496486).(fulltag, tag); |
| 63 | strcatcxx . . $ strcat(b7b3a83273496486).(fulltag, "="); |
| 64 | |
| 65 | for(i=0;i<vc->commentscxx . . $ vorbis_comment#comments.;i++){ |
| 66 | if(!tagcomparecxx . . $ tagcompare(f0be30763a490cce).(vc->user_commentscxx . . $ vorbis_comment#user_comments.[i], fulltag, taglen)){ |
| 67 | if(count == found) |
| 68 | /* We return a pointer to the data, not a copy */ |
| 69 | return vc->user_commentscxx . . $ vorbis_comment#user_comments.[i] + taglen; |
| 70 | else |
| 71 | found++; |
| 72 | } |
| 73 | } |
| 74 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; /* didn't find anything */ |
| 75 | } |
| 76 | |
| 77 | int vorbis_comment_query_countcxx . . $ vorbis_comment_query_count(ee1b7d08fa4bd0ec).(vorbis_commentcxx . . $ vorbis_comment# *vc, char *tag){ |
| 78 | int i,count=0; |
| 79 | int taglen = strlencxx . . $ strlen(751346f8406fd082).(tag)+1; /* +1 for the = we append */ |
| 80 | char *fulltag = (char *)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(taglen+1); |
| 81 | strcpycxx . . $ strcpy(b7b3a83273496486).(fulltag,tag); |
| 82 | strcatcxx . . $ strcat(b7b3a83273496486).(fulltag, "="); |
| 83 | |
| 84 | for(i=0;i<vc->commentscxx . . $ vorbis_comment#comments.;i++){ |
| 85 | if(!tagcomparecxx . . $ tagcompare(f0be30763a490cce).(vc->user_commentscxx . . $ vorbis_comment#user_comments.[i], fulltag, taglen)) |
| 86 | count++; |
| 87 | } |
| 88 | |
| 89 | return count; |
| 90 | } |
| 91 | |
| 92 | void vorbis_comment_clearcxx . . $ vorbis_comment_clear(93d47bffb8aa4dc6).(vorbis_commentcxx . . $ vorbis_comment# *vc){ |
| 93 | if(vc){ |
| 94 | long i; |
| 95 | if(vc->user_commentscxx . . $ vorbis_comment#user_comments.){ |
| 96 | for(i=0;i<vc->commentscxx . . $ vorbis_comment#comments.;i++) |
| 97 | if(vc->user_commentscxx . . $ vorbis_comment#user_comments.[i])_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vc->user_commentscxx . . $ vorbis_comment#user_comments.[i]); |
| 98 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vc->user_commentscxx . . $ vorbis_comment#user_comments.); |
| 99 | } |
| 100 | if(vc->comment_lengthscxx . . $ vorbis_comment#comment_lengths.)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vc->comment_lengthscxx . . $ vorbis_comment#comment_lengths.); |
| 101 | if(vc->vendorcxx . . $ vorbis_comment#vendor.)_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(vc->vendorcxx . . $ vorbis_comment#vendor.); |
| 102 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(vc,0,sizeof(*vc)); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. |
| 107 | They may be equal, but short will never ge greater than long */ |
| 108 | int vorbis_info_blocksizecxx . . $ vorbis_info_blocksize(567c21d5828d03ac).(vorbis_infocxx . . $ vorbis_info# *vi,int zo){ |
| 109 | codec_setup_infocxx . . $ codec_setup_info# *ci = (codec_setup_infocxx . . $ codec_setup_info# *)vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 110 | return ci ? ci->blocksizescxx . . $ codec_setup_info#blocksizes.[zo] : -1; |
| 111 | } |
| 112 | |
| 113 | /* used by synthesis, which has a full, alloced vi */ |
| 114 | void vorbis_info_initcxx . . $ vorbis_info_init(d534a068b27cdae4).(vorbis_infocxx . . $ vorbis_info# *vi){ |
| 115 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(vi,0,sizeof(*vi)); |
| 116 | vi->codec_setupcxx . . $ vorbis_info#codec_setup.=(codec_setup_infocxx . . $ codec_setup_info# *)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(1,sizeof(codec_setup_infocxx . . $ codec_setup_info#)); |
| 117 | } |
| 118 | |
| 119 | void vorbis_info_clearcxx . . $ vorbis_info_clear(d534a068b27cdae4).(vorbis_infocxx . . $ vorbis_info# *vi){ |
| 120 | codec_setup_infocxx . . $ codec_setup_info# *ci=(codec_setup_infocxx . . $ codec_setup_info# *)vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 121 | int i; |
| 122 | |
| 123 | if(ci){ |
| 124 | |
| 125 | for(i=0;i<ci->modescxx . . $ codec_setup_info#modes.;i++) |
| 126 | if(ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i])_ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]); |
| 127 | |
| 128 | for(i=0;i<ci->mapscxx . . $ codec_setup_info#maps.;i++) /* unpack does the range checking */ |
| 129 | if(ci->map_paramcxx . . $ codec_setup_info#map_param.[i]) |
| 130 | _mapping_Pcxx . . $ _mapping_P.[ci->map_typecxx . . $ codec_setup_info#map_type.[i]]->free_infocxx . . $ $anonymous_type_c7374eb872c22577_4#free_info.(ci->map_paramcxx . . $ codec_setup_info#map_param.[i]); |
| 131 | |
| 132 | for(i=0;i<ci->floorscxx . . $ codec_setup_info#floors.;i++) /* unpack does the range checking */ |
| 133 | if(ci->floor_paramcxx . . $ codec_setup_info#floor_param.[i]) |
| 134 | _floor_Pcxx . . $ _floor_P.[ci->floor_typecxx . . $ codec_setup_info#floor_type.[i]]->free_infocxx . . $ $anonymous_type_c7374eb872c22577_0#free_info.(ci->floor_paramcxx . . $ codec_setup_info#floor_param.[i]); |
| 135 | |
| 136 | for(i=0;i<ci->residuescxx . . $ codec_setup_info#residues.;i++) /* unpack does the range checking */ |
| 137 | if(ci->residue_paramcxx . . $ codec_setup_info#residue_param.[i]) |
| 138 | _residue_Pcxx . . $ _residue_P.[ci->residue_typecxx . . $ codec_setup_info#residue_type.[i]]->free_infocxx . . $ $anonymous_type_c7374eb872c22577_3#free_info.(ci->residue_paramcxx . . $ codec_setup_info#residue_param.[i]); |
| 139 | |
| 140 | for(i=0;i<ci->bookscxx . . $ codec_setup_info#books.;i++){ |
| 141 | if(ci->book_paramcxx . . $ codec_setup_info#book_param.[i]){ |
| 142 | /* knows if the book was not alloced */ |
| 143 | vorbis_staticbook_destroycxx . . $ vorbis_staticbook_destroy(50dc96045c2ba69d).(ci->book_paramcxx . . $ codec_setup_info#book_param.[i]); |
| 144 | } |
| 145 | if(ci->fullbookscxx . . $ codec_setup_info#fullbooks.) |
| 146 | vorbis_book_clearcxx . . $ vorbis_book_clear(947fb228bbaa529d).(ci->fullbookscxx . . $ codec_setup_info#fullbooks.+i); |
| 147 | } |
| 148 | if(ci->fullbookscxx . . $ codec_setup_info#fullbooks.) |
| 149 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(ci->fullbookscxx . . $ codec_setup_info#fullbooks.); |
| 150 | |
| 151 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(ci); |
| 152 | } |
| 153 | |
| 154 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(vi,0,sizeof(*vi)); |
| 155 | } |
| 156 | |
| 157 | /* Header packing/unpacking ********************************************/ |
| 158 | |
| 159 | static int _vorbis_unpack_infocxx . . $ _vorbis_unpack_info(b7cda36c0b44a67e).(vorbis_infocxx . . $ vorbis_info# *vi,oggpack_buffercxx . . $ oggpack_buffer# *opb){ |
| 160 | codec_setup_infocxx . . $ codec_setup_info# *ci=(codec_setup_infocxx . . $ codec_setup_info# *)vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 161 | if(!ci)return(OV_EFAULTcxx . . $ `mednafen/tremor/ivorbiscodec.h:188:9`!); |
| 162 | |
| 163 | vi->versioncxx . . $ vorbis_info#version.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,32); |
| 164 | if(vi->versioncxx . . $ vorbis_info#version.!=0)return(OV_EVERSIONcxx . . $ `mednafen/tremor/ivorbiscodec.h:193:9`!); |
| 165 | |
| 166 | vi->channelscxx . . $ vorbis_info#channels.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,8); |
| 167 | vi->ratecxx . . $ vorbis_info#rate.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,32); |
| 168 | |
| 169 | vi->bitrate_uppercxx . . $ vorbis_info#bitrate_upper.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,32); |
| 170 | vi->bitrate_nominalcxx . . $ vorbis_info#bitrate_nominal.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,32); |
| 171 | vi->bitrate_lowercxx . . $ vorbis_info#bitrate_lower.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,32); |
| 172 | |
| 173 | ci->blocksizescxx . . $ codec_setup_info#blocksizes.[0]=1<<oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,4); |
| 174 | ci->blocksizescxx . . $ codec_setup_info#blocksizes.[1]=1<<oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,4); |
| 175 | |
| 176 | if(vi->ratecxx . . $ vorbis_info#rate.<1)goto err_out; |
| 177 | if(vi->channelscxx . . $ vorbis_info#channels.<1)goto err_out; |
| 178 | if(ci->blocksizescxx . . $ codec_setup_info#blocksizes.[0]<64)goto err_out; |
| 179 | if(ci->blocksizescxx . . $ codec_setup_info#blocksizes.[1]<ci->blocksizescxx . . $ codec_setup_info#blocksizes.[0])goto err_out; |
| 180 | if(ci->blocksizescxx . . $ codec_setup_info#blocksizes.[1]>8192)goto err_out; |
| 181 | |
| 182 | if(oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,1)!=1)goto err_out; /* EOP check */ |
| 183 | |
| 184 | return(0); |
| 185 | err_out: |
| 186 | vorbis_info_clearcxx . . $ vorbis_info_clear(d534a068b27cdae4).(vi); |
| 187 | return(OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!); |
| 188 | } |
| 189 | |
| 190 | static int _vorbis_unpack_commentcxx . . $ _vorbis_unpack_comment(ef173cca0843f1c5).(vorbis_commentcxx . . $ vorbis_comment# *vc,oggpack_buffercxx . . $ oggpack_buffer# *opb){ |
| 191 | int i; |
| 192 | int vendorlen; |
| 193 | vendorlen=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,32); |
| 194 | if(vendorlen<0)goto err_out; |
| 195 | if(vendorlen>opb->storagecxx . . $ $anonymous_type_cccabde66011c92d_1#storage.-oggpack_bytescxx . . $ oggpack_bytes(ced507c9175a1bd4).(opb))goto err_out; |
| 196 | vc->vendorcxx . . $ vorbis_comment#vendor.=(char *)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(vendorlen+1,1); |
| 197 | if(vc->vendorcxx . . $ vorbis_comment#vendor.==NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)goto err_out; |
| 198 | _v_readstringcxx . . $ _v_readstring(c44b9a41977e793f).(opb,vc->vendorcxx . . $ vorbis_comment#vendor.,vendorlen); |
| 199 | i=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,32); |
| 200 | if(i<0||i>=INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!||i>(opb->storagecxx . . $ $anonymous_type_cccabde66011c92d_1#storage.-oggpack_bytescxx . . $ oggpack_bytes(ced507c9175a1bd4).(opb))>>2)goto err_out; |
| 201 | vc->user_commentscxx . . $ vorbis_comment#user_comments.=(char **)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(i+1,sizeof(*vc->user_commentscxx . . $ vorbis_comment#user_comments.)); |
| 202 | vc->comment_lengthscxx . . $ vorbis_comment#comment_lengths.=(int *)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(i+1, sizeof(*vc->comment_lengthscxx . . $ vorbis_comment#comment_lengths.)); |
| 203 | if(vc->user_commentscxx . . $ vorbis_comment#user_comments.==NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!||vc->comment_lengthscxx . . $ vorbis_comment#comment_lengths.==NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)goto err_out; |
| 204 | vc->commentscxx . . $ vorbis_comment#comments.=i; |
| 205 | |
| 206 | for(i=0;i<vc->commentscxx . . $ vorbis_comment#comments.;i++){ |
| 207 | int len=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,32); |
| 208 | if(len<0||len>opb->storagecxx . . $ $anonymous_type_cccabde66011c92d_1#storage.-oggpack_bytescxx . . $ oggpack_bytes(ced507c9175a1bd4).(opb))goto err_out; |
| 209 | vc->comment_lengthscxx . . $ vorbis_comment#comment_lengths.[i]=len; |
| 210 | vc->user_commentscxx . . $ vorbis_comment#user_comments.[i]=(char *)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(len+1,1); |
| 211 | if(vc->user_commentscxx . . $ vorbis_comment#user_comments.[i]==NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!){ |
| 212 | vc->commentscxx . . $ vorbis_comment#comments.=i; |
| 213 | goto err_out; |
| 214 | } |
| 215 | _v_readstringcxx . . $ _v_readstring(c44b9a41977e793f).(opb,vc->user_commentscxx . . $ vorbis_comment#user_comments.[i],len); |
| 216 | } |
| 217 | if(oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,1)!=1)goto err_out; /* EOP check */ |
| 218 | |
| 219 | return(0); |
| 220 | err_out: |
| 221 | vorbis_comment_clearcxx . . $ vorbis_comment_clear(93d47bffb8aa4dc6).(vc); |
| 222 | return(OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!); |
| 223 | } |
| 224 | |
| 225 | /* all of the real encoding details are here. The modes, books, |
| 226 | everything */ |
| 227 | static int _vorbis_unpack_bookscxx . . $ _vorbis_unpack_books(b7cda36c0b44a67e).(vorbis_infocxx . . $ vorbis_info# *vi,oggpack_buffercxx . . $ oggpack_buffer# *opb){ |
| 228 | codec_setup_infocxx . . $ codec_setup_info# *ci=(codec_setup_infocxx . . $ codec_setup_info# *)vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 229 | int i; |
| 230 | if(!ci)return(OV_EFAULTcxx . . $ `mednafen/tremor/ivorbiscodec.h:188:9`!); |
| 231 | |
| 232 | /* codebooks */ |
| 233 | ci->bookscxx . . $ codec_setup_info#books.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,8)+1; |
| 234 | if(ci->bookscxx . . $ codec_setup_info#books.<=0)goto err_out; |
| 235 | for(i=0;i<ci->bookscxx . . $ codec_setup_info#books.;i++){ |
| 236 | ci->book_paramcxx . . $ codec_setup_info#book_param.[i]=vorbis_staticbook_unpackcxx . . $ vorbis_staticbook_unpack(5de40fe896400830).(opb); |
| 237 | if(!ci->book_paramcxx . . $ codec_setup_info#book_param.[i])goto err_out; |
| 238 | } |
| 239 | |
| 240 | /* time backend settings */ |
| 241 | ci->timescxx . . $ codec_setup_info#times.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,6)+1; |
| 242 | if(ci->timescxx . . $ codec_setup_info#times.<=0)goto err_out; |
| 243 | for(i=0;i<ci->timescxx . . $ codec_setup_info#times.;i++){ |
| 244 | ci->time_typecxx . . $ codec_setup_info#time_type.[i]=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,16); |
| 245 | if(ci->time_typecxx . . $ codec_setup_info#time_type.[i]<0 || ci->time_typecxx . . $ codec_setup_info#time_type.[i]>=VI_TIMEBcxx . . $ `mednafen/tremor/registry.h:23:9`!)goto err_out; |
| 246 | /* ci->time_param[i]=_time_P[ci->time_type[i]]->unpack(vi,opb); |
| 247 | Vorbis I has no time backend */ |
| 248 | /*if(!ci->time_param[i])goto err_out;*/ |
| 249 | } |
| 250 | |
| 251 | /* floor backend settings */ |
| 252 | ci->floorscxx . . $ codec_setup_info#floors.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,6)+1; |
| 253 | if(ci->floorscxx . . $ codec_setup_info#floors.<=0)goto err_out; |
| 254 | for(i=0;i<ci->floorscxx . . $ codec_setup_info#floors.;i++){ |
| 255 | ci->floor_typecxx . . $ codec_setup_info#floor_type.[i]=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,16); |
| 256 | if(ci->floor_typecxx . . $ codec_setup_info#floor_type.[i]<0 || ci->floor_typecxx . . $ codec_setup_info#floor_type.[i]>=VI_FLOORBcxx . . $ `mednafen/tremor/registry.h:24:9`!)goto err_out; |
| 257 | ci->floor_paramcxx . . $ codec_setup_info#floor_param.[i]=_floor_Pcxx . . $ _floor_P.[ci->floor_typecxx . . $ codec_setup_info#floor_type.[i]]->unpackcxx . . $ $anonymous_type_c7374eb872c22577_0#unpack.(vi,opb); |
| 258 | if(!ci->floor_paramcxx . . $ codec_setup_info#floor_param.[i])goto err_out; |
| 259 | } |
| 260 | |
| 261 | /* residue backend settings */ |
| 262 | ci->residuescxx . . $ codec_setup_info#residues.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,6)+1; |
| 263 | if(ci->residuescxx . . $ codec_setup_info#residues.<=0)goto err_out; |
| 264 | for(i=0;i<ci->residuescxx . . $ codec_setup_info#residues.;i++){ |
| 265 | ci->residue_typecxx . . $ codec_setup_info#residue_type.[i]=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,16); |
| 266 | if(ci->residue_typecxx . . $ codec_setup_info#residue_type.[i]<0 || ci->residue_typecxx . . $ codec_setup_info#residue_type.[i]>=VI_RESBcxx . . $ `mednafen/tremor/registry.h:25:9`!)goto err_out; |
| 267 | ci->residue_paramcxx . . $ codec_setup_info#residue_param.[i]=_residue_Pcxx . . $ _residue_P.[ci->residue_typecxx . . $ codec_setup_info#residue_type.[i]]->unpackcxx . . $ $anonymous_type_c7374eb872c22577_3#unpack.(vi,opb); |
| 268 | if(!ci->residue_paramcxx . . $ codec_setup_info#residue_param.[i])goto err_out; |
| 269 | } |
| 270 | |
| 271 | /* map backend settings */ |
| 272 | ci->mapscxx . . $ codec_setup_info#maps.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,6)+1; |
| 273 | if(ci->mapscxx . . $ codec_setup_info#maps.<=0)goto err_out; |
| 274 | for(i=0;i<ci->mapscxx . . $ codec_setup_info#maps.;i++){ |
| 275 | ci->map_typecxx . . $ codec_setup_info#map_type.[i]=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,16); |
| 276 | if(ci->map_typecxx . . $ codec_setup_info#map_type.[i]<0 || ci->map_typecxx . . $ codec_setup_info#map_type.[i]>=VI_MAPBcxx . . $ `mednafen/tremor/registry.h:26:9`!)goto err_out; |
| 277 | ci->map_paramcxx . . $ codec_setup_info#map_param.[i]=_mapping_Pcxx . . $ _mapping_P.[ci->map_typecxx . . $ codec_setup_info#map_type.[i]]->unpackcxx . . $ $anonymous_type_c7374eb872c22577_4#unpack.(vi,opb); |
| 278 | if(!ci->map_paramcxx . . $ codec_setup_info#map_param.[i])goto err_out; |
| 279 | } |
| 280 | |
| 281 | /* mode settings */ |
| 282 | ci->modescxx . . $ codec_setup_info#modes.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,6)+1; |
| 283 | if(ci->modescxx . . $ codec_setup_info#modes.<=0)goto err_out; |
| 284 | for(i=0;i<ci->modescxx . . $ codec_setup_info#modes.;i++){ |
| 285 | ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]=(vorbis_info_modecxx . . $ vorbis_info_mode# *)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(1,sizeof(*ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i])); |
| 286 | ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]->blockflagcxx . . $ $anonymous_type_310d37d35ac071a0_0#blockflag.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,1); |
| 287 | ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]->windowtypecxx . . $ $anonymous_type_310d37d35ac071a0_0#windowtype.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,16); |
| 288 | ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]->transformtypecxx . . $ $anonymous_type_310d37d35ac071a0_0#transformtype.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,16); |
| 289 | ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]->mappingcxx . . $ $anonymous_type_310d37d35ac071a0_0#mapping.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,8); |
| 290 | |
| 291 | if(ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]->windowtypecxx . . $ $anonymous_type_310d37d35ac071a0_0#windowtype.>=VI_WINDOWBcxx . . $ `mednafen/tremor/registry.h:22:9`!)goto err_out; |
| 292 | if(ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]->transformtypecxx . . $ $anonymous_type_310d37d35ac071a0_0#transformtype.>=VI_WINDOWBcxx . . $ `mednafen/tremor/registry.h:22:9`!)goto err_out; |
| 293 | if(ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]->mappingcxx . . $ $anonymous_type_310d37d35ac071a0_0#mapping.>=ci->mapscxx . . $ codec_setup_info#maps.)goto err_out; |
| 294 | if(ci->mode_paramcxx . . $ codec_setup_info#mode_param.[i]->mappingcxx . . $ $anonymous_type_310d37d35ac071a0_0#mapping.<0)goto err_out; |
| 295 | } |
| 296 | |
| 297 | if(oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,1)!=1)goto err_out; /* top level EOP check */ |
| 298 | |
| 299 | return(0); |
| 300 | err_out: |
| 301 | vorbis_info_clearcxx . . $ vorbis_info_clear(d534a068b27cdae4).(vi); |
| 302 | return(OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!); |
| 303 | } |
| 304 | |
| 305 | /* Is this packet a vorbis ID header? */ |
| 306 | int vorbis_synthesis_idheadercxx . . $ vorbis_synthesis_idheader(93d9f7a6e445c2aa).(ogg_packetcxx . . $ ogg_packet# *op){ |
| 307 | oggpack_buffercxx . . $ oggpack_buffer# opb; |
| 308 | char buffer[6]; |
| 309 | |
| 310 | if(op){ |
| 311 | oggpack_readinitcxx . . $ oggpack_readinit(c5e395f807ba7ecc).(&opb,op->packetcxx . . $ $anonymous_type_cccabde66011c92d_4#packet.,op->bytescxx . . $ $anonymous_type_cccabde66011c92d_4#bytes.); |
| 312 | |
| 313 | if(!op->b_o_scxx . . $ $anonymous_type_cccabde66011c92d_4#b_o_s.) |
| 314 | return(0); /* Not the initial packet */ |
| 315 | |
| 316 | if(oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(&opb,8) != 1) |
| 317 | return 0; /* not an ID header */ |
| 318 | |
| 319 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(buffer,0,6); |
| 320 | _v_readstringcxx . . $ _v_readstring(c44b9a41977e793f).(&opb,buffer,6); |
| 321 | if(memcmpcxx . . $ memcmp(36f949851efa3055).(buffer,"vorbis",6)) |
| 322 | return 0; /* not vorbis */ |
| 323 | |
| 324 | return 1; |
| 325 | } |
| 326 | |
| 327 | return 0; |
| 328 | } |
| 329 | |
| 330 | /* The Vorbis header is in three packets; the initial small packet in |
| 331 | the first page that identifies basic parameters, a second packet |
| 332 | with bitstream comments and a third packet that holds the |
| 333 | codebook. */ |
| 334 | |
| 335 | int vorbis_synthesis_headerincxx . . $ vorbis_synthesis_headerin(3ae6e73fba03d214).(vorbis_infocxx . . $ vorbis_info# *vi,vorbis_commentcxx . . $ vorbis_comment# *vc,ogg_packetcxx . . $ ogg_packet# *op){ |
| 336 | oggpack_buffercxx . . $ oggpack_buffer# opb; |
| 337 | |
| 338 | if(op){ |
| 339 | oggpack_readinitcxx . . $ oggpack_readinit(c5e395f807ba7ecc).(&opb,op->packetcxx . . $ $anonymous_type_cccabde66011c92d_4#packet.,op->bytescxx . . $ $anonymous_type_cccabde66011c92d_4#bytes.); |
| 340 | |
| 341 | /* Which of the three types of header is this? */ |
| 342 | /* Also verify header-ness, vorbis */ |
| 343 | { |
| 344 | char buffer[6]; |
| 345 | int packtype=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(&opb,8); |
| 346 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(buffer,0,6); |
| 347 | _v_readstringcxx . . $ _v_readstring(c44b9a41977e793f).(&opb,buffer,6); |
| 348 | if(memcmpcxx . . $ memcmp(36f949851efa3055).(buffer,"vorbis",6)){ |
| 349 | /* not a vorbis header */ |
| 350 | return(OV_ENOTVORBIScxx . . $ `mednafen/tremor/ivorbiscodec.h:191:9`!); |
| 351 | } |
| 352 | switch(packtype){ |
| 353 | case 0x01: /* least significant *bit* is read first */ |
| 354 | if(!op->b_o_scxx . . $ $anonymous_type_cccabde66011c92d_4#b_o_s.){ |
| 355 | /* Not the initial packet */ |
| 356 | return(OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!); |
| 357 | } |
| 358 | if(vi->ratecxx . . $ vorbis_info#rate.!=0){ |
| 359 | /* previously initialized info header */ |
| 360 | return(OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!); |
| 361 | } |
| 362 | |
| 363 | return(_vorbis_unpack_infocxx . . $ _vorbis_unpack_info(b7cda36c0b44a67e).(vi,&opb)); |
| 364 | |
| 365 | case 0x03: /* least significant *bit* is read first */ |
| 366 | if(vi->ratecxx . . $ vorbis_info#rate.==0){ |
| 367 | /* um... we didn't get the initial header */ |
| 368 | return(OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!); |
| 369 | } |
| 370 | |
| 371 | return(_vorbis_unpack_commentcxx . . $ _vorbis_unpack_comment(ef173cca0843f1c5).(vc,&opb)); |
| 372 | |
| 373 | case 0x05: /* least significant *bit* is read first */ |
| 374 | if(vi->ratecxx . . $ vorbis_info#rate.==0 || vc->vendorcxx . . $ vorbis_comment#vendor.==NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!){ |
| 375 | /* um... we didn;t get the initial header or comments yet */ |
| 376 | return(OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!); |
| 377 | } |
| 378 | |
| 379 | return(_vorbis_unpack_bookscxx . . $ _vorbis_unpack_books(b7cda36c0b44a67e).(vi,&opb)); |
| 380 | |
| 381 | default: |
| 382 | /* Not a valid vorbis header type */ |
| 383 | return(OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!); |
| 384 | break; |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | return(OV_EBADHEADERcxx . . $ `mednafen/tremor/ivorbiscodec.h:192:9`!); |
| 389 | } |
| 390 |