Ah, just run make clean and make in cinelerra directory,
now it starts and I can make few PNGs ....
---------- Пересланное сообщение ----------
Тема: Re: [Cin] How to add correctly BC_TumbleTextBox ?
Дата: Понедельник 16 марта 2020
Отправитель: Andrew Randrianasulu <[email protected]>
Получатель: "Cinelerra.GG" <[email protected]>
В сообщении от Monday 16 March 2020 19:01:27 Phyllis Smith написал(а):
> Turns out there are widgets and gadgets (old school parlance). Widgets
> usually involve a window base class, and gadgets usually involve a set of
> widgets or gadgets. A BC_TumbleTextBox is a gadget, which has a textbox
> widget and a tumbler widget. The "create_objects()" call is mandatory for
> gadgets. A gadget tries to create an organized set of widgets as a
> graphical component. It may have a window base class, and may need an
> add_subwindow... or (as with most of them) it may just be a group of
> objects, usually with a common x,y,w,h base class definition. For a
> BC_TumbleTextBox, just call create objects, and do not add_subwindow. The
> exact initialization order determines this, and can be variable. For
> instance, a popup menu, or a list box may need add_window, and also a
> create_objects to load the widget content prior to invoking the draw.
>
> It is frequently attractive (from a programming perspective) to add a
> pointer to the widgets and gadgets in the gui base class so that you can
> easily access them from the debugger. add_subwindow adds the subwindow to
> the gui subwindow list, and makes it part of the window hierarchy.
> Anything created and added with add_subwindow should probably not be
> deleted in the destructor. The destruction of the gui will delete it
> normally. You can delete a subwindow (lock the gui), and it is ok to do
> that if your intent to to re-factor the gui appearance after construction.
> Gadgets usually need to be deleted in the gui destructor since the object
> is not in the gui subwindow set. If you dont delete it, it wont cause an
> error, but it will be a memory leak.
>
> I tweaked/attached the patch for your review. It is not tested,
> gg
Thanks, I manually added it to source tree, with minor mod:
@@ -351,21 +351,30 @@ PNGUnit::~PNGUnit()
PNGConfigVideo::PNGConfigVideo(BC_WindowBase *parent_window, Asset *asset)
: BC_Window(_(PROGRAM_NAME ": Video Compression"),
parent_window->get_abs_cursor_x(1), parent_window->get_abs_cursor_y(1),
- xS(200), yS(100))
+ xS(200), yS(120))
{
this->parent_window = parent_window;
this->asset = asset;
+ use_alpha = 0;
+ compression = 0;
}
replaced alpha with use_alpha, otherwise it was not compileable.
But now just compiled cin fails to start from its bin directory!
LANG=C ./cin
Cinelerra Infinity - built: Mar 16 2020 01:05:34
git://git.cinelerra-gg.org/goodguy/cinelerra.git
(c) 2006-2019 Heroine Virtual Ltd. by Adam Williams
2007-2020 mods for Cinelerra-GG by W.P.Morrow aka goodguy
Cinelerra is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions. There is absolutely no warranty for Cinelerra.
cin: malloc.c:2395: sysmalloc: Assertion `(old_top == initial_top (av) &&
old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse
(old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
Аварийный останов
system-installed cin still works normally ...
>
> On Mon, Mar 16, 2020 at 5:29 AM Andrew Randrianasulu <
> [email protected]> wrote:
>
> > I tried to add png compression level into filepng.c
> >
> > But I did something stupid, and whole thing doesn't compile:
> >
> > root@slax:/dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra#
> > LANG=C make
> > g++ `cat i686/c_flags` -DMSGQUAL=filepng -c filepng.C -o i686/filepng.o
> > filepng.C: In member function 'virtual void
> > PNGConfigVideo::create_objects()':
> > filepng.C:370:49: error: no matching function for call to
> > 'PNGConfigVideo::add_subwindow(PNGCompression*)'
> > add_subwindow(new PNGCompression(this, x+50, y));
> > ^
> > In file included from
> > /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/bcsubwindow.h:26:0,
> > from
> > /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/bcbar.h:26,
> > from
> > /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/guicast.h:27,
> > from edit.h:30,
> > from filepng.C:23:
> > /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/bcwindowbase.h:276:17:
> > note: candidate: BC_WindowBase* BC_WindowBase::add_subwindow(BC_WindowBase*)
> > BC_WindowBase* add_subwindow(BC_WindowBase *subwindow);
> > ^
> > /dev/shm/tmp/cinelerra-goodguy-20200316/cinelerra-5.1/cinelerra/../guicast/bcwindowbase.h:276:17:
> > note: no known conversion for argument 1 from 'PNGCompression*' to
> > 'BC_WindowBase*'
> > At global scope:
> > cc1plus: warning: unrecognized command line option
> > '-Wno-stringop-truncation'
> > cc1plus: warning: unrecognized command line option '-Wno-format-overflow'
> > cc1plus: warning: unrecognized command line option '-Wno-format-truncation'
> > cc1plus: warning: unrecognized command line option '-Wno-stringop-overflow'
> > cc1plus: warning: unrecognized command line option
> > '-Wno-unknown-warning-option'
> > make: *** [i686/filepng.o] Error 1
> >
> > patch attached ....
> > --
> > Cin mailing list
> > [email protected]
> > https://lists.cinelerra-gg.org/mailman/listinfo/cin
> >
>
-------------------------------------------------------
diff --git a/cinelerra-5.1/cinelerra/asset.C b/cinelerra-5.1/cinelerra/asset.C
index fd6e97e..3e1778e 100644
--- a/cinelerra-5.1/cinelerra/asset.C
+++ b/cinelerra-5.1/cinelerra/asset.C
@@ -133,7 +133,8 @@ int Asset::init_values()
ac3_bitrate = 128;
png_use_alpha = 0;
-
+ png_compression = 0;
+
exr_use_alpha = 0;
exr_compression = 0;
@@ -279,6 +280,7 @@ void Asset::copy_format(Asset *asset, int do_index)
ac3_bitrate = asset->ac3_bitrate;
png_use_alpha = asset->png_use_alpha;
+ png_compression = asset->png_compression;
exr_use_alpha = asset->exr_use_alpha;
exr_compression = asset->exr_compression;
@@ -803,6 +805,7 @@ void Asset::load_defaults(BC_Hash *defaults,
ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
+ png_compression = GET_DEFAULT("PNG_COMPRESSION", png_compression);
exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
@@ -899,6 +902,7 @@ void Asset::save_defaults(BC_Hash *defaults,
UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
+ UPDATE_DEFAULT("PNG_COMPRESSION", png_compression);
UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
diff --git a/cinelerra-5.1/cinelerra/asset.h b/cinelerra-5.1/cinelerra/asset.h
index 096ea98..13ebaf9 100644
--- a/cinelerra-5.1/cinelerra/asset.h
+++ b/cinelerra-5.1/cinelerra/asset.h
@@ -189,6 +189,7 @@ public:
// for jpeg compression
int jpeg_quality;
+
// for mpeg video compression
int vmpeg_iframe_distance;
int vmpeg_progressive;
@@ -220,7 +221,7 @@ public:
// PNG video compression
int png_use_alpha;
-
+ int png_compression;
// EXR video compression
int exr_use_alpha;
int exr_compression;
diff --git a/cinelerra-5.1/cinelerra/filepng.C b/cinelerra-5.1/cinelerra/filepng.C
index f632607..f99e9d1 100644
--- a/cinelerra-5.1/cinelerra/filepng.C
+++ b/cinelerra-5.1/cinelerra/filepng.C
@@ -230,7 +230,7 @@ int FilePNG::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
info_ptr = png_create_info_struct(png_ptr);
png_set_write_fn(png_ptr, data,
(png_rw_ptr)write_function, (png_flush_ptr)flush_function);
- png_set_compression_level(png_ptr, 5);
+ png_set_compression_level(png_ptr, asset->png_compression);
png_set_IHDR(png_ptr, info_ptr, asset->width, asset->height, 8,
asset->png_use_alpha ? PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB,
@@ -351,21 +351,30 @@ PNGUnit::~PNGUnit()
PNGConfigVideo::PNGConfigVideo(BC_WindowBase *parent_window, Asset *asset)
: BC_Window(_(PROGRAM_NAME ": Video Compression"),
parent_window->get_abs_cursor_x(1), parent_window->get_abs_cursor_y(1),
- xS(200), yS(100))
+ xS(200), yS(120))
{
this->parent_window = parent_window;
this->asset = asset;
+ use_alpha = 0;
+ compression = 0;
}
PNGConfigVideo::~PNGConfigVideo()
{
+ delete compression;
}
void PNGConfigVideo::create_objects()
{
lock_window("PNGConfigVideo::create_objects");
+ BC_Title *title;
int x = xS(10), y = yS(10);
- add_subwindow(new PNGUseAlpha(this, x, y));
+ add_subwindow(use_alpha = new PNGUseAlpha(this, x, y));
+ y += use_alpha->get_h() + yS(10);
+ add_subwindow(title = new BC_Title(x,y,_("Compression:")));
+ int x1 = x + title->get_w() + xS(10);
+ compression = new PNGCompression(this, x1, y);
+ compression->create_objects();
add_subwindow(new BC_OKButton(this));
show_window(1);
unlock_window();
@@ -390,3 +399,15 @@ int PNGUseAlpha::handle_event()
return 1;
}
+PNGCompression::PNGCompression(PNGConfigVideo *gui, int x, int y)
+ : BC_TumbleTextBox(gui, (int64_t)gui->asset->png_compression,
+ (int64_t)0, (int64_t)9, x, y, xS(40))
+{
+ this->gui = gui;
+}
+
+int PNGCompression::handle_event()
+{
+ gui->asset->png_compression = atol(get_text());
+ return 1;
+}
diff --git a/cinelerra-5.1/cinelerra/filepng.h b/cinelerra-5.1/cinelerra/filepng.h
index 2263bc3..71d123c 100644
--- a/cinelerra-5.1/cinelerra/filepng.h
+++ b/cinelerra-5.1/cinelerra/filepng.h
@@ -29,6 +29,10 @@
#include "filelist.h"
#include "vframe.inc"
+class PNGUseAlpha;
+class PNGCompression;
+
+
class FilePNG : public FileList
{
public:
@@ -77,6 +81,9 @@ public:
BC_WindowBase *parent_window;
Asset *asset;
+
+ PNGUseAlpha *use_alpha;
+ PNGCompression *compression;
};
@@ -88,5 +95,12 @@ public:
PNGConfigVideo *gui;
};
+class PNGCompression : public BC_TumbleTextBox
+{
+public:
+ PNGCompression(PNGConfigVideo *gui, int x, int y);
+ int handle_event();
+ PNGConfigVideo *gui;
+};
#endif
--
Cin mailing list
[email protected]
https://lists.cinelerra-gg.org/mailman/listinfo/cin