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

Side by Side Diff: third_party/libwebp/dsp/enc.c

Issue 116213006: Update libwebp to 0.4.0 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: After Blink Roll Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « third_party/libwebp/dsp/dsp.h ('k') | third_party/libwebp/dsp/enc_neon.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 Google Inc. All Rights Reserved. 1 // Copyright 2011 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 encoding functions. 10 // Speed-critical encoding functions.
11 // 11 //
12 // Author: Skal (pascal.massimino@gmail.com) 12 // Author: Skal (pascal.massimino@gmail.com)
13 13
14 #include <assert.h>
14 #include <stdlib.h> // for abs() 15 #include <stdlib.h> // for abs()
16
15 #include "./dsp.h" 17 #include "./dsp.h"
16 #include "../enc/vp8enci.h" 18 #include "../enc/vp8enci.h"
17 19
18 #if defined(__cplusplus) || defined(c_plusplus)
19 extern "C" {
20 #endif
21
22 static WEBP_INLINE uint8_t clip_8b(int v) { 20 static WEBP_INLINE uint8_t clip_8b(int v) {
23 return (!(v & ~0xff)) ? v : (v < 0) ? 0 : 255; 21 return (!(v & ~0xff)) ? v : (v < 0) ? 0 : 255;
24 } 22 }
25 23
26 static WEBP_INLINE int clip_max(int v, int max) { 24 static WEBP_INLINE int clip_max(int v, int max) {
27 return (v > max) ? max : v; 25 return (v > max) ? max : v;
28 } 26 }
29 27
30 //------------------------------------------------------------------------------ 28 //------------------------------------------------------------------------------
31 // Compute susceptibility based on DCT-coeff histograms: 29 // Compute susceptibility based on DCT-coeff histograms:
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 out[ 0] = (a0 + a1) >> 3; 181 out[ 0] = (a0 + a1) >> 3;
184 out[16] = (a3 + a2) >> 3; 182 out[16] = (a3 + a2) >> 3;
185 out[32] = (a0 - a1) >> 3; 183 out[32] = (a0 - a1) >> 3;
186 out[48] = (a3 - a2) >> 3; 184 out[48] = (a3 - a2) >> 3;
187 out += 64; 185 out += 64;
188 } 186 }
189 } 187 }
190 188
191 static void FTransformWHT(const int16_t* in, int16_t* out) { 189 static void FTransformWHT(const int16_t* in, int16_t* out) {
192 // input is 12b signed 190 // input is 12b signed
193 int16_t tmp[16]; 191 int32_t tmp[16];
194 int i; 192 int i;
195 for (i = 0; i < 4; ++i, in += 64) { 193 for (i = 0; i < 4; ++i, in += 64) {
196 const int a0 = (in[0 * 16] + in[2 * 16]); // 13b 194 const int a0 = (in[0 * 16] + in[2 * 16]); // 13b
197 const int a1 = (in[1 * 16] + in[3 * 16]); 195 const int a1 = (in[1 * 16] + in[3 * 16]);
198 const int a2 = (in[1 * 16] - in[3 * 16]); 196 const int a2 = (in[1 * 16] - in[3 * 16]);
199 const int a3 = (in[0 * 16] - in[2 * 16]); 197 const int a3 = (in[0 * 16] - in[2 * 16]);
200 tmp[0 + i * 4] = a0 + a1; // 14b 198 tmp[0 + i * 4] = a0 + a1; // 14b
201 tmp[1 + i * 4] = a3 + a2; 199 tmp[1 + i * 4] = a3 + a2;
202 tmp[2 + i * 4] = a3 - a2; 200 tmp[2 + i * 4] = a3 - a2;
203 tmp[3 + i * 4] = a0 - a1; 201 tmp[3 + i * 4] = a0 - a1;
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 in[j] = out[n] * Q; 643 in[j] = out[n] * Q;
646 if (out[n]) last = n; 644 if (out[n]) last = n;
647 } else { 645 } else {
648 out[n] = 0; 646 out[n] = 0;
649 in[j] = 0; 647 in[j] = 0;
650 } 648 }
651 } 649 }
652 return (last >= 0); 650 return (last >= 0);
653 } 651 }
654 652
653 static int QuantizeBlockWHT(int16_t in[16], int16_t out[16],
654 const VP8Matrix* const mtx) {
655 int n, last = -1;
656 for (n = 0; n < 16; ++n) {
657 const int j = kZigzag[n];
658 const int sign = (in[j] < 0);
659 const int coeff = sign ? -in[j] : in[j];
660 assert(mtx->sharpen_[j] == 0);
661 if (coeff > mtx->zthresh_[j]) {
662 const int Q = mtx->q_[j];
663 const int iQ = mtx->iq_[j];
664 const int B = mtx->bias_[j];
665 out[n] = QUANTDIV(coeff, iQ, B);
666 if (out[n] > MAX_LEVEL) out[n] = MAX_LEVEL;
667 if (sign) out[n] = -out[n];
668 in[j] = out[n] * Q;
669 if (out[n]) last = n;
670 } else {
671 out[n] = 0;
672 in[j] = 0;
673 }
674 }
675 return (last >= 0);
676 }
677
655 //------------------------------------------------------------------------------ 678 //------------------------------------------------------------------------------
656 // Block copy 679 // Block copy
657 680
658 static WEBP_INLINE void Copy(const uint8_t* src, uint8_t* dst, int size) { 681 static WEBP_INLINE void Copy(const uint8_t* src, uint8_t* dst, int size) {
659 int y; 682 int y;
660 for (y = 0; y < size; ++y) { 683 for (y = 0; y < size; ++y) {
661 memcpy(dst, src, size); 684 memcpy(dst, src, size);
662 src += BPS; 685 src += BPS;
663 dst += BPS; 686 dst += BPS;
664 } 687 }
(...skipping 14 matching lines...) Expand all
679 VP8Intra4Preds VP8EncPredLuma4; 702 VP8Intra4Preds VP8EncPredLuma4;
680 VP8IntraPreds VP8EncPredLuma16; 703 VP8IntraPreds VP8EncPredLuma16;
681 VP8IntraPreds VP8EncPredChroma8; 704 VP8IntraPreds VP8EncPredChroma8;
682 VP8Metric VP8SSE16x16; 705 VP8Metric VP8SSE16x16;
683 VP8Metric VP8SSE8x8; 706 VP8Metric VP8SSE8x8;
684 VP8Metric VP8SSE16x8; 707 VP8Metric VP8SSE16x8;
685 VP8Metric VP8SSE4x4; 708 VP8Metric VP8SSE4x4;
686 VP8WMetric VP8TDisto4x4; 709 VP8WMetric VP8TDisto4x4;
687 VP8WMetric VP8TDisto16x16; 710 VP8WMetric VP8TDisto16x16;
688 VP8QuantizeBlock VP8EncQuantizeBlock; 711 VP8QuantizeBlock VP8EncQuantizeBlock;
712 VP8QuantizeBlockWHT VP8EncQuantizeBlockWHT;
689 VP8BlockCopy VP8Copy4x4; 713 VP8BlockCopy VP8Copy4x4;
690 714
691 extern void VP8EncDspInitSSE2(void); 715 extern void VP8EncDspInitSSE2(void);
692 #if defined(WEBP_USE_NEON)
693 extern void VP8EncDspInitNEON(void); 716 extern void VP8EncDspInitNEON(void);
694 #endif
695 717
696 void VP8EncDspInit(void) { 718 void VP8EncDspInit(void) {
697 InitTables(); 719 InitTables();
698 720
699 // default C implementations 721 // default C implementations
700 VP8CollectHistogram = CollectHistogram; 722 VP8CollectHistogram = CollectHistogram;
701 VP8ITransform = ITransform; 723 VP8ITransform = ITransform;
702 VP8FTransform = FTransform; 724 VP8FTransform = FTransform;
703 VP8ITransformWHT = ITransformWHT; 725 VP8ITransformWHT = ITransformWHT;
704 VP8FTransformWHT = FTransformWHT; 726 VP8FTransformWHT = FTransformWHT;
705 VP8EncPredLuma4 = Intra4Preds; 727 VP8EncPredLuma4 = Intra4Preds;
706 VP8EncPredLuma16 = Intra16Preds; 728 VP8EncPredLuma16 = Intra16Preds;
707 VP8EncPredChroma8 = IntraChromaPreds; 729 VP8EncPredChroma8 = IntraChromaPreds;
708 VP8SSE16x16 = SSE16x16; 730 VP8SSE16x16 = SSE16x16;
709 VP8SSE8x8 = SSE8x8; 731 VP8SSE8x8 = SSE8x8;
710 VP8SSE16x8 = SSE16x8; 732 VP8SSE16x8 = SSE16x8;
711 VP8SSE4x4 = SSE4x4; 733 VP8SSE4x4 = SSE4x4;
712 VP8TDisto4x4 = Disto4x4; 734 VP8TDisto4x4 = Disto4x4;
713 VP8TDisto16x16 = Disto16x16; 735 VP8TDisto16x16 = Disto16x16;
714 VP8EncQuantizeBlock = QuantizeBlock; 736 VP8EncQuantizeBlock = QuantizeBlock;
737 VP8EncQuantizeBlockWHT = QuantizeBlockWHT;
715 VP8Copy4x4 = Copy4x4; 738 VP8Copy4x4 = Copy4x4;
716 739
717 // If defined, use CPUInfo() to overwrite some pointers with faster versions. 740 // If defined, use CPUInfo() to overwrite some pointers with faster versions.
718 if (VP8GetCPUInfo) { 741 if (VP8GetCPUInfo) {
719 #if defined(WEBP_USE_SSE2) 742 #if defined(WEBP_USE_SSE2)
720 if (VP8GetCPUInfo(kSSE2)) { 743 if (VP8GetCPUInfo(kSSE2)) {
721 VP8EncDspInitSSE2(); 744 VP8EncDspInitSSE2();
722 } 745 }
723 #elif defined(WEBP_USE_NEON) 746 #elif defined(WEBP_USE_NEON)
724 if (VP8GetCPUInfo(kNEON)) { 747 if (VP8GetCPUInfo(kNEON)) {
725 VP8EncDspInitNEON(); 748 VP8EncDspInitNEON();
726 } 749 }
727 #endif 750 #endif
728 } 751 }
729 } 752 }
730 753
731 #if defined(__cplusplus) || defined(c_plusplus)
732 } // extern "C"
733 #endif
OLDNEW
« no previous file with comments | « third_party/libwebp/dsp/dsp.h ('k') | third_party/libwebp/dsp/enc_neon.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698