[Matroska-devel] Haali Coreparser and Ogg Vorbis file

Attractionland - Jeremy Cardon webmaster at attractionland.com
Sun Jul 30 13:18:06 CEST 2006


Hello everybody,
I'm new to the list,

I'm trying as an exercise to retrieve mp3 and vorbis datas from a mkv file,
for the mp3 everything is working ok, but for vorbis
I don't really know how to get the three vorbis headers sizes easily

here is my code, I don't have any problem at compile time, but my graph 
can't connect,
this code is inspired from the matroska directshow filter,

this is part of the GetMediaType method

BYTE *codecPrivate = (unsigned char*)trackinf->CodecPrivate;
VORBISFORMAT2* pvf2 = 
(VORBISFORMAT2*)m_mt.AllocFormatBuffer(sizeof(VORBISFORMAT2) + 
tinf->CodecPrivateSize - 3);
            memcpy((BYTE *)pvf2+sizeof(VORBISFORMAT2),codecPrivate+3, 
trackinf->CodecPrivateSize-3);
            unsigned int lastHeaderSize = trackinf->CodecPrivateSize-1;
            unsigned int nbHeaders = 2;//*((unsigned int *)codecPrivate);
            codecPrivate++;           
            // 3 headers for vorbis
                FILE* f;
            f=fopen("salutaudio.txt","w");
            fprintf(f,"salut %i",nbHeaders);
            fclose(f);
            while(nbHeaders)
            {
                unsigned int currentHeaderSize = 0;
                do{
                    currentHeaderSize += *(unsigned int *)codecPrivate;
                    lastHeaderSize--;
                } while((*codecPrivate++) == 0xFF);
                lastHeaderSize -= currentHeaderSize;
                pvf2->HeaderSize[2-nbHeaders] = currentHeaderSize;
                nbHeaders--;
            }       
       
            //pvf2->HeaderSize[0] = trackinf->CodecPrivate;
            //pvf2->HeaderSize[1] = trackinf->CodecPrivate;
            //pvf2->HeaderSize[2] = trackinf->CodecPrivateSize-1;
            pvf2->HeaderSize[2-nbHeaders] = lastHeaderSize;
            pvf2->Channels = trackinf->AV.Audio.Channels;
            pvf2->SamplesPerSec = trackinf->AV.Audio.SamplingFreq;
            pvf2->BitsPerSample = trackinf->AV.Audio.BitDepth;           
            m_mt.SetSampleSize(1);

Many thanks for your help




More information about the Matroska-devel mailing list