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 2, 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>
34 #define NELEM(x) (sizeof (x) / sizeof (x[0]))
37 static const int NCODERS = atsci_trellis_encoder::NCODERS;
40 qa_atsci_trellis_encoder::t0 ()
42 #if 0 // generate i/o test data for t1
44 atsc_mpeg_packet_rs_encoded in[NCODERS];
45 atsc_data_segment out[NCODERS];
48 memset (in, 0, sizeof (in));
49 memset (out, 0, sizeof (out));
53 printf ("@@@ INPUT @@@\n");
54 for (int i = 0; i < NCODERS; i++){
55 for (unsigned int j = 0; j < NELEM (in[i].data); j++){
56 int t = (random () >> 8) & 0xff; // 8 random bits
65 printf ("@@@ OUTPUT @@@\n");
66 for (int i = 0; i < NCODERS; i++){
67 for (unsigned int j = 0; j < NELEM (out[i].data); j++){
68 printf ("%d\n", out[i].data[j]);
75 qa_atsci_trellis_encoder::t1 ()
77 atsc_mpeg_packet_rs_encoded in[NCODERS];
78 atsc_data_segment expected_out[NCODERS];
79 atsc_data_segment actual_out[NCODERS];
80 static const unsigned char raw_input[NCODERS * NELEM (in[0].data)] = {
81 #include "qa_atsci_trellis_encoder_t1_input.dat"
83 static const unsigned char raw_output[NCODERS * NELEM (expected_out[0].data)] = {
84 #include "qa_atsci_trellis_encoder_t1_output.dat"
89 const unsigned char *r = &raw_input[0];
90 for (int i = 0; i < NCODERS; i++){
91 in[i].pli.set_regular_seg (false, i);
92 for (unsigned int j = 0; j < NELEM (in[i].data); j++){
97 // load up expected output
99 for (int i = 0; i < NCODERS; i++){
100 expected_out[i].pli.set_regular_seg (false, i);
101 for (unsigned int j = 0; j < NELEM (expected_out[i].data); j++){
102 expected_out[i].data[j] = *r++;
106 memset (&actual_out, 0, sizeof (actual_out)); // ensure zero
109 enc.encode (actual_out, in); // trellis code test data
111 for (int i = 0; i < NCODERS; i++){ // check the result
112 CPPUNIT_ASSERT (expected_out[i] == actual_out[i]);
113 CPPUNIT_ASSERT (expected_out[i].pli == actual_out[i].pli);