MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / III_requantize

Function III_requantize

modules/data/mp3/libmad/layer3.c:918–962  ·  view source on GitHub ↗

NAME: III_requantize() DESCRIPTION: requantize one (positive) value */

Source from the content-addressed store, hash-verified

916 DESCRIPTION: requantize one (positive) value
917*/
918static
919mad_fixed_t III_requantize(unsigned int value, signed int exp)
920{
921 mad_fixed_t requantized;
922 signed int frac;
923 struct fixedfloat power;
924
925 stack(__FUNCTION__, __FILE__, __LINE__);
926 frac = exp % 4; /* assumes sign(frac) == sign(exp) */
927 exp /= 4;
928
929#pragma GCC diagnostic push
930#pragma GCC diagnostic ignored "-Wstrict-aliasing"
931 *(uint32_t*)&power = *(uint32_t*)&rq_table[value]; //memcpy_P(&power, &rq_table[value], sizeof(power)); // Avoid byte access to PROGMEM
932#pragma GCC diagnostic pop
933#pragma GCC diagnostic push
934#pragma GCC diagnostic ignored "-Wuninitialized"
935 requantized = power.mantissa;
936 exp += power.exponent;
937#pragma GCC diagnostic pop
938
939 if (exp < 0) {
940 if (-exp >= (int)(sizeof(mad_fixed_t) * CHAR_BIT)) {
941 /* underflow */
942 requantized = 0;
943 }
944 else {
945 requantized += 1L << (-exp - 1);
946 requantized >>= -exp;
947 }
948 }
949 else {
950 if (exp >= 5) {
951 /* overflow */
952# if 0 && defined(DEBUG)
953 fprintf(stderr, "requantize overflow (%f * 2^%d)\n",
954 mad_f_todouble(requantized), exp);
955# endif
956 requantized = MAD_F_MAX;
957 }
958 else
959 requantized <<= exp;
960 }
961 return frac ? mad_f_mul(requantized, root_table(3 + frac)) : requantized;
962}
963
964/* we must take care that sz >= bits and sz < sizeof(long) lest bits == 0 */
965# define MASK(cache, sz, bits) \

Callers 1

III_huffdecodeFunction · 0.85

Calls 1

root_tableFunction · 0.85

Tested by

no test coverage detected