[Sumover-dev] [svn commit] r3895 - in vic/branches/mpeg4: codec
ffmpeg/postproc render
sumover-dev at cs.ucl.ac.uk
sumover-dev at cs.ucl.ac.uk
Fri Oct 13 10:24:47 BST 2006
Author: barz
Date: Fri Oct 13 10:24:08 2006
New Revision: 3895
Modified:
vic/branches/mpeg4/codec/decoder-mpeg4.cpp
vic/branches/mpeg4/codec/encoder-h264.cpp
vic/branches/mpeg4/ffmpeg/postproc/swscale.c
vic/branches/mpeg4/render/renderer-window.cpp
vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl
vic/branches/mpeg4/tcl/ui-windows.tcl
Log:
fix "segment fault while changing resolution"
add arbitrary resizing feature
p.s: fullscreen is stll not working
Modified: vic/branches/mpeg4/codec/decoder-mpeg4.cpp
==============================================================================
--- vic/branches/mpeg4/codec/decoder-mpeg4.cpp (original)
+++ vic/branches/mpeg4/codec/decoder-mpeg4.cpp Fri Oct 13 10:24:08 2006
@@ -182,8 +182,10 @@
}
if (len < 0) {
+
pb->release();
debug_msg("mpeg4dec: frame error\n");
+ std::cout << "mpeg4dec: frame error\n";
stream->clear();
idx = seq + 1;
return;
Modified: vic/branches/mpeg4/codec/encoder-h264.cpp
==============================================================================
--- vic/branches/mpeg4/codec/encoder-h264.cpp (original)
+++ vic/branches/mpeg4/codec/encoder-h264.cpp Fri Oct 13 10:24:08 2006
@@ -108,14 +108,14 @@
}
else if (strcmp(argv[1], "fps") == 0) {
fps = atoi(argv[2]);
- std::cout << "H264: fps " << fps << "\n";
+ //std::cout << "H264: fps " << fps << "\n";
return (TCL_OK);
}
else if (strcmp(argv[1], "kbps") == 0) {
kbps = atoi(argv[2]);
if (kbps < 64)
kbps = 64;
- std::cout << "H264: kbps " << kbps << "\n";
+ //std::cout << "H264: kbps " << kbps << "\n";
return (TCL_OK);
}
else if (strcmp(argv[1], "hq") == 0) {
Modified: vic/branches/mpeg4/ffmpeg/postproc/swscale.c
==============================================================================
--- vic/branches/mpeg4/ffmpeg/postproc/swscale.c (original)
+++ vic/branches/mpeg4/ffmpeg/postproc/swscale.c Fri Oct 13 10:24:08 2006
@@ -1389,47 +1389,47 @@
#if defined(ARCH_X86) || defined(ARCH_X86_64)
// ordered per speed fasterst first
if(flags & SWS_CPU_CAPS_MMX2){
- printf("SWSCALE: MMX2\n");
+// printf("SWSCALE: MMX2\n");
return swScale_MMX2;
}else if(flags & SWS_CPU_CAPS_MMX){
- printf("SWSCALE: 3DNow\n");
+// printf("SWSCALE: 3DNow\n");
return swScale_3DNow;
}else if(flags & SWS_CPU_CAPS_3DNOW){
- printf("SWSCALE: MMX\n");
+// printf("SWSCALE: MMX\n");
return swScale_MMX;
}else{
- printf("SWSCALE: C\n");
+// printf("SWSCALE: C\n");
return swScale_C;
}
#else
#ifdef ARCH_POWERPC
if(flags & SWS_CPU_CAPS_ALTIVEC){
- printf("SWSCALE: Altivec\n");
+// printf("SWSCALE: Altivec\n");
return swScale_altivec;
}else{
- printf("SWSCALE: C\n");
+// printf("SWSCALE: C\n");
return swScale_C;
}
#endif
- printf("SWSCALE: C\n");
+// printf("SWSCALE: C\n");
return swScale_C;
#endif
#else //RUNTIME_CPUDETECT
#ifdef HAVE_MMX2
- printf("SWSCALE: MMX2\n");
+// printf("SWSCALE: MMX2\n");
return swScale_MMX2;
#elif defined (HAVE_3DNOW)
- printf("SWSCALE: 3DNow\n");
+// printf("SWSCALE: 3DNow\n");
return swScale_3DNow;
#elif defined (HAVE_MMX)
- printf("SWSCALE: MMX\n");
+// printf("SWSCALE: MMX\n");
return swScale_MMX;
#elif defined (HAVE_ALTIVEC)
- printf("SWSCALE: Altivec\n");
+// printf("SWSCALE: Altivec\n");
return swScale_altivec;
#else
- printf("SWSCALE: C\n");
+// printf("SWSCALE: C\n");
return swScale_C;
#endif
#endif //!RUNTIME_CPUDETECT
Modified: vic/branches/mpeg4/render/renderer-window.cpp
==============================================================================
--- vic/branches/mpeg4/render/renderer-window.cpp (original)
+++ vic/branches/mpeg4/render/renderer-window.cpp Fri Oct 13 10:24:08 2006
@@ -83,9 +83,9 @@
* On a mismatch, the image will be centered in the window.
*/
scale_ = 0;
-// outw_ = (ww_ >> 2) << 2;
-// outh_ = (wh_ >> 2) << 2;
-
+ outw_ = (ww_ >> 2) << 2;
+ outh_ = (wh_ >> 2) << 2;
+/*
int d = distance(ww_, width_);
int t = distance(ww_, width_ << 1);
if (t < d) {
@@ -111,7 +111,7 @@
outw_ = width_ >> scale_;
outh_ = height_ >> scale_;
}
-
+*/
}
void WindowRenderer::sync() const
Modified: vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl
==============================================================================
--- vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl (original)
+++ vic/branches/mpeg4/tcl/ui-ctrlmenu.tcl Fri Oct 13 10:24:08 2006
@@ -284,7 +284,7 @@
set logoButtonState 0
proc transmit { } {
- global logoButton logoButtonState transmitButtonState videoFormat videoDevice V useJPEGforH261 useHardwareComp numEncoderLayers fps_slider kbps_slider
+ global logoButton logoButtonState transmitButtonState videoFormat videoDevice V useJPEGforH261 useHardwareComp numEncoderLayers
if ![have grabber] {
set DA [$videoDevice attributes]
set DF [attribute_class $DA format]
@@ -380,18 +380,8 @@
}
update idletasks
}
- if {$videoFormat == "mpeg4"} {
- encoder fps [$fps_slider get]
- encoder kbps [$kbps_slider get]
- if [yesno enable_hq] {
- encoder hq 1
- }
- }
- if {$videoFormat == "h264"} {
- encoder fps [$fps_slider get]
- encoder kbps [$kbps_slider get]
- }
+ update_encoder_param
$V(grabber) send $transmitButtonState
}
@@ -462,20 +452,37 @@
proc doNothing { args } {
}
+proc update_encoder_param { } {
+ global videoFormat fps_slider bps_slider
+ if {$videoFormat == "mpeg4" || $videoFormat == "h264"} {
+ encoder kbps [$bps_slider get]
+ encoder fps [$fps_slider get]
+ }
+}
+
proc set_bps { w value } {
+ global videoFormat
+
if [have grabber] {
- grabber bps $value
- encoder bps $value
+ grabber bps $value
+ if {$videoFormat == "mpeg4" || $videoFormat == "h264"} {
+ encoder kbps $value
+ }
+
#XXX
- session data-bandwidth $value
+ session data-bandwidth $value
}
- $w configure -text "$value kbps"
+ $w configure -text "$value bps"
}
proc set_fps { w value } {
+ global videoFormat
+
if [have grabber] {
grabber fps $value
- encoder fps $value
+ if {$videoFormat == "mpeg4" || $videoFormat == "h264"} {
+ encoder fps $value
+ }
}
$w configure -text "$value fps"
}
@@ -524,9 +531,9 @@
$w.bps.scale set [option get . bandwidth Vic]
$w.fps.scale set [option get . framerate Vic]
- global fps_slider kbps_slider
+ global fps_slider bps_slider
set fps_slider $w.fps.scale
- set kbps_slider $w.bps.scale
+ set bps_slider $w.bps.scale
}
proc attribute_class { attr class } {
@@ -685,7 +692,7 @@
}
insert_grabber_panel [$device nickname]
- set videoFormat $defaultFormat($device)
+ #set videoFormat $defaultFormat($device)
select_format $videoFormat
if $wasOverlaying {
$logoButton invoke
@@ -714,7 +721,8 @@
} elseif { $videoFormat == "h264"} {
set videoFormat h264
}
- #
+
+
# Disabled the device button if we have no devices or
# if we don't have transmit persmission.
#
@@ -858,13 +866,13 @@
set b $w.b
frame $b
- radiobutton $b.b0 -text "small" -command "grabber decimate 4" \
+ radiobutton $b.b0 -text "small" -command "restart" \
-padx 0 -pady 0 \
-anchor w -variable inputSize -font $f -relief flat -value 4
- radiobutton $b.b1 -text "normal" -command "grabber decimate 2" \
+ radiobutton $b.b1 -text "normal" -command "restart" \
-padx 0 -pady 0 \
-anchor w -variable inputSize -font $f -relief flat -value 2
- radiobutton $b.b2 -text "large" -command "grabber decimate 1" \
+ radiobutton $b.b2 -text "large" -command "restart" \
-padx 0 -pady 0 \
-anchor w -variable inputSize -font $f -relief flat -value 1
pack $b.b0 $b.b1 $b.b2 -fill x
@@ -1378,7 +1386,7 @@
set lastFmt ""
proc select_format fmt {
- global qscale qlabel videoDevice videoFormat qscale_val lastFmt fps_slider kbps_slider
+ global qscale qlabel videoDevice videoFormat qscale_val lastFmt
if { $fmt == "h261" || $fmt == "pvh"} {
# H.261 supports only QCIF/CIF
@@ -1441,18 +1449,7 @@
delete $V(encoder)
set V(encoder) $encoder
- if {$videoFormat == "mpeg4"} {
- encoder fps [$fps_slider get]
- encoder kbps [$kbps_slider get]
- if [yesno enable_hq] {
- encoder hq 1
- }
- }
-
- if {$videoFormat == "h264"} {
- encoder fps [$fps_slider get]
- encoder kbps [$kbps_slider get]
- }
+ update_encoder_param
$encoder transmitter $V(session)
@@ -1506,9 +1503,9 @@
}
$grabber transmitter $V(session)
- global qscale inputSize fps_slider kbps_slider videoDevice
+ global qscale inputSize fps_slider bps_slider videoDevice
$grabber fps [$fps_slider get]
- $grabber bps [$kbps_slider get]
+ $grabber bps [$bps_slider get]
$grabber decimate $inputSize
if { [lindex [$qscale configure -state] 4] == "normal" } {
set cmd [lindex [$qscale configure -command] 4]
Modified: vic/branches/mpeg4/tcl/ui-windows.tcl
==============================================================================
--- vic/branches/mpeg4/tcl/ui-windows.tcl (original)
+++ vic/branches/mpeg4/tcl/ui-windows.tcl Fri Oct 13 10:24:08 2006
@@ -63,6 +63,7 @@
# resize a video window
#
proc resize { vw w h } {
+
$vw resize $w $h
global win_src
set src $win_src($vw)
@@ -185,11 +186,11 @@
toplevel $w -class Vic \
-visual "[winfo visual .top] [winfo depth .top]" \
-colormap .top
- catch "wm resizable $w false false"
+ #catch "wm resizable $w false false"
#
# make windows become x-y resizeable
#
- #catch "wm resizable $w true false"
+ catch "wm resizable $w true false"
frame $w.frame
@@ -328,10 +329,10 @@
bind $w <less> "switcher_prev $v"
bind $w <comma> "switcher_prev $v"
# double clicking to toggle fullscreen mode
- #bind $w <Double-1> {
- # destroy_userwin %W
- # open_full_window $src
- #}
+ bind $w <Double-1> {
+ #destroy_userwin %W
+ #open_full_window $src
+ }
# Resize
bind $w <Configure> {
@@ -349,13 +350,12 @@
set aspect_r [expr 1.0*$ih / $iw]
- set ow [expr %w + 2*%x]
+ set ow [expr int(%w + 2*%x)]
set oh [expr int($aspect_r * $ow)]
-
if { $iw != $ow || $ih != $oh} {
- # resize_window %W $ow $oh
- # resize %W $ow $oh
+ #resize_window %W $ow $oh
+ resize %W $ow $oh
}
}
}
@@ -368,255 +368,63 @@
windowname $w [getid $src]
}
-
-#
-# create a new window for viewing video
-#
-
proc open_full_window src {
- set f [minifont]
+
set uid [uniqueID]
set d [$src handler]
set iw [$d width]
set ih [$d height]
-
if { $iw == 0 || $ih == 0} {
puts "window width or height is zero"
return
}
-
set w .vw$uid
toplevel $w -class Vic \
-visual "[winfo visual .top] [winfo depth .top]" \
-colormap .top
- catch "wm resizable $w true false"
+ catch "wm resizable $w false false"
+
# for bordless window
set sw [winfo screenwidth .]
set sh [winfo screenheight .]
wm overrideredirect $w true
- #wm aspect . 4 3 4 3
-
- frame $w.frame
- #debug_show "open_window $src"
+ frame $w.frame
global size$w userwin_x userwin_y userwin_size
-
-
create_video_widget $w.frame.video $sw $sh
- set size$w [format "%sx%s" $sw $sh]
-
+ set size$w [format "%sx%s" $sw $sh]
set v $w.frame.video
- #frame $w.bar -height 1
- frame $w.bar
- button $w.bar.dismiss -text Dismiss -font $f -width 8 \
- -highlightthickness 0
-
- set m $w.bar.mode.menu
- menubutton $w.bar.mode -text Modes... -menu $m -relief raised \
- -width 8 -font $f
- menu $m
-
- $m add checkbutton -label Voice-switched \
- -command "window_set_switched $v" \
- -font $f -variable win_is_switched($v)
- $m add checkbutton -label Timer-switched \
- -command "window_set_timed $v" \
- -font $f -variable win_is_timed($v)
- $m add checkbutton -label Save-CPU \
- -command "window_set_slow $v" \
- -font $f -variable win_is_slow($v)
-
- if ![have cb] {
- $m entryconfigure Voice-switched -state disabled
- }
-
- set m $w.bar.size.menu
- #menubutton $w.bar.size -text Size... -menu $m -relief raised -width 8 \
- # -font $f -height 0
- menubutton $w.bar.size -text Size... -menu $m -relief raised -width 8 \
- -font $f
-
- menu $m
- $m add radiobutton -label QCIF -command "resize $v 176 144" \
- -font $f -value 176x144 -variable size$w
- $m add radiobutton -label CIF -command "resize $v 352 288" \
- -font $f -value 352x288 -variable size$w
- $m add radiobutton -label SCIF -command "resize $v 704 576" \
- -font $f -value 704x576 -variable size$w
-
- $m add separator
- $m add radiobutton -label "1/16 NTSC" \
- -command "resize $v 160 120" \
- -font $f -value 160x120 -variable size$w
- $m add radiobutton -label "1/4 NTSC" \
- -command "resize $v 320 240" \
- -font $f -value 320x240 -variable size$w
- $m add radiobutton -label NTSC \
- -command "resize $v 640 480" \
- -font $f -value 640x480 -variable size$w
-
- $m add separator
- $m add radiobutton -label "1/16 PAL" \
- -command "resize $v 192 144" \
- -font $f -value 192x144 -variable size$w
- $m add radiobutton -label "1/4 PAL" \
- -command "resize $v 384 288" \
- -font $f -value 384x288 -variable size$w
- $m add radiobutton -label PAL \
- -command "resize $v 768 576" \
- -font $f -value 768x576 -variable size$w
-
-
-# Marcus ...
- set m $w.bar.decoder.menu
- menubutton $w.bar.decoder -text Decoder... -menu $m -relief raised -width 8 -font $f
- menu $m
- $m add radiobutton -label Use-Magic \
- -command "reallocate_renderer $v" \
- -font $f -variable win_use_hw($v) -value magic
-
- global assistorlist
-
- if ![info exists assistorlist] {
- set assistorlist [new assistorlist xx]
- }
- set d [$src handler]
- set fmt [rtp_format $src]
- if { $fmt == "jpeg" } {
- set fmt $fmt/[$d decimation]
- }
- set targets [$assistorlist assistors $fmt]
- foreach xname $targets {
- if { $xname != "" } {
- $m add radiobutton -label "Use-$xname-Assistor" \
- -command "reallocate_renderer $v" \
- -font $f -variable win_use_hw($v) -value $xname
- }
- }
-
- $m add radiobutton -label "Use-VIC Software" \
- -command "reallocate_renderer $v" \
- -font $f -variable win_use_hw($v) -value software
-
-# ... Marcus
-
- label $w.bar.label -text "" -anchor w -relief raised
- # pack $w.bar.label -expand 1 -side left -fill both
- # comment next line to remove buttons
- # pack $w.bar.decoder $w.bar.size $w.bar.mode $w.bar.dismiss -side left -fill y
-
pack $w.frame.video -anchor c
pack $w.frame -expand 1 -fill both
- # comment next line to remove buttons
- # pack $w.bar -fill x
bind $w <Enter> { focus %W }
- #wm focusmodel $w active
bind $w <d> "destroy_userwin $v"
bind $w <q> "destroy_userwin $v"
-# bind $w <Destroy> "destroy_from_wm $v"
- wm protocol $w WM_DELETE_WINDOW "destroy_userwin $v"
$w.bar.dismiss configure -command "destroy_userwin $v"
+ # added to catch window close action
+ wm protocol $w WM_DELETE_WINDOW "destroy_userwin $v"
+
bind $w <Return> "switcher_next $v"
bind $w <space> "switcher_next $v"
bind $w <greater> "switcher_next $v"
bind $w <less> "switcher_prev $v"
bind $w <comma> "switcher_prev $v"
-
- #bind $w <g> "set_window_glue $v 1"
- #bind $w <G> "set_window_glue $v 0"
- bind $w <h> "set_hardware_render $v 1"
- bind $w <H> "set_hardware_render $v 0"
- bind $w <H> "set_hardware_render $v 0"
- bind $w <Double-1> {
+ # double clicking to toggle fullscreen mode
+ bind $w <Double-1> {
destroy_userwin %W true
- open_window $src
+ open_window $src
}
-
switcher_register $v $src window_switch
- global window_glue
- set window_glue($v) 0
- global button_active vtk_client
-
- bind $v <Button-3> {
- tk_popup $m %x %y
- }
-
-# puts "w is $v"
-
- bind $v <Control-KeyPress> {
-# puts "got ctl keypress %K %x %y"
- if { [string length %K] == 1 } {
- binary scan %K c keyval
- send_to_vtk K 0 $keyval %x %y %W
- break
- }
- }
- bind $v <Button> {
- global notifier_id ag_last_x ag_last_y
-
- send_to_vtk D 0 %b %x %y %W
-
- set button_active %b
- set modifier 0
-
- set ag_last_x %x
- set ag_last_y %y
-
- set notifier_id [after 100 ag_update_motion]
- }
- bind $v <Control-Button> {
- global notifier_id
- send_to_vtk D 0 [expr %b | 8] %x %y %W
-
- set button_active %b
- set notifier_id [after 100 ag_update_motion]
- }
- bind $v <Shift-Button> {
- global notifier_id
- send_to_vtk D 0 [expr %b | 16] %x %y %W
-
- set button_active %b
- set notifier_id [after 100 ag_update_motion]
- }
- bind $v <Shift-Control-Button> {
- global notifier_id
- send_to_vtk D 0 [expr %b | 8 | 16] %x %y %W
-
- set button_active %b
- set notifier_id [after 100 ag_update_motion]
- }
-
- bind $v <ButtonRelease> {
- if $button_active {
- global notifier_id
- set button_active 0
- after cancel $notifier_id
- send_to_vtk U 0 %b %x %y %W
- }
- }
- bind $v <Motion> {
- if $button_active {
- global ag_motion_x ag_motion_y ag_motion_W
-# send_to_vtk M 0 $button_active %x %y %W
- set ag_motion_x %x
- set ag_motion_y %y
- set ag_motion_W %W
- }
- }
-
#
# Finally, bind the source to the window.
- #
- # the last parameter indicates whether using Xvideo or not
- attach_window $src $v true
+ #
+ attach_window $src $v
windowname $w [getid $src]
-
}
proc windowname { w name } {
More information about the Sumover-dev
mailing list