Skip to content

Commit

Permalink
Add property animation to the other movit services.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Jun 1, 2013
1 parent bb8576d commit 0533708
Show file tree
Hide file tree
Showing 18 changed files with 222 additions and 87 deletions.
40 changes: 29 additions & 11 deletions src/modules/opengl/filter_deconvolution_sharpen.cpp
Expand Up @@ -24,22 +24,40 @@
#include "glsl_manager.h"
#include <movit/deconvolution_sharpen_effect.h>

static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
GlslManager::get_instance()->lock_service( frame );
Effect* effect = GlslManager::get_effect( filter, frame );
if ( effect ) {
mlt_position position = mlt_filter_get_position( filter, frame );
mlt_position length = mlt_filter_get_length2( filter, frame );
bool ok = effect->set_int( "matrix_size",
mlt_properties_anim_get_int( properties, "matrix_size", position, length ) );
ok |= effect->set_float( "cirlce_radius",
mlt_properties_anim_get_double( properties, "circle_radius", position, length ) );
ok |= effect->set_float( "gaussian_radius",
mlt_properties_anim_get_double( properties, "gaussian_radius", position, length ) );
ok |= effect->set_float( "correlation",
mlt_properties_anim_get_double( properties, "correlation", position, length ) );
ok |= effect->set_float( "noise",
mlt_properties_anim_get_double( properties, "noise", position, length ) );
assert(ok);
}
GlslManager::get_instance()->unlock_service( frame );
*format = mlt_image_glsl;
return mlt_frame_get_image( frame, image, format, width, height, writable );
}

static mlt_frame process( mlt_filter filter, mlt_frame frame )
{
if ( !mlt_frame_is_test_card( frame ) ) {
Effect* effect = GlslManager::get_effect( filter, frame );
if ( !effect )
if ( !GlslManager::get_effect( filter, frame ) )
GlslManager::add_effect( filter, frame, new DeconvolutionSharpenEffect() );
if ( effect ) {
mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter );
bool ok = effect->set_int( "matrix_size", mlt_properties_get_int( filter_props, "matrix_size" ) );
ok |= effect->set_float( "circle_radius", mlt_properties_get_double( filter_props, "circle_radius" ) );
ok |= effect->set_float( "gaussian_radius", mlt_properties_get_double( filter_props, "gaussian_radius" ) );
ok |= effect->set_float( "correlation", mlt_properties_get_double( filter_props, "correlation" ) );
ok |= effect->set_float( "noise", mlt_properties_get_double( filter_props, "noise" ) );
assert(ok);
}
}
mlt_frame_push_service( frame, filter );
mlt_frame_push_get_image( frame, get_image );
return frame;
}

Expand Down
6 changes: 5 additions & 1 deletion src/modules/opengl/filter_deconvolution_sharpen.yml
Expand Up @@ -26,28 +26,32 @@ parameters:
minimum: 0
maximum: 10
default: 5
mutable: yes

- identifier: circle_radius
title: Circle Radius
type: float
minimum: 0
default: 2
mutable: yes

- identifier: gaussian_radius
title: Gaussian Radius
type: float
minimum: 0
default: 0
mutable: yes

- identifier: correlation
title: Correlation
type: float
minimum: 0
default: 0.95
mutable: yes

- identifier: noise
title: Noise Level
type: float
minimum: 0
default: 0.01

mutable: yes
55 changes: 34 additions & 21 deletions src/modules/opengl/filter_lift_gamma_gain.cpp
Expand Up @@ -24,31 +24,44 @@
#include "glsl_manager.h"
#include <movit/lift_gamma_gain_effect.h>

static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
GlslManager::get_instance()->lock_service( frame );
Effect* effect = GlslManager::get_effect( filter, frame );
if ( effect ) {
mlt_position position = mlt_filter_get_position( filter, frame );
mlt_position length = mlt_filter_get_length2( filter, frame );
RGBTriplet triplet(
mlt_properties_anim_get_double( properties, "lift_r", position, length ),
mlt_properties_anim_get_double( properties, "lift_g", position, length ),
mlt_properties_anim_get_double( properties, "lift_b", position, length )
);
bool ok = effect->set_vec3( "lift", (float*) &triplet );
triplet.r = mlt_properties_anim_get_double( properties, "gamma_r", position, length );
triplet.g = mlt_properties_anim_get_double( properties, "gamma_g", position, length );
triplet.b = mlt_properties_anim_get_double( properties, "gamma_b", position, length );
ok |= effect->set_vec3( "gamma", (float*) &triplet );
triplet.r = mlt_properties_anim_get_double( properties, "gain_r", position, length );
triplet.g = mlt_properties_anim_get_double( properties, "gain_g", position, length );
triplet.b = mlt_properties_anim_get_double( properties, "gain_b", position, length );
ok |= effect->set_vec3( "gain", (float*) &triplet );
assert(ok);
}
GlslManager::get_instance()->unlock_service( frame );
*format = mlt_image_glsl;
return mlt_frame_get_image( frame, image, format, width, height, writable );
}

