Revision 4bdc44c7
libswscale/internal_bfin.S  

24  24  
25  25  
26  26 
/* 
27 
YUV420 to RGB565 conversion. This routine takes a YUV 420 planar macroblock


28 
and converts it to RGB565. R:5 bits, G:6 bits, B:5 bits.. packed into shorts


27 
YUV420 to RGB565 conversion. This routine takes a YUV 420 planar macroblock 

28 
and converts it to RGB565. R:5 bits, G:6 bits, B:5 bits.. packed into shorts 

29  29  
30  30  
31 
The following calculation is used for the conversion:


31 
The following calculation is used for the conversion: 

32  32  
33 
r = clipz((yoy)*cy + crv*(v128))


34 
g = clipz((yoy)*cy + cgv*(v128) + cgu*(u128))


35 
b = clipz((yoy)*cy + cbu*(u128))


33 
r = clipz((yoy)*cy + crv*(v128)) 

34 
g = clipz((yoy)*cy + cgv*(v128) + cgu*(u128)) 

35 
b = clipz((yoy)*cy + cbu*(u128)) 

36  36  
37 
y,u,v are pre scaled by a factor of 4 i.e. left shifted to gain precision.


37 
y,u,v are pre scaled by a factor of 4 i.e. left shifted to gain precision. 

38  38  
39  39  
40 
New factorization to eliminate the truncation error which was


41 
occuring due to the byteop3p.


40 
New factorization to eliminate the truncation error which was 

41 
occuring due to the byteop3p. 

42  42  
43  43  
44 
1) use the bytop16m to subtract quad bytes we use this in U8 this


45 
then so the offsets need to be renormalized to 8bits.


44 
1) use the bytop16m to subtract quad bytes we use this in U8 this 

45 
then so the offsets need to be renormalized to 8bits. 

46  46  
47 
2) scale operands up by a factor of 4 not 8 because Blackfin


48 
multiplies include a shift.


47 
2) scale operands up by a factor of 4 not 8 because Blackfin 

48 
multiplies include a shift. 

49  49  
50 
3) compute into the accumulators cy*yx0, cy*yx1


50 
3) compute into the accumulators cy*yx0, cy*yx1 

51  51  
52 
4) compute each of the linear equations


53 
r = clipz((yoy)*cy + crv*(v128))


52 
4) compute each of the linear equations 

53 
r = clipz((y  oy) * cy + crv * (v  128))


54  54  
55 
g = clipz((yoy)*cy + cgv*(v128) + cgu*(u128))


55 
g = clipz((y  oy) * cy + cgv * (v  128) + cgu * (u  128))


56  56  
57 
b = clipz((yoy)*cy + cbu*(u128))


57 
b = clipz((y  oy) * cy + cbu * (u  128))


58  58  
59 
reuse of the accumulators requires that we actually multiply


60 
twice once with addition and the second time with a subtaction.


59 
reuse of the accumulators requires that we actually multiply 

60 
twice once with addition and the second time with a subtaction. 

61  61  
62 
because of this we need to compute the equations in the order R B


63 
then G saving the writes for B in the case of 24/32 bit color


64 
formats.


62 
because of this we need to compute the equations in the order R B 

63 
then G saving the writes for B in the case of 24/32 bit color 

64 
formats. 

65  65  
66 
api: yuv2rgb_kind (uint8_t *Y, uint8_t *U, uint8_t *V, int *out,


67 
int dW, uint32_t *coeffs);


66 
api: yuv2rgb_kind (uint8_t *Y, uint8_t *U, uint8_t *V, int *out, 

67 
int dW, uint32_t *coeffs); 

68  68  
69 
A B


70 
 


71 
i2 = cb i3 = cr


72 
i1 = coeff i0 = y


69 
A B 

70 
  

71 
i2 = cb i3 = cr 

72 
i1 = coeff i0 = y 

73  73  
74 
Where coeffs have the following layout in memory.


74 
Where coeffs have the following layout in memory. 

75  75  
76 
uint32_t oy,oc,zero,cy,crv,rmask,cbu,bmask,cgu,cgv;


76 
uint32_t oy,oc,zero,cy,crv,rmask,cbu,bmask,cgu,cgv; 

77  77  
78 
coeffs is a pointer to oy.


78 
coeffs is a pointer to oy. 

79  79  
80 
the {rgb} masks are only utilized by the 565 packing algorithm. Note the data


81 
replication is used to simplify the internal algorithms for the dual mac architecture


82 
of BlackFin.


80 
the {rgb} masks are only utilized by the 565 packing algorithm. Note the data 

81 
replication is used to simplify the internal algorithms for the dual mac architecture 

82 
of BlackFin. 

83  83  
84 
All routines are exported with _ff_bfin_ as a symbol prefix


84 
All routines are exported with _ff_bfin_ as a symbol prefix 

85  85  
86 
rough performance gain compared against O3:


86 
rough performance gain compared against O3: 

87  87  
88 
2779809/1484290 187.28% 

89  
90 
which translates to ~33c/pel to ~57c/pel for the reference vs 17.5 

91 
c/pel for the optimized implementations. Not sure why there is such a 

92 
huge variation on the reference codes on Blackfin I guess it must have 

93 
to do with the memory system. 

88 
2779809/1484290 187.28% 

94  89  
90 
which translates to ~33c/pel to ~57c/pel for the reference vs 17.5 

91 
c/pel for the optimized implementations. Not sure why there is such a 

92 
huge variation on the reference codes on Blackfin I guess it must have 

93 
to do with the memory system. 

95  94 
*/ 
96  95  
97  96 
#define mL3 .text 
libswscale/yuv2rgb_altivec.c  

