Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

atsc_types.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2001 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00020 * Boston, MA 02111-1307, USA. 00021 */ 00022 00023 #ifndef _ATSC_TYPES_H_ 00024 #define _ATSC_TYPES_H_ 00025 00026 #include <atsc_consts.h> 00027 #include <cstring> 00028 #include <cassert> 00029 00030 00036 class plinfo { 00037 public: 00038 plinfo () : _flags (0), _segno (0) { } 00039 00040 // accessors 00041 00042 bool field_sync1_p () const { return (_flags & fl_field_sync1) != 0; } 00043 bool field_sync2_p () const { return (_flags & fl_field_sync2) != 0; } 00044 bool field_sync_p () const { return field_sync1_p () || field_sync2_p (); } 00045 00046 bool regular_seg_p () const { return (_flags & fl_regular_seg) != 0; } 00047 00048 bool in_field1_p () const { return (_flags & fl_field2) == 0; } 00049 bool in_field2_p () const { return (_flags & fl_field2) != 0; } 00050 00051 bool first_regular_seg_p () const { return (_flags & fl_first_regular_seg) != 0; } 00052 00053 bool transport_error_p () const { return (_flags & fl_transport_error) != 0; } 00054 00055 unsigned int segno () const { return _segno; } 00056 unsigned int flags () const { return _flags; } 00057 00058 // setters 00059 00060 void set_field_sync1 () 00061 { 00062 _segno = 0; 00063 _flags = fl_field_sync1; 00064 } 00065 00066 void set_field_sync2 () 00067 { 00068 _segno = 0; 00069 _flags = fl_field_sync2 | fl_field2; 00070 } 00071 00072 void set_regular_seg (bool field2, int segno) 00073 { 00074 assert (0 <= segno && segno < ATSC_DSEGS_PER_FIELD); 00075 _segno = segno; 00076 _flags = fl_regular_seg; 00077 if (segno == 0) 00078 _flags |= fl_first_regular_seg; 00079 if (segno >= ATSC_DSEGS_PER_FIELD) 00080 _flags |= fl_transport_error; 00081 if (field2) 00082 _flags |= fl_field2; 00083 } 00084 00085 void set_transport_error (bool error){ 00086 if (error) 00087 _flags |= fl_transport_error; 00088 else 00089 _flags &= ~fl_transport_error; 00090 } 00091 00092 // overload equality operator 00093 bool operator== (const plinfo &other) const { 00094 return (_flags == other._flags && _segno == other._segno); 00095 } 00096 00097 bool operator!= (const plinfo &other) const { 00098 return !(_flags == other._flags && _segno == other._segno); 00099 } 00100 00105 static void delay (plinfo &out, const plinfo &in, int nsegs_of_delay); 00106 00110 static void sanity_check (const plinfo &in); 00111 00112 00113 protected: 00114 unsigned short _flags; // bitmask 00115 unsigned short _segno; // segment number [0,311] 00116 00117 // these three are mutually exclusive 00118 // This is a regular data segment. 00119 static const int fl_regular_seg = 0x0001; 00120 // This is a field sync segment, for 1st half of a field. 00121 static const int fl_field_sync1 = 0x0002; 00122 // This is a field sync segment, for 2nd half of a field. 00123 static const int fl_field_sync2 = 0x0004; 00124 00125 // This bit is on ONLY when fl_regular_seg is set AND when this is 00126 // the first regular data segment AFTER a field sync segment. This 00127 // segment causes various processing modules to reset. 00128 static const int fl_first_regular_seg = 0x0008; 00129 00130 // which field are we in? 00131 static const int fl_field2 = 0x0010; // else field 1 00132 00133 // This bit is set when Reed-Solomon decoding detects an error that it 00134 // can't correct. Note that other error detection (e.g. Viterbi) do not 00135 // set it, since Reed-Solomon will correct many of those. This bit is 00136 // then copied into the final Transport Stream packet so that MPEG 00137 // software can see that the 188-byte data segment has been corrupted. 00138 static const int fl_transport_error = 0x0020; 00139 }; 00140 00141 class atsc_mpeg_packet { 00142 public: 00143 unsigned char data[ATSC_MPEG_DATA_LENGTH + 1]; // first byte is sync 00144 00145 // overload equality operator 00146 bool operator== (const atsc_mpeg_packet &other) const { 00147 return std::memcmp (data, other.data, sizeof (data)) == 0; 00148 }; 00149 00150 bool operator!= (const atsc_mpeg_packet &other) const { 00151 return !(std::memcmp (data, other.data, sizeof (data)) == 0); 00152 }; 00153 }; 00154 00155 class atsc_mpeg_packet_no_sync { 00156 public: 00157 plinfo pli; 00158 unsigned char data[ATSC_MPEG_DATA_LENGTH]; 00159 00160 // overload equality operator 00161 bool operator== (const atsc_mpeg_packet_no_sync &other) const { 00162 return std::memcmp (data, other.data, sizeof (data)) == 0; 00163 } 00164 00165 bool operator!= (const atsc_mpeg_packet_no_sync &other) const { 00166 return !(std::memcmp (data, other.data, sizeof (data)) == 0); 00167 } 00168 }; 00169 00170 class atsc_mpeg_packet_rs_encoded { 00171 public: 00172 plinfo pli; 00173 unsigned char data[ATSC_MPEG_RS_ENCODED_LENGTH]; 00174 00175 // overload equality operator 00176 bool operator== (const atsc_mpeg_packet_rs_encoded &other) const { 00177 return std::memcmp (data, other.data, sizeof (data)) == 0; 00178 } 00179 00180 bool operator!= (const atsc_mpeg_packet_rs_encoded &other) const { 00181 return !(std::memcmp (data, other.data, sizeof (data)) == 0); 00182 } 00183 }; 00184 00185 00187 00188 class atsc_data_segment { 00189 public: 00190 plinfo pli; 00191 unsigned char data[ATSC_DATA_SEGMENT_LENGTH]; 00192 00193 // overload equality operator 00194 bool operator== (const atsc_data_segment &other) const { 00195 return std::memcmp (data, other.data, sizeof (data)) == 0; 00196 } 00197 00198 bool operator!= (const atsc_data_segment &other) const { 00199 return !(std::memcmp (data, other.data, sizeof (data)) == 0); 00200 } 00201 }; 00202 00209 class atsc_soft_data_segment { 00210 public: 00211 plinfo pli; 00212 float data[ATSC_DATA_SEGMENT_LENGTH]; 00213 00214 // overload equality operator 00215 bool operator== (const atsc_data_segment &other) const { 00216 return std::memcmp (data, other.data, sizeof (data)) == 0; 00217 } 00218 00219 bool operator!= (const atsc_data_segment &other) const { 00220 return !(std::memcmp (data, other.data, sizeof (data)) == 0); 00221 } 00222 }; 00223 00224 00225 #endif /* _ATSC_TYPES_H_ */

Generated on Wed Aug 4 02:22:03 2004 for GNU Radio by doxygen 1.3.8