[vorbis-dev] Trouble decoding number of codebooks

ots1 at cs.waikato.ac.nz ots1 at cs.waikato.ac.nz
Fri Jun 13 16:36:32 PDT 2003



I'm having trouble decoding the number of codebooks out of an ogg file,
and was wondering if anyone here could lend a hand?

I read in the sync pattern, and I think the codebook dimensions properly,
but when I try and read in the number of codebook entries, I get a number
larger than the number of bytes in the file, which I have to assume is
wrong :)

Anyway this is how I read in the numbers :

void readCodeBooks(ifstream *file, int codebookCount)
{
  //read in the 24 bit sync pattern
  unsigned char *c = readBytes(file, 3);

  //read the codebook dimensions
  unsigned char *dimensions = readBytes(file,2);
  int codebookDimensions = (int)convertArray2(dimensions, 2);

  //read codebook entries
  unsigned char *entries = readBytes(file,3);
  long codebookEntries = convertArray2(entries,3);
}

long convertArray2(unsigned char *array, int size)
{
  //reverse the array
  unsigned char revArray[size];
  for(int i = size - 1; i >= 0; i--)
    revArray[(size-1) - i] = array[i];

  //return a pointer to a long
  long *result = (long *)revArray;
  return *result;
}

The results that I get from the code are :

 Sync Pattern (starting byte #269) : 42 43 56   (outputed as integers)
 Codebook dimensions (starting byte #272) : 256
 Codebook entries (starting byte #274) : 4194304

Cheers for the help,

Oliver Sneyd
ots1 at cs.waikato.ac.nz

<p><p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis-dev mailing list