[patch] implement fading
Ben Hutchings
ben at decadent.org.uk
Sun Mar 7 23:59:24 UTC 2010
On Wed, 2010-01-27 at 16:31 +0100, Wouter Verhelst wrote:
> diff --git a/src/mixer.cpp b/src/mixer.cpp
> index d4e9d26..6fe782a 100644
> --- a/src/mixer.cpp
> +++ b/src/mixer.cpp
> @@ -35,6 +35,7 @@ struct mixer::video_mix
> virtual void set_active(const mixer &, bool active) = 0;
> virtual void apply(const mix_data &, const auto_codec &,
> raw_frame_ptr &, dv_frame_ptr &) = 0;
> + virtual void set_monitor(monitor*) = 0;
video_mix should not be coupled to monitor. Instead, make apply()
return a flag whenever the effect state changes, and run_mixer() can
then poke the monitor when it's true.
[...]
> + void set_scale(uint8_t scale) { scale_ = scale; };
A video_mix may be shared between all items in the mixer queue, so it
must never be modified once it has been created - except that
transitions can be updated by the apply() function. When you implement
manual adjustment by the user this must be done by creating new objects.
> + uint8_t get_scale() { return scale_; };
Add a blank line here.
> +private:
> + virtual void validate(const mixer &);
> + virtual void set_active(const mixer &, bool active);
> + virtual void apply(const mix_data &, const auto_codec &, raw_frame_ptr &, dv_frame_ptr &);
> + virtual void set_monitor(mixer::monitor* m);
Add a blank line here.
> + mixer::monitor* monitor_;
> + source_id pri_source_id_, sec_source_id_;
> + bool timed_;
> + uint8_t scale_;
> + int bucketsize_;
> + int modulo_;
> + int ms_per_frame_;
> +};
> +
> +void mixer::video_mix_fade::set_monitor(mixer::monitor* m)
> +{
> + monitor_ = m;
> +}
> +
> +// these two were shamelessly copied from video_mix_pic_in_pic -- perhaps that
> +// should be generalized?
No need for such comments in the code.
[...]
> +void mixer::video_mix_fade::apply(const mix_data & m,
> + const auto_codec & decoder,
> + raw_frame_ptr & mixed_raw,
> + dv_frame_ptr &)
> +{
> + const dv_frame_ptr & pri_source_dv = m.source_frames[pri_source_id_];
> + const dv_frame_ptr & sec_source_dv = m.source_frames[sec_source_id_];
> +
> + if (timed_)
> + {
> + int val;
> + int step;
Use tabs consistently for indenting by 8 spaces.
> + if (!ms_per_frame_)
> + {
> + ms_per_frame_ = (1000 * m.format.system->frame_rate_denom) / m.format.system->frame_rate_numer;
> + }
> + val = modulo_ + ms_per_frame_;
> + step = val / bucketsize_;
> + modulo_ = val % bucketsize_;
> + if ((scale_+step) >= 255) {
[...]
Put a space on either side of '+' and all other binary operators.
Put each opening brace on a new line.
Ben.
--
Ben Hutchings
The most exhausting thing in life is being insincere. - Anne Morrow Lindberg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 828 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/dvswitch-devel/attachments/20100307/2d52c576/attachment-0001.pgp>
More information about the dvswitch-devel
mailing list