[FFmpeg-devel] [PATCH] avutil/ppc: Add macro defination of vector types and vector
Michael Niedermayer
michaelni at gmx.at
Sun Feb 8 03:42:36 CET 2015
On Sat, Feb 07, 2015 at 11:12:17AM +0800, Zhenan Lin wrote:
> Hi,
>
>
>
> The attached patch add macro defination of vector types and vector base
> types. Add function printv for dev purpose. Our team is working on AltiVec
> functions for HEVC decoder.
>
>
>
> Best regards,
>
> Zhenan.
>
> types_altivec.h | 20 +++++++
> util_altivec.h | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 161 insertions(+), 2 deletions(-)
> 1210d26fbf3977539f707d4b976e93b342e7a945 avutil-ppc-Add-macro-defination-of-vector-types.patch
> From c3cf6716e144709af7e3768e7ba37697ba3fee7d Mon Sep 17 00:00:00 2001
> From: SO_Random_User <weavbd at sovmp224.lop.siteox.com>
Is this Author name intended ?
> Date: Sat, 7 Feb 2015 03:00:10 +0000
> Subject: [PATCH] avutil/ppc: Add macro defination of vector types and vector
> base types. Add function printv for dev purpose.
>
> ---
> libavutil/ppc/types_altivec.h | 20 +++++-
> libavutil/ppc/util_altivec.h | 143 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 161 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/ppc/types_altivec.h b/libavutil/ppc/types_altivec.h
> index 69d8957..b39f25a 100644
> --- a/libavutil/ppc/types_altivec.h
> +++ b/libavutil/ppc/types_altivec.h
> @@ -30,18 +30,34 @@
> #define vec_s16 vector signed short
> #define vec_u32 vector unsigned int
> #define vec_s32 vector signed int
> +#define vec_u64 vector unsigned long long
> +#define vec_s64 vector signed long long
> #define vec_f vector float
> -
> +#define vec_d vector double
> /***********************************************************************
> + * Vector base types
> + **********************************************************************/
> +#define u8i unsigned char
> +#define s8i signed char
> +#define u16i unsigned short
> +#define s16i signed short
> +#define u32i unsigned int
> +#define s32i signed int
> +#define u64i unsigned long long
> +#define s64i signed long long
> +/**********************************************************************
> * Null vector
> **********************************************************************/
> #define LOAD_ZERO const vec_u8 zerov = vec_splat_u8( 0 )
> -
> #define zero_u8v (vec_u8) zerov
> #define zero_s8v (vec_s8) zerov
> #define zero_u16v (vec_u16) zerov
> #define zero_s16v (vec_s16) zerov
> #define zero_u32v (vec_u32) zerov
> #define zero_s32v (vec_s32) zerov
> +#define zero_u64v (vec_u64) zerov
> +#define zero_s64v (vec_s64) zerov
> +#define zero_fv (vec_f) zerov
> +#define zero_dv (vec_d) zerov
>
> #endif /* AVUTIL_PPC_TYPES_ALTIVEC_H */
> diff --git a/libavutil/ppc/util_altivec.h b/libavutil/ppc/util_altivec.h
> index 51a4e8c..89427c2 100644
> --- a/libavutil/ppc/util_altivec.h
> +++ b/libavutil/ppc/util_altivec.h
> @@ -160,6 +160,149 @@ static inline vec_u8 load_with_perm_vec(int offset, const uint8_t *src, vec_u8 p
> #define VEC_SLD16(a,b,c) vec_sld(b, a, c)
> #endif
>
> +/**
> + * printf for vector
> + * fmt : u8v, s8v, u16v, s16v, u32v, s32v, u64v, s64v, fv, dv
> + */
> +#include <stdio.h>
> +#include <stdarg.h>
> +#include <string.h>
> +static inline void printfv(char *fmt, ...)
> +{
> + int i = 0;
> + int fmt_len = strlen(fmt);
> +
> + int j = 0;
> + char bt_str[5] = {0};
> + int bt_flg = 1;
> +
> + int k = 0;
> +
> +
> + vec_u8 v;
> +
> + va_list argptr;
> + va_start(argptr, fmt);
> +
> + for ( i = 0; i < fmt_len; i++ )
> + {
> + if ( fmt[i] == '%' )
> + {
> + j = 0;
> + v = (vec_u8)va_arg(argptr, vec_u8);
> + bt_flg = 1;
> + while ( bt_flg )
> + {
> + i++;
> + switch( fmt[i] )
> + {
> + case 'u':
> + case 's':
> + case 'f':
> + case 'd':
> + case '1':
> + case '2':
> + case '3':
> + case '4':
> + case '6':
> + case '8':
> + case 'v': bt_str[j++] = fmt[i]; bt_str[j] = '\0'; break;
> + default: bt_flg = 0; break;
> + }
> +
> + if (j == 2)
> + {
> + if ( strcmp(bt_str, "fv") == 0 )
> + {
> + printf("{");
> + for(k = 0; k < sizeof(vec_u8) / sizeof(float) - 1; k++)
> + printf("%.7f,", *((float*)&v + k));
> + printf("%.7f}", *((float*)&v + k));
av_log() or fprintf(stderr, ...) is probably a better choice than
printf(), printf() would even interfere with using stdout as output
for the transcoding
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150208/143cec43/attachment.asc>
More information about the ffmpeg-devel
mailing list