add compositor crop resize/shrink, rework 3rd-party build for pkg-cfg cflags/libs
authorGood Guy <good1.2guy@gmail.com>
Sun, 22 Sep 2019 00:24:14 +0000 (18:24 -0600)
committerGood Guy <good1.2guy@gmail.com>
Sun, 22 Sep 2019 00:24:14 +0000 (18:24 -0600)
15 files changed:
cinelerra-5.1/cinelerra/cwindowgui.h
cinelerra-5.1/cinelerra/cwindowtool.C
cinelerra-5.1/cinelerra/cwindowtool.h
cinelerra-5.1/cinelerra/cwindowtool.inc
cinelerra-5.1/cinelerra/mwindow.h
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/track.C
cinelerra-5.1/cinelerra/track.h
cinelerra-5.1/cinelerra/tracks.C
cinelerra-5.1/cinelerra/tracks.h
cinelerra-5.1/cinelerra/vtrack.C
cinelerra-5.1/cinelerra/vtrack.h
cinelerra-5.1/configure.ac
cinelerra-5.1/guicast/bcwindowbase.C
cinelerra-5.1/thirdparty/Makefile

index b346885afe007de2e975977e42f9faaba36a0dc1..ddbfa372a1831220f54c8c81518c99f49c5f8085 100644 (file)
@@ -54,6 +54,12 @@ class CWindowEditing;
 
 #define AUTO_ZOOM N_("Auto")
 
+#define CROP_REFORMAT 0
+#define CROP_RESIZE 1
+#define CROP_SHRINK 2
+#define CROP_MODES 3
+
+
 class CWindowGUI : public BC_Window
 {
 public:
index 25c436afb4647b4916b77f979dacdc69fe09467d..a7e4f3b977302b4753db0bd2f78458abadaf2ea2 100644 (file)
@@ -372,20 +372,20 @@ int CWindowCoord::handle_event()
 }
 
 
-CWindowCropOK::CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui, int x, int y)
- : BC_GenericButton(x, y, _("Do it"))
+CWindowCropApply::CWindowCropApply(MWindow *mwindow, CWindowCropGUI *crop_gui, int x, int y)
+ : BC_GenericButton(x, y, _("Apply"))
 {
        this->mwindow = mwindow;
-       this->gui = gui;
+       this->crop_gui = crop_gui;
 }
-int CWindowCropOK::handle_event()
+int CWindowCropApply::handle_event()
 {
-       mwindow->crop_video();
+       mwindow->crop_video(crop_gui->crop_mode->mode);
        return 1;
 }
 
 
-int CWindowCropOK::keypress_event()
+int CWindowCropApply::keypress_event()
 {
        if(get_keypress() == 0xd)
        {
@@ -395,7 +395,50 @@ int CWindowCropOK::keypress_event()
        return 0;
 }
 
+const char *CWindowCropOpMode::crop_ops[] = {
+       N_("Reformat"),
+       N_("Resize"),
+       N_("Shrink"),
+};
+
+CWindowCropOpMode::CWindowCropOpMode(MWindow *mwindow, CWindowCropGUI *crop_gui,
+                       int mode, int x, int y)
+ : BC_PopupMenu(x, y, 140, _(crop_ops[mode]), 1)
+{
+        this->mwindow = mwindow;
+        this->crop_gui = crop_gui;
+        this->mode = mode;
+}
+CWindowCropOpMode::~CWindowCropOpMode()
+{
+}
+
+void CWindowCropOpMode::create_objects()
+{
+       for( int id=0,nid=sizeof(crop_ops)/sizeof(crop_ops[0]); id<nid; ++id )
+               add_item(new CWindowCropOpItem(this, _(crop_ops[id]), id));
+       handle_event();
+}
+
+int CWindowCropOpMode::handle_event()
+{
+       set_text(_(crop_ops[mode]));
+       return 1;
+}
+
+CWindowCropOpItem::CWindowCropOpItem(CWindowCropOpMode *popup, const char *text, int id)
+ : BC_MenuItem(text)
+{
+       this->popup = popup;
+       this->id = id;
+}
 
+int CWindowCropOpItem::handle_event()
+{
+       popup->set_text(get_text());
+       popup->mode = id;
+       return popup->handle_event();
+}
 
 
 
@@ -430,7 +473,7 @@ void CWindowCropGUI::create_objects()
        add_subwindow(title = new BC_Title(x, y, _("W:")));
        column1 = MAX(column1, title->get_w());
        y += pad;
-       add_subwindow(new CWindowCropOK(mwindow, thread->tool_gui, x, y));
+       add_subwindow(new CWindowCropApply(mwindow, this, x, y));
 
        x += column1 + 5;
        y = 10;
@@ -459,9 +502,16 @@ void CWindowCropGUI::create_objects()
                mwindow->edl->session->crop_y1);
        y1->create_objects();
        y += pad;
+
        height = new CWindowCoord(thread->tool_gui, x, y,
                mwindow->edl->session->crop_y2 - mwindow->edl->session->crop_y1);
        height->create_objects();
+       y += pad;
+
+       add_subwindow(crop_mode = new CWindowCropOpMode(mwindow, this,
+                               CROP_REFORMAT, x, y));
+       crop_mode->create_objects();
+
        unlock_window();
 }
 
