| 169 | } |
| 170 | |
| 171 | static int wv_get_value(WavpackFrameContext *ctx, GetBitContext *gb, |
| 172 | int channel, int *last) |
| 173 | { |
| 174 | int t, t2; |
| 175 | int sign, base, add, ret; |
| 176 | WvChannel *c = &ctx->ch[channel]; |
| 177 | |
| 178 | *last = 0; |
| 179 | |
| 180 | if ((ctx->ch[0].median[0] < 2U) && (ctx->ch[1].median[0] < 2U) && |
| 181 | !ctx->zero && !ctx->one) { |
| 182 | if (ctx->zeroes) { |
| 183 | ctx->zeroes--; |
| 184 | if (ctx->zeroes) { |
| 185 | c->slow_level -= LEVEL_DECAY(c->slow_level); |
| 186 | return 0; |
| 187 | } |
| 188 | } else { |
| 189 | t = get_unary_0_33(gb); |
| 190 | if (t >= 2) { |
| 191 | if (t >= 32 || get_bits_left(gb) < t - 1) |
| 192 | goto error; |
| 193 | t = get_bits_long(gb, t - 1) | (1 << (t - 1)); |
| 194 | } else { |
| 195 | if (get_bits_left(gb) < 0) |
| 196 | goto error; |
| 197 | } |
| 198 | ctx->zeroes = t; |
| 199 | if (ctx->zeroes) { |
| 200 | memset(ctx->ch[0].median, 0, sizeof(ctx->ch[0].median)); |
| 201 | memset(ctx->ch[1].median, 0, sizeof(ctx->ch[1].median)); |
| 202 | c->slow_level -= LEVEL_DECAY(c->slow_level); |
| 203 | return 0; |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | if (ctx->zero) { |
| 209 | t = 0; |
| 210 | ctx->zero = 0; |
| 211 | } else { |
| 212 | t = get_unary_0_33(gb); |
| 213 | if (get_bits_left(gb) < 0) |
| 214 | goto error; |
| 215 | if (t == 16) { |
| 216 | t2 = get_unary_0_33(gb); |
| 217 | if (t2 < 2) { |
| 218 | if (get_bits_left(gb) < 0) |
| 219 | goto error; |
| 220 | t += t2; |
| 221 | } else { |
| 222 | if (t2 >= 32 || get_bits_left(gb) < t2 - 1) |
| 223 | goto error; |
| 224 | t += get_bits_long(gb, t2 - 1) | (1 << (t2 - 1)); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | if (ctx->one) { |
no test coverage detected