1 # h261-fade-subprogram.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 RealParameter
33
34 Class H261FadeSubprogram -superclass DaliSubprogram
35
36 H261FadeSubprogram 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 set input_info_(i1,primary_trigger) 1
52
53 lappend input_id_list_ i2
54
55 set input_info_(i2,spec) "";
56 set input_info_(i2,trigger) 0;
57 set input_info_(i2,buffertype) Uncompressed;
58 set input_info_(i2,buffername) [new VidRep/Uncompressed];
59 set input_info_(i2,decoder) "";
60
61 # Set up outputs
62
63 $self instvar output_id_list_;
64 $self instvar output_info_;
65
66 lappend output_id_list_ o1;
67
68 set output_info_(o1,spec) "";
69 set output_info_(o1,buffertype) Uncompressed;
70 set output_info_(o1,buffername) [new VidRep/Uncompressed];
71 set output_info_(o1,encoder) "";
72 set output_info_(o1,format) H261;
73 set output_info_(o1,vagent) "";
74
75 # Set up which input will drive each output's synchronization
76 $self set_ntp_reference i1 o1
77
78 # Set up parameters
79
80 $self instvar parameter_id_list_;
81 $self instvar parameter_info_;
82
83 lappend parameter_id_list_ factor
84 set pobj [new RealParameter];
85
86 set parameter_info_(factor,oname) $pobj;
87 $pobj from 0.0
88 $pobj to 1.0
89 $pobj set 0.0
90
91 $self instvar comm_obj_;
92 $comm_obj_ setup;
93
94 }
95
96 H261FadeSubprogram instproc trigger {} {
97 $self instvar parameter_info_;
98 $self instvar input_info_;
99 $self instvar output_info_;
100 $self instvar init_done_;
101 $self instvar temp_a temp_b temp_out;
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 $out_frame set h_subsample_ 2;
116 $out_frame set v_subsample_ 2;
117 $out_frame allocate;
118
119 set temp_a [new VidRep/Uncompressed];
120 $temp_a copy_geometry $in_frame_a;
121 $temp_a allocate;
122
123 set temp_b [new VidRep/Uncompressed];
124 $temp_b copy_geometry $in_frame_b;
125 $temp_b allocate;
126
127 set init_done_ 1;
128 }
129
130 set in_l_a [$in_frame_a get_lum_name];
131 set in_cr_a [$in_frame_a get_cr_name];
132 set in_cb_a [$in_frame_a get_cb_name];
133
134 set in_l_b [$in_frame_b get_lum_name];
135 set in_cr_b [$in_frame_b get_cr_name];
136 set in_cb_b [$in_frame_b get_cb_name];
137
138 set temp_l_a [$temp_a get_lum_name];
139 set temp_cr_a [$temp_a get_cr_name];
140 set temp_cb_a [$temp_a get_cb_name];
141
142 set temp_l_b [$temp_b get_lum_name];
143 set temp_cr_b [$temp_b get_cr_name];
144 set temp_cb_b [$temp_b get_cb_name];
145
146 set out_l [$out_frame get_lum_name];
147 set out_cr [$out_frame get_cr_name];
148 set out_cb [$out_frame get_cb_name];
149
150 set factor [$parameter_info_(factor,oname) get];
151
152 byte_scalar_mult $in_l_a $temp_l_a $factor;
153 byte_scalar_mult $in_cr_a $temp_cr_a $factor;
154 byte_scalar_mult $in_cb_a $temp_cb_a $factor;
155
156 set factor [expr 1.0 - $factor];
157
158 byte_scalar_mult $in_l_b $temp_l_b $factor;
159 byte_scalar_mult $in_cr_b $temp_cr_b $factor;
160 byte_scalar_mult $in_cb_b $temp_cb_b $factor;
161
162 byte_add $temp_cr_a $temp_cr_b $out_cr;
163 byte_add $temp_cb_a $temp_cb_b $out_cb;
164 byte_add $temp_l_a $temp_l_b $out_l;
165
166 $out_frame set ts_ [$in_frame_a set ts_];
167
168 set encoder $output_info_(o1,encoder);
169
170 if {$encoder != ""} {
171 $encoder recv $out_frame;
172 }
173 $self send_completion_token;
174
175 [[[[$input_info_(i1,decoder) set agent_] set network_] set net_(0)] set dn_] recv_flush
176
177 }
178
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.