Commit 5ff1b588 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'c2503d9c'

* commit 'c2503d9c':
  swscale: ppc: Hide arch-specific initialization details

Conflicts:
	libswscale/utils.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 4399e727 c2503d9c
ALTIVEC-OBJS += ppc/swscale_altivec.o \ OBJS += ppc/swscale_altivec.o \
ppc/yuv2rgb_altivec.o \ ppc/yuv2rgb_altivec.o \
ppc/yuv2yuv_altivec.o \ ppc/yuv2yuv_altivec.o \
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "libavutil/cpu.h" #include "libavutil/cpu.h"
#include "yuv2rgb_altivec.h" #include "yuv2rgb_altivec.h"
#if HAVE_ALTIVEC
#define vzero vec_splat_s32(0) #define vzero vec_splat_s32(0)
#define yuv2planeX_8(d1, d2, l1, src, x, perm, filter) do { \ #define yuv2planeX_8(d1, d2, l1, src, x, perm, filter) do { \
...@@ -284,9 +285,11 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW, ...@@ -284,9 +285,11 @@ static void hScale_altivec_real(SwsContext *c, int16_t *dst, int dstW,
} }
} }
} }
#endif /* HAVE_ALTIVEC */
av_cold void ff_sws_init_swScale_altivec(SwsContext *c) av_cold void ff_sws_init_swscale_ppc(SwsContext *c)
{ {
#if HAVE_ALTIVEC
enum AVPixelFormat dstFormat = c->dstFormat; enum AVPixelFormat dstFormat = c->dstFormat;
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
...@@ -325,4 +328,5 @@ av_cold void ff_sws_init_swScale_altivec(SwsContext *c) ...@@ -325,4 +328,5 @@ av_cold void ff_sws_init_swScale_altivec(SwsContext *c)
break; break;
} }
} }
#endif /* HAVE_ALTIVEC */
} }
...@@ -100,6 +100,8 @@ ...@@ -100,6 +100,8 @@
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "yuv2rgb_altivec.h" #include "yuv2rgb_altivec.h"
#if HAVE_ALTIVEC
#undef PROFILE_THE_BEAST #undef PROFILE_THE_BEAST
#undef INC_SCALING #undef INC_SCALING
...@@ -524,14 +526,17 @@ static int altivec_uyvy_rgb32(SwsContext *c, const unsigned char **in, ...@@ -524,14 +526,17 @@ static int altivec_uyvy_rgb32(SwsContext *c, const unsigned char **in,
return srcSliceH; return srcSliceH;
} }
#endif /* HAVE_ALTIVEC */
/* Ok currently the acceleration routine only supports /* Ok currently the acceleration routine only supports
* inputs of widths a multiple of 16 * inputs of widths a multiple of 16
* and heights a multiple 2 * and heights a multiple 2
* *
* So we just fall back to the C codes for this. * So we just fall back to the C codes for this.
*/ */
av_cold SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c) av_cold SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c)
{ {
#if HAVE_ALTIVEC
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return NULL; return NULL;
...@@ -587,20 +592,26 @@ av_cold SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c) ...@@ -587,20 +592,26 @@ av_cold SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c)
} }
break; break;
} }
#endif /* HAVE_ALTIVEC */
return NULL; return NULL;
} }
av_cold void ff_yuv2rgb_init_tables_altivec(SwsContext *c, av_cold void ff_yuv2rgb_init_tables_ppc(SwsContext *c,
const int inv_table[4], const int inv_table[4],
int brightness, int brightness,
int contrast, int contrast,
int saturation) int saturation)
{ {
#if HAVE_ALTIVEC
union { union {
DECLARE_ALIGNED(16, signed short, tmp)[8]; DECLARE_ALIGNED(16, signed short, tmp)[8];
vector signed short vec; vector signed short vec;
} buf; } buf;
if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))
return;
buf.tmp[0] = ((0xffffLL) * contrast >> 8) >> 9; // cy buf.tmp[0] = ((0xffffLL) * contrast >> 8) >> 9; // cy
buf.tmp[1] = -256 * brightness; // oy buf.tmp[1] = -256 * brightness; // oy
buf.tmp[2] = (inv_table[0] >> 3) * (contrast >> 16) * (saturation >> 16); // crv buf.tmp[2] = (inv_table[0] >> 3) * (contrast >> 16) * (saturation >> 16); // crv
...@@ -616,8 +627,11 @@ av_cold void ff_yuv2rgb_init_tables_altivec(SwsContext *c, ...@@ -616,8 +627,11 @@ av_cold void ff_yuv2rgb_init_tables_altivec(SwsContext *c,
c->CGU = vec_splat((vector signed short) buf.vec, 4); c->CGU = vec_splat((vector signed short) buf.vec, 4);
c->CGV = vec_splat((vector signed short) buf.vec, 5); c->CGV = vec_splat((vector signed short) buf.vec, 5);
return; return;
#endif /* HAVE_ALTIVEC */
} }
#if HAVE_ALTIVEC
static av_always_inline void yuv2packedX_altivec(SwsContext *c, static av_always_inline void yuv2packedX_altivec(SwsContext *c,
const int16_t *lumFilter, const int16_t *lumFilter,
const int16_t **lumSrc, const int16_t **lumSrc,
...@@ -850,3 +864,5 @@ YUV2PACKEDX_WRAPPER(argb, AV_PIX_FMT_ARGB); ...@@ -850,3 +864,5 @@ YUV2PACKEDX_WRAPPER(argb, AV_PIX_FMT_ARGB);
YUV2PACKEDX_WRAPPER(rgba, AV_PIX_FMT_RGBA); YUV2PACKEDX_WRAPPER(rgba, AV_PIX_FMT_RGBA);
YUV2PACKEDX_WRAPPER(rgb24, AV_PIX_FMT_RGB24); YUV2PACKEDX_WRAPPER(rgb24, AV_PIX_FMT_RGB24);
YUV2PACKEDX_WRAPPER(bgr24, AV_PIX_FMT_BGR24); YUV2PACKEDX_WRAPPER(bgr24, AV_PIX_FMT_BGR24);
#endif /* HAVE_ALTIVEC */
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "libswscale/swscale_internal.h" #include "libswscale/swscale_internal.h"
#include "libavutil/cpu.h" #include "libavutil/cpu.h"
#if HAVE_ALTIVEC
static int yv12toyuy2_unscaled_altivec(SwsContext *c, const uint8_t *src[], static int yv12toyuy2_unscaled_altivec(SwsContext *c, const uint8_t *src[],
int srcStride[], int srcSliceY, int srcStride[], int srcSliceY,
int srcSliceH, uint8_t *dstParam[], int srcSliceH, uint8_t *dstParam[],
...@@ -179,8 +181,11 @@ static int yv12touyvy_unscaled_altivec(SwsContext *c, const uint8_t *src[], ...@@ -179,8 +181,11 @@ static int yv12touyvy_unscaled_altivec(SwsContext *c, const uint8_t *src[],
return srcSliceH; return srcSliceH;
} }
void ff_swscale_get_unscaled_altivec(SwsContext *c) #endif /* HAVE_ALTIVEC */
void ff_swscale_get_unscaled_ppc(SwsContext *c)
{ {
#if HAVE_ALTIVEC
if ((av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) && !(c->srcW & 15) && if ((av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) && !(c->srcW & 15) &&
!(c->flags & SWS_BITEXACT) && c->srcFormat == AV_PIX_FMT_YUV420P) { !(c->flags & SWS_BITEXACT) && c->srcFormat == AV_PIX_FMT_YUV420P) {
enum AVPixelFormat dstFormat = c->dstFormat; enum AVPixelFormat dstFormat = c->dstFormat;
...@@ -191,4 +196,5 @@ void ff_swscale_get_unscaled_altivec(SwsContext *c) ...@@ -191,4 +196,5 @@ void ff_swscale_get_unscaled_altivec(SwsContext *c)
else if (dstFormat == AV_PIX_FMT_UYVY422) else if (dstFormat == AV_PIX_FMT_UYVY422)
c->swScale = yv12touyvy_unscaled_altivec; c->swScale = yv12touyvy_unscaled_altivec;
} }
#endif /* HAVE_ALTIVEC */
} }
...@@ -759,10 +759,10 @@ SwsFunc ff_getSwsFunc(SwsContext *c) ...@@ -759,10 +759,10 @@ SwsFunc ff_getSwsFunc(SwsContext *c)
{ {
sws_init_swScale_c(c); sws_init_swScale_c(c);
if (ARCH_PPC)
ff_sws_init_swscale_ppc(c);
if (ARCH_X86) if (ARCH_X86)
ff_sws_init_swscale_x86(c); ff_sws_init_swscale_x86(c);
if (HAVE_ALTIVEC)
ff_sws_init_swScale_altivec(c);
return swScale; return swScale;
} }
......
...@@ -610,15 +610,15 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c); ...@@ -610,15 +610,15 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c);
int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
int fullRange, int brightness, int fullRange, int brightness,
int contrast, int saturation); int contrast, int saturation);
void ff_yuv2rgb_init_tables_ppc(SwsContext *c, const int inv_table[4],
int brightness, int contrast, int saturation);
void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4],
int brightness, int contrast, int saturation);
void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex, void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
int lastInLumBuf, int lastInChrBuf); int lastInLumBuf, int lastInChrBuf);
SwsFunc ff_yuv2rgb_init_x86(SwsContext *c); SwsFunc ff_yuv2rgb_init_x86(SwsContext *c);
SwsFunc ff_yuv2rgb_init_vis(SwsContext *c); SwsFunc ff_yuv2rgb_init_vis(SwsContext *c);
SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c); SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c);
SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c); SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c);
void ff_bfin_get_unscaled_swscale(SwsContext *c); void ff_bfin_get_unscaled_swscale(SwsContext *c);
...@@ -833,7 +833,7 @@ extern const AVClass sws_context_class; ...@@ -833,7 +833,7 @@ extern const AVClass sws_context_class;
*/ */
void ff_get_unscaled_swscale(SwsContext *c); void ff_get_unscaled_swscale(SwsContext *c);
void ff_swscale_get_unscaled_altivec(SwsContext *c); void ff_swscale_get_unscaled_ppc(SwsContext *c);
/** /**
* Return function pointer to fastest main scaler path function depending * Return function pointer to fastest main scaler path function depending
...@@ -850,7 +850,7 @@ void ff_sws_init_output_funcs(SwsContext *c, ...@@ -850,7 +850,7 @@ void ff_sws_init_output_funcs(SwsContext *c,
yuv2packed2_fn *yuv2packed2, yuv2packed2_fn *yuv2packed2,
yuv2packedX_fn *yuv2packedX, yuv2packedX_fn *yuv2packedX,
yuv2anyX_fn *yuv2anyX); yuv2anyX_fn *yuv2anyX);
void ff_sws_init_swScale_altivec(SwsContext *c); void ff_sws_init_swscale_ppc(SwsContext *c);
void ff_sws_init_swscale_x86(SwsContext *c); void ff_sws_init_swscale_x86(SwsContext *c);
static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y, static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y,
......
...@@ -1320,8 +1320,8 @@ void ff_get_unscaled_swscale(SwsContext *c) ...@@ -1320,8 +1320,8 @@ void ff_get_unscaled_swscale(SwsContext *c)
if (ARCH_BFIN) if (ARCH_BFIN)
ff_bfin_get_unscaled_swscale(c); ff_bfin_get_unscaled_swscale(c);
if (HAVE_ALTIVEC) if (ARCH_PPC)
ff_swscale_get_unscaled_altivec(c); ff_swscale_get_unscaled_ppc(c);
} }
/* Convert the palette to the same packed 32-bit format as the palette */ /* Convert the palette to the same packed 32-bit format as the palette */
......
...@@ -991,9 +991,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], ...@@ -991,9 +991,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
contrast, saturation); contrast, saturation);
// FIXME factorize // FIXME factorize
if (PPC_ALTIVEC(av_get_cpu_flags())) if (ARCH_PPC)
ff_yuv2rgb_init_tables_altivec(c, inv_table, brightness, ff_yuv2rgb_init_tables_ppc(c, inv_table, brightness,
contrast, saturation); contrast, saturation);
} }
fill_rgb2yuv_table(c, table, dstRange); fill_rgb2yuv_table(c, table, dstRange);
......
...@@ -605,10 +605,10 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) ...@@ -605,10 +605,10 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
t = ff_yuv2rgb_init_x86(c); t = ff_yuv2rgb_init_x86(c);
else if (HAVE_VIS) else if (HAVE_VIS)
t = ff_yuv2rgb_init_vis(c); t = ff_yuv2rgb_init_vis(c);
else if (HAVE_ALTIVEC)
t = ff_yuv2rgb_init_altivec(c);
else if (ARCH_BFIN) else if (ARCH_BFIN)
t = ff_yuv2rgb_get_func_ptr_bfin(c); t = ff_yuv2rgb_get_func_ptr_bfin(c);
else if (ARCH_PPC)
t = ff_yuv2rgb_init_ppc(c);
if (t) if (t)
return t; return t;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment