From: Good Guy Date: Wed, 13 Feb 2019 04:38:44 +0000 (-0700) Subject: identity sh-f11=cam/sh-f12=proj keyframes, odd jpeg fix, zoom submenu, shudmp X-Git-Tag: 2019-08~107 X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=47f71d004db08fb289428240fb87ce97c64382d2;p=goodguy%2Fcinelerra.git identity sh-f11=cam/sh-f12=proj keyframes, odd jpeg fix, zoom submenu, shudmp --- diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile index 09ce46e9..c1f97f1e 100644 --- a/cinelerra-5.1/cinelerra/Makefile +++ b/cinelerra-5.1/cinelerra/Makefile @@ -555,6 +555,8 @@ ydiff: ydiff.C $(LIBRARIES) shdmp: shdmp.C @g++ $(CFLAGS) shdmp.C -o $@ +shudmp: shudmp.C + @g++ $(CFLAGS) shudmp.C -o $@ -lusb-1.0 clean: rm -rf $(OBJDIR) diff --git a/cinelerra-5.1/cinelerra/autos.C b/cinelerra-5.1/cinelerra/autos.C index 490094cd..cb5a1bd2 100644 --- a/cinelerra-5.1/cinelerra/autos.C +++ b/cinelerra-5.1/cinelerra/autos.C @@ -280,7 +280,7 @@ Auto* Autos::get_auto_at_position(double position) } -Auto* Autos::get_auto_for_editing(double position) +Auto* Autos::get_auto_for_editing(double position, int create) { if(position < 0) { position = edl->local_session->get_selectionstart(1); @@ -288,7 +288,8 @@ Auto* Autos::get_auto_for_editing(double position) Auto *result = 0; get_prev_auto(track->to_units(position, 0), PLAY_FORWARD, result); - if( edl->session->auto_keyframes && (!result || result->is_default || + if( create > 0 ) create = edl->session->auto_keyframes; + if( create && (!result || result->is_default || !EQUIV(track->from_units(result->position), position)) ) { //printf("Autos::get_auto_for_editing %p %p %p\n", default_auto, first, result); position = edl->align_to_frame(position, 0); diff --git a/cinelerra-5.1/cinelerra/autos.h b/cinelerra-5.1/cinelerra/autos.h index 5ce985af..2e841bfd 100644 --- a/cinelerra-5.1/cinelerra/autos.h +++ b/cinelerra-5.1/cinelerra/autos.h @@ -62,8 +62,9 @@ public: // Returns auto at exact position, null if non-existent. ignores autokeyframming and align on frames Auto* get_auto_at_position(double position = -1); -// Get keyframe for editing with automatic creation if enabled - Auto* get_auto_for_editing(double position = -1); +// Get keyframe for editing with creation +// create: <0: always new keyframe, =0: no new keyframe, >0: auto keyframe + Auto* get_auto_for_editing(double position=-1, int create=1); // Insert keyframe at the point if it doesn't exist // Interpolate its value if possible diff --git a/cinelerra-5.1/cinelerra/canvas.C b/cinelerra-5.1/cinelerra/canvas.C index 0997e064..6b3f6508 100644 --- a/cinelerra-5.1/cinelerra/canvas.C +++ b/cinelerra-5.1/cinelerra/canvas.C @@ -1050,19 +1050,36 @@ CanvasPopup::~CanvasPopup() { } +CanvasZoomSize::CanvasZoomSize(Canvas *canvas) + : BC_MenuItem(_("Zoom...")) +{ + this->canvas = canvas; +} + +CanvasSizeSubMenu::CanvasSizeSubMenu(CanvasZoomSize *zoom_size) +{ + this->zoom_size = zoom_size; +} + void CanvasPopup::create_objects() { add_item(new BC_MenuItem("-")); add_item(new CanvasFullScreenItem(canvas)); - add_item(new CanvasPopupSize(canvas, _("Zoom 25%"), 0.25)); - add_item(new CanvasPopupSize(canvas, _("Zoom 33%"), 0.33)); - add_item(new CanvasPopupSize(canvas, _("Zoom 50%"), 0.5)); - add_item(new CanvasPopupSize(canvas, _("Zoom 75%"), 0.75)); - add_item(new CanvasPopupSize(canvas, _("Zoom 100%"), 1.0)); - add_item(new CanvasPopupSize(canvas, _("Zoom 150%"), 1.5)); - add_item(new CanvasPopupSize(canvas, _("Zoom 200%"), 2.0)); - add_item(new CanvasPopupSize(canvas, _("Zoom 300%"), 3.0)); - add_item(new CanvasPopupSize(canvas, _("Zoom 400%"), 4.0)); + + CanvasZoomSize *zoom_size = new CanvasZoomSize(canvas); + add_item(zoom_size); + CanvasSizeSubMenu *submenu = new CanvasSizeSubMenu(zoom_size); + zoom_size->add_submenu(submenu); + + submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 25%"), 0.25)); + submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 33%"), 0.33)); + submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 50%"), 0.5)); + submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 75%"), 0.75)); + submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 100%"), 1.0)); + submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 150%"), 1.5)); + submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 200%"), 2.0)); + submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 300%"), 3.0)); + submenu->add_submenuitem(new CanvasPopupSize(canvas, _("Zoom 400%"), 4.0)); } void CanvasPopup::use_cwindow() @@ -1070,6 +1087,8 @@ void CanvasPopup::use_cwindow() add_item(new CanvasPopupAuto(canvas)); add_item(new CanvasPopupResetCamera(canvas)); add_item(new CanvasPopupResetProjector(canvas)); + add_item(new CanvasPopupCameraKeyframe(canvas)); + add_item(new CanvasPopupProjectorKeyframe(canvas)); add_item(toggle_controls = new CanvasToggleControls(canvas)); } @@ -1115,7 +1134,7 @@ int CanvasPopupSize::handle_event() CanvasPopupResetCamera::CanvasPopupResetCamera(Canvas *canvas) - : BC_MenuItem(_("Reset camera"), "F11", KEY_F11) + : BC_MenuItem(_("Reset camera"), _("F11"), KEY_F11) { this->canvas = canvas; } @@ -1125,10 +1144,8 @@ int CanvasPopupResetCamera::handle_event() return 1; } - - CanvasPopupResetProjector::CanvasPopupResetProjector(Canvas *canvas) - : BC_MenuItem(_("Reset projector"), "F12", KEY_F12) + : BC_MenuItem(_("Reset projector"), _("F12"), KEY_F12) { this->canvas = canvas; } @@ -1139,6 +1156,31 @@ int CanvasPopupResetProjector::handle_event() } +CanvasPopupCameraKeyframe::CanvasPopupCameraKeyframe(Canvas *canvas) + : BC_MenuItem(_("Camera keyframe"), _("Shift-F11"), KEY_F11) +{ + this->canvas = canvas; + set_shift(1); +} +int CanvasPopupCameraKeyframe::handle_event() +{ + canvas->camera_keyframe(); + return 1; +} + +CanvasPopupProjectorKeyframe::CanvasPopupProjectorKeyframe(Canvas *canvas) + : BC_MenuItem(_("Projector keyframe"), _("Shift-F12"), KEY_F12) +{ + this->canvas = canvas; + set_shift(1); +} +int CanvasPopupProjectorKeyframe::handle_event() +{ + canvas->projector_keyframe(); + return 1; +} + + CanvasPopupResetTranslation::CanvasPopupResetTranslation(Canvas *canvas) : BC_MenuItem(_("Reset translation")) diff --git a/cinelerra-5.1/cinelerra/canvas.h b/cinelerra-5.1/cinelerra/canvas.h index 19842695..1a654260 100644 --- a/cinelerra-5.1/cinelerra/canvas.h +++ b/cinelerra-5.1/cinelerra/canvas.h @@ -22,44 +22,28 @@ #ifndef CANVAS_H #define CANVAS_H +#include "canvas.inc" #include "edl.inc" #include "guicast.h" #include "mwindow.inc" #include "videodevice.inc" - // Output for all X11 video -class CanvasOutput; -class CanvasFullScreen; -class CanvasXScroll; -class CanvasYScroll; -class CanvasPopup; -class CanvasFullScreenPopup; -class CanvasToggleControls; - // The EDL arguments can be set to 0 if the canvas_w and canvas_h are used class Canvas { public: - Canvas(MWindow *mwindow, - BC_WindowBase *subwindow, - int x, - int y, - int w, - int h, - int output_w, - int output_h, + Canvas(MWindow *mwindow, BC_WindowBase *subwindow, + int x, int y, int w, int h, + int output_w, int output_h, int use_scrollbars); virtual ~Canvas(); void reset(); // Get dimensions given a zoom void calculate_sizes(float aspect_ratio, - int output_w, - int output_h, - float zoom, - int &w, - int &h); + int output_w, int output_h, float zoom, + int &w, int &h); // Lock access to the canvas pointer. // Must be called before get_canvas or locking the canvas. void lock_canvas(const char *location); @@ -88,21 +72,23 @@ public: virtual void status_event() {}; - virtual void reset_camera() {}; - virtual void reset_projector() {}; - virtual void zoom_resize_window(float percentage) {}; - virtual void zoom_auto() {}; - virtual int cursor_leave_event() { return 0; }; - virtual int cursor_enter_event() { return 0; }; - virtual int button_release_event() { return 0; }; + virtual void reset_camera() {} + virtual void reset_projector() {} + virtual void camera_keyframe() {} + virtual void projector_keyframe() {} + virtual void zoom_resize_window(float percentage) {} + virtual void zoom_auto() {} + virtual int cursor_leave_event() { return 0; } + virtual int cursor_enter_event() { return 0; } + virtual int button_release_event() { return 0; } virtual int button_press_event(); - virtual int cursor_motion_event() { return 0; }; + virtual int cursor_motion_event() { return 0; } virtual int need_overlays() { return 1; } - virtual void draw_overlays() { }; - virtual void toggle_controls() { } ; - virtual int get_cwindow_controls() { return 0; }; + virtual void draw_overlays() {} + virtual void toggle_controls() {} + virtual int get_cwindow_controls() { return 0; } virtual int get_fullscreen() { return 0; } - virtual void set_fullscreen(int value) { }; + virtual void set_fullscreen(int value) {} int cursor_leave_event_base(BC_WindowBase *caller); int cursor_enter_event_base(BC_WindowBase *caller); @@ -335,6 +321,22 @@ public: CanvasToggleControls *toggle_controls; }; +class CanvasZoomSize : public BC_MenuItem +{ +public: + CanvasZoomSize(Canvas *canvas); + + Canvas *canvas; +}; + +class CanvasSizeSubMenu : public BC_SubMenu +{ +public: + CanvasSizeSubMenu(CanvasZoomSize *zoom_size); + + CanvasZoomSize *zoom_size; +}; + class CanvasPopupSize : public BC_MenuItem { public: @@ -369,6 +371,22 @@ public: Canvas *canvas; }; +class CanvasPopupCameraKeyframe : public BC_MenuItem +{ +public: + CanvasPopupCameraKeyframe(Canvas *canvas); + int handle_event(); + Canvas *canvas; +}; + +class CanvasPopupProjectorKeyframe : public BC_MenuItem +{ +public: + CanvasPopupProjectorKeyframe(Canvas *canvas); + int handle_event(); + Canvas *canvas; +}; + class CanvasToggleControls : public BC_MenuItem { public: diff --git a/cinelerra-5.1/cinelerra/canvas.inc b/cinelerra-5.1/cinelerra/canvas.inc index 4a275d3d..899c8e0a 100644 --- a/cinelerra-5.1/cinelerra/canvas.inc +++ b/cinelerra-5.1/cinelerra/canvas.inc @@ -23,5 +23,24 @@ #define CANVAS_INC class Canvas; +class CanvasOutput; +class CanvasFullScreen; +class CanvasXScroll; +class CanvasYScroll; +class CanvasFullScreenPopup; +class CanvasSubWindowItem; +class CanvasPopup; +class CanvasZoomSize; +class CanvasSizeSubMenu; +class CanvasPopupSize; +class CanvasPopupAuto; +class CanvasPopupResetCamera; +class CanvasPopupResetProjector; +class CanvasPopupCameraKeyframe; +class CanvasPopupProjectorKeyframe; +class CanvasToggleControls; +class CanvasFullScreenItem; +class CanvasPopupResetTranslation; +class CanvasPopupRemoveSource; #endif diff --git a/cinelerra-5.1/cinelerra/cwindow.C b/cinelerra-5.1/cinelerra/cwindow.C index 1611f753..7667690f 100644 --- a/cinelerra-5.1/cinelerra/cwindow.C +++ b/cinelerra-5.1/cinelerra/cwindow.C @@ -145,24 +145,19 @@ Track* CWindow::calculate_affected_track() } Auto* CWindow::calculate_affected_auto(Autos *autos, - int create, - int *created, - int redraw) + int create, int *created, int redraw) { Auto* affected_auto = 0; - if(created) *created = 0; + if( created ) *created = 0; - if(create) - { + if( create ) { int total = autos->total(); - affected_auto = autos->get_auto_for_editing(); + affected_auto = autos->get_auto_for_editing(-1, create); // Got created - if(total != autos->total()) - { - if(created) *created = 1; - if(redraw) - { + if( total != autos->total() ) { + if( created ) *created = 1; + if( redraw ) { // May have to unlock CWindowGUI here. mwindow->gui->lock_window("CWindow::calculate_affected_auto"); mwindow->gui->draw_overlays(1); @@ -170,8 +165,7 @@ Auto* CWindow::calculate_affected_auto(Autos *autos, } } } - else - { + else { affected_auto = autos->get_prev_auto(PLAY_FORWARD, affected_auto); } @@ -180,39 +174,28 @@ Auto* CWindow::calculate_affected_auto(Autos *autos, -void CWindow::calculate_affected_autos(FloatAuto **x_auto, - FloatAuto **y_auto, - FloatAuto **z_auto, - Track *track, - int use_camera, - int create_x, - int create_y, - int create_z) +void CWindow::calculate_affected_autos(Track *track, + FloatAuto **x_auto, FloatAuto **y_auto, FloatAuto **z_auto, + int use_camera, int create_x, int create_y, int create_z, + int redraw) { - if(x_auto) (*x_auto) = 0; - if(y_auto) (*y_auto) = 0; - if(z_auto) (*z_auto) = 0; - - if(!track) return; - - if(use_camera) - { - if(x_auto) (*x_auto) = (FloatAuto*)calculate_affected_auto( - track->automation->autos[AUTOMATION_CAMERA_X], create_x); - if(y_auto) (*y_auto) = (FloatAuto*)calculate_affected_auto( - track->automation->autos[AUTOMATION_CAMERA_Y], create_y); - if(z_auto) (*z_auto) = (FloatAuto*)calculate_affected_auto( - track->automation->autos[AUTOMATION_CAMERA_Z], create_z); - } - else - { - if(x_auto) (*x_auto) = (FloatAuto*)calculate_affected_auto( - track->automation->autos[AUTOMATION_PROJECTOR_X], create_x); - if(y_auto) (*y_auto) = (FloatAuto*)calculate_affected_auto( - track->automation->autos[AUTOMATION_PROJECTOR_Y], create_y); - if(z_auto) (*z_auto) = (FloatAuto*)calculate_affected_auto( - track->automation->autos[AUTOMATION_PROJECTOR_Z], create_z); - } + if( x_auto ) *x_auto = 0; + if( y_auto ) *y_auto = 0; + if( z_auto ) *z_auto = 0; + if( !track ) return; + + int ix = use_camera ? AUTOMATION_CAMERA_X : AUTOMATION_PROJECTOR_X, x_created = 0; + int iy = use_camera ? AUTOMATION_CAMERA_Y : AUTOMATION_PROJECTOR_Y, y_created = 0; + int iz = use_camera ? AUTOMATION_CAMERA_Z : AUTOMATION_PROJECTOR_Z, z_created = 0; + + if( x_auto ) + *x_auto = (FloatAuto*) calculate_affected_auto(track->automation->autos[ix], + create_x, &x_created, redraw); + if( y_auto ) + *y_auto = (FloatAuto*) calculate_affected_auto(track->automation->autos[iy], + create_y, &y_created, redraw); + if( z_auto ) *z_auto = (FloatAuto*) calculate_affected_auto(track->automation->autos[iz], + create_z, &z_created, redraw); } void CWindow::stop_playback(int wait) diff --git a/cinelerra-5.1/cinelerra/cwindow.h b/cinelerra-5.1/cinelerra/cwindow.h index 28bfa978..e6a9b944 100644 --- a/cinelerra-5.1/cinelerra/cwindow.h +++ b/cinelerra-5.1/cinelerra/cwindow.h @@ -59,14 +59,10 @@ public: int *created = 0, int redraw = 1); // Same as before. Provide 0 to Auto arguments to have them ignored. - void calculate_affected_autos(FloatAuto **x_auto, - FloatAuto **y_auto, - FloatAuto **z_auto, - Track *track, - int use_camera, - int create_x, - int create_y, - int create_z); + void calculate_affected_autos( Track *track, + FloatAuto **x_auto, FloatAuto **y_auto, FloatAuto **z_auto, + int use_camera, int create_x, int create_y, int create_z, + int redraw=1); void show_window(); void hide_window(); int update_position(double position); diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index 610d4e7c..2150e061 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -609,8 +609,24 @@ int CWindowGUI::keypress_event() case KEY_F8: cwindow_operation = CWINDOW_EYEDROP; break; case KEY_F9: cwindow_operation = CWINDOW_TOOL_WINDOW; break; case KEY_F10: cwindow_operation = CWINDOW_TITLESAFE; break; - case KEY_F11: canvas->reset_camera(); result = 1; break; - case KEY_F12: canvas->reset_projector(); result = 1; break; + } + } + if( !result && cwindow_operation < 0 && !ctrl_down() ) { + switch( get_keypress() ) { + case KEY_F11: + if( !shift_down() ) + canvas->reset_camera(); + else + canvas->camera_keyframe(); + result = 1; + break; + case KEY_F12: + if( !shift_down() ) + canvas->reset_projector(); + else + canvas->projector_keyframe(); + result = 1; + break; } } @@ -2499,25 +2515,52 @@ void CWindowCanvas::draw_safe_regions() get_canvas()->set_opaque(); } -void CWindowCanvas::reset_keyframe(int do_camera) -{ - FloatAuto *x_keyframe = 0; - FloatAuto *y_keyframe = 0; - FloatAuto *z_keyframe = 0; - Track *affected_track = 0; - affected_track = gui->cwindow->calculate_affected_track(); +void CWindowCanvas::create_keyframe(int do_camera) +{ + Track *affected_track = gui->cwindow->calculate_affected_track(); + if( affected_track ) { + double pos = mwindow->edl->local_session->get_selectionstart(1); + int64_t position = affected_track->to_units(pos, 0); + int ix = do_camera ? AUTOMATION_CAMERA_X : AUTOMATION_PROJECTOR_X; + int iy = do_camera ? AUTOMATION_CAMERA_Y : AUTOMATION_PROJECTOR_Y; + int iz = do_camera ? AUTOMATION_CAMERA_Z : AUTOMATION_PROJECTOR_Z; + FloatAuto *prev, *next; + FloatAutos **autos = (FloatAutos**)affected_track->automation->autos; + FloatAutos *x_autos = autos[ix]; prev = 0; next = 0; + float x_value = x_autos->get_value(position, PLAY_FORWARD, prev, next); + FloatAutos *y_autos = autos[iy]; prev = 0; next = 0; + float y_value = y_autos->get_value(position, PLAY_FORWARD, prev, next); + FloatAutos *z_autos = autos[iz]; prev = 0; next = 0; + float z_value = z_autos->get_value(position, PLAY_FORWARD, prev, next); + FloatAuto *x_keyframe = 0, *y_keyframe = 0, *z_keyframe = 0; + + gui->cwindow->calculate_affected_autos(affected_track, + &x_keyframe, &y_keyframe, &z_keyframe, + do_camera, -1, -1, -1, 0); + x_keyframe->set_value(x_value); + y_keyframe->set_value(y_value); + z_keyframe->set_value(z_value); - if(affected_track) - { - gui->cwindow->calculate_affected_autos(&x_keyframe, - &y_keyframe, - &z_keyframe, - affected_track, - do_camera, - 1, - 1, - 1); + mwindow->sync_parameters(CHANGE_PARAMS); + gui->update_tool(); + mwindow->gui->lock_window("CWindow::camera_keyframe"); + mwindow->gui->draw_overlays(1); + mwindow->gui->unlock_window(); + } +} + +void CWindowCanvas::camera_keyframe() { create_keyframe(1); } +void CWindowCanvas::projector_keyframe() { create_keyframe(0); } + +void CWindowCanvas::reset_keyframe(int do_camera) +{ + Track *affected_track = gui->cwindow->calculate_affected_track(); + if( affected_track ) { + FloatAuto *x_keyframe = 0, *y_keyframe = 0, *z_keyframe = 0; + gui->cwindow->calculate_affected_autos(affected_track, + &x_keyframe, &y_keyframe, &z_keyframe, + do_camera, 1, 1, 1); x_keyframe->set_value(0); y_keyframe->set_value(0); @@ -2525,18 +2568,15 @@ void CWindowCanvas::reset_keyframe(int do_camera) mwindow->sync_parameters(CHANGE_PARAMS); gui->update_tool(); + mwindow->gui->lock_window("CWindow::camera_keyframe"); + mwindow->gui->draw_overlays(1); + mwindow->gui->unlock_window(); } } -void CWindowCanvas::reset_camera() -{ - reset_keyframe(1); -} +void CWindowCanvas::reset_camera() { reset_keyframe(1); } +void CWindowCanvas::reset_projector() { reset_keyframe(0); } -void CWindowCanvas::reset_projector() -{ - reset_keyframe(0); -} int CWindowCanvas::test_crop(int button_press, int &redraw) { diff --git a/cinelerra-5.1/cinelerra/cwindowgui.h b/cinelerra-5.1/cinelerra/cwindowgui.h index 0e120c8b..ff323cfc 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.h +++ b/cinelerra-5.1/cinelerra/cwindowgui.h @@ -303,9 +303,12 @@ public: int do_camera); int do_ruler(int draw, int motion, int button_press, int button_release); int test_zoom(int &redraw); + void create_keyframe(int do_camera); + void camera_keyframe(); + void projector_keyframe(); + void reset_keyframe(int do_camera); void reset_camera(); void reset_projector(); - void reset_keyframe(int do_camera); void draw_crophandle(int x, int y); void zoom_auto(); diff --git a/cinelerra-5.1/cinelerra/cwindowtool.C b/cinelerra-5.1/cinelerra/cwindowtool.C index f0f372a5..5f7c4165 100644 --- a/cinelerra-5.1/cinelerra/cwindowtool.C +++ b/cinelerra-5.1/cinelerra/cwindowtool.C @@ -696,16 +696,14 @@ void CWindowCurveToggle::check_toggle_state(FloatAuto *x, FloatAuto *y, FloatAut int CWindowCurveToggle::handle_event() { - FloatAuto *x=0, *y=0, *z=0; Track *track = mwindow->cwindow->calculate_affected_track(); - - if(track) - { mwindow->cwindow->calculate_affected_autos(&x, &y, &z, - track, cfg.use_camera, 0,0,0); // don't create new keyframe - - if(x) x->change_curve_mode(cfg.mode); - if(y) y->change_curve_mode(cfg.mode); - if(z) z->change_curve_mode(cfg.mode); + if(track) { + FloatAuto *x=0, *y=0, *z=0; + mwindow->cwindow->calculate_affected_autos(track, + &x, &y, &z, cfg.use_camera, 0,0,0); // don't create new keyframe + if( x ) x->change_curve_mode(cfg.mode); + if( y ) y->change_curve_mode(cfg.mode); + if( z ) z->change_curve_mode(cfg.mode); gui->update(); gui->update_preview(); @@ -748,17 +746,14 @@ void CWindowCameraGUI::create_objects() { int x = 10, y = 10, x1; Track *track = mwindow->cwindow->calculate_affected_track(); - FloatAuto *x_auto = 0; - FloatAuto *y_auto = 0; - FloatAuto *z_auto = 0; + FloatAuto *x_auto = 0, *y_auto = 0, *z_auto = 0; BC_Title *title; BC_Button *button; lock_window("CWindowCameraGUI::create_objects"); - if(track) - { - mwindow->cwindow->calculate_affected_autos(&x_auto, - &y_auto, &z_auto, track, 1, 0, 0, 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + &x_auto, &y_auto, &z_auto, 1, 0, 0, 0); } add_subwindow(title = new BC_Title(x, y, "X:")); @@ -893,17 +888,9 @@ void CWindowCameraGUI::update() FloatAuto *y_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - - if(track) - { - mwindow->cwindow->calculate_affected_autos(&x_auto, - &y_auto, - &z_auto, - track, - 1, - 0, - 0, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + &x_auto, &y_auto, &z_auto, 1, 0, 0, 0); } if(x_auto) @@ -940,16 +927,9 @@ int CWindowCameraLeft::handle_event() FloatAuto *x_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - if(track) - { - mwindow->cwindow->calculate_affected_autos(&x_auto, - 0, - &z_auto, - track, - 1, - 1, - 0, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + &x_auto, 0, &z_auto, 1, 1, 0, 0); } if(x_auto && z_auto) @@ -1017,16 +997,9 @@ int CWindowCameraRight::handle_event() FloatAuto *x_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - if(track) - { - mwindow->cwindow->calculate_affected_autos(&x_auto, - 0, - &z_auto, - track, - 1, - 1, - 0, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + &x_auto, 0, &z_auto, 1, 1, 0, 0); } if(x_auto && z_auto) @@ -1064,16 +1037,9 @@ int CWindowCameraTop::handle_event() FloatAuto *y_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - if(track) - { - mwindow->cwindow->calculate_affected_autos(0, - &y_auto, - &z_auto, - track, - 1, - 0, - 1, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + 0, &y_auto, &z_auto, 1, 0, 1, 0); } if(y_auto && z_auto) @@ -1139,16 +1105,9 @@ int CWindowCameraBottom::handle_event() FloatAuto *y_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - if(track) - { - mwindow->cwindow->calculate_affected_autos(0, - &y_auto, - &z_auto, - track, - 1, - 0, - 1, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + 0, &y_auto, &z_auto, 1, 0, 1, 0); } if(y_auto && z_auto) @@ -1196,16 +1155,9 @@ void CWindowProjectorGUI::create_objects() BC_Button *button; lock_window("CWindowProjectorGUI::create_objects"); - if(track) - { - mwindow->cwindow->calculate_affected_autos(&x_auto, - &y_auto, - &z_auto, - track, - 0, - 0, - 0, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + &x_auto, &y_auto, &z_auto, 0, 0, 0, 0); } add_subwindow(title = new BC_Title(x, y, "X:")); @@ -1337,17 +1289,9 @@ void CWindowProjectorGUI::update() FloatAuto *y_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - - if(track) - { - mwindow->cwindow->calculate_affected_autos(&x_auto, - &y_auto, - &z_auto, - track, - 0, - 0, - 0, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + &x_auto, &y_auto, &z_auto, 0, 0, 0, 0); } if(x_auto) @@ -1381,16 +1325,9 @@ int CWindowProjectorLeft::handle_event() FloatAuto *x_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - if(track) - { - mwindow->cwindow->calculate_affected_autos(&x_auto, - 0, - &z_auto, - track, - 0, - 1, - 0, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + &x_auto, 0, &z_auto, 0, 1, 0, 0); } if(x_auto && z_auto) { @@ -1447,16 +1384,9 @@ int CWindowProjectorRight::handle_event() FloatAuto *x_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - if(track) - { - mwindow->cwindow->calculate_affected_autos(&x_auto, - 0, - &z_auto, - track, - 0, - 1, - 0, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + &x_auto, 0, &z_auto, 0, 1, 0, 0); } if(x_auto && z_auto) @@ -1485,16 +1415,9 @@ int CWindowProjectorTop::handle_event() FloatAuto *y_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - if(track) - { - mwindow->cwindow->calculate_affected_autos(0, - &y_auto, - &z_auto, - track, - 0, - 0, - 1, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + 0, &y_auto, &z_auto, 0, 0, 1, 0); } if(y_auto && z_auto) @@ -1551,16 +1474,9 @@ int CWindowProjectorBottom::handle_event() FloatAuto *y_auto = 0; FloatAuto *z_auto = 0; Track *track = mwindow->cwindow->calculate_affected_track(); - if(track) - { - mwindow->cwindow->calculate_affected_autos(0, - &y_auto, - &z_auto, - track, - 0, - 0, - 1, - 0); + if( track ) { + mwindow->cwindow->calculate_affected_autos(track, + 0, &y_auto, &z_auto, 0, 0, 1, 0); } if(y_auto && z_auto) diff --git a/cinelerra-5.1/cinelerra/filejpeg.C b/cinelerra-5.1/cinelerra/filejpeg.C index d35e9bd4..65dc0e3b 100644 --- a/cinelerra-5.1/cinelerra/filejpeg.C +++ b/cinelerra-5.1/cinelerra/filejpeg.C @@ -279,38 +279,22 @@ int FileJPEG::read_header(FILE *fp, int &w, int &h) int FileJPEG::read_frame(VFrame *output, VFrame *input) { - if(input->get_compressed_size() < 2 || - input->get_data()[0] != 0xff || - input->get_data()[1] != 0xd8) + if( input->get_compressed_size() < 2 || + input->get_data()[0] != 0xff || + input->get_data()[1] != 0xd8 ) return 1; - if(!decompressor) decompressor = mjpeg_new(asset->width, - asset->height, - 1); -// printf("FileJPEG::read_frame %d %p %d %d %d %p %p %p %p %d\n", -// __LINE__, -// input->get_data(), -// input->get_compressed_size(), -// output->get_w(), -// output->get_h(), -// output->get_rows(), -// output->get_y(), -// output->get_u(), -// output->get_v(), + if( !decompressor ) + decompressor = mjpeg_new(asset->width, asset->height, 1); +// printf("FileJPEG::read_frame %d %p %d %d %d %p %p %p %p %d\n", __LINE__, +// input->get_data(), input->get_compressed_size(), output->get_w(), output->get_h(), +// output->get_rows(), output->get_y(), output->get_u(), output->get_v(), // output->get_color_model()); - mjpeg_decompress((mjpeg_t*)decompressor, - input->get_data(), - input->get_compressed_size(), - 0, - output->get_rows(), - output->get_y(), - output->get_u(), - output->get_v(), - output->get_color_model(), - 1); -// PRINT_TRACE - + mjpeg_decompress((mjpeg_t*)decompressor, input->get_data(), input->get_compressed_size(), 0, + output->get_rows(), output->get_y(), output->get_u(), output->get_v(), + output->get_color_model(), 1); //printf("FileJPEG::read_frame %d\n", __LINE__); +// return 0; } diff --git a/cinelerra-5.1/cinelerra/filelist.C b/cinelerra-5.1/cinelerra/filelist.C index dd78cf57..d04ee5ab 100644 --- a/cinelerra-5.1/cinelerra/filelist.C +++ b/cinelerra-5.1/cinelerra/filelist.C @@ -352,49 +352,51 @@ int FileList::read_frame(VFrame *frame) asset->single_frame = 1; // Allocate and decompress single frame into new temporary //printf("FileList::read_frame %d\n", frame->get_color_model()); - if(!temp || temp->get_color_model() != frame->get_color_model()) - { - if(temp) delete temp; - temp = 0; - - - if(!use_path() || frame->get_color_model() == BC_COMPRESSED) - { + if( !temp || temp->get_color_model() != frame->get_color_model() ) { + delete temp; temp = 0; + int aw = asset->actual_width, ah = asset->actual_height; + int color_model = frame->get_color_model(); + switch( color_model ) { + case BC_YUV420P: + case BC_YUV420PI: + case BC_YUV422P: + aw = (aw+1) & ~1; ah = (ah+1) & ~1; + break; + case BC_YUV410P: + case BC_YUV411P: + aw = (aw+3) & ~3; ah = (ah+3) & ~3; + break; + } + if( !use_path() || color_model == BC_COMPRESSED ) { FILE *fd = fopen(asset->path, "rb"); - if(fd) - { + if( fd ) { struct stat ostat; stat(asset->path, &ostat); - switch(frame->get_color_model()) - { - case BC_COMPRESSED: - frame->allocate_compressed_data(ostat.st_size); - frame->set_compressed_size(ostat.st_size); - (void)fread(frame->get_data(), ostat.st_size, 1, fd); - break; - default: - data->allocate_compressed_data(ostat.st_size); - data->set_compressed_size(ostat.st_size); - (void)fread(data->get_data(), ostat.st_size, 1, fd); - temp = new VFrame(asset->actual_width, asset->actual_height, - frame->get_color_model(), 0); - read_frame(temp, data); - break; + switch(frame->get_color_model()) { + case BC_COMPRESSED: + frame->allocate_compressed_data(ostat.st_size); + frame->set_compressed_size(ostat.st_size); + (void)fread(frame->get_data(), ostat.st_size, 1, fd); + break; + default: + data->allocate_compressed_data(ostat.st_size); + data->set_compressed_size(ostat.st_size); + (void)fread(data->get_data(), ostat.st_size, 1, fd); + temp = new VFrame(aw, ah, color_model); + read_frame(temp, data); + break; } fclose(fd); } - else - { + else { eprintf(_("Error while opening \"%s\" for reading. \n%m\n"), asset->path); result = 1; } } - else - { - temp = new VFrame(asset->actual_width, asset->actual_height, - frame->get_color_model(), 0); + else { + temp = new VFrame(aw, ah, color_model); read_frame(temp, asset->path); } } diff --git a/cinelerra-5.1/cinelerra/libmjpeg.C b/cinelerra-5.1/cinelerra/libmjpeg.C index f2df6ddc..6e71b0c0 100644 --- a/cinelerra-5.1/cinelerra/libmjpeg.C +++ b/cinelerra-5.1/cinelerra/libmjpeg.C @@ -1077,27 +1077,13 @@ int mjpeg_compress(mjpeg_t *mjpeg, * printf("mjpeg_compress %d %d %d %d\n", * mjpeg->output_w, mjpeg->output_h, mjpeg->coded_w, mjpeg->coded_h); */ - BC_CModels::transfer(0, - row_pointers, - mjpeg->temp_rows[0][0], - mjpeg->temp_rows[1][0], - mjpeg->temp_rows[2][0], - y_plane, - u_plane, - v_plane, - 0, - 0, - mjpeg->output_w, - mjpeg->output_h, - 0, - 0, - mjpeg->output_w, - mjpeg->output_h, - mjpeg->color_model, - mjpeg->jpeg_color_model, - 0, - mjpeg->output_w, - mjpeg->coded_w); + BC_CModels::transfer(0, row_pointers, + mjpeg->temp_rows[0][0], mjpeg->temp_rows[1][0], mjpeg->temp_rows[2][0], + y_plane, u_plane, v_plane, + 0, 0, mjpeg->output_w, mjpeg->output_h, + 0, 0, mjpeg->output_w, mjpeg->output_h, + mjpeg->color_model, mjpeg->jpeg_color_model, 0, + mjpeg->output_w, mjpeg->coded_w); } /* Start the compressors on the image fields */ @@ -1245,27 +1231,12 @@ int mjpeg_decompress(mjpeg_t *mjpeg, * mjpeg->color_model); */ - BC_CModels::transfer(row_pointers, - 0, - y_plane, - u_plane, - v_plane, - y_in, - u_in, - v_in, - 0, - 0, - mjpeg->output_w, - mjpeg->output_h, - 0, - 0, - mjpeg->output_w, - mjpeg->output_h, - mjpeg->jpeg_color_model, - mjpeg->color_model, - 0, - mjpeg->coded_w, - mjpeg->rowspan ? mjpeg->rowspan : mjpeg->output_w); + BC_CModels::transfer(row_pointers, 0, + y_plane, u_plane, v_plane, y_in, u_in, v_in, + 0, 0, mjpeg->output_w, mjpeg->output_h, + 0, 0, mjpeg->output_w, mjpeg->output_h, + mjpeg->jpeg_color_model, mjpeg->color_model, 0, + mjpeg->coded_w, mjpeg->rowspan ? mjpeg->rowspan : mjpeg->output_w); //printf("mjpeg_decompress 8\n"); } return 0; diff --git a/cinelerra-5.1/cinelerra/shudmp.C b/cinelerra-5.1/cinelerra/shudmp.C new file mode 100644 index 00000000..fbb85cf6 --- /dev/null +++ b/cinelerra-5.1/cinelerra/shudmp.C @@ -0,0 +1,77 @@ +#include +#include +#include +#include +#include +#include + +#include + +#define SHUTTLE_INTERFACE 0 + +libusb_device_handle *devsh = 0; +int claimed = -1; + +void usb_done() +{ + if( devsh ) { + if( claimed > 0 ) { + int sh_iface = SHUTTLE_INTERFACE; + libusb_release_interface(devsh, sh_iface); + libusb_attach_kernel_driver(devsh, sh_iface); + claimed = 0; + } + libusb_close(devsh); + devsh = 0; + } + if( claimed >= 0 ) { + libusb_exit(0); + claimed = -1; + } +} + +void usb_probe() +{ + int ret = libusb_init(0); + if( ret < 0 ) return; + claimed = 0; + devsh = libusb_open_device_with_vid_pid(0, 0x0b33, 0x0030); + if( devsh ) { + int sh_iface = SHUTTLE_INTERFACE; + libusb_detach_kernel_driver(devsh, sh_iface); + ret = libusb_claim_interface(devsh, sh_iface); + if( ret >= 0 ) claimed = 1; + } + if( !claimed ) + usb_done(); +} + +int done = 0; +void sigint(int n) { done = 1; } + +int main(int ac, char **av) +{ + setbuf(stdout, 0); + usb_probe(); + if( claimed > 0 ) { + signal(SIGINT, sigint); + while( !done ) { + int len = 0; + static const int IN_ENDPOINT = 0x81; + unsigned char dat[64]; + int ret = libusb_interrupt_transfer(devsh, + IN_ENDPOINT, dat, sizeof(dat), &len, 100); + if( ret != 0 ) { + if( ret == LIBUSB_ERROR_TIMEOUT ) continue; + printf("error: %s\n", libusb_strerror((libusb_error)ret)); + sleep(1); continue; + } + printf("shuttle: "); + for( int i=0; i