[FFmpeg-devel] [PATCH] move some bitstream related functions
Michael Niedermayer
michaelni
Thu Jul 5 15:04:19 CEST 2007
Hi
On Thu, Jul 05, 2007 at 12:08:50PM +0200, Aurelien Jacobs wrote:
> Hi,
>
> The attached patch moves some bitstream related functions from mpegvideo_enc.c
> to bitstream.c. Those functions are used by other encoders which don't
> depend on mpegvideo_enc.c otherwise (such as svq1.c and h263.c).
> So moving them will then allows me to ensure mpegvideo_enc.c is compiled
> only when necessary (and not as soon as any encoder is enabled).
>
> Is it ok ?
[...]
> Index: libavcodec/bitstream.c
> ===================================================================
> --- libavcodec/bitstream.c (r??vision 9467)
> +++ libavcodec/bitstream.c (copie de travail)
> @@ -29,6 +29,7 @@
>
> #include "avcodec.h"
> #include "bitstream.h"
> +#include "dsputil.h"
ugly
>
> /**
> * Same as av_mallocz_static(), but does a realloc.
> @@ -60,6 +61,42 @@
> 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));
> +}
can be simplified
> +
> +void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix){
> + int i;
> +
> + if(matrix){
> + put_bits(pb, 1, 1);
> + for(i=0;i<64;i++) {
> + put_bits(pb, 8, matrix[ ff_zigzag_direct[i] ]);
> + }
> + }else
> + put_bits(pb, 1, 0);
> +}
> +
> /* VLC decoding */
doesnt belong in bitstream.* at all
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070705/0c9cae56/attachment.pgp>
More information about the ffmpeg-devel
mailing list