This was in else branch of `#if 1` since ever. No need to keep dead code like that, if anyone needs it they can get it from git history.
Unified · Split
| @@ -166,7 +166,6 @@ static inline av_flatten int get_symbol(RangeCoder *c, uint8_t *state, int is_si · 165 unmodified lines | |||
| 166 | } | 166 | } |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | #if 1 | ||
| 170 | static inline int intlist_write(RangeCoder *c, uint8_t *state, int *buf, int entries, int base_2_part) | 169 | static inline int intlist_write(RangeCoder *c, uint8_t *state, int *buf, int entries, int base_2_part) |
| 171 | { | 170 | { |
| 172 | int i; | 171 | int i; |
| @@ -186,274 +185,6 @@ static inline int intlist_read(RangeCoder *c, uint8_t *state, int *buf, int entr · 13 unmodified lines | |||
| 186 | 185 | ||
| 187 | return 1; | 186 | return 1; |
| 188 | } | 187 | } |
| 189 | #elif 1 | ||
| 190 | static inline int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_part) | ||
| 191 | { | ||
| 192 | int i; | ||
| 193 | |||
| 194 | for (i = 0; i < entries; i++) | ||
| 195 | set_se_golomb(pb, buf[i]); | ||
| 196 | |||
| 197 | return 1; | ||
| 198 | } | ||
| 199 | |||
| 200 | static inline int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_part) | ||
| 201 | { | ||
| 202 | int i; | ||
| 203 | |||
| 204 | for (i = 0; i < entries; i++) | ||
| 205 | buf[i] = get_se_golomb(gb); | ||
| 206 | |||
| 207 | return 1; | ||
| 208 | } | ||
| 209 | |||
| 210 | #else | ||
| 211 | |||
| 212 | #define ADAPT_LEVEL 8 | ||
| 213 | |||
| 214 | static int bits_to_store(uint64_t x) | ||
| 215 | { | ||
| 216 | int res = 0; | ||
| 217 | |||
| 218 | while(x) | ||
| 219 | { | ||
| 220 | res++; | ||
| 221 | x >>= 1; | ||
| 222 | } | ||
| 223 | return res; | ||
| 224 | } | ||
| 225 | |||
| 226 | static void write_uint_max(PutBitContext *pb, unsigned int value, unsigned int max) | ||
| 227 | { | ||
| 228 | int i, bits; | ||
| 229 | |||
| 230 | if (!max) | ||
| 231 | return; | ||
| 232 | |||
| 233 | bits = bits_to_store(max); | ||
| 234 | |||
| 235 | for (i = 0; i < bits-1; i++) | ||
| 236 | put_bits(pb, 1, value & (1 << i)); | ||
| 237 | |||
| 238 | if ( (value | (1 << (bits-1))) <= max) | ||
| 239 | put_bits(pb, 1, value & (1 << (bits-1))); | ||
| 240 | } | ||
| 241 | |||
| 242 | static unsigned int read_uint_max(GetBitContext *gb, int max) | ||
| 243 | { | ||
| 244 | int i, bits, value = 0; | ||
| 245 | |||
| 246 | if (!max) | ||
| 247 | return 0; | ||
| 248 | |||
| 249 | bits = bits_to_store(max); | ||
| 250 | |||
| 251 | for (i = 0; i < bits-1; i++) | ||
| 252 | if (get_bits1(gb)) | ||
| 253 | value += 1 << i; | ||
| 254 | |||
| 255 | if ( (value | (1<<(bits-1))) <= max) | ||
| 256 | if (get_bits1(gb)) | ||
| 257 | value += 1 << (bits-1); | ||
| 258 | |||
| 259 | return value; | ||
| 260 | } | ||
| 261 | |||
| 262 | static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_part) | ||
| 263 | { | ||
| 264 | int i, j, x = 0, low_bits = 0, max = 0; | ||
| 265 | int step = 256, pos = 0, dominant = 0, any = 0; | ||
| 266 | int *copy, *bits; | ||
| 267 | |||
| 268 | copy = av_calloc(entries, sizeof(*copy)); | ||
| 269 | if (!copy) | ||
| 270 | return AVERROR(ENOMEM); | ||
| 271 | |||
| 272 | if (base_2_part) | ||
| 273 | { | ||
| 274 | int energy = 0; | ||
| 275 | |||
| 276 | for (i = 0; i < entries; i++) | ||
| 277 | energy += abs(buf[i]); | ||
| 278 | |||
| 279 | low_bits = bits_to_store(energy / (entries * 2)); | ||
| 280 | if (low_bits > 15) | ||
| 281 | low_bits = 15; | ||
| 282 | |||
| 283 | put_bits(pb, 4, low_bits); | ||
| 284 | } | ||
| 285 | |||
| 286 | for (i = 0; i < entries; i++) | ||
| 287 | { | ||
| 288 | put_bits(pb, low_bits, abs(buf[i])); | ||
| 289 | copy[i] = abs(buf[i]) >> low_bits; | ||
| 290 | if (copy[i] > max) | ||
| 291 | max = abs(copy[i]); | ||
| 292 | } | ||
| 293 | |||
| 294 | bits = av_calloc(entries*max, sizeof(*bits)); | ||
| 295 | if (!bits) | ||
| 296 | { | ||
| 297 | av_free(copy); | ||
| 298 | return AVERROR(ENOMEM); | ||
| 299 | } | ||
| 300 | |||
| 301 | for (i = 0; i <= max; i++) | ||
| 302 | { | ||
| 303 | for (j = 0; j < entries; j++) | ||
| 304 | if (copy[j] >= i) | ||
| 305 | bits[x++] = copy[j] > i; | ||
| 306 | } | ||
| 307 | |||
| 308 | // store bitstream | ||
| 309 | while (pos < x) | ||
| 310 | { | ||
| 311 | int steplet = step >> 8; | ||
| 312 | |||
| 313 | if (pos + steplet > x) | ||
| 314 | steplet = x - pos; | ||
| 315 | |||
| 316 | for (i = 0; i < steplet; i++) | ||
| 317 | if (bits[i+pos] != dominant) | ||
| 318 | any = 1; | ||
| 319 | |||
| 320 | put_bits(pb, 1, any); | ||
| 321 | |||
| 322 | if (!any) | ||
| 323 | { | ||
| 324 | pos += steplet; | ||
| 325 | step += step / ADAPT_LEVEL; | ||
| 326 | } | ||
| 327 | else | ||
| 328 | { | ||
| 329 | int interloper = 0; | ||
| 330 | |||
| 331 | while (((pos + interloper) < x) && (bits[pos + interloper] == dominant)) | ||
| 332 | interloper++; | ||
| 333 | |||
| 334 | // note change | ||
| 335 | write_uint_max(pb, interloper, (step >> 8) - 1); | ||
| 336 | |||
| 337 | pos += interloper + 1; | ||
| 338 | step -= step / ADAPT_LEVEL; | ||
| 339 | } | ||
| 340 | |||
| 341 | if (step < 256) | ||
| 342 | { | ||
| 343 | step = 65536 / step; | ||
| 344 | dominant = !dominant; | ||
| 345 | } | ||
| 346 | } | ||
| 347 | |||
| 348 | // store signs | ||
| 349 | for (i = 0; i < entries; i++) | ||
| 350 | if (buf[i]) | ||
| 351 | put_bits(pb, 1, buf[i] < 0); | ||
| 352 | |||
| 353 | av_free(bits); | ||
| 354 | av_free(copy); | ||
| 355 | |||
| 356 | return 0; | ||
| 357 | } | ||
| 358 | |||
| 359 | static int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_part) | ||
| 360 | { | ||
| 361 | int i, low_bits = 0, x = 0; | ||
| 362 | int n_zeros = 0, step = 256, dominant = 0; | ||
| 363 | int pos = 0, level = 0; | ||
| 364 | int *bits = av_calloc(entries, sizeof(*bits)); | ||
| 365 | |||
| 366 | if (!bits) | ||
| 367 | return AVERROR(ENOMEM); | ||
| 368 | |||
| 369 | if (base_2_part) | ||
| 370 | { | ||
| 371 | low_bits = get_bits(gb, 4); | ||
| 372 | |||
| 373 | if (low_bits) | ||
| 374 | for (i = 0; i < entries; i++) | ||
| 375 | buf[i] = get_bits(gb, low_bits); | ||
| 376 | } | ||
| 377 | |||
| 378 | // av_log(NULL, AV_LOG_INFO, "entries: %d, low bits: %d\n", entries, low_bits); | ||
| 379 | |||
| 380 | while (n_zeros < entries) | ||
| 381 | { | ||
| 382 | int steplet = step >> 8; | ||
| 383 | |||
| 384 | if (!get_bits1(gb)) | ||
| 385 | { | ||
| 386 | for (i = 0; i < steplet; i++) | ||
| 387 | bits[x++] = dominant; | ||
| 388 | |||
| 389 | if (!dominant) | ||
| 390 | n_zeros += steplet; | ||
| 391 | |||
| 392 | step += step / ADAPT_LEVEL; | ||
| 393 | } | ||
| 394 | else | ||
| 395 | { | ||
| 396 | int actual_run = read_uint_max(gb, steplet-1); | ||
| 397 | |||
| 398 | // av_log(NULL, AV_LOG_INFO, "actual run: %d\n", actual_run); | ||
| 399 | |||
| 400 | for (i = 0; i < actual_run; i++) | ||
| 401 | bits[x++] = dominant; | ||
| 402 | |||
| 403 | bits[x++] = !dominant; | ||
| 404 | |||
| 405 | if (!dominant) | ||
| 406 | n_zeros += actual_run; | ||
| 407 | else | ||
| 408 | n_zeros++; | ||
| 409 | |||
| 410 | step -= step / ADAPT_LEVEL; | ||
| 411 | } | ||
| 412 | |||
| 413 | if (step < 256) | ||
| 414 | { | ||
| 415 | step = 65536 / step; | ||
| 416 | dominant = !dominant; | ||
| 417 | } | ||
| 418 | } | ||
| 419 | |||
| 420 | // reconstruct unsigned values | ||
| 421 | n_zeros = 0; | ||
| 422 | for (i = 0; n_zeros < entries; i++) | ||
| 423 | { | ||
| 424 | while(1) | ||
| 425 | { | ||
| 426 | if (pos >= entries) | ||
| 427 | { | ||
| 428 | pos = 0; | ||
| 429 | level += 1 << low_bits; | ||
| 430 | } | ||
| 431 | |||
| 432 | if (buf[pos] >= level) | ||
| 433 | break; | ||
| 434 | |||
| 435 | pos++; | ||
| 436 | } | ||
| 437 | |||
| 438 | if (bits[i]) | ||
| 439 | buf[pos] += 1 << low_bits; | ||
| 440 | else | ||
| 441 | n_zeros++; | ||
| 442 | |||
| 443 | pos++; | ||
| 444 | } | ||
| 445 | av_free(bits); | ||
| 446 | |||
| 447 | // read signs | ||
| 448 | for (i = 0; i < entries; i++) | ||
| 449 | if (buf[i] && get_bits1(gb)) | ||
| 450 | buf[i] = -buf[i]; | ||
| 451 | |||
| 452 | // av_log(NULL, AV_LOG_INFO, "zeros: %d pos: %d\n", n_zeros, pos); | ||
| 453 | |||
| 454 | return 0; | ||
| 455 | } | ||
| 456 | #endif | ||
| 457 | 188 | ||
| 458 | static void predictor_init_state(int *k, int *state, int order) | 189 | static void predictor_init_state(int *k, int *state, int order) |
| 459 | { | 190 | { |
| @@ -476,7 +207,6 @@ static int predictor_calc_error(int *k, int *state, int order, int error) · 16 unmodified lines | |||
| 476 | { | 207 | { |
| 477 | int i, x = error - (unsigned)shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT); | 208 | int i, x = error - (unsigned)shift_down(k[order-1] * (unsigned)state[order-1], LATTICE_SHIFT); |
| 478 | 209 | ||
| 479 | #if 1 | ||
| 480 | int *k_ptr = &(k[order-2]), | 210 | int *k_ptr = &(k[order-2]), |
| 481 | *state_ptr = &(state[order-2]); | 211 | *state_ptr = &(state[order-2]); |
| 482 | for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) | 212 | for (i = order-2; i >= 0; i--, k_ptr--, state_ptr--) |
| @@ -485,13 +215,6 @@ static int predictor_calc_error(int *k, int *state, int order, int error) · 2 unmodified lines | |||
| 485 | x -= (unsigned)shift_down(k_value * (unsigned)state_value, LATTICE_SHIFT); | 215 | x -= (unsigned)shift_down(k_value * (unsigned)state_value, LATTICE_SHIFT); |
| 486 | state_ptr[1] = state_value + shift_down(k_value * (unsigned)x, LATTICE_SHIFT); | 216 | state_ptr[1] = state_value + shift_down(k_value * (unsigned)x, LATTICE_SHIFT); |
| 487 | } | 217 | } |
| 488 | #else | ||
| 489 | for (i = order-2; i >= 0; i--) | ||
| 490 | { | ||
| 491 | x -= (unsigned)shift_down(k[i] * state[i], LATTICE_SHIFT); | ||
| 492 | state[i+1] = state[i] + shift_down(k[i] * x, LATTICE_SHIFT); | ||
| 493 | } | ||
| 494 | #endif | ||
| 495 | 218 | ||
| 496 | // don't drift too far, to avoid overflows | 219 | // don't drift too far, to avoid overflows |
| 497 | if (x > (SAMPLE_FACTOR<<16)) x = (SAMPLE_FACTOR<<16); | 220 | if (x > (SAMPLE_FACTOR<<16)) x = (SAMPLE_FACTOR<<16); |
| @@ -519,7 +242,6 @@ static void modified_levinson_durbin(int *window, int window_entries, · 21 unmodified lines | |||
| 519 | { | 242 | { |
| 520 | int step = (i+1)*channels, k, j; | 243 | int step = (i+1)*channels, k, j; |
| 521 | double xx = 0.0, xy = 0.0; | 244 | double xx = 0.0, xy = 0.0; |
| 522 | #if 1 | ||
| 523 | int *x_ptr = &(window[step]); | 245 | int *x_ptr = &(window[step]); |
| 524 | int *state_ptr = &(state[0]); | 246 | int *state_ptr = &(state[0]); |
| 525 | j = window_entries - step; | 247 | j = window_entries - step; |
| @@ -530,17 +252,6 @@ static void modified_levinson_durbin(int *window, int window_entries, · 4 unmodified lines | |||
| 530 | xx += state_value*state_value; | 252 | xx += state_value*state_value; |
| 531 | xy += x_value*state_value; | 253 | xy += x_value*state_value; |
| 532 | } | 254 | } |
| 533 | #else | ||
| 534 | for (j = 0; j <= (window_entries - step); j++); | ||
| 535 | { | ||
| 536 | double stepval = window[step+j]; | ||
| 537 | double stateval = window[j]; | ||
| 538 | // xx += (double)window[j]*(double)window[j]; | ||
| 539 | // xy += (double)window[step+j]*(double)window[j]; | ||
| 540 | xx += stateval*stateval; | ||
| 541 | xy += stepval*stateval; | ||
| 542 | } | ||
| 543 | #endif | ||
| 544 | if (xx == 0.0) | 255 | if (xx == 0.0) |
| 545 | k = 0; | 256 | k = 0; |
| 546 | else | 257 | else |
| @@ -554,7 +265,6 @@ static void modified_levinson_durbin(int *window, int window_entries, · 7 unmodified lines | |||
| 554 | out[i] = k; | 265 | out[i] = k; |
| 555 | k *= tap_quant[i]; | 266 | k *= tap_quant[i]; |
| 556 | 267 | ||
| 557 | #if 1 | ||
| 558 | x_ptr = &(window[step]); | 268 | x_ptr = &(window[step]); |
| 559 | state_ptr = &(state[0]); | 269 | state_ptr = &(state[0]); |
| 560 | j = window_entries - step; | 270 | j = window_entries - step; |
| @@ -565,15 +275,6 @@ static void modified_levinson_durbin(int *window, int window_entries, · 4 unmodified lines | |||
| 565 | *x_ptr = x_value + shift_down(k*state_value,LATTICE_SHIFT); | 275 | *x_ptr = x_value + shift_down(k*state_value,LATTICE_SHIFT); |
| 566 | *state_ptr = state_value + shift_down(k*x_value, LATTICE_SHIFT); | 276 | *state_ptr = state_value + shift_down(k*x_value, LATTICE_SHIFT); |
| 567 | } | 277 | } |
| 568 | #else | ||
| 569 | for (j=0; j <= (window_entries - step); j++) | ||
| 570 | { | ||
| 571 | int stepval = window[step+j]; | ||
| 572 | int stateval=state[j]; | ||
| 573 | window[step+j] += shift_down(k * stateval, LATTICE_SHIFT); | ||
| 574 | state[j] += shift_down(k * stepval, LATTICE_SHIFT); | ||
| 575 | } | ||
| 576 | #endif | ||
| 577 | } | 278 | } |
| 578 | } | 279 | } |
| 579 | 280 | ||