blob: 9ce8be83aecf0f52deab7cdb2b63e73c9cc66726 [file] [log] [blame]
minyue53ff70f2016-05-02 08:50:301/*
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
Mirko Bonadei92ea95e2017-09-15 04:47:3111#ifndef MODULES_AUDIO_CODING_NETEQ_CROSS_CORRELATION_H_
12#define MODULES_AUDIO_CODING_NETEQ_CROSS_CORRELATION_H_
minyue53ff70f2016-05-02 08:50:3013
Yves Gerey988cc082018-10-23 10:03:0114#include <stddef.h>
15#include <stdint.h>
minyue53ff70f2016-05-02 08:50:3016
17namespace 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
42int 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
Mirko Bonadei92ea95e2017-09-15 04:47:3151#endif // MODULES_AUDIO_CODING_NETEQ_CROSS_CORRELATION_H_