comparison parser.c @ 3639:949bc256f1e3 libavcodec

dont copy frame if the whole mp1/2/3 frame is available in one piece in the input
author michael
date Sat, 26 Aug 2006 18:56:24 +0000
parents fa0b285144f0
children 1843a85123b7
comparison
equal deleted inserted replaced
3638:62b3b622f798 3639:949bc256f1e3
632 s->free_format_next_header = 0; 632 s->free_format_next_header = 0;
633 goto got_header; 633 goto got_header;
634 } 634 }
635 /* no header seen : find one. We need at least MPA_HEADER_SIZE 635 /* no header seen : find one. We need at least MPA_HEADER_SIZE
636 bytes to parse it */ 636 bytes to parse it */
637 len = MPA_HEADER_SIZE - len; 637 len = FFMIN(MPA_HEADER_SIZE - len, buf_size);
638 if (len > buf_size)
639 len = buf_size;
640 if (len > 0) { 638 if (len > 0) {
641 memcpy(s->inbuf_ptr, buf_ptr, len); 639 memcpy(s->inbuf_ptr, buf_ptr, len);
642 buf_ptr += len; 640 buf_ptr += len;
643 buf_size -= len; 641 buf_size -= len;
644 s->inbuf_ptr += len; 642 s->inbuf_ptr += len;
734 } else 732 } else
735 #endif 733 #endif
736 if (len < s->frame_size) { 734 if (len < s->frame_size) {
737 if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE) 735 if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE)
738 s->frame_size = MPA_MAX_CODED_FRAME_SIZE; 736 s->frame_size = MPA_MAX_CODED_FRAME_SIZE;
739 len = s->frame_size - len; 737 len = FFMIN(s->frame_size - len, buf_size);
740 if (len > buf_size)
741 len = buf_size;
742 memcpy(s->inbuf_ptr, buf_ptr, len); 738 memcpy(s->inbuf_ptr, buf_ptr, len);
743 buf_ptr += len; 739 buf_ptr += len;
744 s->inbuf_ptr += len; 740 s->inbuf_ptr += len;
745 buf_size -= len; 741 buf_size -= len;
746 } 742 }
743
744 if(s->frame_size > 0 && buf_ptr - buf == s->inbuf_ptr - s->inbuf
745 && buf_size + buf_ptr - buf >= s->frame_size){
746 if(s->header_count > 0){
747 *poutbuf = buf;
748 *poutbuf_size = s->frame_size;
749 }
750 buf_ptr = buf + s->frame_size;
751 s->inbuf_ptr = s->inbuf;
752 s->frame_size = 0;
753 break;
754 }
755
747 // next_data: 756 // next_data:
748 if (s->frame_size > 0 && 757 if (s->frame_size > 0 &&
749 (s->inbuf_ptr - s->inbuf) >= s->frame_size) { 758 (s->inbuf_ptr - s->inbuf) >= s->frame_size) {
750 if(s->header_count > 0){ 759 if(s->header_count > 0){
751 *poutbuf = s->inbuf; 760 *poutbuf = s->inbuf;