1 # pan_and_scan.tcl --
2 #
3 # FIXME: This file needs a description here.
4 #
5 # Copyright (c) 1999-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 RectSubregionParameter
33
34 Class PanAndScanSubprogram -superclass DaliSubprogram
35
36 PanAndScanSubprogram 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) Uncompressed;
61 set output_info_(o1,buffername) [new VidRep/Uncompressed];
62 set output_info_(o1,encoder) "";
63 set output_info_(o1,format) H261;
64 set output_info_(o1,vagent) "";
65
66 # Set up parameters
67
68 $self instvar parameter_id_list_;
69 $self instvar parameter_info_;
70
71 lappend parameter_id_list_ roi
72 set pobj [new RectSubregionParameter];
73 set parameter_info_(roi,oname) $pobj;
74 $pobj set [list 0.0 0.0 1.0 1.0];
75
76 $self instvar comm_obj_;
77 $comm_obj_ setup;
78 }
79
80 PanAndScanSubprogram instproc trigger {} {
81 $self instvar comm_obj_;
82
83 if {![$comm_obj_ parameter_attr_has_value roi value]} {
84 return;
85 }
86
87 $self instvar parameter_info_;
88 $self instvar input_info_;
89 $self instvar output_info_;
90 $self instvar init_done_;
91 $self instvar old_roi_;
92 $self instvar la lb lc ld le lf ca cb cc cd ce cf
93
94 set roi_obj $parameter_info_(roi,oname);
95 set roi_coords [$roi_obj get];
96
97 set in_frame $input_info_(i1,buffername);
98 set out_frame $output_info_(o1,buffername);
99
100 if {![info exists init_done_]} {
101 if {[$in_frame set w_] == 0} {
102 return;
103 }
104 $out_frame copy_geometry $in_frame;
105 if {$output_info_(o1,format) == "JPEG"} {
106 $out_frame set h_subsample_ 2;
107 $out_frame set v_subsample_ 1;
108 } else {
109 $out_frame set h_subsample_ 2;
110 $out_frame set v_subsample_ 2;
111 }
112 $out_frame allocate;
113 set init_done_ 1;
114 set old_roi_ "";
115 }
116
117 if {$old_roi_ != $roi_coords} {
118 set w [$in_frame set w_];
119 set h [$in_frame set h_];
120
121 set in_h_sub [expr 1.0*[$in_frame set h_subsample_]]
122 set in_v_sub [expr 1.0*[$in_frame set v_subsample_]]
123 set out_h_sub [expr 1.0*[$out_frame set h_subsample_]]
124 set out_v_sub [expr 1.0*[$out_frame set v_subsample_]]
125
126 set roi_x1 [lindex $roi_coords 0];
127 set roi_x2 [lindex $roi_coords 2];
128 set roi_y1 [lindex $roi_coords 1];
129 set roi_y2 [lindex $roi_coords 3];
130
131 if {$roi_x2 == $roi_x1} {
132 set roi_x2 [expr $roi_x2+0.01];
133 }
134 if {$roi_y2 == $roi_y1} {
135 set roi_y2 [expr $roi_y2+0.01];
136 }
137
138 set sx [expr 1.0 / ($roi_x2 - $roi_x1)];
139 set sy [expr 1.0 / ($roi_y2 - $roi_y1)];
140
141 set tx [expr $roi_x1 * $w * -1];
142 set ty [expr $roi_x1 * $h * -1];
143
144 set la $sx;
145 set lb 0.0;
146 set lc [expr $tx*$sx];
147 set ld 0.0;
148 set le $sy;
149 set lf [expr $ty*$sy];
150
151 set ca [expr $sx];
152 set cb 0.0;
153 set cc [expr $tx*$sx/$in_h_sub];
154 set cd 0.0;
155 set ce [expr $sy];
156 set cf [expr $ty*$sy/$in_v_sub];
157
158 set old_roi_ $roi_coords;
159 }
160
161 set in_l [$in_frame get_lum_name];
162 set in_cr [$in_frame get_cr_name];
163 set in_cb [$in_frame get_cb_name];
164
165 set out_l [$out_frame get_lum_name];
166 set out_cr [$out_frame get_cr_name];
167 set out_cb [$out_frame get_cb_name];
168
169 byte_affine $in_l $out_l $la $lb $lc $ld $le $lf;
170 byte_affine $in_cr $out_cr $ca $cb $cc $cd $ce $cf;
171 byte_affine $in_cb $out_cb $ca $cb $cc $cd $ce $cf;
172
173 $out_frame set ts_ [$in_frame set ts_];
174
175 set encoder $output_info_(o1,encoder);
176
177 if {$encoder != ""} {
178 $encoder recv $out_frame;
179 }
180
181 $self send_completion_token
182
183 [[[[$input_info_(i1,decoder) set agent_] set network_] set net_(0)] set dn_] recv_flush
184
185 }
186
187
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.