static mlt_frame process( mlt_filter filter, mlt_frame frame )
{
if ( !mlt_frame_is_test_card( frame ) ) {
Effect* effect = GlslManager::get_effect( filter, frame );
if ( !effect )
effect = GlslManager::add_effect( filter, frame, new LiftGammaGainEffect );
if ( effect ) {
mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter );
RGBTriplet triplet(
mlt_properties_get_double( filter_props, "lift_r" ),
mlt_properties_get_double( filter_props, "lift_g" ),
mlt_properties_get_double( filter_props, "lift_b" )
);
bool ok = effect->set_vec3( "lift", (float*) &triplet );
triplet.r = mlt_properties_get_double( filter_props, "gamma_r" );
triplet.g = mlt_properties_get_double( filter_props, "gamma_g" );
triplet.b = mlt_properties_get_double( filter_props, "gamma_b" );
ok |= effect->set_vec3( "gamma", (float*) &triplet );
triplet.r = mlt_properties_get_double( filter_props, "gain_r" );
triplet.g = mlt_properties_get_double( filter_props, "gain_g" );
triplet.b = mlt_properties_get_double( filter_props, "gain_b" );
ok |= effect->set_vec3( "gain", (float*) &triplet );
assert(ok);
}
if ( !GlslManager::get_effect( filter, frame ) )
GlslManager::add_effect( filter, frame, new LiftGammaGainEffect );
}
mlt_frame_push_service( frame, filter );
mlt_frame_push_get_image( frame, get_image );
return frame;
}

Expand Down
9 changes: 9 additions & 0 deletions src/modules/opengl/filter_lift_gamma_gain.yml
Expand Up @@ -30,51 +30,60 @@ parameters:
type: float
minimum: 0.0
default: 0.0
mutable: yes

- identifier: lift_g
title: Lift Green
type: float
minimum: 0.0
default: 0.0
mutable: yes

- identifier: lift_b
title: Lift Blue
type: float
minimum: 0.0
default: 0.0
mutable: yes

- identifier: gamma_r
title: Gamma Red
type: float
minimum: 0.0
default: 1.0
mutable: yes

- identifier: gamma_g
title: Gamma Green
type: float
minimum: 0.0
default: 1.0
mutable: yes

- identifier: gamma_b
title: Gamma Blue
type: float
minimum: 0.0
default: 1.0
mutable: yes

- identifier: gain_r
title: Gain Red
type: float
minimum: 0.0
default: 1.0
mutable: yes

- identifier: gain_g
title: Gain Green
type: float
minimum: 0.0
default: 1.0
mutable: yes

- identifier: gain_b
title: Gain Blue
type: float
minimum: 0.0
default: 1.0
mutable: yes
33 changes: 24 additions & 9 deletions src/modules/opengl/filter_movit_diffusion.cpp
Expand Up @@ -24,19 +24,34 @@
#include "glsl_manager.h"
#include <movit/diffusion_effect.h>

static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
GlslManager::get_instance()->lock_service( frame );
Effect* effect = GlslManager::get_effect( filter, frame );
if ( effect ) {
mlt_position position = mlt_filter_get_position( filter, frame );
mlt_position length = mlt_filter_get_length2( filter, frame );
bool ok = effect->set_float( "radius",
mlt_properties_anim_get_double( properties, "radius", position, length ) );
ok |= effect->set_float( "blurred_mix_amount",
mlt_properties_anim_get_double( properties, "mix", position, length ) );
assert(ok);
}
GlslManager::get_instance()->unlock_service( frame );
*format = mlt_image_glsl;
return mlt_frame_get_image( frame, image, format, width, height, writable );
}

static mlt_frame process( mlt_filter filter, mlt_frame frame )
{
if ( !mlt_frame_is_test_card( frame ) ) {
Effect* effect = GlslManager::get_effect( filter, frame );
if ( !effect )
effect = GlslManager::add_effect( filter, frame, new DiffusionEffect() );
if ( effect ) {
mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter );
bool ok = effect->set_float( "radius", mlt_properties_get_double( filter_props, "radius" ) );
ok |= effect->set_float( "blurred_mix_amount", mlt_properties_get_double( filter_props, "mix" ) );
assert(ok);
}
if ( !GlslManager::get_effect( filter, frame ) )
GlslManager::add_effect( filter, frame, new DiffusionEffect() );
}
mlt_frame_push_service( frame, filter );
mlt_frame_push_get_image( frame, get_image );
return frame;
}

Expand Down
2 changes: 2 additions & 0 deletions src/modules/opengl/filter_movit_diffusion.yml
Expand Up @@ -26,10 +26,12 @@ parameters:
type: float
minimum: 0.0
default: 3.0
mutable: yes

- identifier: mix
title: Blurriness
type: float
minimum: 0.0
maximum: 1.0
default: 0.3
mutable: yes
36 changes: 26 additions & 10 deletions src/modules/opengl/filter_movit_glow.cpp
Expand Up @@ -24,20 +24,36 @@
#include "glsl_manager.h"
#include <movit/glow_effect.h>

