Lines Matching refs:oy
580 void ogg_sync_init(ogg_sync_state *oy){ in ogg_sync_init() argument
581 memset(oy,0,sizeof(*oy)); in ogg_sync_init()
582 oy->bufferpool=ogg_buffer_create(); in ogg_sync_init()
586 ogg_sync_state *oy=_ogg_calloc(1,sizeof(*oy)); in ogg_sync_create() local
587 memset(oy,0,sizeof(*oy)); in ogg_sync_create()
588 oy->bufferpool=ogg_buffer_create(); in ogg_sync_create()
589 return oy; in ogg_sync_create()
592 int ogg_sync_clear(ogg_sync_state *oy){ in ogg_sync_clear() argument
593 if(oy){ in ogg_sync_clear()
594 ogg_sync_reset(oy); in ogg_sync_clear()
595 ogg_buffer_destroy(oy->bufferpool); in ogg_sync_clear()
596 memset(oy,0,sizeof(*oy)); in ogg_sync_clear()
601 int ogg_sync_destroy(ogg_sync_state *oy){ in ogg_sync_destroy() argument
602 if(oy){ in ogg_sync_destroy()
603 ogg_sync_reset(oy); in ogg_sync_destroy()
604 ogg_buffer_destroy(oy->bufferpool); in ogg_sync_destroy()
605 memset(oy,0,sizeof(*oy)); in ogg_sync_destroy()
606 _ogg_free(oy); in ogg_sync_destroy()
611 unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long bytes){ in ogg_sync_bufferin() argument
628 if(!oy->fifo_head){ in ogg_sync_bufferin()
629 oy->fifo_head=oy->fifo_tail=ogg_buffer_alloc(oy->bufferpool,bytes); in ogg_sync_bufferin()
630 return oy->fifo_head->buffer->data; in ogg_sync_bufferin()
634 if(oy->fifo_head->buffer->size- in ogg_sync_bufferin()
635 oy->fifo_head->length- in ogg_sync_bufferin()
636 oy->fifo_head->begin >= bytes) in ogg_sync_bufferin()
637 return oy->fifo_head->buffer->data+ in ogg_sync_bufferin()
638 oy->fifo_head->length+oy->fifo_head->begin; in ogg_sync_bufferin()
641 if(!oy->fifo_head->length){ in ogg_sync_bufferin()
642 ogg_buffer_realloc(oy->fifo_head,bytes); in ogg_sync_bufferin()
643 return oy->fifo_head->buffer->data+oy->fifo_head->begin; in ogg_sync_bufferin()
648 ogg_reference *new=ogg_buffer_alloc(oy->bufferpool,bytes); in ogg_sync_bufferin()
649 oy->fifo_head->next=new; in ogg_sync_bufferin()
650 oy->fifo_head=new; in ogg_sync_bufferin()
652 return oy->fifo_head->buffer->data; in ogg_sync_bufferin()
655 int ogg_sync_wrote(ogg_sync_state *oy, long bytes){ in ogg_sync_wrote() argument
656 if(!oy->fifo_head)return OGG_EINVAL; in ogg_sync_wrote()
657 if(oy->fifo_head->buffer->size-oy->fifo_head->length-oy->fifo_head->begin < in ogg_sync_wrote()
659 oy->fifo_head->length+=bytes; in ogg_sync_wrote()
660 oy->fifo_fill+=bytes; in ogg_sync_wrote()
694 long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){ in ogg_sync_pageseek() argument
700 bytes=oy->fifo_fill; in ogg_sync_pageseek()
701 oggbyte_init(&page,oy->fifo_tail); in ogg_sync_pageseek()
703 if(oy->headerbytes==0){ in ogg_sync_pageseek()
712 oy->headerbytes=oggbyte_read1(&page,26)+27; in ogg_sync_pageseek()
714 if(bytes<oy->headerbytes)goto sync_out; /* not enough for header + in ogg_sync_pageseek()
716 if(oy->bodybytes==0){ in ogg_sync_pageseek()
719 for(i=0;i<oy->headerbytes-27;i++) in ogg_sync_pageseek()
720 oy->bodybytes+=oggbyte_read1(&page,27+i); in ogg_sync_pageseek()
723 if(oy->bodybytes+oy->headerbytes>bytes)goto sync_out; in ogg_sync_pageseek()
732 if(chksum!=_checksum(oy->fifo_tail,oy->bodybytes+oy->headerbytes)){ in ogg_sync_pageseek()
747 og->header=ogg_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->headerbytes); in ogg_sync_pageseek()
748 og->header_len=oy->headerbytes; in ogg_sync_pageseek()
749 og->body=ogg_buffer_split(&oy->fifo_tail,&oy->fifo_head,oy->bodybytes); in ogg_sync_pageseek()
750 og->body_len=oy->bodybytes; in ogg_sync_pageseek()
753 oy->fifo_tail= in ogg_sync_pageseek()
754 ogg_buffer_pretruncate(oy->fifo_tail,oy->headerbytes+oy->bodybytes); in ogg_sync_pageseek()
755 if(!oy->fifo_tail)oy->fifo_head=0; in ogg_sync_pageseek()
758 ret=oy->headerbytes+oy->bodybytes; in ogg_sync_pageseek()
759 oy->unsynced=0; in ogg_sync_pageseek()
760 oy->headerbytes=0; in ogg_sync_pageseek()
761 oy->bodybytes=0; in ogg_sync_pageseek()
762 oy->fifo_fill-=ret; in ogg_sync_pageseek()
768 oy->headerbytes=0; in ogg_sync_pageseek()
769 oy->bodybytes=0; in ogg_sync_pageseek()
770 oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,1); in ogg_sync_pageseek()
774 while(oy->fifo_tail){ in ogg_sync_pageseek()
776 unsigned char *now=oy->fifo_tail->buffer->data+oy->fifo_tail->begin; in ogg_sync_pageseek()
777 unsigned char *next=memchr(now, 'O', oy->fifo_tail->length); in ogg_sync_pageseek()
782 oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,bytes); in ogg_sync_pageseek()
787 long bytes=oy->fifo_tail->length; in ogg_sync_pageseek()
789 oy->fifo_tail=ogg_buffer_pretruncate(oy->fifo_tail,bytes); in ogg_sync_pageseek()
792 if(!oy->fifo_tail)oy->fifo_head=0; in ogg_sync_pageseek()
793 oy->fifo_fill+=ret; in ogg_sync_pageseek()
810 int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){ in ogg_sync_pageout() argument
817 long ret=ogg_sync_pageseek(oy,og); in ogg_sync_pageout()
828 if(!oy->unsynced){ in ogg_sync_pageout()
829 oy->unsynced=1; in ogg_sync_pageout()
839 int ogg_sync_reset(ogg_sync_state *oy){ in ogg_sync_reset() argument
841 ogg_buffer_release(oy->fifo_tail); in ogg_sync_reset()
842 oy->fifo_tail=0; in ogg_sync_reset()
843 oy->fifo_head=0; in ogg_sync_reset()
844 oy->fifo_fill=0; in ogg_sync_reset()
846 oy->unsynced=0; in ogg_sync_reset()
847 oy->headerbytes=0; in ogg_sync_reset()
848 oy->bodybytes=0; in ogg_sync_reset()