1 #ifndef SOURCE_LOOKUP 2 #define SOURCE_LOOKUP(x) (x) 3 #define SOURCE_LOOKUP_AUTO 4 #endif 5 6 #ifndef SOURCE_TYPE 7 #define SOURCE_TYPE u16 8 #define SOURCE_TYPE_AUTO 9 #endif 10 11 #if 0 12 #define HVX_DEBUG(x...) direct_log_printf( NULL, x ) 13 #else 14 #define HVX_DEBUG(x...) do {} while (0) 15 #endif 16 17 18 /*** OPTIMIZE by doing two pixels at once (vertically) with a 32 bit line buffer ***/ 19 20 /*static void STRETCH_HVX_NV16( void *dst, 21 int dpitch, 22 const void *src, 23 int spitch, 24 int width, 25 int height, 26 int dst_width, 27 int dst_height, 28 DFBRegion *clip )*/ 29 { 30 long x, y = 0; 31 long cw = clip->x2 - clip->x1 + 1; 32 long ch = clip->y2 - clip->y1 + 1; 33 long hfraq = ((long)(width - MINUS_1) << 18) / (long)(dst_width); 34 long vfraq = ((long)(height - MINUS_1) << 18) / (long)(dst_height); 35 long point0 = POINT_0 + clip->x1 * hfraq; 36 long point = point0; 37 long line = LINE_0 + clip->y1 * vfraq; 38 long ratios[cw]; 39 u16 *dst16; 40 41 u16 _lbT[cw+16]; 42 u16 _lbB[cw+16]; 43 44 u16 *lbX; 45 u16 *lbT = (u16*)((((ulong)(&_lbT[0])) + 31) & ~31); 46 u16 *lbB = (u16*)((((ulong)(&_lbB[0])) + 31) & ~31); 47 48 long lineT = -2000; 49 50 for (x=0; x<cw; x++) { 51 ratios[x] = POINT_TO_RATIO( point, hfraq ); 52 53 point += hfraq; 54 } 55 56 dst += clip->x1 * 2 + clip->y1 * dpitch; 57 58 dst16 = dst; 59 60 /* 61 * Scale line by line. 62 */ 63 for (y=0; y<ch; y++) { 64 long nlT = LINE_T( line, vfraq ); 65 66 D_ASSERT( nlT >= 0 ); 67 D_ASSERT( nlT < height-1 ); 68 69 /* 70 * Fill line buffer(s) ? 71 */ 72 if (nlT != lineT) { 73 u16 L, R; 74 const SOURCE_TYPE *srcT = src + spitch * nlT; 75 const SOURCE_TYPE *srcB = src + spitch * (nlT + 1); 76 long diff = nlT - lineT; 77 78 if (diff > 1) { 79 /* 80 * Horizontal interpolation 81 */ 82 for (x=0, point=point0; x<cw; x++, point += hfraq) { 83 long pl = POINT_L( point, hfraq ); 84 HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl, 85 POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] ); 86 D_ASSERT( pl >= 0 ); 87 D_ASSERT( pl < width-1 ); 88 89 L = SOURCE_LOOKUP(srcT[pl]); 90 R = SOURCE_LOOKUP(srcT[pl+1]); 91 92 lbT[x] = (((((R & 0x00ff)-(L & 0x00ff))*ratios[x] + ((L & 0x00ff)<<8)) & 0x00ff00) + 93 ((((R & 0xff00)-(L & 0xff00))*ratios[x] + ((L & 0xff00)<<8)) & 0xff0000)) >> 8; 94 95 L = SOURCE_LOOKUP(srcB[pl]); 96 R = SOURCE_LOOKUP(srcB[pl+1]); 97 98 lbB[x] = (((((R & 0x00ff)-(L & 0x00ff))*ratios[x] + ((L & 0x00ff)<<8)) & 0x00ff00) + 99 ((((R & 0xff00)-(L & 0xff00))*ratios[x] + ((L & 0xff00)<<8)) & 0xff0000)) >> 8; 100 } 101 } 102 else { 103 /* Swap */ 104 lbX = lbT; 105 lbT = lbB; 106 lbB = lbX; 107 108 /* 109 * Horizontal interpolation 110 */ 111 for (x=0, point=point0; x<cw; x++, point += hfraq) { 112 long pl = POINT_L( point, hfraq ); 113 HVX_DEBUG("%ld,%ld %lu (%lu/%lu) 0x%x 0x%x\n", x, y, pl, 114 POINT_L( point, hfraq ), POINT_R( point, hfraq ), point, ratios[r] ); 115 D_ASSERT( pl >= 0 ); 116 D_ASSERT( pl < width-1 ); 117 118 L = SOURCE_LOOKUP(srcB[pl]); 119 R = SOURCE_LOOKUP(srcB[pl+1]); 120 121 lbB[x] = (((((R & 0x00ff)-(L & 0x00ff))*ratios[x] + ((L & 0x00ff)<<8)) & 0x00ff00) + 122 ((((R & 0xff00)-(L & 0xff00))*ratios[x] + ((L & 0xff00)<<8)) & 0xff0000)) >> 8; 123 } 124 } 125 126 lineT = nlT; 127 } 128 129 /* 130 * Vertical interpolation 131 */ 132 long X = LINE_TO_RATIO( line, vfraq ); 133 134 for (x=0; x<cw; x++) 135 dst16[x] = (((((lbB[x] & 0x00ff)-(lbT[x] & 0x00ff))*X + ((lbT[x] & 0x00ff)<<8)) & 0x00ff00) + 136 ((((lbB[x] & 0xff00)-(lbT[x] & 0xff00))*X + ((lbT[x] & 0xff00)<<8)) & 0xff0000)) >> 8; 137 138 dst16 += dpitch / 2; 139 line += vfraq; 140 } 141 } 142 143 #ifdef SOURCE_LOOKUP_AUTO 144 #undef SOURCE_LOOKUP_AUTO 145 #undef SOURCE_LOOKUP 146 #endif 147 148 #ifdef SOURCE_TYPE_AUTO 149 #undef SOURCE_TYPE_AUTO 150 #undef SOURCE_TYPE 151 #endif 152 153