clib/dvb_ts_lib/descriptors/parse_desc_vbi_data.c

filter: Statementstmt 0.0% 0 / 54 Branchbran 0.0% 0 / 40 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 94 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« clib/dvb_ts_lib/descriptors/parse_desc_tva_content_identifier.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_vbi_teletext.c »
1 /*
2 * parse_desc_vbi_data.c
3 *
4 * Created by: si_desc.pl
5 * Created on: 20-May-2011
6 * Author: sdprice1
7 */
8
9
10 // VERSION = 1.00
11
12 /*=============================================================================================*/
13 // USES
14 /*=============================================================================================*/
15
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <unistd.h>
19 #include <string.h>
20 #include <errno.h>
21 #include <ctype.h>
22 #include <fcntl.h>
23 #include <inttypes.h>
24
25 #include "parse_desc_vbi_data.h"
26 #include "descriptors/parse_desc.h"
27
28 /*=============================================================================================*/
29 // CONSTANTS
30 /*=============================================================================================*/
31
32 /*=============================================================================================*/
33 // MACROS
34 /*=============================================================================================*/
35
36 /*=============================================================================================*/
37 // FUNCTIONS
38 /*=============================================================================================*/
39
40 /* ----------------------------------------------------------------------- */
41 //
42 // VBI_data_descriptor() {
43 // descriptor_tag 8 uimsbf
44 // descriptor_length 8 uimsbf
45 // for (i=0; i<N; i++) {
46 // data_service_id 8 uimsbf
47 // data_service_descriptor_length 8 uimsbf
48 // if (data_service_id==0x01 ||
49 // for (i=0; i<N; i++) {
50 // reserved 2 bslbf
51 // field_parity 1 bslbf
52 // line_offset 5 uimsbf
53 // }
54 // } else {
55 // for (i=0; i<N; i++) {
56 // reserved 8 bslbf
57 // }
58 // }
59 // }
60 // }
61
62
63 /* ----------------------------------------------------------------------- */
64 0 void print_vbi_data(struct Descriptor_vbi_data *vdd, int level)
65 {
66 struct list_head *item, *safe;
67 struct list_head *item1, *safe1;
68
69 0 printf(" Descriptor: vbi_data [0x%02x]\n", vdd->descriptor_tag) ;
70 0 printf(" Length: %d\n", vdd->descriptor_length) ;
71
72
73 0 ▶ list_for_each_safe(item,safe,&vdd->vdd_array) {
Branch: 1 branch
BranchTrueFalseTotal
list_for_each_safe(item,safe,&vdd->vdd_array) { 0 0 0
74 0 struct VDD_entry *vdd_entry = list_entry(item, struct VDD_entry, next);
75
76 // VDD entry
77 0 printf(" -VDD entry-\n") ;
78
79 0 printf(" data_service_id = %d\n", vdd_entry->data_service_id) ;
80 0 printf(" data_service_descriptor_length = %d\n", vdd_entry->data_service_descriptor_length) ;
81 0 ▶ if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 )
Branch: 6 branches
BranchTrueFalseTotal
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
82 {
83
84 0 ▶ list_for_each_safe(item1,safe1,&vdd_entry->vdd1_array) {
Branch: 1 branch
BranchTrueFalseTotal
list_for_each_safe(item1,safe1,&vdd_entry->vdd1_array) { 0 0 0
85 0 struct VDD1_entry *vdd1_entry = list_entry(item, struct VDD1_entry, next);
86
87 // VDD entry
88 0 printf(" -VDD entry-\n") ;
89
90 0 printf(" field_parity = %d\n", vdd1_entry->field_parity) ;
91 0 printf(" line_offset = %d\n", vdd1_entry->line_offset) ;
92 }
93
94 }
95 else
96 {
97 0 bits_dump("data_service_descriptor", vdd_entry->data_service_descriptor, vdd_entry->data_service_descriptor_length, 3) ;
98 }
99
100 }
101
102 0 }
103
104 /* ----------------------------------------------------------------------- */
105 0 struct Descriptor *parse_vbi_data(struct TS_bits *bits, unsigned tag, unsigned len)
106 {
107 struct Descriptor_vbi_data *vdd ;
108 unsigned byte ;
109 int end_buff_len ;
110
111 0 vdd = (struct Descriptor_vbi_data *)malloc( sizeof(*vdd) ) ;
112 0 memset(vdd,0,sizeof(*vdd));
113
114 //== Parse data ==
115 0 INIT_LIST_HEAD(&vdd->next);
116 0 vdd->descriptor_tag = tag ; // already extracted by parse_desc()
117 0 vdd->descriptor_length = len ; // already extracted by parse_desc()
118
119 0 INIT_LIST_HEAD(&vdd->vdd_array) ;
120 0 end_buff_len = bits_len_calc(bits, -vdd->descriptor_length ) ;
121 0 ▶ while (bits->buff_len > end_buff_len)
Branch: 1 branch
BranchTrueFalseTotal
while (bits->buff_len > end_buff_len) 0 0 0
122 {
123 0 struct VDD_entry *vdd_entry = malloc(sizeof(*vdd_entry));
124 0 memset(vdd_entry,0,sizeof(*vdd_entry));
125 0 list_add_tail(&vdd_entry->next,&vdd->vdd_array);
126
127 0 vdd_entry->data_service_id = bits_get(bits, 8) ;
128 0 vdd_entry->data_service_descriptor_length = bits_get(bits, 8) ;
129 0 ▶ if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 )
Branch: 6 branches
BranchTrueFalseTotal
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
if (vdd_entry->data_service_id == 0x1 || vdd_entry->data_service_id == 0x2 || vdd_entry->data_service_id == 0x4 || vdd_entry->data_service_id == 0x5 || vdd_entry->data_service_id == 0x6 || vdd_entry->data_service_id == 0x7 ) 0 0 0
130 {
131
132 0 INIT_LIST_HEAD(&vdd_entry->vdd1_array) ;
133 0 ▶ while (bits->buff_len >= 1)
Branch: 1 branch
BranchTrueFalseTotal
while (bits->buff_len >= 1) 0 0 0
134 {
135 0 struct VDD1_entry *vdd1_entry = malloc(sizeof(*vdd1_entry));
136 0 memset(vdd1_entry,0,sizeof(*vdd1_entry));
137 0 list_add_tail(&vdd1_entry->next,&vdd_entry->vdd1_array);
138
139 0 bits_skip(bits, 2) ;
140 0 vdd1_entry->field_parity = bits_get(bits, 1) ;
141 0 vdd1_entry->line_offset = bits_get(bits, 5) ;
142 }
143
144 }
145 else
146 {
147
148 0 end_buff_len = bits_len_calc(bits, -vdd_entry->data_service_descriptor_length) ;
149 0 vdd_entry->data_service_descriptor[0] = 0 ;
150 0 ▶ for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_DATA_SERVICE_DESCRIPTOR_LEN); ++byte)
Branch: 2 branches
BranchTrueFalseTotal
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_DATA_SERVICE_DESCRIPTOR_LEN); ++byte) 0 0 0
for (byte=0; (bits->buff_len > end_buff_len) && (byte < MAX_DATA_SERVICE_DESCRIPTOR_LEN); ++byte) 0 0 0
151 {
152 0 vdd_entry->data_service_descriptor[byte] = bits_get(bits, 8) ;
153 0 vdd_entry->data_service_descriptor[byte+1] = 0 ;
154 }
155
156 }
157
158 }
159
160
161 0 return (struct Descriptor *)vdd ;
162 }
163
164 /* ----------------------------------------------------------------------- */
165 0 void free_vbi_data(struct Descriptor_vbi_data *vdd)
166 {
167 struct list_head *item, *safe;
168 struct list_head *item1, *safe1;
169
170 0 ▶ list_for_each_safe(item,safe,&vdd->vdd_array) {
Branch: 1 branch
BranchTrueFalseTotal
list_for_each_safe(item,safe,&vdd->vdd_array) { 0 0 0
171 0 struct VDD_entry *vdd_entry = list_entry(item, struct VDD_entry, next);
172
173 0 ▶ list_for_each_safe(item1,safe1,&vdd_entry->vdd1_array) {
Branch: 1 branch
BranchTrueFalseTotal
list_for_each_safe(item1,safe1,&vdd_entry->vdd1_array) { 0 0 0
174 0 struct VDD1_entry *vdd1_entry = list_entry(item, struct VDD1_entry, next);
175 0 free(vdd1_entry) ;
176 }
177
178 0 free(vdd_entry) ;
179 }
180
181
182 0 free(vdd) ;
183 0 }
« clib/dvb_ts_lib/descriptors/parse_desc_tva_content_identifier.c ↑ Summary clib/dvb_ts_lib/descriptors/parse_desc_vbi_teletext.c »