comparison mpegvideo.c @ 1803:f100993b9b5a libavcodec

ff_copy_bits() optimization
author michael
date Sat, 14 Feb 2004 01:25:41 +0000
parents e91dbb5b1a8d
children cc0a15943a87
comparison
equal deleted inserted replaced
1802:e91dbb5b1a8d 1803:f100993b9b5a
3730 } 3730 }
3731 3731
3732 #ifdef CONFIG_ENCODERS 3732 #ifdef CONFIG_ENCODERS
3733 void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length) 3733 void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length)
3734 { 3734 {
3735 const uint16_t *srcw= src;
3735 int words= length>>4; 3736 int words= length>>4;
3736 int bits= length&15; 3737 int bits= length&15;
3737 int i; 3738 int i;
3738 3739
3739 if(length==0) return; 3740 if(length==0) return;
3740 3741
3741 if(put_bits_count(pb)&7){ 3742 if(words < 16){
3742 for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(((uint16_t*)src)[i])); 3743 for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(srcw[i]));
3744 }else if(put_bits_count(pb)&7){
3745 for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(srcw[i]));
3743 }else{ 3746 }else{
3747 for(i=0; put_bits_count(pb)&31; i++)
3748 put_bits(pb, 8, src[i]);
3744 flush_put_bits(pb); 3749 flush_put_bits(pb);
3745 memcpy(pbBufPtr(pb), src, 2*words); 3750 memcpy(pbBufPtr(pb), src+i, 2*words-i);
3746 skip_put_bytes(pb, 2*words); 3751 skip_put_bytes(pb, 2*words-i);
3747 } 3752 }
3748 3753
3749 put_bits(pb, bits, be2me_16(((uint16_t*)src)[words])>>(16-bits)); 3754 put_bits(pb, bits, be2me_16(srcw[words])>>(16-bits));
3750 } 3755 }
3751 3756
3752 static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){ 3757 static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){
3753 int i; 3758 int i;
3754 3759