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 class atsc_mpeg_packet {
00142
public:
00143 unsigned char data[ATSC_MPEG_DATA_LENGTH + 1];
00144
00145
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
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
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
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
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