Re: [libav-devel] [PATCH 069/132] dsputil: Refactor duplicated CALL_2X_PIXELS / PIXELS16 macros
On 15 Mar 2014, at 12:17, Anton Khirnov wrote: > > On Fri, 14 Mar 2014 05:42:24 -0700, Diego Biurrun wrote: >> --- >> #if HAVE_YASM >> >> -#define HPELDSP_AVG_PIXELS16(CPUEXT)\ >> -PIXELS16(static, put_no_rnd, ff_, _x2, CPUEXT) \ >> -PIXELS16(static, put,ff_, _y2, CPUEXT) \ >> -PIXELS16(static, put_no_rnd, ff_, _y2, CPUEXT) \ >> -PIXELS16(static, avg,ff_, , CPUEXT) \ >> -PIXELS16(static, avg,ff_, _x2, CPUEXT) \ >> -PIXELS16(static, avg,ff_, _y2, CPUEXT) \ >> -PIXELS16(static, avg,ff_, _xy2, CPUEXT) >> +#define HPELDSP_AVG_PIXELS16(CPUEXT) \ >> +CALL_2X_PIXELS(put_no_rnd_pixels16_x2 ## CPUEXT, \ >> + ff_put_no_rnd_pixels8_x2 ## CPUEXT, 8) \ >> +CALL_2X_PIXELS(put_pixels16_y2 ## CPUEXT, \ >> + ff_put_pixels8_y2 ## CPUEXT, 8)\ >> +CALL_2X_PIXELS(put_no_rnd_pixels16_y2 ## CPUEXT, \ >> + ff_put_no_rnd_pixels8_y2 ## CPUEXT, 8) \ >> +CALL_2X_PIXELS(avg_pixels16 ## CPUEXT,\ >> + ff_avg_pixels8 ## CPUEXT, 8) \ >> +CALL_2X_PIXELS(avg_pixels16_x2 ## CPUEXT, \ >> + ff_avg_pixels8_x2 ## CPUEXT, 8)\ >> +CALL_2X_PIXELS(avg_pixels16_y2 ## CPUEXT, \ >> + ff_avg_pixels8_y2 ## CPUEXT, 8)\ >> +CALL_2X_PIXELS(avg_pixels16_xy2 ## CPUEXT,\ >> + ff_avg_pixels8_xy2 ## CPUEXT, 8) > > This is now much less readable Indeed. Tim ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 069/132] dsputil: Refactor duplicated CALL_2X_PIXELS / PIXELS16 macros
On Fri, 14 Mar 2014 05:42:24 -0700, Diego Biurrun wrote: > --- > libavcodec/arm/hpeldsp_init_arm.c | 2 +- > libavcodec/dsputil.h | 2 -- > libavcodec/dsputil_template.c | 2 ++ > libavcodec/hpel_template.c | 2 ++ > libavcodec/hpeldsp_template.c | 2 ++ > libavcodec/{rnd_avg.h => pixels.h} | 35 --- > libavcodec/rnd_avg.h | 8 > libavcodec/x86/dsputil_init.c | 5 +++-- > libavcodec/x86/dsputil_x86.h | 12 > libavcodec/x86/h264_qpel.c | 5 +++-- > libavcodec/x86/hpeldsp_init.c | 36 ++-- > libavcodec/x86/rnd_mmx.c | 5 +++-- > 12 files changed, 46 insertions(+), 70 deletions(-) > copy libavcodec/{rnd_avg.h => pixels.h} (56%) > > diff --git a/libavcodec/arm/hpeldsp_init_arm.c > b/libavcodec/arm/hpeldsp_init_arm.c > index c675166..6390660 100644 > --- a/libavcodec/arm/hpeldsp_init_arm.c > +++ b/libavcodec/arm/hpeldsp_init_arm.c > @@ -21,7 +21,7 @@ > > #include "libavutil/arm/cpu.h" > #include "libavutil/attributes.h" > -#include "libavcodec/rnd_avg.h" > +#include "libavcodec/pixels.h" > #include "hpeldsp_arm.h" > > void ff_put_pixels8_arm(uint8_t *block, const uint8_t *pixels, ptrdiff_t > line_size, int h); > diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h > index b712d49..d596e29 100644 > --- a/libavcodec/dsputil.h > +++ b/libavcodec/dsputil.h > @@ -31,7 +31,6 @@ > #define AVCODEC_DSPUTIL_H > > #include "avcodec.h" > -#include "rnd_avg.h" > > /* encoding scans */ > extern const uint8_t ff_alternate_horizontal_scan[64]; > @@ -40,7 +39,6 @@ extern const uint8_t ff_zigzag248_direct[64]; > > extern uint32_t ff_square_tab[512]; > > -/* pixel operations */ > void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride); > void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride); > void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride); > diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c > index f6e03ec..56f41ad 100644 > --- a/libavcodec/dsputil_template.c > +++ b/libavcodec/dsputil_template.c > @@ -27,6 +27,8 @@ > * DSP utils > */ > > +#include "pixels.h" > + > #include "bit_depth_template.c" > > #if BIT_DEPTH == 8 > diff --git a/libavcodec/hpel_template.c b/libavcodec/hpel_template.c > index 0d90445..1bc18cc 100644 > --- a/libavcodec/hpel_template.c > +++ b/libavcodec/hpel_template.c > @@ -19,6 +19,8 @@ > * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > */ > > +#include "pixels.h" > + > #define DEF_HPEL(OPNAME, OP)\ > static inline void FUNCC(OPNAME ## _pixels2)(uint8_t *block,\ > const uint8_t *pixels, \ > diff --git a/libavcodec/hpeldsp_template.c b/libavcodec/hpeldsp_template.c > index 9456490..f190457 100644 > --- a/libavcodec/hpeldsp_template.c > +++ b/libavcodec/hpeldsp_template.c > @@ -28,6 +28,8 @@ > * Half-pel DSP functions > */ > > +#include "pixels.h" > + > #include "bit_depth_template.c" > > #include "hpel_template.c" > diff --git a/libavcodec/rnd_avg.h b/libavcodec/pixels.h > similarity index 56% > copy from libavcodec/rnd_avg.h > copy to libavcodec/pixels.h > index 8feac28..d9d2fde 100644 > --- a/libavcodec/rnd_avg.h > +++ b/libavcodec/pixels.h > @@ -16,41 +16,22 @@ > * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > */ > > -#ifndef AVCODEC_RND_AVG_H > -#define AVCODEC_RND_AVG_H > +#ifndef AVCODEC_PIXELS_H > +#define AVCODEC_PIXELS_H > > #include > #include > > -#define CALL_2X_PIXELS(a, b, n) \ > -static void a(uint8_t *block, const uint8_t *pixels, \ > +/* pixel operations */ > +#define CALL_2X_PIXELS_MACRO(STATIC, a, b, n)\ > +STATIC void a(uint8_t *block, const uint8_t *pixels, \ >ptrdiff_t line_size, int h)\ > {\ > b(block, pixels, line_size, h); \ > b(block + n, pixels + n, line_size, h); \ > } > > -#define BYTE_VEC32(c) ((c) * 0x01010101UL) > -#define BYTE_VEC64(c) ((c) * 0x0001000100010001UL) > +#define CALL_2X_PIXELS(a, b, n) CALL_2X_PIXELS_MACRO(static, a, b, n) > +#define CALL_2X_PIXELS_EXPORT(a, b, n) CALL_2X_PIXELS_MACRO(, a, b, n) > > -static inline uint32_t rnd_avg32(uint32_t a, uint32_t b) > -{ > -return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1); > -} > - > -static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b) > -{ > -return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1); > -} > - > -static inline uint64_t rnd_avg64(uint64_t a, uint64_t b) > -{ > -return (a | b) - (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1); > -} > - > -static inline uint64_t no_rnd_avg64(uint64_t a, uint64_t b) > -{ > -return (a & b) + (((a ^ b) & ~BYTE_VEC64(
Re: [libav-devel] [PATCH 069/132] dsputil: Refactor duplicated CALL_2X_PIXELS / PIXELS16 macros
On 14/03/14 13:42, Diego Biurrun wrote: > --- > libavcodec/arm/hpeldsp_init_arm.c | 2 +- > libavcodec/dsputil.h | 2 -- > libavcodec/dsputil_template.c | 2 ++ > libavcodec/hpel_template.c | 2 ++ > libavcodec/hpeldsp_template.c | 2 ++ > libavcodec/{rnd_avg.h => pixels.h} | 35 --- > libavcodec/rnd_avg.h | 8 > libavcodec/x86/dsputil_init.c | 5 +++-- > libavcodec/x86/dsputil_x86.h | 12 > libavcodec/x86/h264_qpel.c | 5 +++-- > libavcodec/x86/hpeldsp_init.c | 36 ++-- > libavcodec/x86/rnd_mmx.c | 5 +++-- > 12 files changed, 46 insertions(+), 70 deletions(-) > copy libavcodec/{rnd_avg.h => pixels.h} (56%) Probably ok. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 069/132] dsputil: Refactor duplicated CALL_2X_PIXELS / PIXELS16 macros
--- libavcodec/arm/hpeldsp_init_arm.c | 2 +- libavcodec/dsputil.h | 2 -- libavcodec/dsputil_template.c | 2 ++ libavcodec/hpel_template.c | 2 ++ libavcodec/hpeldsp_template.c | 2 ++ libavcodec/{rnd_avg.h => pixels.h} | 35 --- libavcodec/rnd_avg.h | 8 libavcodec/x86/dsputil_init.c | 5 +++-- libavcodec/x86/dsputil_x86.h | 12 libavcodec/x86/h264_qpel.c | 5 +++-- libavcodec/x86/hpeldsp_init.c | 36 ++-- libavcodec/x86/rnd_mmx.c | 5 +++-- 12 files changed, 46 insertions(+), 70 deletions(-) copy libavcodec/{rnd_avg.h => pixels.h} (56%) diff --git a/libavcodec/arm/hpeldsp_init_arm.c b/libavcodec/arm/hpeldsp_init_arm.c index c675166..6390660 100644 --- a/libavcodec/arm/hpeldsp_init_arm.c +++ b/libavcodec/arm/hpeldsp_init_arm.c @@ -21,7 +21,7 @@ #include "libavutil/arm/cpu.h" #include "libavutil/attributes.h" -#include "libavcodec/rnd_avg.h" +#include "libavcodec/pixels.h" #include "hpeldsp_arm.h" void ff_put_pixels8_arm(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h); diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index b712d49..d596e29 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -31,7 +31,6 @@ #define AVCODEC_DSPUTIL_H #include "avcodec.h" -#include "rnd_avg.h" /* encoding scans */ extern const uint8_t ff_alternate_horizontal_scan[64]; @@ -40,7 +39,6 @@ extern const uint8_t ff_zigzag248_direct[64]; extern uint32_t ff_square_tab[512]; -/* pixel operations */ void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride); void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride); void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride); diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index f6e03ec..56f41ad 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -27,6 +27,8 @@ * DSP utils */ +#include "pixels.h" + #include "bit_depth_template.c" #if BIT_DEPTH == 8 diff --git a/libavcodec/hpel_template.c b/libavcodec/hpel_template.c index 0d90445..1bc18cc 100644 --- a/libavcodec/hpel_template.c +++ b/libavcodec/hpel_template.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "pixels.h" + #define DEF_HPEL(OPNAME, OP)\ static inline void FUNCC(OPNAME ## _pixels2)(uint8_t *block,\ const uint8_t *pixels, \ diff --git a/libavcodec/hpeldsp_template.c b/libavcodec/hpeldsp_template.c index 9456490..f190457 100644 --- a/libavcodec/hpeldsp_template.c +++ b/libavcodec/hpeldsp_template.c @@ -28,6 +28,8 @@ * Half-pel DSP functions */ +#include "pixels.h" + #include "bit_depth_template.c" #include "hpel_template.c" diff --git a/libavcodec/rnd_avg.h b/libavcodec/pixels.h similarity index 56% copy from libavcodec/rnd_avg.h copy to libavcodec/pixels.h index 8feac28..d9d2fde 100644 --- a/libavcodec/rnd_avg.h +++ b/libavcodec/pixels.h @@ -16,41 +16,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_RND_AVG_H -#define AVCODEC_RND_AVG_H +#ifndef AVCODEC_PIXELS_H +#define AVCODEC_PIXELS_H #include #include -#define CALL_2X_PIXELS(a, b, n) \ -static void a(uint8_t *block, const uint8_t *pixels, \ +/* pixel operations */ +#define CALL_2X_PIXELS_MACRO(STATIC, a, b, n)\ +STATIC void a(uint8_t *block, const uint8_t *pixels, \ ptrdiff_t line_size, int h)\ {\ b(block, pixels, line_size, h); \ b(block + n, pixels + n, line_size, h); \ } -#define BYTE_VEC32(c) ((c) * 0x01010101UL) -#define BYTE_VEC64(c) ((c) * 0x0001000100010001UL) +#define CALL_2X_PIXELS(a, b, n) CALL_2X_PIXELS_MACRO(static, a, b, n) +#define CALL_2X_PIXELS_EXPORT(a, b, n) CALL_2X_PIXELS_MACRO(, a, b, n) -static inline uint32_t rnd_avg32(uint32_t a, uint32_t b) -{ -return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1); -} - -static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b) -{ -return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1); -} - -static inline uint64_t rnd_avg64(uint64_t a, uint64_t b) -{ -return (a | b) - (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1); -} - -static inline uint64_t no_rnd_avg64(uint64_t a, uint64_t b) -{ -return (a & b) + (((a ^ b) & ~BYTE_VEC64(0x01)) >> 1); -} - -#endif /* AVCODEC_RND_AVG_H */ +#endif /* AVCODEC_PIXELS_H */ diff --git a/libavcodec/rnd_avg.h b/libavcodec/rnd_avg.h index 8feac28..412cda5 100644 --- a/libavcodec/rnd_avg.h +++ b/libavcodec/rnd_avg.h @@ -22,14 +22,6 @@ #include #include -#define CALL_2X_PIXELS(a, b, n) \ -static void a(uint8_t *block