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

◆ codebook_decode_deinterleave_repeat()

static int32_t fl::third_party::vorbis::codebook_decode_deinterleave_repeat ( vorb * f,
Codebook * c,
float ** outputs,
int32_t ch,
int32_t * c_inter_p,
int32_t * p_inter_p,
int32_t len,
int32_t total_decode )
static

Definition at line 1593 of file stb_vorbis.cpp.hpp.

1594{
1595 int32_t c_inter = *c_inter_p;
1596 int32_t p_inter = *p_inter_p;
1597 int32_t i,z, effective = c->dimensions;
1598
1599 // type 0 is only legal in a scalar context
1600 if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream);
1601
1602 while (total_decode > 0) {
1603 float last = FL_STBV_CODEBOOK_ELEMENT_BASE(c);
1604 FL_STBV_DECODE_VQ(z,f,c);
1605 #ifndef FL_STB_VORBIS_DIVIDES_IN_CODEBOOK
1606 FL_ASSERT(!c->sparse || z < c->sorted_entries, "sparse codebook z must be < sorted_entries");
1607 #endif
1608 if (z < 0) {
1609 if (!f->bytes_in_seg)
1610 if (f->last_seg) return false;
1611 return error(f, VORBIS_invalid_stream);
1612 }
1613
1614 // if this will take us off the end of the buffers, stop short!
1615 // we check by computing the length of the virtual interleaved
1616 // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter),
1617 // and the length we'll be using (effective)
1618 if (c_inter + p_inter*ch + effective > len * ch) {
1619 effective = len*ch - (p_inter*ch - c_inter);
1620 }
1621
1622 #ifdef FL_STB_VORBIS_DIVIDES_IN_CODEBOOK
1623 if (c->lookup_type == 1) {
1624 int32_t div = 1;
1625 for (i=0; i < effective; ++i) {
1626 int32_t off = (z / div) % c->lookup_values;
1627 float val = FL_STBV_CODEBOOK_ELEMENT_FAST(c,off) + last;
1628 if (outputs[c_inter])
1629 outputs[c_inter][p_inter] += val;
1630 if (++c_inter == ch) { c_inter = 0; ++p_inter; }
1631 if (c->sequence_p) last = val;
1632 div *= c->lookup_values;
1633 }
1634 } else
1635 #endif
1636 {
1637 z *= c->dimensions;
1638 if (c->sequence_p) {
1639 for (i=0; i < effective; ++i) {
1640 float val = FL_STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
1641 if (outputs[c_inter])
1642 outputs[c_inter][p_inter] += val;
1643 if (++c_inter == ch) { c_inter = 0; ++p_inter; }
1644 last = val;
1645 }
1646 } else {
1647 for (i=0; i < effective; ++i) {
1648 float val = FL_STBV_CODEBOOK_ELEMENT_FAST(c,z+i) + last;
1649 if (outputs[c_inter])
1650 outputs[c_inter][p_inter] += val;
1651 if (++c_inter == ch) { c_inter = 0; ++p_inter; }
1652 }
1653 }
1654 }
1655
1656 total_decode -= effective;
1657 }
1658 *c_inter_p = c_inter;
1659 *p_inter_p = p_inter;
1660 return true;
1661}
uint32_t z[NUM_LAYERS]
Definition Fire2023.h:93
#define FL_ASSERT(x, MSG)
Definition assert.h:6
static int32_t error(vorb *f, enum STBVorbisError e) FL_NOEXCEPT
fl::i32 int32_t
Definition coder.h:220
fl::i32 int32_t
Definition s16x16x4.h:220
#define FL_STBV_DECODE_VQ(var, f, c)
#define FL_STBV_CODEBOOK_ELEMENT_BASE(c)
#define FL_STBV_CODEBOOK_ELEMENT_FAST(c, off)

References error(), FL_ASSERT, FL_NOEXCEPT, FL_STBV_CODEBOOK_ELEMENT_BASE, FL_STBV_CODEBOOK_ELEMENT_FAST, FL_STBV_DECODE_VQ, VORBIS_invalid_stream, and z.

Referenced by decode_residue().

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