1 # whirlpool-sc.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 WhirlpoolScSubprogram -superclass DaliSubprogram
35
36 WhirlpoolScSubprogram 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 # Set up outputs
53
54 $self instvar output_id_list_;
55 $self instvar output_info_;
56
57 lappend output_id_list_ o1;
58
59 set output_info_(o1,spec) "";
60 set output_info_(o1,buffertype) Semicompressed;
61 set output_info_(o1,buffername) [new VidRep/Semicompressed];
62 set output_info_(o1,encoder) "";
63 set output_info_(o1,format) SC;
64 set output_info_(o1,vagent) "";
65 set output_info_(o1,geometry) [list 0.0 0.0 1.0 1.0];
66 set output_info_(o1,geometry_change) 0;
67
68 # Set up parameters
69
70 $self instvar parameter_id_list_;
71 $self instvar parameter_info_;
72
73 lappend parameter_id_list_ theta
74 set pobj [new RealParameter];
75
76 set parameter_info_(theta,oname) $pobj;
77 $pobj from 0.0
78 $pobj to 10.0
79 $pobj set 0.0
80
81 $self instvar comm_obj_;
82 $comm_obj_ setup;
83 }
84
85 WhirlpoolScSubprogram instproc set_output_geometry {id geometry} {
86 $self instvar output_info_;
87
88 set output_info_($id,geometry) $geometry;
89 set output_info_($id,geometry_change) 1;
90 }
91
92 WhirlpoolScSubprogram instproc trigger {} {
93 $self instvar comm_obj_;
94
95 if {![$comm_obj_ parameter_attr_has_value theta value]} {
96 return;
97 }
98
99 $self instvar parameter_info_;
100 $self instvar input_info_;
101 $self instvar output_info_;
102 $self instvar init_done_;
103 $self instvar old_theta_;
104 $self instvar la lb lc ld le lf ca cb cc cd ce cf
105 $self instvar temp_out_;
106 $self instvar tout_l_ tout_cr_ tout_cb_;
107
108 set angle_obj $parameter_info_(theta,oname);
109 set angle [$angle_obj get];
110
111 set in_frame $input_info_(i1,buffername);
112 set out_frame $output_info_(o1,buffername);
113
114 if {![info exists init_done_]} {
115 if {[$in_frame set w_] == 0} {
116 return;
117 }
118
119 set temp_out_ [new VidRep/Uncompressed];
120 $temp_out_ copy_geometry $in_frame;
121 $temp_out_ set h_subsample_ 2;
122 $temp_out_ set v_subsample_ 1;
123 $temp_out_ allocate;
124
125 set x0 [lindex $output_info_(o1,geometry) 0];
126 set y0 [lindex $output_info_(o1,geometry) 1];
127 set x1 [lindex $output_info_(o1,geometry) 2];
128 set y1 [lindex $output_info_(o1,geometry) 3];
129
130 set xp0 [expr ((int([$in_frame set true_w_] * $x0) + 8) / 16) * 16];
131 set xp1 [expr ((int([$in_frame set true_w_] * $x1) + 8) / 16) * 16];
132 set yp0 [expr ((int([$in_frame set true_h_] * $y0) + 4) / 8) * 8];
133 set yp1 [expr ((int([$in_frame set true_h_] * $y1) + 4) / 8) * 8];
134
135 $out_frame set true_w_ [$in_frame set true_w_];
136 $out_frame set true_h_ [$in_frame set true_h_];
137 $out_frame set xoff_ $xp0;
138 $out_frame set yoff_ $yp0;
139 $out_frame set w_ [expr $xp1 - $xp0]
140 $out_frame set h_ [expr $yp1 - $yp0]
141 $out_frame set h_subsample_ 2;
142 $out_frame set v_subsample_ 1;
143 $out_frame allocate;
144
145 set tout_l_ [byte_clip [$temp_out_ get_lum_name] $xp0 $yp0 [expr $xp1 - $xp0] [expr $yp1 - $yp0]];
146 set tout_cr_ [byte_clip [$temp_out_ get_cr_name] [expr $xp0 / 2] $yp0 [expr ($xp1 - $xp0)/ 2] [expr $yp1 - $yp0]];
147 set tout_cb_ [byte_clip [$temp_out_ get_cb_name] [expr $xp0 / 2] $yp0 [expr ($xp1 - $xp0)/ 2] [expr $yp1 - $yp0]];
148
149 set init_done_ 1;
150 set old_theta_ "";
151 set output_info_(o1,geometry_change) 0;
152 }
153
154 if {$output_info_(o1,geometry_change) == 1} {
155 set x0 [lindex $output_info_(o1,geometry) 0];
156 set y0 [lindex $output_info_(o1,geometry) 1];
157 set x1 [lindex $output_info_(o1,geometry) 2];
158 set y1 [lindex $output_info_(o1,geometry) 3];
159
160 set xp0 [expr ((int([$in_frame set true_w_] * $x0) + 8) / 16) * 16];
161 set xp1 [expr ((int([$in_frame set true_w_] * $x1) + 8) / 16) * 16];
162 set yp0 [expr ((int([$in_frame set true_h_] * $y0) + 4) / 8) * 8];
163 set yp1 [expr ((int([$in_frame set true_h_] * $y1) + 4) / 8) * 8];
164
165 $out_frame set true_w_ [$in_frame set true_w_];
166 $out_frame set true_h_ [$in_frame set true_h_];
167 $out_frame set xoff_ $xp0;
168 $out_frame set yoff_ $yp0;
169 $out_frame set w_ [expr $xp1 - $xp0]
170 $out_frame set h_ [expr $yp1 - $yp0]
171 $out_frame set h_subsample_ 2;
172 $out_frame set v_subsample_ 1;
173 $out_frame allocate;
174
175 byte_free $tout_l_;
176 byte_free $tout_cr_;
177 byte_free $tout_cb_;
178
179 set tout_l_ [byte_clip [$temp_out_ get_lum_name] $xp0 $yp0 [expr $xp1 - $xp0] [expr $yp1 - $yp0]];
180 set tout_cr_ [byte_clip [$temp_out_ get_cr_name] [expr $xp0 / 2] $yp0 [expr ($xp1 - $xp0)/ 2] [expr $yp1 - $yp0]];
181 set tout_cb_ [byte_clip [$temp_out_ get_cb_name] [expr $xp0 / 2] $yp0 [expr ($xp1 - $xp0)/ 2] [expr $yp1 - $yp0]];
182
183 set output_info_(o1,geometry_change) 0;
184 }
185
186 if {$old_theta_ != $angle} {
187 set w [$in_frame set w_];
188 set h [$in_frame set h_];
189
190 set cos_angle [expr cos($angle)];
191 set sin_angle [expr sin($angle)];
192
193 set in_h_sub [expr 1.0*[$in_frame set h_subsample_]]
194 set in_v_sub [expr 1.0*[$in_frame set v_subsample_]]
195 set out_h_sub [expr 1.0*[$out_frame set h_subsample_]]
196 set out_v_sub [expr 1.0*[$out_frame set v_subsample_]]
197
198 set sf [expr 1.0 - ($angle/10.0)];
199
200 set la [expr $sf * $cos_angle];
201 set lb [expr -($sf * $sin_angle)];
202 set lc [expr ($w - ($sf * $w * $cos_angle) + ($sf * $h * $sin_angle)) / 2.0];
203 set ld [expr $sf * $sin_angle];
204 set le [expr $sf * $cos_angle];
205 set lf [expr ($h - ($h * $sf * $cos_angle) - ($sf * $w * $sin_angle)) / 2.0];
206
207 set ca [expr $la * $in_h_sub / $out_h_sub];
208 set cb [expr $lb * $in_v_sub / $out_h_sub];
209 set cc [expr $lc / $out_h_sub];
210 set cd [expr $ld * $in_h_sub / $out_v_sub];
211 set ce [expr $le * $in_v_sub / $out_v_sub];
212 set cf [expr $lf / $out_v_sub];
213
214 set old_theta_ $angle;
215 }
216
217 set in_l [$in_frame get_lum_name];
218 set in_cr [$in_frame get_cr_name];
219 set in_cb [$in_frame get_cb_name];
220
221 byte_set $tout_l_ 0
222 byte_set $tout_cr_ 128
223 byte_set $tout_cb_ 128
224
225
226 byte_affine $in_l $tout_l_ $la $lb $lc $ld $le $lf;
227 byte_affine $in_cr $tout_cr_ $ca $cb $cc $cd $ce $cf;
228 byte_affine $in_cb $tout_cb_ $ca $cb $cc $cd $ce $cf;
229
230 set out_l [$out_frame get_lum_name];
231 set out_cr [$out_frame get_cr_name];
232 set out_cb [$out_frame get_cb_name];
233
234 $out_frame set ts_ [$in_frame set ts_];
235 kpatel_byte_to_sc $tout_l_ $out_l 0;
236 kpatel_byte_to_sc $tout_cr_ $out_cr 1;
237 kpatel_byte_to_sc $tout_cb_ $out_cb 1;
238
239 set encoder $output_info_(o1,encoder);
240
241 if {$encoder != ""} {
242 $encoder recv $out_frame;
243 }
244
245 $self send_completion_token
246
247 [[[[$input_info_(i1,decoder) set agent_] set network_] set net_(0)] set dn_] recv_flush
248
249 }
250
251
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.