On Sun, Aug 24, 2008 at 01:56:10AM +0200, Bartlomiej Wolowiec wrote: > Saturday 23 August 2008 03:33:27 Michael Niedermayer napisaĆ(a): > > On Sat, Aug 23, 2008 at 12:31:48AM +0200, Bartlomiej Wolowiec wrote: > > > In nellymoserenc.c is a duplicate of bitstream writer code from > > > vorbis_enc.c. How should I remove this duplicate? Add to bitstream.h this > > > code and make activation by BITSTREAM_WRITER_LE available? > > > > The put_bits code in vorbis_enc.c is extreemly poorly written and it > > needs be cleaned up before it can be used by another encoder. > > Actually i wonder how this code managed to get into svn ... > > > > [...] > > I tried to wrote patch to bitstream.h. I hope that it's better than previous > code. > > -- > Bartlomiej Wolowiec
> Index: bitstream.h
> ===================================================================
> --- bitstream.h (wersja 14909)
> +++ bitstream.h (kopia robocza)
> @@ -123,6 +123,7 @@
> #ifdef ALT_BITSTREAM_WRITER
> align_put_bits(s);
> #else
> +#ifndef BITSTREAM_WRITER_LE
> s->bit_buf<<= s->bit_left;
> while (s->bit_left < 32) {
> /* XXX: should test end of buffer */
> @@ -130,6 +131,14 @@
> s->bit_buf<<=8;
> s->bit_left+=8;
> }
> +#else
> + while (s->bit_left < 32) {
> + /* XXX: should test end of buffer */
> + *s->buf_ptr++=s->bit_buf;
> + s->bit_buf>>=8;
> + s->bit_left+=8;
> + }
> +#endif
theres some common code between if and else
> s->bit_left=32;
> s->bit_buf=0;
> #endif
> @@ -190,6 +199,7 @@
>
> // printf("n=%d value=%x cnt=%d buf=%x\n", n, value, bit_cnt,
> bit_buf);
> /* XXX: optimize */
> +#ifndef BITSTREAM_WRITER_LE
> if (n < bit_left) {
> bit_buf = (bit_buf<<n) | value;
> bit_left-=n;
> @@ -210,7 +220,27 @@
> bit_left+=32 - n;
> bit_buf = value;
> }
> +#else // BITSTREAM_WRITER_LE
> + bit_buf |= value << (32 - bit_left);
> + if (n >= bit_left) {
> +#ifdef UNALIGNED_STORES_ARE_BAD
> + if (3 & (intptr_t) s->buf_ptr) {
> + s->buf_ptr[0] = bit_buf;
> + s->buf_ptr[1] = bit_buf >> 8;
> + s->buf_ptr[2] = bit_buf >> 16;
> + s->buf_ptr[3] = bit_buf >> 24;
> + } else
> +#endif
> + *(uint32_t *)s->buf_ptr = le2me_32(bit_buf);
> + s->buf_ptr+=4;
>
> + //FIXME: value>>32 == value... ?!
value>>32 == undefined
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The educated differ from the uneducated as much as the living from the
dead. -- Aristotle
signature.asc
Description: Digital signature
_______________________________________________ FFmpeg-soc mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc
