Projects
home:jnweiger
dvswitch-git
mfade_area.diff
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File mfade_area.diff of Package dvswitch-git
--- src/mixer.cpp | 15 +++++++++++---- src/mixer.hpp | 3 ++- src/mixer_window.cpp | 33 +++++++++++++++++++++++++++++---- src/mixer_window.hpp | 4 ++++ src/video_effect.c | 20 ++++++++++++++++++-- src/video_effect.h | 3 ++- 6 files changed, 66 insertions(+), 12 deletions(-) Index: dvswitch-0.9-1-da15ba4/src/video_effect.c =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/video_effect.c +++ dvswitch-0.9-1-da15ba4/src/video_effect.c @@ -289,11 +289,12 @@ void video_effect_pic_in_pic(struct raw_ } } void video_effect_fade(struct raw_frame_ref dest, struct raw_frame_ref sec, - uint8_t scale) + uint8_t scale, + uint8_t area) { int x, y, plane; uint8_t *ptr_d, *ptr_s; uint16_t tmp; int width, height; @@ -313,13 +314,28 @@ void video_effect_fade(struct raw_frame_ width >>= chroma_shift_horiz; height >>= chroma_shift_vert; } for (y = 0; y < height; y++) { + uint8_t sscale = scale; + // CAUTION: keep in sync with mixer_window.cpp:217ff: mfade_area_choice_.append_text() + switch (area) + { + case 8: if (y > 0.5 * height) sscale = 0; break; + case 7: if (y > 0.333 * height) sscale = 0; break; + case 6: if (y > 0.24 * height) sscale = 0; break; + case 5: if (y > 0.166 * height) sscale = 0; break; + case 4: if (y < 0.833 * height) sscale = 0; break; + case 3: if (y < 0.75 * height) sscale = 0; break; + case 2: if (y < 0.666 * height) sscale = 0; break; + case 1: if (y < 0.5 * height) sscale = 0; break; + default: break; // no exceptions. + } + for (x = 0; x < width; x++) { - tmp = scale * (*ptr_s - *ptr_d); + tmp = sscale * (*ptr_s - *ptr_d); *ptr_d += (uint8_t)(tmp >> 8); ptr_d++; ptr_s++; } ptr_d += dest.planes.linesize[plane] - width; ptr_s += dest.planes.linesize[plane] - width; Index: dvswitch-0.9-1-da15ba4/src/mixer_window.hpp =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/mixer_window.hpp +++ dvswitch-0.9-1-da15ba4/src/mixer_window.hpp @@ -10,10 +10,11 @@ #include <boost/thread/mutex.hpp> #include <glibmm/refptr.h> #include <gtkmm/box.h> +#include <gtkmm/comboboxtext.h> #include <gtkmm/menu.h> #include <gtkmm/menubar.h> #include <gtkmm/imagemenuitem.h> #include <gtkmm/separator.h> #include <gtkmm/togglebutton.h> @@ -105,14 +106,16 @@ private: Gtk::Button cut_button_; Gtk::Image cut_icon_; Gtk::HSeparator command_sep_; Gtk::Frame effects_frame_; Gtk::VBox effects_box_; + Gtk::HBox effects_mf_box_; Gtk::RadioButtonGroup effect_group_; Gtk::RadioButton none_button_; Gtk::RadioButton pip_button_; Gtk::RadioButton mfade_button_; + Gtk::ComboBoxText mfade_area_choice_; Gtk::HSeparator transition_sep_; Gtk::RadioButton tfade_button_; Gtk::Label tfade_label_; Gtk::HScale tfade_value_; Gtk::Label mfade_label_; @@ -130,10 +133,11 @@ private: mixer::source_id pri_video_source_id_, sec_video_source_id_; bool pip_active_; bool pip_pending_; bool tfade_pending_; bool mfade_active_; + int mfade_area_; bool allow_mfade_; bool progress_active_; bool fullscreen_state_; double progress_val_; mixer::source_id tfade_target_; Index: dvswitch-0.9-1-da15ba4/src/video_effect.h =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/video_effect.h +++ dvswitch-0.9-1-da15ba4/src/video_effect.h @@ -20,11 +20,12 @@ void video_effect_pic_in_pic(struct raw_ struct rectangle dest_rect, struct raw_frame_ref source, struct rectangle source_rect); void video_effect_fade(struct raw_frame_ref dest, struct raw_frame_ref sec, - uint8_t scale); + uint8_t scale, + uint8_t area); #ifdef __cplusplus } #endif Index: dvswitch-0.9-1-da15ba4/src/mixer.hpp =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/mixer.hpp +++ dvswitch-0.9-1-da15ba4/src/mixer.hpp @@ -151,11 +151,12 @@ public: static std::tr1::shared_ptr<video_mix> create_video_mix_fade(source_id pri_source_id, source_id sec_source_id, bool timed, unsigned int ms, - uint8_t scale=0); + uint8_t scale=0, + uint8_t area=0); bool can_record() const; // Mixer interface format_settings get_format() const; Index: dvswitch-0.9-1-da15ba4/src/mixer.cpp =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/mixer.cpp +++ dvswitch-0.9-1-da15ba4/src/mixer.cpp @@ -704,22 +704,28 @@ bool mixer::video_mix_pic_in_pic::apply( return false; } // Fade video mix - performs a linear interpolation of the values of both // sources on an 8-bit scale. Useful for fading. +// area: 0: normal=all +// 1,2,3,4: bottom 1/2, 1/3, 1/4, 1/6; +// 5,6,7,8: top 1/6, 1/4, 1/3, 1/2; +// area=3 is useful for superimposed subtitles. class mixer::video_mix_fade : public video_mix { public: video_mix_fade(source_id pri_source_id, source_id sec_source_id, bool timed, unsigned int ms, - uint8_t scale=0) + uint8_t scale=0, + uint8_t area=0) : pri_source_id_(pri_source_id), sec_source_id_(sec_source_id), timed_(timed), scale_(scale), + area_(area), bucketsize_(ms * 1000 / 255), modulo_(0), us_per_frame_(0) {} uint8_t get_scale() { return scale_; }; @@ -731,10 +737,11 @@ private: virtual void status(mixer::monitor * monitor); source_id pri_source_id_, sec_source_id_; bool timed_; uint8_t scale_; + uint8_t area_; int bucketsize_; int modulo_; int us_per_frame_; }; @@ -803,11 +810,11 @@ bool mixer::video_mix_fade::apply(const raw_frame_ptr sec_source_raw = decode_video_frame(decoder, sec_source_dv); // Mix raw video video_effect_fade(make_raw_frame_ref(mixed_raw), - make_raw_frame_ref(sec_source_raw), scale_); + make_raw_frame_ref(sec_source_raw), scale_, area_); } return retval; } std::tr1::shared_ptr<mixer::video_mix> mixer::create_video_mix_simple(source_id id) @@ -824,14 +831,14 @@ mixer::create_video_mix_pic_in_pic(sourc } std::tr1::shared_ptr<mixer::video_mix> mixer::create_video_mix_fade(source_id pri_source_id, source_id sec_source_id, bool timed, - unsigned int ms, uint8_t scale) + unsigned int ms, uint8_t scale, uint8_t area) { return std::tr1::shared_ptr<mixer::video_mix>( - new video_mix_fade(pri_source_id, sec_source_id, timed, ms, scale)); + new video_mix_fade(pri_source_id, sec_source_id, timed, ms, scale, area)); } void mixer::run_mixer() { dv_frame_ptr last_mixed_dv; Index: dvswitch-0.9-1-da15ba4/src/mixer_window.cpp =================================================================== --- dvswitch-0.9-1-da15ba4.orig/src/mixer_window.cpp +++ dvswitch-0.9-1-da15ba4/src/mixer_window.cpp @@ -81,10 +81,11 @@ mixer_window::mixer_window(mixer & mixer cut_icon_(Gtk::Stock::CUT, Gtk::ICON_SIZE_BUTTON), effects_frame_(gettext("Effects")), none_button_(effect_group_, gettext("No effect/transition")), pip_button_(effect_group_, gettext("_Pic-in-pic"), true), mfade_button_(effect_group_, gettext("_Manual fade"), true), + mfade_area_choice_(), tfade_button_(effect_group_, gettext("Timed fa_de"), true), tfade_label_(gettext("Transition speed [ms]:")), tfade_value_(40, 15040, 40), mfade_label_(gettext("Manual fade A/B:")), mfade_ab_(0, 256, 1), @@ -95,10 +96,11 @@ mixer_window::mixer_window(mixer & mixer pri_video_source_id_(0), sec_video_source_id_(0), pip_active_(false), pip_pending_(false), mfade_active_(false), + mfade_area_(0), progress_active_(false), fullscreen_state_(false), wakeup_pipe_(O_NONBLOCK, O_NONBLOCK), next_source_id_(0), osc_(NULL), @@ -210,10 +212,26 @@ mixer_window::mixer_window(mixer & mixer mfade_button_.set_sensitive(false); mfade_button_.signal_clicked().connect( sigc::mem_fun(this, &mixer_window::begin_mfade)); mfade_button_.show(); + // CAUTION: keep in sync with video_effect.c:video_effect_fade():320ff + mfade_area_choice_.append_text(gettext("Full")); + mfade_area_choice_.append_text(gettext("1/2b")); + mfade_area_choice_.append_text(gettext("1/3b")); + mfade_area_choice_.append_text(gettext("1/4b")); + mfade_area_choice_.append_text(gettext("1/6b")); + mfade_area_choice_.append_text(gettext("1/6t")); + mfade_area_choice_.append_text(gettext("1/4t")); + mfade_area_choice_.append_text(gettext("1/3t")); + mfade_area_choice_.append_text(gettext("1/2t")); + mfade_area_choice_.set_sensitive(true); + mfade_area_choice_.set_active(0); // activate first entry + mfade_area_choice_.signal_changed().connect( + sigc::mem_fun(this, &mixer_window::mfade_update)); + mfade_area_choice_.show(); + tfade_button_.set_mode(/*draw_indicator=*/false); tfade_button_.set_sensitive(false); tfade_button_.signal_clicked().connect( sigc::mem_fun(this, &mixer_window::begin_tfade)); tfade_button_.show(); @@ -273,15 +291,21 @@ mixer_window::mixer_window(mixer & mixer sigc::mem_fun(*this, &mixer_window::set_sec_video_source)); selector_.signal_audio_selected().connect( sigc::mem_fun(mixer_, &mixer::set_audio_source)); selector_.show(); + effects_mf_box_.set_border_width(0); + effects_mf_box_.set_spacing(gui_standard_spacing); + effects_mf_box_.pack_start(mfade_button_, Gtk::PACK_EXPAND_WIDGET); + effects_mf_box_.pack_start(mfade_area_choice_, Gtk::PACK_SHRINK); + effects_mf_box_.show(); + effects_box_.set_border_width(gui_standard_spacing); effects_box_.set_spacing(gui_standard_spacing); effects_box_.pack_start(apply_button_, Gtk::PACK_SHRINK); effects_box_.pack_start(pip_button_, Gtk::PACK_SHRINK); - effects_box_.pack_start(mfade_button_, Gtk::PACK_SHRINK); + effects_box_.pack_start(effects_mf_box_, Gtk::PACK_SHRINK); effects_box_.pack_start(mfade_label_, Gtk::PACK_SHRINK); effects_box_.pack_start(mfade_ab_, Gtk::PACK_SHRINK); effects_box_.show(); effects_frame_.add(effects_box_); effects_frame_.show(); @@ -568,11 +592,11 @@ void mixer_window::set_pri_video_source( if (tfade_pending_) { tfade_target_ = id; mixer_.set_video_mix( mixer_.create_video_mix_fade(pri_video_source_id_, tfade_target_, - true, int(tfade_value_.get_value()))); + true, int(tfade_value_.get_value()), 0)); pip_active_ = false; mfade_active_ = false; return; } @@ -632,17 +656,17 @@ void mixer_window::mfade_mix() int fade = mfade_ab_.get_value(); if (fade < 1) { mixer_.set_video_mix(mixer_.create_video_mix_simple(pri_video_source_id_)); } - else if (fade > 254) + else if (fade > 254 && mfade_area_ == 0) { mixer_.set_video_mix(mixer_.create_video_mix_simple(sec_video_source_id_)); } else { - mixer_.set_video_mix(mixer_.create_video_mix_fade(pri_video_source_id_, sec_video_source_id_, false, 0, fade)); + mixer_.set_video_mix(mixer_.create_video_mix_fade(pri_video_source_id_, sec_video_source_id_, false, 0, fade, mfade_area_)); } } else { mixer_.set_video_mix(mixer_.create_video_mix_simple(pri_video_source_id_)); @@ -651,10 +675,11 @@ void mixer_window::mfade_mix() mfade_button_.set_sensitive(allow_mfade_); } void mixer_window::mfade_update() { + mfade_area_ = mfade_area_choice_.get_active_row_number(); if (mfade_active_) { mfade_mix(); } }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.