1 # fade-subprogram.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1998-2002 The Regents of the University of California.
6 # All rights reserved.
7 #
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are met:
10 #
11 # A. Redistributions of source code must retain the above copyright notice,
12 # this list of conditions and the following disclaimer.
13 # B. Redistributions in binary form must reproduce the above copyright notice,
14 # this list of conditions and the following disclaimer in the documentation
15 # and/or other materials provided with the distribution.
16 # C. Neither the names of the copyright holders nor the names of its
17 # contributors may be used to endorse or promote products derived from this
18 # software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 import DaliSubprogram
32 import RealParameter
33
34 Class FadeSubprogram -superclass DaliSubprogram
35
36 FadeSubprogram instproc init {args} {
37 eval $self next $args;
38
39 # Set up inputs
40
41 $self instvar input_id_list_;
42 $self instvar input_info_;
43
44 lappend input_id_list_ i1
45
46 set input_info_(i1,spec) "";
47 set input_info_(i1,trigger) 0;
48 set input_info_(i1,buffertype) Uncompressed;
49 set input_info_(i1,buffername) [new VidRep/Uncompressed];
50 set input_info_(i1,decoder) "";
51
52 lappend input_id_list_ i2
53
54 set input_info_(i2,spec) "";
55 set input_info_(i2,trigger) 0;
56 set input_info_(i2,buffertype) Uncompressed;
57 set input_info_(i2,buffername) [new VidRep/Uncompressed];
58 set input_info_(i2,decoder) "";
59
60 # Set up outputs
61
62 $self instvar output_id_list_;
63 $self instvar output_info_;
64
65 lappend output_id_list_ o1;
66
67 set output_info_(o1,spec) "";
68 set output_info_(o1,buffertype) Uncompressed;
69 set output_info_(o1,buffername) [new VidRep/Uncompressed];
70 set output_info_(o1,encoder) "";
71 set output_info_(o1,format) JPEG;
72 set output_info_(o1,vagent) "";
73
74 # Set up which input will drive each output's synchronization
75 $self set_ntp_reference i1 o1
76
77 # Set up parameters
78
79 $self instvar parameter_id_list_;
80 $self instvar parameter_info_;
81
82 lappend parameter_id_list_ factor
83 set pobj [new RealParameter];
84
85 set parameter_info_(factor,oname) $pobj;
86 $pobj from 0.0
87 $pobj to 1.0
88 $pobj set 0.0
89
90 $self instvar comm_obj_;
91 $comm_obj_ setup;
92
93 }
94
95 FadeSubprogram instproc trigger {} {
96 $self instvar parameter_info_;
97 $self instvar input_info_;
98 $self instvar output_info_;
99 $self instvar init_done_;
100 $self instvar temp_a temp_b temp_out;
101 $self instvar rescale_output_flag_;
102
103 set in_frame_a $input_info_(i1,buffername);
104 set in_frame_b $input_info_(i2,buffername);
105 set out_frame $output_info_(o1,buffername);
106
107 if {![info exists init_done_]} {
108 if {[$in_frame_a set w_] == 0} {
109 return;
110 }
111 if {[$in_frame_b set w_] == 0} {
112 return;
113 }
114 $out_frame copy_geometry $in_frame_a;
115 if {$output_info_(o1,format) == "JPEG"} {
116 $out_frame set h_subsample_ 2;
117 $out_frame set v_subsample_ 1;
118 } else {
119 $out_frame set h_subsample_ 2;
120 $out_frame set v_subsample_ 2;
121 }
122 $out_frame allocate;
123
124 set temp_a [new VidRep/Uncompressed];
125 $temp_a copy_geometry $in_frame_a;
126 $temp_a allocate;
127
128 set temp_b [new VidRep/Uncompressed];
129 $temp_b copy_geometry $in_frame_b;
130 $temp_b allocate;
131
132 if {[$out_frame set v_subsample_] != [$temp_a set v_subsample_]} {
133 set rescale_output_flag_ 1;
134 set temp_out [new Uncompressed];
135 $temp_out copy_geometry $temp_a;
136 $temp_out allocate;
137 } else {
138 set rescale_output_flag_ 0;
139 }
140 set init_done_ 1;
141 }
142
143 set in_l_a [$in_frame_a get_lum_name];
144 set in_cr_a [$in_frame_a get_cr_name];
145 set in_cb_a [$in_frame_a get_cb_name];
146
147 set in_l_b [$in_frame_b get_lum_name];
148 set in_cr_b [$in_frame_b get_cr_name];
149 set in_cb_b [$in_frame_b get_cb_name];
150
151 set temp_l_a [$temp_a get_lum_name];
152 set temp_cr_a [$temp_a get_cr_name];
153 set temp_cb_a [$temp_a get_cb_name];
154
155 set temp_l_b [$temp_b get_lum_name];
156 set temp_cr_b [$temp_b get_cr_name];
157 set temp_cb_b [$temp_b get_cb_name];
158
159 set out_l [$out_frame get_lum_name];
160 set out_cr [$out_frame get_cr_name];
161 set out_cb [$out_frame get_cb_name];
162
163 set factor [$parameter_info_(factor,oname) get];
164
165 byte_scalar_mult $in_l_a $temp_l_a $factor;
166 byte_scalar_mult $in_cr_a $temp_cr_a $factor;
167 byte_scalar_mult $in_cb_a $temp_cb_a $factor;
168
169 set factor [expr 1.0 - $factor];
170
171 byte_scalar_mult $in_l_b $temp_l_b $factor;
172 byte_scalar_mult $in_cr_b $temp_cr_b $factor;
173 byte_scalar_mult $in_cb_b $temp_cb_b $factor;
174
175 if {$rescale_output_flag_ == 1} {
176 puts "Ooops"
177 } else {
178 byte_add $temp_cr_a $temp_cr_b $out_cr;
179 byte_add $temp_cb_a $temp_cb_b $out_cb;
180 }
181 byte_add $temp_l_a $temp_l_b $out_l;
182
183 $out_frame set ts_ [$in_frame_a set ts_];
184
185 set encoder $output_info_(o1,encoder);
186
187 if {$encoder != ""} {
188 $encoder recv $out_frame;
189 }
190 $self send_completion_token;
191
192 [[[[$input_info_(i1,decoder) set agent_] set network_] set net_(0)] set dn_] recv_flush
193
194 }
195
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.