move ff_copy_bits to bitstream.c

Originally committed as revision 9503 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Aurelien Jacobs
2007-07-06 14:13:25 +00:00
parent 3662aa766f
commit 98f7b56bb6
4 changed files with 25 additions and 25 deletions

View File

@@ -60,6 +60,30 @@ void ff_put_string(PutBitContext * pbc, char *s, int put_zero)
put_bits(pbc, 8, 0);
}
void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length)
{
const uint16_t *srcw= (uint16_t*)src;
int words= length>>4;
int bits= length&15;
int i;
if(length==0) return;
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+i, 2*words-i);
skip_put_bytes(pb, 2*words-i);
}
put_bits(pb, bits, be2me_16(srcw[words])>>(16-bits));
}
/* VLC decoding */
//#define DEBUG_VLC