• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef MODULES_AUDIO_CODING_NETEQ_CROSS_CORRELATION_H_
12 #define MODULES_AUDIO_CODING_NETEQ_CROSS_CORRELATION_H_
13 
14 #include <stddef.h>
15 #include <stdint.h>
16 
17 namespace webrtc {
18 
19 // The function calculates the cross-correlation between two sequences
20 // |sequence_1| and |sequence_2|. |sequence_1| is taken as reference, with
21 // |sequence_1_length| as its length. |sequence_2| slides for the calculation of
22 // cross-correlation. The result will be saved in |cross_correlation|.
23 // |cross_correlation_length| correlation points are calculated.
24 // The corresponding lag starts from 0, and increases with a step of
25 // |cross_correlation_step|. The result is without normalization. To avoid
26 // overflow, the result will be right shifted. The amount of shifts will be
27 // returned.
28 //
29 // Input:
30 //     - sequence_1     : First sequence (reference).
31 //     - sequence_2     : Second sequence (sliding during calculation).
32 //     - sequence_1_length : Length of |sequence_1|.
33 //     - cross_correlation_length : Number of cross-correlations to calculate.
34 //     - cross_correlation_step : Step in the lag for the cross-correlation.
35 //
36 // Output:
37 //      - cross_correlation : The cross-correlation in Q(-right_shifts)
38 //
39 // Return:
40 //      Number of right shifts in cross_correlation.
41 
42 int CrossCorrelationWithAutoShift(const int16_t* sequence_1,
43                                   const int16_t* sequence_2,
44                                   size_t sequence_1_length,
45                                   size_t cross_correlation_length,
46                                   int cross_correlation_step,
47                                   int32_t* cross_correlation);
48 
49 }  // namespace webrtc
50 
51 #endif  // MODULES_AUDIO_CODING_NETEQ_CROSS_CORRELATION_H_
52