21  21 
*/ 
22  22  
23  23 
/* 
24 
convert I420 YV12 to RGB in various formats,


25 
it rejects images that are not in 420 formats


26 
it rejects images that don't have widths of multiples of 16


27 
it rejects images that don't have heights of multiples of 2


28 
reject defers to C simulation codes.


24 
convert I420 YV12 to RGB in various formats, 

25 
it rejects images that are not in 420 formats 

26 
it rejects images that don't have widths of multiples of 16 

27 
it rejects images that don't have heights of multiples of 2 

28 
reject defers to C simulation codes. 

29  29  
30 
lots of optimizations to be done here


30 
lots of optimizations to be done here 

31  31  
32 
1. need to fix saturation code, I just couldn't get it to fly with packs and adds.


33 
so we currently use max min to clip


32 
1. need to fix saturation code, I just couldn't get it to fly with packs and adds. 

33 
so we currently use max min to clip 

34  34  
35 
2. the inefficient use of chroma loading needs a bit of brushing up


35 
2. the inefficient use of chroma loading needs a bit of brushing up 

36  36  
37 
3. analysis of pipeline stalls needs to be done, use shark to identify pipeline stalls


37 
3. analysis of pipeline stalls needs to be done, use shark to identify pipeline stalls 

38  38  
39  39  
40 
MODIFIED to calculate coeffs from currently selected color space.


41 
MODIFIED core to be a macro which you spec the output format.


42 
ADDED UYVY conversion which is never called due to some thing in SWSCALE.


43 
CORRECTED algorithim selection to be strict on input formats.


44 
ADDED runtime detection of altivec.


40 
MODIFIED to calculate coeffs from currently selected color space. 

41 
MODIFIED core to be a macro which you spec the output format. 

42 
ADDED UYVY conversion which is never called due to some thing in SWSCALE. 

43 
CORRECTED algorithim selection to be strict on input formats. 

44 
ADDED runtime detection of altivec. 

45  45  
46 
ADDED altivec_yuv2packedX vertical scl + RGB converter


46 
ADDED altivec_yuv2packedX vertical scl + RGB converter 

47  47  
48 
March 27,2004


49 
PERFORMANCE ANALYSIS


48 
March 27,2004 

49 
PERFORMANCE ANALYSIS 

50  50  
51 
The C version use 25% of the processor or ~250Mips for D1 video rawvideo used as test


52 
The ALTIVEC version uses 10% of the processor or ~100Mips for D1 video same sequence


51 
The C version use 25% of the processor or ~250Mips for D1 video rawvideo used as test 

52 
The ALTIVEC version uses 10% of the processor or ~100Mips for D1 video same sequence 

53  53  
54 
720*480*30 ~10MPS


54 
720*480*30 ~10MPS 

55  55  
56 
so we have roughly 10clocks per pixel this is too high something has to be wrong.


56 
so we have roughly 10clocks per pixel this is too high something has to be wrong. 

57  57  
58 
OPTIMIZED clip codes to utilize vec_max and vec_packs removing the need for vec_min.


58 
OPTIMIZED clip codes to utilize vec_max and vec_packs removing the need for vec_min. 

59  59  
60 
OPTIMIZED DST OUTPUT cache/dma controls. we are pretty much


61 
guaranteed to have the input video frame it was just decompressed so


62 
it probably resides in L1 caches. However we are creating the


63 
output video stream this needs to use the DSTST instruction to


64 
optimize for the cache. We couple this with the fact that we are


65 
not going to be visiting the input buffer again so we mark it Least


66 
Recently Used. This shaves 25% of the processor cycles off.


60 
OPTIMIZED DST OUTPUT cache/dma controls. we are pretty much 

61 
guaranteed to have the input video frame it was just decompressed so 

62 
it probably resides in L1 caches. However we are creating the 

63 
output video stream this needs to use the DSTST instruction to 

64 
optimize for the cache. We couple this with the fact that we are 

65 
not going to be visiting the input buffer again so we mark it Least 

66 
Recently Used. This shaves 25% of the processor cycles off. 

67  67  
68 
Now MEMCPY is the largest mips consumer in the system, probably due


69 
to the inefficient X11 stuff.


68 
Now MEMCPY is the largest mips consumer in the system, probably due 

69 
to the inefficient X11 stuff. 

70  70  
71 
GL libraries seem to be very slow on this machine 1.33Ghz PB running


72 
Jaguar, this is not the case for my 1Ghz PB. I thought it might be


73 
a versioning issues, however I have libGL.1.2.dylib for both


74 
machines. ((We need to figure this out now))


71 
GL libraries seem to be very slow on this machine 1.33Ghz PB running 

72 
Jaguar, this is not the case for my 1Ghz PB. I thought it might be 

73 
a versioning issues, however I have libGL.1.2.dylib for both 

74 
machines. ((We need to figure this out now)) 

75  75  
76 
GL2 libraries work now with patch for RGB32


76 
GL2 libraries work now with patch for RGB32 

77  77  
78 
NOTE quartz vo driver ARGB32_to_RGB24 consumes 30% of the processor


78 
NOTE quartz vo driver ARGB32_to_RGB24 consumes 30% of the processor 

79  79  
80 
Integrated luma prescaling adjustment for saturation/contrast/brightness adjustment.


80 
Integrated luma prescaling adjustment for saturation/contrast/brightness adjustment. 

81  81 
*/ 
82  82  
83  83 
#include <stdio.h> 
Also available in: Unified diff