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 <cstring>
00028 #include <cassert>
00029
00030
00036 class plinfo {
00037 public:
00038 plinfo () : _flags (0), _segno (0) { }
00039
00040
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
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
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;
00115 unsigned short _segno;
00116
00117
00118
00119 static const int fl_regular_seg = 0x0001;
00120
00121 static const int fl_field_sync1 = 0x0002;
00122
00123 static const int fl_field_sync2 = 0x0004;
00124
00125
00126
00127
00128 static const int fl_first_regular_seg = 0x0008;
00129
00130
00131 static const int fl_field2 = 0x0010;
00132
00133
00134
00135
00136
00137
00138 static const int fl_transport_error = 0x0020;
00139 };
00140
00141
00142
00143
00144 class atsc_mpeg_packet {
00145 public:
00146 static const int NPAD = 68;
00147 unsigned char data[ATSC_MPEG_DATA_LENGTH + 1];
00148 unsigned char _pad_[NPAD];
00149
00150
00151 bool operator== (const atsc_mpeg_packet &other) const {
00152 return std::memcmp (data, other.data, sizeof (data)) == 0;
00153 };
00154
00155 bool operator!= (const atsc_mpeg_packet &other) const {
00156 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00157 };
00158 };
00159
00160 class atsc_mpeg_packet_no_sync {
00161 public:
00162 static const int NPAD = 65;
00163 plinfo pli;
00164 unsigned char data[ATSC_MPEG_DATA_LENGTH];
00165 unsigned char _pad_[NPAD];
00166
00167
00168 bool operator== (const atsc_mpeg_packet_no_sync &other) const {
00169 return std::memcmp (data, other.data, sizeof (data)) == 0;
00170 }
00171
00172 bool operator!= (const atsc_mpeg_packet_no_sync &other) const {
00173 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00174 }
00175 };
00176
00177 class atsc_mpeg_packet_rs_encoded {
00178 public:
00179 static const int NPAD = 45;
00180 plinfo pli;
00181 unsigned char data[ATSC_MPEG_RS_ENCODED_LENGTH];
00182 unsigned char _pad_[NPAD];
00183
00184
00185 bool operator== (const atsc_mpeg_packet_rs_encoded &other) const {
00186 return std::memcmp (data, other.data, sizeof (data)) == 0;
00187 }
00188
00189 bool operator!= (const atsc_mpeg_packet_rs_encoded &other) const {
00190 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00191 }
00192 };
00193
00194
00196
00197 class atsc_data_segment {
00198 public:
00199 static const int NPAD = 188;
00200 plinfo pli;
00201 unsigned char data[ATSC_DATA_SEGMENT_LENGTH];
00202 unsigned char _pad_[NPAD];
00203
00204
00205 bool operator== (const atsc_data_segment &other) const {
00206 return std::memcmp (data, other.data, sizeof (data)) == 0;
00207 }
00208
00209 bool operator!= (const atsc_data_segment &other) const {
00210 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00211 }
00212 };
00213
00220 class atsc_soft_data_segment {
00221 public:
00222 static const int NPAD = 764;
00223 plinfo pli;
00224 float data[ATSC_DATA_SEGMENT_LENGTH];
00225 unsigned char _pad_[NPAD];
00226
00227
00228 bool operator== (const atsc_data_segment &other) const {
00229 return std::memcmp (data, other.data, sizeof (data)) == 0;
00230 }
00231
00232 bool operator!= (const atsc_data_segment &other) const {
00233 return !(std::memcmp (data, other.data, sizeof (data)) == 0);
00234 }
00235 };
00236
00237
00238 #endif