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

Side by Side Diff: source/scale.cc

Issue 1654253004: rework scale code for ubsan (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: merge with head Created 4 years, 10 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 sum += src_ptr[x]; 652 sum += src_ptr[x];
653 } 653 }
654 return sum; 654 return sum;
655 } 655 }
656 656
657 static void ScaleAddCols2_C(int dst_width, int boxheight, int x, int dx, 657 static void ScaleAddCols2_C(int dst_width, int boxheight, int x, int dx,
658 const uint16* src_ptr, uint8* dst_ptr) { 658 const uint16* src_ptr, uint8* dst_ptr) {
659 int i; 659 int i;
660 int scaletbl[2]; 660 int scaletbl[2];
661 int minboxwidth = dx >> 16; 661 int minboxwidth = dx >> 16;
662 int* scaleptr = scaletbl - minboxwidth;
663 int boxwidth; 662 int boxwidth;
664 scaletbl[0] = 65536 / (MIN1(minboxwidth) * boxheight); 663 scaletbl[0] = 65536 / (MIN1(minboxwidth) * boxheight);
665 scaletbl[1] = 65536 / (MIN1(minboxwidth + 1) * boxheight); 664 scaletbl[1] = 65536 / (MIN1(minboxwidth + 1) * boxheight);
666 for (i = 0; i < dst_width; ++i) { 665 for (i = 0; i < dst_width; ++i) {
667 int ix = x >> 16; 666 int ix = x >> 16;
668 x += dx; 667 x += dx;
669 boxwidth = MIN1((x >> 16) - ix); 668 boxwidth = MIN1((x >> 16) - ix);
670 *dst_ptr++ = SumPixels(boxwidth, src_ptr + ix) * scaleptr[boxwidth] >> 16; 669 *dst_ptr++ = SumPixels(boxwidth, src_ptr + ix) *
670 scaletbl[boxwidth - minboxwidth] >> 16;
671 } 671 }
672 } 672 }
673 673
674 static void ScaleAddCols2_16_C(int dst_width, int boxheight, int x, int dx, 674 static void ScaleAddCols2_16_C(int dst_width, int boxheight, int x, int dx,
675 const uint32* src_ptr, uint16* dst_ptr) { 675 const uint32* src_ptr, uint16* dst_ptr) {
676 int i; 676 int i;
677 int scaletbl[2]; 677 int scaletbl[2];
678 int minboxwidth = dx >> 16; 678 int minboxwidth = dx >> 16;
679 int* scaleptr = scaletbl - minboxwidth;
680 int boxwidth; 679 int boxwidth;
681 scaletbl[0] = 65536 / (MIN1(minboxwidth) * boxheight); 680 scaletbl[0] = 65536 / (MIN1(minboxwidth) * boxheight);
682 scaletbl[1] = 65536 / (MIN1(minboxwidth + 1) * boxheight); 681 scaletbl[1] = 65536 / (MIN1(minboxwidth + 1) * boxheight);
683 for (i = 0; i < dst_width; ++i) { 682 for (i = 0; i < dst_width; ++i) {
684 int ix = x >> 16; 683 int ix = x >> 16;
685 x += dx; 684 x += dx;
686 boxwidth = MIN1((x >> 16) - ix); 685 boxwidth = MIN1((x >> 16) - ix);
687 *dst_ptr++ = 686 *dst_ptr++ = SumPixels_16(boxwidth, src_ptr + ix) *
688 SumPixels_16(boxwidth, src_ptr + ix) * scaleptr[boxwidth] >> 16; 687 scaletbl[boxwidth - minboxwidth] >> 16;
689 } 688 }
690 } 689 }
691 690
692 static void ScaleAddCols0_C(int dst_width, int boxheight, int x, int, 691 static void ScaleAddCols0_C(int dst_width, int boxheight, int x, int,
693 const uint16* src_ptr, uint8* dst_ptr) { 692 const uint16* src_ptr, uint8* dst_ptr) {
694 int scaleval = 65536 / boxheight; 693 int scaleval = 65536 / boxheight;
695 int i; 694 int i;
696 src_ptr += (x >> 16); 695 src_ptr += (x >> 16);
697 for (i = 0; i < dst_width; ++i) { 696 for (i = 0; i < dst_width; ++i) {
698 *dst_ptr++ = src_ptr[i] * scaleval >> 16; 697 *dst_ptr++ = src_ptr[i] * scaleval >> 16;
(...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 dst_u, dst_halfwidth, 1663 dst_u, dst_halfwidth,
1665 dst_v, dst_halfwidth, 1664 dst_v, dst_halfwidth,
1666 dst_width, aheight, 1665 dst_width, aheight,
1667 interpolate ? kFilterBox : kFilterNone); 1666 interpolate ? kFilterBox : kFilterNone);
1668 } 1667 }
1669 1668
1670 #ifdef __cplusplus 1669 #ifdef __cplusplus
1671 } // extern "C" 1670 } // extern "C"
1672 } // namespace libyuv 1671 } // namespace libyuv
1673 #endif 1672 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698