From 8f0d97d1da0cd4cfcacf76c2c1788204749b6757 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Thu, 1 Feb 2018 13:50:09 -0700 Subject: [PATCH] xfer parallel build, reload vwindow, snap/grab fixes, shader memeory leak --- cinelerra-5.1/cinelerra/assetpopup.C | 8 +- cinelerra-5.1/cinelerra/mwindow.C | 4 + cinelerra-5.1/cinelerra/vwindow.C | 8 +- cinelerra-5.1/cinelerra/vwindow.h | 1 + cinelerra-5.1/configure.ac | 8 +- cinelerra-5.1/guicast/Makefile | 17 ++- cinelerra-5.1/guicast/bccmdl.py | 121 ++++++++++++--------- cinelerra-5.1/guicast/{xfer.C => bcxfer.C} | 0 cinelerra-5.1/guicast/{xfer.h => bcxfer.h} | 0 cinelerra-5.1/guicast/vframe3d.C | 1 + cinelerra-5.1/guicast/xfer/Makefile | 18 +++ 11 files changed, 120 insertions(+), 66 deletions(-) rename cinelerra-5.1/guicast/{xfer.C => bcxfer.C} (100%) rename cinelerra-5.1/guicast/{xfer.h => bcxfer.h} (100%) create mode 100644 cinelerra-5.1/guicast/xfer/Makefile diff --git a/cinelerra-5.1/cinelerra/assetpopup.C b/cinelerra-5.1/cinelerra/assetpopup.C index d39aaa13..1afb19e4 100644 --- a/cinelerra-5.1/cinelerra/assetpopup.C +++ b/cinelerra-5.1/cinelerra/assetpopup.C @@ -809,7 +809,8 @@ int SnapshotMenuItem::handle_event() double position = edl->local_session->get_selectionstart(1); int64_t source_position = (int64_t)(position * edl->get_frame_rate()); - ret = render_engine.vrender->process_buffer(frame, source_position, 0); + ret = !render_engine.vrender ? 1 : + render_engine.vrender->process_buffer(frame, source_position, 0); if( !ret ) ret = file.write_video_buffer(1); file.close_file(); @@ -965,6 +966,7 @@ int GrabshotPopup::grab_event(XEvent *event) int cw = lx1-lx0, ch = ly1-ly0; hide_window(); sync_display(); + grab_thread->done = 1; MWindow *mwindow = grab_thread->mwindow; Preferences *preferences = mwindow->preferences; @@ -996,12 +998,15 @@ int GrabshotPopup::grab_event(XEvent *event) asset->format = FILE_PPM; break; } + // no odd dimensions int rw = get_root_w(0), rh = get_root_h(0); if( cx < 0 ) { cw += cx; cx = 0; } if( cy < 0 ) { ch += cy; cy = 0; } if( cx+cw > rw ) cw = rw-cx; if( cy+ch > rh ) ch = rh-cy; + if( !cw || !ch ) return 1; + VFrame vframe(cw,ch, BC_RGB888); if( cx+cw < rw ) ++cw; if( cy+ch < rh ) ++ch; @@ -1040,7 +1045,6 @@ int GrabshotPopup::grab_event(XEvent *event) asset->remove_user(); } - grab_thread->done = 1; return 1; } diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 1f69fd50..d14f228c 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -3280,6 +3280,10 @@ void MWindow::update_project(int load_mode) if( !vwindow->is_running() ) continue; vwindow->close_window(); } + for( int i=0; ivwindow_edls.size(); ++i ) { + VWindow *vwindow = get_viewer(1, -1); + vwindow->change_source(i); + } if(debug) PRINT_TRACE select_zwindow(0); close_mixers(); diff --git a/cinelerra-5.1/cinelerra/vwindow.C b/cinelerra-5.1/cinelerra/vwindow.C index 8de4eb73..1bb3f0c3 100644 --- a/cinelerra-5.1/cinelerra/vwindow.C +++ b/cinelerra-5.1/cinelerra/vwindow.C @@ -137,8 +137,6 @@ void VWindow::handle_done_event(int result) } } - - BC_Window* VWindow::new_gui() { //printf("VWindow::create_objects 1\n"); @@ -164,6 +162,12 @@ BC_Window* VWindow::new_gui() return gui; } +void VWindow::handle_close_event(int result) +{ + delete playback_engine; + playback_engine = 0; +} + EDL* VWindow::get_edl() { diff --git a/cinelerra-5.1/cinelerra/vwindow.h b/cinelerra-5.1/cinelerra/vwindow.h index a9ee980a..a858d5c0 100644 --- a/cinelerra-5.1/cinelerra/vwindow.h +++ b/cinelerra-5.1/cinelerra/vwindow.h @@ -41,6 +41,7 @@ public: ~VWindow(); void handle_done_event(int result); + void handle_close_event(int result); BC_Window* new_gui(); void load_defaults(); diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac index dcfd41d4..70326a93 100644 --- a/cinelerra-5.1/configure.ac +++ b/cinelerra-5.1/configure.ac @@ -9,7 +9,13 @@ AC_LANG_C AC_PROG_CXX CFG_CFLAGS+=" -fno-omit-frame-pointer -fno-math-errno -fno-signed-zeros" -CFG_CFLAGS+=" -pthread -Wall -Wno-unused-result -Wno-format-truncation" +CFG_CFLAGS+=" -pthread -Wall" +# misguided pedantic warnings +CFG_CFLAGS+=" -Wno-unused-result" +CFG_CFLAGS+=" -Wno-stringop-truncation" +CFG_CFLAGS+=" -Wno-stringop-overflow" +CFG_CFLAGS+=" -Wno-format-truncation" +CFG_CFLAGS+=" -Wno-format-overflow" CFG_CFLAGS+=" -D__STDC_CONSTANT_MACROS" CFG_CFLAGS+=" -D__STDC_LIMIT_MACROS" CFG_CFLAGS+=" -DPNG_SKIP_SETJMP_CHECK=1" diff --git a/cinelerra-5.1/guicast/Makefile b/cinelerra-5.1/guicast/Makefile index 43404b59..c1e03659 100644 --- a/cinelerra-5.1/guicast/Makefile +++ b/cinelerra-5.1/guicast/Makefile @@ -65,7 +65,6 @@ OBJS = \ $(OBJDIR)/bcwindowbase.o \ $(OBJDIR)/bcwindowdraw.o \ $(OBJDIR)/bcwindowevents.o \ - $(OBJDIR)/bcxfer.o \ $(OBJDIR)/condition.o \ $(OBJDIR)/errorbox.o \ $(OBJDIR)/filesystem.o \ @@ -83,6 +82,7 @@ OBJS = \ OUTPUT = $(OBJDIR)/libguicast.a UTILS = $(OBJDIR)/bootstrap $(OBJDIR)/pngtoh $(OBJDIR)/pngtoraw +BCXFER = xfer/$(OBJDIR)/xfer.o CFLAGS += -I/usr/include/freetype2 @@ -91,14 +91,13 @@ $(shell echo $(OBJS) > $(OBJDIR)/objs) all: $(OUTPUT) $(UTILS) -$(OBJDIR)/bcxfer.o: bcxfer.C xfer.C xfer.h - $(CXX) `cat $(OBJDIR)/c_flags` -O3 -c $< -o $@ +$(BCXFER): bccmdl.py bcxfer.C bcxfer.h + python2.7 < ./bccmdl.py + +make -C xfer -bcxfer.C: bccmdl.py - python2.7 < ./bccmdl.py > bcxfer.C - -$(OUTPUT): $(OBJS) - ar rcs $(OUTPUT) `cat $(OBJDIR)/objs` +$(OUTPUT): $(OBJS) $(BCXFER) + ar rc $(OUTPUT) `cat $(OBJDIR)/objs` `ls -1 $(dir $(BCXFER))/xfer*.o` + ar rs $(OUTPUT) `ls -1 $(dir $(BCXFER))/xfer*.o` $(OBJDIR)/bootstrap: gcc -O2 $(BOOTSTRAPFLAGS) bootstrap.c -o $(OBJDIR)/bootstrap @@ -111,7 +110,7 @@ $(OBJDIR)/pngtoraw: pngtoraw.c clean: rm -rf $(OBJDIR) - rm -f bcxfer.C + make -C xfer clean install: diff --git a/cinelerra-5.1/guicast/bccmdl.py b/cinelerra-5.1/guicast/bccmdl.py index 4c184bd0..bae50c50 100755 --- a/cinelerra-5.1/guicast/bccmdl.py +++ b/cinelerra-5.1/guicast/bccmdl.py @@ -554,21 +554,21 @@ def is_planar(nm): def is_float(nm): return nm in ["bc_rgb_float", "bc_rgba_float", "bc_rgb_floatp", "bc_rgba_floatp", ] -def gen_xfer_proto(pfx, cls, fr_cmdl, to_cmdl): +def gen_xfer_proto(fd, pfx, cls, fr_cmdl, to_cmdl): global dtype, ctype - print "%svoid %sxfer_%s_to_%s" % (pfx, cls, fr_cmdl[3:], to_cmdl[3:]), + print >>fd, "%svoid %sxfer_%s_to_%s" % (pfx, cls, fr_cmdl[3:], to_cmdl[3:]), ityp = dtype[fr_cmdl]; fr_typ = ctype[ityp]; otyp = dtype[to_cmdl]; to_typ = ctype[otyp]; - print "(unsigned y0, unsigned y1)", + print >>fd, "(unsigned y0, unsigned y1)", -def gen_xfer_fn(fr_cmdl, to_cmdl): +def gen_xfer_fn(fd, fr_cmdl, to_cmdl): global layout, dtype, adata ityp = dtype[fr_cmdl]; otyp = dtype[to_cmdl] if( ityp is None or otyp is None ): return # xfr fn header - gen_xfer_proto("", class_qual, fr_cmdl, to_cmdl); + gen_xfer_proto(fd, "", class_qual, fr_cmdl, to_cmdl); # xfr fn body - print "{" + print >>fd, "{" # loops / pointer preload in_xfer = "flat" if not is_planar(fr_cmdl) else \ fr_cmdl[3:] if is_yuv(fr_cmdl) else \ @@ -576,105 +576,122 @@ def gen_xfer_fn(fr_cmdl, to_cmdl): out_xfer = "flat" if not is_planar(to_cmdl) else \ to_cmdl[3:] if is_yuv(to_cmdl) else \ "rgbp" if not has_alpha(to_cmdl) else "rgbap" - print " xfer_%s_row_out(%s) xfer_%s_row_in(%s)" % \ + print >>fd, " xfer_%s_row_out(%s) xfer_%s_row_in(%s)" % \ (out_xfer, ctype[otyp], in_xfer, ctype[ityp],) # load inp if( is_float(to_cmdl) and is_yuv(fr_cmdl) ): - for ic in layout[fr_cmdl]: print "%s" % (base[ic][ityp]['r']), + for ic in layout[fr_cmdl]: print >>fd, "%s" % (base[ic][ityp]['r']), if( ityp == "i8" ): - print "\n float r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);", + print >>fd, "\n float r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);", elif( ityp == "i16" ): - print "\n float r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);", + print >>fd, "\n float r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);", if( has_alpha(fr_cmdl) or has_alpha(to_cmdl) ): if( not has_alpha(fr_cmdl) ): - print " z_float fa = 1;", + print >>fd, " z_float fa = 1;", elif( ityp == "i8" ): - print " float fa = fclp(a,256);", + print >>fd, " float fa = fclp(a,256);", elif( ityp == "i16" ): - print " float fa = fclp(a,65536);", + print >>fd, " float fa = fclp(a,65536);", else: - for ic in layout[fr_cmdl]: print "%s" % (base[ic][otyp]['r']), + for ic in layout[fr_cmdl]: print >>fd, "%s" % (base[ic][otyp]['r']), if( has_alpha(to_cmdl) and not has_alpha(fr_cmdl) ): - print "%s" % (adata[otyp]), - print "" + print >>fd, "%s" % (adata[otyp]), + print >>fd, "" # xfer if( is_rgb(fr_cmdl) and is_yuv(to_cmdl) ): if( otyp == "i8" ): - print " int32_t y, u, v; YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v);" + print >>fd, " int32_t y, u, v; YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v);" elif( otyp == "i16" ): - print " int32_t y, u, v; YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v);" + print >>fd, " int32_t y, u, v; YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v);" elif( is_yuv(fr_cmdl) and is_rgb(to_cmdl)): if( otyp == "i8" ): - print " int32_t r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);" + print >>fd, " int32_t r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);" elif( otyp == "i16" ): - print " int32_t r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);" + print >>fd, " int32_t r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);" # blend if( has_bgcolor(fr_cmdl,to_cmdl) ): - print "%s" % (base["bbg"][otyp]) + print >>fd, "%s" % (base["bbg"][otyp]) elif( has_alpha(fr_cmdl) and not has_alpha(to_cmdl) ): if( is_rgb(to_cmdl) ): - print "%s" % (base["brgb"][otyp]) + print >>fd, "%s" % (base["brgb"][otyp]) elif( is_yuv(to_cmdl) ): - print "%s" % (base["byuv"][otyp]) + print >>fd, "%s" % (base["byuv"][otyp]) # store out for oc in layout[to_cmdl]: - print "%s" % (base[oc][otyp]['w']), - print "xfer_end" - print "}" - print "" + print >>fd, "%s" % (base[oc][otyp]['w']), + print >>fd, "xfer_end" + print >>fd, "}" + print >>fd, "" # output code file class_qual = "BC_Xfer::" - -print "#include \"xfer.h\"" -print "" +xfn = "xfer/xfer.h" +fd = open(xfn, "w") +xid = "".join([chr(x) if chr(x).isalnum() else '_' for x in range(256)]) +xid = "__" + xfn.upper()[xfn.rfind("/")+1:].translate("".join(xid)) + "__" +print >>fd, "#ifndef %s" % xid +print >>fd, "#define %s" % xid +print >>fd, "" +xfd = open("bcxfer.h") +fd.write(xfd.read()) +xfd.close() for fr_cmdl in cmodels: ityp = dtype[fr_cmdl] for to_cmdl in cmodels: otyp = dtype[to_cmdl] if( is_specialized(fr_cmdl, to_cmdl) ): - print " void %s(unsigned y0, unsigned y1);" % (special[(fr_cmdl, to_cmdl)]) + print >>fd, " void %s(unsigned y0, unsigned y1);" % (special[(fr_cmdl, to_cmdl)]) continue if( ityp is None or otyp is None ): continue - gen_xfer_proto(" ", "", fr_cmdl, to_cmdl); - print ";" + gen_xfer_proto(fd, " ", "", fr_cmdl, to_cmdl); + print >>fd, ";" # end of class definition -print "};" -print "" +print >>fd, "};" +print >>fd, "" +print >>fd, "#endif" +fd.close() +xfn = xfn[:xfn.rfind(".h")] # xfer functions for fr_cmdl in cmodels: + fd = open(xfn + "_" + fr_cmdl + ".C", "w") + print >>fd, "#include \"xfer.h\"" + print >>fd, "" for to_cmdl in cmodels: - gen_xfer_fn(fr_cmdl, to_cmdl) + gen_xfer_fn(fd, fr_cmdl, to_cmdl) + fd.close() +fd = open(xfn + ".C", "w") # transfer switch -print "" -print "void %sxfer()" % class_qual -print "{" +print >>fd, "#include \"xfer.h\"" +print >>fd, "" +print >>fd, "void %sxfer()" % class_qual +print >>fd, "{" mx_no = mx_bcmdl + 1 -print " static xfer_fn xfns[%d][%d] = {" % (mx_no, mx_no) +print >>fd, " static xfer_fn xfns[%d][%d] = {" % (mx_no, mx_no) for fr_no in range(mx_no): fr_cmdl = bcmodels.get(fr_no) ityp = dtype[fr_cmdl] - print " { // %s" % (fr_cmdl.upper() if ityp else "None") + print >>fd, " { // %s" % (fr_cmdl.upper() if ityp else "None") n = 0 for to_no in range(mx_no): to_cmdl = bcmodels.get(to_no) otyp = dtype[to_cmdl] xfn = special[(fr_cmdl, to_cmdl)] if( is_specialized(fr_cmdl, to_cmdl) ) else \ "xfer_%s_to_%s" % (fr_cmdl[3:], to_cmdl[3:]) if ( ityp and otyp ) else None - if( n > 72 ): print ""; n = 0 - if( n == 0 ): print " ",; n += 4 + if( n > 72 ): print >>fd, ""; n = 0 + if( n == 0 ): print >>fd, " ",; n += 4 fn = "&%s%s" % (class_qual, xfn) if( xfn ) else "0" - print "%s, " % (fn), + print >>fd, "%s, " % (fn), n += len(fn) + 3 - print "}, " -print " }; " -print " xfn = xfns[in_colormodel][out_colormodel];" -print " xfer_slices(out_w*out_h/0x80000+1);" -print "}" -print "" -print "#include \"xfer.C\"" -print "" + print >>fd, "}, " +print >>fd, " }; " +print >>fd, " xfn = xfns[in_colormodel][out_colormodel];" +print >>fd, " xfer_slices(out_w*out_h/0x80000+1);" +print >>fd, "}" +print >>fd, "" +print >>fd, "#include \"bcxfer.C\"" +print >>fd, "" +fd.close() diff --git a/cinelerra-5.1/guicast/xfer.C b/cinelerra-5.1/guicast/bcxfer.C similarity index 100% rename from cinelerra-5.1/guicast/xfer.C rename to cinelerra-5.1/guicast/bcxfer.C diff --git a/cinelerra-5.1/guicast/xfer.h b/cinelerra-5.1/guicast/bcxfer.h similarity index 100% rename from cinelerra-5.1/guicast/xfer.h rename to cinelerra-5.1/guicast/bcxfer.h diff --git a/cinelerra-5.1/guicast/vframe3d.C b/cinelerra-5.1/guicast/vframe3d.C index 8d5f88e8..35f1ac69 100644 --- a/cinelerra-5.1/guicast/vframe3d.C +++ b/cinelerra-5.1/guicast/vframe3d.C @@ -413,6 +413,7 @@ unsigned int VFrame::make_shader(const char **fragments, ...) } //printf("VFrame::make_shader\n%s\n", program); + delete [] program; #endif return result; } diff --git a/cinelerra-5.1/guicast/xfer/Makefile b/cinelerra-5.1/guicast/xfer/Makefile new file mode 100644 index 00000000..0a289010 --- /dev/null +++ b/cinelerra-5.1/guicast/xfer/Makefile @@ -0,0 +1,18 @@ +export TOPDIR ?= $(CURDIR)/../.. +include $(TOPDIR)/global_config + +$(shell mkdir -p $(OBJDIR) ) +$(shell echo $(CFLAGS) > $(OBJDIR)/c_flags) + +OUTPUT := $(OBJDIR)/xfer.o + +all: $(OUTPUT) + +clean: + rm -rf $(OBJDIR) xfer*.[Ch] + +$(OBJDIR)/%.o: %.C + $(CXX) -I.. `cat $(OBJDIR)/c_flags` -O3 -DMSGQUAL=$* -c $< -o $@ + +$(OUTPUT): $(patsubst %.C,$(OBJDIR)/%.o,$(wildcard *.C)) + -- 2.26.2