xs/DVBT-ts-skip.c

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 64 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 114 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/DVBT-ts-shared-c.c ↑ Summary xs/DVBT-ts.c »
1 # VERSION = "1.000"
2  
3 # /*---------------------------------------------------------------------------------------------------*/
4 # /* Cut TS file removing cut regions (adverts) */
5  
6 int
7 dvb_ts_cut(char *filename, char *ofilename, SV *cuts_aref, HV *settings_href=NULL)
8 INIT:
9 struct TS_settings settings;
10 SV **val;
11 struct list_head cut_list;
12 unsigned num_entries ;
13 unsigned i ;
14 SV **item ;
15 HV *href ;
16 unsigned start ;
17 unsigned end ;
18  
19 CODE:
20 0 dvb_error_clear() ;
21 0 clear_settings(&settings) ;
22  
23 0 ▶ if (settings_href)
Branch: 1 branch
BranchTrueFalseTotal
if (settings_href) 0 0 0
24 {
25 0 ▶ HVF_IV(settings_href, debug, settings.debug) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
26 0 ▶ HVF_IV(settings_href, save_cut, settings.save_cut) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, save_cut, settings.save_cut) ; 0 0 0
HVF_IV(settings_href, save_cut, settings.save_cut) ; 0 0 0
27 0 ▶ HVF_SVV(settings_href, error_callback, settings.error_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
28 0 ▶ HVF_SVV(settings_href, user_data, settings.perl_data) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
29 }
30  
31 // fprintf(stderr, "cuts_aref ok = %d\n", SvROK(cuts_aref)) ;
32 // fprintf(stderr, "cuts_aref type %d want %d\n", SvTYPE(SvRV(cuts_aref)), SVt_PVAV);
33  
34  
35 0 ▶ if ((!SvROK(cuts_aref))
Branch: 1 branch
BranchTrueFalseTotal
if ((!SvROK(cuts_aref)) 0 0 0
36 0 ▶ || (SvTYPE(SvRV(cuts_aref)) != SVt_PVAV))
Branch: 1 branch
BranchTrueFalseTotal
|| (SvTYPE(SvRV(cuts_aref)) != SVt_PVAV)) 0 0 0
37 {
38 0 croak("Linux::DVB::DVBT::TS::dvb_ts_cut requires a valid cuts array ref") ;
39 }
40  
41 // av_len returns -1 for empty. Returns maximum index number otherwise
42 0 num_entries = av_len( (AV *)SvRV(cuts_aref) ) + 1 ;
43 0 ▶ if (num_entries <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (num_entries <= 0) 0 0 0
44 {
45 0 croak("Linux::DVB::DVBT::TS::dvb_ts_cut requires a list of cuts hashes") ;
46 }
47  
48  
49 // Create cut list
50 0 INIT_LIST_HEAD(&cut_list);
51  
52 0 ▶ for (i=0; i <= num_entries ; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i=0; i <= num_entries ; i++) 0 0 0
53 {
54 0 ▶ if ((item = av_fetch((AV *)SvRV(cuts_aref), i, 0)) && SvOK (*item))
Branch: 2 branches
BranchTrueFalseTotal
if ((item = av_fetch((AV *)SvRV(cuts_aref), i, 0)) && SvOK (*item)) 0 0 0
if ((item = av_fetch((AV *)SvRV(cuts_aref), i, 0)) && SvOK (*item)) 0 0 0
55 {
56 0 ▶ if ( SvTYPE(SvRV(*item)) != SVt_PVHV )
Branch: 1 branch
BranchTrueFalseTotal
if ( SvTYPE(SvRV(*item)) != SVt_PVHV ) 0 0 0
57 {
58 0 croak("Linux::DVB::DVBT::TS::dvb_ts_cut requires a list of cut hashes") ;
59 }
60 0 href = (HV *)SvRV(*item) ;
61  
62 // get start..end cut packet numbers
63 0 val = HVF(href, start_pkt) ;
64 0 start = SvIV (*val) ;
65 0 val = HVF(href, end_pkt) ;
66 0 end = SvIV (*val) ;
67  
68 // add to cut list
69 0 add_cut(&cut_list, start, end) ;
70 }
71 }
72  
73  
74 //_print_cut_list("__INITIAL__", &cut_list) ;
75  
76 // cut (frees the cut_list)
77 0 RETVAL = ts_cut(filename, ofilename, &cut_list, settings.debug) ;
78  
79 OUTPUT:
80 RETVAL
81  
82 # /*---------------------------------------------------------------------------------------------------*/
83 # /* Split TS file into program segments and advert segments */
84  
85 int
86 dvb_ts_split(char *filename, char *ofilename, SV *cuts_aref, HV *settings_href=NULL)
87 INIT:
88 struct TS_settings settings;
89 SV **val;
90 struct list_head cut_list;
91 unsigned num_entries ;
92 unsigned i ;
93 SV **item ;
94 HV *href ;
95 unsigned start ;
96 unsigned end ;
97  
98 CODE:
99 0 dvb_error_clear() ;
100 0 clear_settings(&settings) ;
101  
102 0 ▶ if (settings_href)
Branch: 1 branch
BranchTrueFalseTotal
if (settings_href) 0 0 0
103 {
104 0 ▶ HVF_IV(settings_href, debug, settings.debug) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
HVF_IV(settings_href, debug, settings.debug) ; 0 0 0
105 0 ▶ HVF_IV(settings_href, save_cut, settings.save_cut) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_IV(settings_href, save_cut, settings.save_cut) ; 0 0 0
HVF_IV(settings_href, save_cut, settings.save_cut) ; 0 0 0
106 0 ▶ HVF_SVV(settings_href, error_callback, settings.error_callback) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
HVF_SVV(settings_href, error_callback, settings.error_callback) ; 0 0 0
107 0 ▶ HVF_SVV(settings_href, user_data, settings.perl_data) ;
Branch: 2 branches
BranchTrueFalseTotal
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
HVF_SVV(settings_href, user_data, settings.perl_data) ; 0 0 0
108 }
109  
110 // fprintf(stderr, "cuts_aref ok = %d\n", SvROK(cuts_aref)) ;
111 // fprintf(stderr, "cuts_aref type %d want %d\n", SvTYPE(SvRV(cuts_aref)), SVt_PVAV);
112  
113  
114 0 ▶ if ((!SvROK(cuts_aref))
Branch: 1 branch
BranchTrueFalseTotal
if ((!SvROK(cuts_aref)) 0 0 0
115 0 ▶ || (SvTYPE(SvRV(cuts_aref)) != SVt_PVAV))
Branch: 1 branch
BranchTrueFalseTotal
|| (SvTYPE(SvRV(cuts_aref)) != SVt_PVAV)) 0 0 0
116 {
117 0 croak("Linux::DVB::DVBT::TS::dvb_ts_split requires a valid cuts array ref") ;
118 }
119  
120 // av_len returns -1 for empty. Returns maximum index number otherwise
121 0 num_entries = av_len( (AV *)SvRV(cuts_aref) ) + 1 ;
122 0 ▶ if (num_entries <= 0)
Branch: 1 branch
BranchTrueFalseTotal
if (num_entries <= 0) 0 0 0
123 {
124 0 croak("Linux::DVB::DVBT::TS::dvb_ts_split requires a list of cuts hashes") ;
125 }
126  
127  
128 // Create cut list
129 0 INIT_LIST_HEAD(&cut_list);
130  
131 0 ▶ for (i=0; i <= num_entries ; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i=0; i <= num_entries ; i++) 0 0 0
132 {
133 0 ▶ if ((item = av_fetch((AV *)SvRV(cuts_aref), i, 0)) && SvOK (*item))
Branch: 2 branches
BranchTrueFalseTotal
if ((item = av_fetch((AV *)SvRV(cuts_aref), i, 0)) && SvOK (*item)) 0 0 0
if ((item = av_fetch((AV *)SvRV(cuts_aref), i, 0)) && SvOK (*item)) 0 0 0
134 {
135 0 ▶ if ( SvTYPE(SvRV(*item)) != SVt_PVHV )
Branch: 1 branch
BranchTrueFalseTotal
if ( SvTYPE(SvRV(*item)) != SVt_PVHV ) 0 0 0
136 {
137 0 croak("Linux::DVB::DVBT::TS::dvb_ts_split requires a list of cut hashes") ;
138 }
139 0 href = (HV *)SvRV(*item) ;
140  
141 // get start..end cut packet numbers
142 0 val = HVF(href, start_pkt) ;
143 0 start = SvIV (*val) ;
144 0 val = HVF(href, end_pkt) ;
145 0 end = SvIV (*val) ;
146  
147 // add to cut list
148 0 add_cut(&cut_list, start, end) ;
149 }
150 }
151  
152  
153 //_print_cut_list("__INITIAL__", &cut_list) ;
154  
155 // split (frees the cut_list)
156 0 RETVAL = ts_split(filename, ofilename, &cut_list, settings.debug) ;
157  
158 OUTPUT:
159 RETVAL
160  
161  
« xs/DVBT-ts-shared-c.c ↑ Summary xs/DVBT-ts.c »