static int I_step_one(PMPSTR mp, sideinfo_layer_I* si) { struct frame *fr = &(mp->fr); int jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : 32; int i; int illegal_value_detected = 0; unsigned char const ba15 = 15; /* bit pattern not allowed, looks like sync(?) */ memset(si, 0, sizeof(*si)); assert(fr->stereo == 1 || fr->stereo == 2); if (fr->stereo == 2) { for (i = 0; i < jsbound; i++) { unsigned char b0 = get_leq_8_bits(mp, 4); /* values 0-15 */ unsigned char b1 = get_leq_8_bits(mp, 4); /* values 0-15 */ si->allocation[i][0] = b0; si->allocation[i][1] = b1; if (b0 == ba15 || b1 == ba15) illegal_value_detected = 1; } for (i = jsbound; i < SBLIMIT; i++) { unsigned char b = get_leq_8_bits(mp, 4); /* values 0-15 */ si->allocation[i][0] = b; si->allocation[i][1] = b; if (b == ba15) illegal_value_detected = 1; } for (i = 0; i < SBLIMIT; i++) { unsigned char n0 = si->allocation[i][0]; unsigned char n1 = si->allocation[i][1]; unsigned char b0 = n0 ? get_leq_8_bits(mp, 6) : 0; /* values 0-63 */ unsigned char b1 = n1 ? get_leq_8_bits(mp, 6) : 0; /* values 0-63 */ si->scalefactor[i][0] = b0; si->scalefactor[i][1] = b1; } } else { for (i = 0; i < SBLIMIT; i++) { unsigned char b0 = get_leq_8_bits(mp, 4); /* values 0-15 */ si->allocation[i][0] = b0; if (b0 == ba15) illegal_value_detected = 1; } for (i = 0; i < SBLIMIT; i++) { unsigned char n0 = si->allocation[i][0]; unsigned char b0 = n0 ? get_leq_8_bits(mp, 6) : 0; /* values 0-63 */ si->scalefactor[i][0] = b0; } } return illegal_value_detected; }
static void I_step_one(PMPSTR mp, sideinfo_layer_I* si) { struct frame *fr = &(mp->fr); int jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : 32; int i; memset(si, 0, sizeof(*si)); assert(fr->stereo == 1 || fr->stereo == 2); if (fr->stereo == 2) { for (i = 0; i < jsbound; i++) { unsigned char b0 = get_leq_8_bits(mp, 4); /* values 0-15 */ unsigned char b1 = get_leq_8_bits(mp, 4); /* values 0-15 */ si->allocation[i][0] = b0; si->allocation[i][1] = b1; } for (i = jsbound; i < SBLIMIT; i++) { unsigned char b = get_leq_8_bits(mp, 4); /* values 0-15 */ si->allocation[i][0] = b; si->allocation[i][1] = b; } for (i = 0; i < SBLIMIT; i++) { unsigned char n0 = si->allocation[i][0]; unsigned char n1 = si->allocation[i][1]; unsigned char b0 = n0 ? get_leq_8_bits(mp, 6) : 0; /* values 0-63 */ unsigned char b1 = n1 ? get_leq_8_bits(mp, 6) : 0; /* values 0-63 */ si->scalefactor[i][0] = b0; si->scalefactor[i][1] = b1; } } else { for (i = 0; i < SBLIMIT; i++) { unsigned char b0 = get_leq_8_bits(mp, 4); /* values 0-15 */ si->allocation[i][0] = b0; } for (i = 0; i < SBLIMIT; i++) { unsigned char n0 = si->allocation[i][0]; unsigned char b0 = n0 ? get_leq_8_bits(mp, 6) : 0; /* values 0-63 */ si->scalefactor[i][0] = b0; } } }
static void II_step_one(PMPSTR mp, sideinfo_layer_II *si, struct frame *fr) { int nch = fr->stereo; int sblimit = fr->II_sblimit; int jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext << 2) + 4 : fr->II_sblimit; struct al_table2 const *alloc1 = fr->alloc; unsigned char scfsi[SBLIMIT][2]; int i, ch; memset(si, 0, sizeof(*si)); if (nch == 2) { for (i = 0; i < jsbound; ++i) { short step = alloc1->bits; unsigned char b0 = get_leq_8_bits(mp, step); unsigned char b1 = get_leq_8_bits(mp, step); alloc1 += ((size_t)1 << step); si->allocation[i][0] = b0; si->allocation[i][1] = b1; } for (i = jsbound; i < sblimit; ++i) { short step = alloc1->bits; unsigned char b0 = get_leq_8_bits(mp, step); alloc1 += ((size_t)1 << step); si->allocation[i][0] = b0; si->allocation[i][1] = b0; } for (i = 0; i < sblimit; ++i) { unsigned char n0 = si->allocation[i][0]; unsigned char n1 = si->allocation[i][1]; unsigned char b0 = n0 ? get_leq_8_bits(mp, 2) : 0; unsigned char b1 = n1 ? get_leq_8_bits(mp, 2) : 0; scfsi[i][0] = b0; scfsi[i][1] = b1; } } else { /* mono */ for (i = 0; i < sblimit; ++i) { short step = alloc1->bits; unsigned char b0 = get_leq_8_bits(mp, step); alloc1 += ((size_t)1 << step); si->allocation[i][0] = b0; } for (i = 0; i < sblimit; ++i) { unsigned char n0 = si->allocation[i][0]; unsigned char b0 = n0 ? get_leq_8_bits(mp, 2) : 0; scfsi[i][0] = b0; } } for (i = 0; i < sblimit; ++i) { for (ch = 0; ch < nch; ++ch) { unsigned char s0 = 0, s1 = 0, s2 = 0; if (si->allocation[i][ch]) { switch (scfsi[i][ch]) { case 0: s0 = get_leq_8_bits(mp, 6); s1 = get_leq_8_bits(mp, 6); s2 = get_leq_8_bits(mp, 6); break; case 1: s0 = get_leq_8_bits(mp, 6); s1 = s0; s2 = get_leq_8_bits(mp, 6); break; case 2: s0 = get_leq_8_bits(mp, 6); s1 = s0; s2 = s0; break; case 3: s0 = get_leq_8_bits(mp, 6); s1 = get_leq_8_bits(mp, 6); s2 = s1; break; default: assert(0); } } si->scalefactor[i][ch][0] = s0; si->scalefactor[i][ch][1] = s1; si->scalefactor[i][ch][2] = s2; } } }