/src/libwebp/src/dsp/lossless_common.h
Line | Count | Source |
1 | | // Copyright 2012 Google Inc. All Rights Reserved. |
2 | | // |
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 |
5 | | // tree. An additional intellectual property rights grant can be found |
6 | | // in the file PATENTS. All contributing project authors may |
7 | | // be found in the AUTHORS file in the root of the source tree. |
8 | | // ----------------------------------------------------------------------------- |
9 | | // |
10 | | // Image transforms and color space conversion methods for lossless decoder. |
11 | | // |
12 | | // Authors: Vikas Arora (vikaas.arora@gmail.com) |
13 | | // Jyrki Alakuijala (jyrki@google.com) |
14 | | // Vincent Rabaud (vrabaud@google.com) |
15 | | |
16 | | #ifndef WEBP_DSP_LOSSLESS_COMMON_H_ |
17 | | #define WEBP_DSP_LOSSLESS_COMMON_H_ |
18 | | |
19 | | #include <assert.h> |
20 | | #include <stddef.h> |
21 | | |
22 | | #include "src/dsp/cpu.h" |
23 | | #include "src/utils/utils.h" |
24 | | #include "src/webp/types.h" |
25 | | |
26 | | #ifdef __cplusplus |
27 | | extern "C" { |
28 | | #endif |
29 | | |
30 | | //------------------------------------------------------------------------------ |
31 | | // Decoding |
32 | | |
33 | | // color mapping related functions. |
34 | 15.1M | static WEBP_INLINE uint32_t VP8GetARGBIndex(uint32_t idx) { |
35 | 15.1M | return (idx >> 8) & 0xff; |
36 | 15.1M | } Unexecuted instantiation: vp8l_dec.c:VP8GetARGBIndex lossless.c:VP8GetARGBIndex Line | Count | Source | 34 | 15.1M | static WEBP_INLINE uint32_t VP8GetARGBIndex(uint32_t idx) { | 35 | 15.1M | return (idx >> 8) & 0xff; | 36 | 15.1M | } |
Unexecuted instantiation: lossless_sse2.c:VP8GetARGBIndex Unexecuted instantiation: vp8l_enc.c:VP8GetARGBIndex Unexecuted instantiation: palette.c:VP8GetARGBIndex Unexecuted instantiation: lossless_enc.c:VP8GetARGBIndex Unexecuted instantiation: lossless_enc_sse2.c:VP8GetARGBIndex Unexecuted instantiation: backward_references_enc.c:VP8GetARGBIndex Unexecuted instantiation: histogram_enc.c:VP8GetARGBIndex Unexecuted instantiation: near_lossless_enc.c:VP8GetARGBIndex Unexecuted instantiation: predictor_enc.c:VP8GetARGBIndex Unexecuted instantiation: lossless_enc_avx2.c:VP8GetARGBIndex Unexecuted instantiation: backward_references_cost_enc.c:VP8GetARGBIndex |
37 | | |
38 | 1.16M | static WEBP_INLINE uint8_t VP8GetAlphaIndex(uint8_t idx) { return idx; }Unexecuted instantiation: vp8l_dec.c:VP8GetAlphaIndex lossless.c:VP8GetAlphaIndex Line | Count | Source | 38 | 1.16M | static WEBP_INLINE uint8_t VP8GetAlphaIndex(uint8_t idx) { return idx; } |
Unexecuted instantiation: lossless_sse2.c:VP8GetAlphaIndex Unexecuted instantiation: vp8l_enc.c:VP8GetAlphaIndex Unexecuted instantiation: palette.c:VP8GetAlphaIndex Unexecuted instantiation: lossless_enc.c:VP8GetAlphaIndex Unexecuted instantiation: lossless_enc_sse2.c:VP8GetAlphaIndex Unexecuted instantiation: backward_references_enc.c:VP8GetAlphaIndex Unexecuted instantiation: histogram_enc.c:VP8GetAlphaIndex Unexecuted instantiation: near_lossless_enc.c:VP8GetAlphaIndex Unexecuted instantiation: predictor_enc.c:VP8GetAlphaIndex Unexecuted instantiation: lossless_enc_avx2.c:VP8GetAlphaIndex Unexecuted instantiation: backward_references_cost_enc.c:VP8GetAlphaIndex |
39 | | |
40 | 20.5M | static WEBP_INLINE uint32_t VP8GetARGBValue(uint32_t val) { return val; }Unexecuted instantiation: vp8l_dec.c:VP8GetARGBValue lossless.c:VP8GetARGBValue Line | Count | Source | 40 | 20.5M | static WEBP_INLINE uint32_t VP8GetARGBValue(uint32_t val) { return val; } |
Unexecuted instantiation: lossless_sse2.c:VP8GetARGBValue Unexecuted instantiation: vp8l_enc.c:VP8GetARGBValue Unexecuted instantiation: palette.c:VP8GetARGBValue Unexecuted instantiation: lossless_enc.c:VP8GetARGBValue Unexecuted instantiation: lossless_enc_sse2.c:VP8GetARGBValue Unexecuted instantiation: backward_references_enc.c:VP8GetARGBValue Unexecuted instantiation: histogram_enc.c:VP8GetARGBValue Unexecuted instantiation: near_lossless_enc.c:VP8GetARGBValue Unexecuted instantiation: predictor_enc.c:VP8GetARGBValue Unexecuted instantiation: lossless_enc_avx2.c:VP8GetARGBValue Unexecuted instantiation: backward_references_cost_enc.c:VP8GetARGBValue |
41 | | |
42 | 3.21M | static WEBP_INLINE uint8_t VP8GetAlphaValue(uint32_t val) { |
43 | 3.21M | return (val >> 8) & 0xff; |
44 | 3.21M | } Unexecuted instantiation: vp8l_dec.c:VP8GetAlphaValue lossless.c:VP8GetAlphaValue Line | Count | Source | 42 | 3.21M | static WEBP_INLINE uint8_t VP8GetAlphaValue(uint32_t val) { | 43 | 3.21M | return (val >> 8) & 0xff; | 44 | 3.21M | } |
Unexecuted instantiation: lossless_sse2.c:VP8GetAlphaValue Unexecuted instantiation: vp8l_enc.c:VP8GetAlphaValue Unexecuted instantiation: palette.c:VP8GetAlphaValue Unexecuted instantiation: lossless_enc.c:VP8GetAlphaValue Unexecuted instantiation: lossless_enc_sse2.c:VP8GetAlphaValue Unexecuted instantiation: backward_references_enc.c:VP8GetAlphaValue Unexecuted instantiation: histogram_enc.c:VP8GetAlphaValue Unexecuted instantiation: near_lossless_enc.c:VP8GetAlphaValue Unexecuted instantiation: predictor_enc.c:VP8GetAlphaValue Unexecuted instantiation: lossless_enc_avx2.c:VP8GetAlphaValue Unexecuted instantiation: backward_references_cost_enc.c:VP8GetAlphaValue |
45 | | |
46 | | //------------------------------------------------------------------------------ |
47 | | // Misc methods. |
48 | | |
49 | | // Computes sampled size of 'size' when sampling using 'sampling bits'. |
50 | | static WEBP_INLINE uint32_t VP8LSubSampleSize(uint32_t size, |
51 | 1.50M | uint32_t sampling_bits) { |
52 | 1.50M | return (size + (1 << sampling_bits) - 1) >> sampling_bits; |
53 | 1.50M | } vp8l_dec.c:VP8LSubSampleSize Line | Count | Source | 51 | 402k | uint32_t sampling_bits) { | 52 | 402k | return (size + (1 << sampling_bits) - 1) >> sampling_bits; | 53 | 402k | } |
lossless.c:VP8LSubSampleSize Line | Count | Source | 51 | 96.3k | uint32_t sampling_bits) { | 52 | 96.3k | return (size + (1 << sampling_bits) - 1) >> sampling_bits; | 53 | 96.3k | } |
Unexecuted instantiation: lossless_sse2.c:VP8LSubSampleSize vp8l_enc.c:VP8LSubSampleSize Line | Count | Source | 51 | 87.9k | uint32_t sampling_bits) { | 52 | 87.9k | return (size + (1 << sampling_bits) - 1) >> sampling_bits; | 53 | 87.9k | } |
Unexecuted instantiation: palette.c:VP8LSubSampleSize Unexecuted instantiation: lossless_enc.c:VP8LSubSampleSize Unexecuted instantiation: lossless_enc_sse2.c:VP8LSubSampleSize Unexecuted instantiation: backward_references_enc.c:VP8LSubSampleSize histogram_enc.c:VP8LSubSampleSize Line | Count | Source | 51 | 25.8k | uint32_t sampling_bits) { | 52 | 25.8k | return (size + (1 << sampling_bits) - 1) >> sampling_bits; | 53 | 25.8k | } |
Unexecuted instantiation: near_lossless_enc.c:VP8LSubSampleSize predictor_enc.c:VP8LSubSampleSize Line | Count | Source | 51 | 888k | uint32_t sampling_bits) { | 52 | 888k | return (size + (1 << sampling_bits) - 1) >> sampling_bits; | 53 | 888k | } |
Unexecuted instantiation: lossless_enc_avx2.c:VP8LSubSampleSize Unexecuted instantiation: backward_references_cost_enc.c:VP8LSubSampleSize |
54 | | |
55 | | // Converts near lossless quality into max number of bits shaved off. |
56 | 2.30k | static WEBP_INLINE int VP8LNearLosslessBits(int near_lossless_quality) { |
57 | | // 100 -> 0 |
58 | | // 80..99 -> 1 |
59 | | // 60..79 -> 2 |
60 | | // 40..59 -> 3 |
61 | | // 20..39 -> 4 |
62 | | // 0..19 -> 5 |
63 | 2.30k | return 5 - near_lossless_quality / 20; |
64 | 2.30k | } Unexecuted instantiation: vp8l_dec.c:VP8LNearLosslessBits Unexecuted instantiation: lossless.c:VP8LNearLosslessBits Unexecuted instantiation: lossless_sse2.c:VP8LNearLosslessBits Unexecuted instantiation: vp8l_enc.c:VP8LNearLosslessBits Unexecuted instantiation: palette.c:VP8LNearLosslessBits Unexecuted instantiation: lossless_enc.c:VP8LNearLosslessBits Unexecuted instantiation: lossless_enc_sse2.c:VP8LNearLosslessBits Unexecuted instantiation: backward_references_enc.c:VP8LNearLosslessBits Unexecuted instantiation: histogram_enc.c:VP8LNearLosslessBits Unexecuted instantiation: near_lossless_enc.c:VP8LNearLosslessBits predictor_enc.c:VP8LNearLosslessBits Line | Count | Source | 56 | 2.30k | static WEBP_INLINE int VP8LNearLosslessBits(int near_lossless_quality) { | 57 | | // 100 -> 0 | 58 | | // 80..99 -> 1 | 59 | | // 60..79 -> 2 | 60 | | // 40..59 -> 3 | 61 | | // 20..39 -> 4 | 62 | | // 0..19 -> 5 | 63 | 2.30k | return 5 - near_lossless_quality / 20; | 64 | 2.30k | } |
Unexecuted instantiation: lossless_enc_avx2.c:VP8LNearLosslessBits Unexecuted instantiation: backward_references_cost_enc.c:VP8LNearLosslessBits |
65 | | |
66 | | // ----------------------------------------------------------------------------- |
67 | | // Faster logarithm for integers. Small values use a look-up table. |
68 | | |
69 | | // The threshold till approximate version of log_2 can be used. |
70 | | // Practically, we can get rid of the call to log() as the two values match to |
71 | | // very high degree (the ratio of these two is 0.99999x). |
72 | | // Keeping a high threshold for now. |
73 | 346M | #define APPROX_LOG_WITH_CORRECTION_MAX 65536 |
74 | 73.2k | #define APPROX_LOG_MAX 4096 |
75 | | // VP8LFastLog2 and VP8LFastSLog2 are used on elements from image histograms. |
76 | | // The histogram values cannot exceed the maximum number of pixels, which |
77 | | // is (1 << 14) * (1 << 14). Therefore S * log(S) < (1 << 33). |
78 | | // No more than 32 bits of precision should be chosen. |
79 | | // To match the original float implementation, 23 bits of precision are used. |
80 | 596M | #define LOG_2_PRECISION_BITS 23 |
81 | | #define LOG_2_RECIPROCAL 1.44269504088896338700465094007086 |
82 | | // LOG_2_RECIPROCAL * (1 << LOG_2_PRECISION_BITS) |
83 | 94.5M | #define LOG_2_RECIPROCAL_FIXED_DOUBLE 12102203.161561485379934310913085937500 |
84 | 252M | #define LOG_2_RECIPROCAL_FIXED ((uint64_t)12102203) |
85 | 2.69G | #define LOG_LOOKUP_IDX_MAX 256 |
86 | | extern const uint32_t kLog2Table[LOG_LOOKUP_IDX_MAX]; |
87 | | extern const uint64_t kSLog2Table[LOG_LOOKUP_IDX_MAX]; |
88 | | typedef uint32_t (*VP8LFastLog2SlowFunc)(uint32_t v); |
89 | | typedef uint64_t (*VP8LFastSLog2SlowFunc)(uint32_t v); |
90 | | |
91 | | extern VP8LFastLog2SlowFunc VP8LFastLog2Slow; |
92 | | extern VP8LFastSLog2SlowFunc VP8LFastSLog2Slow; |
93 | | |
94 | 2.07M | static WEBP_INLINE uint32_t VP8LFastLog2(uint32_t v) { |
95 | 2.07M | return (v < LOG_LOOKUP_IDX_MAX) ? kLog2Table[v] : VP8LFastLog2Slow(v); |
96 | 2.07M | } Unexecuted instantiation: vp8l_dec.c:VP8LFastLog2 Unexecuted instantiation: lossless.c:VP8LFastLog2 Unexecuted instantiation: lossless_sse2.c:VP8LFastLog2 Line | Count | Source | 94 | 8.13k | static WEBP_INLINE uint32_t VP8LFastLog2(uint32_t v) { | 95 | 8.13k | return (v < LOG_LOOKUP_IDX_MAX) ? kLog2Table[v] : VP8LFastLog2Slow(v); | 96 | 8.13k | } |
Unexecuted instantiation: palette.c:VP8LFastLog2 Unexecuted instantiation: lossless_enc.c:VP8LFastLog2 Unexecuted instantiation: lossless_enc_sse2.c:VP8LFastLog2 Unexecuted instantiation: backward_references_enc.c:VP8LFastLog2 Unexecuted instantiation: histogram_enc.c:VP8LFastLog2 Unexecuted instantiation: near_lossless_enc.c:VP8LFastLog2 Unexecuted instantiation: predictor_enc.c:VP8LFastLog2 Unexecuted instantiation: lossless_enc_avx2.c:VP8LFastLog2 backward_references_cost_enc.c:VP8LFastLog2 Line | Count | Source | 94 | 2.06M | static WEBP_INLINE uint32_t VP8LFastLog2(uint32_t v) { | 95 | 2.06M | return (v < LOG_LOOKUP_IDX_MAX) ? kLog2Table[v] : VP8LFastLog2Slow(v); | 96 | 2.06M | } |
|
97 | | // Fast calculation of v * log2(v) for integer input. |
98 | 2.69G | static WEBP_INLINE uint64_t VP8LFastSLog2(uint32_t v) { |
99 | 2.69G | return (v < LOG_LOOKUP_IDX_MAX) ? kSLog2Table[v] : VP8LFastSLog2Slow(v); |
100 | 2.69G | } Unexecuted instantiation: vp8l_dec.c:VP8LFastSLog2 Unexecuted instantiation: lossless.c:VP8LFastSLog2 Unexecuted instantiation: lossless_sse2.c:VP8LFastSLog2 Unexecuted instantiation: vp8l_enc.c:VP8LFastSLog2 Unexecuted instantiation: palette.c:VP8LFastSLog2 lossless_enc.c:VP8LFastSLog2 Line | Count | Source | 98 | 1.68G | static WEBP_INLINE uint64_t VP8LFastSLog2(uint32_t v) { | 99 | 1.68G | return (v < LOG_LOOKUP_IDX_MAX) ? kSLog2Table[v] : VP8LFastSLog2Slow(v); | 100 | 1.68G | } |
Unexecuted instantiation: lossless_enc_sse2.c:VP8LFastSLog2 Unexecuted instantiation: backward_references_enc.c:VP8LFastSLog2 Unexecuted instantiation: histogram_enc.c:VP8LFastSLog2 Unexecuted instantiation: near_lossless_enc.c:VP8LFastSLog2 Unexecuted instantiation: predictor_enc.c:VP8LFastSLog2 lossless_enc_avx2.c:VP8LFastSLog2 Line | Count | Source | 98 | 1.00G | static WEBP_INLINE uint64_t VP8LFastSLog2(uint32_t v) { | 99 | 1.00G | return (v < LOG_LOOKUP_IDX_MAX) ? kSLog2Table[v] : VP8LFastSLog2Slow(v); | 100 | 1.00G | } |
Unexecuted instantiation: backward_references_cost_enc.c:VP8LFastSLog2 |
101 | | |
102 | 0 | static WEBP_INLINE uint64_t RightShiftRound(uint64_t v, uint32_t shift) { |
103 | 0 | return (v + (1ull << shift >> 1)) >> shift; |
104 | 0 | } Unexecuted instantiation: vp8l_dec.c:RightShiftRound Unexecuted instantiation: lossless.c:RightShiftRound Unexecuted instantiation: lossless_sse2.c:RightShiftRound Unexecuted instantiation: vp8l_enc.c:RightShiftRound Unexecuted instantiation: palette.c:RightShiftRound Unexecuted instantiation: lossless_enc.c:RightShiftRound Unexecuted instantiation: lossless_enc_sse2.c:RightShiftRound Unexecuted instantiation: backward_references_enc.c:RightShiftRound Unexecuted instantiation: histogram_enc.c:RightShiftRound Unexecuted instantiation: near_lossless_enc.c:RightShiftRound Unexecuted instantiation: predictor_enc.c:RightShiftRound Unexecuted instantiation: lossless_enc_avx2.c:RightShiftRound Unexecuted instantiation: backward_references_cost_enc.c:RightShiftRound |
105 | | |
106 | 2.42G | static WEBP_INLINE int64_t DivRound(int64_t a, int64_t b) { |
107 | 2.42G | return ((a < 0) == (b < 0)) ? ((a + b / 2) / b) : ((a - b / 2) / b); |
108 | 2.42G | } Unexecuted instantiation: vp8l_dec.c:DivRound Unexecuted instantiation: lossless.c:DivRound Unexecuted instantiation: lossless_sse2.c:DivRound Unexecuted instantiation: vp8l_enc.c:DivRound Unexecuted instantiation: palette.c:DivRound Line | Count | Source | 106 | 13.1k | static WEBP_INLINE int64_t DivRound(int64_t a, int64_t b) { | 107 | 13.1k | return ((a < 0) == (b < 0)) ? ((a + b / 2) / b) : ((a - b / 2) / b); | 108 | 13.1k | } |
Unexecuted instantiation: lossless_enc_sse2.c:DivRound Unexecuted instantiation: backward_references_enc.c:DivRound Line | Count | Source | 106 | 38.1M | static WEBP_INLINE int64_t DivRound(int64_t a, int64_t b) { | 107 | 38.1M | return ((a < 0) == (b < 0)) ? ((a + b / 2) / b) : ((a - b / 2) / b); | 108 | 38.1M | } |
Unexecuted instantiation: near_lossless_enc.c:DivRound Line | Count | Source | 106 | 1.49G | static WEBP_INLINE int64_t DivRound(int64_t a, int64_t b) { | 107 | 1.49G | return ((a < 0) == (b < 0)) ? ((a + b / 2) / b) : ((a - b / 2) / b); | 108 | 1.49G | } |
Unexecuted instantiation: lossless_enc_avx2.c:DivRound backward_references_cost_enc.c:DivRound Line | Count | Source | 106 | 890M | static WEBP_INLINE int64_t DivRound(int64_t a, int64_t b) { | 107 | 890M | return ((a < 0) == (b < 0)) ? ((a + b / 2) / b) : ((a - b / 2) / b); | 108 | 890M | } |
|
109 | | |
110 | 898M | #define WEBP_INT64_MAX ((int64_t)((1ull << 63) - 1)) |
111 | 59.0k | #define WEBP_UINT64_MAX (~0ull) |
112 | | |
113 | | // ----------------------------------------------------------------------------- |
114 | | // PrefixEncode() |
115 | | |
116 | | // Splitting of distance and length codes into prefixes and |
117 | | // extra bits. The prefixes are encoded with an entropy code |
118 | | // while the extra bits are stored just as normal bits. |
119 | | static WEBP_INLINE void VP8LPrefixEncodeBitsNoLUT(int distance, int* const code, |
120 | 181M | int* const extra_bits) { |
121 | 181M | const int highest_bit = BitsLog2Floor(--distance); |
122 | 181M | const int second_highest_bit = (distance >> (highest_bit - 1)) & 1; |
123 | 181M | *extra_bits = highest_bit - 1; |
124 | 181M | *code = 2 * highest_bit + second_highest_bit; |
125 | 181M | } Unexecuted instantiation: vp8l_dec.c:VP8LPrefixEncodeBitsNoLUT Unexecuted instantiation: lossless.c:VP8LPrefixEncodeBitsNoLUT Unexecuted instantiation: lossless_sse2.c:VP8LPrefixEncodeBitsNoLUT Unexecuted instantiation: vp8l_enc.c:VP8LPrefixEncodeBitsNoLUT Unexecuted instantiation: palette.c:VP8LPrefixEncodeBitsNoLUT Unexecuted instantiation: lossless_enc.c:VP8LPrefixEncodeBitsNoLUT Unexecuted instantiation: lossless_enc_sse2.c:VP8LPrefixEncodeBitsNoLUT Unexecuted instantiation: backward_references_enc.c:VP8LPrefixEncodeBitsNoLUT histogram_enc.c:VP8LPrefixEncodeBitsNoLUT Line | Count | Source | 120 | 50.2M | int* const extra_bits) { | 121 | 50.2M | const int highest_bit = BitsLog2Floor(--distance); | 122 | 50.2M | const int second_highest_bit = (distance >> (highest_bit - 1)) & 1; | 123 | 50.2M | *extra_bits = highest_bit - 1; | 124 | 50.2M | *code = 2 * highest_bit + second_highest_bit; | 125 | 50.2M | } |
Unexecuted instantiation: near_lossless_enc.c:VP8LPrefixEncodeBitsNoLUT Unexecuted instantiation: predictor_enc.c:VP8LPrefixEncodeBitsNoLUT Unexecuted instantiation: lossless_enc_avx2.c:VP8LPrefixEncodeBitsNoLUT backward_references_cost_enc.c:VP8LPrefixEncodeBitsNoLUT Line | Count | Source | 120 | 131M | int* const extra_bits) { | 121 | 131M | const int highest_bit = BitsLog2Floor(--distance); | 122 | 131M | const int second_highest_bit = (distance >> (highest_bit - 1)) & 1; | 123 | 131M | *extra_bits = highest_bit - 1; | 124 | 131M | *code = 2 * highest_bit + second_highest_bit; | 125 | 131M | } |
|
126 | | |
127 | | static WEBP_INLINE void VP8LPrefixEncodeNoLUT(int distance, int* const code, |
128 | | int* const extra_bits, |
129 | 9.78M | int* const extra_bits_value) { |
130 | 9.78M | const int highest_bit = BitsLog2Floor(--distance); |
131 | 9.78M | const int second_highest_bit = (distance >> (highest_bit - 1)) & 1; |
132 | 9.78M | *extra_bits = highest_bit - 1; |
133 | 9.78M | *extra_bits_value = distance & ((1 << *extra_bits) - 1); |
134 | 9.78M | *code = 2 * highest_bit + second_highest_bit; |
135 | 9.78M | } Unexecuted instantiation: vp8l_dec.c:VP8LPrefixEncodeNoLUT Unexecuted instantiation: lossless.c:VP8LPrefixEncodeNoLUT Unexecuted instantiation: lossless_sse2.c:VP8LPrefixEncodeNoLUT vp8l_enc.c:VP8LPrefixEncodeNoLUT Line | Count | Source | 129 | 8.75M | int* const extra_bits_value) { | 130 | 8.75M | const int highest_bit = BitsLog2Floor(--distance); | 131 | 8.75M | const int second_highest_bit = (distance >> (highest_bit - 1)) & 1; | 132 | 8.75M | *extra_bits = highest_bit - 1; | 133 | 8.75M | *extra_bits_value = distance & ((1 << *extra_bits) - 1); | 134 | 8.75M | *code = 2 * highest_bit + second_highest_bit; | 135 | 8.75M | } |
Unexecuted instantiation: palette.c:VP8LPrefixEncodeNoLUT Unexecuted instantiation: lossless_enc.c:VP8LPrefixEncodeNoLUT Unexecuted instantiation: lossless_enc_sse2.c:VP8LPrefixEncodeNoLUT backward_references_enc.c:VP8LPrefixEncodeNoLUT Line | Count | Source | 129 | 1.03M | int* const extra_bits_value) { | 130 | 1.03M | const int highest_bit = BitsLog2Floor(--distance); | 131 | 1.03M | const int second_highest_bit = (distance >> (highest_bit - 1)) & 1; | 132 | 1.03M | *extra_bits = highest_bit - 1; | 133 | 1.03M | *extra_bits_value = distance & ((1 << *extra_bits) - 1); | 134 | 1.03M | *code = 2 * highest_bit + second_highest_bit; | 135 | 1.03M | } |
Unexecuted instantiation: histogram_enc.c:VP8LPrefixEncodeNoLUT Unexecuted instantiation: near_lossless_enc.c:VP8LPrefixEncodeNoLUT Unexecuted instantiation: predictor_enc.c:VP8LPrefixEncodeNoLUT Unexecuted instantiation: lossless_enc_avx2.c:VP8LPrefixEncodeNoLUT Unexecuted instantiation: backward_references_cost_enc.c:VP8LPrefixEncodeNoLUT |
136 | | |
137 | 382M | #define PREFIX_LOOKUP_IDX_MAX 512 |
138 | | typedef struct { |
139 | | int8_t code; |
140 | | int8_t extra_bits; |
141 | | } VP8LPrefixCode; |
142 | | |
143 | | // These tables are derived using VP8LPrefixEncodeNoLUT. |
144 | | extern const VP8LPrefixCode kPrefixEncodeCode[PREFIX_LOOKUP_IDX_MAX]; |
145 | | extern const uint8_t kPrefixEncodeExtraBitsValue[PREFIX_LOOKUP_IDX_MAX]; |
146 | | static WEBP_INLINE void VP8LPrefixEncodeBits(int distance, int* const code, |
147 | 321M | int* const extra_bits) { |
148 | 321M | if (distance < PREFIX_LOOKUP_IDX_MAX) { |
149 | 140M | const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance]; |
150 | 140M | *code = prefix_code.code; |
151 | 140M | *extra_bits = prefix_code.extra_bits; |
152 | 181M | } else { |
153 | 181M | VP8LPrefixEncodeBitsNoLUT(distance, code, extra_bits); |
154 | 181M | } |
155 | 321M | } Unexecuted instantiation: vp8l_dec.c:VP8LPrefixEncodeBits Unexecuted instantiation: lossless.c:VP8LPrefixEncodeBits Unexecuted instantiation: lossless_sse2.c:VP8LPrefixEncodeBits Unexecuted instantiation: vp8l_enc.c:VP8LPrefixEncodeBits Unexecuted instantiation: palette.c:VP8LPrefixEncodeBits Unexecuted instantiation: lossless_enc.c:VP8LPrefixEncodeBits Unexecuted instantiation: lossless_enc_sse2.c:VP8LPrefixEncodeBits Unexecuted instantiation: backward_references_enc.c:VP8LPrefixEncodeBits histogram_enc.c:VP8LPrefixEncodeBits Line | Count | Source | 147 | 156M | int* const extra_bits) { | 148 | 156M | if (distance < PREFIX_LOOKUP_IDX_MAX) { | 149 | 106M | const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance]; | 150 | 106M | *code = prefix_code.code; | 151 | 106M | *extra_bits = prefix_code.extra_bits; | 152 | 106M | } else { | 153 | 50.2M | VP8LPrefixEncodeBitsNoLUT(distance, code, extra_bits); | 154 | 50.2M | } | 155 | 156M | } |
Unexecuted instantiation: near_lossless_enc.c:VP8LPrefixEncodeBits Unexecuted instantiation: predictor_enc.c:VP8LPrefixEncodeBits Unexecuted instantiation: lossless_enc_avx2.c:VP8LPrefixEncodeBits backward_references_cost_enc.c:VP8LPrefixEncodeBits Line | Count | Source | 147 | 165M | int* const extra_bits) { | 148 | 165M | if (distance < PREFIX_LOOKUP_IDX_MAX) { | 149 | 34.1M | const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance]; | 150 | 34.1M | *code = prefix_code.code; | 151 | 34.1M | *extra_bits = prefix_code.extra_bits; | 152 | 131M | } else { | 153 | 131M | VP8LPrefixEncodeBitsNoLUT(distance, code, extra_bits); | 154 | 131M | } | 155 | 165M | } |
|
156 | | |
157 | | static WEBP_INLINE void VP8LPrefixEncode(int distance, int* const code, |
158 | | int* const extra_bits, |
159 | 60.9M | int* const extra_bits_value) { |
160 | 60.9M | if (distance < PREFIX_LOOKUP_IDX_MAX) { |
161 | 51.1M | const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance]; |
162 | 51.1M | *code = prefix_code.code; |
163 | 51.1M | *extra_bits = prefix_code.extra_bits; |
164 | 51.1M | *extra_bits_value = kPrefixEncodeExtraBitsValue[distance]; |
165 | 51.1M | } else { |
166 | 9.78M | VP8LPrefixEncodeNoLUT(distance, code, extra_bits, extra_bits_value); |
167 | 9.78M | } |
168 | 60.9M | } Unexecuted instantiation: vp8l_dec.c:VP8LPrefixEncode Unexecuted instantiation: lossless.c:VP8LPrefixEncode Unexecuted instantiation: lossless_sse2.c:VP8LPrefixEncode vp8l_enc.c:VP8LPrefixEncode Line | Count | Source | 159 | 32.1M | int* const extra_bits_value) { | 160 | 32.1M | if (distance < PREFIX_LOOKUP_IDX_MAX) { | 161 | 23.4M | const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance]; | 162 | 23.4M | *code = prefix_code.code; | 163 | 23.4M | *extra_bits = prefix_code.extra_bits; | 164 | 23.4M | *extra_bits_value = kPrefixEncodeExtraBitsValue[distance]; | 165 | 23.4M | } else { | 166 | 8.75M | VP8LPrefixEncodeNoLUT(distance, code, extra_bits, extra_bits_value); | 167 | 8.75M | } | 168 | 32.1M | } |
Unexecuted instantiation: palette.c:VP8LPrefixEncode Unexecuted instantiation: lossless_enc.c:VP8LPrefixEncode Unexecuted instantiation: lossless_enc_sse2.c:VP8LPrefixEncode backward_references_enc.c:VP8LPrefixEncode Line | Count | Source | 159 | 28.7M | int* const extra_bits_value) { | 160 | 28.7M | if (distance < PREFIX_LOOKUP_IDX_MAX) { | 161 | 27.7M | const VP8LPrefixCode prefix_code = kPrefixEncodeCode[distance]; | 162 | 27.7M | *code = prefix_code.code; | 163 | 27.7M | *extra_bits = prefix_code.extra_bits; | 164 | 27.7M | *extra_bits_value = kPrefixEncodeExtraBitsValue[distance]; | 165 | 27.7M | } else { | 166 | 1.03M | VP8LPrefixEncodeNoLUT(distance, code, extra_bits, extra_bits_value); | 167 | 1.03M | } | 168 | 28.7M | } |
Unexecuted instantiation: histogram_enc.c:VP8LPrefixEncode Unexecuted instantiation: near_lossless_enc.c:VP8LPrefixEncode Unexecuted instantiation: predictor_enc.c:VP8LPrefixEncode Unexecuted instantiation: lossless_enc_avx2.c:VP8LPrefixEncode Unexecuted instantiation: backward_references_cost_enc.c:VP8LPrefixEncode |
169 | | |
170 | | // Sum of each component, mod 256. |
171 | | static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE uint32_t |
172 | 112M | VP8LAddPixels(uint32_t a, uint32_t b) { |
173 | 112M | const uint32_t alpha_and_green = (a & 0xff00ff00u) + (b & 0xff00ff00u); |
174 | 112M | const uint32_t red_and_blue = (a & 0x00ff00ffu) + (b & 0x00ff00ffu); |
175 | 112M | return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); |
176 | 112M | } Unexecuted instantiation: vp8l_dec.c:VP8LAddPixels Line | Count | Source | 172 | 6.43M | VP8LAddPixels(uint32_t a, uint32_t b) { | 173 | 6.43M | const uint32_t alpha_and_green = (a & 0xff00ff00u) + (b & 0xff00ff00u); | 174 | 6.43M | const uint32_t red_and_blue = (a & 0x00ff00ffu) + (b & 0x00ff00ffu); | 175 | 6.43M | return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); | 176 | 6.43M | } |
lossless_sse2.c:VP8LAddPixels Line | Count | Source | 172 | 106M | VP8LAddPixels(uint32_t a, uint32_t b) { | 173 | 106M | const uint32_t alpha_and_green = (a & 0xff00ff00u) + (b & 0xff00ff00u); | 174 | 106M | const uint32_t red_and_blue = (a & 0x00ff00ffu) + (b & 0x00ff00ffu); | 175 | 106M | return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); | 176 | 106M | } |
Unexecuted instantiation: vp8l_enc.c:VP8LAddPixels Unexecuted instantiation: palette.c:VP8LAddPixels Unexecuted instantiation: lossless_enc.c:VP8LAddPixels Unexecuted instantiation: lossless_enc_sse2.c:VP8LAddPixels Unexecuted instantiation: backward_references_enc.c:VP8LAddPixels Unexecuted instantiation: histogram_enc.c:VP8LAddPixels Unexecuted instantiation: near_lossless_enc.c:VP8LAddPixels Unexecuted instantiation: predictor_enc.c:VP8LAddPixels Unexecuted instantiation: lossless_enc_avx2.c:VP8LAddPixels Unexecuted instantiation: backward_references_cost_enc.c:VP8LAddPixels |
177 | | |
178 | | // Difference of each component, mod 256. |
179 | | static WEBP_UBSAN_IGNORE_UNSIGNED_OVERFLOW WEBP_INLINE uint32_t |
180 | 1.60G | VP8LSubPixels(uint32_t a, uint32_t b) { |
181 | 1.60G | const uint32_t alpha_and_green = |
182 | 1.60G | 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u); |
183 | 1.60G | const uint32_t red_and_blue = |
184 | 1.60G | 0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu); |
185 | 1.60G | return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); |
186 | 1.60G | } Unexecuted instantiation: vp8l_dec.c:VP8LSubPixels Unexecuted instantiation: lossless.c:VP8LSubPixels Unexecuted instantiation: lossless_sse2.c:VP8LSubPixels Line | Count | Source | 180 | 1.53G | VP8LSubPixels(uint32_t a, uint32_t b) { | 181 | 1.53G | const uint32_t alpha_and_green = | 182 | 1.53G | 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u); | 183 | 1.53G | const uint32_t red_and_blue = | 184 | 1.53G | 0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu); | 185 | 1.53G | return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); | 186 | 1.53G | } |
Line | Count | Source | 180 | 252k | VP8LSubPixels(uint32_t a, uint32_t b) { | 181 | 252k | const uint32_t alpha_and_green = | 182 | 252k | 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u); | 183 | 252k | const uint32_t red_and_blue = | 184 | 252k | 0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu); | 185 | 252k | return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); | 186 | 252k | } |
lossless_enc.c:VP8LSubPixels Line | Count | Source | 180 | 66.0M | VP8LSubPixels(uint32_t a, uint32_t b) { | 181 | 66.0M | const uint32_t alpha_and_green = | 182 | 66.0M | 0x00ff00ffu + (a & 0xff00ff00u) - (b & 0xff00ff00u); | 183 | 66.0M | const uint32_t red_and_blue = | 184 | 66.0M | 0xff00ff00u + (a & 0x00ff00ffu) - (b & 0x00ff00ffu); | 185 | 66.0M | return (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu); | 186 | 66.0M | } |
Unexecuted instantiation: lossless_enc_sse2.c:VP8LSubPixels Unexecuted instantiation: backward_references_enc.c:VP8LSubPixels Unexecuted instantiation: histogram_enc.c:VP8LSubPixels Unexecuted instantiation: near_lossless_enc.c:VP8LSubPixels Unexecuted instantiation: predictor_enc.c:VP8LSubPixels Unexecuted instantiation: lossless_enc_avx2.c:VP8LSubPixels Unexecuted instantiation: backward_references_cost_enc.c:VP8LSubPixels |
187 | | |
188 | | //------------------------------------------------------------------------------ |
189 | | // Transform-related functions used in both encoding and decoding. |
190 | | |
191 | | // Macros used to create a batch predictor that iteratively uses a |
192 | | // one-pixel predictor. |
193 | | |
194 | | // The predictor is added to the output pixel (which |
195 | | // is therefore considered as a residual) to get the final prediction. |
196 | | #define GENERATE_PREDICTOR_ADD(PREDICTOR, PREDICTOR_ADD) \ |
197 | | static void PREDICTOR_ADD(const uint32_t* in, const uint32_t* upper, \ |
198 | 4.40M | int num_pixels, uint32_t* WEBP_RESTRICT out) { \ |
199 | 4.40M | int x; \ |
200 | 4.40M | assert(upper != NULL); \ |
201 | 113M | for (x = 0; x < num_pixels; ++x) { \ |
202 | 109M | const uint32_t pred = (PREDICTOR)(&out[x - 1], upper + x); \ |
203 | 109M | out[x] = VP8LAddPixels(in[x], pred); \ |
204 | 109M | } \ |
205 | 4.40M | } |
206 | | |
207 | | #ifdef __cplusplus |
208 | | } // extern "C" |
209 | | #endif |
210 | | |
211 | | #endif // WEBP_DSP_LOSSLESS_COMMON_H_ |