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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/* -*- c++ -*- */
/*
* Copyright 2016,2017 Free Software Foundation, Inc.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "catv_frame_sync_enc_bb_impl.h"
#include <gnuradio/io_signature.h>
namespace gr {
namespace dtv {
catv_frame_sync_enc_bb::sptr
catv_frame_sync_enc_bb::make(catv_constellation_t constellation, int ctrlword)
{
return gnuradio::make_block_sptr<catv_frame_sync_enc_bb_impl>(constellation,
ctrlword);
}
/*
* The private constructor
*/
catv_frame_sync_enc_bb_impl::catv_frame_sync_enc_bb_impl(
catv_constellation_t constellation, int ctrlword)
: gr::block("catv_frame_sync_enc_bb",
gr::io_signature::make(1, 1, sizeof(unsigned char)),
gr::io_signature::make(1, 1, sizeof(unsigned char)))
{
if (constellation == CATV_MOD_64QAM) {
set_output_multiple((60 * 128 * 7) + 42);
} else {
set_output_multiple((88 * 128 * 7) + 40);
}
control_word = ctrlword;
signal_constellation = constellation;
}
/*
* Our virtual destructor.
*/
catv_frame_sync_enc_bb_impl::~catv_frame_sync_enc_bb_impl() {}
void catv_frame_sync_enc_bb_impl::forecast(int noutput_items,
gr_vector_int& ninput_items_required)
{
if (signal_constellation == CATV_MOD_64QAM) {
ninput_items_required[0] = noutput_items / ((60 * 128 * 7) + 42) * (60 * 128);
} else {
ninput_items_required[0] = noutput_items / ((88 * 128 * 7) + 40) * (88 * 128);
}
}
int catv_frame_sync_enc_bb_impl::general_work(int noutput_items,
gr_vector_int& ninput_items,
gr_vector_const_void_star& input_items,
gr_vector_void_star& output_items)
{
const unsigned char* in = (const unsigned char*)input_items[0];
unsigned char* out = (unsigned char*)output_items[0];
int consumed = 0;
int i = 0;
unsigned char b;
while (i < noutput_items) {
if (signal_constellation == CATV_MOD_64QAM) {
for (int j = 0; j < 60 * 128; j++) {
b = *in++;
consumed++;
for (int n = 6; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
}
b = 0x75;
for (int n = 6; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
b = 0x2c;
for (int n = 6; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
b = 0x0d;
for (int n = 6; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
b = 0x6c;
for (int n = 6; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
b = control_word << 3;
for (int n = 6; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
for (int n = 6; n >= 0; n--) {
out[i++] = 0;
}
} else {
for (int j = 0; j < 88 * 128; j++) {
b = *in++;
consumed++;
for (int n = 6; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
}
b = 0x71;
for (int n = 7; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
b = 0xe8;
for (int n = 7; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
b = 0x4d;
for (int n = 7; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
b = 0xd4;
for (int n = 7; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
b = control_word << 4;
for (int n = 7; n >= 0; n--) {
out[i++] = b & (1 << n) ? 1 : 0;
}
}
}
// Tell runtime system how many input items we consumed on
// each input stream.
consume_each(consumed);
// Tell runtime system how many output items we produced.
return noutput_items;
}
} /* namespace dtv */
} /* namespace gr */
|