Fixes: Ticket9816 Fixes: vlc.ape and APE_48K_24bit_2CH_02_01.ape Regression since: ed0001482a74b60f3d5bc5cd7e304c9d65b2fcd5.
Unified · Split
| @@ -1184,7 +1184,8 @@ static void predictor_decode_mono_3930(APEContext *ctx, int count) · 1183 unmodified lines | ||
| 1184 | 1184 | static av_always_inline int predictor_update_filter(APEPredictor64 *p, |
| 1185 | 1185 | const int decoded, const int filter, |
| 1186 | 1186 | const int delayA, const int delayB, |
| 1187 | − const int adaptA, const int adaptB) | |
| 1187 | + const int adaptA, const int adaptB, | |
| 1188 | + int compression_level) | |
| 1188 | 1189 | { |
| 1189 | 1190 | int64_t predictionA, predictionB; |
| 1190 | 1191 | int32_t sign; |
| @@ -1212,7 +1213,13 @@ static av_always_inline int predictor_update_filter(APEPredictor64 *p, · 21 unmodified lines | ||
| 1212 | 1213 | p->buf[delayB - 3] * p->coeffsB[filter][3] + |
| 1213 | 1214 | p->buf[delayB - 4] * p->coeffsB[filter][4]; |
| 1214 | 1215 | |
| 1215 | − p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10); | |
| 1216 | + if (compression_level < COMPRESSION_LEVEL_INSANE) { | |
| 1217 | + predictionA = (int32_t)predictionA; | |
| 1218 | + predictionB = (int32_t)predictionB; | |
| 1219 | + p->lastA[filter] = decoded + ((int32_t)(predictionA + (predictionB >> 1)) >> 10); | |
| 1220 | + } else { | |
| 1221 | + p->lastA[filter] = decoded + ((int64_t)((uint64_t)predictionA + (predictionB >> 1)) >> 10); | |
| 1222 | + } | |
| 1216 | 1223 | p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter] * 31ULL) >> 5); |
| 1217 | 1224 | |
| 1218 | 1225 | sign = APESIGN(decoded); |
| @@ -1240,10 +1247,12 @@ static void predictor_decode_stereo_3950(APEContext *ctx, int count) · 21 unmodified lines | ||
| 1240 | 1247 | while (count--) { |
| 1241 | 1248 | /* Predictor Y */ |
| 1242 | 1249 | *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, |
| 1243 | − YADAPTCOEFFSA, YADAPTCOEFFSB); | |
| 1250 | + YADAPTCOEFFSA, YADAPTCOEFFSB, | |
| 1251 | + ctx->compression_level); | |
| 1244 | 1252 | decoded0++; |
| 1245 | 1253 | *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, |
| 1246 | − XADAPTCOEFFSA, XADAPTCOEFFSB); | |
| 1254 | + XADAPTCOEFFSA, XADAPTCOEFFSB, | |
| 1255 | + ctx->compression_level); | |
| 1247 | 1256 | decoded1++; |
| 1248 | 1257 | |
| 1249 | 1258 | /* Combined */ |