[Ffmpeg-devel] Reading bit-reversed VLC codes
Michael Niedermayer
michaelni
Sun Mar 18 21:59:35 CET 2007
Hi
On Sun, Mar 18, 2007 at 08:54:13PM +0000, M?ns Rullg?rd wrote:
> Michael Niedermayer <michaelni at gmx.at> writes:
>
> > Hi
> >
> > On Sun, Mar 18, 2007 at 09:38:10PM +0100, Michael Niedermayer wrote:
> >> Hi
> >>
> >> On Sun, Mar 18, 2007 at 08:33:31PM +0000, M?ns Rullg?rd wrote:
> >> > Michael Niedermayer <michaelni at gmx.at> writes:
> >> >
> >> > > Hi
> >> > >
> >> > > On Sun, Mar 18, 2007 at 08:10:59PM +0000, M?ns Rullg?rd wrote:
> >> > >> Michael Niedermayer <michaelni at gmx.at> writes:
> >> > >>
> >> > >> > Hi
> >> > >> >
> >> > >> > On Sun, Mar 18, 2007 at 07:27:43PM +0000, M?ns Rullg?rd wrote:
> >> > >> >> Michael Niedermayer <michaelni at gmx.at> writes:
> >> > >> >>
> >> > >> >> > Hi
> >> > >> >> >
> >> > >> >> > On Sun, Mar 18, 2007 at 07:13:30PM +0000, M?ns Rullg?rd wrote:
> >> > >> >> >> I need to read VLC codes that are stored in reverse order in the
> >> > >> >> >> bitstream, i.e. a 4-bit code value of 5 is returned by get_bits as
> >> > >> >> >> 0xa. Is there some way to do this using the lavc VLC reader?
> >> > >> >> >
> >> > >> >> > for get bits the code in asv1.c
> >> > >> >> > static inline int asv2_get_bits(GetBitContext *gb, int n){
> >> > >> >> > return ff_reverse[ get_bits(gb, n) << (8-n) ];
> >> > >> >> > }
> >> > >> >>
> >> > >> >> Non-VLC elements are stored the right way around, so I don't need to
> >> > >> >> do anything special with those.
> >> > >> >>
> >> > >> >> > might do what you want, for get_vlc() just change the table
> >> > >> >> > before init_vlc()
> >> > >> >>
> >> > >> >> I tried reversing the bits of each code before init_vlc(), but that
> >> > >> >> only gives me an "incorrect codes" message and an error return. I
> >> > >> >> guess I did something wrong, but I'm at a loss figuring out what.
> >> > >> >
> >> > >> > well, you cannot just reverse a vlc like that, maybe you
> >> > >> > could elaborate on what exactly you are trying to do (link
> >> > >> > to codec spec?)
> >> > >>
> >> > >> I'm trying to write a zlib decoder. The spec is RFC1951.
> >> > >>
> >> > >> > i thought that you wanted to reverse the output of get_vlc() not the
> >> > >> > bits of the vlc codes as stored in the bitstream later wont work in
> >> > >> > general example:
> >> > >>
> >> > >> [...]
> >> > >>
> >> > >> > init_vlc/get_vlc() doesnt support such non prefix codes (for obvious
> >> > >> > reasons)
> >> > >>
> >> > >> No, of course it doesn't. Do you have any suggestion how to solve
> >> > >> this?
> >> > >
> >> > > now without reading the RFC (will do so in a moment) are you sure the
> >> > > vlc is reversed instead of each byte being reversed?
> >> >
> >> > It's stored in such a way that if I get_bits() the right number of
> >> > bits for a code, I get the bits reversed compared to the code value
> >> > I'm expecting.
> >> >
> >> > Here's what the spec has to say:
> >> >
> >> > * Data elements are packed into bytes in order of
> >> > increasing bit number within the byte, i.e., starting
> >> > with the least-significant bit of the byte.
> >>
> >> try a
> >> #define ALT_BITSTREAM_READER_LE
> >> before the #incldues
> >
> > and pass INIT_VLC_LE to init_vlc()
>
> Segmentation fault.
gdb?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- 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/20070318/4600029c/attachment.pgp>
More information about the ffmpeg-devel
mailing list