index c8918071a1fda2223b4dd7c178a97822f5c749f3..1a116541200f9f4b1bfb6f9937142dd2504e65ea 100644 (file)
@@ -117,18 +117,44 @@ public:
        CWindowToolGUI *gui;
 };
 
-class CWindowCropOK : public BC_GenericButton
+class CWindowCropApply : public BC_GenericButton
 {
 public:
-       CWindowCropOK(MWindow *mwindow, CWindowToolGUI *gui,
+       CWindowCropApply(MWindow *mwindow, CWindowCropGUI *crop_gui,
                        int x, int y);
 // Perform the cropping operation
        int handle_event();
        int keypress_event();
        MWindow *mwindow;
-       CWindowToolGUI *gui;
+       CWindowCropGUI *crop_gui;
+};
+
+class CWindowCropOpMode : public BC_PopupMenu
+{
+       static const char *crop_ops[CROP_MODES];
+public:
+       CWindowCropOpMode(MWindow *mwindow, CWindowCropGUI *crop_gui,
+                       int mode, int x, int y);
+       ~CWindowCropOpMode();
+       void create_objects();
+       int handle_event();
+
+       MWindow *mwindow;
+       CWindowCropGUI *crop_gui;
+       int mode;
 };
 
+class CWindowCropOpItem : public BC_MenuItem
+{
+public:
+       CWindowCropOpItem(CWindowCropOpMode *popup, const char *text, int id);
+       int handle_event();
+
+       CWindowCropOpMode *popup;
+       int id;
+};
+
+
 class CWindowCropGUI : public CWindowToolGUI
 {
 public:
@@ -139,6 +165,7 @@ public:
 // Update the gui
        void handle_event();
        CWindowCoord *x1, *y1, *width, *height;
+       CWindowCropOpMode *crop_mode;
 };
 
 class CWindowMaskItem : public BC_ListBoxItem
index 39fd3df03b56b0bb6b43fb387ee186c006e24b79..6f19a15f5829403f900714c9beafd776219d4b5e 100644 (file)
@@ -25,7 +25,9 @@
 class CWindowTool;
 class CWindowToolGUI;
 class CWindowCoord;
-class CWindowCropOK;
+class CWindowCropApply;
+class CWindowCropOpMode;
+class CWindowCropOpItem;
 class CWindowCropGUI;
 class CWindowMaskItem;
 class CWindowMaskItems;
index ff5ea817a2dc805775a3421dae4a10346b756478..6083242d37ac8a235996d729670d02de6d9d1505 100644 (file)
@@ -285,7 +285,7 @@ public:
        int zoom_in_t();
        void split_x();
        void split_y();
-       void crop_video();
+       void crop_video(int mode);
        void update_plugins();
 // Call after every edit operation
        void save_backup();
index f9f92900ff170c47d9001b384116e876fc21a2f8..f7d43ee92b14de8a9743ab8a2d4eae658b1de55f 100644 (file)
@@ -511,12 +511,10 @@ int MWindow::copy_default_keyframe()
        return 0;
 }
 
-
 // Uses cropping coordinates in edl session to crop and translate video.
 // We modify the projector since camera automation depends on the track size.
