summaryrefslogtreecommitdiff
path: root/gr-digital/lib/ofdm_chanest_vcvc_impl.h
blob: eed755c9fb82eee850b2ca3c43e84b1f908030c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* -*- c++ -*- */
/*
 * Copyright 2013 Free Software Foundation, Inc.
 *
 * This file is part of GNU Radio
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 */

#ifndef INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_IMPL_H
#define INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_IMPL_H

#include <gnuradio/digital/ofdm_chanest_vcvc.h>

namespace gr {
namespace digital {

class ofdm_chanest_vcvc_impl : public ofdm_chanest_vcvc
{
private:
    int d_fft_len;     //! FFT length
    int d_n_data_syms; //! Number of data symbols following the sync symbol(s)
    int d_n_sync_syms; //! Number of sync symbols (1 or 2)
    //! 0 if no noise reduction is done for the initial channel state estimation.
    //! Otherwise, the maximum length of the channel delay in samples.
    int d_eq_noise_red_len;
    //! Is sync_symbol1 if d_n_sync_syms == 1, otherwise sync_symbol2. Used as a reference
    //! symbol to estimate the channel.
    std::vector<gr_complex> d_ref_sym;
    //! If d_n_sync_syms == 2 this is used as a differential correlation vector (called
    //! 'v' in [1]).
    std::vector<gr_complex> d_corr_v;
    //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq.
    //! offset
    std::vector<float> d_known_symbol_diffs;
    //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq.
    //! offset (temp. variable)
    std::vector<float> d_new_symbol_diffs;
    //! The index of the first carrier with data (index 0 is not DC here, but the lowest
    //! frequency)
    int d_first_active_carrier;
    //! The index of the last carrier with data
    int d_last_active_carrier;
    //! If true, the channel estimation must be interpolated
    bool d_interpolate;
    //! Maximum carrier offset (negative value!)
    int d_max_neg_carr_offset;
    //! Maximum carrier offset (positive value!)
    int d_max_pos_carr_offset;

    //! Calculate the coarse frequency offset in number of carriers
    int get_carr_offset(const gr_complex* sync_sym1, const gr_complex* sync_sym2);
    //! Estimate the channel (phase and amplitude offset per carrier)
    void get_chan_taps(const gr_complex* sync_sym1,
                       const gr_complex* sync_sym2,
                       int carr_offset,
                       std::vector<gr_complex>& taps);

public:
    ofdm_chanest_vcvc_impl(const std::vector<gr_complex>& sync_symbol1,
                           const std::vector<gr_complex>& sync_symbol2,
                           int n_data_symbols,
                           int eq_noise_red_len,
                           int max_carr_offset,
                           bool force_one_sync_symbol);
    ~ofdm_chanest_vcvc_impl() override;

    void forecast(int noutput_items, gr_vector_int& ninput_items_required) override;
    int general_work(int noutput_items,
                     gr_vector_int& ninput_items,
                     gr_vector_const_void_star& input_items,
                     gr_vector_void_star& output_items) override;
};

} // namespace digital
} // namespace gr

#endif /* INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_IMPL_H */