| OLD | NEW |
| 1 // Copyright 2010 Google Inc. All Rights Reserved. | 1 // Copyright 2010 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // Use of this source code is governed by a BSD-style license | 3 // Use of this source code is governed by a BSD-style license |
| 4 // that can be found in the COPYING file in the root of the source | 4 // that can be found in the COPYING file in the root of the source |
| 5 // tree. An additional intellectual property rights grant can be found | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may | 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. | 7 // be found in the AUTHORS file in the root of the source tree. |
| 8 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 9 // | 9 // |
| 10 // Speed-critical decoding functions, default plain-C implementations. | 10 // Speed-critical decoding functions, default plain-C implementations. |
| 11 // | 11 // |
| 12 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
| 13 | 13 |
| 14 #include "./dsp.h" | 14 #include "./dsp.h" |
| 15 #include "../dec/vp8i.h" | 15 #include "../dec/vp8i.h" |
| 16 #include "../utils/utils.h" |
| 16 | 17 |
| 17 //------------------------------------------------------------------------------ | 18 //------------------------------------------------------------------------------ |
| 18 | 19 |
| 19 static WEBP_INLINE uint8_t clip_8b(int v) { | 20 static WEBP_INLINE uint8_t clip_8b(int v) { |
| 20 return (!(v & ~0xff)) ? v : (v < 0) ? 0 : 255; | 21 return (!(v & ~0xff)) ? v : (v < 0) ? 0 : 255; |
| 21 } | 22 } |
| 22 | 23 |
| 23 //------------------------------------------------------------------------------ | 24 //------------------------------------------------------------------------------ |
| 24 // Transforms (Paragraph 14.4) | 25 // Transforms (Paragraph 14.4) |
| 25 | 26 |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 648 } |
| 648 | 649 |
| 649 static void HFilter8i(uint8_t* u, uint8_t* v, int stride, | 650 static void HFilter8i(uint8_t* u, uint8_t* v, int stride, |
| 650 int thresh, int ithresh, int hev_thresh) { | 651 int thresh, int ithresh, int hev_thresh) { |
| 651 FilterLoop24(u + 4, 1, stride, 8, thresh, ithresh, hev_thresh); | 652 FilterLoop24(u + 4, 1, stride, 8, thresh, ithresh, hev_thresh); |
| 652 FilterLoop24(v + 4, 1, stride, 8, thresh, ithresh, hev_thresh); | 653 FilterLoop24(v + 4, 1, stride, 8, thresh, ithresh, hev_thresh); |
| 653 } | 654 } |
| 654 | 655 |
| 655 //------------------------------------------------------------------------------ | 656 //------------------------------------------------------------------------------ |
| 656 | 657 |
| 658 static void DitherCombine8x8(const uint8_t* dither, uint8_t* dst, |
| 659 int dst_stride) { |
| 660 int i, j; |
| 661 for (j = 0; j < 8; ++j) { |
| 662 for (i = 0; i < 8; ++i) { |
| 663 const int delta0 = dither[i] - VP8_DITHER_AMP_CENTER; |
| 664 const int delta1 = |
| 665 (delta0 + VP8_DITHER_DESCALE_ROUNDER) >> VP8_DITHER_DESCALE; |
| 666 dst[i] = clip_8b((int)dst[i] + delta1); |
| 667 } |
| 668 dst += dst_stride; |
| 669 dither += 8; |
| 670 } |
| 671 } |
| 672 |
| 673 //------------------------------------------------------------------------------ |
| 674 |
| 657 VP8DecIdct2 VP8Transform; | 675 VP8DecIdct2 VP8Transform; |
| 658 VP8DecIdct VP8TransformAC3; | 676 VP8DecIdct VP8TransformAC3; |
| 659 VP8DecIdct VP8TransformUV; | 677 VP8DecIdct VP8TransformUV; |
| 660 VP8DecIdct VP8TransformDC; | 678 VP8DecIdct VP8TransformDC; |
| 661 VP8DecIdct VP8TransformDCUV; | 679 VP8DecIdct VP8TransformDCUV; |
| 662 | 680 |
| 663 VP8LumaFilterFunc VP8VFilter16; | 681 VP8LumaFilterFunc VP8VFilter16; |
| 664 VP8LumaFilterFunc VP8HFilter16; | 682 VP8LumaFilterFunc VP8HFilter16; |
| 665 VP8ChromaFilterFunc VP8VFilter8; | 683 VP8ChromaFilterFunc VP8VFilter8; |
| 666 VP8ChromaFilterFunc VP8HFilter8; | 684 VP8ChromaFilterFunc VP8HFilter8; |
| 667 VP8LumaFilterFunc VP8VFilter16i; | 685 VP8LumaFilterFunc VP8VFilter16i; |
| 668 VP8LumaFilterFunc VP8HFilter16i; | 686 VP8LumaFilterFunc VP8HFilter16i; |
| 669 VP8ChromaFilterFunc VP8VFilter8i; | 687 VP8ChromaFilterFunc VP8VFilter8i; |
| 670 VP8ChromaFilterFunc VP8HFilter8i; | 688 VP8ChromaFilterFunc VP8HFilter8i; |
| 671 VP8SimpleFilterFunc VP8SimpleVFilter16; | 689 VP8SimpleFilterFunc VP8SimpleVFilter16; |
| 672 VP8SimpleFilterFunc VP8SimpleHFilter16; | 690 VP8SimpleFilterFunc VP8SimpleHFilter16; |
| 673 VP8SimpleFilterFunc VP8SimpleVFilter16i; | 691 VP8SimpleFilterFunc VP8SimpleVFilter16i; |
| 674 VP8SimpleFilterFunc VP8SimpleHFilter16i; | 692 VP8SimpleFilterFunc VP8SimpleHFilter16i; |
| 675 | 693 |
| 694 void (*VP8DitherCombine8x8)(const uint8_t* dither, uint8_t* dst, |
| 695 int dst_stride); |
| 696 |
| 676 extern void VP8DspInitSSE2(void); | 697 extern void VP8DspInitSSE2(void); |
| 677 extern void VP8DspInitSSE41(void); | 698 extern void VP8DspInitSSE41(void); |
| 678 extern void VP8DspInitNEON(void); | 699 extern void VP8DspInitNEON(void); |
| 679 extern void VP8DspInitMIPS32(void); | 700 extern void VP8DspInitMIPS32(void); |
| 680 extern void VP8DspInitMIPSdspR2(void); | 701 extern void VP8DspInitMIPSdspR2(void); |
| 702 extern void VP8DspInitMSA(void); |
| 681 | 703 |
| 682 static volatile VP8CPUInfo dec_last_cpuinfo_used = | 704 static volatile VP8CPUInfo dec_last_cpuinfo_used = |
| 683 (VP8CPUInfo)&dec_last_cpuinfo_used; | 705 (VP8CPUInfo)&dec_last_cpuinfo_used; |
| 684 | 706 |
| 685 WEBP_TSAN_IGNORE_FUNCTION void VP8DspInit(void) { | 707 WEBP_TSAN_IGNORE_FUNCTION void VP8DspInit(void) { |
| 686 if (dec_last_cpuinfo_used == VP8GetCPUInfo) return; | 708 if (dec_last_cpuinfo_used == VP8GetCPUInfo) return; |
| 687 | 709 |
| 688 VP8InitClipTables(); | 710 VP8InitClipTables(); |
| 689 | 711 |
| 690 VP8TransformWHT = TransformWHT; | 712 VP8TransformWHT = TransformWHT; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 VP8PredLuma16[6] = DC16NoTopLeft; | 749 VP8PredLuma16[6] = DC16NoTopLeft; |
| 728 | 750 |
| 729 VP8PredChroma8[0] = DC8uv; | 751 VP8PredChroma8[0] = DC8uv; |
| 730 VP8PredChroma8[1] = TM8uv; | 752 VP8PredChroma8[1] = TM8uv; |
| 731 VP8PredChroma8[2] = VE8uv; | 753 VP8PredChroma8[2] = VE8uv; |
| 732 VP8PredChroma8[3] = HE8uv; | 754 VP8PredChroma8[3] = HE8uv; |
| 733 VP8PredChroma8[4] = DC8uvNoTop; | 755 VP8PredChroma8[4] = DC8uvNoTop; |
| 734 VP8PredChroma8[5] = DC8uvNoLeft; | 756 VP8PredChroma8[5] = DC8uvNoLeft; |
| 735 VP8PredChroma8[6] = DC8uvNoTopLeft; | 757 VP8PredChroma8[6] = DC8uvNoTopLeft; |
| 736 | 758 |
| 759 VP8DitherCombine8x8 = DitherCombine8x8; |
| 760 |
| 737 // If defined, use CPUInfo() to overwrite some pointers with faster versions. | 761 // If defined, use CPUInfo() to overwrite some pointers with faster versions. |
| 738 if (VP8GetCPUInfo != NULL) { | 762 if (VP8GetCPUInfo != NULL) { |
| 739 #if defined(WEBP_USE_SSE2) | 763 #if defined(WEBP_USE_SSE2) |
| 740 if (VP8GetCPUInfo(kSSE2)) { | 764 if (VP8GetCPUInfo(kSSE2)) { |
| 741 VP8DspInitSSE2(); | 765 VP8DspInitSSE2(); |
| 742 #if defined(WEBP_USE_SSE41) | 766 #if defined(WEBP_USE_SSE41) |
| 743 if (VP8GetCPUInfo(kSSE4_1)) { | 767 if (VP8GetCPUInfo(kSSE4_1)) { |
| 744 VP8DspInitSSE41(); | 768 VP8DspInitSSE41(); |
| 745 } | 769 } |
| 746 #endif | 770 #endif |
| 747 } | 771 } |
| 748 #endif | 772 #endif |
| 749 #if defined(WEBP_USE_NEON) | 773 #if defined(WEBP_USE_NEON) |
| 750 if (VP8GetCPUInfo(kNEON)) { | 774 if (VP8GetCPUInfo(kNEON)) { |
| 751 VP8DspInitNEON(); | 775 VP8DspInitNEON(); |
| 752 } | 776 } |
| 753 #endif | 777 #endif |
| 754 #if defined(WEBP_USE_MIPS32) | 778 #if defined(WEBP_USE_MIPS32) |
| 755 if (VP8GetCPUInfo(kMIPS32)) { | 779 if (VP8GetCPUInfo(kMIPS32)) { |
| 756 VP8DspInitMIPS32(); | 780 VP8DspInitMIPS32(); |
| 757 } | 781 } |
| 758 #endif | 782 #endif |
| 759 #if defined(WEBP_USE_MIPS_DSP_R2) | 783 #if defined(WEBP_USE_MIPS_DSP_R2) |
| 760 if (VP8GetCPUInfo(kMIPSdspR2)) { | 784 if (VP8GetCPUInfo(kMIPSdspR2)) { |
| 761 VP8DspInitMIPSdspR2(); | 785 VP8DspInitMIPSdspR2(); |
| 762 } | 786 } |
| 763 #endif | 787 #endif |
| 788 #if defined(WEBP_USE_MSA) |
| 789 if (VP8GetCPUInfo(kMSA)) { |
| 790 VP8DspInitMSA(); |
| 791 } |
| 792 #endif |
| 764 } | 793 } |
| 765 dec_last_cpuinfo_used = VP8GetCPUInfo; | 794 dec_last_cpuinfo_used = VP8GetCPUInfo; |
| 766 } | 795 } |
| OLD | NEW |