History

avcodec/apedec: Fix 48khz 24bit below insane level

Fixes: Ticket9816 Fixes: vlc.ape and APE_48K_24bit_2CH_02_01.ape Regression since: ed0001482a74b60f3d5bc5cd7e304c9d65b2fcd5.

Michael Niedermayer committed 3 years ago

Commit 80ad0e21 parent 696e1611 file · +13 −4Browse files

Unified · Split

libavcodec/apedec.c+13−4
@@ -1184,7 +1184,8 @@ static void predictor_decode_mono_3930(APEContext *ctx, int count) · 1183 unmodified lines
11841184 static av_always_inline int predictor_update_filter(APEPredictor64 *p,
11851185 const int decoded, const int filter,
11861186 const int delayA, const int delayB,
1187− const int adaptA, const int adaptB)
1187+ const int adaptA, const int adaptB,
1188+ int compression_level)
11881189 {
11891190 int64_t predictionA, predictionB;
11901191 int32_t sign;
@@ -1212,7 +1213,13 @@ static av_always_inline int predictor_update_filter(APEPredictor64 *p, · 21 unmodified lines
12121213 p->buf[delayB - 3] * p->coeffsB[filter][3] +
12131214 p->buf[delayB - 4] * p->coeffsB[filter][4];
12141215
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+ }
12161223 p->filterA[filter] = p->lastA[filter] + ((int64_t)(p->filterA[filter] * 31ULL) >> 5);
12171224
12181225 sign = APESIGN(decoded);
@@ -1240,10 +1247,12 @@ static void predictor_decode_stereo_3950(APEContext *ctx, int count) · 21 unmodified lines
12401247 while (count--) {
12411248 /* Predictor Y */
12421249 *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB,
1243− YADAPTCOEFFSA, YADAPTCOEFFSB);
1250+ YADAPTCOEFFSA, YADAPTCOEFFSB,
1251+ ctx->compression_level);
12441252 decoded0++;
12451253 *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB,
1246− XADAPTCOEFFSA, XADAPTCOEFFSB);
1254+ XADAPTCOEFFSA, XADAPTCOEFFSB,
1255+ ctx->compression_level);
12471256 decoded1++;
12481257
12491258 /* Combined */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t