FastLED 3.9.15
Loading...
Searching...
No Matches

◆ plm_audio_read_samples()

void fl::third_party::plm_audio_read_samples ( plm_audio_t * self,
int ch,
int sb,
int part )

Definition at line 3588 of file pl_mpeg.hpp.

3588 {
3589 const plm_quantizer_spec_t *q = self->allocation[ch][sb];
3590 int sf = self->scale_factor[ch][sb][part];
3591 int *sample = self->sample[ch][sb];
3592 int val = 0;
3593
3594 if (!q) {
3595 // No bits allocated for this subband
3596 sample[0] = sample[1] = sample[2] = 0;
3597 return;
3598 }
3599
3600 // Resolve scalefactor
3601 if (sf == 63) {
3602 sf = 0;
3603 }
3604 else {
3605 int shift = (sf / 3) | 0;
3606 sf = (PLM_AUDIO_SCALEFACTOR_BASE[sf % 3] + ((1 << shift) >> 1)) >> shift;
3607 }
3608
3609 // Decode samples
3610 int adj = q->levels;
3611 if (q->group) {
3612 // Decode grouped samples
3613 val = plm_buffer_read(self->buffer, q->bits);
3614 sample[0] = val % adj;
3615 val /= adj;
3616 sample[1] = val % adj;
3617 sample[2] = val / adj;
3618 }
3619 else {
3620 // Decode direct samples
3621 sample[0] = plm_buffer_read(self->buffer, q->bits);
3622 sample[1] = plm_buffer_read(self->buffer, q->bits);
3623 sample[2] = plm_buffer_read(self->buffer, q->bits);
3624 }
3625
3626 // Postmultiply samples
3627 int scale = 65536 / (adj + 1);
3628 adj = ((adj + 1) >> 1) - 1;
3629
3630 val = (adj - sample[0]) * scale;
3631 sample[0] = (val * (sf >> 12) + ((val * (sf & 4095) + 2048) >> 12)) >> 12;
3632
3633 val = (adj - sample[1]) * scale;
3634 sample[1] = (val * (sf >> 12) + ((val * (sf & 4095) + 2048) >> 12)) >> 12;
3635
3636 val = (adj - sample[2]) * scale;
3637 sample[2] = (val * (sf >> 12) + ((val * (sf & 4095) + 2048) >> 12)) >> 12;
3638}
fl::UISlider scale("Scale", 4,.1, 4,.1)
int plm_buffer_read(plm_buffer_t *self, int count) FL_NOEXCEPT
Definition pl_mpeg.hpp:1017
static const int32_t PLM_AUDIO_SCALEFACTOR_BASE[]
Definition pl_mpeg.hpp:3027
const plm_quantizer_spec_t * allocation[2][32]
Definition pl_mpeg.hpp:3217
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode)
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
Definition sample.cpp.hpp:9

References fl::third_party::plm_quantizer_spec_t::bits, FL_NOEXCEPT, fl::third_party::plm_quantizer_spec_t::group, fl::third_party::plm_quantizer_spec_t::levels, PLM_AUDIO_SCALEFACTOR_BASE, plm_buffer_read(), fl::sample(), and scale.

Referenced by plm_audio_decode_frame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: