Mercurial > libavcodec.hg
diff mpegvideo.c @ 1803:f100993b9b5a libavcodec
ff_copy_bits() optimization
author | michael |
---|---|
date | Sat, 14 Feb 2004 01:25:41 +0000 |
parents | e91dbb5b1a8d |
children | cc0a15943a87 |
line wrap: on
line diff
--- a/mpegvideo.c Fri Feb 13 21:07:31 2004 +0000 +++ b/mpegvideo.c Sat Feb 14 01:25:41 2004 +0000 @@ -3732,21 +3732,26 @@ #ifdef CONFIG_ENCODERS void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length) { + const uint16_t *srcw= src; int words= length>>4; int bits= length&15; int i; if(length==0) return; - if(put_bits_count(pb)&7){ - for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(((uint16_t*)src)[i])); + if(words < 16){ + for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(srcw[i])); + }else if(put_bits_count(pb)&7){ + for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(srcw[i])); }else{ + for(i=0; put_bits_count(pb)&31; i++) + put_bits(pb, 8, src[i]); flush_put_bits(pb); - memcpy(pbBufPtr(pb), src, 2*words); - skip_put_bytes(pb, 2*words); + memcpy(pbBufPtr(pb), src+i, 2*words-i); + skip_put_bytes(pb, 2*words-i); } - put_bits(pb, bits, be2me_16(((uint16_t*)src)[words])>>(16-bits)); + put_bits(pb, bits, be2me_16(srcw[words])>>(16-bits)); } static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){