Merge commit 'v3.3.0' into upstream
[debian/gnuradio] / gr-atsc / src / lib / atsci_syminfo.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
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 3, or (at your option)
10  * any later version.
11  * 
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.
16  * 
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.
21  */
22 #ifndef _ATSC_SYMINFO_H_
23 #define _ATSC_SYMINFO_H_
24
25 namespace atsc {
26
27   static const unsigned int SI_SEGMENT_NUM_MASK       = 0x1ff;
28   static const unsigned int SI_FIELD_SYNC_SEGMENT_NUM = SI_SEGMENT_NUM_MASK;  // conceptually -1
29
30   struct syminfo {
31     unsigned int    symbol_num          : 10;   // 0..831
32     unsigned int    segment_num         :  9;   // 0..311 and SI_FIELD_SYNC_SEGMENT_NUM
33     unsigned int    field_num           :  1;   // 0..1
34     unsigned int    valid               :  1;   // contents are valid
35   };
36
37
38   static inline bool
39   tag_is_start_field_sync (syminfo tag)
40   {
41     return tag.symbol_num == 0 && tag.segment_num == SI_FIELD_SYNC_SEGMENT_NUM && tag.valid;
42   }
43
44   static inline bool
45   tag_is_start_field_sync_1 (syminfo tag)
46   {
47     return tag_is_start_field_sync (tag) && tag.field_num == 0;
48   }
49
50   static inline bool
51   tag_is_start_field_sync_2 (syminfo tag)
52   {
53     return tag_is_start_field_sync (tag) && tag.field_num == 1;
54   }
55
56 }
57
58 #endif /* _ATSC_SYMINFO_H_ */