[vorbis-dev] Small vorbis files with vorbisfile
Michael Smith
msmith at labyrinth.net.au
Fri Nov 23 01:37:20 PST 2001
> int StartOffset =
>ov_pcm_tell(&m_pDecoder->VorbisFile);
>
> if (StartOffset<0)
> Error("Decode","Offset error");
>
> // uninterleave samples
> ret = ov_read(&m_pDecoder->VorbisFile,(char
>*)_pData,_nBytes,0,2,1,&m_pDecoder->Section);
>
> int EndOffset =
>ov_pcm_tell(&m_pDecoder->VorbisFile);
> if (EndOffset<0)
> Error("Decode","Offset error");
>
> if (EndOffset == StartOffset)
> ++NumTimesNoData;
> else
> NumTimesNoData = 0;
>
> _nBytes -= EndOffset - StartOffset;
> pData += EndOffset - StartOffset;
And finally (I didn't actually read the code before, this was silly of me)
this code appears to be spectacularly wrong. Your ov_pcm_tell() calls are
irrelevent and misleading, and you then advance the data pointer by the
wrong amount anyway.
You should be doing:
ret = ov_read(...)
if(ret < 0 ) {
deal with error somehow...
}
else if (ret == 0) {
EOF, do whatever you want here
}
else {
_nBytes -= ret;
pData += bytes;
}
Michael
--- >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