[ogg-dev] Skipping of sample in ogg writing
charan
charan.dsouza at creativegenius.co.in
Fri Dec 11 20:23:10 PST 2009
Hi All,
I m having a strange problem with the Ogg-Vorbis writting code. The code
I m using to write is skipping some samples at the end of the file. For
example I m converting the 10000 sample .wav file ( 441000 sample rate ,
16 bit depth , stereo ) to ogg format. But while reading the ogg file I
only find 5824 samples in the ogg file. Can any one suggest what could
be wrong in the code. Is there anything like bug in ogg itself or am I
missing something critical step.
Here is the code for writing the ogg file.
//==============================================================================
bool write (const int** samplesToWrite, int numSamples)
{
if (numSamples > 0)
{
float** const vorbisBuffer = vorbis_analysis_buffer (&vd,
numSamples);
for (int i = numChannels; --i >= 0;)
{
float* const dst = vorbisBuffer[i];
const int* const src = samplesToWrite [i];
if (src != 0 && dst != 0)
{
for (int j = 0; j < numSamples; ++j)
dst[j] = (float) src[j];
}
}
}
vorbis_analysis_wrote (&vd, numSamples);
while (vorbis_analysis_blockout (&vd, &vb) == 1)
{
vorbis_analysis (&vb, 0);
vorbis_bitrate_addblock (&vb);
while (vorbis_bitrate_flushpacket (&vd, &op))
{
ogg_stream_packetin (&os, &op);
for (;;)
{
if (ogg_stream_pageout (&os, &og) == 0)
break;
mywrite (og.header, og.header_len);
mywrite (og.body, og.body_len);
if (ogg_page_eos (&og))
break;
}
}
}
return true;
}
//==============================================================================
Thanks and Regards,
Charan D'Souza
More information about the ogg-dev
mailing list