~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/psvp/effects/whirlpool-mjpeg.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # whirlpool-mjpeg.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 WhirlpoolMJPEGSubprogram -superclass DaliSubprogram
 35 
 36 WhirlpoolMJPEGSubprogram 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) JPEGCompressed;
 49     set input_info_(i1,buffername) [new VidRep/JPEGCompressed];
 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) JPEG;
 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_ theta
 72     set pobj [new RealParameter];
 73 
 74     set parameter_info_(theta,oname) $pobj;
 75     $pobj from 0.0
 76     $pobj to 10.0
 77     $pobj set 0.0
 78 
 79     $self instvar comm_obj_;
 80     $comm_obj_ setup;
 81 }
 82 
 83 WhirlpoolMJPEGSubprogram instproc trigger {} {
 84     $self instvar comm_obj_;
 85 
 86     if {![$comm_obj_ parameter_attr_has_value theta value]} {
 87         return;
 88     }
 89 
 90     $self instvar parameter_info_;
 91     $self instvar input_info_;
 92     $self instvar output_info_;
 93     $self instvar init_done_;
 94     $self instvar old_theta_;
 95     $self instvar la lb lc ld le lf ca cb cc cd ce cf
 96     $self instvar uncomp_in_;
 97     $self instvar xcoder_;
 98 
 99     set angle_obj $parameter_info_(theta,oname);
100     set angle [$angle_obj get];
101 
102     set in_frame $input_info_(i1,buffername);
103     set out_frame $output_info_(o1,buffername);
104 
105     if {![info exists init_done_]} {
106         if {[$in_frame set w_] == 0} {
107             return;
108         }
109 
110         $out_frame copy_geometry $in_frame;
111         if {$output_info_(o1,format) == "JPEG"} {
112             $out_frame set h_subsample_ 2;
113             $out_frame set v_subsample_ 1;
114         } else {
115             $out_frame set h_subsample_ 2;
116             $out_frame set v_subsample_ 2;
117         }
118         $out_frame allocate;
119 
120         set uncomp_in_ [new VidRep/Uncompressed];
121         $uncomp_in_ copy_geometry $in_frame;
122         $uncomp_in_ allocate;
123 
124         set xcoder_ [new Module/VideoXcoder/JPEGCompressedToUncompressed];
125         $xcoder_ set_frame_buffer $uncomp_in_;
126 
127         set init_done_ 1;
128         set old_theta_ "";
129     }
130 
131     $xcoder_ transcode $in_frame;
132 
133     if {$old_theta_ != $angle} {
134         set w [$in_frame set w_];
135         set h [$in_frame set h_];
136 
137         set cos_angle [expr cos($angle)];
138         set sin_angle [expr sin($angle)];
139 
140         set in_h_sub [expr 1.0*[$in_frame set h_subsample_]]
141         set in_v_sub [expr 1.0*[$in_frame set v_subsample_]]
142         set out_h_sub [expr 1.0*[$out_frame set h_subsample_]]
143         set out_v_sub [expr 1.0*[$out_frame set v_subsample_]]
144 
145         set sf [expr 1.0 - ($angle/10.0)];
146 
147         set la [expr $sf * $cos_angle];
148         set lb [expr -($sf * $sin_angle)];
149         set lc [expr ($w - ($sf * $w * $cos_angle) + ($sf * $h * $sin_angle)) / 2.0];
150         set ld [expr $sf * $sin_angle];
151         set le [expr $sf * $cos_angle];
152         set lf [expr ($h - ($h * $sf * $cos_angle) - ($sf * $w * $sin_angle)) / 2.0];
153 
154         set ca [expr $la * $in_h_sub / $out_h_sub];
155         set cb [expr $lb * $in_v_sub / $out_h_sub];
156         set cc [expr $lc / $out_h_sub];
157         set cd [expr $ld * $in_h_sub / $out_v_sub];
158         set ce [expr $le * $in_v_sub / $out_v_sub];
159         set cf [expr $lf / $out_v_sub];
160 
161         set old_theta_ $angle;
162     }
163 
164     set in_l [$uncomp_in_ get_lum_name];
165     set in_cr [$uncomp_in_ get_cr_name];
166     set in_cb [$uncomp_in_ get_cb_name];
167 
168     set out_l [$out_frame get_lum_name];
169     set out_cr [$out_frame get_cr_name];
170     set out_cb [$out_frame get_cb_name];
171 
172     byte_set $out_l 0
173     byte_set $out_cr 128
174     byte_set $out_cb 128
175 
176     byte_affine $in_l $out_l $la $lb $lc $ld $le $lf;
177     byte_affine $in_cr $out_cr $ca $cb $cc $cd $ce $cf;
178     byte_affine $in_cb $out_cb $ca $cb $cc $cd $ce $cf;
179 
180     $out_frame set ts_ [$in_frame set ts_];
181 
182     set encoder $output_info_(o1,encoder);
183 
184     if {$encoder != ""} {
185         $encoder recv $out_frame;
186     }
187 
188     $self send_completion_token
189 
190     #    [[[[$input_info_(i1,decoder) set agent_] set network_] set net_(0)] set dn_] recv_flush
191 
192 }
193 
194 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.