namespace movit {
-EffectChain::EffectChain(float aspect_nom, float aspect_denom, ResourcePool *resource_pool)
+EffectChain::EffectChain(float aspect_nom, float aspect_denom, ResourcePool *resource_pool, GLenum intermediate_format)
: aspect_nom(aspect_nom),
aspect_denom(aspect_denom),
output_color_rgba(false),
output_color_ycbcr(false),
dither_effect(NULL),
+ intermediate_format(intermediate_format),
num_dither_bits(0),
output_origin(OUTPUT_ORIGIN_BOTTOM_LEFT),
finalized(false),
check_error();
glDisable(GL_DITHER);
check_error();
+ glEnable(GL_FRAMEBUFFER_SRGB);
+ check_error();
// Save original viewport.
GLuint x = 0, y = 0;
if (!last_phase) {
find_output_size(phase);
- GLuint tex_num = resource_pool->create_2d_texture(GL_RGBA16F, phase->output_width, phase->output_height);
+ GLuint tex_num = resource_pool->create_2d_texture(intermediate_format, phase->output_width, phase->output_height);
output_textures->insert(make_pair(phase, tex_num));
}
// will create its own that is not shared with anything else. Does not take
// ownership of the passed-in ResourcePool, but will naturally take ownership
// of its own internal one if created.
- EffectChain(float aspect_nom, float aspect_denom, ResourcePool *resource_pool = NULL);
+ EffectChain(float aspect_nom, float aspect_denom, ResourcePool *resource_pool = NULL, GLenum intermediate_format = GL_RGBA16F);
~EffectChain();
// User API:
std::vector<Input *> inputs; // Also contained in nodes.
std::vector<Phase *> phases;
+ GLenum intermediate_format;
unsigned num_dither_bits;
OutputOrigin output_origin;
bool finalized;
free(saved_locale);
}
+TEST(EffectChainTest, sRGBIntermediate) {
+ float data[] = {
+ 0.0f, 0.25f, 0.0f, 1.0f,
+ };
+ float expected_data[] = {
+ 0.0f, 0.25048828125f, 0.0f, 1.0f,
+ };
+ float out_data[4];
+ EffectChainTester tester(data, 1, 1, FORMAT_RGBA_PREMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA16F_ARB, GL_SRGB8);
+ tester.get_chain()->add_effect(new IdentityEffect());
+ tester.get_chain()->add_effect(new BouncingIdentityEffect());
+ tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR);
+
+ expect_equal(expected_data, out_data, 4, 1, 1e-4);
+}
} // namespace movit
// of errors are stored here.
//
// If this value is above 0, we will round off explicitly at the very end
-// of the shader.
+// of the shader. Note the following limitations:
+//
+// - The measurement is done on linear 8-bit, not any sRGB format,
+// 10-bit output, or the likes.
+// - This only covers the final pass; intermediates are not covered
+// (only relevant if you use e.g. GL_SRGB8 intermediates).
extern int movit_num_wrongly_rounded;
// Whether the GPU in use supports GL_EXT_texture_sRGB.
EffectChainTester::EffectChainTester(const float *data, unsigned width, unsigned height,
MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve,
- GLenum framebuffer_format)
- : chain(width, height, get_static_pool()), width(width), height(height), framebuffer_format(framebuffer_format), output_added(false), finalized(false)
+ GLenum framebuffer_format,
+ GLenum intermediate_format)
+ : chain(width, height, get_static_pool(), intermediate_format),
+ width(width),
+ height(height),
+ framebuffer_format(framebuffer_format),
+ output_added(false),
+ finalized(false)
{
CHECK(init_movit(".", MOVIT_DEBUG_OFF));
MovitPixelFormat pixel_format = FORMAT_GRAYSCALE,
Colorspace color_space = COLORSPACE_sRGB,
GammaCurve gamma_curve = GAMMA_LINEAR,
- GLenum framebuffer_format = GL_RGBA16F_ARB);
+ GLenum framebuffer_format = GL_RGBA16F_ARB,
+ GLenum intermediate_format = GL_RGBA16F_ARB);
~EffectChainTester();
EffectChain *get_chain() { return &chain; }
// changes, even within git versions. There is no specific version
// documentation outside the regular changelogs, though.
-#define MOVIT_VERSION 18
+#define MOVIT_VERSION 19
#endif // !defined(_MOVIT_VERSION_H)