swscale: K&R formatting cosmetics for PowerPC code (part II/II)

This commit is contained in:
Diego Biurrun 2012-02-21 19:59:38 +01:00
parent c05e2be9a2
commit 36697be187
1 changed files with 622 additions and 592 deletions

View File

@ -21,68 +21,68 @@
*/
/*
Convert I420 YV12 to RGB in various formats,
it rejects images that are not in 420 formats,
it rejects images that don't have widths of multiples of 16,
it rejects images that don't have heights of multiples of 2.
Reject defers to C simulation code.
Lots of optimizations to be done here.
1. Need to fix saturation code. I just couldn't get it to fly with packs
and adds, so we currently use max/min to clip.
2. The inefficient use of chroma loading needs a bit of brushing up.
3. Analysis of pipeline stalls needs to be done. Use shark to identify
pipeline stalls.
MODIFIED to calculate coeffs from currently selected color space.
MODIFIED core to be a macro where you specify the output format.
ADDED UYVY conversion which is never called due to some thing in swscale.
CORRECTED algorithim selection to be strict on input formats.
ADDED runtime detection of AltiVec.
ADDED altivec_yuv2packedX vertical scl + RGB converter
March 27,2004
PERFORMANCE ANALYSIS
The C version uses 25% of the processor or ~250Mips for D1 video rawvideo
used as test.
The AltiVec version uses 10% of the processor or ~100Mips for D1 video
same sequence.
720 * 480 * 30 ~10MPS
so we have roughly 10 clocks per pixel. This is too high, something has
to be wrong.
OPTIMIZED clip codes to utilize vec_max and vec_packs removing the
need for vec_min.
OPTIMIZED DST OUTPUT cache/DMA controls. We are pretty much guaranteed to have
the input video frame, it was just decompressed so it probably resides in L1
caches. However, we are creating the output video stream. This needs to use the
DSTST instruction to optimize for the cache. We couple this with the fact that
we are not going to be visiting the input buffer again so we mark it Least
Recently Used. This shaves 25% of the processor cycles off.
Now memcpy is the largest mips consumer in the system, probably due
to the inefficient X11 stuff.
GL libraries seem to be very slow on this machine 1.33Ghz PB running
Jaguar, this is not the case for my 1Ghz PB. I thought it might be
a versioning issue, however I have libGL.1.2.dylib for both
machines. (We need to figure this out now.)
GL2 libraries work now with patch for RGB32.
NOTE: quartz vo driver ARGB32_to_RGB24 consumes 30% of the processor.
Integrated luma prescaling adjustment for saturation/contrast/brightness
adjustment.
* Convert I420 YV12 to RGB in various formats,
* it rejects images that are not in 420 formats,
* it rejects images that don't have widths of multiples of 16,
* it rejects images that don't have heights of multiples of 2.
* Reject defers to C simulation code.
*
* Lots of optimizations to be done here.
*
* 1. Need to fix saturation code. I just couldn't get it to fly with packs
* and adds, so we currently use max/min to clip.
*
* 2. The inefficient use of chroma loading needs a bit of brushing up.
*
* 3. Analysis of pipeline stalls needs to be done. Use shark to identify
* pipeline stalls.
*
*
* MODIFIED to calculate coeffs from currently selected color space.
* MODIFIED core to be a macro where you specify the output format.
* ADDED UYVY conversion which is never called due to some thing in swscale.
* CORRECTED algorithim selection to be strict on input formats.
* ADDED runtime detection of AltiVec.
*
* ADDED altivec_yuv2packedX vertical scl + RGB converter
*
* March 27,2004
* PERFORMANCE ANALYSIS
*
* The C version uses 25% of the processor or ~250Mips for D1 video rawvideo
* used as test.
* The AltiVec version uses 10% of the processor or ~100Mips for D1 video
* same sequence.
*
* 720 * 480 * 30 ~10MPS
*
* so we have roughly 10 clocks per pixel. This is too high, something has
* to be wrong.
*
* OPTIMIZED clip codes to utilize vec_max and vec_packs removing the
* need for vec_min.
*
* OPTIMIZED DST OUTPUT cache/DMA controls. We are pretty much guaranteed to
* have the input video frame, it was just decompressed so it probably resides
* in L1 caches. However, we are creating the output video stream. This needs
* to use the DSTST instruction to optimize for the cache. We couple this with
* the fact that we are not going to be visiting the input buffer again so we
* mark it Least Recently Used. This shaves 25% of the processor cycles off.
*
* Now memcpy is the largest mips consumer in the system, probably due
* to the inefficient X11 stuff.
*
* GL libraries seem to be very slow on this machine 1.33Ghz PB running
* Jaguar, this is not the case for my 1Ghz PB. I thought it might be
* a versioning issue, however I have libGL.1.2.dylib for both
* machines. (We need to figure this out now.)
*
* GL2 libraries work now with patch for RGB32.
*
* NOTE: quartz vo driver ARGB32_to_RGB24 consumes 30% of the processor.
*
* Integrated luma prescaling adjustment for saturation/contrast/brightness
* adjustment.
*/
#include <stdio.h>
@ -90,6 +90,7 @@ adjustment.
#include <string.h>
#include <inttypes.h>
#include <assert.h>
#include "config.h"
#include "libswscale/rgb2rgb.h"
#include "libswscale/swscale.h"
@ -103,45 +104,43 @@ adjustment.
typedef unsigned char ubyte;
typedef signed char sbyte;
/* RGB interleaver, 16 planar pels 8-bit samples per channel in
homogeneous vector registers x0,x1,x2 are interleaved with the
following technique:
o0 = vec_mergeh (x0,x1);
o1 = vec_perm (o0, x2, perm_rgb_0);
o2 = vec_perm (o0, x2, perm_rgb_1);
o3 = vec_mergel (x0,x1);
o4 = vec_perm (o3,o2,perm_rgb_2);
o5 = vec_perm (o3,o2,perm_rgb_3);
perm_rgb_0: o0(RG).h v1(B) --> o1*
0 1 2 3 4
rgbr|gbrg|brgb|rgbr
0010 0100 1001 0010
0102 3145 2673 894A
perm_rgb_1: o0(RG).h v1(B) --> o2
0 1 2 3 4
gbrg|brgb|bbbb|bbbb
0100 1001 1111 1111
B5CD 6EF7 89AB CDEF
perm_rgb_2: o3(RG).l o2(rgbB.l) --> o4*
0 1 2 3 4
gbrg|brgb|rgbr|gbrg
1111 1111 0010 0100
89AB CDEF 0182 3945
perm_rgb_2: o3(RG).l o2(rgbB.l) ---> o5*
0 1 2 3 4
brgb|rgbr|gbrg|brgb
1001 0010 0100 1001
a67b 89cA BdCD eEFf
* homogeneous vector registers x0,x1,x2 are interleaved with the
* following technique:
*
* o0 = vec_mergeh(x0, x1);
* o1 = vec_perm(o0, x2, perm_rgb_0);
* o2 = vec_perm(o0, x2, perm_rgb_1);
* o3 = vec_mergel(x0, x1);
* o4 = vec_perm(o3, o2, perm_rgb_2);
* o5 = vec_perm(o3, o2, perm_rgb_3);
*
* perm_rgb_0: o0(RG).h v1(B) --> o1*
* 0 1 2 3 4
* rgbr|gbrg|brgb|rgbr
* 0010 0100 1001 0010
* 0102 3145 2673 894A
*
* perm_rgb_1: o0(RG).h v1(B) --> o2
* 0 1 2 3 4
* gbrg|brgb|bbbb|bbbb
* 0100 1001 1111 1111
* B5CD 6EF7 89AB CDEF
*
* perm_rgb_2: o3(RG).l o2(rgbB.l) --> o4*
* 0 1 2 3 4
* gbrg|brgb|rgbr|gbrg
* 1111 1111 0010 0100
* 89AB CDEF 0182 3945
*
* perm_rgb_2: o3(RG).l o2(rgbB.l) ---> o5*
* 0 1 2 3 4
* brgb|rgbr|gbrg|brgb
* 1001 0010 0100 1001
* a67b 89cA BdCD eEFf
*
*/
static
const vector unsigned char
static const vector unsigned char
perm_rgb_0 = { 0x00, 0x01, 0x10, 0x02, 0x03, 0x11, 0x04, 0x05,
0x12, 0x06, 0x07, 0x13, 0x08, 0x09, 0x14, 0x0a },
perm_rgb_1 = { 0x0b, 0x15, 0x0c, 0x0d, 0x16, 0x0e, 0x0f, 0x17,
@ -181,70 +180,76 @@ do { \
} while (0)
/* pack the pixels in rgb0 format
msb R
lsb 0
* msb R
* lsb 0
*/
#define vec_mstrgb32(T, x0, x1, x2, x3, ptr) \
do { \
T _0, _1, _2, _3; \
_0 = vec_mergeh(x0, x1); \
_1 = vec_mergeh(x2, x3); \
_2 = (T)vec_mergeh ((vector unsigned short)_0,(vector unsigned short)_1); \
_3 = (T)vec_mergel ((vector unsigned short)_0,(vector unsigned short)_1); \
_2 = (T) vec_mergeh((vector unsigned short) _0, \
(vector unsigned short) _1); \
_3 = (T) vec_mergel((vector unsigned short) _0, \
(vector unsigned short) _1); \
vec_st(_2, 0 * 16, (T *) ptr); \
vec_st(_3, 1 * 16, (T *) ptr); \
_0 = vec_mergel(x0, x1); \
_1 = vec_mergel(x2, x3); \
_2 = (T)vec_mergeh ((vector unsigned short)_0,(vector unsigned short)_1); \
_3 = (T)vec_mergel ((vector unsigned short)_0,(vector unsigned short)_1); \
_2 = (T) vec_mergeh((vector unsigned short) _0, \
(vector unsigned short) _1); \
_3 = (T) vec_mergel((vector unsigned short) _0, \
(vector unsigned short) _1); \
vec_st(_2, 2 * 16, (T *) ptr); \
vec_st(_3, 3 * 16, (T *) ptr); \
ptr += 4; \
} while (0)
/*
| 1 0 1.4021 | | Y |
| 1 -0.3441 -0.7142 |x| Cb|
| 1 1.7718 0 | | Cr|
Y: [-128 127]
Cb/Cr : [-128 127]
typical yuv conversion work on Y: 0-255 this version has been optimized for jpeg decode.
* 1 0 1.4021 | | Y |
* 1 -0.3441 -0.7142 |x| Cb|
* 1 1.7718 0 | | Cr|
*
*
* Y: [-128 127]
* Cb/Cr : [-128 127]
*
* typical YUV conversion works on Y: 0-255 this version has been
* optimized for JPEG decoding.
*/
#define vec_unh(x) \
(vector signed short) \
vec_perm(x, (__typeof__(x)) { 0 }, \
((vector unsigned char){0x10,0x00,0x10,0x01,0x10,0x02,0x10,0x03,\
((vector unsigned char) { \
0x10, 0x00, 0x10, 0x01, 0x10, 0x02, 0x10, 0x03, \
0x10, 0x04, 0x10, 0x05, 0x10, 0x06, 0x10, 0x07 }))
#define vec_unl(x) \
(vector signed short) \
vec_perm(x, (__typeof__(x)) { 0 }, \
((vector unsigned char){0x10,0x08,0x10,0x09,0x10,0x0A,0x10,0x0B,\
((vector unsigned char) { \
0x10, 0x08, 0x10, 0x09, 0x10, 0x0A, 0x10, 0x0B, \
0x10, 0x0C, 0x10, 0x0D, 0x10, 0x0E, 0x10, 0x0F }))
#define vec_clip_s16(x) \
vec_max (vec_min (x, ((vector signed short){235,235,235,235,235,235,235,235})), \
vec_max(vec_min(x, ((vector signed short) { \
235, 235, 235, 235, 235, 235, 235, 235 })), \
((vector signed short) { 16, 16, 16, 16, 16, 16, 16, 16 }))
#define vec_packclp(x, y) \
(vector unsigned char)vec_packs \
((vector unsigned short)vec_max (x,((vector signed short) {0})), \
(vector unsigned short)vec_max (y,((vector signed short) {0})))
(vector unsigned char) \
vec_packs((vector unsigned short) \
vec_max(x, ((vector signed short) { 0 })), \
(vector unsigned short) \
vec_max(y, ((vector signed short) { 0 })))
//#define out_pixels(a, b, c, ptr) vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), a, a, a, ptr)
static inline void cvtyuvtoRGB (SwsContext *c,
vector signed short Y, vector signed short U, vector signed short V,
vector signed short *R, vector signed short *G, vector signed short *B)
static inline void cvtyuvtoRGB(SwsContext *c, vector signed short Y,
vector signed short U, vector signed short V,
vector signed short *R, vector signed short *G,
vector signed short *B)
{
vector signed short vx, ux, uvx;
@ -267,18 +272,15 @@ static inline void cvtyuvtoRGB (SwsContext *c,
*G = vec_mradds(V, c->CGV, uvx);
}
/*
------------------------------------------------------------------------------
CS converters
------------------------------------------------------------------------------
* ------------------------------------------------------------------------------
* CS converters
* ------------------------------------------------------------------------------
*/
#define DEFCSP420_CVT(name, out_pixels) \
static int altivec_##name (SwsContext *c, \
const unsigned char **in, int *instrides, \
int srcSliceY, int srcSliceH, \
static int altivec_ ## name(SwsContext *c, const unsigned char **in, \
int *instrides, int srcSliceY, int srcSliceH, \
unsigned char **oplanes, int *outstrides) \
{ \
int w = c->srcW; \
@ -301,14 +303,12 @@ static int altivec_##name (SwsContext *c, \
vector unsigned char *y1ivP, *y2ivP, *uivP, *vivP; \
vector unsigned char align_perm; \
\
vector signed short \
lCY = c->CY, \
lOY = c->OY, \
lCRV = c->CRV, \
lCBU = c->CBU, \
lCGU = c->CGU, \
lCGV = c->CGV; \
\
vector signed short lCY = c->CY; \
vector signed short lOY = c->OY; \
vector signed short lCRV = c->CRV; \
vector signed short lCBU = c->CBU; \
vector signed short lCGU = c->CGU; \
vector signed short lCGV = c->CGV; \
vector unsigned short lCSHIFT = c->CSHIFT; \
\
const ubyte *y1i = in[0]; \
@ -316,25 +316,25 @@ static int altivec_##name (SwsContext *c, \
const ubyte *ui = in[1]; \
const ubyte *vi = in[2]; \
\
vector unsigned char *oute \
= (vector unsigned char *) \
vector unsigned char *oute = \
(vector unsigned char *) \
(oplanes[0] + srcSliceY * outstrides[0]); \
vector unsigned char *outo \
= (vector unsigned char *) \
vector unsigned char *outo = \
(vector unsigned char *) \
(oplanes[0] + srcSliceY * outstrides[0] + outstrides[0]); \
\
\
instrides_scl[0] = instrides[0]*2-w; /* the loop moves y{1,2}i by w */ \
instrides_scl[1] = instrides[1]-w/2; /* the loop moves ui by w/2 */ \
instrides_scl[2] = instrides[2]-w/2; /* the loop moves vi by w/2 */ \
\
/* loop moves y{1, 2}i by w */ \
instrides_scl[0] = instrides[0] * 2 - w; \
/* loop moves ui by w / 2 */ \
instrides_scl[1] = instrides[1] - w / 2; \
/* loop moves vi by w / 2 */ \
instrides_scl[2] = instrides[2] - w / 2; \
\
for (i = 0; i < h / 2; i++) { \
vec_dstst(outo, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 0); \
vec_dstst(oute, (0x02000002 | (((w * 3 + 32) / 32) << 16)), 1); \
\
for (j = 0; j < w / 16; j++) { \
\
y1ivP = (vector unsigned char *) y1i; \
y2ivP = (vector unsigned char *) y2i; \
uivP = (vector unsigned char *) ui; \
@ -357,16 +357,17 @@ static int altivec_##name (SwsContext *c, \
vec_perm(vivP[0], vivP[1], align_perm); \
\
u = (vector signed char) \
vec_sub (u,(vector signed char) \
vec_sub(u, \
(vector signed char) \
vec_splat((vector signed char) { 128 }, 0)); \
v = (vector signed char) \
vec_sub (v,(vector signed char) \
vec_sub(v, \
(vector signed char) \
vec_splat((vector signed char) { 128 }, 0)); \
\
U = vec_unpackh(u); \
V = vec_unpackh(v); \
\
\
Y0 = vec_unh(y0); \
Y1 = vec_unl(y0); \
Y2 = vec_unh(y1); \
@ -425,7 +426,6 @@ static int altivec_##name (SwsContext *c, \
y2i += 16; \
ui += 8; \
vi += 8; \
\
} \
\
outo += (outstrides[0]) >> 4; \
@ -439,11 +439,14 @@ static int altivec_##name (SwsContext *c, \
return srcSliceH; \
}
#define out_abgr(a,b,c,ptr) vec_mstrgb32(__typeof__(a),((__typeof__ (a)){255}),c,b,a,ptr)
#define out_bgra(a,b,c,ptr) vec_mstrgb32(__typeof__(a),c,b,a,((__typeof__ (a)){255}),ptr)
#define out_rgba(a,b,c,ptr) vec_mstrgb32(__typeof__(a),a,b,c,((__typeof__ (a)){255}),ptr)
#define out_argb(a,b,c,ptr) vec_mstrgb32(__typeof__(a),((__typeof__ (a)){255}),a,b,c,ptr)
#define out_abgr(a, b, c, ptr) \
vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), c, b, a, ptr)
#define out_bgra(a, b, c, ptr) \
vec_mstrgb32(__typeof__(a), c, b, a, ((__typeof__(a)) { 255 }), ptr)
#define out_rgba(a, b, c, ptr) \
vec_mstrgb32(__typeof__(a), a, b, c, ((__typeof__(a)) { 255 }), ptr)
#define out_argb(a, b, c, ptr) \
vec_mstrgb32(__typeof__(a), ((__typeof__(a)) { 255 }), a, b, c, ptr)
#define out_rgb24(a, b, c, ptr) vec_mstrgb24(a, b, c, ptr)
#define out_bgr24(a, b, c, ptr) vec_mstbgr24(a, b, c, ptr)
@ -454,11 +457,9 @@ DEFCSP420_CVT (yuv2_argb, out_argb)
DEFCSP420_CVT(yuv2_rgb24, out_rgb24)
DEFCSP420_CVT(yuv2_bgr24, out_bgr24)
// uyvy|uyvy|uyvy|uyvy
// 0123 4567 89ab cdef
static
const vector unsigned char
static const vector unsigned char
demux_u = { 0x10, 0x00, 0x10, 0x00,
0x10, 0x04, 0x10, 0x04,
0x10, 0x08, 0x10, 0x08,
@ -473,11 +474,10 @@ const vector unsigned char
0x10, 0x0D, 0x10, 0x0F };
/*
this is so I can play live CCIR raw video
* this is so I can play live CCIR raw video
*/
static int altivec_uyvy_rgb32 (SwsContext *c,
const unsigned char **in, int *instrides,
int srcSliceY, int srcSliceH,
static int altivec_uyvy_rgb32(SwsContext *c, const unsigned char **in,
int *instrides, int srcSliceY, int srcSliceH,
unsigned char **oplanes, int *outstrides)
{
int w = c->srcW;
@ -493,27 +493,25 @@ static int altivec_uyvy_rgb32 (SwsContext *c,
img = in[0];
out = (vector unsigned char *) (oplanes[0] + srcSliceY * outstrides[0]);
for (i=0;i<h;i++) {
for (i = 0; i < h; i++)
for (j = 0; j < w / 16; j++) {
uyvy = vec_ld(0, img);
U = (vector signed short)
vec_perm(uyvy, (vector unsigned char) { 0 }, demux_u);
V = (vector signed short)
vec_perm(uyvy, (vector unsigned char) { 0 }, demux_v);
Y = (vector signed short)
vec_perm(uyvy, (vector unsigned char) { 0 }, demux_y);
cvtyuvtoRGB(c, Y, U, V, &R0, &G0, &B0);
uyvy = vec_ld(16, img);
U = (vector signed short)
vec_perm(uyvy, (vector unsigned char) { 0 }, demux_u);
V = (vector signed short)
vec_perm(uyvy, (vector unsigned char) { 0 }, demux_v);
Y = (vector signed short)
vec_perm(uyvy, (vector unsigned char) { 0 }, demux_y);
@ -528,17 +526,14 @@ static int altivec_uyvy_rgb32 (SwsContext *c,
img += 32;
}
}
return srcSliceH;
}
/* Ok currently the acceleration routine only supports
inputs of widths a multiple of 16
and heights a multiple 2
So we just fall back to the C codes for this.
* inputs of widths a multiple of 16
* and heights a multiple 2
*
* So we just fall back to the C codes for this.
*/
SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c)
{
@ -546,13 +541,14 @@ SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c)
return NULL;
/*
and this seems not to matter too much I tried a bunch of
videos with abnormal widths and MPlayer crashes elsewhere.
mplayer -vo x11 -rawvideo on:w=350:h=240 raw-350x240.eyuv
boom with X11 bad match.
* and this seems not to matter too much I tried a bunch of
* videos with abnormal widths and MPlayer crashes elsewhere.
* mplayer -vo x11 -rawvideo on:w=350:h=240 raw-350x240.eyuv
* boom with X11 bad match.
*
*/
if ((c->srcW & 0xf) != 0) return NULL;
if ((c->srcW & 0xf) != 0)
return NULL;
switch (c->srcFormat) {
case PIX_FMT_YUV410P:
@ -595,12 +591,13 @@ SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c)
default: return NULL;
}
break;
}
return NULL;
}
void ff_yuv2rgb_init_tables_altivec(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)
{
union {
DECLARE_ALIGNED(16, signed short, tmp)[8];
@ -614,7 +611,6 @@ void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4], int b
buf.tmp[4] = -((inv_table[2] >> 1) * (contrast >> 16) * (saturation >> 16)); // cgu
buf.tmp[5] = -((inv_table[3] >> 1) * (contrast >> 16) * (saturation >> 16)); // cgv
c->CSHIFT = (vector unsigned short) vec_splat_u16(2);
c->CY = vec_splat((vector signed short) buf.vec, 0);
c->OY = vec_splat((vector signed short) buf.vec, 1);
@ -625,14 +621,18 @@ void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4], int b
return;
}
static av_always_inline void
ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter,
const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrUSrc,
const int16_t **chrVSrc, int chrFilterSize,
const int16_t **alpSrc, uint8_t *dest,
int dstW, int dstY, enum PixelFormat target)
static av_always_inline void ff_yuv2packedX_altivec(SwsContext *c,
const int16_t *lumFilter,
const int16_t **lumSrc,
int lumFilterSize,
const int16_t *chrFilter,
const int16_t **chrUSrc,
const int16_t **chrVSrc,
int chrFilterSize,
const int16_t **alpSrc,
uint8_t *dest,
int dstW, int dstY,
enum PixelFormat target)
{
int i, j;
vector signed short X, X0, X1, Y0, U0, V0, Y1, U1, V1, U, V;
@ -685,12 +685,12 @@ ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter,
V = vec_clip_s16(V);
/* now we have
Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
U= u0 u1 u2 u3 u4 u5 u6 u7 V= v0 v1 v2 v3 v4 v5 v6 v7
Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
U0= u0 u0 u1 u1 u2 u2 u3 u3 U1= u4 u4 u5 u5 u6 u6 u7 u7
V0= v0 v0 v1 v1 v2 v2 v3 v3 V1= v4 v4 v5 v5 v6 v6 v7 v7
* Y0 = y0 y1 y2 y3 y4 y5 y6 y7 Y1 = y8 y9 y10 y11 y12 y13 y14 y15
* U = u0 u1 u2 u3 u4 u5 u6 u7 V = v0 v1 v2 v3 v4 v5 v6 v7
*
* Y0 = y0 y1 y2 y3 y4 y5 y6 y7 Y1 = y8 y9 y10 y11 y12 y13 y14 y15
* U0 = u0 u0 u1 u1 u2 u2 u3 u3 U1 = u4 u4 u5 u5 u6 u6 u7 u7
* V0 = v0 v0 v1 v1 v2 v2 v3 v3 V1 = v4 v4 v5 v5 v6 v6 v7 v7
*/
U0 = vec_mergeh(U, U);
@ -707,19 +707,32 @@ ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter,
B = vec_packclp(B0, B1);
switch (target) {
case PIX_FMT_ABGR: out_abgr (R,G,B,out); break;
case PIX_FMT_BGRA: out_bgra (R,G,B,out); break;
case PIX_FMT_RGBA: out_rgba (R,G,B,out); break;
case PIX_FMT_ARGB: out_argb (R,G,B,out); break;
case PIX_FMT_RGB24: out_rgb24 (R,G,B,out); break;
case PIX_FMT_BGR24: out_bgr24 (R,G,B,out); break;
case PIX_FMT_ABGR:
out_abgr(R, G, B, out);
break;
case PIX_FMT_BGRA:
out_bgra(R, G, B, out);
break;
case PIX_FMT_RGBA:
out_rgba(R, G, B, out);
break;
case PIX_FMT_ARGB:
out_argb(R, G, B, out);
break;
case PIX_FMT_RGB24:
out_rgb24(R, G, B, out);
break;
case PIX_FMT_BGR24:
out_bgr24(R, G, B, out);
break;
default:
{
/* If this is reached, the caller should have called yuv2packedXinC
instead. */
* instead. */
static int printed_error_message;
if (!printed_error_message) {
av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n",
av_log(c, AV_LOG_ERROR,
"altivec_yuv2packedX doesn't support %s output\n",
sws_format_name(c->dstFormat));
printed_error_message = 1;
}
@ -763,12 +776,12 @@ ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter,
V = vec_clip_s16(V);
/* now we have
Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
U = u0 u1 u2 u3 u4 u5 u6 u7 V = v0 v1 v2 v3 v4 v5 v6 v7
Y0= y0 y1 y2 y3 y4 y5 y6 y7 Y1= y8 y9 y10 y11 y12 y13 y14 y15
U0= u0 u0 u1 u1 u2 u2 u3 u3 U1= u4 u4 u5 u5 u6 u6 u7 u7
V0= v0 v0 v1 v1 v2 v2 v3 v3 V1= v4 v4 v5 v5 v6 v6 v7 v7
* Y0 = y0 y1 y2 y3 y4 y5 y6 y7 Y1 = y8 y9 y10 y11 y12 y13 y14 y15
* U = u0 u1 u2 u3 u4 u5 u6 u7 V = v0 v1 v2 v3 v4 v5 v6 v7
*
* Y0 = y0 y1 y2 y3 y4 y5 y6 y7 Y1 = y8 y9 y10 y11 y12 y13 y14 y15
* U0 = u0 u0 u1 u1 u2 u2 u3 u3 U1 = u4 u4 u5 u5 u6 u6 u7 u7
* V0 = v0 v0 v1 v1 v2 v2 v3 v3 V1 = v4 v4 v5 v5 v6 v6 v7 v7
*/
U0 = vec_mergeh(U, U);
@ -786,35 +799,52 @@ ff_yuv2packedX_altivec(SwsContext *c, const int16_t *lumFilter,
nout = (vector unsigned char *) scratch;
switch (target) {
case PIX_FMT_ABGR: out_abgr (R,G,B,nout); break;
case PIX_FMT_BGRA: out_bgra (R,G,B,nout); break;
case PIX_FMT_RGBA: out_rgba (R,G,B,nout); break;
case PIX_FMT_ARGB: out_argb (R,G,B,nout); break;
case PIX_FMT_RGB24: out_rgb24 (R,G,B,nout); break;
case PIX_FMT_BGR24: out_bgr24 (R,G,B,nout); break;
case PIX_FMT_ABGR:
out_abgr(R, G, B, nout);
break;
case PIX_FMT_BGRA:
out_bgra(R, G, B, nout);
break;
case PIX_FMT_RGBA:
out_rgba(R, G, B, nout);
break;
case PIX_FMT_ARGB:
out_argb(R, G, B, nout);
break;
case PIX_FMT_RGB24:
out_rgb24(R, G, B, nout);
break;
case PIX_FMT_BGR24:
out_bgr24(R, G, B, nout);
break;
default:
/* Unreachable, I think. */
av_log(c, AV_LOG_ERROR, "altivec_yuv2packedX doesn't support %s output\n",
av_log(c, AV_LOG_ERROR,
"altivec_yuv2packedX doesn't support %s output\n",
sws_format_name(c->dstFormat));
return;
}
memcpy(&((uint32_t *) dest)[i], scratch, (dstW - i) / 4);
}
}
#define YUV2PACKEDX_WRAPPER(suffix, pixfmt) \
void ff_yuv2 ## suffix ## _X_altivec(SwsContext *c, const int16_t *lumFilter, \
const int16_t **lumSrc, int lumFilterSize, \
const int16_t *chrFilter, const int16_t **chrUSrc, \
const int16_t **chrVSrc, int chrFilterSize, \
const int16_t **alpSrc, uint8_t *dest, \
int dstW, int dstY) \
void ff_yuv2 ## suffix ## _X_altivec(SwsContext *c, \
const int16_t *lumFilter, \
const int16_t **lumSrc, \
int lumFilterSize, \
const int16_t *chrFilter, \
const int16_t **chrUSrc, \
const int16_t **chrVSrc, \
int chrFilterSize, \
const int16_t **alpSrc, \
uint8_t *dest, int dstW, int dstY) \
{ \
ff_yuv2packedX_altivec(c, lumFilter, lumSrc, lumFilterSize, \
chrFilter, chrUSrc, chrVSrc, chrFilterSize, \
alpSrc, dest, dstW, dstY, pixfmt); \
chrFilter, chrUSrc, chrVSrc, \
chrFilterSize, alpSrc, \
dest, dstW, dstY, pixfmt); \
}
YUV2PACKEDX_WRAPPER(abgr, PIX_FMT_ABGR);