1 #include "../libzmpeg3.h"
3 int pcm_check(uint8_t *header)
5 if( header[0] == ((zmpeg3_t::PCM_START_CODE >> 24) & 0xff) &&
6 header[1] == ((zmpeg3_t::PCM_START_CODE >> 16) & 0xff) &&
7 header[2] == ((zmpeg3_t::PCM_START_CODE >> 8) & 0xff) &&
8 header[3] == ((zmpeg3_t::PCM_START_CODE >> 0) & 0xff) )
13 int zaudio_decoder_pcm_t::
14 pcm_header(uint8_t *data)
16 if( pcm_check(data) ) return 0;
18 /* Custom header generated by the demuxer */
19 samplerate = *(int32_t*)(data + 4);
20 bits = *(int32_t*)(data + 8);
21 channels = *(int32_t*)(data + 12);
22 framesize = *(int32_t*)(data + 16);
27 int zaudio_decoder_pcm_t::
28 do_pcm(uint8_t *zframe, int zframe_size, float **zoutput, int render)
31 int bytes_per_sample = bits / 8 * channels;
33 (zframe_size - zaudio_t::PCM_HEADERSIZE) / bytes_per_sample;
34 //zmsgs("2 %d\n", zframe_size);
37 for( i=0; i < channels; ++i ) {
39 float *output_channel = zoutput[i];
45 zframe + zaudio_t::PCM_HEADERSIZE + bits / 8 * i;
47 for( j=0; j < output_size; ++j ) {
48 int16_t sample = ((int16_t)(input[0])) << 8;
50 *output_channel = (float)sample / 32767.0;
51 input += bytes_per_sample;
60 //zmsgs("2 %02x%02x%02x%02x\n",
61 // *(uint8_t*)(zframe+zaudio_t::PCM_HEADERSIZE + 0),
62 // *(uint8_t*)(zframe+zaudio_t::PCM_HEADERSIZE + 1),
63 // *(uint8_t*)(zframe+zaudio_t::PCM_HEADERSIZE + 2),
64 // *(uint8_t*)(zframe+zaudio_t::PCM_HEADERSIZE + 3));