atsc_types.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _ATSC_TYPES_H_
00024 #define _ATSC_TYPES_H_
00025
00026 #include <atsc_consts.h>
00027 #include <string.h>
00028 #include <cstring>
00029 #include <cassert>
00030
00031
00037 class plinfo {
00038 public:
00039 plinfo () : _flags (0), _segno (0) { }
00040
00041
00042
00043 bool field_sync1_p () const { return (_flags & fl_field_sync1) != 0; }
00044 bool field_sync2_p () const { return (_flags & fl_field_sync2) != 0; }
00045 bool field_sync_p () const { return field_sync1_p () || field_sync2_p (); }
00046
00047 bool regular_seg_p () const { return (_flags & fl_regular_seg) != 0; }
00048
00049 bool in_field1_p () const { return (_flags & fl_field2) == 0; }
00050 bool in_field2_p () const { return (_flags & fl_field2) != 0; }
00051
00052 bool first_regular_seg_p () const { return (_flags & fl_first_regular_seg) != 0; }
00053
00054 bool transport_error_p () const { return (_flags & fl_transport_error) != 0; }
00055
00056 unsigned int segno () const { return _segno; }
00057 unsigned int flags () const { return _flags; }
00058
00059
00060
00061 void set_field_sync1 ()
00062 {
00063 _segno = 0;
00064 _flags = fl_field_sync1;
00065 }
00066
00067 void set_field_sync2 ()
00068 {
00069 _segno = 0;
00070 _flags = fl_field_sync2 | fl_field2;
00071 }
00072
00073 void set_regular_seg (bool field2, int segno)
00074 {
00075 assert (0 <= segno && segno < ATSC_DSEGS_PER_FIELD);
00076 _segno = segno;
00077 _flags = fl_regular_seg;
00078 if (segno == 0)
00079 _flags |= fl_first_regular_seg;
00080 if (segno >= ATSC_DSEGS_PER_FIELD)
00081 _flags |= fl_transport_error;
00082 if (field2)
00083 _flags |= fl_field2;
00084 }
00085
00086 void set_transport_error (bool error){
00087 if (error)
00088 _flags |= fl_transport_error;
00089 else
00090 _flags &= ~fl_transport_error;
00091 }
00092
00093
00094 bool operator== (const plinfo &other) const {
00095 return (_flags == other._flags && _segno == other._segno);
00096 }
00097
00098 bool operator!= (const plinfo &other) const {
00099 return !(_flags == other._flags && _segno == other._segno);
00100 }
00101
00106 static void delay (plinfo &out, const plinfo &in, int nsegs_of_delay);
00107
00111 static void sanity_check (const plinfo &in);
00112
00113
00114 protected:
00115 unsigned short _flags;
00116 unsigned short _segno;
00117
00118
00119
00120 static const int fl_regular_seg = 0x0001;
00121
00122 static const int fl_field_sync1 = 0x0002;
00123
00124 static const int fl_field_sync2 = 0x0004;
00125
00126
00127
00128
00129 static const int fl_first_regular_seg = 0x0008;
00130
00131
00132 static const int fl_field2 = 0x0010;
00133
00134
00135
00136
00137
00138
00139 static const int fl_transport_error = 0x0020;
00140 };
00141
00142
00143
00144
00145 class atsc_mpeg_packet {
00146 public:
00147 static const int NPAD = 68;
00148 unsigned char data[ATSC_MPEG_DATA_LENGTH + 1];
00149 unsigned char _pad_[NPAD];
00150
00151
00152 bool operator== (const atsc_mpeg_packet &other) const {
00153 return std::memcmp (data, other.data, sizeof (data)) == 0;
00154 };
00155
00156 bool operator!= (const atsc_mpeg_packet &other) const {
00157 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00158 };
00159 };
00160
00161 class atsc_mpeg_packet_no_sync {
00162 public:
00163 static const int NPAD = 65;
00164 plinfo pli;
00165 unsigned char data[ATSC_MPEG_DATA_LENGTH];
00166 unsigned char _pad_[NPAD];
00167
00168
00169 bool operator== (const atsc_mpeg_packet_no_sync &other) const {
00170 return std::memcmp (data, other.data, sizeof (data)) == 0;
00171 }
00172
00173 bool operator!= (const atsc_mpeg_packet_no_sync &other) const {
00174 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00175 }
00176 };
00177
00178 class atsc_mpeg_packet_rs_encoded {
00179 public:
00180 static const int NPAD = 45;
00181 plinfo pli;
00182 unsigned char data[ATSC_MPEG_RS_ENCODED_LENGTH];
00183 unsigned char _pad_[NPAD];
00184
00185
00186 bool operator== (const atsc_mpeg_packet_rs_encoded &other) const {
00187 return std::memcmp (data, other.data, sizeof (data)) == 0;
00188 }
00189
00190 bool operator!= (const atsc_mpeg_packet_rs_encoded &other) const {
00191 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00192 }
00193 };
00194
00195
00197
00198 class atsc_data_segment {
00199 public:
00200 static const int NPAD = 188;
00201 plinfo pli;
00202 unsigned char data[ATSC_DATA_SEGMENT_LENGTH];
00203 unsigned char _pad_[NPAD];
00204
00205
00206 bool operator== (const atsc_data_segment &other) const {
00207 return std::memcmp (data, other.data, sizeof (data)) == 0;
00208 }
00209
00210 bool operator!= (const atsc_data_segment &other) const {
00211 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00212 }
00213 };
00214
00221 class atsc_soft_data_segment {
00222 public:
00223 static const int NPAD = 764;
00224 plinfo pli;
00225 float data[ATSC_DATA_SEGMENT_LENGTH];
00226 unsigned char _pad_[NPAD];
00227
00228
00229 bool operator== (const atsc_data_segment &other) const {
00230 return std::memcmp (data, other.data, sizeof (data)) == 0;
00231 }
00232
00233 bool operator!= (const atsc_data_segment &other) const {
00234 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00235 }
00236 };
00237
00238
00239 #endif