static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
GlslManager::get_instance()->lock_service( frame );
Effect* effect = GlslManager::get_effect( filter, frame );
if ( effect ) {
mlt_position position = mlt_filter_get_position( filter, frame );
mlt_position length = mlt_filter_get_length2( filter, frame );
bool ok = effect->set_float( "radius",
mlt_properties_anim_get_double( properties, "radius", position, length ) );
ok |= effect->set_float( "blurred_mix_amount",
mlt_properties_anim_get_double( properties, "blur_mix", position, length ) );
ok |= effect->set_float( "highlight_cutoff",
mlt_properties_anim_get_double( properties, "highlight_cutoff", position, length ) );
assert(ok);
}
GlslManager::get_instance()->unlock_service( frame );
*format = mlt_image_glsl;
return mlt_frame_get_image( frame, image, format, width, height, writable );
}

static mlt_frame process( mlt_filter filter, mlt_frame frame )
{
if ( !mlt_frame_is_test_card( frame ) ) {
Effect* effect = GlslManager::get_effect( filter, frame );
if ( !effect )
effect = GlslManager::add_effect( filter, frame, new GlowEffect() );
if ( effect ) {
mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter );
bool ok = effect->set_float( "radius", mlt_properties_get_double( filter_props, "radius" ) );
ok |= effect->set_float( "blurred_mix_amount", mlt_properties_get_double( filter_props, "blur_mix" ) );
ok |= effect->set_float( "highlight_cutoff", mlt_properties_get_double( filter_props, "highlight_cutoff" ) );
assert(ok);
}
if ( !GlslManager::get_effect( filter, frame ) )
GlslManager::add_effect( filter, frame, new GlowEffect() );
}
mlt_frame_push_service( frame, filter );
mlt_frame_push_get_image( frame, get_image );
return frame;
}

Expand Down
3 changes: 3 additions & 0 deletions src/modules/opengl/filter_movit_glow.yml
Expand Up @@ -19,17 +19,20 @@ parameters:
type: float
minimum: 0.0
default: 20.0
mutable: yes

- identifier: blur_mix
title: Highlight Blurriness
type: float
minimum: 0.0
maximum: 1.0
default: 1.0
mutable: yes

- identifier: highlight_cutoff
title: Highlight Cutoff Threshold
type: float
minimum: 0.0
maximum: 1.0
default: 0.2
mutable: yes
5 changes: 4 additions & 1 deletion src/modules/opengl/filter_movit_opacity.cpp
Expand Up @@ -31,7 +31,10 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format
GlslManager::get_instance()->lock_service( frame );
Effect* effect = GlslManager::get_effect( filter, frame );
if ( effect ) {
bool ok = effect->set_float( "strength_first", mlt_properties_get_double( properties, "opacity" ) );
mlt_position position = mlt_filter_get_position( filter, frame );
mlt_position length = mlt_filter_get_length2( filter, frame );
bool ok = effect->set_float( "strength_first",
mlt_properties_anim_get_double( properties, "opacity", position, length ) );
assert(ok);
}
GlslManager::get_instance()->unlock_service( frame );
Expand Down
1 change: 1 addition & 0 deletions src/modules/opengl/filter_movit_opacity.yml
Expand Up @@ -23,3 +23,4 @@ parameters:
minimum: 0
maximum: 1
default: 1
mutable: yes
30 changes: 22 additions & 8 deletions src/modules/opengl/filter_movit_saturation.cpp
Expand Up @@ -24,18 +24,32 @@
#include "glsl_manager.h"
#include <movit/saturation_effect.h>

static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable )
{
mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame );
mlt_properties properties = MLT_FILTER_PROPERTIES( filter );
GlslManager::get_instance()->lock_service( frame );
Effect* effect = GlslManager::get_effect( filter, frame );
if ( effect ) {
mlt_position position = mlt_filter_get_position( filter, frame );
mlt_position length = mlt_filter_get_length2( filter, frame );
bool ok = effect->set_float( "saturation",
mlt_properties_anim_get_double( properties, "saturation", position, length ) );
assert(ok);
}
GlslManager::get_instance()->unlock_service( frame );
*format = mlt_image_glsl;
return mlt_frame_get_image( frame, image, format, width, height, writable );
}

static mlt_frame process( mlt_filter filter, mlt_frame frame )
{
if ( !mlt_frame_is_test_card( frame ) ) {
Effect* effect = GlslManager::get_effect( filter, frame );
if ( !effect )
effect = GlslManager::add_effect( filter, frame, new SaturationEffect() );
if ( effect ) {
mlt_properties filter_props = MLT_FILTER_PROPERTIES( filter );
bool ok = effect->set_float( "saturation", mlt_properties_get_double( filter_props, "saturation" ) );
assert(ok);
}
if ( !GlslManager::get_effect( filter, frame ) )
GlslManager::add_effect( filter, frame, new SaturationEffect() );
}
mlt_frame_push_service( frame, filter );
mlt_frame_push_get_image( frame, get_image );
return frame;
}

Expand Down

0 comments on commit 0533708

Please sign in to comment.