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

◆ plm_audio_decode_frame()

void fl::third_party::plm_audio_decode_frame ( plm_audio_t * self)

Definition at line 3424 of file pl_mpeg.hpp.

3424 {
3425 // Prepare the quantizer table lookups
3426 int tab3 = 0;
3427 int sblimit = 0;
3428
3429 int tab1 = (self->mode == PLM_AUDIO_MODE_MONO) ? 0 : 1;
3430 int tab2 = PLM_AUDIO_QUANT_LUT_STEP_1[tab1][self->bitrate_index];
3431 tab3 = QUANT_LUT_STEP_2[tab2][self->samplerate_index];
3432 sblimit = tab3 & 63;
3433 tab3 >>= 6;
3434
3435 if (self->bound > sblimit) {
3436 self->bound = sblimit;
3437 }
3438
3439 // Read the allocation information
3440 for (int sb = 0; sb < self->bound; sb++) {
3441 self->allocation[0][sb] = plm_audio_read_allocation(self, sb, tab3);
3442 self->allocation[1][sb] = plm_audio_read_allocation(self, sb, tab3);
3443 }
3444
3445 for (int sb = self->bound; sb < sblimit; sb++) {
3446 self->allocation[0][sb] =
3447 self->allocation[1][sb] =
3448 plm_audio_read_allocation(self, sb, tab3);
3449 }
3450
3451 // Read scale factor selector information
3452 int channels = (self->mode == PLM_AUDIO_MODE_MONO) ? 1 : 2;
3453 for (int sb = 0; sb < sblimit; sb++) {
3454 for (int ch = 0; ch < channels; ch++) {
3455 if (self->allocation[ch][sb]) {
3456 self->scale_factor_info[ch][sb] = plm_buffer_read(self->buffer, 2);
3457 }
3458 }
3459 if (self->mode == PLM_AUDIO_MODE_MONO) {
3460 self->scale_factor_info[1][sb] = self->scale_factor_info[0][sb];
3461 }
3462 }
3463
3464 // Read scale factors
3465 for (int sb = 0; sb < sblimit; sb++) {
3466 for (int ch = 0; ch < channels; ch++) {
3467 if (self->allocation[ch][sb]) {
3468 int *sf = self->scale_factor[ch][sb];
3469 switch (self->scale_factor_info[ch][sb]) {
3470 case 0:
3471 sf[0] = plm_buffer_read(self->buffer, 6);
3472 sf[1] = plm_buffer_read(self->buffer, 6);
3473 sf[2] = plm_buffer_read(self->buffer, 6);
3474 break;
3475 case 1:
3476 sf[0] =
3477 sf[1] = plm_buffer_read(self->buffer, 6);
3478 sf[2] = plm_buffer_read(self->buffer, 6);
3479 break;
3480 case 2:
3481 sf[0] =
3482 sf[1] =
3483 sf[2] = plm_buffer_read(self->buffer, 6);
3484 break;
3485 case 3:
3486 sf[0] = plm_buffer_read(self->buffer, 6);
3487 sf[1] =
3488 sf[2] = plm_buffer_read(self->buffer, 6);
3489 break;
3490 }
3491 }
3492 }
3493 if (self->mode == PLM_AUDIO_MODE_MONO) {
3494 self->scale_factor[1][sb][0] = self->scale_factor[0][sb][0];
3495 self->scale_factor[1][sb][1] = self->scale_factor[0][sb][1];
3496 self->scale_factor[1][sb][2] = self->scale_factor[0][sb][2];
3497 }
3498 }
3499
3500 // Coefficient input and reconstruction
3501 int out_pos = 0;
3502 for (int part = 0; part < 3; part++) {
3503 for (int granule = 0; granule < 4; granule++) {
3504
3505 // Read the samples
3506 for (int sb = 0; sb < self->bound; sb++) {
3507 plm_audio_read_samples(self, 0, sb, part);
3508 plm_audio_read_samples(self, 1, sb, part);
3509 }
3510 for (int sb = self->bound; sb < sblimit; sb++) {
3511 plm_audio_read_samples(self, 0, sb, part);
3512 self->sample[1][sb][0] = self->sample[0][sb][0];
3513 self->sample[1][sb][1] = self->sample[0][sb][1];
3514 self->sample[1][sb][2] = self->sample[0][sb][2];
3515 }
3516 for (int sb = sblimit; sb < 32; sb++) {
3517 self->sample[0][sb][0] = 0;
3518 self->sample[0][sb][1] = 0;
3519 self->sample[0][sb][2] = 0;
3520 self->sample[1][sb][0] = 0;
3521 self->sample[1][sb][1] = 0;
3522 self->sample[1][sb][2] = 0;
3523 }
3524
3525 // Synthesis loop
3526 for (int p = 0; p < 3; p++) {
3527 // Shifting step
3528 self->v_pos = (self->v_pos - 64) & 1023;
3529
3530 for (int ch = 0; ch < 2; ch++) {
3531 plm_audio_idct36(self->sample[ch], p, self->V[ch], self->v_pos);
3532
3533 // Build U, windowing, calculate output
3534 fl::memset(self->U, 0, sizeof(self->U));
3535
3536 int d_index = 512 - (self->v_pos >> 1);
3537 int v_index = (self->v_pos % 128) >> 1;
3538 while (v_index < 1024) {
3539 for (int i = 0; i < 32; ++i) {
3540 self->U[i] += self->D[d_index++] * self->V[ch][v_index++];
3541 }
3542
3543 v_index += 128 - 32;
3544 d_index += 64 - 32;
3545 }
3546
3547 d_index -= (512 - 32);
3548 v_index = (128 - 32 + 1024) - v_index;
3549 while (v_index < 1024) {
3550 for (int i = 0; i < 32; ++i) {
3551 self->U[i] += self->D[d_index++] * self->V[ch][v_index++];
3552 }
3553
3554 v_index += 128 - 32;
3555 d_index += 64 - 32;
3556 }
3557
3558 // Output samples
3559 #ifdef PLM_AUDIO_SEPARATE_CHANNELS
3560 float *out_channel = ch == 0
3561 ? self->samples.left
3562 : self->samples.right;
3563 for (int j = 0; j < 32; j++) {
3564 out_channel[out_pos + j] = self->U[j] / -1090519040.0f;
3565 }
3566 #else
3567 for (int j = 0; j < 32; j++) {
3568 self->samples.interleaved[((out_pos + j) << 1) + ch] =
3569 self->U[j] / -1090519040.0f;
3570 }
3571 #endif
3572 } // End of synthesis channel loop
3573 out_pos += 32;
3574 } // End of synthesis sub-block loop
3575
3576 } // Decoding of the granule finished
3577 }
3578
3579 plm_buffer_align(self->buffer);
3580}
void plm_audio_idct36(int s[32][3], int ss, float *d, int dp) FL_NOEXCEPT
Definition pl_mpeg.hpp:3640
int plm_buffer_read(plm_buffer_t *self, int count) FL_NOEXCEPT
Definition pl_mpeg.hpp:1017
static const int PLM_AUDIO_MODE_MONO
Definition pl_mpeg.hpp:3015
static const uint8_t QUANT_LUT_STEP_2[3][3]
Definition pl_mpeg.hpp:3134
void plm_audio_read_samples(plm_audio_t *self, int ch, int sb, int part) FL_NOEXCEPT
Definition pl_mpeg.hpp:3588
void plm_buffer_align(plm_buffer_t *self) FL_NOEXCEPT
Definition pl_mpeg.hpp:1040
const plm_quantizer_spec_t * plm_audio_read_allocation(plm_audio_t *self, int sb, int tab3) FL_NOEXCEPT
Definition pl_mpeg.hpp:3582
static const uint8_t PLM_AUDIO_QUANT_LUT_STEP_1[2][16]
Definition pl_mpeg.hpp:3121
float interleaved[PLM_AUDIO_SAMPLES_PER_FRAME *2]
Definition pl_mpeg.h:232
const plm_quantizer_spec_t * allocation[2][32]
Definition pl_mpeg.hpp:3217
uint8_t scale_factor_info[2][32]
Definition pl_mpeg.hpp:3218
void * memset(void *s, int c, size_t n) FL_NOEXCEPT

References FL_NOEXCEPT, fl::memset(), plm_audio_idct36(), PLM_AUDIO_MODE_MONO, PLM_AUDIO_QUANT_LUT_STEP_1, plm_audio_read_allocation(), plm_audio_read_samples(), plm_buffer_align(), plm_buffer_read(), and QUANT_LUT_STEP_2.

Referenced by plm_audio_decode().

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