| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2013 The WebM project authors. All Rights Reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #include <assert.h> | |
| 12 #include <stdio.h> | |
| 13 | |
| 14 #include "./vpx_dsp_rtcd.h" | |
| 15 #include "vpx_dsp/mips/vpx_common_dspr2.h" | |
| 16 #include "vpx_dsp/vpx_convolve.h" | |
| 17 #include "vpx_dsp/vpx_dsp_common.h" | |
| 18 #include "vpx_ports/mem.h" | |
| 19 | |
| 20 #if HAVE_DSPR2 | |
| 21 static void convolve_bi_avg_vert_4_dspr2(const uint8_t *src, | |
| 22 int32_t src_stride, | |
| 23 uint8_t *dst, | |
| 24 int32_t dst_stride, | |
| 25 const int16_t *filter_y, | |
| 26 int32_t w, | |
| 27 int32_t h) { | |
| 28 int32_t x, y; | |
| 29 const uint8_t *src_ptr; | |
| 30 uint8_t *dst_ptr; | |
| 31 uint8_t *cm = vpx_ff_cropTbl; | |
| 32 uint32_t vector4a = 64; | |
| 33 uint32_t load1, load2; | |
| 34 uint32_t p1, p2; | |
| 35 uint32_t scratch1, scratch2; | |
| 36 uint32_t store1, store2; | |
| 37 int32_t Temp1, Temp2; | |
| 38 const int16_t *filter = &filter_y[3]; | |
| 39 uint32_t filter45; | |
| 40 | |
| 41 filter45 = ((const int32_t *)filter)[0]; | |
| 42 | |
| 43 for (y = h; y--;) { | |
| 44 /* prefetch data to cache memory */ | |
| 45 prefetch_store(dst + dst_stride); | |
| 46 | |
| 47 for (x = 0; x < w; x += 4) { | |
| 48 src_ptr = src + x; | |
| 49 dst_ptr = dst + x; | |
| 50 | |
| 51 __asm__ __volatile__ ( | |
| 52 "ulw %[load1], 0(%[src_ptr]) \n\t" | |
| 53 "add %[src_ptr], %[src_ptr], %[src_stride] \n\t" | |
| 54 "ulw %[load2], 0(%[src_ptr]) \n\t" | |
| 55 | |
| 56 "mtlo %[vector4a], $ac0 \n\t" | |
| 57 "mtlo %[vector4a], $ac1 \n\t" | |
| 58 "mtlo %[vector4a], $ac2 \n\t" | |
| 59 "mtlo %[vector4a], $ac3 \n\t" | |
| 60 "mthi $zero, $ac0 \n\t" | |
| 61 "mthi $zero, $ac1 \n\t" | |
| 62 "mthi $zero, $ac2 \n\t" | |
| 63 "mthi $zero, $ac3 \n\t" | |
| 64 | |
| 65 "preceu.ph.qbr %[scratch1], %[load1] \n\t" | |
| 66 "preceu.ph.qbr %[p1], %[load2] \n\t" | |
| 67 "precrq.ph.w %[p2], %[p1], %[scratch1] \n\t"
/* pixel 2 */ | |
| 68 "append %[p1], %[scratch1], 16 \n\t"
/* pixel 1 */ | |
| 69 | |
| 70 "dpa.w.ph $ac0, %[p1], %[filter45] \n\t" | |
| 71 "dpa.w.ph $ac1, %[p2], %[filter45] \n\t" | |
| 72 | |
| 73 "preceu.ph.qbl %[scratch1], %[load1] \n\t" | |
| 74 "preceu.ph.qbl %[p1], %[load2] \n\t" | |
| 75 "precrq.ph.w %[p2], %[p1], %[scratch1] \n\t"
/* pixel 2 */ | |
| 76 "append %[p1], %[scratch1], 16 \n\t"
/* pixel 1 */ | |
| 77 | |
| 78 "dpa.w.ph $ac2, %[p1], %[filter45] \n\t" | |
| 79 "dpa.w.ph $ac3, %[p2], %[filter45] \n\t" | |
| 80 | |
| 81 "extp %[Temp1], $ac0, 31 \n\t" | |
| 82 "extp %[Temp2], $ac1, 31 \n\t" | |
| 83 | |
| 84 "lbu %[scratch1], 0(%[dst_ptr]) \n\t" | |
| 85 "lbu %[scratch2], 1(%[dst_ptr]) \n\t" | |
| 86 | |
| 87 "lbux %[store1], %[Temp1](%[cm]) \n\t" | |
| 88 "addqh_r.w %[store1], %[store1], %[scratch1] \n\t"
/* pixel 1 */ | |
| 89 "extp %[Temp1], $ac2, 31 \n\t" | |
| 90 | |
| 91 "lbux %[store2], %[Temp2](%[cm]) \n\t" | |
| 92 "addqh_r.w %[store2], %[store2], %[scratch2] \n\t"
/* pixel 2 */ | |
| 93 "extp %[Temp2], $ac3, 31 \n\t" | |
| 94 "lbu %[scratch1], 2(%[dst_ptr]) \n\t" | |
| 95 | |
| 96 "sb %[store1], 0(%[dst_ptr]) \n\t" | |
| 97 "sb %[store2], 1(%[dst_ptr]) \n\t" | |
| 98 "lbu %[scratch2], 3(%[dst_ptr]) \n\t" | |
| 99 | |
| 100 "lbux %[store1], %[Temp1](%[cm]) \n\t" | |
| 101 "lbux %[store2], %[Temp2](%[cm]) \n\t" | |
| 102 "addqh_r.w %[store1], %[store1], %[scratch1] \n\t"
/* pixel 3 */ | |
| 103 "addqh_r.w %[store2], %[store2], %[scratch2] \n\t"
/* pixel 4 */ | |
| 104 | |
| 105 "sb %[store1], 2(%[dst_ptr]) \n\t" | |
| 106 "sb %[store2], 3(%[dst_ptr]) \n\t" | |
| 107 | |
| 108 : [load1] "=&r" (load1), [load2] "=&r" (load2), | |
| 109 [p1] "=&r" (p1), [p2] "=&r" (p2), | |
| 110 [scratch1] "=&r" (scratch1), [scratch2] "=&r" (scratch2), | |
| 111 [Temp1] "=&r" (Temp1), [Temp2] "=&r" (Temp2), | |
| 112 [store1] "=&r" (store1), [store2] "=&r" (store2), | |
| 113 [src_ptr] "+r" (src_ptr) | |
| 114 : [filter45] "r" (filter45), [vector4a] "r" (vector4a), | |
| 115 [src_stride] "r" (src_stride), [cm] "r" (cm), | |
| 116 [dst_ptr] "r" (dst_ptr) | |
| 117 ); | |
| 118 } | |
| 119 | |
| 120 /* Next row... */ | |
| 121 src += src_stride; | |
| 122 dst += dst_stride; | |
| 123 } | |
| 124 } | |
| 125 | |
| 126 static void convolve_bi_avg_vert_64_dspr2(const uint8_t *src, | |
| 127 int32_t src_stride, | |
| 128 uint8_t *dst, | |
| 129 int32_t dst_stride, | |
| 130 const int16_t *filter_y, | |
| 131 int32_t h) { | |
| 132 int32_t x, y; | |
| 133 const uint8_t *src_ptr; | |
| 134 uint8_t *dst_ptr; | |
| 135 uint8_t *cm = vpx_ff_cropTbl; | |
| 136 uint32_t vector4a = 64; | |
| 137 uint32_t load1, load2; | |
| 138 uint32_t p1, p2; | |
| 139 uint32_t scratch1, scratch2; | |
| 140 uint32_t store1, store2; | |
| 141 int32_t Temp1, Temp2; | |
| 142 const int16_t *filter = &filter_y[3]; | |
| 143 uint32_t filter45;; | |
| 144 | |
| 145 filter45 = ((const int32_t *)filter)[0]; | |
| 146 | |
| 147 for (y = h; y--;) { | |
| 148 /* prefetch data to cache memory */ | |
| 149 prefetch_store(dst + dst_stride); | |
| 150 prefetch_store(dst + dst_stride + 32); | |
| 151 | |
| 152 for (x = 0; x < 64; x += 4) { | |
| 153 src_ptr = src + x; | |
| 154 dst_ptr = dst + x; | |
| 155 | |
| 156 __asm__ __volatile__ ( | |
| 157 "ulw %[load1], 0(%[src_ptr]) \n\t" | |
| 158 "add %[src_ptr], %[src_ptr], %[src_stride] \n\t" | |
| 159 "ulw %[load2], 0(%[src_ptr]) \n\t" | |
| 160 | |
| 161 "mtlo %[vector4a], $ac0 \n\t" | |
| 162 "mtlo %[vector4a], $ac1 \n\t" | |
| 163 "mtlo %[vector4a], $ac2 \n\t" | |
| 164 "mtlo %[vector4a], $ac3 \n\t" | |
| 165 "mthi $zero, $ac0 \n\t" | |
| 166 "mthi $zero, $ac1 \n\t" | |
| 167 "mthi $zero, $ac2 \n\t" | |
| 168 "mthi $zero, $ac3 \n\t" | |
| 169 | |
| 170 "preceu.ph.qbr %[scratch1], %[load1] \n\t" | |
| 171 "preceu.ph.qbr %[p1], %[load2] \n\t" | |
| 172 "precrq.ph.w %[p2], %[p1], %[scratch1] \n\t"
/* pixel 2 */ | |
| 173 "append %[p1], %[scratch1], 16 \n\t"
/* pixel 1 */ | |
| 174 | |
| 175 "dpa.w.ph $ac0, %[p1], %[filter45] \n\t" | |
| 176 "dpa.w.ph $ac1, %[p2], %[filter45] \n\t" | |
| 177 | |
| 178 "preceu.ph.qbl %[scratch1], %[load1] \n\t" | |
| 179 "preceu.ph.qbl %[p1], %[load2] \n\t" | |
| 180 "precrq.ph.w %[p2], %[p1], %[scratch1] \n\t"
/* pixel 2 */ | |
| 181 "append %[p1], %[scratch1], 16 \n\t"
/* pixel 1 */ | |
| 182 | |
| 183 "dpa.w.ph $ac2, %[p1], %[filter45] \n\t" | |
| 184 "dpa.w.ph $ac3, %[p2], %[filter45] \n\t" | |
| 185 | |
| 186 "extp %[Temp1], $ac0, 31 \n\t" | |
| 187 "extp %[Temp2], $ac1, 31 \n\t" | |
| 188 | |
| 189 "lbu %[scratch1], 0(%[dst_ptr]) \n\t" | |
| 190 "lbu %[scratch2], 1(%[dst_ptr]) \n\t" | |
| 191 | |
| 192 "lbux %[store1], %[Temp1](%[cm]) \n\t" | |
| 193 "addqh_r.w %[store1], %[store1], %[scratch1] \n\t"
/* pixel 1 */ | |
| 194 "extp %[Temp1], $ac2, 31 \n\t" | |
| 195 | |
| 196 "lbux %[store2], %[Temp2](%[cm]) \n\t" | |
| 197 "addqh_r.w %[store2], %[store2], %[scratch2] \n\t"
/* pixel 2 */ | |
| 198 "extp %[Temp2], $ac3, 31 \n\t" | |
| 199 "lbu %[scratch1], 2(%[dst_ptr]) \n\t" | |
| 200 | |
| 201 "sb %[store1], 0(%[dst_ptr]) \n\t" | |
| 202 "sb %[store2], 1(%[dst_ptr]) \n\t" | |
| 203 "lbu %[scratch2], 3(%[dst_ptr]) \n\t" | |
| 204 | |
| 205 "lbux %[store1], %[Temp1](%[cm]) \n\t" | |
| 206 "lbux %[store2], %[Temp2](%[cm]) \n\t" | |
| 207 "addqh_r.w %[store1], %[store1], %[scratch1] \n\t"
/* pixel 3 */ | |
| 208 "addqh_r.w %[store2], %[store2], %[scratch2] \n\t"
/* pixel 4 */ | |
| 209 | |
| 210 "sb %[store1], 2(%[dst_ptr]) \n\t" | |
| 211 "sb %[store2], 3(%[dst_ptr]) \n\t" | |
| 212 | |
| 213 : [load1] "=&r" (load1), [load2] "=&r" (load2), | |
| 214 [p1] "=&r" (p1), [p2] "=&r" (p2), | |
| 215 [scratch1] "=&r" (scratch1), [scratch2] "=&r" (scratch2), | |
| 216 [Temp1] "=&r" (Temp1), [Temp2] "=&r" (Temp2), | |
| 217 [store1] "=&r" (store1), [store2] "=&r" (store2), | |
| 218 [src_ptr] "+r" (src_ptr) | |
| 219 : [filter45] "r" (filter45), [vector4a] "r" (vector4a), | |
| 220 [src_stride] "r" (src_stride), [cm] "r" (cm), | |
| 221 [dst_ptr] "r" (dst_ptr) | |
| 222 ); | |
| 223 } | |
| 224 | |
| 225 /* Next row... */ | |
| 226 src += src_stride; | |
| 227 dst += dst_stride; | |
| 228 } | |
| 229 } | |
| 230 | |
| 231 void vpx_convolve2_avg_vert_dspr2(const uint8_t *src, ptrdiff_t src_stride, | |
| 232 uint8_t *dst, ptrdiff_t dst_stride, | |
| 233 const int16_t *filter_x, int x_step_q4, | |
| 234 const int16_t *filter_y, int y_step_q4, | |
| 235 int w, int h) { | |
| 236 if (16 == y_step_q4) { | |
| 237 uint32_t pos = 38; | |
| 238 | |
| 239 /* bit positon for extract from acc */ | |
| 240 __asm__ __volatile__ ( | |
| 241 "wrdsp %[pos], 1 \n\t" | |
| 242 : | |
| 243 : [pos] "r" (pos) | |
| 244 ); | |
| 245 | |
| 246 prefetch_store(dst); | |
| 247 | |
| 248 switch (w) { | |
| 249 case 4: | |
| 250 case 8: | |
| 251 case 16: | |
| 252 case 32: | |
| 253 convolve_bi_avg_vert_4_dspr2(src, src_stride, | |
| 254 dst, dst_stride, | |
| 255 filter_y, w, h); | |
| 256 break; | |
| 257 case 64: | |
| 258 prefetch_store(dst + 32); | |
| 259 convolve_bi_avg_vert_64_dspr2(src, src_stride, | |
| 260 dst, dst_stride, | |
| 261 filter_y, h); | |
| 262 break; | |
| 263 default: | |
| 264 vpx_convolve8_avg_vert_c(src, src_stride, | |
| 265 dst, dst_stride, | |
| 266 filter_x, x_step_q4, | |
| 267 filter_y, y_step_q4, | |
| 268 w, h); | |
| 269 break; | |
| 270 } | |
| 271 } else { | |
| 272 vpx_convolve8_avg_vert_c(src, src_stride, | |
| 273 dst, dst_stride, | |
| 274 filter_x, x_step_q4, | |
| 275 filter_y, y_step_q4, | |
| 276 w, h); | |
| 277 } | |
| 278 } | |
| 279 #endif | |
| OLD | NEW |