comparison mpeg12.c @ 1988:b5753525f9a8 libavcodec

remove duplicated find_frame_end() code move codec specific code from parser.c -> <codecname>.c as far as its easily possible
author michael
date Thu, 29 Apr 2004 14:21:33 +0000
parents c8e866f4515f
children 11991f81afd6
comparison
equal deleted inserted replaced
1987:d9e067853051 1988:b5753525f9a8
2713 } 2713 }
2714 /** 2714 /**
2715 * finds the end of the current frame in the bitstream. 2715 * finds the end of the current frame in the bitstream.
2716 * @return the position of the first byte of the next frame, or -1 2716 * @return the position of the first byte of the next frame, or -1
2717 */ 2717 */
2718 static int mpeg1_find_frame_end(MpegEncContext *s, uint8_t *buf, int buf_size){ 2718 int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
2719 ParseContext *pc= &s->parse_context; 2719 {
2720 int i; 2720 int i;
2721 uint32_t state; 2721 uint32_t state;
2722 2722
2723 state= pc->state; 2723 state= pc->state;
2724 2724
2733 } 2733 }
2734 } 2734 }
2735 } 2735 }
2736 2736
2737 if(pc->frame_start_found){ 2737 if(pc->frame_start_found){
2738 /* EOF considered as end of frame */
2739 if (buf_size == 0)
2740 return 0;
2738 for(; i<buf_size; i++){ 2741 for(; i<buf_size; i++){
2739 state= (state<<8) | buf[i]; 2742 state= (state<<8) | buf[i];
2740 if((state&0xFFFFFF00) == 0x100){ 2743 if((state&0xFFFFFF00) == 0x100){
2741 if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){ 2744 if(state < SLICE_MIN_START_CODE || state > SLICE_MAX_START_CODE){
2742 pc->frame_start_found=0; 2745 pc->frame_start_found=0;
2773 *data_size = sizeof(AVFrame); 2776 *data_size = sizeof(AVFrame);
2774 return 0; 2777 return 0;
2775 } 2778 }
2776 2779
2777 if(s2->flags&CODEC_FLAG_TRUNCATED){ 2780 if(s2->flags&CODEC_FLAG_TRUNCATED){
2778 int next= mpeg1_find_frame_end(s2, buf, buf_size); 2781 int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size);
2779 2782
2780 if( ff_combine_frame(s2, next, &buf, &buf_size) < 0 ) 2783 if( ff_combine_frame(&s2->parse_context, next, &buf, &buf_size) < 0 )
2781 return buf_size; 2784 return buf_size;
2782 } 2785 }
2783 2786
2784 buf_ptr = buf; 2787 buf_ptr = buf;
2785 buf_end = buf + buf_size; 2788 buf_end = buf + buf_size;