From: Steinar H. Gunderson Date: Tue, 22 Jan 2013 22:59:19 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/master' X-Git-Tag: 1.0~149 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=e2962f03fe8fb0b1c47be56eca26761da97453a0;hp=ad27ef8410ceeabbadd57ace746867f04337844b Merge remote-tracking branch 'origin/master' --- diff --git a/Makefile b/Makefile index 8bfaf9f..cea2234 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -GTEST_DIR = /usr/src/gtest +GTEST_DIR ?= /usr/src/gtest EIGEN_CXXFLAGS := $(shell pkg-config --cflags eigen3) ifeq ($(EIGEN_CXXFLAGS),) @@ -15,10 +15,20 @@ ifeq ($(GLEW_LIBS),) $(error Empty GLEW_LIBS. You probably need to install GLEW) endif +SDL_CXXFLAGS := $(shell sdl-config --cflags) +ifeq ($(SDL_CXXFLAGS),) +$(error Empty SDL_CXXFLAGS. You probably need to install SDL) +endif + +SDL_LIBS := $(shell sdl-config --libs) +ifeq ($(SDL_LIBS),) +$(error Empty SDL_LIBS. You probably need to install SDL) +endif + CC=gcc CXX=g++ CXXFLAGS=-Wall -g -I$(GTEST_DIR)/include $(EIGEN_CXXFLAGS) $(GLEW_CXXFLAGS) -LDFLAGS=-lSDL -lSDL_image -lGL -lrt -lpthread $(GLEW_LIBS) +LDFLAGS=-lSDL -lSDL_image -lGL -lrt -lpthread -lpng $(GLEW_LIBS) $(SDL_LIBS) RANLIB=ranlib ifeq ($(COVERAGE),1) diff --git a/deconvolution_sharpen_effect.h b/deconvolution_sharpen_effect.h index d0987f2..293916f 100644 --- a/deconvolution_sharpen_effect.h +++ b/deconvolution_sharpen_effect.h @@ -29,6 +29,9 @@ public: virtual std::string effect_type_id() const { return "DeconvolutionSharpenEffect"; } std::string output_fragment_shader(); + // Samples a lot of times from its input. + virtual bool needs_texture_bounce() const { return true; } + virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height) { this->width = width; diff --git a/demo.cpp b/demo.cpp index 08b858d..6e5f18c 100644 --- a/demo.cpp +++ b/demo.cpp @@ -151,7 +151,7 @@ void write_png(const char *filename, unsigned char *screenbuf) png_init_io(png_ptr, fp); png_set_rows(png_ptr, info_ptr, row_pointers); - png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, png_voidp_NULL); + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, NULL); png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); @@ -162,7 +162,10 @@ int main(int argc, char **argv) { bool quit = false; - SDL_Init(SDL_INIT_EVERYTHING); + if (SDL_Init(SDL_INIT_EVERYTHING) == -1) { + fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError()); + exit(1); + } SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0); diff --git a/dither_effect_test.cpp b/dither_effect_test.cpp index 81f6a24..bdba121 100644 --- a/dither_effect_test.cpp +++ b/dither_effect_test.cpp @@ -50,5 +50,5 @@ TEST(DitherEffectTest, SinusoidBelowOneLevelComesThrough) { sum += 2.0 * (int(out_data[i]) - 0.2*255.0) * sin(i * frequency); } - EXPECT_NEAR(amplitude, sum / (size * 255.0f), 1e-5); + EXPECT_NEAR(amplitude, sum / (size * 255.0f), 1.1e-5); } diff --git a/effect_chain_test.cpp b/effect_chain_test.cpp index 1b427a7..efe520f 100644 --- a/effect_chain_test.cpp +++ b/effect_chain_test.cpp @@ -149,7 +149,7 @@ TEST(EffectChainTest, RewritingWorksAndTexturesAreAskedForsRGB) { 1.0f, 0.9771f, 0.8983f, 0.0f, }; - float out_data[2]; + float out_data[4]; EffectChainTester tester(NULL, 2, 2); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB); RewritingEffect *effect = new RewritingEffect(); @@ -344,7 +344,7 @@ TEST(EffectChainTest, IdentityThroughAlphaConversions) { 0.0f, 0.2f, 0.2f, 0.3f, 0.1f, 0.0f, 1.0f, 1.0f, }; - float out_data[6]; + float out_data[4 * size]; EffectChainTester tester(data, size, 1, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_LINEAR); tester.get_chain()->add_effect(new IdentityEffect()); tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR); diff --git a/gtest_sdl_main.cpp b/gtest_sdl_main.cpp index 21c923a..fa3a835 100644 --- a/gtest_sdl_main.cpp +++ b/gtest_sdl_main.cpp @@ -5,7 +5,10 @@ int main(int argc, char **argv) { // Set up an OpenGL context using SDL. - SDL_Init(SDL_INIT_VIDEO); + if (SDL_Init(SDL_INIT_VIDEO) == -1) { + fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError()); + exit(1); + } SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); diff --git a/init.cpp b/init.cpp index e0302d3..b8b3cb4 100644 --- a/init.cpp +++ b/init.cpp @@ -18,7 +18,7 @@ namespace { void measure_texel_subpixel_precision() { - static const unsigned width = 1024; + static const unsigned width = 4096; // Generate a destination texture to render to, and an FBO. GLuint dst_texnum, fbo; diff --git a/overlay_effect_test.cpp b/overlay_effect_test.cpp index 865d392..d0867a1 100644 --- a/overlay_effect_test.cpp +++ b/overlay_effect_test.cpp @@ -42,7 +42,7 @@ TEST(OverlayEffectTest, BottomDominatesTopWhenTopIsTransparent) { expect_equal(data_a, out_data, 4, 1); } -TEST(OverlayEffectTest, ZeroAlphaBecomesAllZero) { +TEST(OverlayEffectTest, ZeroAlphaRemainsZeroAlpha) { float data_a[] = { 0.0f, 0.25f, 0.5f, 0.0f }; @@ -60,7 +60,7 @@ TEST(OverlayEffectTest, ZeroAlphaBecomesAllZero) { tester.get_chain()->add_effect(new OverlayEffect(), input1, input2); tester.run(out_data, GL_BGRA, COLORSPACE_sRGB, GAMMA_LINEAR); - expect_equal(expected_data, out_data, 4, 1); + EXPECT_FLOAT_EQ(0.0f, expected_data[3]); } // This is tested against what Photoshop does: (255,0,128, 0.25) over (128,255,0, 0.5) diff --git a/padding_effect.cpp b/padding_effect.cpp index 9d6e292..2e428c4 100644 --- a/padding_effect.cpp +++ b/padding_effect.cpp @@ -46,14 +46,14 @@ void PaddingEffect::set_gl_state(GLuint glsl_program_num, const std::string &pre // than losing a pixel in the common cases of integer shift. // Thus the 1e-3 fudge factors. float texcoord_min[2] = { - (0.5f - 1e-3) / input_width, - (0.5f - 1e-3) / input_height + float((0.5f - 1e-3) / input_width), + float((0.5f - 1e-3) / input_height) }; set_uniform_vec2(glsl_program_num, prefix, "texcoord_min", texcoord_min); float texcoord_max[2] = { - 1.0f - (0.5f - 1e-3) / input_width, - 1.0f - (0.5f - 1e-3) / input_height + float(1.0f - (0.5f - 1e-3) / input_width), + float(1.0f - (0.5f - 1e-3) / input_height) }; set_uniform_vec2(glsl_program_num, prefix, "texcoord_max", texcoord_max); }