1 # pip-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 PiPSubprogram -superclass DaliSubprogram
35
36 PiPSubprogram 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 parameters
75
76 $self instvar parameter_id_list_;
77 $self instvar parameter_info_;
78
79 lappend parameter_id_list_ size
80 set pobj [new RealParameter];
81
82 set parameter_info_(size,oname) $pobj;
83 $pobj from 0.0
84 $pobj to 1.0
85 $pobj set 0.0
86
87 lappend parameter_id_list_ xpos
88 set pobj [new RealParameter];
89
90 set parameter_info_(xpos,oname) $pobj;
91 $pobj from 0.0
92 $pobj to 1.0
93 $pobj set 0.0
94
95 lappend parameter_id_list_ ypos
96 set pobj [new RealParameter];
97
98 set parameter_info_(ypos,oname) $pobj;
99 $pobj from 0.0
100 $pobj to 1.0
101 $pobj set 0.0
102 }
103
104 PiPSubprogram instproc trigger {} {
105 $self instvar parameter_info_;
106 $self instvar input_info_;
107 $self instvar output_info_;
108 $self instvar init_done_;
109 $self instvar la lb lc ld le lf ca cb cc cd ce cf
110 $self instvar old_xpos old_ypos old_size;
111
112
113 set size [$parameter_info_(size,oname) get];
114 set xpos [$parameter_info_(xpos,oname) get];
115 set ypos [$parameter_info_(ypos,oname) get];
116
117 set in_frame $input_info_(i1,buffername);
118 set pip_frame $input_info_(i2,buffername);
119 set out_frame $output_info_(o1,buffername);
120
121 if {![info exists init_done_]} {
122 if {[$in_frame set w_] == 0} {
123 $self send_debug_mesg "Init failure: in_frame w == 0";
124 return;
125 }
126 if {[$pip_frame set w_] == 0} {
127 $self send_debug_mesg "Init failure: pip_frame w == 0";
128 return;
129 }
130
131 $out_frame copy_geometry $in_frame;
132
133 if {$output_info_(o1,format) == "JPEG"} {
134 $out_frame set h_subsample_ 2;
135 $out_frame set v_subsample_ 1;
136 } else {
137 $out_frame set h_subsample_ 2;
138 $out_frame set v_subsample_ 2;
139 }
140 $out_frame allocate;
141
142 set init_done_ 1;
143
144 set old_xpos "";
145 set old_ypos "";
146 set old_size "";
147 }
148
149 if {$old_xpos != $xpos || $old_ypos != $ypos || $old_size != $size} {
150 set wa [$in_frame set w_];
151 set ha [$in_frame set h_];
152
153 set wb [$pip_frame set w_];
154 set hb [$pip_frame set h_];
155
156 set la [expr ($size * $wa) / ($wb * 1.0)];
157 set lb 0.0;
158 set lc [expr $wa * $xpos];
159 set ld 0.0;
160 set le [expr ($size * $ha) / ($hb * 1.0)];
161 set lf [expr $ha * $ypos];
162
163 set ca [expr $la * [$pip_frame set h_subsample_] / [$out_frame set h_subsample_]];
164 set cb $lb;
165 set cc [expr $lc/([$out_frame set h_subsample_]*1.0)];
166 set cd $ld;
167 set ce [expr $le * [$pip_frame set v_subsample_] / [$out_frame set v_subsample_]];
168 set cf [expr $lf/([$out_frame set v_subsample_]*1.0)];
169
170 set old_xpos $xpos;
171 set old_ypos $ypos;
172 set old_size $size;
173 }
174
175 set in_l [$in_frame get_lum_name];
176 set in_cr [$in_frame get_cr_name];
177 set in_cb [$in_frame get_cb_name];
178
179 set out_l [$out_frame get_lum_name];
180 set out_cr [$out_frame get_cr_name];
181 set out_cb [$out_frame get_cb_name];
182
183 set pip_l [$pip_frame get_lum_name];
184 set pip_cr [$pip_frame get_cr_name];
185 set pip_cb [$pip_frame get_cb_name];
186
187 byte_copy $in_l $out_l;
188 if {[$out_frame set v_subsample_] == 2 && [$in_frame set v_subsample_] == 1} {
189 byte_shrink_1x2 $in_cr $out_cr;
190 byte_shrink_1x2 $in_cb $out_cb;
191 } elseif {[$out_frame set v_subsample_] == 1 && [$in_frame set v_subsample_] == 2} {
192 byte_expand_1x2 $in_cr $out_cr;
193 byte_expand_1x2 $in_cb $out_cb;
194 } else {
195 byte_copy $in_cr $out_cr;
196 byte_copy $in_cb $out_cb;
197 }
198
199 byte_affine $pip_l $out_l $la $lb $lc $ld $le $lf;
200 byte_affine $pip_cr $out_cr $ca $cb $cc $cd $ce $cf;
201 byte_affine $pip_cb $out_cb $ca $cb $cc $cd $ce $cf;
202
203 $out_frame set ts_ [$in_frame set ts_];
204
205 set encoder $output_info_(o1,encoder);
206
207 if {$encoder != ""} {
208 $encoder recv $out_frame;
209 }
210 $self send_completion_token
211 }
212
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.