3 * Copyright 2002 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
27 #include <cppunit/TestAssert.h>
28 #include <qa_atsci_trellis_encoder.h>
35 #define NELEM(x) (sizeof (x) / sizeof (x[0]))
38 static const int NCODERS = atsci_trellis_encoder::NCODERS;
41 qa_atsci_trellis_encoder::t0 ()
43 #if 0 // generate i/o test data for t1
45 atsc_mpeg_packet_rs_encoded in[NCODERS];
46 atsc_data_segment out[NCODERS];
49 memset (in, 0, sizeof (in));
50 memset (out, 0, sizeof (out));
54 printf ("@@@ INPUT @@@\n");
55 for (int i = 0; i < NCODERS; i++){
56 for (unsigned int j = 0; j < NELEM (in[i].data); j++){
57 int t = (random () >> 8) & 0xff; // 8 random bits
66 printf ("@@@ OUTPUT @@@\n");
67 for (int i = 0; i < NCODERS; i++){
68 for (unsigned int j = 0; j < NELEM (out[i].data); j++){
69 printf ("%d\n", out[i].data[j]);
76 qa_atsci_trellis_encoder::t1 ()
78 atsc_mpeg_packet_rs_encoded in[NCODERS];
79 atsc_data_segment expected_out[NCODERS];
80 atsc_data_segment actual_out[NCODERS];
81 static const unsigned char raw_input[NCODERS * NELEM (in[0].data)] = {
82 #include "qa_atsci_trellis_encoder_t1_input.dat"
84 static const unsigned char raw_output[NCODERS * NELEM (expected_out[0].data)] = {
85 #include "qa_atsci_trellis_encoder_t1_output.dat"
90 const unsigned char *r = &raw_input[0];
91 for (int i = 0; i < NCODERS; i++){
92 in[i].pli.set_regular_seg (false, i);
93 for (unsigned int j = 0; j < NELEM (in[i].data); j++){
98 // load up expected output
100 for (int i = 0; i < NCODERS; i++){
101 expected_out[i].pli.set_regular_seg (false, i);
102 for (unsigned int j = 0; j < NELEM (expected_out[i].data); j++){
103 expected_out[i].data[j] = *r++;
107 memset (&actual_out, 0, sizeof (actual_out)); // ensure zero
110 enc.encode (actual_out, in); // trellis code test data
112 for (int i = 0; i < NCODERS; i++){ // check the result
113 CPPUNIT_ASSERT (expected_out[i] == actual_out[i]);
114 CPPUNIT_ASSERT (expected_out[i].pli == actual_out[i].pli);