[MPlayer-dev-eng] RFC on libspe2 detection
Kristian Jerpetjøn
kristian.jerpetjoen at gmail.com
Tue May 29 23:31:21 CEST 2007
I attach here the original yuv colorspace code from patch 01
relicensed under lgpl as well as bsdv2
it performs slightly better than the version you are currently running.
I will add further improvements with some software pipelining once im
done with the yuv scaler this should bring the performance higher than
the 300FPS @1080p it has been tested to.
I have changed the iargs->width to iargs->dstW and same for height to
be able to reuse the same header for the yuv scaler which is nearing
completion this is also familiar names from libswscale i belive.
There is no ppu side implementation as the example back in rev01 should suffice.
I hope this will come to use!
Cheers
Kristian Jerpetjøn
Tlf: +4721694436
Mob +4792822774
Email: kristian.jerpetjoen at gmail.com
-------------- next part --------------
/**
* SPU YUV to RGB conversion kernel
* --------------------------------
* You can abide at one of the following licenses at your choice
* Licensed under the BSDv2 license, and lGPL
*
* libspedma.h - SPU DMA Macros
*
* Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
* $Id:
*/
// Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Copyright (C) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef __LIBSPEDMA_H
#define __LIBSPEDMA_H
#include <spu_mfcio.h>
typedef unsigned int uint32_t;
static inline void dmaGetnWait(void *localstore, unsigned long long extern_adr, uint32_t size, int tag)
{
int uiMask=1<<tag;
mfc_get(localstore, extern_adr, size, tag, 0, 0);
mfc_write_tag_mask(uiMask);
mfc_read_tag_status_any();
}
static inline void dmaPutnWait(void *localstore, unsigned long long extern_adr, uint32_t size, int tag)
{
int uiMask=1<<tag;
mfc_put(localstore, extern_adr, size, tag, 0, 0);
mfc_write_tag_mask(uiMask);
mfc_read_tag_status_any();
}
static inline void dmaWaitTag(int tag)
{
int uiMask=1<<tag;
mfc_write_tag_mask(uiMask);
mfc_read_tag_status_all();
}
static inline void dmaGet(void *localstore, unsigned long long extern_adr, uint32_t size, int tag) {
// printf("Get to %08x from %08x size %i\n",localstore,extern_adr,size);
mfc_get(localstore, extern_adr,size,tag, 0, 0);
}
static inline void dmaGetb(void *localstore, unsigned long long extern_adr, uint32_t size, int tag) {
// printf("Get to %08x from %08x size %i\n", ls, ea, size);
mfc_getb(localstore, extern_adr, size, tag, 0, 0);
}
static inline void dmaGetf(void *localstore, unsigned long long extern_adr, uint32_t size, int tag) {
// printf("Get to %08x from %08x size %i\n", ls, ea, size);
mfc_getf(localstore, extern_adr, size, tag, 0, 0);
}
static inline void dmaPut(void *localstore, unsigned long long extern_adr, uint32_t size, int tag) {
// printf("Get to %08x from %08x size %i\n", ls, ea, size);
mfc_put(localstore, extern_adr, size, tag, 0, 0);
}
static inline void dmaPutb(void *localstore, unsigned long long extern_adr, uint32_t size, int tag) {
// printf("Get to %08x from %08x size %i\n", ls, ea, size);
mfc_putb(localstore, extern_adr, size, tag, 0, 0);
}
static inline void dmaPutf(void *localstore, unsigned long long extern_adr, uint32_t size, int tag) {
// printf("Get to %08x from %08x size %i\n", ls, ea, size);
mfc_putf(localstore, extern_adr, size, tag, 0, 0);
}
static inline void dmaWaitAll(unsigned int uiMask) {
mfc_write_tag_mask(uiMask);
mfc_read_tag_status_all();
}
static inline void dmaWaitAny(unsigned int uiMask) {
mfc_write_tag_mask(uiMask);
mfc_read_tag_status_any();
}
#endif
/**
* SPU YUV to RGB conversion kernel
* --------------------------------
* You can abide at one of the following licenses at your choice
* Licensed under the BSDv2 license, and lGPL
*
* pack.h - SPU unpack to float routines
*
* Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
* $Id:
*/
// Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Copyright (C) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef __PACK_H
#define __PACK_H
static inline vector float unpackhh(vector unsigned char a) {
return (spu_convtf((vector unsigned int)spu_shuffle(a,((vector unsigned char){0}),((vector unsigned char){16,16,16,0,16,16,16,1,16,16,16,2,16,16,16,3})),0));
}
static inline vector float unpacklh(vector unsigned char a) {
return (spu_convtf((vector signed int)spu_shuffle(a,((vector unsigned char){0}),((vector unsigned char){16,16,16,4,16,16,16,5,16,16,16,6,16,16,16,7})),0));
}
static inline vector float unpackhl(vector unsigned char a) {
return (spu_convtf((vector signed int)spu_shuffle(a,((vector unsigned char){0}),((vector unsigned char){16,16,16,8,16,16,16,9,16,16,16,10,16,16,16,11})),0));
}
static inline vector float unpackll(vector unsigned char a) {
return (spu_convtf((vector signed int)spu_shuffle(a,((vector unsigned char){0}),((vector unsigned char){16,16,16,12,16,16,16,13,16,16,16,14,16,16,16,15})),0));
}
static inline vector float unpackfaabb(vector float a) {
return (spu_shuffle(a,a,((vector unsigned char){0,1,2,3,0,1,2,3,4,5,6,7,4,5,6,7})));
}
static inline vector float unpackfccdd(vector float a) {
return (spu_shuffle(a,a,((vector unsigned char){8,9,10,11,8,9,10,11,12,13,14,15,12,13,14,15})));
}
#endif
/**
* SPU YUV to RGB conversion kernel
* --------------------------------
* You can abide at one of the following licenses at your choice
* Licensed under the BSDv2 license, and lGPL
*
* spu_yuv2rgb.cpp - SPU YUV to RGB conversion kernel
*
* Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
* $Id:
*/
// Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Copyright (C) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <spu_mfcio.h>
#include <malloc.h>
#include <stdio.h>
#include "libspedma.h"
#include "spu_colorspace.h"
#include "yuv_datastructs.h"
#include "spu_control.h"
#define PPU_ADDR_MASK 0xFF00000000000000ULL
int main(unsigned long long speid, unsigned long long argp, unsigned long long envp)
{
int tgiA=1, tgiB=2, tgoA=3, tgoB=4;
int selOut = 0;
int tag = 1;
struct img_args *iargs;
iargs =(struct img_args*)memalign(128,sizeof(*iargs));
dmaGetnWait(iargs,(unsigned int)argp,(int)envp,tag); //getting neccesary data to process image
vector unsigned char* IybufferA=(vector unsigned char*)memalign(128,iargs->dstW*4); // 4 lines of Y
vector unsigned char* IubufferA=(vector unsigned char*)memalign(128,iargs->dstW); // 1 line of U
vector unsigned char* IvbufferA=(vector unsigned char*)memalign(128,iargs->dstW); // 1 line of V
vector unsigned char* IybufferB=(vector unsigned char*)memalign(128,iargs->dstW*4); // 4 lines of Y
vector unsigned char* IubufferB=(vector unsigned char*)memalign(128,iargs->dstW); // 1 line of U
vector unsigned char* IvbufferB=(vector unsigned char*)memalign(128,iargs->dstW); // 1 line of V
vector unsigned char* ObufferA=(vector unsigned char*)memalign(128,iargs->maxwidth*4*2); //2 lines of ARGB
vector unsigned char* ObufferB=(vector unsigned char*)memalign(128,iargs->maxwidth*4*2); //2 lines of ARGB
vector unsigned char* IyAp;
vector unsigned char* IyBp;
vector unsigned char* IuAp;
vector unsigned char* IuBp;
vector unsigned char* IvAp;
vector unsigned char* IvBp;
unsigned long long Op, Yp, Up, Vp;
unsigned int msg;
int *LSB=0;z
do {
int i;
spu_writech(SPU_WrOutIntrMbox, 0);
LSB=0;
selOut = spu_read_in_mbox();
if(selOut < 0)
break;
Op=iargs->Output[selOut];
Yp=iargs->Ystart[selOut];
Up=iargs->Ustart[selOut];
Vp=iargs->Vstart[selOut];
dmaGet(IybufferA,Yp,iargs->dstW*4,tgiA);
dmaGet(IubufferA,Up,iargs->dstW,tgiA);
dmaGet(IvbufferA,Vp,iargs->dstW,tgiA);
Yp=Yp+iargs->dstW*4;
Up=Up+iargs->dstW;
Vp=Vp+iargs->dstW;
dmaGet(IybufferB,Yp,iargs->dstW*4,tgiB);
dmaGet(IubufferB,Up,iargs->dstW,tgiB);
dmaGet(IvbufferB,Vp,iargs->dstW,tgiB);
for (i=0;i < iargs->dstH/8;i++) { // loop asumes height is a factor of eight
dmaWaitTag(tgiA);
dmaWaitTag(tgoA);
yuv420toARGB(IybufferA,IubufferA,IvbufferA,ObufferA,iargs->dstW,iargs->maxwidth,LSB);
dmaPut(ObufferA,Op,iargs->maxwidth*4*2,tgoA);
Op += iargs->maxwidth*4*2;
IyAp=IybufferA+iargs->dstW*2/16;
dmaWaitTag(tgoB);
yuv420toARGB(IyAp,IubufferA,IvbufferA,ObufferB,iargs->dstW,iargs->maxwidth,LSB);
dmaPut(ObufferB,Op,iargs->maxwidth*4*2,tgoB);
Yp=Yp+iargs->dstW*4;
Up=Up+iargs->dstW;
Vp=Vp+iargs->dstW;
Op += iargs->maxwidth*4*2;
if (iargs->dstH/8-1 != i){ // do not get on the last loop ..
dmaGet(IybufferA,Yp,iargs->dstW*4,tgiA);
dmaGet(IubufferA,Up,iargs->dstW,tgiA);
dmaGet(IvbufferA,Vp,iargs->dstW,tgiA);
}
dmaWaitTag(tgiB);
dmaWaitTag(tgoA);
yuv420toARGB(IybufferB,IubufferB,IvbufferB,ObufferA,iargs->dstW,iargs->maxwidth,LSB);
dmaPut(ObufferA,Op,iargs->maxwidth*4*2,tgoA);
Op += iargs->maxwidth*4*2;
IyBp=IybufferB+iargs->dstW*2/16;
dmaWaitTag(tgoB);
yuv420toARGB(IyBp,IubufferB,IvbufferB,ObufferB,iargs->dstW,iargs->maxwidth,LSB);
dmaPut(ObufferB,Op,iargs->maxwidth*4*2,tgoB);
Yp=Yp+iargs->dstW*4;
Up=Up+iargs->dstW;
Vp=Vp+iargs->dstW;
Op += iargs->maxwidth*4*2;
if (iargs->dstH/8-1 != i) { // do not get on the last loop ..
dmaGet(IybufferB,Yp,iargs->dstW*4,tgiB);
dmaGet(IubufferB,Up,iargs->dstW,tgiB);
dmaGet(IvbufferB,Vp,iargs->dstW,tgiB);
}
}
dmaWaitTag(tgoA);
dmaWaitTag(tgoB);
} while(1);
return 0;
}
/**
* SPU YUV to RGB conversion kernel
* --------------------------------
* You can abide at one of the following licenses at your choice
* Licensed under the BSDv2 license, and lGPL
*
* spu_colorspace.h - SPU YUV to RGB conversion kernel
*
* Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
* $Id:
*/
// Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Copyright (C) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef __SPU_COLORSPACE_H
#define __SPU_COLORSPACE_H
#include "pack.h"
static inline void YUV2RGB(vector float Y,vector float U, vector float V ,vector float *R,vector float *G, vector float *B )
{
vector float E=spu_sub(V,((vector float){128.0,128.0,128.0,128.0}));
vector float D=spu_sub(U,((vector float){128.0,128.0,128.0,128.0}));
R[0]=spu_add(Y,spu_mul(E,((vector float){1.402,1.402,1.402,1.402})));
G[0]=spu_sub(Y,spu_add((spu_mul(D,((vector float){0.34414,0.34414,0.34414,0.34414}))),(spu_mul(E,((vector float){0.71414,0.71414,0.71414,0.71414})))));
B[0]=spu_add(Y,spu_mul(D,((vector float) {1.772,1.772,1.772,1.772})));
}
static inline vector unsigned char packfARGB(vector float R, vector float G, vector float B)
{
vector unsigned int max = spu_splats((unsigned int)0x00FF);
static vector unsigned char Rff=/*(vector unsigned char)*/{0,19,2,3,4,23,6,7,8,27,10,11,12,31,14,15};
static vector unsigned char Gff=/*(vector unsigned char)*/{0,1,19,3,4,5,23,7,8,9 ,27,11,12,13,31,15};
vector unsigned int Ri=spu_convtu(R,0);
Ri= spu_sel(Ri, max, spu_cmpgt(Ri,255));
vector unsigned int Gi=spu_convtu(G,0);
Gi= spu_sel(Gi, max, spu_cmpgt(Gi,255));
vector unsigned int Bi=spu_convtu(B,0);
Bi= spu_sel(Bi, max, spu_cmpgt(Bi,255));
vector unsigned char ARGB;
ARGB=spu_shuffle((vector unsigned char)Bi,(vector unsigned char)Ri,Rff);
ARGB=spu_shuffle(ARGB,(vector unsigned char)Gi,Gff);
return ARGB;
}
static inline void yuv420toARGB(vector unsigned char *Y,vector unsigned char *U, vector unsigned char *V,vector unsigned char *ARGB, int width,int maxwidth,int *LSB)
{
vector float Yf0,Yf1,Yf2,Yf3,Yf4,Yf5,Yf6,Yf7;
vector float Uf0,Uf1;
vector float Vf0,Vf1;
vector float R0,G0,B0;
vector float yfv,ufuv,vfu;
vector float E,D;
int i;
for (i =0;i < width/16;i++) {
Yf0=unpackhh(Y[0]);
Yf1=unpacklh(Y[0]);
Yf2=unpackhl(Y[0]);
Yf3=unpackll(Y[0]);
Yf4=unpackhh(Y[width/16]);
Yf5=unpacklh(Y[width/16]);
Yf6=unpackhl(Y[width/16]);
Yf7=unpackll(Y[width/16]);
Y++;
if ( LSB == 1 ) {
Uf0=unpackhl(U[0]);
Uf1=unpackll(U[0]);
Vf0=unpackhl(V[0]);
Vf1=unpackll(V[0]);
LSB=0;
U++;
V++;
} else {
Uf0=unpackhh(U[0]);
Uf1=unpacklh(U[0]);
Vf0=unpackhh(V[0]);
Vf1=unpacklh(V[0]);
LSB=1;
}
E=spu_sub(Vf0,((vector float){128.0,128.0,128.0,128.0}));
D=spu_sub(Uf0,((vector float){128.0,128.0,128.0,128.0}));
yfv=spu_mul(E,((vector float){1.402,1.402,1.402,1.402}));
ufuv=spu_add((spu_mul(D,((vector float){0.34414,0.34414,0.34414,0.34414}))),(spu_mul(E,((vector float){0.71414,0.71414,0.71414,0.71414}))));
vfu=spu_mul(D,((vector float) {1.772,1.772,1.772,1.772}));
R0=spu_add(Yf0,unpackfaabb(yfv));
G0=spu_sub(Yf0,unpackfaabb(ufuv));
B0=spu_add(Yf0,unpackfaabb(vfu));
ARGB[i*4]=packfARGB(R0,G0,B0);
R0=spu_add(Yf4,unpackfaabb(yfv));
G0=spu_sub(Yf4,unpackfaabb(ufuv));
B0=spu_add(Yf4,unpackfaabb(vfu));
ARGB[i*4+maxwidth/4]=packfARGB(R0,G0,B0);
R0=spu_add(Yf1,unpackfccdd(yfv));
G0=spu_sub(Yf1,unpackfccdd(ufuv));
B0=spu_add(Yf1,unpackfccdd(vfu));
ARGB[i*4+1]=packfARGB(R0,G0,B0);
R0=spu_add(Yf5,unpackfccdd(yfv));
G0=spu_sub(Yf5,unpackfccdd(ufuv));
B0=spu_add(Yf5,unpackfccdd(vfu));
ARGB[i*4+1+maxwidth/4]=packfARGB(R0,G0,B0);
E=spu_sub(Vf1,((vector float){128.0,128.0,128.0,128.0}));
D=spu_sub(Uf1,((vector float){128.0,128.0,128.0,128.0}));
yfv=spu_mul(E,((vector float){1.402,1.402,1.402,1.402}));
ufuv=spu_add((spu_mul(D,((vector float){0.34414,0.34414,0.34414,0.34414}))),(spu_mul(E,((vector float){0.71414,0.71414,0.71414,0.71414})))); vfu=spu_mul(D,((vector float) {1.772,1.772,1.772,1.772}));
R0=spu_add(Yf2,unpackfaabb(yfv));
G0=spu_sub(Yf2,unpackfaabb(ufuv));
B0=spu_add(Yf2,unpackfaabb(vfu));
ARGB[i*4+2]=packfARGB(R0,G0,B0);
R0=spu_add(Yf6,unpackfaabb(yfv));
G0=spu_sub(Yf6,unpackfaabb(ufuv));
B0=spu_add(Yf6,unpackfaabb(vfu));
ARGB[i*4+2+maxwidth/4]=packfARGB(R0,G0,B0);
R0=spu_add(Yf3,unpackfccdd(yfv));
G0=spu_sub(Yf3,unpackfccdd(ufuv));
B0=spu_add(Yf3,unpackfccdd(vfu));
ARGB[i*4+3]=packfARGB(R0,G0,B0);
R0=spu_add(Yf7,unpackfccdd(yfv));
G0=spu_sub(Yf7,unpackfccdd(ufuv));
B0=spu_add(Yf7,unpackfccdd(vfu));
ARGB[i*4+3+maxwidth/4]=packfARGB(R0,G0,B0);
}
Y=Y+width/16;
}
#endif
/**
* SPU YUV to RGB conversion kernel
* --------------------------------
* You can abide at one of the following licenses at your choice
* Licensed under the BSDv2 license, and lGPL
*
* spu_control.h - General Purpose controls
*
* Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
* $Id:
*/
// Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Copyright (C) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef __SPU_CONTROL_H
#define __SPU_CONTROL_H
enum control { RUN, STOP, WAIT ,RDY , BUSY };
#endif
/**
* SPU YUV to RGB conversion kernel
* --------------------------------
* You can abide at one of the following licenses at your choice
* Licensed under the BSDv2 license, and lGPL
*
* yuv_datastructs.h - YUV datatypes
*
* Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
* $Id:
*/
// Copyright (c) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. The names of the authors may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Copyright (C) 2007, Kristian Jerpetj?n <kristian.jerpetjoen at gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef __YUV_DATASTRUCTS_H
#define __YUV_DATASTRUCTS_H
struct img_args {
int srcW;
int srcH;
int wMax;
int hMax;
int yOffset;
int xOffset;
int dstW;
int dstH;
unsigned long long Ystart[2];
unsigned long long Ustart[2];
unsigned long long Vstart[2];
unsigned long long Output[2];
} __attribute__((aligned(128)));
#endif
More information about the MPlayer-dev-eng
mailing list