~ubuntu-branches/ubuntu/trusty/gnuradio/trusty-updates

« back to all changes in this revision

Viewing changes to gr-atsc/src/lib/GrAtscSymbolMapper.h

  • Committer: Package Import Robot
  • Author(s): A. Maitland Bottoms
  • Date: 2012-02-26 21:26:16 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120226212616-vsfkbi1158xshdql
Tags: 3.5.1-1
* new upstream version, re-packaged from scratch with modern tools
    closes: #642716, #645332, #394849, #616832, #590048, #642580,
    #647018, #557050, #559640, #631863
* CMake build

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- c++ -*- */
 
2
/*
 
3
 * Copyright 2002 Free Software Foundation, Inc.
 
4
 * 
 
5
 * This file is part of GNU Radio
 
6
 * 
 
7
 * GNU Radio is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 3, or (at your option)
 
10
 * any later version.
 
11
 * 
 
12
 * GNU Radio is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 * 
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with GNU Radio; see the file COPYING.  If not, write to
 
19
 * the Free Software Foundation, Inc., 51 Franklin Street,
 
20
 * Boston, MA 02110-1301, USA.
 
21
 */
 
22
 
 
23
#ifndef _GRATSCSYMBOLMAPPER_H_
 
24
#define _GRATSCSYMBOLMAPPER_H_
 
25
 
 
26
 
 
27
#include <VrInterpolatingSigProcNoWork.h>
 
28
#include <atsc_types.h>
 
29
#include <gr_nco.h>
 
30
 
 
31
/*!
 
32
 * \brief take atsc_data_segments and map them to symbols.
 
33
 *
 
34
 * Input is a stream of atsc_data_segments.
 
35
 * Output is a stream of symbols at 1x the symbol rate
 
36
 *
 
37
 * This module performs the signal mapping & pilot addition.
 
38
 */
 
39
 
 
40
template<class oType>
 
41
class GrAtscSymbolMapper
 
42
  : public VrInterpolatingSigProcNoWork<atsc_data_segment, oType> {
 
43
 
 
44
public:
 
45
  GrAtscSymbolMapper ()
 
46
    : VrInterpolatingSigProcNoWork<atsc_data_segment, oType>(1, INTERP_FACTOR) {};
 
47
 
 
48
  ~GrAtscSymbolMapper () {};
 
49
 
 
50
  const char *name () { return "GrAtscSymbolMapper"; }
 
51
 
 
52
  int work (VrSampleRange output, void *ao[],
 
53
            VrSampleRange inputs[], void *ai[]);
 
54
 
 
55
protected:
 
56
  static const int      INTERP_FACTOR = ATSC_DATA_SEGMENT_LENGTH;
 
57
};
 
58
 
 
59
 
 
60
template<class oType>
 
61
int 
 
62
GrAtscSymbolMapper<oType>::work (VrSampleRange output, void *ao[],
 
63
                                 VrSampleRange inputs[], void *ai[])
 
64
{
 
65
  atsc_data_segment     *in =  ((atsc_data_segment **) ai)[0];
 
66
  oType                 *out = ((oType **) ao)[0];
 
67
  
 
68
  assert ((output.size % INTERP_FACTOR) == 0);
 
69
  
 
70
  static const float pilot_add = 1.25;
 
71
  static const float map[8] = {
 
72
    -7 + pilot_add,
 
73
    -5 + pilot_add,
 
74
    -3 + pilot_add,
 
75
    -1 + pilot_add,
 
76
     1 + pilot_add,
 
77
     3 + pilot_add,
 
78
     5 + pilot_add,
 
79
     7 + pilot_add
 
80
  };
 
81
 
 
82
  unsigned int  oo = 0;
 
83
  unsigned int  nsegs = output.size / INTERP_FACTOR;
 
84
 
 
85
  for (unsigned int n = 0; n < nsegs; n++){
 
86
    unsigned char *symbol = in[n].data;
 
87
 
 
88
    for (int i = 0; i < ATSC_DATA_SEGMENT_LENGTH; i++){
 
89
      out[oo++] = (oType) map[symbol[i] & 0x7];
 
90
    }
 
91
  }
 
92
 
 
93
  assert (oo == output.size);
 
94
  return output.size;
 
95
}
 
96
 
 
97
#endif /* _GRATSCSYMBOLMAPPER_H_ */