Revision 4bdc44c7 libswscale/internal_bfin.S

View differences:

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((y-oy)*cy  + crv*(v-128))
34
      g = clipz((y-oy)*cy  + cgv*(v-128) + cgu*(u-128))
35
      b = clipz((y-oy)*cy  + cbu*(u-128))
33
  r = clipz((y-oy)*cy  + crv*(v-128))
34
  g = clipz((y-oy)*cy  + cgv*(v-128) + cgu*(u-128))
35
  b = clipz((y-oy)*cy  + cbu*(u-128))
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((y-oy)*cy  + crv*(v-128))
52
4) compute each of the linear equations
53
     r = clipz((y - oy) * cy  + crv * (v - 128))
54 54

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

  
57
      b = clipz((y-oy)*cy  + cbu*(u-128))
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

Also available in: Unified diff