Mercurial > libavcodec.hg
changeset 10213:cebf6e3381e0 libavcodec
aacenc: Use preprocessor constants for trellis states and stages.
author | alexc |
---|---|
date | Mon, 21 Sep 2009 04:32:51 +0000 |
parents | 4e2db0d76fad |
children | 97f38ca4ed14 |
files | aaccoder.c |
diffstat | 1 files changed, 12 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/aaccoder.c Mon Sep 21 04:15:12 2009 +0000 +++ b/aaccoder.c Mon Sep 21 04:32:51 2009 +0000 @@ -463,6 +463,9 @@ int max_val; } TrellisPath; +#define TRELLIS_STAGES 121 +#define TRELLIS_STATES 256 + static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, const float lambda) @@ -470,19 +473,19 @@ int q, w, w2, g, start = 0; int i, j; int idx; - TrellisPath paths[121][256]; - int bandaddr[121]; + TrellisPath paths[TRELLIS_STAGES][TRELLIS_STATES]; + int bandaddr[TRELLIS_STAGES]; int minq; float mincost; - for (i = 0; i < 256; i++) { + for (i = 0; i < TRELLIS_STATES; i++) { paths[0][i].cost = 0.0f; paths[0][i].prev = -1; paths[0][i].min_val = i; paths[0][i].max_val = i; } - for (j = 1; j < 121; j++) { - for (i = 0; i < 256; i++) { + for (j = 1; j < TRELLIS_STAGES; j++) { + for (i = 0; i < TRELLIS_STATES; i++) { paths[j][i].cost = INFINITY; paths[j][i].prev = -2; paths[j][i].min_val = INT_MAX; @@ -538,7 +541,7 @@ dist = FFMIN(dist, dists[i]); minrd = FFMIN(minrd, dist); - for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, 256); i++) { + for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, TRELLIS_STATES); i++) { float cost; int minv, maxv; if (isinf(paths[idx - 1][i].cost)) @@ -556,7 +559,7 @@ } } } else { - for (q = 0; q < 256; q++) { + for (q = 0; q < TRELLIS_STATES; q++) { if (!isinf(paths[idx - 1][q].cost)) { paths[idx][q].cost = paths[idx - 1][q].cost + 1; paths[idx][q].prev = q; @@ -564,7 +567,7 @@ paths[idx][q].max_val = FFMAX(paths[idx - 1][q].max_val, q); continue; } - for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, 256); i++) { + for (i = FFMAX(q - SCALE_MAX_DIFF, 0); i < FFMIN(q + SCALE_MAX_DIFF, TRELLIS_STATES); i++) { float cost; int minv, maxv; if (isinf(paths[idx - 1][i].cost)) @@ -589,7 +592,7 @@ idx--; mincost = paths[idx][0].cost; minq = 0; - for (i = 1; i < 256; i++) { + for (i = 1; i < TRELLIS_STATES; i++) { if (paths[idx][i].cost < mincost) { mincost = paths[idx][i].cost; minq = i;