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

Side by Side Diff: src/libFLAC/stream_encoder_intrin_avx2.c

Issue 1961133002: Update FLAC to 1.3.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/flac.git@master
Patch Set: build config tweaks for Windows Created 4 years, 7 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 | « src/libFLAC/stream_encoder_framing.c ('k') | src/libFLAC/stream_encoder_intrin_sse2.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* libFLAC - Free Lossless Audio Codec library
2 * Copyright (C) 2000-2009 Josh Coalson
3 * Copyright (C) 2011-2014 Xiph.Org Foundation
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * - Neither the name of the Xiph.org Foundation nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifdef HAVE_CONFIG_H
34 # include <config.h>
35 #endif
36
37 #ifndef FLAC__NO_ASM
38 #if (defined FLAC__CPU_IA32 || defined FLAC__CPU_X86_64) && defined FLAC__HAS_X8 6INTRIN
39 #include "private/stream_encoder.h"
40 #include "private/bitmath.h"
41 #ifdef FLAC__AVX2_SUPPORTED
42
43 #include <stdlib.h> /* for abs() */
44 #include <immintrin.h> /* AVX2 */
45 #include "FLAC/assert.h"
46
47 FLAC__SSE_TARGET("avx2")
48 void FLAC__precompute_partition_info_sums_intrin_avx2(const FLAC__int32 residual [], FLAC__uint64 abs_residual_partition_sums[],
49 unsigned residual_samples, unsigned predictor_order, unsigned mi n_partition_order, unsigned max_partition_order, unsigned bps)
50 {
51 const unsigned default_partition_samples = (residual_samples + predictor _order) >> max_partition_order;
52 unsigned partitions = 1u << max_partition_order;
53
54 FLAC__ASSERT(default_partition_samples > predictor_order);
55
56 /* first do max_partition_order */
57 {
58 unsigned partition, residual_sample, end = (unsigned)(-(int)pred ictor_order);
59 __m256i res256, sum256;
60 __m128i res128, sum128;
61
62 if(FLAC__bitmath_ilog2(default_partition_samples) + bps + FLAC__ MAX_EXTRA_RESIDUAL_BPS < 32) {
63 for(partition = residual_sample = 0; partition < partiti ons; partition++) {
64 end += default_partition_samples;
65 sum256 = _mm256_setzero_si256();
66
67 for( ; (int)residual_sample < (int)end-7; residu al_sample+=8) {
68 res256 = _mm256_abs_epi32(_mm256_loadu_s i256((const __m256i*)(residual+residual_sample)));
69 sum256 = _mm256_add_epi32(sum256, res256 );
70 }
71
72 sum128 = _mm_add_epi32(_mm256_extracti128_si256( sum256, 1), _mm256_castsi256_si128(sum256));
73
74 for( ; (int)residual_sample < (int)end-3; residu al_sample+=4) {
75 res128 = _mm_abs_epi32(_mm_loadu_si128(( const __m128i*)(residual+residual_sample)));
76 sum128 = _mm_add_epi32(sum128, res128);
77 }
78
79 for( ; residual_sample < end; residual_sample++) {
80 res128 = _mm_cvtsi32_si128(residual[resi dual_sample]);
81 res128 = _mm_abs_epi32(res128);
82 sum128 = _mm_add_epi32(sum128, res128);
83 }
84
85 sum128 = _mm_hadd_epi32(sum128, sum128);
86 sum128 = _mm_hadd_epi32(sum128, sum128);
87 abs_residual_partition_sums[partition] = (FLAC__ uint32)_mm_cvtsi128_si32(sum128);
88 }
89 }
90 else { /* have to pessimistically use 64 bits for accumulator */
91 for(partition = residual_sample = 0; partition < partiti ons; partition++) {
92 end += default_partition_samples;
93 sum256 = _mm256_setzero_si256();
94
95 for( ; (int)residual_sample < (int)end-3; residu al_sample+=4) {
96 res128 = _mm_abs_epi32(_mm_loadu_si128(( const __m128i*)(residual+residual_sample)));
97 res256 = _mm256_cvtepu32_epi64(res128);
98 sum256 = _mm256_add_epi64(sum256, res256 );
99 }
100
101 sum128 = _mm_add_epi64(_mm256_extracti128_si256( sum256, 1), _mm256_castsi256_si128(sum256));
102
103 for( ; (int)residual_sample < (int)end-1; residu al_sample+=2) {
104 res128 = _mm_loadl_epi64((const __m128i* )(residual+residual_sample));
105 res128 = _mm_abs_epi32(res128);
106 res128 = _mm_cvtepu32_epi64(res128);
107 sum128 = _mm_add_epi64(sum128, res128);
108 }
109
110 for( ; residual_sample < end; residual_sample++) {
111 res128 = _mm_cvtsi32_si128(residual[resi dual_sample]);
112 res128 = _mm_abs_epi32(res128);
113 sum128 = _mm_add_epi64(sum128, res128);
114 }
115
116 sum128 = _mm_add_epi64(sum128, _mm_srli_si128(su m128, 8));
117 _mm_storel_epi64((__m128i*)(abs_residual_partiti on_sums+partition), sum128);
118 }
119 }
120 }
121
122 /* now merge partitions for lower orders */
123 {
124 unsigned from_partition = 0, to_partition = partitions;
125 int partition_order;
126 for(partition_order = (int)max_partition_order - 1; partition_or der >= (int)min_partition_order; partition_order--) {
127 unsigned i;
128 partitions >>= 1;
129 for(i = 0; i < partitions; i++) {
130 abs_residual_partition_sums[to_partition++] =
131 abs_residual_partition_sums[from_partiti on ] +
132 abs_residual_partition_sums[from_partiti on+1];
133 from_partition += 2;
134 }
135 }
136 }
137 _mm256_zeroupper();
138 }
139
140 #endif /* FLAC__AVX2_SUPPORTED */
141 #endif /* (FLAC__CPU_IA32 || FLAC__CPU_X86_64) && FLAC__HAS_X86INTRIN */
142 #endif /* FLAC__NO_ASM */
OLDNEW
« no previous file with comments | « src/libFLAC/stream_encoder_framing.c ('k') | src/libFLAC/stream_encoder_intrin_sse2.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698