summaryrefslogtreecommitdiff
path: root/libavcodec/flacenc.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2010-07-31 20:17:59 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2010-07-31 20:17:59 +0000
commit089c18f3159d6bedda5647769d81b5f369bdfb5c (patch)
tree0ec075d859d9eeeeaf8b8fb2979f5a98c1c02f96 /libavcodec/flacenc.c
parentd309f0195040db62f462e8bd68203fd38b274158 (diff)
Reduce number of input parameters to find_subblock_rice_params().
Originally committed as revision 24628 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/flacenc.c')
-rw-r--r--libavcodec/flacenc.c56
1 files changed, 22 insertions, 34 deletions
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 7d1e773781..76b070915d 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -606,17 +606,19 @@ static int get_max_p_order(int max_porder, int n, int order)
}
-static uint32_t find_subblock_rice_params(RiceContext *rc, int pmin, int pmax,
- int32_t *data, int n, int pred_order,
- int bps, int precision)
+static uint32_t find_subblock_rice_params(FlacEncodeContext *s,
+ FlacSubframe *sub, int pred_order)
{
- uint32_t bits;
- pmin = get_max_p_order(pmin, n, pred_order);
- pmax = get_max_p_order(pmax, n, pred_order);
- bits = pred_order * bps + 6;
- if (precision > 0)
- bits += 4 + 5 + pred_order * precision;
- bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order);
+ int pmin = get_max_p_order(s->options.min_partition_order,
+ s->frame.blocksize, pred_order);
+ int pmax = get_max_p_order(s->options.max_partition_order,
+ s->frame.blocksize, pred_order);
+
+ uint32_t bits = 8 + pred_order * sub->obits + 2 + 4;
+ if (sub->type == FLAC_SUBFRAME_LPC)
+ bits += 4 + 5 + pred_order * s->options.lpc_coeff_precision;
+ bits += calc_rice_params(&sub->rc, pmin, pmax, sub->residual,
+ s->frame.blocksize, pred_order);
return bits;
}
@@ -779,8 +781,7 @@ static void encode_residual_lpc(int32_t *res, const int32_t *smp, int n,
static int encode_residual_ch(FlacEncodeContext *s, int ch)
{
int i, n;
- int min_order, max_order, opt_order, precision, omethod;
- int min_porder, max_porder;
+ int min_order, max_order, opt_order, omethod;
FlacFrame *frame;
FlacSubframe *sub;
int32_t coefs[MAX_LPC_ORDER][MAX_LPC_ORDER];
@@ -812,12 +813,10 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
min_order = s->options.min_prediction_order;
max_order = s->options.max_prediction_order;
- min_porder = s->options.min_partition_order;
- max_porder = s->options.max_partition_order;
- precision = s->options.lpc_coeff_precision;
omethod = s->options.prediction_order_method;
/* FIXED */
+ sub->type = FLAC_SUBFRAME_FIXED;
if (s->options.lpc_type == AV_LPC_TYPE_NONE ||
s->options.lpc_type == AV_LPC_TYPE_FIXED || n <= max_order) {
uint32_t bits[MAX_FIXED_ORDER+1];
@@ -827,26 +826,23 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
bits[0] = UINT32_MAX;
for (i = min_order; i <= max_order; i++) {
encode_residual_fixed(res, smp, n, i);
- bits[i] = find_subblock_rice_params(&sub->rc, min_porder,
- max_porder, res, n, i,
- sub->obits, 0);
+ bits[i] = find_subblock_rice_params(s, sub, i);
if (bits[i] < bits[opt_order])
opt_order = i;
}
sub->order = opt_order;
- sub->type = FLAC_SUBFRAME_FIXED;
sub->type_code = sub->type | sub->order;
if (sub->order != max_order) {
encode_residual_fixed(res, smp, n, sub->order);
- return find_subblock_rice_params(&sub->rc, min_porder, max_porder,
- res, n, sub->order, sub->obits, 0);
+ return find_subblock_rice_params(s, sub, sub->order);
}
return bits[sub->order];
}
/* LPC */
+ sub->type = FLAC_SUBFRAME_LPC;
opt_order = ff_lpc_calc_coefs(&s->dsp, smp, n, min_order, max_order,
- precision, coefs, shift, s->options.lpc_type,
+ s->options.lpc_coeff_precision, coefs, shift, s->options.lpc_type,
s->options.lpc_passes, omethod,
MAX_LPC_SHIFT, 0);
@@ -864,9 +860,7 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
if (order < 0)
order = 0;
encode_residual_lpc(res, smp, n, order+1, coefs[order], shift[order]);
- bits[i] = find_subblock_rice_params(&sub->rc, min_porder,
- max_porder, res, n, order+1,
- sub->obits, precision);
+ bits[i] = find_subblock_rice_params(s, sub, order+1);
if (bits[i] < bits[opt_index]) {
opt_index = i;
opt_order = order;
@@ -880,9 +874,7 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
bits[0] = UINT32_MAX;
for (i = min_order-1; i < max_order; i++) {
encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]);
- bits[i] = find_subblock_rice_params(&sub->rc, min_porder,
- max_porder, res, n, i+1,
- sub->obits, precision);
+ bits[i] = find_subblock_rice_params(s, sub, i+1);
if (bits[i] < bits[opt_order])
opt_order = i;
}
@@ -900,9 +892,7 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
if (i < min_order-1 || i >= max_order || bits[i] < UINT32_MAX)
continue;
encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]);
- bits[i] = find_subblock_rice_params(&sub->rc, min_porder,
- max_porder, res, n, i+1,
- sub->obits, precision);
+ bits[i] = find_subblock_rice_params(s, sub, i+1);
if (bits[i] < bits[opt_order])
opt_order = i;
}
@@ -911,7 +901,6 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
}
sub->order = opt_order;
- sub->type = FLAC_SUBFRAME_LPC;
sub->type_code = sub->type | (sub->order-1);
sub->shift = shift[sub->order-1];
for (i = 0; i < sub->order; i++)
@@ -919,8 +908,7 @@ static int encode_residual_ch(FlacEncodeContext *s, int ch)
encode_residual_lpc(res, smp, n, sub->order, sub->coefs, sub->shift);
- return find_subblock_rice_params(&sub->rc, min_porder, max_porder, res, n,
- sub->order, sub->obits, precision);
+ return find_subblock_rice_params(s, sub, sub->order);
}