static int put_output (char *buf, int buf_len, struct mad_pcm *pcm, struct mad_header *header) { unsigned int nsamples; mad_fixed_t const *left_ch, *right_ch; int olen; nsamples = pcm->length; left_ch = pcm->samples[0]; right_ch = pcm->samples[1]; olen = nsamples * MAD_NCHANNELS (header) * 4; if (olen > buf_len) { logit ("PCM buffer to small!"); return 0; } while (nsamples--) { long sample0 = round_sample (*left_ch++); buf[0] = 0; buf[1] = sample0; buf[2] = sample0 >> 8; buf[3] = sample0 >> 16; buf += 4; if (MAD_NCHANNELS(header) == 2) { long sample1; sample1 = round_sample (*right_ch++); buf[0] = 0; buf[1] = sample1; buf[2] = sample1 >> 8; buf[3] = sample1 >> 16; buf += 4; } }
void foo(int *dither_state, int *samples) { int16_t *synth_buf; const int16_t *w, *p; int sum; sum = *dither_state; p = synth_buf + 16; SUM8(sum, +=, w, p); p = synth_buf + 48; SUM8(sum, -=, w + 32, p); *samples = round_sample(&sum); }