Commit 60a447551a for ffmpeg
commit 60a447551a1a41971aa93d0819baa365251fc211
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date: Wed Dec 2 00:28:29 2026 -0800
avcodec/mace: preserve precision in MACE6 interpolation
Keep the full predictor value and shift each weighted term separately.
The mono and stereo QuickTime 7 fixtures now match exactly. Update
the existing mono, stereo and MOV round-trip FATE checks.
Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
diff --git a/libavcodec/mace.c b/libavcodec/mace.c
index 87e802684a..8edd7e9b96 100644
--- a/libavcodec/mace.c
+++ b/libavcodec/mace.c
@@ -214,12 +214,12 @@ static void chomp6(ChannelData *chd, int16_t *output, uint8_t val, int tab_idx)
current = mace_broken_clip_int16(current + chd->level);
chd->level = (current*chd->factor) >> 15;
- current >>= 1;
- output[0] = QT_8S_2_16S(chd->previous + chd->prev2 -
- ((chd->prev2-current) >> 2));
- output[1] = QT_8S_2_16S(chd->previous + current +
- ((chd->prev2-current) >> 2));
+ /* Keep the full predictor precision and round each interpolation term. */
+ output[0] = QT_8S_2_16S((chd->previous >> 1) +
+ ((3 * chd->prev2) >> 3) + (current >> 3));
+ output[1] = QT_8S_2_16S((chd->previous >> 1) +
+ (chd->prev2 >> 3) + ((3 * current) >> 3));
chd->prev2 = chd->previous;
chd->previous = current;
}
diff --git a/tests/ref/fate/qt-mac6-mono b/tests/ref/fate/qt-mac6-mono
index d4d5104b20..916ab10aee 100644
--- a/tests/ref/fate/qt-mac6-mono
+++ b/tests/ref/fate/qt-mac6-mono
@@ -1 +1 @@
-eec238d2737365fba15da813e5a7fbc9
+c6f6c98d775e2767e04256bc31f5b71c
diff --git a/tests/ref/fate/qt-mac6-stereo b/tests/ref/fate/qt-mac6-stereo
index d018cb0835..52b7f9c9af 100644
--- a/tests/ref/fate/qt-mac6-stereo
+++ b/tests/ref/fate/qt-mac6-stereo
@@ -1 +1 @@
-2716d66016d8230bcc0fe90586da97a9
+11d729fce40acad3c2bd6374e9f9c4cf
diff --git a/tests/ref/lavf-fate/qtrle_mace6.mov b/tests/ref/lavf-fate/qtrle_mace6.mov
index b05d8890e0..c0098567c5 100644
--- a/tests/ref/lavf-fate/qtrle_mace6.mov
+++ b/tests/ref/lavf-fate/qtrle_mace6.mov
@@ -1,3 +1,3 @@
9ef5f70482cef2e9e8d51ba2816d6a86 *tests/data/lavf-fate/lavf.qtrle_mace6.mov
1270415 tests/data/lavf-fate/lavf.qtrle_mace6.mov
-tests/data/lavf-fate/lavf.qtrle_mace6.mov CRC=0x9320cd26
+tests/data/lavf-fate/lavf.qtrle_mace6.mov CRC=0x40401364