[FFmpeg-devel] Resubmit patch - [patch 4/4] Fix bugforPOWERLE: libswscale/ppc/swscale_altivec.c
rongyan
rongyan236 at foxmail.com
Wed Nov 12 08:41:46 CET 2014
Hi,
Again, thanks for your patience and review.
New patch please find in the attachment. The fate test results on both LE and BE are as follows:
Regards,
Rong Yan
------------------
The world has enough for everyone's need, but not enough for everyone's greed.
------------------ 原始邮件 ------------------
发件人: "Tony Lin";<linzhaolover at gmail.com>;
发送时间: 2014年11月12日(星期三) 上午9:38
收件人: "rongyan"<rongyan236 at foxmail.com>;
主题: Fwd: [FFmpeg-devel] Resubmit patch02 - [patch 4/4] Fix bugforPOWERLE: libswscale/ppc/swscale_altivec.c
Forwarded conversation
Subject: [FFmpeg-devel] Resubmit patch02 - [patch 4/4] Fix bug forPOWERLE: libswscale/ppc/swscale_altivec.c
------------------------
From: rongyan <rongyan236 at foxmail.com>
Date: 2014-11-11 14:18 GMT+08:00
To: ffmpeg-devel <ffmpeg-devel at ffmpeg.org>
Hi,
Thanks for your patience and review.
New patch please find in the attachment. This is the second of two.
The fate test result is here:
Regards,
Rong Yan
________________________________________________________________________________________________
Subject: [FFmpeg-devel] Resubmit patch02 - Fwd: [patch 4/4] Fix bug for POWERLE: libswscale/ppc/swscale_altivec.c
------------------------
From: rongyan <rongyan236 at foxmail.com>
Date: 2014-11-10 17:03 GMT+08:00
To: ffmpeg-devel <ffmpeg-devel at ffmpeg.org>
Cc: Tony Lin <linzhaolover at gmail.com>
Hi,
New patch please find in the attachment. There are two patches to re-submit, this is the second.
The fate test result is here:
Rong Yan
------------------ 原始邮件 ------------------
发件人: "Tony Lin";<linzhaolover at gmail.com>;
发送时间: 2014年11月10日(星期一) 中午11:32
收件人: "rongyan"<rongyan236 at foxmail.com>;
主题: Fwd: [FFmpeg-devel] [patch 4/4] Fix bug for POWERLE: libswscale/ppc/swscale_altivec.c
Forwarded conversation
Subject: [FFmpeg-devel] [patch 4/4] Fix bug for POWERLE: libswscale/ppc/swscale_altivec.c
------------------------
From: rongyan <rongyan236 at foxmail.com>
Date: 2014-11-07 17:43 GMT+08:00
To: ffmpeg-devel <ffmpeg-devel at ffmpeg.org>
Hi,
There are 4 patches presented to fix bugs for POWER8 little endian. I will send 4 patches in 4 different email. This is the fourth.
It fixed the function hScale_altivec_real(), yuv2planeX_16_altivec(), yuv2planeX_8().
The fate test result on POWER BE and POWER LE after merge these 4 patches are attached here to facilitate the review:
The passed test cases change from 1679/2182 to 2010/2236.
Rong Yan
------------------
The world has enough for everyone's need, but not enough for everyone's greed.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
----------
From: Michael Niedermayer <michaelni at gmx.at>
Date: 2014-11-08 1:54 GMT+08:00
To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> swscale_altivec.c | 142 +++++++++++++++++++-----------------------------------
> 1 file changed, 50 insertions(+), 92 deletions(-)
> 0c364d48e08b7df42bee5e269fe46b2d7be0f4b9 0004-libswscale-ppc-swscale_altivec.c-fix-hScale_altivec_.patch
> From 9ec626726d1cc30db54390ee81f52cfe53ebeedf Mon Sep 17 00:00:00 2001
> From: Rong Yan <rongyan236 at gmail.com>
> Date: Fri, 7 Nov 2014 09:09:09 +0000
> Subject: [PATCH 4/4] libswscale/ppc/swscale_altivec.c : fix
> hScale_altivec_real() yuv2planeX_16_altivec() yuv2planeX_8() for POWER LE
>
> ---
> libswscale/ppc/swscale_altivec.c | 142 ++++++++++++++-------------------------
> 1 file changed, 50 insertions(+), 92 deletions(-)
>
> diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c
> index 86f40ab..1673b8b 100644
> --- a/libswscale/ppc/swscale_altivec.c
> +++ b/libswscale/ppc/swscale_altivec.c
> @@ -29,20 +29,30 @@
> #include "libavutil/attributes.h"
> #include "libavutil/cpu.h"
> #include "yuv2rgb_altivec.h"
> +#include "libavutil/ppc/util_altivec.h"
>
> #if HAVE_ALTIVEC
> #define vzero vec_splat_s32(0)
>
> -#define yuv2planeX_8(d1, d2, l1, src, x, perm, filter) do { \
> - vector signed short l2 = vec_ld(((x) << 1) + 16, src); \
> - vector signed short ls = vec_perm(l1, l2, perm); \
> - vector signed int i1 = vec_mule(filter, ls); \
> - vector signed int i2 = vec_mulo(filter, ls); \
> - vector signed int vf1 = vec_mergeh(i1, i2); \
> - vector signed int vf2 = vec_mergel(i1, i2); \
> - d1 = vec_add(d1, vf1); \
> - d2 = vec_add(d2, vf2); \
> - l1 = l2; \
> +#if HAVE_BIGENDIAN
> +#define GET_VF(a, b) {\
> + a = vec_mergeh(i1, i2);\
> + b = vec_mergel(i1, i2);\
> + }
> +#else
> +#define GET_VF(a, b) {\
> + a = vec_mergel(i2, i1);\
> + b = vec_mergeh(i2, i1);\
> + }
> +#endif
> +
> +#define yuv2planeX_8(d1, d2, l1, src, x, filter) do {\
> + vector signed int i1 = vec_mule(filter, l1);\
> + vector signed int i2 = vec_mulo(filter, l1);\
> + vector signed int vf1, vf2;\
> + GET_VF(vf1, vf2);\
> + d1 = vec_add(d1, vf1);\
> + d2 = vec_add(d2, vf2);\
> } while (0)
>
> static void yuv2planeX_16_altivec(const int16_t *filter, int filterSize,
> @@ -66,16 +76,13 @@ static void yuv2planeX_16_altivec(const int16_t *filter, int filterSize,
> vo4 = vec_ld(48, val);
>
> for (j = 0; j < filterSize; j++) {
> - vector signed short l1, vLumFilter = vec_ld(j << 1, filter);
> - vector unsigned char perm, perm0 = vec_lvsl(j << 1, filter);
> - vLumFilter = vec_perm(vLumFilter, vLumFilter, perm0);
> + vector signed short l1, l2;
> + vector signed short vLumFilter = (vector signed short)unaligned_load(j << 1, filter);
> vLumFilter = vec_splat(vLumFilter, 0); // lumFilter[j] is loaded 8 times in vLumFilter
> -
> - perm = vec_lvsl(x << 1, src[j]);
> - l1 = vec_ld(x << 1, src[j]);
> -
> - yuv2planeX_8(vo1, vo2, l1, src[j], x, perm, vLumFilter);
> - yuv2planeX_8(vo3, vo4, l1, src[j], x + 8, perm, vLumFilter);
> + l1 = (vector signed short)unaligned_load(x << 1, src[j]);
> + l2 = (vector signed short)unaligned_load(((x) << 1) + 16, src[j]);
> + yuv2planeX_8(vo1, vo2, l1, src[j], x, vLumFilter);
> + yuv2planeX_8(vo3, vo4, l2, src[j], x + 8, vLumFilter);
> }
i belive this uses more vec_ld() on big endian than before.
i counted 4 before and 6 after the change
this would likely slow big endian down
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
----------
From: Michael Niedermayer <michaelni at gmx.at>
Date: 2014-11-10 23:13 GMT+08:00
To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> swscale_altivec.c | 163 +++++++++++++++++++++++++-----------------------------
> 1 file changed, 77 insertions(+), 86 deletions(-)
> faf64846206b6d93a709b40f9e229a2329285ede 0002-libswscale-ppc-swscale_altivec.c-fix-hScale_altivec_.patch
> From 68a7c25b17cce4e473ddb458e7dfc93a58d4a560 Mon Sep 17 00:00:00 2001
> From: Rong Yan <rongyan236 at gmail.com>
> Date: Mon, 10 Nov 2014 08:42:10 +0000
> Subject: [PATCH 2/2] libswscale/ppc/swscale_altivec.c : fix
> hScale_altivec_real() yuv2planeX_16_altivec() yuv2planeX_8() add marcos
> GET_LS() GET_VF() for POWER LE
>
> ---
> libswscale/ppc/swscale_altivec.c | 163 ++++++++++++++++++---------------------
> 1 file changed, 77 insertions(+), 86 deletions(-)
>
> diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c
> index 86f40ab..390c4bb 100644
> --- a/libswscale/ppc/swscale_altivec.c
> +++ b/libswscale/ppc/swscale_altivec.c
> @@ -29,22 +29,62 @@
> #include "libavutil/attributes.h"
> #include "libavutil/cpu.h"
> #include "yuv2rgb_altivec.h"
> +#include "libavutil/ppc/util_altivec.h"
>
> #if HAVE_ALTIVEC
> #define vzero vec_splat_s32(0)
>
> +#if HAVE_BIGENDIAN
> +#define GET_LS(a,b,c,s) {\
> + vector signed short l2 = vec_ld(((b) << 1) + 16, s); \
> + ls = vec_perm(a, l2, c);\
> + a = l2;\
> + }
> +#define GET_VF(a, b) {\
> + a = vec_mergeh(i1, i2);\
> + b = vec_mergel(i1, i2);\
> + }
> +#else
> +#define GET_LS(a,b,c,s) {\
> + ls = a; \
> + a = vec_vsx_ld(((b) << 1) + 16, s);\
> + }
> +#define GET_VF(a, b) {\
> + a = vec_mergel(i2, i1);\
> + b = vec_mergeh(i2, i1);\
> + }
i1 and i2 should be passed into the macro as well
for example
GET_VF(a, b, i1, i2)
[...]
> @@ -177,19 +201,12 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
> for (i = 0; i < dstW; i++) {
> register int srcPos = filterPos[i];
>
> - vector unsigned char src_v0 = vec_ld(srcPos, src);
> - vector unsigned char src_v1, src_vF;
> + vector unsigned char src_vF = unaligned_load(srcPos, src);
> vector signed short src_v, filter_v;
> vector signed int val_v, val_s;
> - if ((((uintptr_t)src + srcPos) % 16) > 8) {
> - src_v1 = vec_ld(srcPos + 16, src);
> - }
> - src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
> -
> src_v = // vec_unpackh sign-extends...
> - (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
> - filter_v = vec_ld(i << 4, filter);
> - // the 4 above is 3 (filterSize == 8) + 1 (sizeof(short) == 2)
> + (vector signed short)(VEC_MERGEH((vector unsigned char)vzero, src_vF));
> + filter_v = (vector signed short)unaligned_load(i << 4, filter);
>
> val_v = vec_msums(src_v, filter_v, (vector signed int)vzero);
> val_s = vec_sums(val_v, vzero);
the removed code does up to 3 vec_ld() on big endian, the added code
does 4 vec_ld()
> @@ -202,25 +219,21 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
> for (i = 0; i < dstW; i++) {
> register int srcPos = filterPos[i];
>
> - vector unsigned char src_v0 = vec_ld(srcPos, src);
> - vector unsigned char src_v1 = vec_ld(srcPos + 16, src);
> - vector unsigned char src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
> -
> + vector unsigned char src_vF = unaligned_load(srcPos, src);
> vector signed short src_vA = // vec_unpackh sign-extends...
> - (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
> + (vector signed short)(VEC_MERGEH((vector unsigned char)vzero, src_vF));
> vector signed short src_vB = // vec_unpackh sign-extends...
> - (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF));
> + (vector signed short)(VEC_MERGEL((vector unsigned char)vzero, src_vF));
>
> - vector signed short filter_v0 = vec_ld(i << 5, filter);
> - vector signed short filter_v1 = vec_ld((i << 5) + 16, filter);
> - // the 5 above are 4 (filterSize == 16) + 1 (sizeof(short) == 2)
> + vector signed short filter_v0 = (vector signed short)unaligned_load(i << 5, filter);
> + vector signed short filter_v1 = (vector signed short)unaligned_load((i << 5) + 16, filter);
>
> vector signed int val_acc = vec_msums(src_vA, filter_v0, (vector signed int)vzero);
> vector signed int val_v = vec_msums(src_vB, filter_v1, val_acc);
>
> vector signed int val_s = vec_sums(val_v, vzero);
>
> - vec_st(val_s, 0, tempo);
> + VEC_ST(val_s, 0, tempo);
> dst[i] = FFMIN(tempo[3] >> 7, (1 << 15) - 1);
> }
the removed code does 3 vec_ld() the added code does 6 vec_ld() on
big endian
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
----------
From: Michael Niedermayer <michaelni at gmx.at>
Date: 2014-11-12 2:31 GMT+08:00
To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
[...]
> @@ -140,31 +180,15 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
> for (i = 0; i < dstW; i++) {
> register int srcPos = filterPos[i];
>
> - vector unsigned char src_v0 = vec_ld(srcPos, src);
> - vector unsigned char src_v1, src_vF;
> + vector unsigned char src_vF = unaligned_load(srcPos, src);
> vector signed short src_v, filter_v;
> vector signed int val_vEven, val_s;
> - if ((((uintptr_t)src + srcPos) % 16) > 12) {
> - src_v1 = vec_ld(srcPos + 16, src);
> - }
> - src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
> -
> src_v = // vec_unpackh sign-extends...
> - (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
> + (vector signed short)(VEC_MERGEH((vector unsigned char)vzero, src_vF));
> // now put our elements in the even slots
> src_v = vec_mergeh(src_v, (vector signed short)vzero);
> -
> - filter_v = vec_ld(i << 3, filter);
> - // The 3 above is 2 (filterSize == 4) + 1 (sizeof(short) == 2).
> -
> - // The neat trick: We only care for half the elements,
> - // high or low depending on (i<<3)%16 (it's 0 or 8 here),
> - // and we're going to use vec_mule, so we choose
> - // carefully how to "unpack" the elements into the even slots.
> - if ((i << 3) % 16)
> - filter_v = vec_mergel(filter_v, (vector signed short)vzero);
> - else
> - filter_v = vec_mergeh(filter_v, (vector signed short)vzero);
> + filter_v = (vector signed short)unaligned_load(i << 3, filter);
> + filter_v = vec_mergeh(filter_v, (vector signed short)vzero);
>
> val_vEven = vec_mule(src_v, filter_v);
> val_s = vec_sums(val_vEven, vzero);
i see 3 vec_ld() before and 2 unaligned_load() each 2 vec_ld()
afterwards on big endian
> @@ -172,25 +196,16 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
> dst[i] = FFMIN(tempo[3] >> 7, (1 << 15) - 1);
> }
> break;
> -
> case 8:
> for (i = 0; i < dstW; i++) {
> register int srcPos = filterPos[i];
>
> - vector unsigned char src_v0 = vec_ld(srcPos, src);
> - vector unsigned char src_v1, src_vF;
> + vector unsigned char src_vF = unaligned_load(srcPos, src);
> vector signed short src_v, filter_v;
> vector signed int val_v, val_s;
> - if ((((uintptr_t)src + srcPos) % 16) > 8) {
> - src_v1 = vec_ld(srcPos + 16, src);
> - }
> - src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
> -
> src_v = // vec_unpackh sign-extends...
> - (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
> + (vector signed short)(VEC_MERGEH((vector unsigned char)vzero, src_vF));
> filter_v = vec_ld(i << 4, filter);
> - // the 4 above is 3 (filterSize == 8) + 1 (sizeof(short) == 2)
> -
> val_v = vec_msums(src_v, filter_v, (vector signed int)vzero);
> val_s = vec_sums(val_v, vzero);
> vec_st(val_s, 0, tempo);
> @@ -202,25 +217,20 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
> for (i = 0; i < dstW; i++) {
> register int srcPos = filterPos[i];
>
> - vector unsigned char src_v0 = vec_ld(srcPos, src);
> - vector unsigned char src_v1 = vec_ld(srcPos + 16, src);
> - vector unsigned char src_vF = vec_perm(src_v0, src_v1, vec_lvsl(srcPos, src));
> -
> + vector unsigned char src_vF = unaligned_load(srcPos, src);
> vector signed short src_vA = // vec_unpackh sign-extends...
> - (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
> + (vector signed short)(VEC_MERGEH((vector unsigned char)vzero, src_vF));
> vector signed short src_vB = // vec_unpackh sign-extends...
> - (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF));
> -
> + (vector signed short)(VEC_MERGEL((vector unsigned char)vzero, src_vF));
> vector signed short filter_v0 = vec_ld(i << 5, filter);
> vector signed short filter_v1 = vec_ld((i << 5) + 16, filter);
> - // the 5 above are 4 (filterSize == 16) + 1 (sizeof(short) == 2)
>
> vector signed int val_acc = vec_msums(src_vA, filter_v0, (vector signed int)vzero);
> vector signed int val_v = vec_msums(src_vB, filter_v1, val_acc);
>
> vector signed int val_s = vec_sums(val_v, vzero);
>
> - vec_st(val_s, 0, tempo);
> + VEC_ST(val_s, 0, tempo);
> dst[i] = FFMIN(tempo[3] >> 7, (1 << 15) - 1);
> }
> break;
> @@ -231,56 +241,34 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
> register int srcPos = filterPos[i];
>
> vector signed int val_s, val_v = (vector signed int)vzero;
> - vector signed short filter_v0R = vec_ld(i * 2 * filterSize, filter);
> - vector unsigned char permF = vec_lvsl((i * 2 * filterSize), filter);
> -
> - vector unsigned char src_v0 = vec_ld(srcPos, src);
> - vector unsigned char permS = vec_lvsl(srcPos, src);
>
> for (j = 0; j < filterSize - 15; j += 16) {
> - vector unsigned char src_v1 = vec_ld(srcPos + j + 16, src);
> - vector unsigned char src_vF = vec_perm(src_v0, src_v1, permS);
> -
> + vector unsigned char src_vF = unaligned_load(srcPos + j, src);
> vector signed short src_vA = // vec_unpackh sign-extends...
> - (vector signed short)(vec_mergeh((vector unsigned char)vzero, src_vF));
> + (vector signed short)(VEC_MERGEH((vector unsigned char)vzero, src_vF));
> vector signed short src_vB = // vec_unpackh sign-extends...
> - (vector signed short)(vec_mergel((vector unsigned char)vzero, src_vF));
> -
> - vector signed short filter_v1R = vec_ld((i * 2 * filterSize) + (j * 2) + 16, filter);
> - vector signed short filter_v2R = vec_ld((i * 2 * filterSize) + (j * 2) + 32, filter);
> - vector signed short filter_v0 = vec_perm(filter_v0R, filter_v1R, permF);
> - vector signed short filter_v1 = vec_perm(filter_v1R, filter_v2R, permF);
> + (vector signed short)(VEC_MERGEL((vector unsigned char)vzero, src_vF));
> + vector signed short filter_v0 = (vector signed short)unaligned_load((i * 2 * filterSize) + (j * 2), filter);
> + vector signed short filter_v1 = (vector signed short)unaligned_load((i * 2 * filterSize) + (j * 2) + 16, filter);
>
> vector signed int val_acc = vec_msums(src_vA, filter_v0, val_v);
> val_v = vec_msums(src_vB, filter_v1, val_acc);
> -
> - filter_v0R = filter_v2R;
> - src_v0 = src_v1;
> }
i count 3 vec_ld() before and 6 (2 for each unaligned_load())
after the change for big endian
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 43657 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141112/29580a6f/attachment.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libswscale-ppc-swscale_altivec.c-fix-hScale_altivec_.patch
Type: application/octet-stream
Size: 16494 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141112/29580a6f/attachment.obj>
More information about the ffmpeg-devel
mailing list