xs/DVBT-ad-tie.c

filter: Statementstmt 85.1% 246 / 289 Branchbran 51.7% 205 / 396 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 65.8% 451 / 685 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/DVBT-advert-c.c ↑ Summary xs/DVBT-const.c »
1 # /*---------------------------------------------------------------------------------------------------*/
2 # /* Implements a tied HASH pointing to advert results */
3
4 # // VERSION = "1.003"
5
6 # /*---------------------------------------------------------------------------------------------------*/
7 # /* */
8
9 ADAV *
10 TIEARRAY(char *CLASS, char *TYPE, AV *extra=NULL)
11
12 INIT:
13 11 ADA_METHOD(TIEARRAY);
14 SV *sv ;
15 11 char *key = "" ;
16 11 int threshold = 1 ;
17 ADAV *that ;
18 enum Adav_type type ;
19 Adata *user_data ;
20
21 CODE:
22 11 ada_dbg_printf("== ADAV:TIEARRAY(%s) ==\n", TYPE) ;
23 11 Newz(0, RETVAL, 1, ADAV);
24
25 11 ▶ if (strcmp(TYPE, "ADATA")==0)
Branch: 1 branch
BranchTrueFalseTotal
if (strcmp(TYPE, "ADATA")==0) 5 6 11
26 {
27 5 type = ADAV_ADATA ;
28 5 ▶ if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) )
Branch: 3 branches
BranchTrueFalseTotal
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 5 0 5
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 5 0 5
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 5 0 5
29 {
30 // Adata*
31 5 sv = av_pop( extra );
32 10 ▶ if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG)
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG) 5 0 5
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG) 5 0 5
33 5 {
34 5 IV tmp = SvIV((SV*)SvRV(sv));
35 5 user_data = INT2PTR(Adata *, tmp);
36 }
37 else
38 {
39 0 croak("FILTER tie invalid ADAV*");
40 }
41 }
42 else
43 {
44 0 croak("ADATA tie requires array ref with [Adata*]");
45 }
46
47 }
48 6 ▶ else if (strcmp(TYPE, "FILTER")==0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcmp(TYPE, "FILTER")==0) 2 4 6
49 {
50 2 type = ADAV_FILTERED ;
51
52 2 ▶ if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) )
Branch: 3 branches
BranchTrueFalseTotal
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 2 0 2
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 2 0 2
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 2 0 2
53 {
54 // threshold
55 2 ▶ if (av_len( extra ) > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (av_len( extra ) > 1) 2 0 2
56 {
57 2 sv = av_pop( extra );
58 2 threshold = SvIV(sv) ;
59 }
60
61 // key
62 2 ▶ if (av_len( extra ) > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (av_len( extra ) > 0) 2 0 2
63 {
64 2 sv = av_pop( extra );
65 2 key = SvPV_nolen(sv) ;
66 }
67
68 // ADAV*
69 2 sv = av_pop( extra );
70 2 ▶ if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG)
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG) 2 0 2
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG) 2 0 2
71 2 {
72 2 IV tmp = SvIV((SV*)SvRV(sv));
73 2 that = INT2PTR(ADAV *, tmp);
74 2 ▶ ADA_CHECK_OBJECT(that) ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_OBJECT(that) ; 0 2 2
ADA_CHECK_OBJECT(that) ; 0 2 2
ADA_CHECK_OBJECT(that) ; 0 0 0
ADA_CHECK_OBJECT(that) ; 2 0 2
ADA_CHECK_OBJECT(that) ; 0 2 2
75
76 2 user_data = that->user_data ;
77 }
78 else
79 {
80 0 croak("FILTER tie invalid ADAV*");
81 }
82
83 2 create_adav_filter(RETVAL, user_data, key, threshold) ;
84 }
85 else
86 {
87 0 croak("FILTER tie requires array ref with [ADAV*, char*]");
88 }
89
90 }
91 4 ▶ else if (strcmp(TYPE, "LOGO")==0)
Branch: 1 branch
BranchTrueFalseTotal
else if (strcmp(TYPE, "LOGO")==0) 1 3 4
92 {
93 1 type = ADAV_LOGO ;
94
95 1 ▶ if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) )
Branch: 3 branches
BranchTrueFalseTotal
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 1 0 1
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 1 0 1
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 1 0 1
96 {
97 // ADAV*
98 1 sv = av_pop( extra );
99 1 ▶ if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG)
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG) 1 0 1
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG) 1 0 1
100 1 {
101 1 IV tmp = SvIV((SV*)SvRV(sv));
102 1 that = INT2PTR(ADAV *, tmp);
103 1 ▶ ADA_CHECK_OBJECT(that) ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_OBJECT(that) ; 0 1 1
ADA_CHECK_OBJECT(that) ; 0 1 1
ADA_CHECK_OBJECT(that) ; 0 0 0
ADA_CHECK_OBJECT(that) ; 1 0 1
ADA_CHECK_OBJECT(that) ; 0 1 1
104
105 1 user_data = that->user_data ;
106 }
107 else
108 {
109 0 croak("LOGO tie invalid ADAV*");
110 }
111
112 1 create_adav_logo(RETVAL, user_data) ;
113 }
114 else
115 {
116 0 croak("LOGO tie requires array ref with [ADAV*]");
117 }
118
119 }
120 3 ▶ else if ((strcmp(TYPE, "CSV")==0) || (strcmp(TYPE, "ADV")==0))
Branch: 2 branches
BranchTrueFalseTotal
else if ((strcmp(TYPE, "CSV")==0) || (strcmp(TYPE, "ADV")==0)) 3 0 3
else if ((strcmp(TYPE, "CSV")==0) || (strcmp(TYPE, "ADV")==0)) 3 0 3
121 {
122 3 type = ADAV_CSV ;
123
124 3 ▶ if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) )
Branch: 3 branches
BranchTrueFalseTotal
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 3 0 3
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 3 0 3
if( extra && (SvTYPE((SV*)extra) == SVt_PVAV) && (av_len( extra ) > -1) ) 3 0 3
125 {
126 // ADAV*
127 3 sv = av_pop( extra );
128 3 ▶ if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG)
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG) 3 0 3
if (sv_isobject(sv) && SvTYPE(SvRV(sv)) == SVt_PVMG) 3 0 3
129 3 {
130 3 IV tmp = SvIV((SV*)SvRV(sv));
131 3 that = INT2PTR(ADAV *, tmp);
132 3 ▶ ADA_CHECK_OBJECT(that) ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_OBJECT(that) ; 0 3 3
ADA_CHECK_OBJECT(that) ; 0 3 3
ADA_CHECK_OBJECT(that) ; 0 0 0
ADA_CHECK_OBJECT(that) ; 3 0 3
ADA_CHECK_OBJECT(that) ; 0 3 3
133
134 3 user_data = that->user_data ;
135 }
136 else
137 {
138 0 croak("CSV tie invalid ADAV*");
139 }
140
141 3 create_adav_csv(RETVAL, user_data) ;
142 }
143 else
144 {
145 0 croak("CSV tie requires array ref with [ADAV*]");
146 }
147
148 }
149 else
150 {
151 0 croak ("Unsupported tie type");
152 }
153 11 RETVAL->user_data = user_data ;
154 11 RETVAL->signature = ADA_SIGNATURE;
155 11 RETVAL->type = type ;
156
157 11 ada_dbg_printf("== ADAV:TIEARRAY(%s) - %p - END ==\n", TYPE, RETVAL) ;
158
159 OUTPUT:
160 RETVAL
161
162
163 # /*---------------------------------------------------------------------------------------------------*/
164 # /* */
165
166 void
167 ADAV::DESTROY()
168
169 INIT:
170 11 ADA_METHOD(DESTROY);
171
172 CODE:
173 11 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 11 11
ADA_CHECK_THIS ; 0 11 11
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 11 0 11
ADA_CHECK_THIS ; 0 11 11
174
175 11 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 5 6 11
176 {
177 // free all of the user data
178 5 free_user_data(THIS->user_data) ;
179 5 clear_adav(THIS) ;
180 }
181 6 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 2 4 6
182 {
183 // free up filtered list
184 2 free_adav_filter(THIS) ;
185 }
186 4 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 1 3 4
187 {
188 // free up logo list
189 1 free_adav_logo(THIS) ;
190 }
191 3 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 3 0 3
192 {
193 // free up csv list
194 3 free_adav_csv(THIS) ;
195 }
196 else
197 {
198 0 croak ("Unsupported tie type");
199 }
200
201 11 ADA_END_THIS ;
202 11 Safefree(THIS);
203
204 # /*---------------------------------------------------------------------------------------------------*/
205 # /* */
206
207 SV *
208 ADAV::FETCH(int idx)
209
210 INIT:
211 111 ADA_METHOD(FETCH);
212 HV *results ;
213 int frame ;
214
215 CODE:
216 111 ▶ ADA_CHECK_THIS_NODBG ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS_NODBG ; 0 111 111
ADA_CHECK_THIS_NODBG ; 0 111 111
ADA_CHECK_THIS_NODBG ; 0 0 0
ADA_CHECK_THIS_NODBG ; 111 0 111
ADA_CHECK_THIS_NODBG ; 0 111 111
217
218 111 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 102 9 111
219 {
220 102 ▶ if ((idx >= THIS->user_data->results_list_size) || (idx < 0))
Branch: 2 branches
BranchTrueFalseTotal
if ((idx >= THIS->user_data->results_list_size) || (idx < 0)) 101 1 102
if ((idx >= THIS->user_data->results_list_size) || (idx < 0)) 0 101 101
221 1 XSRETURN_UNDEF;
222
223 101 results = advert_result(THIS->user_data, THIS->user_data->results_list[idx].idx) ;
224 101 RETVAL = newRV((SV *)results);
225 }
226 9 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 2 7 9
227 {
228 2 ▶ if ((idx >= THIS->filter_data.num_elems) || (idx < 0))
Branch: 2 branches
BranchTrueFalseTotal
if ((idx >= THIS->filter_data.num_elems) || (idx < 0)) 1 1 2
if ((idx >= THIS->filter_data.num_elems) || (idx < 0)) 0 1 1
229 1 XSRETURN_UNDEF;
230
231 // get frame info first
232 1 frame = THIS->filter_data.data[idx].frame ;
233 1 results = advert_result(THIS->user_data, THIS->user_data->results_list[frame].idx) ;
234
235 // update with the filtered list stuff
236 1 HVS_INT(results, frame_end, THIS->filter_data.data[idx].frame_end ) ;
237 1 HVS_INT(results, gap, THIS->filter_data.data[idx].gap ) ;
238
239 // return
240 1 RETVAL = newRV((SV *)results);
241 }
242 7 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 3 4 7
243 {
244 3 ▶ if ((idx >= THIS->logo_data.num_elems) || (idx < 0))
Branch: 2 branches
BranchTrueFalseTotal
if ((idx >= THIS->logo_data.num_elems) || (idx < 0)) 2 1 3
if ((idx >= THIS->logo_data.num_elems) || (idx < 0)) 0 2 2
245 1 XSRETURN_UNDEF;
246
247 // get frame info first
248 2 frame = THIS->logo_data.data[idx].frame ;
249 2 results = advert_result(THIS->user_data, THIS->user_data->results_list[frame].idx) ;
250
251 // update with the logo list stuff
252 2 HVS_INT(results, frame_end, THIS->logo_data.data[idx].frame_end ) ;
253 2 HVS_INT(results, gap, THIS->logo_data.data[idx].gap ) ;
254 2 HVS_INT(results, match_percent, THIS->logo_data.data[idx].match_percent ) ;
255 2 HVS_INT(results, ave_percent, THIS->logo_data.data[idx].ave_percent ) ;
256
257 // return
258 2 RETVAL = newRV((SV *)results);
259 }
260 4 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 4 0 4
261 {
262 4 ▶ if ((idx >= THIS->csv_data.num_elems) || (idx < 0))
Branch: 2 branches
BranchTrueFalseTotal
if ((idx >= THIS->csv_data.num_elems) || (idx < 0)) 3 1 4
if ((idx >= THIS->csv_data.num_elems) || (idx < 0)) 0 3 3
263 1 XSRETURN_UNDEF;
264
265 // get frame info first
266 3 frame = THIS->csv_data.data[idx].frame ;
267 3 results = advert_result(THIS->user_data, THIS->user_data->results_list[frame].idx) ;
268
269 // update with the csv list stuff
270 3 fetch_csv(THIS, idx, results) ;
271
272 // return
273 3 RETVAL = newRV((SV *)results);
274 }
275
276 OUTPUT:
277 RETVAL
278
279 # /*---------------------------------------------------------------------------------------------------*/
280 # /* */
281
282 SV *
283 ADAV::POP()
284
285 INIT:
286 128 ADA_METHOD(POP);
287 HV *results ;
288 int frame ;
289
290 CODE:
291 128 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 128 128
ADA_CHECK_THIS ; 0 128 128
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 128 0 128
ADA_CHECK_THIS ; 0 128 128
292
293 128 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 1 127 128
294 {
295 1 ADA_UNEXPECTED_CALL;
296 //if (THIS->user_data->results_list_size <= 0)
297 // XSRETURN_UNDEF;
298
299 //results = advert_result(THIS->user_data, THIS->user_data->results_list[THIS->user_data->results_list_size-1].idx) ;
300 //THIS->user_data->results_list_size-- ;
301
302 //RETVAL = newRV((SV *)results);
303 }
304 127 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 103 24 127
305 {
306 103 ▶ if (THIS->filter_data.num_elems <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->filter_data.num_elems <= 0) 3 100 103
307 3 XSRETURN_UNDEF;
308
309 // get frame info first
310 100 frame = THIS->filter_data.data[THIS->filter_data.num_elems-1].frame ;
311 100 results = advert_result(THIS->user_data, THIS->user_data->results_list[frame].idx) ;
312
313 // update with the filtered list stuff
314 100 HVS_INT(results, frame_end, THIS->filter_data.data[THIS->filter_data.num_elems-1].frame_end ) ;
315 100 HVS_INT(results, gap, THIS->filter_data.data[THIS->filter_data.num_elems-1].gap ) ;
316
317 100 THIS->filter_data.num_elems-- ;
318
319 // return
320 100 RETVAL = newRV((SV *)results);
321 }
322 24 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 23 1 24
323 {
324 23 ▶ if (THIS->logo_data.num_elems <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->logo_data.num_elems <= 0) 10 13 23
325 10 XSRETURN_UNDEF;
326
327 // get frame info first
328 13 frame = THIS->logo_data.data[THIS->logo_data.num_elems-1].frame ;
329 13 results = advert_result(THIS->user_data, THIS->user_data->results_list[frame].idx) ;
330
331 // update with the logo list stuff
332 13 HVS_INT(results, frame_end, THIS->logo_data.data[THIS->logo_data.num_elems-1].frame_end ) ;
333 13 HVS_INT(results, gap, THIS->logo_data.data[THIS->logo_data.num_elems-1].gap ) ;
334
335 13 THIS->logo_data.num_elems-- ;
336
337 // return
338 13 RETVAL = newRV((SV *)results);
339 }
340 1 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 1 0 1
341 {
342 1 ADA_UNEXPECTED_CALL;
343 }
344 113 ADA_END_THIS ;
345
346 OUTPUT:
347 RETVAL
348
349
350 # /*---------------------------------------------------------------------------------------------------*/
351 # /* Push value(s) - only valid for calling on logo array */
352
353 SV *
354 ADAV::PUSH(SV *sv_arg, ...)
355
356 INIT:
357 43 ADA_METHOD(PUSH);
358 SV *sv_val ;
359 HV *hv_val ;
360 int idx ;
361 HV *results ;
362
363 CODE:
364 43 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 43 43
ADA_CHECK_THIS ; 0 43 43
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 43 0 43
ADA_CHECK_THIS ; 0 43 43
365
366 43 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 1 42 43
367 {
368 1 ADA_UNEXPECTED_CALL;
369 }
370 42 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 1 41 42
371 {
372 1 ADA_UNEXPECTED_CALL;
373 }
374 41 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 40 1 41
375 {
376 40 ada_dbg_printf("PUSH(%d) - curr size=%d\n", items-1, THIS->logo_data.num_elems) ;
377
378 80 ▶ for (idx=1; idx < items; ++idx)
Branch: 1 branch
BranchTrueFalseTotal
for (idx=1; idx < items; ++idx) 40 40 80
379 {
380 40 sv_val = ST(idx) ;
381 40 ada_dbg_printf(" + %d - type=%d\n", idx, SvTYPE(sv_val)) ;
382 //if(SvTYPE(sv_val) == SVt_RV)
383 {
384 // process item
385 40 hv_val = (HV *)SvRV(sv_val) ;
386 40 results = store_logo(THIS, THIS->logo_data.num_elems, hv_val) ;
387 }
388 }
389
390 40 ada_dbg_printf("PUSH() - END size=%d\n", THIS->logo_data.num_elems) ;
391
392 // return
393 40 RETVAL = newRV((SV *)results);
394 }
395 1 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 1 0 1
396 {
397 1 ADA_UNEXPECTED_CALL;
398 }
399 40 ADA_END_THIS ;
400
401
402 OUTPUT:
403 RETVAL
404
405
406 # /*---------------------------------------------------------------------------------------------------*/
407 # /* unshift value(s) - only valid for calling on logo array */
408
409 SV *
410 ADAV::UNSHIFT(SV *sv_arg, ...)
411
412 INIT:
413 6 ADA_METHOD(UNSHIFT);
414 SV *sv_val ;
415 HV *hv_val ;
416 int idx ;
417 HV *results ;
418
419 CODE:
420 6 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 6 6
ADA_CHECK_THIS ; 0 6 6
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 6 0 6
ADA_CHECK_THIS ; 0 6 6
421
422 6 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 1 5 6
423 {
424 1 ADA_UNEXPECTED_CALL;
425 }
426 5 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 1 4 5
427 {
428 1 ADA_UNEXPECTED_CALL;
429 }
430 4 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 3 1 4
431 {
432 3 ada_dbg_printf("UNSHIFT(%d) - curr size=%d\n", items-1, THIS->logo_data.num_elems) ;
433
434 3 unshift_logo(THIS, items-1) ;
435
436 3 ada_dbg_printf(" + size=%d\n", THIS->logo_data.num_elems) ;
437
438 6 ▶ for (idx=1; idx < items; ++idx)
Branch: 1 branch
BranchTrueFalseTotal
for (idx=1; idx < items; ++idx) 3 3 6
439 {
440 3 sv_val = ST(idx) ;
441 //if(SvTYPE(sv_val) == SVt_RV)
442 {
443 // process item
444 3 hv_val = (HV *)SvRV(sv_val) ;
445 3 results = store_logo(THIS, idx-1, hv_val) ;
446 }
447 }
448 3 ada_dbg_printf("UNSHIFT() - END size=%d\n", THIS->logo_data.num_elems) ;
449
450 // return
451 3 RETVAL = newRV((SV *)results);
452 }
453 1 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 1 0 1
454 {
455 1 ADA_UNEXPECTED_CALL;
456 }
457 3 ADA_END_THIS ;
458
459 OUTPUT:
460 RETVAL
461
462
463
464
465 # /*---------------------------------------------------------------------------------------------------*/
466 # /* Store value - only valid for calling on logo/csv array */
467
468 SV *
469 ADAV::STORE(int idx, HV *hv_val)
470
471 INIT:
472 4 ADA_METHOD(STORE);
473 HV *results ;
474
475 CODE:
476 4 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 4 4
ADA_CHECK_THIS ; 0 4 4
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 4 0 4
ADA_CHECK_THIS ; 0 4 4
477
478 4 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 1 3 4
479 {
480 1 ADA_UNEXPECTED_CALL;
481 }
482 3 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 1 2 3
483 {
484 1 ADA_UNEXPECTED_CALL;
485 }
486 2 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 1 1 2
487 {
488 1 results = store_logo(THIS, idx, hv_val) ;
489
490 // return
491 1 RETVAL = newRV((SV *)results);
492 }
493 1 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 1 0 1
494 {
495 1 ▶ if ( (idx < 0) || (idx >= THIS->logo_data.num_elems) )
Branch: 2 branches
BranchTrueFalseTotal
if ( (idx < 0) || (idx >= THIS->logo_data.num_elems) ) 1 0 1
if ( (idx < 0) || (idx >= THIS->logo_data.num_elems) ) 0 1 1
496 0 XSRETURN_UNDEF;
497
498 1 results = store_csv(THIS, idx, hv_val) ;
499
500 // return
501 1 RETVAL = newRV((SV *)results);
502 }
503 2 ADA_END_THIS ;
504
505 OUTPUT:
506 RETVAL
507
508 # /*---------------------------------------------------------------------------------------------------*/
509 # /* Splice - only supports 'splice @list, offset' that removes from offset to end of array */
510 # /* Does NOT return anything */
511
512 SV *
513 ADAV::SPLICE(int offset)
514
515 INIT:
516 5 ADA_METHOD(SPLICE);
517
518 CODE:
519 5 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 5 5
ADA_CHECK_THIS ; 0 5 5
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 5 0 5
ADA_CHECK_THIS ; 0 5 5
520
521 5 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 1 4 5
522 {
523 1 ADA_UNEXPECTED_CALL;
524 }
525 4 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 1 3 4
526 {
527 1 ADA_UNEXPECTED_CALL;
528 }
529 3 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 2 1 3
530 {
531 2 ada_dbg_printf("%s(%d) - curr size=%d\n", method, offset, THIS->logo_data.num_elems) ;
532
533 2 ▶ if (THIS->logo_data.num_elems <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->logo_data.num_elems <= 0) 1 1 2
534 1 XSRETURN_UNDEF;
535
536 // len=10
537 //
538 // 0 1 2 3 4 5 6 7 8 9
539 // ^-------------- offset=3, new_len=3
540 // ^-- offset=-1 => 9, new_len=9
541 // ^------ offset=-3 => 7, new_len=7
542
543 1 ▶ if (offset < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (offset < 0) 0 1 1
544 {
545 // offset from end
546 0 offset = THIS->logo_data.num_elems + offset ;
547 }
548
549 1 ▶ if ( (offset < 0) || (offset >= THIS->logo_data.num_elems) )
Branch: 2 branches
BranchTrueFalseTotal
if ( (offset < 0) || (offset >= THIS->logo_data.num_elems) ) 1 0 1
if ( (offset < 0) || (offset >= THIS->logo_data.num_elems) ) 0 1 1
550 0 XSRETURN_UNDEF;
551
552 // adjust element count
553 1 THIS->logo_data.num_elems = offset ;
554
555 1 ada_dbg_printf("%s() - END new size=%d\n", method, THIS->logo_data.num_elems) ;
556
557
558 1 XSRETURN_UNDEF;
559 }
560 1 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 1 0 1
561 {
562 1 ADA_UNEXPECTED_CALL;
563 }
564 0 ADA_END_THIS ;
565
566 OUTPUT:
567 RETVAL
568
569
570 # /*---------------------------------------------------------------------------------------------------*/
571 # /* Get the current "array" size */
572
573 int
574 ADAV::FETCHSIZE()
575
576 INIT:
577 17 ADA_METHOD(FETCHSIZE);
578
579 CODE:
580 //ADA_CHECK_THIS_NODBG ;
581 17 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 17 17
ADA_CHECK_THIS ; 0 17 17
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 17 0 17
ADA_CHECK_THIS ; 0 17 17
582
583 17 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 2 15 17
584 {
585 2 RETVAL = THIS->user_data->results_list_size;
586 }
587 15 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 5 10 15
588 {
589 5 RETVAL = THIS->filter_data.num_elems;
590 }
591 10 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 9 1 10
592 {
593 9 RETVAL = THIS->logo_data.num_elems;
594 }
595 1 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 1 0 1
596 {
597 1 RETVAL = THIS->csv_data.num_elems;
598 }
599 17 ada_dbg_printf("%s() - END size=%d\n", method, RETVAL) ;
600
601 OUTPUT:
602 RETVAL
603
604 # /*---------------------------------------------------------------------------------------------------*/
605 # /* UNSUPPORTED */
606
607 int
608 ADAV::STORESIZE(int size)
609
610 INIT:
611 0 ADA_METHOD(STORESIZE);
612
613 CODE:
614 0 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 0 0 0
615 0 ADA_UNEXPECTED_CALL ;
616
617 OUTPUT:
618 RETVAL
619
620
621 # /*---------------------------------------------------------------------------------------------------*/
622 # /* Clear the array - only supported for filtered/logo array */
623
624 void
625 ADAV::CLEAR()
626
627 INIT:
628 4 ADA_METHOD(CLEAR);
629
630 CODE:
631 4 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 4 4
ADA_CHECK_THIS ; 0 4 4
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 4 0 4
ADA_CHECK_THIS ; 0 4 4
632
633 4 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 1 3 4
634 {
635 1 ADA_UNEXPECTED_CALL ;
636 }
637 3 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 1 2 3
638 {
639 1 THIS->filter_data.num_elems = 0 ;
640 }
641 2 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 1 1 2
642 {
643 1 THIS->logo_data.num_elems = 0 ;
644 }
645 1 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 1 0 1
646 {
647 1 ADA_UNEXPECTED_CALL ;
648 }
649 2 ADA_END_THIS ;
650
651 # /*---------------------------------------------------------------------------------------------------*/
652 # /* Ignore - only valid for calling on filtered/logo/csv array */
653
654 void
655 ADAV::EXTEND(int size)
656
657 INIT:
658 0 ADA_METHOD(EXTEND);
659
660 CODE:
661 0 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 0 0 0
662
663 0 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 0 0 0
664 {
665 0 ADA_UNEXPECTED_CALL ;
666 }
667 0 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 0 0 0
668 {
669 // do nothing
670 }
671 0 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 0 0 0
672 {
673 // do nothing
674 }
675 0 else if (THIS->type == ADAV_CSV)
676 {
677 // do nothing
678 }
679
680 0 ADA_END_THIS ;
681
682
683 # /*---------------------------------------------------------------------------------------------------*/
684 # /* */
685
686 void
687 ADAV::EXISTS(int idx)
688
689 INIT:
690 8 ADA_METHOD(EXISTS);
691
692 HV *results ;
693 int frame ;
694
695 PPCODE:
696 8 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 8 8
ADA_CHECK_THIS ; 0 8 8
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 8 0 8
ADA_CHECK_THIS ; 0 8 8
697
698 8 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 2 6 8
699 {
700 2 ▶ if ((idx >= THIS->user_data->results_list_size) || (idx < 0))
Branch: 2 branches
BranchTrueFalseTotal
if ((idx >= THIS->user_data->results_list_size) || (idx < 0)) 1 1 2
if ((idx >= THIS->user_data->results_list_size) || (idx < 0)) 0 1 1
701 1 XSRETURN_NO ;
702 }
703 6 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 2 4 6
704 {
705 2 ▶ if ((idx >= THIS->filter_data.num_elems) || (idx < 0))
Branch: 2 branches
BranchTrueFalseTotal
if ((idx >= THIS->filter_data.num_elems) || (idx < 0)) 1 1 2
if ((idx >= THIS->filter_data.num_elems) || (idx < 0)) 0 1 1
706 1 XSRETURN_NO ;
707 }
708 4 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 2 2 4
709 {
710 2 ▶ if ((idx >= THIS->logo_data.num_elems) || (idx < 0))
Branch: 2 branches
BranchTrueFalseTotal
if ((idx >= THIS->logo_data.num_elems) || (idx < 0)) 1 1 2
if ((idx >= THIS->logo_data.num_elems) || (idx < 0)) 0 1 1
711 1 XSRETURN_NO ;
712 }
713 2 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 2 0 2
714 {
715 2 ▶ if ((idx >= THIS->csv_data.num_elems) || (idx < 0))
Branch: 2 branches
BranchTrueFalseTotal
if ((idx >= THIS->csv_data.num_elems) || (idx < 0)) 1 1 2
if ((idx >= THIS->csv_data.num_elems) || (idx < 0)) 0 1 1
716 1 XSRETURN_NO ;
717 }
718 4 ADA_END_THIS ;
719
720 4 XSRETURN_YES;
721
722
723 # /*===================================================================================================*/
724
725
726 # /*---------------------------------------------------------------------------------------------------*/
727 # /* Update the gap count - only valid for filtered/logo array */
728
729 void
730 ADAV::update_gaps()
731
732 INIT:
733 2 ADA_METHOD(update_gaps);
734
735 CODE:
736 2 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 2 2
ADA_CHECK_THIS ; 0 2 2
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 2 0 2
ADA_CHECK_THIS ; 0 2 2
737
738 //fprintf(stderr, "ADAV:FETCHSIZE()\n") ;
739 2 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 0 2 2
740 {
741 0 ADA_UNEXPECTED_CALL ;
742 }
743 2 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 2 0 2
744 {
745 2 filtered_update_gaps(THIS) ;
746 }
747 0 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 0 0 0
748 {
749 0 logo_update_gaps(THIS) ;
750 }
751 0 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 0 0 0
752 {
753 0 ADA_UNEXPECTED_CALL ;
754 }
755 2 ADA_END_THIS ;
756
757
758 # /*---------------------------------------------------------------------------------------------------*/
759 # /* Add the key to all HASH entries - only valid for csv array */
760
761 void
762 ADAV::add_key(SV *key)
763
764 INIT:
765 1 ADA_METHOD(update_gaps);
766
767 CODE:
768 1 ▶ ADA_CHECK_THIS ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS ; 0 1 1
ADA_CHECK_THIS ; 0 1 1
ADA_CHECK_THIS ; 0 0 0
ADA_CHECK_THIS ; 1 0 1
ADA_CHECK_THIS ; 0 1 1
769
770 //fprintf(stderr, "ADAV:FETCHSIZE()\n") ;
771 1 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 0 1 1
772 {
773 0 ADA_UNEXPECTED_CALL ;
774 }
775 1 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 0 1 1
776 {
777 0 ADA_UNEXPECTED_CALL ;
778 }
779 1 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 0 1 1
780 {
781 0 ADA_UNEXPECTED_CALL ;
782 }
783 1 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 1 0 1
784 {
785 1 csv_add_key(THIS, key) ;
786 }
787 1 ADA_END_THIS ;
788
789
790 # /*---------------------------------------------------------------------------------------------------*/
791 # /* Check logo gap values - only valid for logo array */
792
793 void
794 ADAV::logo_frames_sanity(int frame)
795
796 INIT:
797 0 ADA_METHOD(logo_frames_sanity);
798
799 CODE:
800 0 ▶ ADA_CHECK_THIS_NODBG ;
Branch: 5 branches
BranchTrueFalseTotal
ADA_CHECK_THIS_NODBG ; 0 0 0
ADA_CHECK_THIS_NODBG ; 0 0 0
ADA_CHECK_THIS_NODBG ; 0 0 0
ADA_CHECK_THIS_NODBG ; 0 0 0
ADA_CHECK_THIS_NODBG ; 0 0 0
801
802 //fprintf(stderr, "ADAV:FETCHSIZE()\n") ;
803 0 ▶ if (THIS->type == ADAV_ADATA)
Branch: 1 branch
BranchTrueFalseTotal
if (THIS->type == ADAV_ADATA) 0 0 0
804 {
805 0 ADA_UNEXPECTED_CALL ;
806 }
807 0 ▶ else if (THIS->type == ADAV_FILTERED)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_FILTERED) 0 0 0
808 {
809 0 ADA_UNEXPECTED_CALL ;
810 }
811 0 ▶ else if (THIS->type == ADAV_LOGO)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_LOGO) 0 0 0
812 {
813 logo_frames_sanity(THIS, frame) ;
814 }
815 0 ▶ else if (THIS->type == ADAV_CSV)
Branch: 1 branch
BranchTrueFalseTotal
else if (THIS->type == ADAV_CSV) 0 0 0
816 {
817 0 ADA_UNEXPECTED_CALL ;
818 }
819 0 ADA_END_THIS ;
820
« xs/DVBT-advert-c.c ↑ Summary xs/DVBT-const.c »