1 # sc-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 ScFadeSubprogram -superclass DaliSubprogram
35
36 ScFadeSubprogram 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) Semicompressed;
49 set input_info_(i1,buffername) [new VidRep/Semicompressed];
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) Semicompressed;
57 set input_info_(i2,buffername) [new VidRep/Semicompressed];
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) Semicompressed;
69 set output_info_(o1,buffername) [new VidRep/Semicompressed];
70 set output_info_(o1,encoder) "";
71 set output_info_(o1,format) JPEG;
72 set output_info_(o1,vagent) "";
73
74 # Set up parameters
75
76 $self instvar parameter_id_list_;
77 $self instvar parameter_info_;
78
79 lappend parameter_id_list_ factor
80 set pobj [new RealParameter];
81
82 set parameter_info_(factor,oname) $pobj;
83 $pobj from 0.0
84 $pobj to 1.0
85 $pobj set 0.0
86 }
87
88 ScFadeSubprogram instproc trigger {} {
89 $self instvar parameter_info_;
90 $self instvar input_info_;
91 $self instvar output_info_;
92 $self instvar init_done_;
93 $self instvar temp_a temp_b temp_out;
94 $self instvar rescale_output_flag_;
95
96 set in_frame_a $input_info_(i1,buffername);
97 set in_frame_b $input_info_(i2,buffername);
98 set out_frame $output_info_(o1,buffername);
99
100 if {![info exists init_done_]} {
101 if {[$in_frame_a set w_] == 0} {
102 return;
103 }
104 if {[$in_frame_b set w_] == 0} {
105 return;
106 }
107 $out_frame copy_geometry $in_frame_a;
108 if {$output_info_(o1,format) == "JPEG"} {
109 $out_frame set h_subsample_ 2;
110 $out_frame set v_subsample_ 1;
111 } else {
112 $out_frame set h_subsample_ 2;
113 $out_frame set v_subsample_ 2;
114 }
115 $out_frame allocate;
116
117 set temp_a [new VidRep/Semicompressed];
118 $temp_a copy_geometry $in_frame_a;
119 $temp_a allocate;
120
121 set temp_b [new VidRep/Semicompressed];
122 $temp_b copy_geometry $in_frame_b;
123 $temp_b allocate;
124
125 if {[$out_frame set v_subsample_] != [$temp_a set v_subsample_]} {
126 set rescale_output_flag_ 1;
127 set temp_out [new Semicompressed];
128 $temp_out copy_geometry $temp_a;
129 $temp_out allocate;
130 } else {
131 set rescale_output_flag_ 0;
132 }
133 set init_done_ 1;
134 }
135
136 set in_l_a [$in_frame_a get_lum_name];
137 set in_cr_a [$in_frame_a get_cr_name];
138 set in_cb_a [$in_frame_a get_cb_name];
139
140 set in_l_b [$in_frame_b get_lum_name];
141 set in_cr_b [$in_frame_b get_cr_name];
142 set in_cb_b [$in_frame_b get_cb_name];
143
144 set temp_l_a [$temp_a get_lum_name];
145 set temp_cr_a [$temp_a get_cr_name];
146 set temp_cb_a [$temp_a get_cb_name];
147
148 set temp_l_b [$temp_b get_lum_name];
149 set temp_cr_b [$temp_b get_cr_name];
150 set temp_cb_b [$temp_b get_cb_name];
151
152 set out_l [$out_frame get_lum_name];
153 set out_cr [$out_frame get_cr_name];
154 set out_cb [$out_frame get_cb_name];
155
156 set factor [$parameter_info_(factor,oname) get];
157
158 sc_scalar_mult $in_l_a $temp_l_a $factor;
159 sc_scalar_mult $in_cr_a $temp_cr_a $factor;
160 sc_scalar_mult $in_cb_a $temp_cb_a $factor;
161
162 sc_scalar_mult $in_l_b $temp_l_b [expr 1.0 - $factor];
163 sc_scalar_mult $in_cr_b $temp_cr_b [expr 1.0 - $factor];
164 sc_scalar_mult $in_cb_b $temp_cb_b [expr 1.0 - $factor];
165
166 if {$rescale_output_flag_ == 1} {
167 puts "Ooops"
168 } else {
169 sc_add $temp_cr_a $temp_cr_b $out_cr;
170 sc_add $temp_cb_a $temp_cb_b $out_cb;
171 }
172 sc_add $temp_l_a $temp_l_b $out_l;
173
174 $out_frame set ts_ [$in_frame_a set ts_];
175
176 set encoder $output_info_(o1,encoder);
177
178 if {$encoder != ""} {
179 $encoder recv $out_frame;
180 }
181 $self send_completion_token;
182 }
183
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.