Commit b6335c9f authored by Michael Niedermayer's avatar Michael Niedermayer

ff_copy_bits() optimization

Originally committed as revision 2777 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 842b556a
...@@ -3732,21 +3732,26 @@ void ff_mpeg_flush(AVCodecContext *avctx){ ...@@ -3732,21 +3732,26 @@ void ff_mpeg_flush(AVCodecContext *avctx){
#ifdef CONFIG_ENCODERS #ifdef CONFIG_ENCODERS
void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length) void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length)
{ {
const uint16_t *srcw= src;
int words= length>>4; int words= length>>4;
int bits= length&15; int bits= length&15;
int i; int i;
if(length==0) return; if(length==0) return;
if(put_bits_count(pb)&7){ if(words < 16){
for(i=0; i<words; i++) put_bits(pb, 16, be2me_16(((uint16_t*)src)[i])); 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{ }else{
for(i=0; put_bits_count(pb)&31; i++)
put_bits(pb, 8, src[i]);
flush_put_bits(pb); flush_put_bits(pb);
memcpy(pbBufPtr(pb), src, 2*words); memcpy(pbBufPtr(pb), src+i, 2*words-i);
skip_put_bytes(pb, 2*words); 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){ static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment