summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Boyle <[email protected]>2015-06-16 08:25:01 +0100
committerCarl Eugen Hoyos <[email protected]>2015-06-19 10:26:41 +0200
commitd9dd0cbe632e7b4b0b1652b13112bb805e737522 (patch)
tree9f28aae8d9ecc054b7a3d46e5a9618a9186cef4d
parent1f7343c8145f76a482d5009e9b0739b4fcd1b891 (diff)
avcodec/flacenc: Fix Invalid Rice order
Fixes ticket #4628. The problem arose, in the sample file at least, in the last block where the minimum and maximum Rice partition orders were both 0. In that case, and any other where pmax == pmin, the original UINT32_MAX placeholder value for bits[opt_porder] was getting overwritten before the comparison to check if the current partition order is a new optimal, so the correct partition order and RiceContext params were not being set. Signed-off-by: Michael Niedermayer <[email protected]> (cherry picked from commit 2469ed32c81ebf2347e6883091c566724b286167) Conflicts: libavcodec/flacenc.c
-rw-r--r--libavcodec/flacenc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 97867823d9..78bd36ad39 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -663,7 +663,7 @@ static uint64_t calc_rice_params(RiceContext *rc, int pmin, int pmax,
bits[pmin] = UINT32_MAX;
for (i = pmax; ; ) {
bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums, n, pred_order);
- if (bits[i] < bits[opt_porder]) {
+ if (bits[i] < bits[opt_porder] || pmax == pmin) {
opt_porder = i;
*rc = tmp_rc;
}