[Matroska-devel] haali and vorbis

Mike Matsnev mike at po.cs.msu.su
Mon Jul 31 10:13:43 CEST 2006


On Sun, Jul 30, 2006 at 04:43:07PM +0200, Attractionland - Jeremy Cardon wrote:
> 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);
This is wrong. You need to skip the encoded length bytes, their number is
variable and usually more than 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
> 
> _______________________________________________
> Matroska-devel mailing list
> Matroska-devel at lists.matroska.org
> http://lists.matroska.org/cgi-bin/mailman/listinfo/matroska-devel
> Read Matroska-Devel on GMane: 
> http://dir.gmane.org/gmane.comp.multimedia.matroska.devel
> 



More information about the Matroska-devel mailing list