summaryrefslogtreecommitdiff
path: root/gr-dtv/lib/dvbt/dvbt_demap_impl.h
blob: 11741c9a92940d3009b73679d6602ee089ee18fe (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
/* -*- c++ -*- */
/*
 * Copyright 2015 Free Software Foundation, Inc.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 */

#ifndef INCLUDED_DTV_DVBT_DVBT_DEMAP_IMPL_H
#define INCLUDED_DTV_DVBT_DVBT_DEMAP_IMPL_H

#include "dvbt_configure.h"
#include <gnuradio/dtv/dvbt_demap.h>
#include <volk/volk_alloc.hh>

namespace gr {
namespace dtv {

class dvbt_demap_impl : public dvbt_demap
{
private:
    const dvbt_configure config;

    int d_nsize;

    // Constellation size
    const unsigned char d_constellation_size;
    // Transmission mode
    dvbt_transmission_mode_t d_transmission_mode;
    // Step on each axis of the constellation
    unsigned char d_step;
    // Keep Alpha internally
    unsigned char d_alpha;
    // Gain for the complex values
    float d_gain;

    volk::vector<gr_complex> d_constellation_points;
    volk::vector<float> d_sq_dist;

    void make_constellation_points(int size, int step, int alpha);
    int find_constellation_value(gr_complex val);
    int bin_to_gray(int val);

public:
    dvbt_demap_impl(int nsize,
                    dvb_constellation_t constellation,
                    dvbt_hierarchy_t hierarchy,
                    dvbt_transmission_mode_t transmission,
                    float gain);
    ~dvbt_demap_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 dtv
} // namespace gr

#endif /* INCLUDED_DTV_DVBT_DVBT_DEMAP_IMPL_H */