From: Good Guy Date: Tue, 7 May 2019 14:52:16 +0000 (-0600) Subject: add color3way clrbtns, repair sw fallback on hw accel not avail X-Git-Tag: 2019-08~56 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=f890683b11652fc31712acd0d7317a1b235a314e;p=goodguy%2Fcinelerra.git add color3way clrbtns, repair sw fallback on hw accel not avail --- diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C index 33941868..3bb9dd80 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.C +++ b/cinelerra-5.1/cinelerra/ffmpeg.C @@ -349,8 +349,9 @@ AVHWDeviceType FFStream::decode_hw_activate() return AV_HWDEVICE_TYPE_NONE; } -void FFStream::decode_hw_format(AVCodec *decoder, AVHWDeviceType type) +int FFStream::decode_hw_format(AVCodec *decoder, AVHWDeviceType type) { + return 0; } int FFStream::decode_activate() @@ -379,9 +380,10 @@ int FFStream::decode_activate() eprintf(_("cant allocate codec context\n")); ret = AVERROR(ENOMEM); } - if( ret >= 0 && hw_type != AV_HWDEVICE_TYPE_NONE ) - decode_hw_format(decoder, hw_type); - + if( ret >= 0 && hw_type != AV_HWDEVICE_TYPE_NONE ) { + ret = decode_hw_format(decoder, hw_type); + if( !ret ) hw_type = AV_HWDEVICE_TYPE_NONE; + } if( ret >= 0 ) { avcodec_parameters_to_context(avctx, st->codecpar); if( !av_dict_get(copts, "threads", NULL, 0) ) @@ -1027,8 +1029,9 @@ AVHWDeviceType FFVideoStream::decode_hw_activate() return type; } -void FFVideoStream::decode_hw_format(AVCodec *decoder, AVHWDeviceType type) +int FFVideoStream::decode_hw_format(AVCodec *decoder, AVHWDeviceType type) { + int ret = 0; hw_pix_fmt = AV_PIX_FMT_NONE; for( int i=0; ; ++i ) { const AVCodecHWConfig *config = avcodec_get_hw_config(decoder, i); @@ -1046,13 +1049,16 @@ void FFVideoStream::decode_hw_format(AVCodec *decoder, AVHWDeviceType type) if( hw_pix_fmt >= 0 ) { hw_pixfmt = hw_pix_fmt; avctx->get_format = get_hw_format; - int ret = av_hwdevice_ctx_create(&hw_device_ctx, type, 0, 0, 0); - if( ret >= 0 ) + ret = av_hwdevice_ctx_create(&hw_device_ctx, type, 0, 0, 0); + if( ret >= 0 ) { avctx->hw_device_ctx = av_buffer_ref(hw_device_ctx); + ret = 1; + } else ff_err(ret, "Failed HW device create.\ndev:%s\n", av_hwdevice_get_type_name(type)); } + return ret; } AVHWDeviceType FFVideoStream::encode_hw_activate(const char *hw_dev) diff --git a/cinelerra-5.1/cinelerra/ffmpeg.h b/cinelerra-5.1/cinelerra/ffmpeg.h index 9bfd268a..b4867b8e 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.h +++ b/cinelerra-5.1/cinelerra/ffmpeg.h @@ -83,7 +83,7 @@ public: virtual int encode_activate(); virtual int decode_activate(); virtual AVHWDeviceType decode_hw_activate(); - virtual void decode_hw_format(AVCodec *decoder, AVHWDeviceType type); + virtual int decode_hw_format(AVCodec *decoder, AVHWDeviceType type); virtual int write_packet(FFPacket &pkt); int read_packet(); int seek(int64_t no, double rate); @@ -235,7 +235,7 @@ public: int is_video() { return 1; } int decode_frame(AVFrame *frame); AVHWDeviceType decode_hw_activate(); - void decode_hw_format(AVCodec *decoder, AVHWDeviceType type); + int decode_hw_format(AVCodec *decoder, AVHWDeviceType type); AVHWDeviceType encode_hw_activate(const char *hw_dev); int encode_hw_write(FFrame *picture); int encode_frame(AVFrame *frame); diff --git a/cinelerra-5.1/plugins/color3way/color3waywindow.C b/cinelerra-5.1/plugins/color3way/color3waywindow.C index 54705c95..78203e86 100644 --- a/cinelerra-5.1/plugins/color3way/color3waywindow.C +++ b/cinelerra-5.1/plugins/color3way/color3waywindow.C @@ -35,12 +35,11 @@ - Color3WayWindow::Color3WayWindow(Color3WayMain *plugin) : PluginClientWindow(plugin, plugin->w, plugin->h, - 500, + 680, 370, 1) { @@ -137,9 +136,9 @@ void Color3WaySection::create_objects() _("Midtones"), _("Highlights") }; + int w1 = w - (CLEAR_BTN_WIDTH + margin * 2); - - gui->add_tool(title = new BC_Title(x + w / 2 - + gui->add_tool(title = new BC_Title(x + w1 / 2 - gui->get_text_width(MEDIUMFONT, titles[section]) / 2, y, titles[section])); @@ -150,8 +149,10 @@ void Color3WaySection::create_objects() &plugin->config.hue_y[section], x, y, - w / 2, + w1 / 2, section)); + gui->add_tool(pointClr = new Color3WaySliderClrSection(plugin, gui, + x + w1 + margin, y, CLEAR_BTN_WIDTH, RESET_POINT, section)); y += point->get_h() + margin; gui->add_tool(value_title = new BC_Title(x, y, _("Value:"))); @@ -161,8 +162,10 @@ void Color3WaySection::create_objects() &plugin->config.value[section], x, y, - w, + w1, section)); + gui->add_tool(valueClr = new Color3WaySliderClrSection(plugin, gui, + x + w1 + margin, y, CLEAR_BTN_WIDTH, RESET_VALUE, section)); y += value->get_h() + margin; gui->add_tool(sat_title = new BC_Title(x, y, _("Saturation:"))); @@ -172,8 +175,10 @@ void Color3WaySection::create_objects() &plugin->config.saturation[section], x, y, - w, + w1, section)); + gui->add_tool(saturationClr = new Color3WaySliderClrSection(plugin, gui, + x + w1 + margin, y, CLEAR_BTN_WIDTH, RESET_SATURATION, section)); y += saturation->get_h() + margin; gui->add_tool(reset = new Color3WayResetSection(plugin, @@ -204,23 +209,29 @@ int Color3WaySection::reposition_window(int x, int y, int w, int h) this->y = y; this->w = w; this->h = h; + int w1 = w - (CLEAR_BTN_WIDTH + margin * 2); - title->reposition_window(x + w / 2 - + title->reposition_window(x + w1 / 2 - title->get_w() / 2, title->get_y()); - point->reposition_window(x, point->get_y(), w / 2); + point->reposition_window(x, point->get_y(), w1 / 2); + pointClr->reposition_window(x + w1 + margin, point->get_y()); y = point->get_y() + point->get_h() + margin; + value_title->reposition_window(x, y); y += value_title->get_h() + margin; - value->reposition_window(x, y, w, value->get_h()); - value->set_pointer_motion_range(w); + value->reposition_window(x, y, w1, value->get_h()); + value->set_pointer_motion_range(w1); + valueClr->reposition_window(x + w1 + margin, y); y += value->get_h() + margin; sat_title->reposition_window(x, y); y += sat_title->get_h() + margin; - saturation->reposition_window(x, y, w, saturation->get_h()); - saturation->set_pointer_motion_range(w); + saturation->reposition_window(x, y, w1, saturation->get_h()); + saturation->set_pointer_motion_range(w1); + saturationClr->reposition_window(x + w1 + margin, y); y += saturation->get_h() + margin; + reset->reposition_window(x, y); y += reset->get_h() + margin; balance->reposition_window(x, y); @@ -370,7 +381,7 @@ void Color3WayPoint::draw_face(int flash, int flush) // set_color(BLACK); // draw_arc(0, 0, radius * 2, radius * 2, 45, 180); -// +// // set_color(MEGREY); // draw_arc(0, 0, radius * 2, radius * 2, 45, -180); @@ -659,6 +670,45 @@ int Color3WayResetSection::handle_event() +Color3WaySliderClrSection::Color3WaySliderClrSection(Color3WayMain *plugin, + Color3WayWindow *gui, + int x, + int y, + int w, + int clear, + int section) + : BC_GenericButton(x, y, w, _("⌂")) +{ + this->plugin = plugin; + this->gui = gui; + this->clear = clear; + this->section = section; +} +Color3WaySliderClrSection::~Color3WaySliderClrSection() +{ +} +int Color3WaySliderClrSection::handle_event() +{ + switch(clear) { + case RESET_POINT : + plugin->config.hue_x[section] = 0; + plugin->config.hue_y[section] = 0; + break; + case RESET_VALUE : plugin->config.value[section] = 0; + break; + case RESET_SATURATION : plugin->config.saturation[section] = 0; + break; + } + if(plugin->copy_to_all[section]) plugin->config.copy_to_all(section); + plugin->send_configure_change(); + gui->update(); + return 1; +} + + + + + Color3WayCopySection::Color3WayCopySection(Color3WayMain *plugin, Color3WayWindow *gui, int x, diff --git a/cinelerra-5.1/plugins/color3way/color3waywindow.h b/cinelerra-5.1/plugins/color3way/color3waywindow.h index 70dc3759..6c6d728b 100644 --- a/cinelerra-5.1/plugins/color3way/color3waywindow.h +++ b/cinelerra-5.1/plugins/color3way/color3waywindow.h @@ -30,6 +30,7 @@ class Color3WayPreserve; class Color3WayLock; class Color3WayWhite; class Color3WayReset; +class Color3WaySliderClr; class Color3WayWindow; @@ -40,6 +41,11 @@ class Color3WayWindow; #include "color3way.h" #include "pluginclient.h" +#define CLEAR_BTN_WIDTH 50 + +#define RESET_POINT 1 +#define RESET_VALUE 2 +#define RESET_SATURATION 3 class Color3WayPoint : public BC_SubWindow { @@ -135,6 +141,26 @@ public: int section; }; + +class Color3WaySliderClrSection : public BC_GenericButton +{ +public: + Color3WaySliderClrSection(Color3WayMain *plugin, + Color3WayWindow *gui, + int x, + int y, + int w, + int clear, + int section); + ~Color3WaySliderClrSection(); + int handle_event(); + Color3WayMain *plugin; + Color3WayWindow *gui; + int section; + int clear; +}; + + class Color3WayBalanceSection : public BC_GenericButton { public: @@ -190,6 +216,7 @@ public: Color3WayResetSection *reset; Color3WayBalanceSection *balance; Color3WayCopySection *copy; + Color3WaySliderClrSection *pointClr, *valueClr, *saturationClr; };