support for vorbis and tremor (-DHAS_TREMOR)

This commit is contained in:
badaix 2016-04-10 22:52:02 +02:00
parent ae557f0d79
commit 73175adedf
4 changed files with 21 additions and 6 deletions

View file

@ -19,7 +19,6 @@
#include <iostream>
#include <cstring>
#include <cmath>
//#include <tremor/ivorbisfile.h>
#include "oggDecoder.h"
#include "common/snapException.h"
@ -92,7 +91,11 @@ bool OggDecoder::decode(msg::PcmChunk* chunk)
continue; /* missing or corrupt data at this page position */
/* no reason to complain; already complained above */
/* we have a packet. Decode it */
#ifdef HAS_TREMOR
ogg_int32_t **pcm;
#else
float **pcm;
#endif
int samples;
if (vorbis_synthesis(&vb,&op) == 0) /* test for success! */
@ -113,10 +116,18 @@ bool OggDecoder::decode(msg::PcmChunk* chunk)
for(int i=0; i<vi.channels; i++)
{
ogg_int16_t *ptr=convbuffer+i;
#ifdef HAS_TREMOR
ogg_int32_t *mono=pcm[i];
#else
float *mono=pcm[i];
#endif
for (int j=0; j<bout; j++)
{
ogg_int32_t val = mono[j] >> 9;//floor(mono[j]*32767.f+.5f);
#ifdef HAS_TREMOR
ogg_int32_t val = mono[j] >> 9;
#else
ogg_int32_t val = floor(mono[j]*32767.f+.5f);
#endif
/* might as well guard against clipping */
if(val>32767)
val=32767;