Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: source/scale.cc

Issue 2559683002: Add MSA optimized remaining scale row functions (Closed)
Patch Set: Variable renaming and rework Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 } 101 }
102 #endif 102 #endif
103 #if defined(HAS_SCALEROWDOWN2_DSPR2) 103 #if defined(HAS_SCALEROWDOWN2_DSPR2)
104 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(src_ptr, 4) && 104 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(src_ptr, 4) &&
105 IS_ALIGNED(src_stride, 4) && IS_ALIGNED(row_stride, 4) && 105 IS_ALIGNED(src_stride, 4) && IS_ALIGNED(row_stride, 4) &&
106 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 106 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) {
107 ScaleRowDown2 = filtering ? ScaleRowDown2Box_DSPR2 : ScaleRowDown2_DSPR2; 107 ScaleRowDown2 = filtering ? ScaleRowDown2Box_DSPR2 : ScaleRowDown2_DSPR2;
108 } 108 }
109 #endif 109 #endif
110 #if defined(HAS_SCALEROWDOWN2_MSA)
111 if (TestCpuFlag(kCpuHasMSA)) {
112 ScaleRowDown2 =
113 filtering == kFilterNone
114 ? ScaleRowDown2_Any_MSA
115 : (filtering == kFilterLinear ? ScaleRowDown2Linear_Any_MSA
116 : ScaleRowDown2Box_Any_MSA);
117 if (IS_ALIGNED(dst_width, 32)) {
118 ScaleRowDown2 = filtering == kFilterNone ? ScaleRowDown2_MSA
119 : (filtering == kFilterLinear
120 ? ScaleRowDown2Linear_MSA
121 : ScaleRowDown2Box_MSA);
122 }
123 }
124 #endif
110 125
111 if (filtering == kFilterLinear) { 126 if (filtering == kFilterLinear) {
112 src_stride = 0; 127 src_stride = 0;
113 } 128 }
114 // TODO(fbarchard): Loop through source height to allow odd height. 129 // TODO(fbarchard): Loop through source height to allow odd height.
115 for (y = 0; y < dst_height; ++y) { 130 for (y = 0; y < dst_height; ++y) {
116 ScaleRowDown2(src_ptr, src_stride, dst_ptr, dst_width); 131 ScaleRowDown2(src_ptr, src_stride, dst_ptr, dst_width);
117 src_ptr += row_stride; 132 src_ptr += row_stride;
118 dst_ptr += dst_stride; 133 dst_ptr += dst_stride;
119 } 134 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 240 }
226 } 241 }
227 #endif 242 #endif
228 #if defined(HAS_SCALEROWDOWN4_DSPR2) 243 #if defined(HAS_SCALEROWDOWN4_DSPR2)
229 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(row_stride, 4) && 244 if (TestCpuFlag(kCpuHasDSPR2) && IS_ALIGNED(row_stride, 4) &&
230 IS_ALIGNED(src_ptr, 4) && IS_ALIGNED(src_stride, 4) && 245 IS_ALIGNED(src_ptr, 4) && IS_ALIGNED(src_stride, 4) &&
231 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 246 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) {
232 ScaleRowDown4 = filtering ? ScaleRowDown4Box_DSPR2 : ScaleRowDown4_DSPR2; 247 ScaleRowDown4 = filtering ? ScaleRowDown4Box_DSPR2 : ScaleRowDown4_DSPR2;
233 } 248 }
234 #endif 249 #endif
250 #if defined(HAS_SCALEROWDOWN4_MSA)
251 if (TestCpuFlag(kCpuHasMSA)) {
252 ScaleRowDown4 =
253 filtering ? ScaleRowDown4Box_Any_MSA : ScaleRowDown4_Any_MSA;
254 if (IS_ALIGNED(dst_width, 16)) {
255 ScaleRowDown4 = filtering ? ScaleRowDown4Box_MSA : ScaleRowDown4_MSA;
256 }
257 }
258 #endif
235 259
236 if (filtering == kFilterLinear) { 260 if (filtering == kFilterLinear) {
237 src_stride = 0; 261 src_stride = 0;
238 } 262 }
239 for (y = 0; y < dst_height; ++y) { 263 for (y = 0; y < dst_height; ++y) {
240 ScaleRowDown4(src_ptr, src_stride, dst_ptr, dst_width); 264 ScaleRowDown4(src_ptr, src_stride, dst_ptr, dst_width);
241 src_ptr += row_stride; 265 src_ptr += row_stride;
242 dst_ptr += dst_stride; 266 dst_ptr += dst_stride;
243 } 267 }
244 } 268 }
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) { 584 IS_ALIGNED(dst_ptr, 4) && IS_ALIGNED(dst_stride, 4)) {
561 if (!filtering) { 585 if (!filtering) {
562 ScaleRowDown38_3 = ScaleRowDown38_DSPR2; 586 ScaleRowDown38_3 = ScaleRowDown38_DSPR2;
563 ScaleRowDown38_2 = ScaleRowDown38_DSPR2; 587 ScaleRowDown38_2 = ScaleRowDown38_DSPR2;
564 } else { 588 } else {
565 ScaleRowDown38_3 = ScaleRowDown38_3_Box_DSPR2; 589 ScaleRowDown38_3 = ScaleRowDown38_3_Box_DSPR2;
566 ScaleRowDown38_2 = ScaleRowDown38_2_Box_DSPR2; 590 ScaleRowDown38_2 = ScaleRowDown38_2_Box_DSPR2;
567 } 591 }
568 } 592 }
569 #endif 593 #endif
594 #if defined(HAS_SCALEROWDOWN38_MSA)
595 if (TestCpuFlag(kCpuHasMSA)) {
596 if (!filtering) {
597 ScaleRowDown38_3 = ScaleRowDown38_Any_MSA;
598 ScaleRowDown38_2 = ScaleRowDown38_Any_MSA;
599 } else {
600 ScaleRowDown38_3 = ScaleRowDown38_3_Box_Any_MSA;
601 ScaleRowDown38_2 = ScaleRowDown38_2_Box_Any_MSA;
602 }
603 if (dst_width % 12 == 0) {
604 if (!filtering) {
605 ScaleRowDown38_3 = ScaleRowDown38_MSA;
606 ScaleRowDown38_2 = ScaleRowDown38_MSA;
607 } else {
608 ScaleRowDown38_3 = ScaleRowDown38_3_Box_MSA;
609 ScaleRowDown38_2 = ScaleRowDown38_2_Box_MSA;
610 }
611 }
612 }
613 #endif
570 614
571 for (y = 0; y < dst_height - 2; y += 3) { 615 for (y = 0; y < dst_height - 2; y += 3) {
572 ScaleRowDown38_3(src_ptr, filter_stride, dst_ptr, dst_width); 616 ScaleRowDown38_3(src_ptr, filter_stride, dst_ptr, dst_width);
573 src_ptr += src_stride * 3; 617 src_ptr += src_stride * 3;
574 dst_ptr += dst_stride; 618 dst_ptr += dst_stride;
575 ScaleRowDown38_3(src_ptr, filter_stride, dst_ptr, dst_width); 619 ScaleRowDown38_3(src_ptr, filter_stride, dst_ptr, dst_width);
576 src_ptr += src_stride * 3; 620 src_ptr += src_stride * 3;
577 dst_ptr += dst_stride; 621 dst_ptr += dst_stride;
578 ScaleRowDown38_2(src_ptr, filter_stride, dst_ptr, dst_width); 622 ScaleRowDown38_2(src_ptr, filter_stride, dst_ptr, dst_width);
579 src_ptr += src_stride * 2; 623 src_ptr += src_stride * 2;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 } 879 }
836 #endif 880 #endif
837 #if defined(HAS_SCALEADDROW_NEON) 881 #if defined(HAS_SCALEADDROW_NEON)
838 if (TestCpuFlag(kCpuHasNEON)) { 882 if (TestCpuFlag(kCpuHasNEON)) {
839 ScaleAddRow = ScaleAddRow_Any_NEON; 883 ScaleAddRow = ScaleAddRow_Any_NEON;
840 if (IS_ALIGNED(src_width, 16)) { 884 if (IS_ALIGNED(src_width, 16)) {
841 ScaleAddRow = ScaleAddRow_NEON; 885 ScaleAddRow = ScaleAddRow_NEON;
842 } 886 }
843 } 887 }
844 #endif 888 #endif
889 #if defined(HAS_SCALEADDROW_MSA)
890 if (TestCpuFlag(kCpuHasMSA)) {
891 ScaleAddRow = ScaleAddRow_Any_MSA;
892 if (IS_ALIGNED(src_width, 16)) {
893 ScaleAddRow = ScaleAddRow_MSA;
894 }
895 }
896 #endif
845 897
846 for (j = 0; j < dst_height; ++j) { 898 for (j = 0; j < dst_height; ++j) {
847 int boxheight; 899 int boxheight;
848 int iy = y >> 16; 900 int iy = y >> 16;
849 const uint8* src = src_ptr + iy * src_stride; 901 const uint8* src = src_ptr + iy * src_stride;
850 y += dy; 902 y += dy;
851 if (y > max_y) { 903 if (y > max_y) {
852 y = max_y; 904 y = max_y;
853 } 905 }
854 boxheight = MIN1((y >> 16) - iy); 906 boxheight = MIN1((y >> 16) - iy);
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 return I420Scale(src_y, src_width, src_u, src_halfwidth, src_v, src_halfwidth, 1822 return I420Scale(src_y, src_width, src_u, src_halfwidth, src_v, src_halfwidth,
1771 src_width, src_height, dst_y, dst_width, dst_u, 1823 src_width, src_height, dst_y, dst_width, dst_u,
1772 dst_halfwidth, dst_v, dst_halfwidth, dst_width, aheight, 1824 dst_halfwidth, dst_v, dst_halfwidth, dst_width, aheight,
1773 interpolate ? kFilterBox : kFilterNone); 1825 interpolate ? kFilterBox : kFilterNone);
1774 } 1826 }
1775 1827
1776 #ifdef __cplusplus 1828 #ifdef __cplusplus
1777 } // extern "C" 1829 } // extern "C"
1778 } // namespace libyuv 1830 } // namespace libyuv
1779 #endif 1831 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698