comparison mpegvideo.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 1d5abf80fa41
children be2386b2f201
comparison
equal deleted inserted replaced
1987:d9e067853051 1988:b5753525f9a8
3695 assert(0); 3695 assert(0);
3696 } 3696 }
3697 } 3697 }
3698 3698
3699 #endif //CONFIG_ENCODERS 3699 #endif //CONFIG_ENCODERS
3700
3701 /**
3702 * combines the (truncated) bitstream to a complete frame
3703 * @returns -1 if no complete frame could be created
3704 */
3705 int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size){
3706 ParseContext *pc= &s->parse_context;
3707
3708 #if 0
3709 if(pc->overread){
3710 printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
3711 printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
3712 }
3713 #endif
3714
3715 /* copy overreaded byes from last frame into buffer */
3716 for(; pc->overread>0; pc->overread--){
3717 pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
3718 }
3719
3720 pc->last_index= pc->index;
3721
3722 /* copy into buffer end return */
3723 if(next == END_NOT_FOUND){
3724 pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
3725
3726 memcpy(&pc->buffer[pc->index], *buf, *buf_size);
3727 pc->index += *buf_size;
3728 return -1;
3729 }
3730
3731 *buf_size=
3732 pc->overread_index= pc->index + next;
3733
3734 /* append to buffer */
3735 if(pc->index){
3736 pc->buffer= av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
3737
3738 memcpy(&pc->buffer[pc->index], *buf, next + FF_INPUT_BUFFER_PADDING_SIZE );
3739 pc->index = 0;
3740 *buf= pc->buffer;
3741 }
3742
3743 /* store overread bytes */
3744 for(;next < 0; next++){
3745 pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];
3746 pc->overread++;
3747 }
3748
3749 #if 0
3750 if(pc->overread){
3751 printf("overread %d, state:%X next:%d index:%d o_index:%d\n", pc->overread, pc->state, next, pc->index, pc->overread_index);
3752 printf("%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
3753 }
3754 #endif
3755
3756 return 0;
3757 }
3758 3700
3759 void ff_mpeg_flush(AVCodecContext *avctx){ 3701 void ff_mpeg_flush(AVCodecContext *avctx){
3760 int i; 3702 int i;
3761 MpegEncContext *s = avctx->priv_data; 3703 MpegEncContext *s = avctx->priv_data;
3762 3704