[Vorbis] Destination buffer is always empty when calling acmstreamconvert() for converting OGG to PCM format using vorbis.acm

sujitha sujitha.ramamoorthy at aspiresys.com
Fri Jul 8 05:38:24 PDT 2011


 

Hi,

 

  I tried to encode from PCM format to OGG format using vorbis.acm. It was
working fine. Whereas when trying to convert from OGG to PCM format, call to
acmstreamconvert() returns success but the destination buffer is always
empty . I used the 0.0.3.6 version of vorbis.acm.

 

Here is the code I am using for conversion.

 

        DWORD maxFormatSize = 0;

        mmr = acmMetrics( NULL, ACM_METRIC_MAX_SIZE_FORMAT, &maxFormatSize
);

      

         // define  input format

        LPWAVEFORMATEX waveFormat = (LPWAVEFORMATEX) LocalAlloc( LPTR,
maxFormatSize +sizeof( LPWAVEFORMATEX) );

        waveFormat->wFormatTag = WAVE_FORMAT_PCM;

        waveFormat->nChannels =2;

        waveFormat->nSamplesPerSec = 22050;

        waveFormat->wBitsPerSample = 16;

        waveFormat->nBlockAlign =2*16/8; 

        waveFormat->nAvgBytesPerSec = 22050*4 ;

        waveFormat->cbSize =0;

 

 

        LPWAVEFORMATEX oggFormat = (LPWAVEFORMATEX) LocalAlloc( LPTR,
maxFormatSize );

        oggFormat->wFormatTag =WAVE_FORMAT_VORBIS2;

        oggFormat->nChannels = 2; 

        oggFormat->nSamplesPerSec = 22050; 

        oggFormat->wBitsPerSample = 16; 

        oggFormat->nBlockAlign =0; 

        oggFormat->nAvgBytesPerSec =4; 

        oggFormat->cbSize =32776; 

 

        g_wavstream = NULL;

        mmr = acmStreamOpen( &g_wavstream,               // open an ACM
conversion stream

                         driver,                       // querying all ACM
drivers

                         oggFormat, // converting from MP3

                        /*(LPWAVEFORMATEX)*/ waveFormat  ,
// to WAV

                         NULL,                       // with no filter

                         NULL,                          // or async
callbacks

                         0,                          // (and no data for the
callback)

                         0                         // and no flags

                         );

 

 

      LPCWSTR szFileName = DEFAULT_FILE;

      BYTE *pSrcData= new BYTE[2500];

      char *data = new char[2500];

 

      FILE *outf =fopen("E:\\Bomb.ogg","rb+");

      LONG dwSrcBytes = fread(pSrcData,1,2500,outf);

      DWORD dwDst1Bytes = 0;

      mmr = acmStreamSize( g_wavstream, dwSrcBytes, &dwDst1Bytes,
ACM_STREAMSIZEF_SOURCE);

 

        // allocate a buffer for the result of the conversion.

      BYTE* pDst1Data = new BYTE [dwDst1Bytes];

      // fill in the conversion info

      ACMSTREAMHEADER strhdr;

      memset(&strhdr, 0, sizeof(strhdr));

      strhdr.cbStruct = sizeof(strhdr);

      strhdr.pbSrc = pSrcData; // the source data to convert

      strhdr.cbSrcLength = dwSrcBytes;

      strhdr.pbDst = pDst1Data;

      strhdr.cbDstLength = dwDst1Bytes;

 

      // prep the header

      mmr = acmStreamPrepareHeader(g_wavstream, &strhdr, 0); 

 

      // convert the data

      printf("Converting to intermediate PCM format...\n");

      mmr = acmStreamConvert(g_wavstream, &strhdr, 0);

      if (mmr) {

            printf("Failed to do PCM to PCM conversion\n");

            exit(1);

      }

      printf("Converted OK\n");

 

      // close the stream

      acmStreamClose(g_wavstream, 0);

 

What should be the values for nBlockAlign and cbSize of WAVEFORMATEX?  Can I
get any samples for decoding OGG format to PCM format with vorbis.acm?

 

 

Thanks,

Sujitha

 

 



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/vorbis/attachments/20110708/ca31962f/attachment.htm 


More information about the Vorbis mailing list