-void MWindow::crop_video()
+void MWindow::crop_video(int mode)
 {
-
        undo_before();
 // Clamp EDL crop region
        if( edl->session->crop_x1 > edl->session->crop_x2 ) {
@@ -529,22 +527,54 @@ void MWindow::crop_video()
                edl->session->crop_y2 ^= edl->session->crop_y1;
                edl->session->crop_y1 ^= edl->session->crop_y2;
        }
-
-       float old_projector_x = (float)edl->session->output_w / 2;
-       float old_projector_y = (float)edl->session->output_h / 2;
-       float new_projector_x = (float)(edl->session->crop_x1 + edl->session->crop_x2) / 2;
-       float new_projector_y = (float)(edl->session->crop_y1 + edl->session->crop_y2) / 2;
-       float projector_offset_x = -(new_projector_x - old_projector_x);
-       float projector_offset_y = -(new_projector_y - old_projector_y);
-
-       edl->tracks->translate_projector(projector_offset_x, projector_offset_y);
-
-       edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
-       edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
-       edl->session->crop_x1 = 0;
-       edl->session->crop_y1 = 0;
-       edl->session->crop_x2 = edl->session->output_w;
-       edl->session->crop_y2 = edl->session->output_h;
+       switch( mode ) {
+       case CROP_REFORMAT: {
+               float ctr_x = edl->session->output_w / 2.;
+               float ctr_y = edl->session->output_h / 2.;
+               float new_x = (edl->session->crop_x1 + edl->session->crop_x2) / 2.;
+               float new_y = (edl->session->crop_y1 + edl->session->crop_y2) / 2.;
+               float dx = -(new_x - ctr_x), dy = -(new_y - ctr_y);
+               edl->tracks->translate_projector(dx, dy, 1);
+
+               edl->session->output_w = edl->session->crop_x2 - edl->session->crop_x1;
+               edl->session->output_h = edl->session->crop_y2 - edl->session->crop_y1;
+               edl->session->crop_x1 = edl->session->crop_y1 = 0;
+               edl->session->crop_x2 = edl->session->output_w;
+               edl->session->crop_y2 = edl->session->output_h;
+               break; }
+       case CROP_RESIZE: {
+               float old_w = edl->session->output_w;
+               float old_h = edl->session->output_h;
+               float new_w = edl->session->crop_x2 - edl->session->crop_x1;
+               float new_h = edl->session->crop_y2 - edl->session->crop_y1;
+               if( !new_w ) new_w = 1;
+               if( !new_h ) new_h = 1;
+               float xzoom = old_w / new_w, yzoom = old_h / new_h;
+               float new_z = bmin(xzoom, yzoom);
+               float new_x = (edl->session->crop_x1 + edl->session->crop_x2) / 2.;
+               float new_y = (edl->session->crop_y1 + edl->session->crop_y2) / 2.;
+               edl->tracks->crop_resize(new_x, new_y, new_z);
+
+               edl->session->crop_x1 = 0;
+               edl->session->crop_y1 = 0;
+               edl->session->crop_x2 = edl->session->output_w;
+               edl->session->crop_y2 = edl->session->output_h;
+               break; }
+       case CROP_SHRINK: {
+               float old_w = edl->session->output_w;
+               float old_h = edl->session->output_h;
+               float new_w = edl->session->crop_x2 - edl->session->crop_x1;
+               float new_h = edl->session->crop_y2 - edl->session->crop_y1;
+               if( !new_w ) new_w = 1;
+               if( !new_h ) new_h = 1;
+               float xzoom = old_w / new_w, yzoom = old_h / new_h;
+               float new_z = bmin(xzoom, yzoom);
+
+               float new_x = (edl->session->crop_x1 + edl->session->crop_x2) / 2.;
+               float new_y = (edl->session->crop_y1 + edl->session->crop_y2) / 2.;
+               edl->tracks->crop_shrink(new_x, new_y, new_z);
+               break; }
+       }
 
 // Recalculate aspect ratio
        if( defaults->get("AUTOASPECT", 0) ) {
index d5363317c5877b8e7badd91fe36537e5d62be09f..9fdc531a2b43854c299a7d076750a78a43fbc0b7 100644 (file)
@@ -1863,3 +1863,42 @@ int Track::get_mixer_id()
        return mixer_id;
 }
 
+void Track::get_fauto_xyz(int fauto, float &x, float &y, float &z)
+{
+       FloatAutos **fautos = (FloatAutos **)&automation->autos;
+       FloatAuto *xauto = (FloatAuto *)fautos[fauto+0]->get_auto_for_editing(-1, 1);
+       if( xauto ) x = xauto->get_value();
+       FloatAuto *yauto = (FloatAuto *)fautos[fauto+1]->get_auto_for_editing(-1, 1);
+       if( yauto ) y = yauto->get_value();
+       FloatAuto *zauto = (FloatAuto *)fautos[fauto+2]->get_auto_for_editing(-1, 1);
+       if( zauto ) z = zauto->get_value();
+}
+void Track::set_fauto_xyz(int fauto, float x, float y, float z)
+{
+       FloatAutos **fautos = (FloatAutos **)&automation->autos;
+       FloatAuto *xauto = (FloatAuto *)fautos[fauto+0]->get_auto_for_editing(-1, 1);
+       if( xauto ) xauto->set_value(x);
+       FloatAuto *yauto = (FloatAuto *)fautos[fauto+1]->get_auto_for_editing(-1, 1);
+       if( yauto ) yauto->set_value(y);
+       FloatAuto *zauto = (FloatAuto *)fautos[fauto+2]->get_auto_for_editing(-1, 1);
+       if( zauto ) zauto->set_value(z);
+}
+
+void Track::get_projector(float &x, float &y, float &z)
+{
+       get_fauto_xyz(AUTOMATION_PROJECTOR_X, x, y, z);
+}
+void Track::set_projector(float x, float y, float z)
+{
+       set_fauto_xyz(AUTOMATION_PROJECTOR_X, x, y, z);
+}
+
+void Track::get_camera(float &x, float &y, float &z)
+{
+       get_fauto_xyz(AUTOMATION_CAMERA_X, x, y, z);
+}
+void Track::set_camera(float x, float y, float z)
+{
+       set_fauto_xyz(AUTOMATION_CAMERA_X, x, y, z);
+}
+
index 513c046b47631e73d9430b7f14f65e64cfc48932..ada29f21e06c43132402d44183e40ae09b433b28 100644 (file)
@@ -71,6 +71,13 @@ public:
        void equivalent_output(Track *track, double *result);
        int get_mixer_id();
 
+       void get_fauto_xyz(int fauto, float &x, float &y, float &z);
+       void set_fauto_xyz(int fauto, float x, float y, float z);
+       void get_projector(float &x, float &y, float &z);
+       void set_projector(float x, float y, float z);
+       void get_camera(float &x, float &y, float &z);
+       void set_camera(float x, float y, float z);
+
        virtual void copy_from(Track *track);
        Track& operator=(Track& track);
        virtual PluginSet* new_plugins() { return 0; };
index 7feb1f99cfc1febeec05653ee8843c244ec52f1f..bb31f6dbecd2fa59c492101819bf5aae192244cb 100644 (file)
@@ -522,14 +522,62 @@ double Tracks::total_length_framealigned(double fps)
        return 0;
 }
 
