Choose band type (codebook) zero, count its bits, and mark the other states as unnavigable.
Showing the changes to libavcodec/aaccoder.c (1 of 1 file). Show all
Unified · Split
| @@ -432,10 +432,26 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, · 431 unmodified lines | |||
| 432 | for (swb = 0; swb < max_sfb; swb++) { | 432 | for (swb = 0; swb < max_sfb; swb++) { |
| 433 | size = sce->ics.swb_sizes[swb]; | 433 | size = sce->ics.swb_sizes[swb]; |
| 434 | if (sce->zeroes[win*16 + swb]) { | 434 | if (sce->zeroes[win*16 + swb]) { |
| 435 | for (cb = 0; cb < 12; cb++) { | 435 | float cost_stay_here = path[swb][0].cost; |
| 436 | path[swb+1][cb].prev_idx = cb; | 436 | float cost_get_here = next_minrd + run_bits + 4; |
| 437 | path[swb+1][cb].cost = path[swb][cb].cost; | 437 | if ( run_value_bits[sce->ics.num_windows == 8][path[swb][0].run] |
| 438 | path[swb+1][cb].run = path[swb][cb].run + 1; | 438 | != run_value_bits[sce->ics.num_windows == 8][path[swb][0].run+1]) |
| 439 | cost_stay_here += run_bits; | ||
| 440 | if (cost_get_here < cost_stay_here) { | ||
| 441 | path[swb+1][0].prev_idx = next_mincb; | ||
| 442 | path[swb+1][0].cost = cost_get_here; | ||
| 443 | path[swb+1][0].run = 1; | ||
| 444 | } else { | ||
| 445 | path[swb+1][0].prev_idx = 0; | ||
| 446 | path[swb+1][0].cost = cost_stay_here; | ||
| 447 | path[swb+1][0].run = path[swb][0].run + 1; | ||
| 448 | } | ||
| 449 | next_minrd = path[swb+1][0].cost; | ||
| 450 | next_mincb = 0; | ||
| 451 | for (cb = 1; cb < 12; cb++) { | ||
| 452 | path[swb+1][cb].cost = 61450; | ||
| 453 | path[swb+1][cb].prev_idx = -1; | ||
| 454 | path[swb+1][cb].run = 0; | ||
| 439 | } | 455 | } |
| 440 | } else { | 456 | } else { |
| 441 | float minrd = next_minrd; | 457 | float minrd = next_minrd; |