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

Open Mash Cross Reference
mash/tcl/psvp/effects/edge-detect-sc.tcl

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

  1 # edge-detect-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 
 33 Class EdgeDetectScSubprogram -superclass DaliSubprogram
 34 
 35 EdgeDetectScSubprogram instproc init {args} {
 36     eval $self next $args;
 37 
 38     # Set up inputs
 39 
 40     $self instvar input_id_list_;
 41     $self instvar input_info_;
 42 
 43     lappend input_id_list_ i1
 44 
 45     set input_info_(i1,spec) "";
 46     set input_info_(i1,trigger) 0;
 47     set input_info_(i1,buffertype) Semicompressed;
 48     set input_info_(i1,buffername) [new VidRep/Semicompressed];
 49     set input_info_(i1,decoder) "";
 50 
 51     # Set up outputs
 52 
 53     $self instvar output_id_list_;
 54     $self instvar output_info_;
 55 
 56     lappend output_id_list_ o1;
 57 
 58     set output_info_(o1,spec) "";
 59     set output_info_(o1,buffertype) Semicompressed;
 60     set output_info_(o1,buffername) [new VidRep/Semicompressed];
 61     set output_info_(o1,encoder) "";
 62     set output_info_(o1,format) SC;
 63     set output_info_(o1,vagent) "";
 64     set output_info_(o1,geometry) [list 0.0 0.0 1.0 1.0];
 65     set output_info_(o1,geometry_change) 0;
 66 
 67     # Set up parameters
 68 
 69     $self instvar parameter_id_list_;
 70     $self instvar parameter_info_;
 71 
 72     set parameter_id_list_ "";
 73 }
 74 
 75 EdgeDetectScSubprogram instproc set_output_geometry {id geometry} {
 76     $self instvar output_info_;
 77 
 78     set output_info_($id,geometry) $geometry;
 79     set output_info_($id,geometry_change) 1;
 80 }
 81 
 82 EdgeDetectScSubprogram instproc trigger {} {
 83     $self instvar input_info_;
 84     $self instvar output_info_;
 85     $self instvar init_done_;
 86     $self instvar smooth_;
 87     $self instvar uncomp_input_;
 88     $self instvar uncomp_output_;
 89     $self instvar inframe_lum_clip_;
 90 
 91     set in_frame $input_info_(i1,buffername);
 92     set out_frame $output_info_(o1,buffername);
 93 
 94     if {![info exists init_done_]} {
 95         if {[$in_frame set w_] == 0} {
 96             return;
 97         }
 98 
 99         set init_done_ 1;
100 
101         set x0 [lindex $output_info_(o1,geometry) 0];
102         set y0 [lindex $output_info_(o1,geometry) 1];
103         set x1 [lindex $output_info_(o1,geometry) 2];
104         set y1 [lindex $output_info_(o1,geometry) 3];
105 
106         set xp0 [expr ((int([$in_frame set true_w_] * $x0) + 8) / 16) * 16];
107         set xp1 [expr ((int([$in_frame set true_w_] * $x1) + 8) / 16) * 16];
108         set yp0 [expr ((int([$in_frame set true_h_] * $y0) + 4) / 8) * 8];
109         set yp1 [expr ((int([$in_frame set true_h_] * $y1) + 4) / 8) * 8];
110 
111         set sub_w [expr $xp1 - $xp0];
112         set sub_h [expr $yp1 - $yp0];
113 
114         set in_l [$in_frame get_lum_name];
115 
116         set inframe_lum_clip_ [sc_clip $in_l [expr $xp0/8] [expr $yp0/8] [expr $sub_w/8] [expr $sub_h/8]];
117 
118         $out_frame set true_w_ [$in_frame set true_w_];
119         $out_frame set true_h_ [$in_frame set true_h_];
120         $out_frame set xoff_ $xp0;
121         $out_frame set yoff_ $yp0;
122         $out_frame set w_ $sub_w
123         $out_frame set h_ $sub_h
124         $out_frame set h_subsample_ 2;
125         $out_frame set v_subsample_ 1;
126         $out_frame allocate;
127 
128         set out_cr [$out_frame get_cr_name];
129         set out_cb [$out_frame get_cb_name];
130 
131         set smooth_ [new VidRep/Uncompressed];
132         $smooth_ copy_geometry $out_frame;
133         $smooth_ allocate;
134 
135         set uncomp_input_ [new VidRep/Uncompressed];
136         $uncomp_input_ copy_geometry $out_frame;
137         $uncomp_input_ allocate
138 
139         set uncomp_output_ [new VidRep/Uncompressed];
140         $uncomp_output_ copy_geometry $out_frame;
141         $uncomp_output_ allocate
142     }
143 
144     if {$output_info_(o1,geometry_change) ==  1} {
145         set x0 [lindex $output_info_(o1,geometry) 0];
146         set y0 [lindex $output_info_(o1,geometry) 1];
147         set x1 [lindex $output_info_(o1,geometry) 2];
148         set y1 [lindex $output_info_(o1,geometry) 3];
149 
150         set xp0 [expr ((int([$in_frame set true_w_] * $x0) + 8) / 16) * 16];
151         set xp1 [expr ((int([$in_frame set true_w_] * $x1) + 8) / 16) * 16];
152         set yp0 [expr ((int([$in_frame set true_h_] * $y0) + 4) / 8) * 8];
153         set yp1 [expr ((int([$in_frame set true_h_] * $y1) + 4) / 8) * 8];
154 
155         set sub_w [expr $xp1 - $xp0];
156         set sub_h [expr $yp1 - $yp0];
157 
158         set in_l [$in_frame get_lum_name];
159 
160         sc_free $inframe_lum_clip_;
161         set inframe_lum_clip_ [sc_clip $in_l [expr $xp0/8] [expr $yp0/8] [expr $sub_w/8] [expr $sub_h/8]];
162 
163         $out_frame set true_w_ [$in_frame set true_w_];
164         $out_frame set true_h_ [$in_frame set true_h_];
165         $out_frame set xoff_ $xp0;
166         $out_frame set yoff_ $yp0;
167         $out_frame set w_ $sub_w
168         $out_frame set h_ $sub_h
169         $out_frame set h_subsample_ 2;
170         $out_frame set v_subsample_ 1;
171         $out_frame allocate;
172 
173         set out_cr [$out_frame get_cr_name];
174         set out_cb [$out_frame get_cb_name];
175 
176         $smooth_ copy_geometry $out_frame;
177         $smooth_ allocate;
178 
179         $uncomp_input_ copy_geometry $out_frame;
180         $uncomp_input_ allocate
181 
182         $uncomp_output_ copy_geometry $out_frame;
183         $uncomp_output_ allocate
184     }
185 
186 
187     set uncomp_in_l [$uncomp_input_ get_lum_name];
188     set smooth_l [$smooth_ get_lum_name];
189     set uncomp_out_l [$uncomp_output_ get_lum_name];
190     set out_l [$out_frame get_lum_name];
191 
192     sc_to_byte_with_bias $inframe_lum_clip_ $uncomp_in_l 0;
193     byte_smooth $uncomp_in_l $smooth_l 2;
194     byte_edge_detect_canny $smooth_l $uncomp_out_l 5 10;
195     byte_to_sc $uncomp_out_l $out_l 0;
196 
197     $out_frame set ts_ [$in_frame set ts_];
198 
199     set encoder $output_info_(o1,encoder);
200 
201     if {$encoder != ""} {
202         $encoder recv $out_frame;
203     }
204     $self send_completion_token;
205 }
206 

~ [ 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.