mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-10-24 02:09:03 +03:00
avcodec/ppc/h264dsp: Fix edge cases for bi-weight on ppc
S16 saturating sum must be computed dot-product-first. The Altivec code added the offset to the first product before adding the second product, so an intermediate saturation could corrupt the result even when the true sum fits. Swap the two vec_adds to form the dot product first. This fixes bi-weight checkasm test for PPC. Signed-off-by: Zuxy Meng <zuxy.meng@gmail.com>
This commit is contained in:
@@ -749,16 +749,16 @@ void biweight_h264_W_altivec(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h
|
||||
v0 = vec_mladd(v0, vweightd, zero_s16v);
|
||||
v2 = vec_mladd(v2, vweights, zero_s16v);
|
||||
|
||||
v0 = vec_adds(v0, voffset);
|
||||
v0 = vec_adds(v0, v2);
|
||||
v0 = vec_adds(v0, voffset);
|
||||
v0 = vec_sra(v0, vlog2_denom);
|
||||
}
|
||||
if (w == 16 || !dst_aligned) {
|
||||
v1 = vec_mladd(v1, vweightd, zero_s16v);
|
||||
v3 = vec_mladd(v3, vweights, zero_s16v);
|
||||
|
||||
v1 = vec_adds(v1, voffset);
|
||||
v1 = vec_adds(v1, v3);
|
||||
v1 = vec_adds(v1, voffset);
|
||||
v1 = vec_sra(v1, vlog2_denom);
|
||||
}
|
||||
vdst = vec_packsu(v0, v1);
|
||||
|
||||
@@ -544,8 +544,8 @@ static void check_weight(void)
|
||||
}
|
||||
}
|
||||
|
||||
// only arch that can pass test
|
||||
#define H264_CHECK_BIWEIGHT ARCH_X86
|
||||
// only archs that can pass test
|
||||
#define H264_CHECK_BIWEIGHT (ARCH_X86 || ARCH_PPC)
|
||||
|
||||
#if H264_CHECK_BIWEIGHT
|
||||
static void check_biweight(void)
|
||||
|
||||
Reference in New Issue
Block a user