This is a pretty hard API break, but it's probably the last big API
break before 1.0, and some of the names (e.g. Effect, Input ResourcePool)
are really so generic that they should not be allowed to pollute the global
namespace.
96 files changed:
Assuming you have an OpenGL context already set up:
<code>
Assuming you have an OpenGL context already set up:
<code>
EffectChain chain(1280, 720);
ImageFormat inout_format;
EffectChain chain(1280, 720);
ImageFormat inout_format;
string AlphaDivisionEffect::output_fragment_shader()
{
return read_file("alpha_division_effect.frag");
}
string AlphaDivisionEffect::output_fragment_shader()
{
return read_file("alpha_division_effect.frag");
}
class AlphaDivisionEffect : public Effect {
public:
AlphaDivisionEffect() {}
class AlphaDivisionEffect : public Effect {
public:
AlphaDivisionEffect() {}
std::string output_fragment_shader();
};
std::string output_fragment_shader();
};
#endif // !defined(_MOVIT_ALPHA_DIVISION_EFFECT_H)
#endif // !defined(_MOVIT_ALPHA_DIVISION_EFFECT_H)
#include "image_format.h"
#include "test_util.h"
#include "image_format.h"
#include "test_util.h"
TEST(AlphaDivisionEffectTest, SimpleTest) {
const int size = 2;
float data[4 * size] = {
TEST(AlphaDivisionEffectTest, SimpleTest) {
const int size = 2;
float data[4 * size] = {
EXPECT_EQ(0.0f, out_data[3]);
EXPECT_EQ(0.0f, out_data[7]);
}
EXPECT_EQ(0.0f, out_data[3]);
EXPECT_EQ(0.0f, out_data[7]);
}
string AlphaMultiplicationEffect::output_fragment_shader()
{
return read_file("alpha_multiplication_effect.frag");
}
string AlphaMultiplicationEffect::output_fragment_shader()
{
return read_file("alpha_multiplication_effect.frag");
}
class AlphaMultiplicationEffect : public Effect {
public:
AlphaMultiplicationEffect() {}
class AlphaMultiplicationEffect : public Effect {
public:
AlphaMultiplicationEffect() {}
std::string output_fragment_shader();
};
std::string output_fragment_shader();
};
#endif // !defined(_MOVIT_ALPHA_MULTIPLICATION_EFFECT_H)
#endif // !defined(_MOVIT_ALPHA_MULTIPLICATION_EFFECT_H)
#include "image_format.h"
#include "test_util.h"
#include "image_format.h"
#include "test_util.h"
TEST(AlphaMultiplicationEffectTest, SimpleTest) {
const int size = 3;
float data[4 * size] = {
TEST(AlphaMultiplicationEffectTest, SimpleTest) {
const int size = 3;
float data[4 * size] = {
expect_equal(expected_data, out_data, 4, size);
}
expect_equal(expected_data, out_data, 4, size);
}
#define NUM_TAPS 16
using namespace std;
#define NUM_TAPS 16
using namespace std;
BlurEffect::BlurEffect()
: radius(3.0f),
BlurEffect::BlurEffect()
: radius(3.0f),
void SingleBlurPassEffect::clear_gl_state()
{
}
void SingleBlurPassEffect::clear_gl_state()
{
}
class EffectChain;
class Node;
class SingleBlurPassEffect;
class EffectChain;
class Node;
class SingleBlurPassEffect;
int width, height, virtual_width, virtual_height;
};
int width, height, virtual_width, virtual_height;
};
#endif // !defined(_MOVIT_BLUR_EFFECT_H)
#endif // !defined(_MOVIT_BLUR_EFFECT_H)
#include "image_format.h"
#include "test_util.h"
#include "image_format.h"
#include "test_util.h"
TEST(BlurEffectTest, IdentityTransformDoesNothing) {
const int size = 4;
TEST(BlurEffectTest, IdentityTransformDoesNothing) {
const int size = 4;
expect_equal(expected_data, out_data, size, size, 0.1f, 1e-3);
}
expect_equal(expected_data, out_data, size, size, 0.1f, 1e-3);
}
using namespace Eigen;
using namespace std;
using namespace Eigen;
using namespace std;
// Color coordinates from Rec. 709; sRGB uses the same primaries.
static const double rec709_x_R = 0.640, rec709_x_G = 0.300, rec709_x_B = 0.150;
static const double rec709_y_R = 0.330, rec709_y_G = 0.600, rec709_y_B = 0.060;
// Color coordinates from Rec. 709; sRGB uses the same primaries.
static const double rec709_x_R = 0.640, rec709_x_G = 0.300, rec709_x_B = 0.150;
static const double rec709_y_R = 0.330, rec709_y_G = 0.600, rec709_y_B = 0.060;
return output_glsl_mat3("PREFIX(conversion_matrix)", m) +
read_file("colorspace_conversion_effect.frag");
}
return output_glsl_mat3("PREFIX(conversion_matrix)", m) +
read_file("colorspace_conversion_effect.frag");
}
#include "effect.h"
#include "image_format.h"
#include "effect.h"
#include "image_format.h"
class ColorspaceConversionEffect : public Effect {
private:
// Should not be instantiated by end users.
class ColorspaceConversionEffect : public Effect {
private:
// Should not be instantiated by end users.
Colorspace source_space, destination_space;
};
Colorspace source_space, destination_space;
};
#endif // !defined(_MOVIT_COLORSPACE_CONVERSION_EFFECT_H)
#endif // !defined(_MOVIT_COLORSPACE_CONVERSION_EFFECT_H)
#include "gtest/gtest.h"
#include "test_util.h"
#include "gtest/gtest.h"
#include "test_util.h"
TEST(ColorspaceConversionEffectTest, Reversible) {
float data[] = {
0.0f, 0.0f, 0.0f, 1.0f,
TEST(ColorspaceConversionEffectTest, Reversible) {
float data[] = {
0.0f, 0.0f, 0.0f, 1.0f,
expect_equal(expected_data, out_data, 4, 6);
}
expect_equal(expected_data, out_data, 4, 6);
}
#ifndef _MOVIT_D65_H
#define _MOVIT_D65_H 1
#ifndef _MOVIT_D65_H
#define _MOVIT_D65_H 1
// The D65 illuminant, which is the standard white point (ie. what you should get
// for R=G=B=1) for almost all video color spaces in common use. It has a color
// temperature roughly around 6500 K, which is sort of bluish; it is intended to
// The D65 illuminant, which is the standard white point (ie. what you should get
// for R=G=B=1) for almost all video color spaces in common use. It has a color
// temperature roughly around 6500 K, which is sort of bluish; it is intended to
static const double d65_Y = 1.0;
static const double d65_Z = d65_z / d65_y;
static const double d65_Y = 1.0;
static const double d65_Z = d65_z / d65_y;
#endif // !defined(_MOVIT_D65_H)
#endif // !defined(_MOVIT_D65_H)
using namespace Eigen;
using namespace std;
using namespace Eigen;
using namespace std;
DeconvolutionSharpenEffect::DeconvolutionSharpenEffect()
: R(5),
circle_radius(2.0f),
DeconvolutionSharpenEffect::DeconvolutionSharpenEffect()
: R(5),
circle_radius(2.0f),
set_uniform_vec4_array(glsl_program_num, prefix, "samples", samples, (R + 1) * (R + 1));
}
set_uniform_vec4_array(glsl_program_num, prefix, "samples", samples, (R + 1) * (R + 1));
}
class DeconvolutionSharpenEffect : public Effect {
public:
DeconvolutionSharpenEffect();
class DeconvolutionSharpenEffect : public Effect {
public:
DeconvolutionSharpenEffect();
void update_deconvolution_kernel();
};
void update_deconvolution_kernel();
};
#endif // !defined(_MOVIT_DECONVOLUTION_SHARPEN_EFFECT_H)
#endif // !defined(_MOVIT_DECONVOLUTION_SHARPEN_EFFECT_H)
#include "image_format.h"
#include "test_util.h"
#include "image_format.h"
#include "test_util.h"
TEST(DeconvolutionSharpenEffectTest, IdentityTransformDoesNothing) {
const int size = 4;
TEST(DeconvolutionSharpenEffectTest, IdentityTransformDoesNothing) {
const int size = 4;
expect_equal(expected_alpha, out_data, size, size);
}
expect_equal(expected_alpha, out_data, size, size);
}
#include "util.h"
#include "widgets.h"
#include "util.h"
#include "widgets.h"
+using namespace movit;
+
unsigned char result[WIDTH * HEIGHT * 4];
float lift_theta = 0.0f, lift_rad = 0.0f, lift_v = 0.0f;
unsigned char result[WIDTH * HEIGHT * 4];
float lift_theta = 0.0f, lift_rad = 0.0f, lift_v = 0.0f;
DiffusionEffect::DiffusionEffect()
: blur(new BlurEffect),
overlay_matte(new OverlayMatteEffect)
DiffusionEffect::DiffusionEffect()
: blur(new BlurEffect),
overlay_matte(new OverlayMatteEffect)
{
return read_file("overlay_matte_effect.frag");
}
{
return read_file("overlay_matte_effect.frag");
}
class BlurEffect;
class EffectChain;
class Node;
class BlurEffect;
class EffectChain;
class Node;
float blurred_mix_amount;
};
float blurred_mix_amount;
};
#endif // !defined(_MOVIT_DIFFUSION_EFFECT_H)
#endif // !defined(_MOVIT_DIFFUSION_EFFECT_H)
#include "image_format.h"
#include "test_util.h"
#include "image_format.h"
#include "test_util.h"
TEST(DiffusionEffectTest, IdentityTransformDoesNothing) {
const int size = 4;
TEST(DiffusionEffectTest, IdentityTransformDoesNothing) {
const int size = 4;
expect_equal(expected_data, out_data, size, size, 0.05f, 0.002);
}
expect_equal(expected_data, out_data, size, size, 0.05f, 0.002);
}
namespace {
// A simple LCG (linear congruental generator) random generator.
namespace {
// A simple LCG (linear congruental generator) random generator.
set_uniform_float(glsl_program_num, prefix, "round_fac", round_fac);
set_uniform_float(glsl_program_num, prefix, "inv_round_fac", 1.0f / round_fac);
}
set_uniform_float(glsl_program_num, prefix, "round_fac", round_fac);
set_uniform_float(glsl_program_num, prefix, "inv_round_fac", 1.0f / round_fac);
}
class DitherEffect : public Effect {
private:
// Should not be instantiated by end users;
class DitherEffect : public Effect {
private:
// Should not be instantiated by end users;
#endif // !defined(_MOVIT_DITHER_EFFECT_H)
#endif // !defined(_MOVIT_DITHER_EFFECT_H)
#include "image_format.h"
#include "test_util.h"
#include "image_format.h"
#include "test_util.h"
TEST(DitherEffectTest, NoDitherOnExactValues) {
const int size = 4;
TEST(DitherEffectTest, NoDitherOnExactValues) {
const int size = 4;
EXPECT_NEAR(amplitude, sum / (size * 255.0f), 1.1e-5);
}
EXPECT_NEAR(amplitude, sum / (size * 255.0f), 1.1e-5);
}
bool Effect::set_int(const string &key, int value)
{
if (params_int.count(key) == 0) {
bool Effect::set_int(const string &key, int value)
{
if (params_int.count(key) == 0) {
}
void Effect::clear_gl_state() {}
}
void Effect::clear_gl_state() {}
class EffectChain;
class Node;
class EffectChain;
class Node;
std::map<std::string, float *> params_vec4;
};
std::map<std::string, float *> params_vec4;
};
#endif // !defined(_MOVIT_EFFECT_H)
#endif // !defined(_MOVIT_EFFECT_H)
EffectChain::EffectChain(float aspect_nom, float aspect_denom, ResourcePool *resource_pool)
: aspect_nom(aspect_nom),
aspect_denom(aspect_denom),
EffectChain::EffectChain(float aspect_nom, float aspect_denom, ResourcePool *resource_pool)
: aspect_nom(aspect_nom),
aspect_denom(aspect_denom),
#include "image_format.h"
#include "image_format.h"
class Effect;
class Input;
struct Phase;
class Effect;
class Input;
struct Phase;
bool owns_resource_pool;
};
bool owns_resource_pool;
};
#endif // !defined(_MOVIT_EFFECT_CHAIN_H)
#endif // !defined(_MOVIT_EFFECT_CHAIN_H)
TEST(EffectChainTest, EmptyChain) {
float data[] = {
0.0f, 0.25f, 0.3f,
TEST(EffectChainTest, EmptyChain) {
float data[] = {
0.0f, 0.25f, 0.3f,
// Reset the debug status again.
movit_debug_level = MOVIT_DEBUG_OFF;
}
// Reset the debug status again.
movit_debug_level = MOVIT_DEBUG_OFF;
}
GLint get_uniform_location(GLuint glsl_program_num, const string &prefix, const string &key)
{
string name = prefix + "_" + key;
GLint get_uniform_location(GLuint glsl_program_num, const string &prefix, const string &key)
{
string name = prefix + "_" + key;
glUniformMatrix3fv(location, 1, GL_FALSE, matrixf);
check_error();
}
glUniformMatrix3fv(location, 1, GL_FALSE, matrixf);
check_error();
}
class EffectChain;
class Node;
class EffectChain;
class Node;
void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values, size_t num_values);
void set_uniform_mat3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const Eigen::Matrix3d &matrix);
void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values, size_t num_values);
void set_uniform_mat3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const Eigen::Matrix3d &matrix);
#endif // !defined(_MOVIT_EFFECT_UTIL_H)
#endif // !defined(_MOVIT_EFFECT_UTIL_H)
FFTPassEffect::FFTPassEffect()
: input_width(1280),
input_height(720),
FFTPassEffect::FFTPassEffect()
: input_width(1280),
input_height(720),
assert(input_size % fft_size == 0);
set_uniform_float(glsl_program_num, prefix, "num_repeats", input_size / fft_size);
}
assert(input_size % fft_size == 0);
set_uniform_float(glsl_program_num, prefix, "num_repeats", input_size / fft_size);
}
class FFTPassEffect : public Effect {
public:
FFTPassEffect();
class FFTPassEffect : public Effect {
public:
FFTPassEffect();
int inverse; // 0 = forward (FFT), 1 = reverse (IFFT).
};
int inverse; // 0 = forward (FFT), 1 = reverse (IFFT).
};
#endif // !defined(_MOVIT_FFT_PASS_EFFECT_H)
#endif // !defined(_MOVIT_FFT_PASS_EFFECT_H)
#include "multiply_effect.h"
#include "test_util.h"
#include "multiply_effect.h"
#include "test_util.h"
namespace {
// Generate a random number uniformly distributed between [-1.0, 1.0].
namespace {
// Generate a random number uniformly distributed between [-1.0, 1.0].
expect_equal(in, out2, 4, fft_size, max_error, rms_limit);
}
}
expect_equal(in, out2, 4, fft_size, max_error, rms_limit);
}
}
FlatInput::FlatInput(ImageFormat image_format, MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height)
: image_format(image_format),
pixel_format(pixel_format),
FlatInput::FlatInput(ImageFormat image_format, MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height)
: image_format(image_format),
pixel_format(pixel_format),
#include "init.h"
#include "input.h"
#include "init.h"
#include "input.h"
class ResourcePool;
// A FlatInput is the normal, “classic” case of an input, where everything
class ResourcePool;
// A FlatInput is the normal, “classic” case of an input, where everything
ResourcePool *resource_pool;
};
ResourcePool *resource_pool;
};
#endif // !defined(_MOVIT_FLAT_INPUT_H)
#endif // !defined(_MOVIT_FLAT_INPUT_H)
#include "test_util.h"
#include "util.h"
#include "test_util.h"
#include "util.h"
TEST(FlatInput, SimpleGrayscale) {
const int size = 4;
TEST(FlatInput, SimpleGrayscale) {
const int size = 4;
glDeleteBuffers(1, &pbo);
}
glDeleteBuffers(1, &pbo);
}
GammaCompressionEffect::GammaCompressionEffect()
: destination_curve(GAMMA_LINEAR)
{
GammaCompressionEffect::GammaCompressionEffect()
: destination_curve(GAMMA_LINEAR)
{
set_uniform_float(glsl_program_num, prefix, "beta", 0.0181);
}
}
set_uniform_float(glsl_program_num, prefix, "beta", 0.0181);
}
}
#include "effect.h"
#include "image_format.h"
#include "effect.h"
#include "image_format.h"
class GammaCompressionEffect : public Effect {
private:
// Should not be instantiated by end users.
class GammaCompressionEffect : public Effect {
private:
// Should not be instantiated by end users.
GammaCurve destination_curve;
};
GammaCurve destination_curve;
};
#endif // !defined(_MOVIT_GAMMA_COMPRESSION_EFFECT_H)
#endif // !defined(_MOVIT_GAMMA_COMPRESSION_EFFECT_H)
#include "image_format.h"
#include "test_util.h"
#include "image_format.h"
#include "test_util.h"
TEST(GammaCompressionEffectTest, sRGB_KeyValues) {
float data[] = {
0.0f, 1.0f,
TEST(GammaCompressionEffectTest, sRGB_KeyValues) {
float data[] = {
0.0f, 1.0f,
// precision and inaccuracies in the polynomial approximation.
expect_equal(expected_data, out_data, 4096, 1, 1.2 / 4095.0, 1e-5);
}
// precision and inaccuracies in the polynomial approximation.
expect_equal(expected_data, out_data, 4096, 1, 1.2 / 4095.0, 1e-5);
}
GammaExpansionEffect::GammaExpansionEffect()
: source_curve(GAMMA_LINEAR)
{
GammaExpansionEffect::GammaExpansionEffect()
: source_curve(GAMMA_LINEAR)
{
set_uniform_float(glsl_program_num, prefix, "beta", 0.0181 * 4.5);
}
}
set_uniform_float(glsl_program_num, prefix, "beta", 0.0181 * 4.5);
}
}
#include "effect.h"
#include "image_format.h"
#include "effect.h"
#include "image_format.h"
class GammaExpansionEffect : public Effect {
private:
// Should not be instantiated by end users.
class GammaExpansionEffect : public Effect {
private:
// Should not be instantiated by end users.
GammaCurve source_curve;
};
GammaCurve source_curve;
};
#endif // !defined(_MOVIT_GAMMA_EXPANSION_EFFECT_H)
#endif // !defined(_MOVIT_GAMMA_EXPANSION_EFFECT_H)
#include "gtest/gtest-message.h"
#include "test_util.h"
#include "gtest/gtest-message.h"
#include "test_util.h"
TEST(GammaExpansionEffectTest, sRGB_KeyValues) {
float data[] = {
0.0f, 1.0f,
TEST(GammaExpansionEffectTest, sRGB_KeyValues) {
float data[] = {
0.0f, 1.0f,
//
test_accuracy(expected_data, out_data, 4096, 1e-3, 0.01, 2.50, 1e-4);
}
//
test_accuracy(expected_data, out_data, 4096, 1e-3, 0.01, 2.50, 1e-4);
}
GlowEffect::GlowEffect()
: blur(new BlurEffect),
cutoff(new HighlightCutoffEffect),
GlowEffect::GlowEffect()
: blur(new BlurEffect),
cutoff(new HighlightCutoffEffect),
{
return read_file("highlight_cutoff_effect.frag");
}
{
return read_file("highlight_cutoff_effect.frag");
}
class BlurEffect;
class EffectChain;
class HighlightCutoffEffect;
class BlurEffect;
class EffectChain;
class HighlightCutoffEffect;
#endif // !defined(_MOVIT_GLOW_EFFECT_H)
#endif // !defined(_MOVIT_GLOW_EFFECT_H)
#include "image_format.h"
#include "test_util.h"
#include "image_format.h"
#include "test_util.h"
TEST(GlowEffectTest, NoAmountDoesNothing) {
const int size = 4;
TEST(GlowEffectTest, NoAmountDoesNothing) {
const int size = 4;
expect_equal(expected_data, out_data, 4, size);
}
expect_equal(expected_data, out_data, 4, size);
}
// where Y' is derived from R'G'B' instead of RGB, since this is the same
// system as used in Rec. 601 and 709.
// where Y' is derived from R'G'B' instead of RGB, since this is the same
// system as used in Rec. 601 and 709.
enum MovitPixelFormat {
FORMAT_RGB,
FORMAT_RGBA_PREMULTIPLIED_ALPHA,
enum MovitPixelFormat {
FORMAT_RGB,
FORMAT_RGBA_PREMULTIPLIED_ALPHA,
GammaCurve gamma_curve;
};
GammaCurve gamma_curve;
};
#endif // !defined(_MOVIT_IMAGE_FORMAT_H)
#endif // !defined(_MOVIT_IMAGE_FORMAT_H)
bool movit_initialized = false;
MovitDebugLevel movit_debug_level = MOVIT_DEBUG_ON;
float movit_texel_subpixel_precision;
bool movit_initialized = false;
MovitDebugLevel movit_debug_level = MOVIT_DEBUG_ON;
float movit_texel_subpixel_precision;
movit_initialized = true;
return true;
}
movit_initialized = true;
return true;
}
#include "defs.h"
#include <string>
#include "defs.h"
#include <string>
enum MovitDebugLevel {
MOVIT_DEBUG_OFF = 0,
MOVIT_DEBUG_ON = 1,
enum MovitDebugLevel {
MOVIT_DEBUG_OFF = 0,
MOVIT_DEBUG_ON = 1,
// Whether the GPU in use supports GL_EXT_texture_sRGB.
extern bool movit_srgb_textures_supported;
// Whether the GPU in use supports GL_EXT_texture_sRGB.
extern bool movit_srgb_textures_supported;
#endif // !defined(_MOVIT_INIT_H)
#endif // !defined(_MOVIT_INIT_H)
#include "effect.h"
#include "image_format.h"
#include "effect.h"
#include "image_format.h"
// An input is a degenerate case of an effect; it represents the picture data
// that comes from the user. As such, it has zero “inputs” itself.
//
// An input is a degenerate case of an effect; it represents the picture data
// that comes from the user. As such, it has zero “inputs” itself.
//
virtual GammaCurve get_gamma_curve() const = 0;
};
virtual GammaCurve get_gamma_curve() const = 0;
};
#endif // !defined(_MOVIT_INPUT_H)
#endif // !defined(_MOVIT_INPUT_H)
LiftGammaGainEffect::LiftGammaGainEffect()
: lift(0.0f, 0.0f, 0.0f),
gamma(1.0f, 1.0f, 1.0f),
LiftGammaGainEffect::LiftGammaGainEffect()
: lift(0.0f, 0.0f, 0.0f),
gamma(1.0f, 1.0f, 1.0f),
2.2f / gamma.b);
set_uniform_vec3(glsl_program_num, prefix, "inv_gamma_22", (float *)&inv_gamma_22);
}
2.2f / gamma.b);
set_uniform_vec3(glsl_program_num, prefix, "inv_gamma_22", (float *)&inv_gamma_22);
}
class LiftGammaGainEffect : public Effect {
public:
LiftGammaGainEffect();
class LiftGammaGainEffect : public Effect {
public:
LiftGammaGainEffect();
RGBTriplet lift, gamma, gain;
};
RGBTriplet lift, gamma, gain;
};
#endif // !defined(_MOVIT_LIFT_GAMMA_GAIN_EFFECT_H)
#endif // !defined(_MOVIT_LIFT_GAMMA_GAIN_EFFECT_H)
#include "lift_gamma_gain_effect.h"
#include "test_util.h"
#include "lift_gamma_gain_effect.h"
#include "test_util.h"
TEST(LiftGammaGainEffectTest, DefaultIsNoop) {
float data[] = {
0.0f, 0.0f, 0.0f, 1.0f,
TEST(LiftGammaGainEffectTest, DefaultIsNoop) {
float data[] = {
0.0f, 0.0f, 0.0f, 1.0f,
expect_equal(expected_data, out_data, 4, 3);
}
expect_equal(expected_data, out_data, 4, 3);
}
MirrorEffect::MirrorEffect()
{
}
MirrorEffect::MirrorEffect()
{
}
{
return read_file("mirror_effect.frag");
}
{
return read_file("mirror_effect.frag");
}
class MirrorEffect : public Effect {
public:
MirrorEffect();
class MirrorEffect : public Effect {
public:
MirrorEffect();
virtual AlphaHandling alpha_handling() const { return DONT_CARE_ALPHA_TYPE; }
};
virtual AlphaHandling alpha_handling() const { return DONT_CARE_ALPHA_TYPE; }
};
#endif // !defined(_MOVIT_MIRROR_EFFECT_H)
#endif // !defined(_MOVIT_MIRROR_EFFECT_H)
MixEffect::MixEffect()
: strength_first(0.5f), strength_second(0.5f)
{
MixEffect::MixEffect()
: strength_first(0.5f), strength_second(0.5f)
{
{
return read_file("mix_effect.frag");
}
{
return read_file("mix_effect.frag");
}
class MixEffect : public Effect {
public:
MixEffect();
class MixEffect : public Effect {
public:
MixEffect();
float strength_first, strength_second;
};
float strength_first, strength_second;
};
#endif // !defined(_MOVIT_MIX_EFFECT_H)
#endif // !defined(_MOVIT_MIX_EFFECT_H)
#include "mix_effect.h"
#include "test_util.h"
#include "mix_effect.h"
#include "test_util.h"
TEST(MixEffectTest, FiftyFiftyMix) {
float data_a[] = {
0.0f, 0.25f,
TEST(MixEffectTest, FiftyFiftyMix) {
float data_a[] = {
0.0f, 0.25f,
expect_equal(expected_data, out_data, 2, 2);
}
expect_equal(expected_data, out_data, 2, 2);
}
MultiplyEffect::MultiplyEffect()
: factor(1.0f, 1.0f, 1.0f, 1.0f)
{
MultiplyEffect::MultiplyEffect()
: factor(1.0f, 1.0f, 1.0f, 1.0f)
{
{
return read_file("multiply_effect.frag");
}
{
return read_file("multiply_effect.frag");
}
class MultiplyEffect : public Effect {
public:
MultiplyEffect();
class MultiplyEffect : public Effect {
public:
MultiplyEffect();
#endif // !defined(_MOVIT_MULTIPLY_EFFECT_H)
#endif // !defined(_MOVIT_MULTIPLY_EFFECT_H)
OverlayEffect::OverlayEffect() {}
string OverlayEffect::output_fragment_shader()
{
return read_file("overlay_effect.frag");
}
OverlayEffect::OverlayEffect() {}
string OverlayEffect::output_fragment_shader()
{
return read_file("overlay_effect.frag");
}
class OverlayEffect : public Effect {
public:
OverlayEffect();
class OverlayEffect : public Effect {
public:
OverlayEffect();
virtual AlphaHandling alpha_handling() const { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; }
};
virtual AlphaHandling alpha_handling() const { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; }
};
#endif // !defined(_MOVIT_OVERLAY_EFFECT_H)
#endif // !defined(_MOVIT_OVERLAY_EFFECT_H)
#include "overlay_effect.h"
#include "test_util.h"
#include "overlay_effect.h"
#include "test_util.h"
TEST(OverlayEffectTest, TopDominatesBottomWhenNoAlpha) {
float data_a[] = {
0.0f, 0.25f,
TEST(OverlayEffectTest, TopDominatesBottomWhenNoAlpha) {
float data_a[] = {
0.0f, 0.25f,
expect_equal(expected_data, out_data, 4, 1);
}
expect_equal(expected_data, out_data, 4, 1);
}
PaddingEffect::PaddingEffect()
: border_color(0.0f, 0.0f, 0.0f, 0.0f),
output_width(1280),
PaddingEffect::PaddingEffect()
: border_color(0.0f, 0.0f, 0.0f, 0.0f),
output_width(1280),
input_width = width;
input_height = height;
}
input_width = width;
input_height = height;
}
class PaddingEffect : public Effect {
public:
PaddingEffect();
class PaddingEffect : public Effect {
public:
PaddingEffect();
#endif // !defined(_MOVIT_PADDING_EFFECT_H)
#endif // !defined(_MOVIT_PADDING_EFFECT_H)
#include "test_util.h"
#include "util.h"
#include "test_util.h"
#include "util.h"
TEST(PaddingEffectTest, SimpleCenter) {
float data[2 * 2] = {
1.0f, 0.5f,
TEST(PaddingEffectTest, SimpleCenter) {
float data[2 * 2] = {
1.0f, 0.5f,
tester.run(out_data, GL_RGBA, COLORSPACE_REC_601_625, GAMMA_REC_709, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED);
expect_equal(expected_data, out_data, 4, 4);
}
tester.run(out_data, GL_RGBA, COLORSPACE_REC_601_625, GAMMA_REC_709, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED);
expect_equal(expected_data, out_data, 4, 4);
}
namespace {
float sinc(float x)
namespace {
float sinc(float x)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
check_error();
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
check_error();
}
class EffectChain;
class Node;
class SingleResamplePassEffect;
class EffectChain;
class Node;
class SingleResamplePassEffect;
#endif // !defined(_MOVIT_RESAMPLE_EFFECT_H)
#endif // !defined(_MOVIT_RESAMPLE_EFFECT_H)
#include "resample_effect.h"
#include "test_util.h"
#include "resample_effect.h"
#include "test_util.h"
namespace {
float sinc(float x)
namespace {
float sinc(float x)
// for 8-bit accuracy, though.
expect_equal(expected_data, out_data, dwidth, dheight, 0.5 / 1023.0);
}
// for 8-bit accuracy, though.
expect_equal(expected_data, out_data, dwidth, dheight, 0.5 / 1023.0);
}
ResizeEffect::ResizeEffect()
: width(1280), height(720)
{
ResizeEffect::ResizeEffect()
: width(1280), height(720)
{
*virtual_width = *width = this->width;
*virtual_height = *height = this->height;
}
*virtual_width = *width = this->width;
*virtual_height = *height = this->height;
}
class ResizeEffect : public Effect {
public:
ResizeEffect();
class ResizeEffect : public Effect {
public:
ResizeEffect();
#endif // !defined(_MOVIT_RESIZE_EFFECT_H)
#endif // !defined(_MOVIT_RESIZE_EFFECT_H)
ResourcePool::ResourcePool(size_t program_freelist_max_length,
size_t texture_freelist_max_bytes)
: program_freelist_max_length(program_freelist_max_length),
ResourcePool::ResourcePool(size_t program_freelist_max_length,
size_t texture_freelist_max_bytes)
: program_freelist_max_length(program_freelist_max_length),
return texture_format.width * texture_format.height * bytes_per_pixel;
}
return texture_format.width * texture_format.height * bytes_per_pixel;
}
#include <string>
#include <utility>
#include <string>
#include <utility>
class ResourcePool {
public:
// program_freelist_max_length is how many compiled programs that are unused to keep
class ResourcePool {
public:
// program_freelist_max_length is how many compiled programs that are unused to keep
static size_t estimate_texture_size(const Texture2D &texture_format);
};
static size_t estimate_texture_size(const Texture2D &texture_format);
};
#endif // !defined(_MOVIT_RESOURCE_POOL_H)
#endif // !defined(_MOVIT_RESOURCE_POOL_H)
SandboxEffect::SandboxEffect()
: parm(0.0f)
{
SandboxEffect::SandboxEffect()
: parm(0.0f)
{
// Any OpenGL state you might want to set, goes here.
}
// Any OpenGL state you might want to set, goes here.
}
class SandboxEffect : public Effect {
public:
SandboxEffect();
class SandboxEffect : public Effect {
public:
SandboxEffect();
#endif // !defined(_MOVIT_SANDBOX_EFFECT_H)
#endif // !defined(_MOVIT_SANDBOX_EFFECT_H)
SaturationEffect::SaturationEffect()
: saturation(1.0f)
{
SaturationEffect::SaturationEffect()
: saturation(1.0f)
{
{
return read_file("saturation_effect.frag");
}
{
return read_file("saturation_effect.frag");
}
class SaturationEffect : public Effect {
public:
SaturationEffect();
class SaturationEffect : public Effect {
public:
SaturationEffect();
#endif // !defined(_MOVIT_SATURATION_EFFECT_H)
#endif // !defined(_MOVIT_SATURATION_EFFECT_H)
#include "saturation_effect.h"
#include "test_util.h"
#include "saturation_effect.h"
#include "test_util.h"
TEST(SaturationEffectTest, SaturationOneIsPassThrough) {
float data[] = {
1.0f, 0.5f, 0.75f, 0.6f,
TEST(SaturationEffectTest, SaturationOneIsPassThrough) {
float data[] = {
1.0f, 0.5f, 0.75f, 0.6f,
expect_equal(expected_data, out_data, 4, 3);
}
expect_equal(expected_data, out_data, 4, 3);
}
double rms = sqrt(squared_difference) / num_values;
EXPECT_LT(rms, rms_limit);
}
double rms = sqrt(squared_difference) / num_values;
EXPECT_LT(rms, rms_limit);
}
#include "effect_chain.h"
#include "image_format.h"
#include "effect_chain.h"
#include "image_format.h"
class Input;
class EffectChainTester {
class Input;
class EffectChainTester {
void expect_equal(const unsigned char *ref, const unsigned char *result, unsigned width, unsigned height, unsigned largest_difference_limit = 1, float rms_limit = 0.2);
void test_accuracy(const float *expected, const float *result, unsigned num_values, double absolute_error_limit, double relative_error_limit, double local_relative_error_limit, double rms_limit);
void expect_equal(const unsigned char *ref, const unsigned char *result, unsigned width, unsigned height, unsigned largest_difference_limit = 1, float rms_limit = 0.2);
void test_accuracy(const float *expected, const float *result, unsigned num_values, double absolute_error_limit, double relative_error_limit, double local_relative_error_limit, double rms_limit);
#endif // !defined(_MOVIT_TEST_UTIL_H)
#endif // !defined(_MOVIT_TEST_UTIL_H)
UnsharpMaskEffect::UnsharpMaskEffect()
: blur(new BlurEffect),
mix(new MixEffect)
UnsharpMaskEffect::UnsharpMaskEffect()
: blur(new BlurEffect),
mix(new MixEffect)
}
return blur->set_float(key, value);
}
}
return blur->set_float(key, value);
}
class BlurEffect;
class EffectChain;
class MixEffect;
class BlurEffect;
class EffectChain;
class MixEffect;
#endif // !defined(_MOVIT_UNSHARP_MASK_EFFECT_H)
#endif // !defined(_MOVIT_UNSHARP_MASK_EFFECT_H)
#include "test_util.h"
#include "unsharp_mask_effect.h"
#include "test_util.h"
#include "unsharp_mask_effect.h"
TEST(UnsharpMaskEffectTest, NoAmountDoesNothing) {
const int size = 4;
TEST(UnsharpMaskEffectTest, NoAmountDoesNothing) {
const int size = 4;
// Add some leeway for the rest; unsharp masking is not expected to be extremely good.
expect_equal(expected_data, out_data, size, size, 0.1, 0.001);
}
// Add some leeway for the rest; unsharp masking is not expected to be extremely good.
expect_equal(expected_data, out_data, size, size, 0.1, 0.001);
}
extern string *movit_data_directory;
void hsv2rgb(float h, float s, float v, float *r, float *g, float *b)
extern string *movit_data_directory;
void hsv2rgb(float h, float s, float v, float *r, float *g, float *b)
assert(*offset >= 0.0f);
assert(*offset <= 1.0f);
}
assert(*offset >= 0.0f);
assert(*offset <= 1.0f);
}
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
// Converts a HSV color to RGB. Assumes h in [0, 2pi> or [-pi, pi>
void hsv2rgb(float h, float s, float v, float *r, float *g, float *b);
// Converts a HSV color to RGB. Assumes h in [0, 2pi> or [-pi, pi>
void hsv2rgb(float h, float s, float v, float *r, float *g, float *b);
// (estimated) squared errors of the two weights.
void combine_two_samples(float w1, float w2, float *offset, float *total_weight, float *sum_sq_error);
// (estimated) squared errors of the two weights.
void combine_two_samples(float w1, float w2, float *offset, float *total_weight, float *sum_sq_error);
#ifdef NDEBUG
#define check_error()
#else
#ifdef NDEBUG
#define check_error()
#else
VignetteEffect::VignetteEffect()
: center(0.5f, 0.5f),
aspect_correction(1.0f, 1.0f),
VignetteEffect::VignetteEffect()
: center(0.5f, 0.5f),
aspect_correction(1.0f, 1.0f),
Point2D flipped_center(center.x, 1.0f - center.y);
set_uniform_vec2(glsl_program_num, prefix, "flipped_center", (float *)&flipped_center);
}
Point2D flipped_center(center.x, 1.0f - center.y);
set_uniform_vec2(glsl_program_num, prefix, "flipped_center", (float *)&flipped_center);
}
class VignetteEffect : public Effect {
public:
VignetteEffect();
class VignetteEffect : public Effect {
public:
VignetteEffect();
float radius, inner_radius;
};
float radius, inner_radius;
};
#endif // !defined(_MOVIT_VIGNETTE_EFFECT_H)
#endif // !defined(_MOVIT_VIGNETTE_EFFECT_H)
#include "test_util.h"
#include "vignette_effect.h"
#include "test_util.h"
#include "vignette_effect.h"
TEST(VignetteEffectTest, HugeInnerRadiusDoesNothing) {
const int size = 4;
TEST(VignetteEffectTest, HugeInnerRadiusDoesNothing) {
const int size = 4;
expect_equal(expected_data, out_data, width, height);
}
expect_equal(expected_data, out_data, width, height);
}
using namespace Eigen;
using namespace std;
using namespace Eigen;
using namespace std;
namespace {
// Temperature is in Kelvin. Formula from http://en.wikipedia.org/wiki/Planckian_locus#Approximation .
namespace {
// Temperature is in Kelvin. Formula from http://en.wikipedia.org/wiki/Planckian_locus#Approximation .
rgb_to_xyz_matrix;
set_uniform_mat3(glsl_program_num, prefix, "correction_matrix", corr_matrix);
}
rgb_to_xyz_matrix;
set_uniform_mat3(glsl_program_num, prefix, "correction_matrix", corr_matrix);
}
class WhiteBalanceEffect : public Effect {
public:
WhiteBalanceEffect();
class WhiteBalanceEffect : public Effect {
public:
WhiteBalanceEffect();
float output_color_temperature;
};
float output_color_temperature;
};
#endif // !defined(_MOVIT_WHITE_BALANCE_EFFECT_H)
#endif // !defined(_MOVIT_WHITE_BALANCE_EFFECT_H)
#include "test_util.h"
#include "white_balance_effect.h"
#include "test_util.h"
#include "white_balance_effect.h"
TEST(WhiteBalanceEffectTest, GrayNeutralDoesNothing) {
float data[] = {
0.0f, 0.0f, 0.0f, 1.0f,
TEST(WhiteBalanceEffectTest, GrayNeutralDoesNothing) {
float data[] = {
0.0f, 0.0f, 0.0f, 1.0f,
EXPECT_GT(out_data[4 * 1 + 2] - out_data[4 * 1 + 1], 0.05);
EXPECT_GT(out_data[4 * 1 + 1] - out_data[4 * 1 + 0], 0.05);
}
EXPECT_GT(out_data[4 * 1 + 2] - out_data[4 * 1 + 1], 0.05);
EXPECT_GT(out_data[4 * 1 + 1] - out_data[4 * 1 + 0], 0.05);
}
#define HSV_WHEEL_SIZE 128
#define HSV_WHEEL_SIZE 128
GLuint hsv_wheel_num;
void draw_hsv_wheel(float y, float rad, float theta, float value)
GLuint hsv_wheel_num;
void draw_hsv_wheel(float y, float rad, float theta, float value)
// Some simple UI widgets for test use.
// Some simple UI widgets for test use.
void draw_hsv_wheel(float y, float rad, float theta, float value);
void draw_saturation_bar(float y, float saturation);
void make_hsv_wheel_texture();
void read_colorwheel(float xf, float yf, float *rad, float *theta, float *value);
void draw_hsv_wheel(float y, float rad, float theta, float value);
void draw_saturation_bar(float y, float saturation);
void make_hsv_wheel_texture();
void read_colorwheel(float xf, float yf, float *rad, float *theta, float *value);
#endif // !defined(_MOVIT_WIDGETS_H)
#endif // !defined(_MOVIT_WIDGETS_H)
using namespace Eigen;
using namespace std;
using namespace Eigen;
using namespace std;
namespace {
// OpenGL has texel center in (0.5, 0.5), but different formats have
namespace {
// OpenGL has texel center in (0.5, 0.5), but different formats have
#include "image_format.h"
#include "input.h"
#include "image_format.h"
#include "input.h"
class ResourcePool;
struct YCbCrFormat {
class ResourcePool;
struct YCbCrFormat {
ResourcePool *resource_pool;
};
ResourcePool *resource_pool;
};
#endif // !defined(_MOVIT_YCBCR_INPUT_H)
#endif // !defined(_MOVIT_YCBCR_INPUT_H)
#include "util.h"
#include "ycbcr_input.h"
#include "util.h"
#include "ycbcr_input.h"
TEST(YCbCrInput, Simple444) {
const int width = 1;
const int height = 5;
TEST(YCbCrInput, Simple444) {
const int width = 1;
const int height = 5;
glDeleteBuffers(1, &pbo);
}
glDeleteBuffers(1, &pbo);
}