function: code raw [Vorbis] packets into framed OggSquish stream and
decode Ogg streams back into raw packets
- last mod: $Id: framing.c,v 1.18 2000/06/19 14:59:06 xiphmont Exp $
+ last mod: $Id: framing.c,v 1.19 2000/07/07 01:20:46 xiphmont Exp $
note: The CRC code is directly derived from public domain code by
Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html
}
lastno=no;
if(op->packetno!=sequence){
- fprintf(stderr,"incorrect packet sequence %ld != %d\n",op->packetno,sequence);
+ fprintf(stderr,"incorrect packet sequence %ld != %d\n",
+ (long)(op->packetno),sequence);
exit(1);
}
}
}
-void check_page(unsigned char *data,int *header,ogg_page *og){
+void check_page(unsigned char *data,const int *header,ogg_page *og){
long j;
/* Test data */
for(j=0;j<og->body_len;j++)
exit(1);
}
-void test_pack(int *pl, int **headers){
+void test_pack(const int *pl, const int **headers){
unsigned char *data=malloc(1024*1024); /* for scripted test cases only */
long inptr=0;
long outptr=0;
{
/* 17 only */
- int packets[]={17, -1};
- int head1[] = {0x4f,0x67,0x67,0x53,0,0x06,
+ const int packets[]={17, -1};
+ const int head1[] = {0x4f,0x67,0x67,0x53,0,0x06,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,0,0,0,0,
0x15,0xed,0xec,0x91,
1,
17};
- int *headret[]={head1,NULL};
+ const int *headret[]={head1,NULL};
fprintf(stderr,"testing single page encoding... ");
test_pack(packets,headret);
{
/* 17, 254, 255, 256, 500, 510, 600 byte, pad */
- int packets[]={17, 254, 255, 256, 500, 510, 600, -1};
- int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
+ const int packets[]={17, 254, 255, 256, 500, 510, 600, -1};
+ const int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,0,0,0,0,
0x59,0x10,0x6c,0x2c,
1,
17};
- int head2[] = {0x4f,0x67,0x67,0x53,0,0x04,
+ const int head2[] = {0x4f,0x67,0x67,0x53,0,0x04,
0x07,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,1,0,0,0,
0x89,0x33,0x85,0xce,
13,
254,255,0,255,1,255,245,255,255,0,
255,255,90};
- int *headret[]={head1,head2,NULL};
+ const int *headret[]={head1,head2,NULL};
fprintf(stderr,"testing basic page encoding... ");
test_pack(packets,headret);
{
/* nil packets; beginning,middle,end */
- int packets[]={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1};
+ const int packets[]={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1};
- int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
+ const int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,0,0,0,0,
0xff,0x7b,0x23,0x17,
1,
0};
- int head2[] = {0x4f,0x67,0x67,0x53,0,0x04,
+ const int head2[] = {0x4f,0x67,0x67,0x53,0,0x04,
0x07,0x28,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,1,0,0,0,
0x5c,0x3f,0x66,0xcb,
17,
17,254,255,0,0,255,1,0,255,245,255,255,0,
255,255,90,0};
- int *headret[]={head1,head2,NULL};
+ const int *headret[]={head1,head2,NULL};
fprintf(stderr,"testing basic nil packets... ");
test_pack(packets,headret);
{
/* large initial packet */
- int packets[]={4345,259,255,-1};
+ const int packets[]={4345,259,255,-1};
- int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
+ const int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,0,0,0,0,
0x01,0x27,0x31,0xaa,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,10};
- int head2[] = {0x4f,0x67,0x67,0x53,0,0x04,
+ const int head2[] = {0x4f,0x67,0x67,0x53,0,0x04,
0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,1,0,0,0,
0x7f,0x4e,0x8a,0xd2,
4,
255,4,255,0};
- int *headret[]={head1,head2,NULL};
+ const int *headret[]={head1,head2,NULL};
fprintf(stderr,"testing initial-packet lacing > 4k... ");
test_pack(packets,headret);
{
/* continuing packet test */
- int packets[]={0,4345,259,255,-1};
+ const int packets[]={0,4345,259,255,-1};
- int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
+ const int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,0,0,0,0,
0xff,0x7b,0x23,0x17,
1,
0};
- int head2[] = {0x4f,0x67,0x67,0x53,0,0x00,
+ const int head2[] = {0x4f,0x67,0x67,0x53,0,0x00,
0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,1,0,0,0,
0x34,0x24,0xd5,0x29,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255};
- int head3[] = {0x4f,0x67,0x67,0x53,0,0x05,
+ const int head3[] = {0x4f,0x67,0x67,0x53,0,0x05,
0x07,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,2,0,0,0,
0xc8,0xc3,0xcb,0xed,
5,
10,255,4,255,0};
- int *headret[]={head1,head2,head3,NULL};
+ const int *headret[]={head1,head2,head3,NULL};
fprintf(stderr,"testing single packet page span... ");
test_pack(packets,headret);
/* page with the 255 segment limit */
{
- int packets[]={0,10,10,10,10,10,10,10,10,
+ const int packets[]={0,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,50,-1};
- int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
+ const int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,0,0,0,0,
0xff,0x7b,0x23,0x17,
1,
0};
- int head2[] = {0x4f,0x67,0x67,0x53,0,0x00,
+ const int head2[] = {0x4f,0x67,0x67,0x53,0,0x00,
0x07,0xfc,0x03,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,1,0,0,0,
0xed,0x2a,0x2e,0xa7,
10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10};
- int head3[] = {0x4f,0x67,0x67,0x53,0,0x04,
+ const int head3[] = {0x4f,0x67,0x67,0x53,0,0x04,
0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,2,0,0,0,
0x6c,0x3b,0x82,0x3d,
1,
50};
- int *headret[]={head1,head2,head3,NULL};
+ const int *headret[]={head1,head2,head3,NULL};
fprintf(stderr,"testing max packet segments... ");
test_pack(packets,headret);
{
/* packet that overspans over an entire page */
- int packets[]={0,100,9000,259,255,-1};
+ const int packets[]={0,100,9000,259,255,-1};
- int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
+ const int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,0,0,0,0,
0xff,0x7b,0x23,0x17,
1,
0};
- int head2[] = {0x4f,0x67,0x67,0x53,0,0x00,
+ const int head2[] = {0x4f,0x67,0x67,0x53,0,0x00,
0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,1,0,0,0,
0x3c,0xd9,0x4d,0x3f,
100,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255};
- int head3[] = {0x4f,0x67,0x67,0x53,0,0x01,
+ const int head3[] = {0x4f,0x67,0x67,0x53,0,0x01,
0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,2,0,0,0,
0xbd,0xd5,0xb5,0x8b,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255};
- int head4[] = {0x4f,0x67,0x67,0x53,0,0x05,
+ const int head4[] = {0x4f,0x67,0x67,0x53,0,0x05,
0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,3,0,0,0,
0xef,0xdd,0x88,0xde,
7,
255,255,75,255,4,255,0};
- int *headret[]={head1,head2,head3,head4,NULL};
+ const int *headret[]={head1,head2,head3,head4,NULL};
fprintf(stderr,"testing very large packets... ");
test_pack(packets,headret);
{
/* term only page. why not? */
- int packets[]={0,100,4080,-1};
+ const int packets[]={0,100,4080,-1};
- int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
+ const int head1[] = {0x4f,0x67,0x67,0x53,0,0x02,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,0,0,0,0,
0xff,0x7b,0x23,0x17,
1,
0};
- int head2[] = {0x4f,0x67,0x67,0x53,0,0x00,
+ const int head2[] = {0x4f,0x67,0x67,0x53,0,0x00,
0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,1,0,0,0,
0x3c,0xd9,0x4d,0x3f,
100,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255};
- int head3[] = {0x4f,0x67,0x67,0x53,0,0x05,
+ const int head3[] = {0x4f,0x67,0x67,0x53,0,0x05,
0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x02,0x03,0x04,2,0,0,0,
0xd4,0xe0,0x60,0xe5,
1,0};
- int *headret[]={head1,head2,head3,NULL};
+ const int *headret[]={head1,head2,head3,NULL};
fprintf(stderr,"testing zero data page (1 nil packet)... ");
test_pack(packets,headret);