-void Tracks::translate_projector(float offset_x, float offset_y)
+void Tracks::translate_fauto_xy(int fauto, float dx, float dy, int all)
 {
-       for(Track *current = first; current; current = NEXT)
-       {
-               if(current->data_type == TRACK_VIDEO)
-               {
-                       ((VTrack*)current)->translate(offset_x, offset_y, 0);
-               }
+       Track *track = first;
+       for( ; track; track=track->next ) {
+               if( !all && !track->record ) continue;
+               if( track->data_type != TRACK_VIDEO ) continue;
+               ((VTrack*)track)->translate(fauto, dx, dy, all);
+       }
+}
+
+void Tracks::translate_projector(float dx, float dy, int all)
+{
+       translate_fauto_xy(AUTOMATION_PROJECTOR_X, dx, dy, all);
+}
+
+void Tracks::translate_camera(float dx, float dy, int all)
+{
+       translate_fauto_xy(AUTOMATION_CAMERA_X, dx, dy, all);
+}
+
+void Tracks::crop_resize(float x, float y, float z)
+{
+       float ctr_x = edl->session->output_w / 2.;
+       float ctr_y = edl->session->output_h / 2.;
+       Track *track = first;
+       for( ; track; track=track->next ) {
+               if( !track->record ) continue;
+               if( track->data_type != TRACK_VIDEO ) continue;
+               float px, py, pz;
+               track->get_projector(px, py, pz);
+               float old_x = px + ctr_x;
+               float old_y = py + ctr_y;
+               float nx = (old_x - x) * z;
+               float ny = (old_y - y) * z;
+               track->set_projector(nx, ny, pz * z);
+       }
+}
+
+void Tracks::crop_shrink(float x, float y, float z)
+{
+       float ctr_x = edl->session->output_w / 2.;
+       float ctr_y = edl->session->output_h / 2.;
+       Track *track = first;
+       for( ; track; track=track->next ) {
+               if( !track->record ) continue;
+               if( track->data_type != TRACK_VIDEO ) continue;
+               float cx, cy, cz, px, py, pz;
+               track->get_camera(cx, cy, cz);
+               track->get_projector(px, py, pz);
+               float dx = x - (px + ctr_x);
+               float dy = y - (py + ctr_y);
+               cz *= pz;
+               cx += dx / cz;  cy += dy / cz;
+               track->set_camera(cx, cy, cz * z);
+               px += dx;  py += dy;
+               track->set_projector(px, py, 1 / z);
        }
 }
 
index 0aff6a37365930a5865cb54ac9463b0876a65490..63a98a5230d34e806094b2c3a2e17a1d80154df4 100644 (file)
@@ -101,9 +101,14 @@ public:
 // Update y pixels after a zoom
        void update_y_pixels(Theme *theme);
 // Total number of tracks where the following toggles are selected
-       void select_all(int type,
-               int value);
-       void translate_projector(float offset_x, float offset_y);
+       void select_all(int type, int value);
+
+       void translate_fauto_xy(int fauto, float dx, float dy, int all);
+       void translate_projector(float dx, float dy, int all=0);
+       void translate_camera(float dx, float dy, int all=0);
+       void crop_resize(float x, float y, float z);
+       void crop_shrink(float x, float y, float z);
+
        int total_of(int type);
        Track* get_track_by_id(int id);
 // add a track
index c8a34e45931571fad1b4fc8d150571c3e663c367..826144ad4121b2646d00a68d84914743be51e294 100644 (file)
@@ -484,37 +484,48 @@ int VTrack::get_projection(float &in_x1, float &in_y1, float &in_x2, float &in_y
 
 
 
-inline void addto_value(FloatAuto *fauto, float offset)
+static inline void addto_value(FloatAuto *fauto, float offset)
 {
        fauto->set_value(fauto->get_value() + offset);
 }
 
-
-void VTrack::translate(float offset_x, float offset_y, int do_camera)
+static inline void multiply_value(FloatAuto *fauto, float scale)
 {
-       int subscript;
-       if(do_camera)
-               subscript = AUTOMATION_CAMERA_X;
-       else
-               subscript = AUTOMATION_PROJECTOR_X;
+       fauto->set_value(fauto->get_value() * scale);
+}
 
-// Translate default keyframe
-       addto_value((FloatAuto*)automation->autos[subscript]->default_auto, offset_x);
-       addto_value((FloatAuto*)automation->autos[subscript + 1]->default_auto, offset_y);
 
-// Translate everyone else
-       for(Auto *current = automation->autos[subscript]->first;
-               current;
-               current = NEXT)
-       {
-               addto_value((FloatAuto*)current, offset_x);
-       }
+void VTrack::set_fauto_xy(int fauto, float x, float y)
+{
+// set default keyframe
+       FloatAuto *xdft = (FloatAuto *)automation->autos[fauto+0]->default_auto;
+       FloatAuto *ydft = (FloatAuto *)automation->autos[fauto+1]->default_auto;
+       xdft->set_value(x);
+       ydft->set_value(y);
+// set everyone else
+       FloatAuto *xauto = (FloatAuto *)automation->autos[fauto+0]->first;
+       FloatAuto *yauto = (FloatAuto *)automation->autos[fauto+1]->first;
+       for( ; xauto; xauto=(FloatAuto *)xauto->next ) xauto->set_value(x);
+       for( ; yauto; yauto=(FloatAuto *)yauto->next ) yauto->set_value(y);
+}
 
-       for(Auto *current = automation->autos[subscript + 1]->first;
-               current;
-               current = NEXT)
-       {
-               addto_value((FloatAuto*)current, offset_y);
+void VTrack::translate(int fauto, float dx, float dy, int all)
+{
+       if( all ) {
+               addto_value((FloatAuto*)automation->autos[fauto+0]->default_auto, dx);
+               addto_value((FloatAuto*)automation->autos[fauto+1]->default_auto, dy);
+               FloatAutos **fautos = (FloatAutos **)&automation->autos;
+               FloatAuto *xauto = (FloatAuto *)fautos[fauto+0]->first;
+               FloatAuto *yauto = (FloatAuto *)fautos[fauto+1]->first;
+               for( ; xauto; xauto=(FloatAuto *)xauto->next ) addto_value(xauto, dx);
+               for( ; yauto; yauto=(FloatAuto *)yauto->next ) addto_value(yauto, dy);
+       }
+       else {
+               FloatAutos **fautos = (FloatAutos **)&automation->autos;
+               FloatAuto *xauto = (FloatAuto *)fautos[fauto+0]->get_auto_for_editing(-1, 1);
+               FloatAuto *yauto = (FloatAuto *)fautos[fauto+1]->get_auto_for_editing(-1, 1);
+               addto_value(xauto, dx);
+               addto_value(yauto, dy);
        }
 }
 
index ff2cbbe77bd5e7058518e497b4e3cda33104e6bc..cdc4badd3a4cd663b0487f2c3d2e90d8cc6b60e4 100644 (file)
@@ -120,7 +120,8 @@ public:
        int draw_floating_autos_derived(float view_start, float zoom_units, AutoConf *auto_conf, int flash);
        int select_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y);
        int move_auto_derived(float zoom_units, float view_start, AutoConf *auto_conf, int cursor_x, int cursor_y, int shift_down);
-       void translate(float offset_x, float offset_y, int do_camera);
+       void set_fauto_xy(int fauto, float x, float y);
+       void translate(int fauto, float dx, float dy, int all);
 
 // ===================================== for handles, titles, etc
 
index a60bb1103de17a6df4cfcf79e588b0dfcaf3acb5..7d4cdca011b712f3778081e0dff97882981de3ac 100644 (file)
@@ -597,14 +597,23 @@ CHECK_HEADERS([encore], [encore headers], [encore.h])
 CHECK_LIB([giflib], [gif], [DGifOpen])
 CHECK_HEADERS([giflib], [gif lib headers], [gif_lib.h])
 CHECK_LIB([jbig], [jbig], [jbg_dec_init])
+
 CHECK_LIB([VDPAU], [vdpau], [vdp_device_create_x11])
+if test "x$HAVE_VDPAU" != "xyes" -a "x$WANT_VDPAU" = "xyes"; then
+  AC_MSG_ERROR([requires vdpau support.])
+fi
+
 CHECK_LIB([VAAPI], [va], [vaInitialize])
-if test "x$WANT_VAAPI" != "xno" -a "x$HAVE_VAAPI" = "xyes"; then
+if test "x$HAVE_VAAPI" = "xyes" -a "x$WANT_VAAPI" != "xno"; then
   CHECK_HEADERS([vaapi_x11], [va x11 headers], [va/va_x11.h])
   CHECK_LIB([vaapi_x11], [va-x11], [vaGetDisplay])
   CHECK_HEADERS([vaapi_drm], [va drm headers], [va/va_drm.h])
   CHECK_LIB([vaapi_drm], [va-drm], [vaGetDisplayDRM])
 fi
+if test "x$HAVE_VAAPI" != "xyes" -a "x$WANT_VAAPI" = "xyes"; then
+  AC_MSG_ERROR([requires vappi support.])
+fi
+
 #CHECK_LIB([NVENC], [nvidia-encode], [NvEncodeAPICreateInstance])
 
 #if test "x$HAVE_mjpegtools" = "xyes"; then
@@ -763,6 +772,7 @@ AC_DEFUN([PKG_DISABLED],[
  echo "AC_HELP_STRING([disabled],[$1])"
 ])
 AC_DEFUN([PKG_SHARED],[
+ PKG_$1="shared"
  BUILD_$1=0
  AC_SUBST(BUILD_$1)
  SHARED_LIBS+="$SHARED_$1"
@@ -890,32 +900,6 @@ for v in GL XFT XXF86VM OSS ALSA FIREWIRE DV DVB \
   echo "  using: $vv-$v"
 done
 
-echo "  using: with-jobs = $WANT_JOBS"
-echo "  using: exec-name = $WANT_CIN"
-echo "  using: with-cinlib = $WANT_CINLIB_DIR"
-echo "  using: with-cindat = $WANT_CINDAT_DIR"
-echo "  using: with-config-dir = $WANT_CONFIG_DIR"
-echo "  using: with-browser = $WANT_CIN_BROWSER"
-echo "  using: with-plugin-dir = $WANT_PLUGIN_DIR"
-echo "  using: with-ladspa-dir = $WANT_LADSPA_DIR"
-echo "  using: with-opencv = $WANT_OPENCV"
-echo "  using: with-git-ffmpeg = $WANT_GIT_FFMPEG"
-echo "  using: with-noelision = $WANT_NOELISION"
-echo "  using: with-booby = $WANT_BOOBY"
-echo "  using: with-libzmpeg = $WANT_LIBZMPEG"
-echo "  using: with-commerical = $WANT_COMMERCIAL"
-echo "  using: with-vaapi = $WANT_VAAPI"
-echo "  using: with-vdpau = $WANT_VDPAU"
-echo "  using: with-nv = $WANT_NV"
-echo "  using: with-cuda = $WANT_CUDA"
-echo "  using: with-clang = $WANT_CLANG"
-echo ""
-echo "  using: thirdparty build = $WANT_CIN_3RDPARTY"
-echo "  using: single-user  = $WANT_CINBIN_BUILD"
-echo "  using: static-build = $WANT_STATIC_BUILD"
-echo "  using: ladspa-build = $WANT_LADSPA_BUILD"
-echo ""
-
 # build extras
 if test "x$WANT_CLANG" = "xyes" ; then
   FFMPEG_EXTRA_CFG+=' --cc=clang --cxx=clang++'
@@ -934,7 +918,6 @@ if test "x$WANT_VAAPI" != "xno" -a "x$HAVE_VAAPI" = "xyes"; then
   FFMPEG_EXTRA_LDFLAGS+=' -lva'
   EXTRA_LIBS+=' -lva'
   WANT_VAPPI="yes"
-  CFG_WANTS+=" VAAPI"
   if test "x$HAVE_vaapi_x11" = "xyes"; then
     FFMPEG_EXTRA_LDFLAGS+=' -lva-x11'
     EXTRA_LIBS+=' -lva-x11'
@@ -944,10 +927,13 @@ if test "x$WANT_VAAPI" != "xno" -a "x$HAVE_VAAPI" = "xyes"; then
     EXTRA_LIBS+=' -lva-drm'
   fi
 fi
+CFG_WANTS+=" VAAPI"
+
 if test "x$WANT_VDPAU" != "xno" -a "x$HAVE_VDPAU" = "xyes"; then
   WANT_VDPAU="yes"
-  CFG_WANTS+=" VDPAU"
 fi
+CFG_WANTS+=" VDPAU"
+
 if test "x$WANT_NV" != "xno"; then
   WANT_NV="yes"
   CFG_WANTS+=" NV"
@@ -975,6 +961,26 @@ if test "x$WANT_NOELISION" != "xno"; then
   | tail -1`
 fi
 
+echo "  using: with-jobs = $WANT_JOBS"
+echo "  using: exec-name = $WANT_CIN"
+echo "  using: with-cinlib = $WANT_CINLIB_DIR"
+echo "  using: with-cindat = $WANT_CINDAT_DIR"
+echo "  using: with-config-dir = $WANT_CONFIG_DIR"
+echo "  using: with-browser = $WANT_CIN_BROWSER"
+echo "  using: with-plugin-dir = $WANT_PLUGIN_DIR"
+echo "  using: with-ladspa-dir = $WANT_LADSPA_DIR"
+echo "  using: with-opencv = $WANT_OPENCV"
+echo "  using: with-git-ffmpeg = $WANT_GIT_FFMPEG"
+echo "  using: with-noelision = $WANT_NOELISION"
+echo "  using: with-booby = $WANT_BOOBY"
+echo "  using: with-clang = $WANT_CLANG"
+echo ""
+echo "  using: thirdparty build = $WANT_CIN_3RDPARTY"
+echo "  using: single-user  = $WANT_CINBIN_BUILD"
+echo "  using: static-build = $WANT_STATIC_BUILD"
+echo "  using: ladspa-build = $WANT_LADSPA_BUILD"
+echo ""
+
 AC_SUBST(WANT_CIN_3RDPARTY)
 AC_SUBST(EXTRA_LIBS)
 AC_SUBST(FFMPEG_EXTRA_CFG)
@@ -1016,7 +1022,7 @@ echo "export THIRDPARTY EXTRA_LIBS FFMPEG_EXTRA_CFG"
 echo ""
 
 echo "WANT_CIN := $WANT_CIN"
-CFG_WANTS+=" CIN_3RDPARTY LIBZMPEG COMMERCIAL"
+CFG_WANTS+=" CIN_3RDPARTY LIBZMPEG COMMERCIAL STATIC_BUILD"
 for w in $CFG_WANTS; do ww=WANT_$w; echo "WANT_$w := ${!ww}"; done
 echo ""
 
@@ -1067,8 +1073,11 @@ fi
 
 for pkg in $STATIC_PKGS; do
   eval pkg_lib="\$PKG_$pkg"
-  if test "x$pkg_lib" = "xno"; then continue; fi;
-  echo "static_pkgs += $pkg"
+  if test "x$pkg_lib" = "xyes"; then
+    echo "static_pkgs += $pkg"
+  elif test "x$pkg_lib" = "xshared"; then
+    echo "shared_pkgs += $pkg"
+  fi
 done
 echo ""
 
@@ -1097,7 +1106,7 @@ echo ""
 for lib in $SHARED_LIBS; do echo "shared_libs += $lib"; done
 echo ""
 for lib in $SYSTEM_LIBS; do echo "system_libs += $lib"; done
-echo "export static_pkgs static_blds shared_libs system_libs"
+echo "export static_pkgs shared_pkgs static_blds shared_libs system_libs"
 echo ""
 
 echo "thirdparty_libraries := \$(static_libs) \$(shared_libs)"
@@ -1108,11 +1117,13 @@ fi
 
 echo "libraries += -Wl,--start-group"
 echo "libraries += \$(thirdparty_libraries)"
+echo "libraries += \$(shared_libs)"
 echo "libraries += \$(system_libs)"
 echo "libraries += \$(EXTRA_LIBS)"
 echo "libraries += -Wl,--end-group"
 # -Wl,--start-group ... -Wl,--end-group does not work on ubuntu
 echo "libraries += \$(thirdparty_libraries)"
+echo "libraries += \$(shared_libs)"
 echo "libraries += \$(system_libs)"
 echo "libraries += \$(EXTRA_LIBS)"
 echo ""
index 1f1d0d30c151581dfbe51cc2ff90ec67ab71e1e0..93b3d4554077c45aeb721636fe574ed77a09a73a 100644 (file)
@@ -462,7 +462,10 @@ int BC_WindowBase::create_window(BC_WindowBase *parent_window, const char *title
 #endif
                {
                        int mask = VisualDepthMask | VisualClassMask;
-                       static XVisualInfo vinfo = { .depth = 24, .c_class = DirectColor, };
+                       static XVisualInfo vinfo;
+                       memset(&vinfo, 0, sizeof(vinfo));
+                       vinfo.depth = 24;
+                       vinfo.c_class = TrueColor;
                        int nitems = 0;
                        XVisualInfo *vis_info = XGetVisualInfo(display, mask, &vinfo, &nitems);
                        vis = vis_info && nitems>0 ? vis_info[0].visual : 0;
index 2562727f8df90394bebcb8901fcd374af67082ed..846a843fca468e0eeb2a63ecf14bca02a0c68978 100644 (file)
@@ -21,6 +21,7 @@
 #     add $(call rules,$(call std-build,<name>,<dep>...))
 #     add deps to other call rules if they require the new library
 #     add config enables if other libraries use the new library
+#     add pc_<pkg>=<pkgcfg names> if needed for system build
 #
 
 TOPDIR ?= $(CURDIR)/..
@@ -52,10 +53,14 @@ unpack_bz2=tar -xjf $(1)
 unpack_xz=tar -xJf $(1)
 bld_depends=$(if $(ver_$(1)),$(call pkg-built,$(1)))
 bld_path=$(ver_$(1))/$(2)
-if_pkg=$(if $(ver_$(1)),$(2))
+if_pkg=$(if $(ver_$(1)),$(2),$(3))
 if_npkg=$(if $(ver_$(1)),,$(2))
-inc_path=$(call if_pkg,$(1),$(inc_$(1)))
+if_shr=$(if $(findstring $(1),$(shared_pkgs)),$(2),$(3))
+pkg_conf=$(call if_shr,$(1),$(foreach p,$(pc_$(1)), $(shell pkg-config 2> /dev/null $(2) $(p))))
+inc_path=$(call if_pkg,$(1),$(inc_$(1)), $(call pkg_conf,$(1),--cflags))
 ld_path=$(call if_pkg,$(1),-L$(call bld_path,$(1),$(2)) $(lib_$(1)))
+if_ena=$(if $(or $(ver_$(1)),$(findstring $(1),$(shared_pkgs))),$(2))
+if_want=$(if $(findstring x$(WANT_$(1)),xyes),$(2),$(3))
 
 #$(eval $(call std-build,pkg,deps...))
 #$(pkg.cflags) added as CFLAGS+=$(cflags) to pkg.vars
@@ -101,9 +106,20 @@ $(TARGETS):        $(BLD)
 $(BLD):
        mkdir $(BLD)
 
+# pkg-config names
+pc_libaom=aom
+pc_dav1d=dav1d
+pc_libwebp=libwebp libwebpmux
+pc_opus=opus
+pc_openjpeg=libopenjp2
+pc_libvorbis=vorbis vorbisenc
+pc_libvpx=vpx
+pc_x264=x264
+pc_x265=x265
+
 # vars first
 encore.cfg_vars= true ||
-esound.cfg_vars:= AUDIOFILE_CFLAGS="$(call inc_path,audiofile,libaudiofile) -laudiofile"
+esound.cfg_vars:= AUDIOFILE_CFLAGS="$(call inc_path,audiofile) -laudiofile"
 esound.cfg_vars+= AUDIOFILE_LIBS="$(call ld_path,audiofile,libaudiofile/.libs)"
 esound.cfg_params= --enable-shared=no --with-pic
 esound.mak_vars+= CFLAGS="" 
@@ -111,37 +127,36 @@ esound.ldflags=" -lm -lstdc++"
 fftw.cfg_params= --disable-fortran --enable-shared=no
 ffmpeg.cfg_params= \
        --enable-pthreads --enable-gpl --disable-ffplay \
-       $(if $(WANT_VAAPI),--enable-vaapi,--disable-vaapi) \
-       $(if $(WANT_VDPAU),--enable-vdpau,--disable-vdpau) \
-       $(if $(WANT_NV), --enable-nvenc --enable-nvdec) \
-       $(call if_pkg,twolame,--enable-libtwolame) \
-       $(call if_pkg,openjpeg,--enable-libopenjpeg) \
-       $(call if_pkg,lame,--enable-libmp3lame) \
-       $(call if_pkg,libaom,--enable-libaom) \
-       $(call if_pkg,dav1d,--enable-libdav1d) \
-       $(call if_pkg,libwebp,--enable-libwebp) \
-       $(call if_pkg,opus,--enable-libopus) \
-       $(call if_pkg,libvorbis,--enable-libvorbis) \
-       $(call if_pkg,libtheora,--enable-libtheora) \
-       $(call if_pkg,libvpx,--enable-libvpx) \
-       $(call if_pkg,x264,--enable-libx264) \
-       $(call if_pkg,x265,--enable-libx265) \
+       $(call if_want,VAAPI,--enable-vaapi,--disable-vaapi) \
+       $(call if_want,VDPAU,--enable-vdpau,--disable-vdpau) \
+       $(call if_want,NV, --enable-nvenc --enable-nvdec --enable-ffnvcodec) \
+       $(call if_ena,twolame,--enable-libtwolame) \
+       $(call if_ena,openjpeg,--enable-libopenjpeg) \
+       $(call if_ena,lame,--enable-libmp3lame) \
+       $(call if_ena,libaom,--enable-libaom) \
+       $(call if_ena,dav1d,--enable-libdav1d) \
+       $(call if_ena,libwebp,--enable-libwebp) \
+       $(call if_ena,opus,--enable-libopus) \
+       $(call if_ena,libvorbis,--enable-libvorbis) \
+       $(call if_ena,libtheora,--enable-libtheora) \
+       $(call if_ena,libvpx,--enable-libvpx) \
+       $(call if_ena,x264,--enable-libx264) \
+       $(call if_ena,x265,--enable-libx265) \
        --extra-cflags="-Wno-attributes \
-               $(if $(WANT_NV), $(inc_ffnvcodec)) \
-               $(call inc_path,twolame,libtwolame) \
-               $(call inc_path,lame,include) \
-               $(call inc_path,libaom,usr/local/include) \
-               $(call inc_path,dav1d,usr/local/include) \
-               $(call inc_path,libwebp,usr/local/include) \
-               $(call inc_path,openjpeg,src/lib/openjp2) \
-               $(call inc_path,libogg,include) \
-               $(call inc_path,opus,include) \
-               $(call inc_path,libvorbis,include) \
-               $(call inc_path,libtheora,include) \
+               $(call if_want,NV,$(inc_ffnvcodec)) \
+               $(call inc_path,twolame) \
+               $(call inc_path,lame) \
+               $(call inc_path,libaom) \
+               $(call inc_path,dav1d) \
+               $(call inc_path,libwebp) \
+               $(call inc_path,openjpeg) \
+               $(call inc_path,libogg) \
+               $(call inc_path,opus) \
+               $(call inc_path,libvorbis) \
+               $(call inc_path,libtheora) \
                $(call inc_path,libvpx) \
                $(call inc_path,x264) \
-               $(call inc_path,x265) \
-               $(call inc_path,x265,source)" \
+               $(call inc_path,x265)" \
        --extra-cxxflags="-D__STDC_CONSTANT_MACROS" \
        --pkg-config=true \
        --extra-libs="-Wl,--start-group \
@@ -158,6 +173,7 @@ ffmpeg.cfg_params= \
                $(call ld_path,libvpx) \
                $(call ld_path,x264) \
                $(call ld_path,x265) \
+               $(shared_libs) \
                -Wl,--end-group -lm -lstdc++ -pthread \
                $(EXTRA_LIBS)" $(FFMPEG_EXTRA_CFG) \
 
@@ -173,7 +189,7 @@ djbfft.mak_params?=; cd $(call bld_path,djbfft); ln -sf djbfft.a libdjbfft.a
 audiofile.cfg_params?=--enable-shared=no
 audiofile.mak_params?=LIBS="-lm -lstdc++"
 flac.cfg_params?= --enable-shared=no
-flac.cflags?="$(call inc_path,libogg,include) $(call ld_path,libogg,src/.libs)"
+flac.cflags?="$(call inc_path,libogg) $(call ld_path,libogg,src/.libs)"
 giflib.cfg_params=echo "exec true" > ./configure; chmod +x ./configure;
 ilmbase.cfg_vars= CFLAGS+=" -Wno-narrowing" CXXFLAGS+=" -Wno-narrowing"
 ilmbase.cfg_params?=--prefix=$(call bld_path,ilmbase,usr)
@@ -209,7 +225,7 @@ libjpeg.cfg_params?= --enable-shared=no
 libogg.cfg_params?= --enable-shared=no
 libraw1394.cfg_params?=  --enable-shared=no; ln -sf src libraw1394
 libtheora.cfg_vars?=PKG_CONFIG_PATH=$(call bld_path,libogg):$(call bld_path,libvorbis)
-libtheora.cflags?="$(call inc_path,libogg,include) $(call inc_path,libogg,src) $(call inc_path,libvorbis,include)"
+libtheora.cflags?="$(call inc_path,libogg) $(call inc_path,libvorbis)"
 libtheora.ldflags?="$(call ld_path,libvorbis,lib/.libs) $(call ld_path,libogg,src/.libs)"
 libtheora.cfg_params?= --disable-examples --disable-spec --enable-shared=no
 libuuid.cfg_params?=--enable-shared=no
@@ -298,7 +314,7 @@ $(call rules,$(call std-build,encore))
 $(call rules,$(call std-build,esound,audiofile))
 $(call rules,$(call std-build,ffmpeg, twolame lame openjpeg opus \
        libtheora x264 x265 libvpx libaom dav1d libwebp \
-       $(if $(WANT_NV), ffnvcodec)))
+       $(call if_want,NV, ffnvcodec)))
 $(call rules,$(call std-build,fftw))
 $(call rules,$(call std-build,flac,libogg))
 $(call rules,$(call std-build,giflib))