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

◆ decode_residue()

static void fl::third_party::vorbis::decode_residue ( vorb * f,
float * residue_buffers[],
int32_t ch,
int32_t n,
int32_t rn,
uint8 * do_not_decode )
static

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

1833{
1834 int32_t i,j,pass;
1835 Residue *r = f->residue_config + rn;
1836 int32_t rtype = f->residue_types[rn];
1837 int32_t c = r->classbook;
1838 int32_t classwords = f->codebooks[c].dimensions;
1839 uint32_t actual_size = rtype == 2 ? n*2 : n;
1840 uint32_t limit_r_begin = (r->begin < actual_size ? r->begin : actual_size);
1841 uint32_t limit_r_end = (r->end < actual_size ? r->end : actual_size);
1842 int32_t n_read = limit_r_end - limit_r_begin;
1843 int32_t part_read = n_read / r->part_size;
1844 int32_t fl_stbv_temp_alloc_point = fl_stbv_temp_alloc_save(f);
1845 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
1846 uint8 ***part_classdata = (uint8 ***) fl_stbv_temp_block_array(f,f->channels, part_read * sizeof(**part_classdata));
1847 #else
1848 int32_t**classifications = (int32_t**) fl_stbv_temp_block_array(f,f->channels, part_read * sizeof(**classifications));
1849 #endif
1850
1851 FL_STBV_CHECK(f);
1852
1853 for (i=0; i < ch; ++i)
1854 if (!do_not_decode[i])
1855 memset(residue_buffers[i], 0, sizeof(float) * n);
1856
1857 if (rtype == 2 && ch != 1) {
1858 for (j=0; j < ch; ++j)
1859 if (!do_not_decode[j])
1860 break;
1861 if (j == ch)
1862 goto done;
1863
1864 for (pass=0; pass < 8; ++pass) {
1865 int32_t pcount = 0, class_set = 0;
1866 if (ch == 2) {
1867 while (pcount < part_read) {
1868 int32_t z = r->begin + pcount*r->part_size;
1869 int32_t c_inter = (z & 1), p_inter = z>>1;
1870 if (pass == 0) {
1871 Codebook *c = f->codebooks+r->classbook;
1872 int32_t q;
1873 FL_STBV_DECODE(q,f,c);
1874 if (q == EOP) goto done;
1875 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
1876 part_classdata[0][class_set] = r->classdata[q];
1877 #else
1878 for (i=classwords-1; i >= 0; --i) {
1879 classifications[0][i+pcount] = q % r->classifications;
1880 q /= r->classifications;
1881 }
1882 #endif
1883 }
1884 for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
1885 int32_t z = r->begin + pcount*r->part_size;
1886 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
1887 int32_t c = part_classdata[0][class_set][i];
1888 #else
1889 int32_t c = classifications[0][pcount];
1890 #endif
1891 int32_t b = r->residue_books[c][pass];
1892 if (b >= 0) {
1893 Codebook *book = f->codebooks + b;
1894 #ifdef FL_STB_VORBIS_DIVIDES_IN_CODEBOOK
1895 if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
1896 goto done;
1897 #else
1898 // saves 1%
1899 if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
1900 goto done;
1901 #endif
1902 } else {
1903 z += r->part_size;
1904 c_inter = z & 1;
1905 p_inter = z >> 1;
1906 }
1907 }
1908 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
1909 ++class_set;
1910 #endif
1911 }
1912 } else if (ch > 2) {
1913 while (pcount < part_read) {
1914 int32_t z = r->begin + pcount*r->part_size;
1915 int32_t c_inter = z % ch, p_inter = z/ch;
1916 if (pass == 0) {
1917 Codebook *c = f->codebooks+r->classbook;
1918 int32_t q;
1919 FL_STBV_DECODE(q,f,c);
1920 if (q == EOP) goto done;
1921 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
1922 part_classdata[0][class_set] = r->classdata[q];
1923 #else
1924 for (i=classwords-1; i >= 0; --i) {
1925 classifications[0][i+pcount] = q % r->classifications;
1926 q /= r->classifications;
1927 }
1928 #endif
1929 }
1930 for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
1931 int32_t z = r->begin + pcount*r->part_size;
1932 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
1933 int32_t c = part_classdata[0][class_set][i];
1934 #else
1935 int32_t c = classifications[0][pcount];
1936 #endif
1937 int32_t b = r->residue_books[c][pass];
1938 if (b >= 0) {
1939 Codebook *book = f->codebooks + b;
1940 if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
1941 goto done;
1942 } else {
1943 z += r->part_size;
1944 c_inter = z % ch;
1945 p_inter = z / ch;
1946 }
1947 }
1948 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
1949 ++class_set;
1950 #endif
1951 }
1952 }
1953 }
1954 goto done;
1955 }
1956 FL_STBV_CHECK(f);
1957
1958 for (pass=0; pass < 8; ++pass) {
1959 int32_t pcount = 0, class_set=0;
1960 while (pcount < part_read) {
1961 if (pass == 0) {
1962 for (j=0; j < ch; ++j) {
1963 if (!do_not_decode[j]) {
1964 Codebook *c = f->codebooks+r->classbook;
1965 int32_t temp;
1966 FL_STBV_DECODE(temp,f,c);
1967 if (temp == EOP) goto done;
1968 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
1969 part_classdata[j][class_set] = r->classdata[temp];
1970 #else
1971 for (i=classwords-1; i >= 0; --i) {
1972 classifications[j][i+pcount] = temp % r->classifications;
1973 temp /= r->classifications;
1974 }
1975 #endif
1976 }
1977 }
1978 }
1979 for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
1980 for (j=0; j < ch; ++j) {
1981 if (!do_not_decode[j]) {
1982 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
1983 int32_t c = part_classdata[j][class_set][i];
1984 #else
1985 int32_t c = classifications[j][pcount];
1986 #endif
1987 int32_t b = r->residue_books[c][pass];
1988 if (b >= 0) {
1989 float *target = residue_buffers[j];
1990 int32_t offset = r->begin + pcount * r->part_size;
1991 int32_t n = r->part_size;
1992 Codebook *book = f->codebooks + b;
1993 if (!residue_decode(f, book, target, offset, n, rtype))
1994 goto done;
1995 }
1996 }
1997 }
1998 }
1999 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
2000 ++class_set;
2001 #endif
2002 }
2003 }
2004 done:
2005 FL_STBV_CHECK(f);
2006 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
2007 fl_stbv_temp_free(f,part_classdata);
2008 #else
2009 fl_stbv_temp_free(f,classifications);
2010 #endif
2011 fl_stbv_temp_alloc_restore(f,fl_stbv_temp_alloc_point);
2012}
bool done
uint32_t z[NUM_LAYERS]
Definition Fire2023.h:93
static uint8_t pcount
Definition Pintest.h:147
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
static int32_t residue_decode(vorb *f, Codebook *book, float *target, int32_t offset, int32_t n, int32_t rtype) FL_NOEXCEPT
void * memset(void *s, int c, size_t n) FL_NOEXCEPT
static constexpr int32_t EOP
static int32_t 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) FL_NOEXCEPT
fl::u32 uint32_t
Definition coder.h:219
fl::i32 int32_t
Definition coder.h:220
fl::i32 int32_t
Definition s16x16x4.h:220
#define fl_stbv_temp_free(f, p)
#define FL_STBV_DECODE(var, f, c)
#define fl_stbv_temp_alloc_save(f)
#define fl_stbv_temp_block_array(f, count, size)
#define fl_stbv_temp_alloc_restore(f, p)
#define FL_STBV_CHECK(f)

References fl::third_party::vorbis::Residue::begin, fl::third_party::vorbis::Residue::classbook, fl::third_party::vorbis::Residue::classdata, fl::third_party::vorbis::Residue::classifications, codebook_decode_deinterleave_repeat(), done, fl::third_party::vorbis::Residue::end, EOP, FL_NOEXCEPT, FL_STBV_CHECK, FL_STBV_DECODE, fl_stbv_temp_alloc_restore, fl_stbv_temp_alloc_save, fl_stbv_temp_block_array, fl_stbv_temp_free, memset(), offset(), fl::third_party::vorbis::Residue::part_size, pcount, fl::third_party::vorbis::Residue::residue_books, residue_decode(), and z.

Referenced by vorbis_decode_packet_rest().

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