30 return((
int)(og->
header[4]));
34 return((
int)(og->
header[5]&0x01));
38 return((
int)(og->
header[5]&0x02));
42 return((
int)(og->
header[5]&0x04));
46 unsigned char *page=og->
header;
48 granulepos= (granulepos<<8)|(page[12]&0xff);
49 granulepos= (granulepos<<8)|(page[11]&0xff);
50 granulepos= (granulepos<<8)|(page[10]&0xff);
51 granulepos= (granulepos<<8)|(page[9]&0xff);
52 granulepos= (granulepos<<8)|(page[8]&0xff);
53 granulepos= (granulepos<<8)|(page[7]&0xff);
54 granulepos= (granulepos<<8)|(page[6]&0xff);
109 if (r & 0x80000000UL)
110 r = (r << 1) ^ 0x04c11db7;
116 return (r & 0xffffffffUL);
121 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,
122 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005,
123 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,
124 0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd,
125 0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9,
126 0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75,
127 0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,
128 0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd,
129 0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039,
130 0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5,
131 0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81,
132 0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d,
133 0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,
134 0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95,
135 0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1,
136 0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d,
137 0x34867077,0x30476dc0,0x3d044b19,0x39c556ae,
138 0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072,
139 0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,
140 0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca,
141 0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde,
142 0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02,
143 0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066,
144 0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba,
145 0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,
146 0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692,
147 0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6,
148 0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a,
149 0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e,
150 0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2,
151 0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,
152 0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a,
153 0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637,
154 0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb,
155 0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f,
156 0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53,
157 0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,
158 0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b,
159 0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff,
160 0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623,
161 0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7,
162 0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b,
163 0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,
164 0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3,
165 0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7,
166 0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b,
167 0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f,
168 0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3,
169 0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,
170 0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c,
171 0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8,
172 0x68860bfd,0x6c47164a,0x61043093,0x65c52d24,
173 0x119b4be9,0x155a565e,0x18197087,0x1cd86d30,
174 0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec,
175 0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,
176 0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654,
177 0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0,
178 0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c,
179 0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18,
180 0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4,
181 0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,
182 0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c,
183 0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668,
184 0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4};
292 crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->
header[
i]];
294 crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->
body[
i]];
296 og->
header[22]=(
unsigned char)(crc_reg&0xff);
297 og->
header[23]=(
unsigned char)((crc_reg>>8)&0xff);
298 og->
header[24]=(
unsigned char)((crc_reg>>16)&0xff);
299 og->
header[25]=(
unsigned char)((crc_reg>>24)&0xff);
307 int bytes = 0, lacing_vals,
i;
313 lacing_vals=bytes/255+1;
336 for (i = 0; i <
count; ++
i) {
342 for(i=0;i<lacing_vals-1;i++){
357 if(e_o_s)os->
e_o_s=1;
381 if(maxvals==0)
return(0);
390 for(vals=0;vals<maxvals;vals++){
408 int packet_just_done=0;
409 for(vals=0;vals<maxvals;vals++){
410 if(acc>nfill && packet_just_done>=4){
417 packet_just_done=++packets_done;
421 if(vals==255)force=1;
424 if(!force)
return(0);
443 os->
header[
i]=(
unsigned char)(granule_pos&0xff);
451 os->
header[
i]=(
unsigned char)(serialno&0xff);
466 os->
header[
i]=(
unsigned char)(pageno&0xff);
478 os->
header[26]=(
unsigned char)(vals&0xff);
623 long newsize=size+oy->
fill+4096;
668 if(bytes<27)
return(0);
671 if(memcmp(page,
"OggS",4))
goto sync_fail;
673 headerbytes=page[26]+27;
674 if(bytes<headerbytes)
return(0);
678 for(i=0;i<page[26];i++)
702 if(memcmp(chksum,page+22,4)){
738 next=memchr(page+1,
'O',bytes-1);
743 return((
long)-(next-page));
792 unsigned char *body=og->
body;
803 int segments=header[26];
835 if(serialno!=os->
serialno)
return(-1);
836 if(version>0)
return(-1);
862 for(;segptr<segments;segptr++){
863 int val=header[27+segptr];
882 while(segptr<segments){
883 int val=header[27+segptr];
976 if(!op && !adv)
return(1);
990 if(val&0x200)eos=0x200;
1024 memset(op, 0,
sizeof(*op));
1033 void checkpacket(
ogg_packet *op,
long len,
int no,
long pos){
1035 static int sequence=0;
1036 static int lastno=0;
1039 fprintf(stderr,
"incorrect packet length (%ld != %ld)!\n",op->
bytes,len);
1043 fprintf(stderr,
"incorrect packet granpos (%ld != %ld)!\n",(
long)op->
granulepos,pos);
1058 fprintf(stderr,
"incorrect packet sequence %ld != %d\n",
1064 for(j=0;j<op->
bytes;j++)
1065 if(op->
packet[j]!=((j+no)&0xff)){
1066 fprintf(stderr,
"body data mismatch (1) at pos %ld: %x!=%lx!\n\n",
1067 j,op->
packet[j],(j+no)&0xff);
1076 if(og->
body[j]!=data[j]){
1077 fprintf(stderr,
"body data mismatch (2) at pos %ld: %x!=%x!\n\n",
1078 j,data[j],og->
body[j]);
1084 if(og->
header[j]!=header[j]){
1085 fprintf(stderr,
"header content mismatch at pos %ld:\n",j);
1086 for(j=0;j<header[26]+27;j++)
1087 fprintf(stderr,
" (%ld)%02x:%02x",j,header[j],og->
header[j]);
1088 fprintf(stderr,
"\n");
1093 fprintf(stderr,
"header length incorrect! (%ld!=%d)\n",
1101 fprintf(stderr,
"\nHEADER:\n");
1102 fprintf(stderr,
" capture: %c %c %c %c version: %d flags: %x\n",
1106 fprintf(stderr,
" granulepos: %d serialno: %d pageno: %ld\n",
1114 fprintf(stderr,
" checksum: %02x:%02x:%02x:%02x\n segments: %d (",
1120 fprintf(stderr,
"%d ",(
int)og->
header[j]);
1121 fprintf(stderr,
")\n\n");
1140 fprintf(stderr,
"error!\n");
1145 const int head1_0[] = {0x4f,0x67,0x67,0x53,0,0x06,
1146 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1147 0x01,0x02,0x03,0x04,0,0,0,0,
1148 0x15,0xed,0xec,0x91,
1153 const int head1_1[] = {0x4f,0x67,0x67,0x53,0,0x02,
1154 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1155 0x01,0x02,0x03,0x04,0,0,0,0,
1156 0x59,0x10,0x6c,0x2c,
1159 const int head2_1[] = {0x4f,0x67,0x67,0x53,0,0x04,
1160 0x07,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
1161 0x01,0x02,0x03,0x04,1,0,0,0,
1162 0x89,0x33,0x85,0xce,
1164 254,255,0,255,1,255,245,255,255,0,
1168 const int head1_2[] = {0x4f,0x67,0x67,0x53,0,0x02,
1169 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1170 0x01,0x02,0x03,0x04,0,0,0,0,
1171 0xff,0x7b,0x23,0x17,
1174 const int head2_2[] = {0x4f,0x67,0x67,0x53,0,0x04,
1175 0x07,0x28,0x00,0x00,0x00,0x00,0x00,0x00,
1176 0x01,0x02,0x03,0x04,1,0,0,0,
1177 0x5c,0x3f,0x66,0xcb,
1179 17,254,255,0,0,255,1,0,255,245,255,255,0,
1183 const int head1_3[] = {0x4f,0x67,0x67,0x53,0,0x02,
1184 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1185 0x01,0x02,0x03,0x04,0,0,0,0,
1186 0x01,0x27,0x31,0xaa,
1188 255,255,255,255,255,255,255,255,
1189 255,255,255,255,255,255,255,255,255,10};
1191 const int head2_3[] = {0x4f,0x67,0x67,0x53,0,0x04,
1192 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
1193 0x01,0x02,0x03,0x04,1,0,0,0,
1194 0x7f,0x4e,0x8a,0xd2,
1200 const int head1_4[] = {0x4f,0x67,0x67,0x53,0,0x02,
1201 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1202 0x01,0x02,0x03,0x04,0,0,0,0,
1203 0xff,0x7b,0x23,0x17,
1207 const int head2_4[] = {0x4f,0x67,0x67,0x53,0,0x00,
1208 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
1209 0x01,0x02,0x03,0x04,1,0,0,0,
1210 0xf8,0x3c,0x19,0x79,
1212 255,255,255,255,255,255,255,255,
1213 255,255,255,255,255,255,255,255,
1214 255,255,255,255,255,255,255,255,
1215 255,255,255,255,255,255,255,255,
1216 255,255,255,255,255,255,255,255,
1217 255,255,255,255,255,255,255,255,
1218 255,255,255,255,255,255,255,255,
1219 255,255,255,255,255,255,255,255,
1220 255,255,255,255,255,255,255,255,
1221 255,255,255,255,255,255,255,255,
1222 255,255,255,255,255,255,255,255,
1223 255,255,255,255,255,255,255,255,
1224 255,255,255,255,255,255,255,255,
1225 255,255,255,255,255,255,255,255,
1226 255,255,255,255,255,255,255,255,
1227 255,255,255,255,255,255,255,255,
1228 255,255,255,255,255,255,255,255,
1229 255,255,255,255,255,255,255,255,
1230 255,255,255,255,255,255,255,255,
1231 255,255,255,255,255,255,255,255,
1232 255,255,255,255,255,255,255,255,
1233 255,255,255,255,255,255,255,255,
1234 255,255,255,255,255,255,255,255,
1235 255,255,255,255,255,255,255,255,
1236 255,255,255,255,255,255,255,255,
1237 255,255,255,255,255,255,255,255,
1238 255,255,255,255,255,255,255,255,
1239 255,255,255,255,255,255,255,255,
1240 255,255,255,255,255,255,255,255,
1241 255,255,255,255,255,255,255,255,
1242 255,255,255,255,255,255,255,255,
1243 255,255,255,255,255,255,255};
1245 const int head3_4[] = {0x4f,0x67,0x67,0x53,0,0x05,
1246 0x07,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,
1247 0x01,0x02,0x03,0x04,2,0,0,0,
1248 0x38,0xe6,0xb6,0x28,
1250 255,220,255,4,255,0};
1254 const int head1_4b[] = {0x4f,0x67,0x67,0x53,0,0x02,
1255 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1256 0x01,0x02,0x03,0x04,0,0,0,0,
1257 0xff,0x7b,0x23,0x17,
1261 const int head2_4b[] = {0x4f,0x67,0x67,0x53,0,0x00,
1262 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
1263 0x01,0x02,0x03,0x04,1,0,0,0,
1264 0xce,0x8f,0x17,0x1a,
1266 255,255,255,255,255,255,255,255,
1267 255,255,255,255,255,255,255,255,255,10,255,4,255,0,0};
1270 const int head3_4b[] = {0x4f,0x67,0x67,0x53,0,0x04,
1271 0x07,0x14,0x00,0x00,0x00,0x00,0x00,0x00,
1272 0x01,0x02,0x03,0x04,2,0,0,0,
1273 0x9b,0xb2,0x50,0xa1,
1278 const int head1_5[] = {0x4f,0x67,0x67,0x53,0,0x02,
1279 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1280 0x01,0x02,0x03,0x04,0,0,0,0,
1281 0xff,0x7b,0x23,0x17,
1285 const int head2_5[] = {0x4f,0x67,0x67,0x53,0,0x00,
1286 0x07,0xfc,0x03,0x00,0x00,0x00,0x00,0x00,
1287 0x01,0x02,0x03,0x04,1,0,0,0,
1288 0xed,0x2a,0x2e,0xa7,
1290 10,10,10,10,10,10,10,10,
1291 10,10,10,10,10,10,10,10,
1292 10,10,10,10,10,10,10,10,
1293 10,10,10,10,10,10,10,10,
1294 10,10,10,10,10,10,10,10,
1295 10,10,10,10,10,10,10,10,
1296 10,10,10,10,10,10,10,10,
1297 10,10,10,10,10,10,10,10,
1298 10,10,10,10,10,10,10,10,
1299 10,10,10,10,10,10,10,10,
1300 10,10,10,10,10,10,10,10,
1301 10,10,10,10,10,10,10,10,
1302 10,10,10,10,10,10,10,10,
1303 10,10,10,10,10,10,10,10,
1304 10,10,10,10,10,10,10,10,
1305 10,10,10,10,10,10,10,10,
1306 10,10,10,10,10,10,10,10,
1307 10,10,10,10,10,10,10,10,
1308 10,10,10,10,10,10,10,10,
1309 10,10,10,10,10,10,10,10,
1310 10,10,10,10,10,10,10,10,
1311 10,10,10,10,10,10,10,10,
1312 10,10,10,10,10,10,10,10,
1313 10,10,10,10,10,10,10,10,
1314 10,10,10,10,10,10,10,10,
1315 10,10,10,10,10,10,10,10,
1316 10,10,10,10,10,10,10,10,
1317 10,10,10,10,10,10,10,10,
1318 10,10,10,10,10,10,10,10,
1319 10,10,10,10,10,10,10,10,
1320 10,10,10,10,10,10,10,10,
1321 10,10,10,10,10,10,10};
1323 const int head3_5[] = {0x4f,0x67,0x67,0x53,0,0x04,
1324 0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
1325 0x01,0x02,0x03,0x04,2,0,0,0,
1326 0x6c,0x3b,0x82,0x3d,
1332 const int head1_6[] = {0x4f,0x67,0x67,0x53,0,0x02,
1333 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1334 0x01,0x02,0x03,0x04,0,0,0,0,
1335 0xff,0x7b,0x23,0x17,
1339 const int head2_6[] = {0x4f,0x67,0x67,0x53,0,0x00,
1340 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
1341 0x01,0x02,0x03,0x04,1,0,0,0,
1342 0x68,0x22,0x7c,0x3d,
1345 255,255,255,255,255,255,255,255,
1346 255,255,255,255,255,255,255,255,
1347 255,255,255,255,255,255,255,255,
1348 255,255,255,255,255,255,255,255,
1349 255,255,255,255,255,255,255,255,
1350 255,255,255,255,255,255,255,255,
1351 255,255,255,255,255,255,255,255,
1352 255,255,255,255,255,255,255,255,
1353 255,255,255,255,255,255,255,255,
1354 255,255,255,255,255,255,255,255,
1355 255,255,255,255,255,255,255,255,
1356 255,255,255,255,255,255,255,255,
1357 255,255,255,255,255,255,255,255,
1358 255,255,255,255,255,255,255,255,
1359 255,255,255,255,255,255,255,255,
1360 255,255,255,255,255,255,255,255,
1361 255,255,255,255,255,255,255,255,
1362 255,255,255,255,255,255,255,255,
1363 255,255,255,255,255,255,255,255,
1364 255,255,255,255,255,255,255,255,
1365 255,255,255,255,255,255,255,255,
1366 255,255,255,255,255,255,255,255,
1367 255,255,255,255,255,255,255,255,
1368 255,255,255,255,255,255,255,255,
1369 255,255,255,255,255,255,255,255,
1370 255,255,255,255,255,255,255,255,
1371 255,255,255,255,255,255,255,255,
1372 255,255,255,255,255,255,255,255,
1373 255,255,255,255,255,255,255,255,
1374 255,255,255,255,255,255,255,255,
1375 255,255,255,255,255,255,255,255,
1376 255,255,255,255,255,255};
1378 const int head3_6[] = {0x4f,0x67,0x67,0x53,0,0x01,
1379 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
1380 0x01,0x02,0x03,0x04,2,0,0,0,
1381 0xf4,0x87,0xba,0xf3,
1383 255,255,255,255,255,255,255,255,
1384 255,255,255,255,255,255,255,255,
1385 255,255,255,255,255,255,255,255,
1386 255,255,255,255,255,255,255,255,
1387 255,255,255,255,255,255,255,255,
1388 255,255,255,255,255,255,255,255,
1389 255,255,255,255,255,255,255,255,
1390 255,255,255,255,255,255,255,255,
1391 255,255,255,255,255,255,255,255,
1392 255,255,255,255,255,255,255,255,
1393 255,255,255,255,255,255,255,255,
1394 255,255,255,255,255,255,255,255,
1395 255,255,255,255,255,255,255,255,
1396 255,255,255,255,255,255,255,255,
1397 255,255,255,255,255,255,255,255,
1398 255,255,255,255,255,255,255,255,
1399 255,255,255,255,255,255,255,255,
1400 255,255,255,255,255,255,255,255,
1401 255,255,255,255,255,255,255,255,
1402 255,255,255,255,255,255,255,255,
1403 255,255,255,255,255,255,255,255,
1404 255,255,255,255,255,255,255,255,
1405 255,255,255,255,255,255,255,255,
1406 255,255,255,255,255,255,255,255,
1407 255,255,255,255,255,255,255,255,
1408 255,255,255,255,255,255,255,255,
1409 255,255,255,255,255,255,255,255,
1410 255,255,255,255,255,255,255,255,
1411 255,255,255,255,255,255,255,255,
1412 255,255,255,255,255,255,255,255,
1413 255,255,255,255,255,255,255,255,
1414 255,255,255,255,255,255,255};
1416 const int head4_6[] = {0x4f,0x67,0x67,0x53,0,0x05,
1417 0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
1418 0x01,0x02,0x03,0x04,3,0,0,0,
1419 0xf7,0x2f,0x6c,0x60,
1424 const int head1_7[] = {0x4f,0x67,0x67,0x53,0,0x02,
1425 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1426 0x01,0x02,0x03,0x04,0,0,0,0,
1427 0xff,0x7b,0x23,0x17,
1431 const int head2_7[] = {0x4f,0x67,0x67,0x53,0,0x00,
1432 0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
1433 0x01,0x02,0x03,0x04,1,0,0,0,
1434 0x68,0x22,0x7c,0x3d,
1437 255,255,255,255,255,255,255,255,
1438 255,255,255,255,255,255,255,255,
1439 255,255,255,255,255,255,255,255,
1440 255,255,255,255,255,255,255,255,
1441 255,255,255,255,255,255,255,255,
1442 255,255,255,255,255,255,255,255,
1443 255,255,255,255,255,255,255,255,
1444 255,255,255,255,255,255,255,255,
1445 255,255,255,255,255,255,255,255,
1446 255,255,255,255,255,255,255,255,
1447 255,255,255,255,255,255,255,255,
1448 255,255,255,255,255,255,255,255,
1449 255,255,255,255,255,255,255,255,
1450 255,255,255,255,255,255,255,255,
1451 255,255,255,255,255,255,255,255,
1452 255,255,255,255,255,255,255,255,
1453 255,255,255,255,255,255,255,255,
1454 255,255,255,255,255,255,255,255,
1455 255,255,255,255,255,255,255,255,
1456 255,255,255,255,255,255,255,255,
1457 255,255,255,255,255,255,255,255,
1458 255,255,255,255,255,255,255,255,
1459 255,255,255,255,255,255,255,255,
1460 255,255,255,255,255,255,255,255,
1461 255,255,255,255,255,255,255,255,
1462 255,255,255,255,255,255,255,255,
1463 255,255,255,255,255,255,255,255,
1464 255,255,255,255,255,255,255,255,
1465 255,255,255,255,255,255,255,255,
1466 255,255,255,255,255,255,255,255,
1467 255,255,255,255,255,255,255,255,
1468 255,255,255,255,255,255};
1470 const int head3_7[] = {0x4f,0x67,0x67,0x53,0,0x05,
1471 0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
1472 0x01,0x02,0x03,0x04,2,0,0,0,
1473 0xd4,0xe0,0x60,0xe5,
1477 void test_pack(
const int *pl,
const int **headers,
int byteskip,
1478 int pageskip,
int packetskip){
1484 long granule_pos=7,pageno=0;
1489 int byteskipcount=0;
1495 for(packets=0;packets<packetskip;packets++)
1496 depacket+=pl[packets];
1498 for(packets=0;;packets++)
if(pl[packets]==-1)
break;
1507 op.
e_o_s=(pl[i+1]<0?1:0);
1512 for(j=0;j<
len;j++)data[inptr++]=i+j;
1524 fprintf(stderr,
"%ld, ",pageno);
1526 if(headers[pageno]==
NULL){
1527 fprintf(stderr,
"coded too many pages!\n");
1531 check_page(data+outptr,headers[pageno],&og);
1549 if(byteskipcount>byteskip){
1551 next+=byteskipcount-byteskip;
1552 byteskipcount=byteskip;
1556 if(byteskipcount>byteskip){
1558 next+=byteskipcount-byteskip;
1559 byteskipcount=byteskip;
1570 fprintf(stderr,
"(%d), ",pageout);
1572 check_page(data+deptr,headers[pageout],&og_de);
1585 if(memcmp(&op_de,&op_de2,
sizeof(op_de))){
1586 fprintf(stderr,
"packetout != packetpeek! pos=%ld\n",
1593 if(memcmp(data+depacket,op_de.
packet,op_de.
bytes)){
1594 fprintf(stderr,
"packet data mismatch in decode! pos=%ld\n",
1599 if(bosflag==0 && op_de.
b_o_s==0){
1600 fprintf(stderr,
"b_o_s flag not set on packet!\n");
1603 if(bosflag && op_de.
b_o_s){
1604 fprintf(stderr,
"b_o_s flag incorrectly set on packet!\n");
1608 depacket+=op_de.
bytes;
1612 fprintf(stderr,
"Multiple decoded packets with eos flag!\n");
1616 if(op_de.
e_o_s)eosflag=1;
1620 fprintf(stderr,
" granule:%ld ",(
long)op_de.
granulepos);
1629 if(headers[pageno]!=
NULL){
1630 fprintf(stderr,
"did not write last page!\n");
1633 if(headers[pageout]!=
NULL){
1634 fprintf(stderr,
"did not decode last page!\n");
1638 fprintf(stderr,
"encoded page data incomplete!\n");
1642 fprintf(stderr,
"decoded page data incomplete!\n");
1645 if(inptr!=depacket){
1646 fprintf(stderr,
"decoded packet data incomplete!\n");
1650 fprintf(stderr,
"Never got a packet with EOS set!\n");
1653 fprintf(stderr,
"ok.\n");
1667 const int packets[]={17, -1};
1668 const int *headret[]={head1_0,
NULL};
1670 fprintf(stderr,
"testing single page encoding... ");
1671 test_pack(packets,headret,0,0,0);
1676 const int packets[]={17, 254, 255, 256, 500, 510, 600, -1};
1677 const int *headret[]={head1_1,head2_1,
NULL};
1679 fprintf(stderr,
"testing basic page encoding... ");
1680 test_pack(packets,headret,0,0,0);
1685 const int packets[]={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1};
1686 const int *headret[]={head1_2,head2_2,
NULL};
1688 fprintf(stderr,
"testing basic nil packets... ");
1689 test_pack(packets,headret,0,0,0);
1694 const int packets[]={4345,259,255,-1};
1695 const int *headret[]={head1_3,head2_3,
NULL};
1697 fprintf(stderr,
"testing initial-packet lacing > 4k... ");
1698 test_pack(packets,headret,0,0,0);
1704 const int packets[]={0,65500,259,255,-1};
1705 const int *headret[]={head1_4,head2_4,head3_4,
NULL};
1707 fprintf(stderr,
"testing single packet page span... ");
1708 test_pack(packets,headret,0,0,0);
1713 const int packets[]={0,4345,259,255,0,0,-1};
1714 const int *headret[]={head1_4b,head2_4b,head3_4b,
NULL};
1716 fprintf(stderr,
"testing page spill expansion... ");
1717 test_pack(packets,headret,0,0,0);
1723 const int packets[]={0,10,10,10,10,10,10,10,10,
1724 10,10,10,10,10,10,10,10,
1725 10,10,10,10,10,10,10,10,
1726 10,10,10,10,10,10,10,10,
1727 10,10,10,10,10,10,10,10,
1728 10,10,10,10,10,10,10,10,
1729 10,10,10,10,10,10,10,10,
1730 10,10,10,10,10,10,10,10,
1731 10,10,10,10,10,10,10,10,
1732 10,10,10,10,10,10,10,10,
1733 10,10,10,10,10,10,10,10,
1734 10,10,10,10,10,10,10,10,
1735 10,10,10,10,10,10,10,10,
1736 10,10,10,10,10,10,10,10,
1737 10,10,10,10,10,10,10,10,
1738 10,10,10,10,10,10,10,10,
1739 10,10,10,10,10,10,10,10,
1740 10,10,10,10,10,10,10,10,
1741 10,10,10,10,10,10,10,10,
1742 10,10,10,10,10,10,10,10,
1743 10,10,10,10,10,10,10,10,
1744 10,10,10,10,10,10,10,10,
1745 10,10,10,10,10,10,10,10,
1746 10,10,10,10,10,10,10,10,
1747 10,10,10,10,10,10,10,10,
1748 10,10,10,10,10,10,10,10,
1749 10,10,10,10,10,10,10,10,
1750 10,10,10,10,10,10,10,10,
1751 10,10,10,10,10,10,10,10,
1752 10,10,10,10,10,10,10,10,
1753 10,10,10,10,10,10,10,10,
1754 10,10,10,10,10,10,10,50,-1};
1755 const int *headret[]={head1_5,head2_5,head3_5,
NULL};
1757 fprintf(stderr,
"testing max packet segments... ");
1758 test_pack(packets,headret,0,0,0);
1763 const int packets[]={0,100,130049,259,255,-1};
1764 const int *headret[]={head1_6,head2_6,head3_6,head4_6,
NULL};
1766 fprintf(stderr,
"testing very large packets... ");
1767 test_pack(packets,headret,0,0,0);
1773 const int packets[]={0,100,130049,259,255,-1};
1774 const int *headret[]={head1_6,head2_6,head3_6,head4_6,
NULL};
1776 fprintf(stderr,
"testing continuation resync in very large packets... ");
1777 test_pack(packets,headret,100,2,3);
1782 const int packets[]={0,100,64770,-1};
1783 const int *headret[]={head1_7,head2_7,head3_7,
NULL};
1785 fprintf(stderr,
"testing zero data page (1 nil packet)... ");
1786 test_pack(packets,headret,0,0,0);
1794 int pl[]={0, 1,1,98,4079, 1,1,2954,2057, 76,34,912,0,234,1000,1000, 1000,300,-1};
1800 for(i=0;pl[
i]!=-1;i++){
1806 op.
e_o_s=(pl[i+1]<0?1:0);
1809 for(j=0;j<
len;j++)data[inptr++]=i+j;
1818 fprintf(stderr,
"Too few pages output building sync tests!\n");
1829 fprintf(stderr,
"Testing loss of pages... ");
1853 checkpacket(&test,0,0,0);
1855 checkpacket(&test,1,1,-1);
1857 checkpacket(&test,1,2,-1);
1859 checkpacket(&test,98,3,-1);
1861 checkpacket(&test,4079,4,5000);
1863 fprintf(stderr,
"Error: loss of page did not return error\n");
1867 checkpacket(&test,76,9,-1);
1869 checkpacket(&test,34,10,-1);
1870 fprintf(stderr,
"ok.\n");
1878 fprintf(stderr,
"Testing loss of pages (rollback required)... ");
1904 checkpacket(&test,0,0,0);
1906 checkpacket(&test,1,1,-1);
1908 checkpacket(&test,1,2,-1);
1910 checkpacket(&test,98,3,-1);
1912 checkpacket(&test,4079,4,5000);
1914 checkpacket(&test,1,5,-1);
1916 checkpacket(&test,1,6,-1);
1918 checkpacket(&test,2954,7,-1);
1920 checkpacket(&test,2057,8,9000);
1922 fprintf(stderr,
"Error: loss of page did not return error\n");
1926 checkpacket(&test,300,17,18000);
1927 fprintf(stderr,
"ok.\n");
1934 fprintf(stderr,
"Testing sync on partial inputs... ");
1956 og[1].header_len-28);
1965 og[1].body_len-1000);
1969 fprintf(stderr,
"ok.\n");
1975 fprintf(stderr,
"Testing sync on 1+partial inputs... ");
1993 og[1].header_len-20);
2000 fprintf(stderr,
"ok.\n");
2006 fprintf(stderr,
"Testing search for capture... ");
2030 og[2].header_len-20);
2037 fprintf(stderr,
"ok.\n");
2043 fprintf(stderr,
"Testing recapture... ");
2079 fprintf(stderr,
"ok.\n");
int ogg_page_eos(const ogg_page *og)
GLuint const GLfloat * val
static int _os_body_expand(ogg_stream_state *os, int needed)
cannot open resource broken file module version is too low unimplemented feature broken offset within table missing module invalid character code cannot render this glyph format invalid composite glyph invalid pixel size invalid library handle invalid face handle invalid glyph slot handle invalid cache manager handle too many modules out of memory cannot open stream invalid stream skip invalid stream operation nested frame access raster uninitialized raster overflow too many registered caches too few arguments code overflow division by zero found debug opcode nested DEFS execution context too long too many instruction definitions horizontal header(hhea) table missing" ) FT_ERRORDEF_( Locations_Missing
int ogg_stream_flush(ogg_stream_state *os, ogg_page *og)
int ogg_stream_check(ogg_stream_state *os)
int main(int argc, char **argv)
unsigned char * body_data
int ogg_stream_flush_fill(ogg_stream_state *os, ogg_page *og, int nfill)
int ogg_sync_wrote(ogg_sync_state *oy, long bytes)
int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill)
int ogg_stream_eos(ogg_stream_state *os)
ogg_int64_t * granule_vals
int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og)
unsigned char header[282]
static UDPpacket ** packets
static int _packetout(ogg_stream_state *os, ogg_packet *op, int adv)
static int _os_lacing_expand(ogg_stream_state *os, int needed)
char * ogg_sync_buffer(ogg_sync_state *oy, long size)
int ogg_sync_reset(ogg_sync_state *oy)
int ogg_page_continued(const ogg_page *og)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
int ogg_stream_packetpeek(ogg_stream_state *os, ogg_packet *op)
int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op)
int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og)
int ogg_page_bos(const ogg_page *og)
void ogg_packet_clear(ogg_packet *op)
void ogg_page_checksum_set(ogg_page *og)
int ogg_sync_check(ogg_sync_state *oy)
int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og)
int ogg_sync_clear(ogg_sync_state *oy)
int ogg_sync_destroy(ogg_sync_state *oy)
static const ogg_uint32_t crc_lookup[256]
unsigned int ogg_uint32_t
long ogg_page_pageno(const ogg_page *og)
int ogg_stream_clear(ogg_stream_state *os)
static int ogg_stream_flush_i(ogg_stream_state *os, ogg_page *og, int force, int nfill)
int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, int count, long e_o_s, ogg_int64_t granulepos)
int ogg_page_packets(const ogg_page *og)
long ogg_sync_pageseek(ogg_sync_state *oy, ogg_page *og)
GLenum GLuint GLsizei const GLchar * buf
int ogg_stream_destroy(ogg_stream_state *os)
int ogg_stream_packetout(ogg_stream_state *os, ogg_packet *op)
GLdouble GLdouble GLdouble r
int ogg_stream_reset(ogg_stream_state *os)
int ogg_sync_init(ogg_sync_state *oy)
int ogg_stream_reset_serialno(ogg_stream_state *os, int serialno)
int ogg_page_serialno(const ogg_page *og)
ogg_int64_t ogg_page_granulepos(const ogg_page *og)
int ogg_stream_init(ogg_stream_state *os, int serialno)
int ogg_page_version(const ogg_page *og)