From c34865f55569942959da2815a790b5ad76ba0057 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 15 Mar 2014 21:51:32 +0100 Subject: [PATCH] Revert "Support pad/crop from bottom, not just from the top." This turned out not to be so useful after all, as we'd like a more consistent top-left coordinate system, and changes to do that will obsolete this patch. This reverts commit e92a5ffa19eb67b4db5af1db8559630139073668. --- padding_effect.cpp | 15 +++++---------- padding_effect.h | 5 ----- padding_effect_test.cpp | 31 ------------------------------- 3 files changed, 5 insertions(+), 46 deletions(-) diff --git a/padding_effect.cpp b/padding_effect.cpp index a70025d..15381a3 100644 --- a/padding_effect.cpp +++ b/padding_effect.cpp @@ -14,15 +14,13 @@ PaddingEffect::PaddingEffect() output_width(1280), output_height(720), top(0), - left(0), - pad_from_bottom(0) + left(0) { register_vec4("border_color", (float *)&border_color); register_int("width", &output_width); register_int("height", &output_height); register_float("top", &top); register_float("left", &left); - register_int("pad_from_bottom", &pad_from_bottom); } string PaddingEffect::output_fragment_shader() @@ -34,13 +32,10 @@ void PaddingEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, { Effect::set_gl_state(glsl_program_num, prefix, sampler_num); - float offset[2]; - offset[0] = left / output_width; - if (pad_from_bottom) { - offset[1] = top / output_height; - } else { - offset[1] = (output_height - input_height - top) / output_height; - } + float offset[2] = { + left / output_width, + (output_height - input_height - top) / output_height + }; set_uniform_vec2(glsl_program_num, prefix, "offset", offset); float scale[2] = { diff --git a/padding_effect.h b/padding_effect.h index fdefbe0..3bd4aac 100644 --- a/padding_effect.h +++ b/padding_effect.h @@ -11,10 +11,6 @@ // The border color is taken to be in linear gamma, sRGB, with premultiplied alpha. // You may not change it after calling finalize(), since that could change the // graph (need_linear_light() etc. depend on the border color you choose). -// -// As a convenience, if the flag “pad_from_bottom” is nonzero, the “top” parameter -// will mean pixels from the bottom (matching OpenGL's usual bottom-left convention), -// instead of from the top as usual. #include #include @@ -43,7 +39,6 @@ private: int input_width, input_height; int output_width, output_height; float top, left; - int pad_from_bottom; }; } // namespace movit diff --git a/padding_effect_test.cpp b/padding_effect_test.cpp index 8c05a1e..767f3e8 100644 --- a/padding_effect_test.cpp +++ b/padding_effect_test.cpp @@ -208,37 +208,6 @@ TEST(PaddingEffectTest, Crop) { expect_equal(expected_data, out_data, 1, 1); } -TEST(PaddingEffectTest, CropFromBottom) { - float data[2 * 2] = { - 1.0f, 0.5f, - 0.8f, 0.3f, - }; - float expected_data[1 * 1] = { - 0.5f, - }; - float out_data[1 * 1]; - - EffectChainTester tester(NULL, 1, 1); - - ImageFormat format; - format.color_space = COLORSPACE_sRGB; - format.gamma_curve = GAMMA_LINEAR; - - FlatInput *input = new FlatInput(format, FORMAT_GRAYSCALE, GL_FLOAT, 2, 2); - input->set_pixel_data(data); - tester.get_chain()->add_input(input); - - Effect *effect = tester.get_chain()->add_effect(new PaddingEffect()); - CHECK(effect->set_int("width", 1)); - CHECK(effect->set_int("height", 1)); - CHECK(effect->set_float("left", -1.0f)); - CHECK(effect->set_float("top", -1.0f)); - CHECK(effect->set_int("pad_from_bottom", 1)); - - tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR, OUTPUT_ALPHA_FORMAT_PREMULTIPLIED); - expect_equal(expected_data, out_data, 1, 1); -} - TEST(PaddingEffectTest, AlphaIsCorrectEvenWithNonLinearInputsAndOutputs) { float data[2 * 1] = { 1.0f, -- 2.39.5