diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2007-07-06 14:13:25 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2007-07-06 14:13:25 +0000 |
commit | 98f7b56bb6562db841219a42ea4e15d43a835c93 (patch) | |
tree | 610fa0bffb5ad5a5ede46e21b6b6c3d883f62489 | |
parent | 3662aa766f8ca086d8a23a9372d51706c86c2ec7 (diff) | |
download | ffmpeg-98f7b56bb6562db841219a42ea4e15d43a835c93.tar.gz |
move ff_copy_bits to bitstream.c
Originally committed as revision 9503 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/bitstream.c | 24 | ||||
-rw-r--r-- | libavcodec/bitstream.h | 1 | ||||
-rw-r--r-- | libavcodec/mpegvideo.h | 1 | ||||
-rw-r--r-- | libavcodec/mpegvideo_enc.c | 24 |
4 files changed, 25 insertions, 25 deletions
diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 8e5d15aceb..79a3f6c2f1 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -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 diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h index dcaba8ab2c..fd1b4a94f8 100644 --- a/libavcodec/bitstream.h +++ b/libavcodec/bitstream.h @@ -137,6 +137,7 @@ static inline void flush_put_bits(PutBitContext *s) void align_put_bits(PutBitContext *s); void ff_put_string(PutBitContext * pbc, char *s, int put_zero); +void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length); /* bit input */ /* buffer, buffer_end and size_in_bits must be present and used by every reader */ diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index f7a87a3432..7935a71441 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -717,7 +717,6 @@ void MPV_common_init_armv4l(MpegEncContext *s); void MPV_common_init_ppc(MpegEncContext *s); #endif extern void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w); -void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length); void ff_clean_intra_table_entries(MpegEncContext *s); void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable); void ff_draw_horiz_band(MpegEncContext *s, int y, int h); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 2ac8a6fc68..4f933a6997 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1734,30 +1734,6 @@ static av_always_inline void encode_mb(MpegEncContext *s, int motion_x, int moti else encode_mb_internal(s, motion_x, motion_y, 16, 8); } -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)); -} - static inline void copy_context_before_encode(MpegEncContext *d, MpegEncContext *s, int type){ int i; |