?? framing.c
字號:
if(continued){ if(os->lacing_fill<1 || os->lacing_vals[os->lacing_fill-1]==0x400){ bos=0; for(;segptr<segments;segptr++){ int val=header[27+segptr]; body+=val; bodysize-=val; if(val<255){ segptr++; break; } } } } if(bodysize){ _os_body_expand(os,bodysize); memcpy(os->body_data+os->body_fill,body,bodysize); os->body_fill+=bodysize; } { int saved=-1; while(segptr<segments){ int val=header[27+segptr]; os->lacing_vals[os->lacing_fill]=val; os->granule_vals[os->lacing_fill]=-1; if(bos){ os->lacing_vals[os->lacing_fill]|=0x100; bos=0; } if(val<255)saved=os->lacing_fill; os->lacing_fill++; segptr++; if(val<255)os->lacing_packet=os->lacing_fill; } /* set the granulepos on the last granuleval of the last full packet */ if(saved!=-1){ os->granule_vals[saved]=granulepos; } } if(eos){ os->e_o_s=1; if(os->lacing_fill>0) os->lacing_vals[os->lacing_fill-1]|=0x200; } os->pageno=pageno+1; return(0);}/* clear things to an initial state. Good to call, eg, before seeking */int ogg_sync_reset(ogg_sync_state *oy){ oy->fill=0; oy->returned=0; oy->unsynced=0; oy->headerbytes=0; oy->bodybytes=0; return(0);}int ogg_stream_reset(ogg_stream_state *os){ os->body_fill=0; os->body_returned=0; os->lacing_fill=0; os->lacing_packet=0; os->lacing_returned=0; os->header_fill=0; os->e_o_s=0; os->b_o_s=0; os->pageno=-1; os->packetno=0; os->granulepos=0; return(0);}int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno){ ogg_stream_reset(os); os->serialno=serialno; return(0);}static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){ /* The last part of decode. We have the stream broken into packet segments. Now we need to group them into packets (or return the out of sync markers) */ int ptr=os->lacing_returned; if(os->lacing_packet<=ptr)return(0); if(os->lacing_vals[ptr]&0x400){ /* we need to tell the codec there's a gap; it might need to handle previous packet dependencies. */ os->lacing_returned++; os->packetno++; return(-1); } if(!op && !adv)return(1); /* just using peek as an inexpensive way to ask if there's a whole packet waiting */ /* Gather the whole packet. We'll have no holes or a partial packet */ { int size=os->lacing_vals[ptr]&0xff; int bytes=size; int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */ int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */ while(size==255){ int val=os->lacing_vals[++ptr]; size=val&0xff; if(val&0x200)eos=0x200; bytes+=size; } if(op){ op->e_o_s=eos; op->b_o_s=bos; op->packet=os->body_data+os->body_returned; op->packetno=os->packetno; op->granulepos=os->granule_vals[ptr]; op->bytes=bytes; } if(adv){ os->body_returned+=bytes; os->lacing_returned=ptr+1; os->packetno++; } } return(1);}int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){ return _packetout(os,op,1);}int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){ return _packetout(os,op,0);}void ogg_packet_clear(ogg_packet *op) { _ogg_free(op->packet); memset(op, 0, sizeof(*op));}#ifdef _V_SELFTEST#include <stdio.h>ogg_stream_state os_en, os_de;ogg_sync_state oy;void error(void){ fprintf(stderr,"error!\n"); exit(1);}/* 17 only */const int head1_0[] = {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};/* 17, 254, 255, 256, 500, 510, 600 byte, pad */const int head1_1[] = {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};const int head2_1[] = {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};/* nil packets; beginning,middle,end */const int head1_2[] = {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};const int head2_2[] = {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};/* large initial packet */const int head1_3[] = {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, 18, 255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,10};const int head2_3[] = {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};/* continuing packet test */const int head1_4[] = {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};const int head2_4[] = {0x4f,0x67,0x67,0x53,0,0x00, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x01,0x02,0x03,0x04,1,0,0,0, 0x54,0x05,0x51,0xc8, 17, 255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255};const int head3_4[] = {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};/* page with the 255 segment limit */const int head1_5[] = {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};const int head2_5[] = {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, 255, 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,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,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,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,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,10,10,10,10,10, 10,10,10,10,10,10,10,10, 10,10,10,10,10,10,10};const int head3_5[] = {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};/* packet that overspans over an entire page */const int head1_6[] = {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};const int head2_6[] = {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, 17, 100,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255};const int head3_6[] = {0x4f,0x67,0x67,0x53,0,0x01, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x01,0x02,0x03,0x04,2,0,0,0, 0x01,0xd2,0xe5,0xe5, 17, 255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255};const int head4_6[] = {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};/* packet that overspans over an entire page */const int head1_7[] = {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};const int head2_7[] = {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, 17, 100,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255};const int head3_7[] = {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};#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -