[Vorbis-dev] Codebook decoding help

thomas.guettinger at aon.at thomas.guettinger at aon.at
Sun Apr 16 05:42:51 PDT 2006


Dear Sir or Maddam,

we're in the progress of developing a multimedia framework for Java. We started with programming a Vorbis (ogg) codec and demultiplexer and have still some problems with this.

The problem occured when trying to read the setup header of a vorbis file.
After a certain time we have to decode the codebook_lengths but this does not work.

We followed the instructions in the Vorbis 1 specification script (chapter 3 - Codebooks) but we didn't understand, how it works.

So, what we can do is:
- reading the 24 bit sync-pattern (0x564342)
- reading the 16 codebook_dimensions
- reading the 24 codebook_entries

Afterwards the script says: "Next read the ordered bit flag" and so we read the 8th byte containing the ordered bit-flag.

byte 8: [               x] [ordered]

Now the script says: "If the ordered bit is unset do that, if it's set than to that ...".

So we proceeded in programming both cases but in both cases there still occurs a problem: With Java you can't read bits directly from a file so you have to read bytes instead (8 bit).

As an example, the first type (if the ordered bit-flag is unset):

"The decoder first reads one additional bit flag, the [sparse] flag. This flag determines whether or not the codebook contains unused entries that are not to be included in the codeword decode tree:

byte 8: [             X 1 ] [sparse] flag (1 bit)

The decoder now performs for each of the [codebook_entries] codebook entries: 

1) if([sparse] is set){

         2) [flag] = read one bit;
         3) if([flag] is set){

              4) [length] = read a five bit unsigned integer;
              5) codeword length for this entry is [length]+1;

            } else {

              6) this entry is unused.  mark it as such.

            }

     } else the sparse flag is not set {

        7) [length] = read a five bit unsigned integer;
        8) the codeword length for this entry is [length]+1;
        
     }"
<hr>
--> As you can see, byte 8 which normaly contains the ordered bit-flag also contains the sparse bit-flag. 

And so our question is: Would it be possible if you could sent us a short table which shows on an example, how many bytes (8 bit) we have to read and what data these bytes are containing because we haven't any plan how this things with the sparse, ordered and flag bit-flags are working.

Thanks a lot!

Sincerely,
Thomas Guettinger

-------------------------------------------
Versendet durch aonWebmail (webmail.aon.at)


More information about the Vorbis-dev mailing list