From: Steinar H. Gunderson Date: Wed, 15 Nov 2017 19:45:41 +0000 (+0100) Subject: Use nullptr everywhere, now that we have C++11. X-Git-Tag: 1.6.0~71 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=f34b1c36acd27944f00885edfc55363432bfec8e Use nullptr everywhere, now that we have C++11. --- diff --git a/blur_effect.cpp b/blur_effect.cpp index 6c1fd3a..d2178d8 100644 --- a/blur_effect.cpp +++ b/blur_effect.cpp @@ -22,7 +22,7 @@ BlurEffect::BlurEffect() // The first blur pass will forward resolution information to us. hpass = new SingleBlurPassEffect(this); CHECK(hpass->set_int("direction", SingleBlurPassEffect::HORIZONTAL)); - vpass = new SingleBlurPassEffect(NULL); + vpass = new SingleBlurPassEffect(nullptr); CHECK(vpass->set_int("direction", SingleBlurPassEffect::VERTICAL)); update_radius(); @@ -111,7 +111,7 @@ SingleBlurPassEffect::SingleBlurPassEffect(BlurEffect *parent) direction(HORIZONTAL), width(1280), height(720), - uniform_samples(NULL) + uniform_samples(nullptr) { register_float("radius", &radius); register_int("direction", (int *)&direction); @@ -209,7 +209,7 @@ void SingleBlurPassEffect::set_gl_state(GLuint glsl_program_num, const string &p float pos1 = base_pos / (float)size; float pos, total_weight; - combine_two_samples(w1, w2, pos1, 1.0 / (float)size, size, num_subtexels, inv_num_subtexels, &pos, &total_weight, NULL); + combine_two_samples(w1, w2, pos1, 1.0 / (float)size, size, num_subtexels, inv_num_subtexels, &pos, &total_weight, nullptr); uniform_samples[2 * i + 0] = pos; uniform_samples[2 * i + 1] = total_weight; diff --git a/blur_effect.h b/blur_effect.h index 8ad3da9..69bd663 100644 --- a/blur_effect.h +++ b/blur_effect.h @@ -63,7 +63,7 @@ private: class SingleBlurPassEffect : public Effect { public: - // If parent is non-NULL, calls to inform_input_size will be forwarded + // If parent is non-nullptr, calls to inform_input_size will be forwarded // so that it can make reasonable decisions for both blur passes. SingleBlurPassEffect(BlurEffect *parent); virtual ~SingleBlurPassEffect(); @@ -77,7 +77,7 @@ public: virtual AlphaHandling alpha_handling() const { return INPUT_PREMULTIPLIED_ALPHA_KEEP_BLANK; } virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height) { - if (parent != NULL) { + if (parent != nullptr) { parent->inform_input_size(input_num, width, height); } } diff --git a/deconvolution_sharpen_effect.cpp b/deconvolution_sharpen_effect.cpp index 2db15dc..37a55e9 100644 --- a/deconvolution_sharpen_effect.cpp +++ b/deconvolution_sharpen_effect.cpp @@ -32,7 +32,7 @@ DeconvolutionSharpenEffect::DeconvolutionSharpenEffect() last_gaussian_radius(-1.0f), last_correlation(-1.0f), last_noise(-1.0f), - uniform_samples(NULL) + uniform_samples(nullptr) { register_int("matrix_size", &R); register_float("circle_radius", &circle_radius); diff --git a/deinterlace_effect_test.cpp b/deinterlace_effect_test.cpp index d2045eb..f880f0f 100644 --- a/deinterlace_effect_test.cpp +++ b/deinterlace_effect_test.cpp @@ -33,7 +33,7 @@ TEST(DeinterlaceTest, ConstantColor) { 0.3f, 0.3f, }; float out_data[12]; - EffectChainTester tester(NULL, 2, 6); + EffectChainTester tester(nullptr, 2, 6); Effect *input1 = tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, 2, 3); Effect *input2 = tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, 2, 3); Effect *input3 = tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, 2, 3); @@ -79,7 +79,7 @@ TEST(DeinterlaceTest, VerticalInterpolation) { fill(neg_blowout_data, neg_blowout_data + width * height, -100.0f); fill(pos_blowout_data, pos_blowout_data + width * height, 100.0f); - EffectChainTester tester(NULL, width, height * 2); + EffectChainTester tester(nullptr, width, height * 2); Effect *input1 = tester.add_input(neg_blowout_data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); Effect *input2 = tester.add_input(neg_blowout_data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); Effect *input3 = tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); @@ -131,7 +131,7 @@ TEST(DeinterlaceTest, DiagonalInterpolation) { fill(neg_blowout_data, neg_blowout_data + width * height, -100.0f); fill(pos_blowout_data, pos_blowout_data + width * height, 100.0f); - EffectChainTester tester(NULL, width, height * 2); + EffectChainTester tester(nullptr, width, height * 2); Effect *input1 = tester.add_input(neg_blowout_data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); Effect *input2 = tester.add_input(neg_blowout_data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); Effect *input3 = tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); @@ -172,7 +172,7 @@ TEST(DeinterlaceTest, FlickerBox) { float out_data[width * height * 2]; { - EffectChainTester tester(NULL, width, height * 2); + EffectChainTester tester(nullptr, width, height * 2); Effect *white_input = tester.add_input(white_data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); Effect *black_input = tester.add_input(black_data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); Effect *deinterlace_effect = tester.get_chain()->add_effect(new DeinterlaceEffect(), white_input, black_input, white_input, black_input, white_input); @@ -184,7 +184,7 @@ TEST(DeinterlaceTest, FlickerBox) { } { - EffectChainTester tester(NULL, width, height * 2); + EffectChainTester tester(nullptr, width, height * 2); Effect *white_input = tester.add_input(white_data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); Effect *black_input = tester.add_input(black_data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, height); Effect *deinterlace_effect = tester.get_chain()->add_effect(new DeinterlaceEffect(), white_input, black_input, white_input, black_input, white_input); @@ -217,7 +217,7 @@ void BM_DeinterlaceEffect_Gray(benchmark::State &state) field5[i] = rand(); } - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); Effect *input1 = tester.add_input(field1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, field_height); Effect *input2 = tester.add_input(field2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, field_height); Effect *input3 = tester.add_input(field3, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, width, field_height); diff --git a/demo.cpp b/demo.cpp index dd04c84..53a5d72 100644 --- a/demo.cpp +++ b/demo.cpp @@ -111,13 +111,13 @@ void mouse(int x, int y) unsigned char *load_image(const char *filename, unsigned *w, unsigned *h) { SDL_Surface *img = IMG_Load(filename); - if (img == NULL) { + if (img == nullptr) { fprintf(stderr, "Load of '%s' failed\n", filename); exit(1); } SDL_PixelFormat rgba_fmt; - rgba_fmt.palette = NULL; + rgba_fmt.palette = nullptr; rgba_fmt.BitsPerPixel = 32; rgba_fmt.BytesPerPixel = 8; rgba_fmt.Rloss = rgba_fmt.Gloss = rgba_fmt.Bloss = rgba_fmt.Aloss = 0; @@ -151,7 +151,7 @@ unsigned char *load_image(const char *filename, unsigned *w, unsigned *h) void write_png(const char *filename, unsigned char *screenbuf) { FILE *fp = fopen(filename, "wb"); - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, NULL, NULL); png_infop info_ptr = png_create_info_struct(png_ptr); if (setjmp(png_jmpbuf(png_ptr))) { @@ -169,7 +169,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, NULL); + png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_BGR, nullptr); png_destroy_write_struct(&png_ptr, &info_ptr); fclose(fp); @@ -200,10 +200,10 @@ int main(int argc, char **argv) WIDTH, HEIGHT, SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(window); - assert(context != NULL); + assert(context != nullptr); #else SDL_SetVideoMode(WIDTH, HEIGHT, 0, SDL_OPENGL); - SDL_WM_SetCaption("OpenGL window", NULL); + SDL_WM_SetCaption("OpenGL window", nullptr); #endif CHECK(init_movit(".", MOVIT_DEBUG_ON)); @@ -243,7 +243,7 @@ int main(int argc, char **argv) GLuint pbo; glGenBuffers(1, &pbo); glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, pbo); - glBufferData(GL_PIXEL_PACK_BUFFER_ARB, WIDTH * HEIGHT * 4, NULL, GL_STREAM_READ); + glBufferData(GL_PIXEL_PACK_BUFFER_ARB, WIDTH * HEIGHT * 4, nullptr, GL_STREAM_READ); init_hsv_resources(); check_error(); @@ -255,7 +255,7 @@ int main(int argc, char **argv) clock_gettime(CLOCK_MONOTONIC, &start); #else struct timeval start, now; - gettimeofday(&start, NULL); + gettimeofday(&start, nullptr); #endif while (!quit) { @@ -334,7 +334,7 @@ int main(int argc, char **argv) double elapsed = now.tv_sec - start.tv_sec + 1e-9 * (now.tv_nsec - start.tv_nsec); #else - gettimeofday(&now, NULL); + gettimeofday(&now, nullptr); double elapsed = now.tv_sec - start.tv_sec + 1e-6 * (now.tv_usec - start.tv_usec); #endif diff --git a/effect_chain.cpp b/effect_chain.cpp index a9d9e1e..0c46768 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -49,8 +49,8 @@ EffectChain::EffectChain(float aspect_nom, float aspect_denom, ResourcePool *res aspect_denom(aspect_denom), output_color_rgba(false), num_output_color_ycbcr(0), - dither_effect(NULL), - ycbcr_conversion_effect_node(NULL), + dither_effect(nullptr), + ycbcr_conversion_effect_node(nullptr), intermediate_format(GL_RGBA16F), intermediate_transformation(NO_FRAMEBUFFER_TRANSFORMATION), num_dither_bits(0), @@ -58,7 +58,7 @@ EffectChain::EffectChain(float aspect_nom, float aspect_denom, ResourcePool *res finalized(false), resource_pool(resource_pool), do_phase_timing(false) { - if (resource_pool == NULL) { + if (resource_pool == nullptr) { this->resource_pool = new ResourcePool(); owns_resource_pool = true; } else { @@ -781,7 +781,7 @@ void EffectChain::output_dot(const char *filename) } FILE *fp = fopen(filename, "w"); - if (fp == NULL) { + if (fp == nullptr) { perror(filename); exit(1); } @@ -825,7 +825,7 @@ void EffectChain::output_dot(const char *filename) if (nodes[i]->outgoing_links.empty() && !nodes[i]->disabled) { // Output node. - vector labels = get_labels_for_edge(nodes[i], NULL); + vector labels = get_labels_for_edge(nodes[i], nullptr); output_dot_edge(fp, from_node_id, "output", labels); } } @@ -838,7 +838,7 @@ vector EffectChain::get_labels_for_edge(const Node *from, const Node *to { vector labels; - if (to != NULL && to->effect->needs_texture_bounce()) { + if (to != nullptr && to->effect->needs_texture_bounce()) { labels.push_back("needs_bounce"); } if (from->effect->changes_output_size()) { @@ -1880,7 +1880,7 @@ void EffectChain::render_to_fbo(GLuint dest_fbo, unsigned width, unsigned height GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); assert(status == GL_FRAMEBUFFER_COMPLETE); glViewport(x, y, width, height); - if (dither_effect != NULL) { + if (dither_effect != nullptr) { CHECK(dither_effect->set_int("output_width", width)); CHECK(dither_effect->set_int("output_height", height)); } diff --git a/effect_chain.h b/effect_chain.h index c292b38..54cf0e5 100644 --- a/effect_chain.h +++ b/effect_chain.h @@ -216,11 +216,11 @@ class EffectChain { public: // Aspect: e.g. 16.0f, 9.0f for 16:9. // resource_pool is a pointer to a ResourcePool with which to share shaders - // and other resources (see resource_pool.h). If NULL (the default), + // and other resources (see resource_pool.h). If nullptr (the default), // 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 = nullptr); ~EffectChain(); // User API: @@ -391,7 +391,7 @@ public: Effect *last_added_effect() { if (nodes.empty()) { - return NULL; + return nullptr; } else { return nodes.back()->effect; } diff --git a/effect_chain_test.cpp b/effect_chain_test.cpp index 97b90ed..1200876 100644 --- a/effect_chain_test.cpp +++ b/effect_chain_test.cpp @@ -136,7 +136,7 @@ public: template class RewritingEffect : public Effect { public: - RewritingEffect() : effect(new T()), replaced_node(NULL) {} + RewritingEffect() : effect(new T()), replaced_node(nullptr) {} virtual string effect_type_id() const { return "RewritingEffect[" + effect->effect_type_id() + "]"; } string output_fragment_shader() { EXPECT_TRUE(false); return read_file("identity.frag"); } virtual void rewrite_graph(EffectChain *graph, Node *self) { @@ -188,7 +188,7 @@ TEST(EffectChainTest, RewritingWorksAndTexturesAreAskedForsRGB) { 0.0000f, 0.0000f, 0.0000f, 1.0000f }; float out_data[4 * 4]; - EffectChainTester tester(NULL, 1, 4); + EffectChainTester tester(nullptr, 1, 4); tester.add_input(data, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_sRGB); RewritingEffect *effect = new RewritingEffect(); tester.get_chain()->add_effect(effect); @@ -262,7 +262,7 @@ TEST(EffectChainTest, HandlesInputChangingColorspace) { }; float out_data[size]; - EffectChainTester tester(NULL, 4, 1, FORMAT_GRAYSCALE); + EffectChainTester tester(nullptr, 4, 1, FORMAT_GRAYSCALE); // First say that we have sRGB, linear input. ImageFormat format; @@ -352,7 +352,7 @@ TEST(EffectChainTest, IdentityThroughGPUsRGBConversions) { expected_data[i] = i / 255.0; }; float out_data[256]; - EffectChainTester tester(NULL, 256, 1); + EffectChainTester tester(nullptr, 256, 1); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB); tester.get_chain()->add_effect(new IdentityEffect()); tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB); @@ -438,7 +438,7 @@ private: // which outputs blank alpha. class RewritingToBlueInput : public Input { public: - RewritingToBlueInput() : blue_node(NULL) { register_int("needs_mipmaps", &needs_mipmaps); } + RewritingToBlueInput() : blue_node(nullptr) { register_int("needs_mipmaps", &needs_mipmaps); } virtual string effect_type_id() const { return "RewritingToBlueInput"; } string output_fragment_shader() { EXPECT_TRUE(false); return read_file("identity.frag"); } virtual void rewrite_graph(EffectChain *graph, Node *self) { @@ -474,7 +474,7 @@ TEST(EffectChainTest, NoAlphaConversionsWithBlankAlpha) { 0.0f, 0.0f, 1.0f, 1.0f, }; float out_data[4 * size]; - EffectChainTester tester(NULL, size, 1); + EffectChainTester tester(nullptr, size, 1); RewritingToBlueInput *input = new RewritingToBlueInput(); tester.get_chain()->add_input(input); tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR, OUTPUT_ALPHA_FORMAT_PREMULTIPLIED); @@ -503,7 +503,7 @@ TEST(EffectChainTest, NoAlphaConversionsWithBlankAlphaPreservingEffect) { 0.0f, 0.0f, 1.0f, 1.0f, }; float out_data[4 * size]; - EffectChainTester tester(NULL, size, 1); + EffectChainTester tester(nullptr, size, 1); tester.get_chain()->add_input(new BlueInput()); tester.get_chain()->add_effect(new BlankAlphaPreservingEffect()); RewritingEffect *effect = new RewritingEffect(); @@ -529,7 +529,7 @@ TEST(EffectChainTest, AlphaConversionsWithNonBlankAlphaPreservingEffect) { 0.0f, 0.0f, 1.0f, 1.0f, }; float out_data[4 * size]; - EffectChainTester tester(NULL, size, 1); + EffectChainTester tester(nullptr, size, 1); tester.get_chain()->add_input(new BlueInput()); tester.get_chain()->add_effect(new IdentityEffect()); // Not BlankAlphaPreservingEffect. RewritingEffect *effect = new RewritingEffect(); @@ -684,7 +684,7 @@ TEST(EffectChainTest, MipmapsWithNonMipmapCapableInput) { 0.25f, 0.25f, 0.25f, 0.25f, }; float out_data[4 * 16]; - EffectChainTester tester(NULL, 4, 16, FORMAT_GRAYSCALE); + EffectChainTester tester(nullptr, 4, 16, FORMAT_GRAYSCALE); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -796,7 +796,7 @@ TEST(EffectChainTest, DiamondGraph) { MultiplyEffect *mul_two = new MultiplyEffect(); ASSERT_TRUE(mul_two->set_vec4("factor", two)); - EffectChainTester tester(NULL, 2, 2); + EffectChainTester tester(nullptr, 2, 2); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -847,7 +847,7 @@ TEST(EffectChainTest, DiamondGraphWithOneInputUsedInTwoPhases) { BouncingIdentityEffect *bounce = new BouncingIdentityEffect(); - EffectChainTester tester(NULL, 2, 2); + EffectChainTester tester(nullptr, 2, 2); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -877,7 +877,7 @@ TEST(EffectChainTest, EffectUsedTwiceOnlyGetsOneGammaConversion) { }; float out_data[2 * 2]; - EffectChainTester tester(NULL, 2, 2); + EffectChainTester tester(nullptr, 2, 2); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_sRGB); // MirrorEffect does not get linear light, so the conversions will be @@ -910,7 +910,7 @@ TEST(EffectChainTest, EffectUsedTwiceOnlyGetsOneColorspaceConversion) { }; float out_data[2 * 2]; - EffectChainTester tester(NULL, 2, 2); + EffectChainTester tester(nullptr, 2, 2); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_REC_601_625, GAMMA_LINEAR); // MirrorEffect does not get linear light, so the conversions will be @@ -954,7 +954,7 @@ TEST(EffectChainTest, SameInputsGiveSameOutputs) { }; float out_data[4 * 3]; - EffectChainTester tester(NULL, 4, 3); // Note non-square aspect. + EffectChainTester tester(nullptr, 4, 3); // Note non-square aspect. ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -999,7 +999,7 @@ TEST(EffectChainTest, AspectRatioConversion) { // (keep the height, round the width 9.333 to 9). float out_data[9 * 7]; - EffectChainTester tester(NULL, 4, 3); + EffectChainTester tester(nullptr, 4, 3); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -1044,7 +1044,7 @@ TEST(EffectChainTest, FirstPhaseWithNoTextureCoordinates) { FlatInput *input = new FlatInput(format, FORMAT_GRAYSCALE, GL_FLOAT, 1, size); input->set_pixel_data(data); - EffectChainTester tester(NULL, 1, size); + EffectChainTester tester(nullptr, 1, size); tester.get_chain()->add_input(new BlueInput()); Effect *phase1_end = tester.get_chain()->add_effect(new BouncingIdentityEffect()); tester.get_chain()->add_input(input); @@ -1224,7 +1224,7 @@ TEST(EffectChainTest, IdentityWithOwnPool) { check_error(); glBindTexture(GL_TEXTURE_2D, texnum); check_error(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT, nullptr); check_error(); glGenFramebuffers(1, &fbo); @@ -1282,7 +1282,7 @@ TEST(EffectChainTest, StringStreamLocalesWork) { // setlocale() behind-the-scenes, and that might corrupt the returned // pointer, so we need to take our own copy of it here. char *saved_locale = setlocale(LC_ALL, "nb_NO.UTF_8"); - if (saved_locale == NULL) { + if (saved_locale == nullptr) { // The locale wasn't available. return; } diff --git a/fft_convolution_effect_test.cpp b/fft_convolution_effect_test.cpp index 9d395f2..d1c1626 100644 --- a/fft_convolution_effect_test.cpp +++ b/fft_convolution_effect_test.cpp @@ -29,7 +29,7 @@ TEST(FFTConvolutionEffectTest, Identity) { } kernel[0] = 1.0f; - EffectChainTester tester(NULL, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, size, size); FFTConvolutionEffect *fft_effect = new FFTConvolutionEffect(size, size, convolve_size, convolve_size); @@ -64,7 +64,7 @@ TEST(FFTConvolutionEffectTest, Constant) { } kernel[0] = f; - EffectChainTester tester(NULL, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, size, size); FFTConvolutionEffect *fft_effect = new FFTConvolutionEffect(size, size, convolve_size, convolve_size); @@ -98,7 +98,7 @@ TEST(FFTConvolutionEffectTest, MoveRight) { }; float out_data[size * size]; - EffectChainTester tester(NULL, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, size, size); FFTConvolutionEffect *fft_effect = new FFTConvolutionEffect(size, size, convolve_size, convolve_size); @@ -131,7 +131,7 @@ TEST(FFTConvolutionEffectTest, MoveDown) { }; float out_data[size * size]; - EffectChainTester tester(NULL, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, size, size); FFTConvolutionEffect *fft_effect = new FFTConvolutionEffect(size, size, convolve_size, convolve_size); @@ -164,7 +164,7 @@ TEST(FFTConvolutionEffectTest, MergeWithLeft) { }; float out_data[size * size]; - EffectChainTester tester(NULL, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, size, size); FFTConvolutionEffect *fft_effect = new FFTConvolutionEffect(size, size, convolve_size, convolve_size); @@ -197,7 +197,7 @@ TEST(FFTConvolutionEffectTest, NegativeCoefficients) { }; float out_data[size * size]; - EffectChainTester tester(NULL, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, size, size); FFTConvolutionEffect *fft_effect = new FFTConvolutionEffect(size, size, convolve_width, convolve_height); diff --git a/fft_input.cpp b/fft_input.cpp index f9339df..bbc4a5f 100644 --- a/fft_input.cpp +++ b/fft_input.cpp @@ -19,7 +19,7 @@ FFTInput::FFTInput(unsigned width, unsigned height) fft_height(height), convolve_width(width), convolve_height(height), - pixel_data(NULL) + pixel_data(nullptr) { register_int("fft_width", &fft_width); register_int("fft_height", &fft_height); @@ -39,7 +39,7 @@ void FFTInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsig check_error(); if (texture_num == 0) { - assert(pixel_data != NULL); + assert(pixel_data != nullptr); // Do the FFT. Our FFTs should typically be small enough and // the data changed often enough that FFTW_ESTIMATE should be diff --git a/flat_input.cpp b/flat_input.cpp index 8f24d86..29165db 100644 --- a/flat_input.cpp +++ b/flat_input.cpp @@ -22,7 +22,7 @@ FlatInput::FlatInput(ImageFormat image_format, MovitPixelFormat pixel_format_in, height(height), pitch(width), owns_texture(false), - pixel_data(NULL), + pixel_data(nullptr), fixup_swap_rb(false), fixup_red_to_grayscale(false) { @@ -66,7 +66,7 @@ void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsi glActiveTexture(GL_TEXTURE0 + *sampler_num); check_error(); - if (texture_num == 0 && (pbo != 0 || pixel_data != NULL)) { + if (texture_num == 0 && (pbo != 0 || pixel_data != nullptr)) { // Translate the input format to OpenGL's enums. GLint internal_format; GLenum format; diff --git a/flat_input_test.cpp b/flat_input_test.cpp index 2fb807e..f01bab8 100644 --- a/flat_input_test.cpp +++ b/flat_input_test.cpp @@ -109,7 +109,7 @@ TEST(FlatInput, AlphaIsNotModifiedBySRGBConversion) { }; float out_data[4 * size]; - EffectChainTester tester(NULL, 1, size); + EffectChainTester tester(nullptr, 1, size); tester.add_input(data, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_sRGB); tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_LINEAR); @@ -185,7 +185,7 @@ TEST(FlatInput, Pitch) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -212,7 +212,7 @@ TEST(FlatInput, UpdatedData) { }; float out_data[width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -252,7 +252,7 @@ TEST(FlatInput, PBO) { glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, width * height * sizeof(float), data, GL_STREAM_DRAW); glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0); - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -287,7 +287,7 @@ TEST(FlatInput, ExternalTexture) { }; float out_data[4 * size]; - EffectChainTester tester(NULL, 1, size, FORMAT_RGB, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, 1, size, FORMAT_RGB, COLORSPACE_sRGB, GAMMA_LINEAR); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -326,7 +326,7 @@ TEST(FlatInput, NoData) { float out_data[width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; diff --git a/gtest_sdl_main.cpp b/gtest_sdl_main.cpp index 70fed13..e3051ad 100644 --- a/gtest_sdl_main.cpp +++ b/gtest_sdl_main.cpp @@ -47,10 +47,10 @@ int main(int argc, char **argv) { 32, 32, SDL_WINDOW_OPENGL); SDL_GLContext context = SDL_GL_CreateContext(window); - assert(context != NULL); + assert(context != nullptr); #else SDL_SetVideoMode(32, 32, 0, SDL_OPENGL); - SDL_WM_SetCaption("OpenGL window for unit test", NULL); + SDL_WM_SetCaption("OpenGL window for unit test", nullptr); #endif int err; diff --git a/init.cpp b/init.cpp index 7f2f5cc..44dd723 100644 --- a/init.cpp +++ b/init.cpp @@ -22,7 +22,7 @@ MovitShaderModel movit_shader_model; // The rules for objects with nontrivial constructors in static scope // are somewhat convoluted, and easy to mess up. We simply have a // pointer instead (and never care to clean it up). -string *movit_data_directory = NULL; +string *movit_data_directory = nullptr; namespace { @@ -38,7 +38,7 @@ void measure_texel_subpixel_precision() check_error(); glBindTexture(GL_TEXTURE_2D, dst_texnum); check_error(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, 1, 0, GL_RGBA, GL_FLOAT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, 1, 0, GL_RGBA, GL_FLOAT, nullptr); check_error(); glGenFramebuffers(1, &fbo); @@ -166,7 +166,7 @@ void measure_roundoff_problems() check_error(); glBindTexture(GL_TEXTURE_2D, dst_texnum); check_error(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 512, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); check_error(); glGenFramebuffers(1, &fbo); @@ -329,7 +329,7 @@ double get_glsl_version() // Skip past the first period. char *ptr = strchr(glsl_version_str, '.'); - assert(ptr != NULL); + assert(ptr != nullptr); ++ptr; // Now cut the string off at the next period or space, whatever comes first @@ -381,7 +381,7 @@ bool init_movit(const string& data_directory, MovitDebugLevel debug_level) // You can turn this on if you want detailed debug messages from the driver. // You should probably also ask for a debug context (see gtest_sdl_main.cpp), // or you might not get much data back. - // glDebugMessageCallbackARB(callback, NULL); + // glDebugMessageCallbackARB(callback, nullptr); // glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0, GL_TRUE); if (!check_extensions()) { diff --git a/padding_effect_test.cpp b/padding_effect_test.cpp index 86ce9e9..5fa0e42 100644 --- a/padding_effect_test.cpp +++ b/padding_effect_test.cpp @@ -26,7 +26,7 @@ TEST(PaddingEffectTest, SimpleCenter) { }; float out_data[4 * 4]; - EffectChainTester tester(NULL, 4, 4); + EffectChainTester tester(nullptr, 4, 4); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -59,7 +59,7 @@ TEST(PaddingEffectTest, WhiteBorderColor) { }; float out_data[4 * 4]; - EffectChainTester tester(NULL, 4, 4); + EffectChainTester tester(nullptr, 4, 4); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -92,7 +92,7 @@ TEST(PaddingEffectTest, BorderColorIsInLinearGamma) { }; float out_data[4 * 2]; - EffectChainTester tester(NULL, 1, 2); + EffectChainTester tester(nullptr, 1, 2); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -126,7 +126,7 @@ TEST(PaddingEffectTest, DifferentXAndYOffset) { }; float out_data[3 * 3]; - EffectChainTester tester(NULL, 3, 3); + EffectChainTester tester(nullptr, 3, 3); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -156,7 +156,7 @@ TEST(PaddingEffectTest, NonIntegerOffset) { }; float out_data[5 * 2]; - EffectChainTester tester(NULL, 5, 2); + EffectChainTester tester(nullptr, 5, 2); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -186,7 +186,7 @@ TEST(PaddingEffectTest, Crop) { }; float out_data[1 * 1]; - EffectChainTester tester(NULL, 1, 1); + EffectChainTester tester(nullptr, 1, 1); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -219,7 +219,7 @@ TEST(PaddingEffectTest, AlphaIsCorrectEvenWithNonLinearInputsAndOutputs) { }; float out_data[4 * 4]; - EffectChainTester tester(NULL, 1, 4); + EffectChainTester tester(nullptr, 1, 4); ImageFormat format; format.color_space = COLORSPACE_REC_601_625; @@ -255,7 +255,7 @@ TEST(PaddingEffectTest, RedBorder) { // Not black nor white, but still a satura }; float out_data[4 * 4]; - EffectChainTester tester(NULL, 1, 4); + EffectChainTester tester(nullptr, 1, 4); ImageFormat format; format.color_space = COLORSPACE_REC_601_625; @@ -291,7 +291,7 @@ TEST(PaddingEffectTest, BorderOffsetTopAndBottom) { }; float out_data[4 * 4]; - EffectChainTester tester(NULL, 4, 4); + EffectChainTester tester(nullptr, 4, 4); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -324,7 +324,7 @@ TEST(PaddingEffectTest, BorderOffsetLeftAndRight) { }; float out_data[4 * 2]; - EffectChainTester tester(NULL, 4, 2); + EffectChainTester tester(nullptr, 4, 2); ImageFormat format; format.color_space = COLORSPACE_sRGB; diff --git a/resample_effect.cpp b/resample_effect.cpp index 453a838..0a050cf 100644 --- a/resample_effect.cpp +++ b/resample_effect.cpp @@ -129,7 +129,7 @@ unsigned combine_samples(const Tap *src, Tap *dst, float num_s for (unsigned i = 0, j = 0; i < num_src_samples; ++i, ++j) { // Copy the sample directly; it will be overwritten later if we can combine. - if (dst != NULL) { + if (dst != nullptr) { dst[j].weight = convert_float(src[i].weight); dst[j].pos = convert_float(src[i].pos); } @@ -169,7 +169,7 @@ unsigned combine_samples(const Tap *src, Tap *dst, float num_s } // OK, we can combine this and the next sample. - if (dst != NULL) { + if (dst != nullptr) { dst[j].weight = total_weight; dst[j].pos = pos; } @@ -215,13 +215,13 @@ unsigned combine_many_samples(const Tap *weights, unsigned src_size, unsi unsigned max_samples_saved = UINT_MAX; for (unsigned y = 0; y < dst_samples && max_samples_saved > 0; ++y) { - unsigned num_samples_saved = combine_samples(weights + y * src_samples, NULL, num_subtexels, inv_num_subtexels, src_samples, max_samples_saved, pos1_pos2_diff, inv_pos1_pos2_diff); + unsigned num_samples_saved = combine_samples(weights + y * src_samples, nullptr, num_subtexels, inv_num_subtexels, src_samples, max_samples_saved, pos1_pos2_diff, inv_pos1_pos2_diff); max_samples_saved = min(max_samples_saved, num_samples_saved); } // Now that we know the right width, actually combine the samples. unsigned src_bilinear_samples = src_samples - max_samples_saved; - if (*bilinear_weights != NULL) delete[] *bilinear_weights; + if (*bilinear_weights != nullptr) delete[] *bilinear_weights; *bilinear_weights = new Tap[dst_samples * src_bilinear_samples]; for (unsigned y = 0; y < dst_samples; ++y) { Tap *bilinear_weights_ptr = *bilinear_weights + y * src_bilinear_samples; @@ -314,7 +314,7 @@ ResampleEffect::ResampleEffect() // The first blur pass will forward resolution information to us. hpass = new SingleResamplePassEffect(this); CHECK(hpass->set_int("direction", SingleResamplePassEffect::HORIZONTAL)); - vpass = new SingleResamplePassEffect(NULL); + vpass = new SingleResamplePassEffect(nullptr); CHECK(vpass->set_int("direction", SingleResamplePassEffect::VERTICAL)); update_size(); @@ -537,8 +537,8 @@ void SingleResamplePassEffect::update_texture(GLuint glsl_program_num, const str GLenum type, internal_format; void *pixels; - assert((weights.bilinear_weights_fp16 == NULL) != (weights.bilinear_weights_fp32 == NULL)); - if (weights.bilinear_weights_fp32 != NULL) { + assert((weights.bilinear_weights_fp16 == nullptr) != (weights.bilinear_weights_fp32 == NULL)); + if (weights.bilinear_weights_fp32 != nullptr) { type = GL_FLOAT; internal_format = GL_RG32F; pixels = weights.bilinear_weights_fp32; @@ -670,9 +670,9 @@ ScalingWeights calculate_scaling_weights(unsigned src_size, unsigned dst_size, f // Our tolerance level for total error is a bit higher than the one for invididual // samples, since one would assume overall errors in the shape don't matter as much. const float max_error = 2.0f / (255.0f * 255.0f); - Tap *bilinear_weights_fp16 = NULL; + Tap *bilinear_weights_fp16 = nullptr; int src_bilinear_samples = combine_many_samples(weights, src_size, src_samples, dst_samples, &bilinear_weights_fp16); - Tap *bilinear_weights_fp32 = NULL; + Tap *bilinear_weights_fp32 = nullptr; double max_sum_sq_error_fp16 = 0.0; for (unsigned y = 0; y < dst_samples; ++y) { double sum_sq_error_fp16 = compute_sum_sq_error( @@ -687,7 +687,7 @@ ScalingWeights calculate_scaling_weights(unsigned src_size, unsigned dst_size, f if (max_sum_sq_error_fp16 > max_error) { delete[] bilinear_weights_fp16; - bilinear_weights_fp16 = NULL; + bilinear_weights_fp16 = nullptr; src_bilinear_samples = combine_many_samples(weights, src_size, src_samples, dst_samples, &bilinear_weights_fp32); } diff --git a/resample_effect.h b/resample_effect.h index ceae920..a8e37e4 100644 --- a/resample_effect.h +++ b/resample_effect.h @@ -87,7 +87,7 @@ private: class SingleResamplePassEffect : public Effect { public: - // If parent is non-NULL, calls to inform_input_size will be forwarded, + // If parent is non-nullptr, calls to inform_input_size will be forwarded, // so that it can inform both passes about the right input and output // resolutions. SingleResamplePassEffect(ResampleEffect *parent); @@ -102,7 +102,7 @@ public: virtual void inform_added(EffectChain *chain) { this->chain = chain; } virtual void inform_input_size(unsigned input_num, unsigned width, unsigned height) { - if (parent != NULL) { + if (parent != nullptr) { parent->inform_input_size(input_num, width, height); } } diff --git a/resample_effect_test.cpp b/resample_effect_test.cpp index 02d9d74..9678aa0 100644 --- a/resample_effect_test.cpp +++ b/resample_effect_test.cpp @@ -70,7 +70,7 @@ TEST(ResampleEffectTest, UpscaleByTwoGetsCorrectPixelCenters) { } } - EffectChainTester tester(NULL, size * 2, size * 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, size * 2, size * 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -112,7 +112,7 @@ TEST(ResampleEffectTest, DownscaleByTwoGetsCorrectPixelCenters) { } } - EffectChainTester tester(NULL, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -142,7 +142,7 @@ TEST(ResampleEffectTest, UpscaleByThreeGetsCorrectPixelCenters) { }; float out_data[size * size * 9]; - EffectChainTester tester(NULL, size * 3, size * 3, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, size * 3, size * 3, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -187,7 +187,7 @@ TEST(ResampleEffectTest, HeavyResampleGetsSumRight) { } } - EffectChainTester tester(NULL, dwidth, dheight, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA32F); + EffectChainTester tester(nullptr, dwidth, dheight, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA32F); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -317,7 +317,7 @@ TEST(ResampleEffectTest, ReadHalfPixelFromLeftAndScale) { }; float out_data[dst_width * 1]; - EffectChainTester tester(NULL, dst_width, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, dst_width, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); ImageFormat format; format.color_space = COLORSPACE_sRGB; diff --git a/resource_pool.cpp b/resource_pool.cpp index b9adda7..10ab788 100644 --- a/resource_pool.cpp +++ b/resource_pool.cpp @@ -26,7 +26,7 @@ ResourcePool::ResourcePool(size_t program_freelist_max_length, vao_freelist_max_length(vao_freelist_max_length), texture_freelist_bytes(0) { - pthread_mutex_init(&lock, NULL); + pthread_mutex_init(&lock, nullptr); } ResourcePool::~ResourcePool() @@ -182,7 +182,7 @@ GLuint ResourcePool::link_program(GLuint vs_obj, glGetProgramiv(glsl_program_num, GL_LINK_STATUS, &success); if (success == GL_FALSE) { GLchar error_log[1024] = {0}; - glGetProgramInfoLog(glsl_program_num, 1024, NULL, error_log); + glGetProgramInfoLog(glsl_program_num, 1024, nullptr, error_log); fprintf(stderr, "Error linking program: %s\n", error_log); exit(1); } @@ -252,7 +252,7 @@ GLuint ResourcePool::link_compute_program(GLuint cs_obj) glGetProgramiv(glsl_program_num, GL_LINK_STATUS, &success); if (success == GL_FALSE) { GLchar error_log[1024] = {0}; - glGetProgramInfoLog(glsl_program_num, 1024, NULL, error_log); + glGetProgramInfoLog(glsl_program_num, 1024, nullptr, error_log); fprintf(stderr, "Error linking program: %s\n", error_log); exit(1); } @@ -336,7 +336,7 @@ GLuint ResourcePool::create_2d_texture(GLint internal_format, GLsizei width, GLs } // Find any reasonable format given the internal format; OpenGL validates it - // even though we give NULL as pointer. + // even though we give nullptr as pointer. GLenum format; switch (internal_format) { case GL_RGBA32F_ARB: @@ -420,7 +420,7 @@ GLuint ResourcePool::create_2d_texture(GLint internal_format, GLsizei width, GLs check_error(); glBindTexture(GL_TEXTURE_2D, texture_num); check_error(); - glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, type, nullptr); check_error(); glBindTexture(GL_TEXTURE_2D, 0); check_error(); @@ -710,7 +710,7 @@ void ResourcePool::output_debug_shader(const string &shader_src, const string &s char filename[256]; sprintf(filename, "chain-%03d.%s", compiled_shader_num++, suffix.c_str()); FILE *fp = fopen(filename, "w"); - if (fp == NULL) { + if (fp == nullptr) { perror(filename); exit(1); } diff --git a/slice_effect_test.cpp b/slice_effect_test.cpp index 477c7a7..163561e 100644 --- a/slice_effect_test.cpp +++ b/slice_effect_test.cpp @@ -26,7 +26,7 @@ TEST(SliceEffectTest, Identity) { }; float out_data[output_size * size]; - EffectChainTester tester(NULL, output_size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, output_size, size, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, size, size); Effect *slice_effect = tester.get_chain()->add_effect(new SliceEffect()); @@ -49,7 +49,7 @@ TEST(SliceEffectTest, HorizontalOverlap) { }; float out_data[9 * 2]; - EffectChainTester tester(NULL, 9, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, 9, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, 5, 2); Effect *slice_effect = tester.get_chain()->add_effect(new SliceEffect()); @@ -72,7 +72,7 @@ TEST(SliceEffectTest, HorizontalDiscard) { }; float out_data[4 * 2]; - EffectChainTester tester(NULL, 4, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, 4, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, 6, 2); Effect *slice_effect = tester.get_chain()->add_effect(new SliceEffect()); @@ -95,7 +95,7 @@ TEST(SliceEffectTest, HorizontalOverlapWithOffset) { }; float out_data[9 * 2]; - EffectChainTester tester(NULL, 9, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, 9, 2, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, 5, 2); Effect *slice_effect = tester.get_chain()->add_effect(new SliceEffect()); @@ -126,7 +126,7 @@ TEST(SliceEffectTest, VerticalOverlapSlicesFromTop) { }; float out_data[2 * 6]; - EffectChainTester tester(NULL, 2, 6, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, 2, 6, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, 2, 3); Effect *slice_effect = tester.get_chain()->add_effect(new SliceEffect()); @@ -156,7 +156,7 @@ TEST(SliceEffectTest, VerticalOverlapOffsetsFromTop) { }; float out_data[2 * 6]; - EffectChainTester tester(NULL, 2, 6, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); + EffectChainTester tester(nullptr, 2, 6, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.add_input(data, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, 2, 3); Effect *slice_effect = tester.get_chain()->add_effect(new SliceEffect()); diff --git a/test_util.cpp b/test_util.cpp index 65dbe8a..1a69b0c 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -23,7 +23,7 @@ namespace { // Not thread-safe, but this isn't a big problem for testing. ResourcePool *get_static_pool() { - static ResourcePool *resource_pool = NULL; + static ResourcePool *resource_pool = nullptr; if (!resource_pool) { resource_pool = new ResourcePool(); } @@ -56,7 +56,7 @@ EffectChainTester::EffectChainTester(const float *data, unsigned width, unsigned { CHECK(init_movit(".", MOVIT_DEBUG_OFF)); - if (data != NULL) { + if (data != nullptr) { add_input(data, pixel_format, color_space, gamma_curve); } } @@ -105,17 +105,17 @@ Input *EffectChainTester::add_input(const unsigned char *data, MovitPixelFormat void EffectChainTester::run(float *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, NULL, NULL, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format); + internal_run(out_data, nullptr, NULL, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format); } void EffectChainTester::run(float *out_data, float *out_data2, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, out_data2, NULL, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format); + internal_run(out_data, out_data2, nullptr, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format); } void EffectChainTester::run(float *out_data, float *out_data2, float *out_data3, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, out_data2, out_data3, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format); + internal_run(out_data, out_data2, out_data3, nullptr, GL_FLOAT, format, color_space, gamma_curve, alpha_format); } void EffectChainTester::run(float *out_data, float *out_data2, float *out_data3, float *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) @@ -125,17 +125,17 @@ void EffectChainTester::run(float *out_data, float *out_data2, float *out_data3, void EffectChainTester::run(unsigned char *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, NULL, NULL, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format); + internal_run(out_data, nullptr, NULL, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format); } void EffectChainTester::run(unsigned char *out_data, unsigned char *out_data2, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, out_data2, NULL, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format); + internal_run(out_data, out_data2, nullptr, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format); } void EffectChainTester::run(unsigned char *out_data, unsigned char *out_data2, unsigned char *out_data3, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, out_data2, out_data3, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format); + internal_run(out_data, out_data2, out_data3, nullptr, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format); } void EffectChainTester::run(unsigned char *out_data, unsigned char *out_data2, unsigned char *out_data3, unsigned char *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) @@ -145,29 +145,29 @@ void EffectChainTester::run(unsigned char *out_data, unsigned char *out_data2, u void EffectChainTester::run(uint16_t *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, NULL, NULL, NULL, GL_UNSIGNED_SHORT, format, color_space, gamma_curve, alpha_format); + internal_run(out_data, nullptr, NULL, NULL, GL_UNSIGNED_SHORT, format, color_space, gamma_curve, alpha_format); } void EffectChainTester::run_10_10_10_2(uint32_t *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, NULL, NULL, NULL, GL_UNSIGNED_INT_2_10_10_10_REV, format, color_space, gamma_curve, alpha_format); + internal_run(out_data, nullptr, NULL, NULL, GL_UNSIGNED_INT_2_10_10_10_REV, format, color_space, gamma_curve, alpha_format); } #ifdef HAVE_BENCHMARK void EffectChainTester::benchmark(benchmark::State &state, float *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, NULL, NULL, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format, &state); + internal_run(out_data, nullptr, NULL, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format, &state); } void EffectChainTester::benchmark(benchmark::State &state, float *out_data, float *out_data2, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, out_data2, NULL, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format, &state); + internal_run(out_data, out_data2, nullptr, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format, &state); } void EffectChainTester::benchmark(benchmark::State &state, float *out_data, float *out_data2, float *out_data3, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, out_data2, out_data3, NULL, GL_FLOAT, format, color_space, gamma_curve, alpha_format, &state); + internal_run(out_data, out_data2, out_data3, nullptr, GL_FLOAT, format, color_space, gamma_curve, alpha_format, &state); } void EffectChainTester::benchmark(benchmark::State &state, float *out_data, float *out_data2, float *out_data3, float *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) @@ -177,17 +177,17 @@ void EffectChainTester::benchmark(benchmark::State &state, float *out_data, floa void EffectChainTester::benchmark(benchmark::State &state, unsigned char *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, NULL, NULL, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format, &state); + internal_run(out_data, nullptr, NULL, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format, &state); } void EffectChainTester::benchmark(benchmark::State &state, unsigned char *out_data, unsigned char *out_data2, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, out_data2, NULL, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format, &state); + internal_run(out_data, out_data2, nullptr, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format, &state); } void EffectChainTester::benchmark(benchmark::State &state, unsigned char *out_data, unsigned char *out_data2, unsigned char *out_data3, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, out_data2, out_data3, NULL, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format, &state); + internal_run(out_data, out_data2, out_data3, nullptr, GL_UNSIGNED_BYTE, format, color_space, gamma_curve, alpha_format, &state); } void EffectChainTester::benchmark(benchmark::State &state, unsigned char *out_data, unsigned char *out_data2, unsigned char *out_data3, unsigned char *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) @@ -197,12 +197,12 @@ void EffectChainTester::benchmark(benchmark::State &state, unsigned char *out_da void EffectChainTester::benchmark(benchmark::State &state, uint16_t *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, NULL, NULL, NULL, GL_UNSIGNED_SHORT, format, color_space, gamma_curve, alpha_format, &state); + internal_run(out_data, nullptr, NULL, NULL, GL_UNSIGNED_SHORT, format, color_space, gamma_curve, alpha_format, &state); } void EffectChainTester::benchmark_10_10_10_2(benchmark::State &state, uint32_t *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format) { - internal_run(out_data, NULL, NULL, NULL, GL_UNSIGNED_INT_2_10_10_10_REV, format, color_space, gamma_curve, alpha_format, &state); + internal_run(out_data, nullptr, NULL, NULL, GL_UNSIGNED_INT_2_10_10_10_REV, format, color_space, gamma_curve, alpha_format, &state); } #endif @@ -233,11 +233,11 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T } unsigned num_outputs; - if (out_data4 != NULL) { + if (out_data4 != nullptr) { num_outputs = 4; - } else if (out_data3 != NULL) { + } else if (out_data3 != nullptr) { num_outputs = 3; - } else if (out_data2 != NULL) { + } else if (out_data2 != nullptr) { num_outputs = 2; } else { num_outputs = 1; @@ -250,7 +250,7 @@ void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T for (unsigned i = 0; i < num_outputs; ++i) { glBindTexture(GL_TEXTURE_2D, texnum[i]); check_error(); - glTexImage2D(GL_TEXTURE_2D, 0, framebuffer_format, width, height, 0, GL_RGBA, type, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, framebuffer_format, width, height, 0, GL_RGBA, type, nullptr); check_error(); } diff --git a/test_util.h b/test_util.h index b619aed..a5124bd 100644 --- a/test_util.h +++ b/test_util.h @@ -58,7 +58,7 @@ private: template void internal_run(T *out_data, T *out_data2, T *out_data3, T *out_data4, GLenum internal_format, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format = OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED #ifdef HAVE_BENCHMARK - , benchmark::State *state = NULL + , benchmark::State *state = nullptr #endif ); diff --git a/util.cpp b/util.cpp index 4016644..2f6e694 100644 --- a/util.cpp +++ b/util.cpp @@ -89,7 +89,7 @@ string read_file(const string &filename) const string full_pathname = *movit_data_directory + "/" + filename; FILE *fp = fopen(full_pathname.c_str(), "r"); - if (fp == NULL) { + if (fp == nullptr) { perror(full_pathname.c_str()); exit(1); } @@ -294,7 +294,7 @@ void *get_gl_context_identifier() return (void *)wglGetCurrentContext(); #else void *ret = (void *)eglGetCurrentContext(); - if (ret != NULL) { + if (ret != nullptr) { return ret; } return (void *)glXGetCurrentContext(); diff --git a/util.h b/util.h index feefea5..5e8cc6d 100644 --- a/util.h +++ b/util.h @@ -11,7 +11,7 @@ #include "defs.h" #include "fp16.h" -#define BUFFER_OFFSET(i) ((char *)NULL + (i)) +#define BUFFER_OFFSET(i) ((char *)nullptr + (i)) namespace movit { @@ -65,7 +65,7 @@ enum CombineRoundingBehavior { // // Note that since the GPU might have limited precision in its linear // interpolation, the effective weights might be different from the ones you -// asked for. sum_sq_error, if not NULL, will contain the sum of the +// asked for. sum_sq_error, if not nullptr, will contain the sum of the // (estimated) squared errors of the two weights. // // The answer, in "offset", comes as a normalized coordinate, @@ -109,7 +109,7 @@ void combine_two_samples(float w1, float w2, float pos1, float pos1_pos2_diff, f // If z had infinite precision, this would simply reduce to w = w1 + w2. *total_weight = from_fp32((w1 + z * (w2 - w1)) / (z * z + (1 - z) * (1 - z))); - if (sum_sq_error != NULL) { + if (sum_sq_error != nullptr) { float err1 = to_fp32(*total_weight) * (1 - z) - w1; float err2 = to_fp32(*total_weight) * z - w2; *sum_sq_error = err1 * err1 + err2 * err2; diff --git a/ycbcr.cpp b/ycbcr.cpp index 8c4f780..59b7eed 100644 --- a/ycbcr.cpp +++ b/ycbcr.cpp @@ -148,10 +148,10 @@ void compute_ycbcr_matrix(YCbCrFormat ycbcr_format, float* offset, Matrix3d* ycb offset[1] /= scale; offset[2] /= scale; *ycbcr_to_rgb *= scale; - if (scale_factor != NULL) { + if (scale_factor != nullptr) { *scale_factor = scale; } - } else if (scale_factor != NULL) { + } else if (scale_factor != nullptr) { *scale_factor = 1.0; } } diff --git a/ycbcr.h b/ycbcr.h index 1c55c39..207be4e 100644 --- a/ycbcr.h +++ b/ycbcr.h @@ -82,7 +82,7 @@ float compute_chroma_offset(float pos, unsigned subsampling_factor, unsigned res // we support storing it in 16-bit formats, which incurs extra scaling factors. // You can get that scaling factor in if you want. void compute_ycbcr_matrix(YCbCrFormat ycbcr_format, float *offset, Eigen::Matrix3d *ycbcr_to_rgb, - GLenum type = GL_UNSIGNED_BYTE, double *scale_factor = NULL); + GLenum type = GL_UNSIGNED_BYTE, double *scale_factor = nullptr); } // namespace movit diff --git a/ycbcr_422interleaved_input.cpp b/ycbcr_422interleaved_input.cpp index c345f8d..6546c87 100644 --- a/ycbcr_422interleaved_input.cpp +++ b/ycbcr_422interleaved_input.cpp @@ -21,7 +21,7 @@ YCbCr422InterleavedInput::YCbCr422InterleavedInput(const ImageFormat &image_form ycbcr_format(ycbcr_format), width(width), height(height), - resource_pool(NULL) + resource_pool(nullptr) { pbo = 0; texture_num[0] = texture_num[1] = 0; @@ -35,7 +35,7 @@ YCbCr422InterleavedInput::YCbCr422InterleavedInput(const ImageFormat &image_form pitches[CHANNEL_LUMA] = width; pitches[CHANNEL_CHROMA] = width / ycbcr_format.chroma_subsampling_x; - pixel_data = NULL; + pixel_data = nullptr; register_uniform_sampler2d("tex_y", &uniform_tex_y); register_uniform_sampler2d("tex_cbcr", &uniform_tex_cbcr); diff --git a/ycbcr_422interleaved_input_test.cpp b/ycbcr_422interleaved_input_test.cpp index 9a56fb1..668793a 100644 --- a/ycbcr_422interleaved_input_test.cpp +++ b/ycbcr_422interleaved_input_test.cpp @@ -36,7 +36,7 @@ TEST(YCbCr422InterleavedInputTest, Simple422) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -82,7 +82,7 @@ TEST(YCbCr422InterleavedInputTest, LumaLinearInterpolation) { }; float out_data[out_width * height]; - EffectChainTester tester(NULL, out_width, height); + EffectChainTester tester(nullptr, out_width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -143,7 +143,7 @@ TEST(YCbCr422InterleavedInputTest, DifferentCbAndCrPositioning) { }; float out_data[width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -202,7 +202,7 @@ TEST(YCbCr422InterleavedInputTest, PBO) { glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, width * height * 2, uyvy, GL_STREAM_DRAW); glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0); - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; diff --git a/ycbcr_conversion_effect_test.cpp b/ycbcr_conversion_effect_test.cpp index 6bac556..3eec271 100644 --- a/ycbcr_conversion_effect_test.cpp +++ b/ycbcr_conversion_effect_test.cpp @@ -40,7 +40,7 @@ TEST(YCbCrConversionEffectTest, BasicInOut) { unsigned char out_data[width * height * 4]; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -96,7 +96,7 @@ TEST(YCbCrConversionEffectTest, ClampToValidRange) { unsigned char out_data[width * height * 4]; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -152,7 +152,7 @@ TEST(YCbCrConversionEffectTest, LimitedRangeToFullRange) { unsigned char out_data[width * height * 4]; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -209,7 +209,7 @@ TEST(YCbCrConversionEffectTest, PlanarOutput) { unsigned char out_y[width * height], out_cb[width * height], out_cr[width * height]; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -279,7 +279,7 @@ TEST(YCbCrConversionEffectTest, SplitLumaAndChroma) { unsigned char out_y[width * height * 4], out_cbcr[width * height * 4]; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -343,7 +343,7 @@ TEST(YCbCrConversionEffectTest, OutputChunkyAndRGBA) { unsigned char out_ycbcr[width * height * 4]; unsigned char out_rgba[width * height * 4]; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -417,7 +417,7 @@ TEST(YCbCrConversionEffectTest, MultipleOutputsAndRGBA) { unsigned char out_cbcr[width * height * 4]; unsigned char out_rgba[width * height * 4]; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -483,7 +483,7 @@ TEST(YCbCrConversionEffectTest, ChangeOutputFormat) { unsigned char out_y[width * height], out_cb[width * height], out_cr[width * height]; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -545,7 +545,7 @@ TEST(YCbCrConversionEffectTest, TenBitOutput) { 127, 960, 471, 3, }; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGB10_A2); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGB10_A2); tester.add_input(data, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_sRGB); ImageFormat format; @@ -598,7 +598,7 @@ TEST(YCbCrConversionEffectTest, TenBitOutputInSixteen) { 127, 960, 471, 65535, }; - EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA16); + EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA16); tester.add_input(data, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_sRGB); ImageFormat format; diff --git a/ycbcr_input.cpp b/ycbcr_input.cpp index e7b53bb..47f58cc 100644 --- a/ycbcr_input.cpp +++ b/ycbcr_input.cpp @@ -28,7 +28,7 @@ YCbCrInput::YCbCrInput(const ImageFormat &image_format, type(type), width(width), height(height), - resource_pool(NULL) + resource_pool(nullptr) { pbos[0] = pbos[1] = pbos[2] = 0; texture_num[0] = texture_num[1] = texture_num[2] = 0; @@ -36,7 +36,7 @@ YCbCrInput::YCbCrInput(const ImageFormat &image_format, set_width(width); set_height(height); - pixel_data[0] = pixel_data[1] = pixel_data[2] = NULL; + pixel_data[0] = pixel_data[1] = pixel_data[2] = nullptr; owns_texture[0] = owns_texture[1] = owns_texture[2] = false; register_uniform_sampler2d("tex_y", &uniform_tex_y); @@ -87,7 +87,7 @@ void YCbCrInput::set_gl_state(GLuint glsl_program_num, const string& prefix, uns glActiveTexture(GL_TEXTURE0 + *sampler_num + channel); check_error(); - if (texture_num[channel] == 0 && (pbos[channel] != 0 || pixel_data[channel] != NULL)) { + if (texture_num[channel] == 0 && (pbos[channel] != 0 || pixel_data[channel] != nullptr)) { GLenum format, internal_format; if (channel == 0 && ycbcr_input_splitting == YCBCR_INPUT_INTERLEAVED) { if (type == GL_UNSIGNED_INT_2_10_10_10_REV) { diff --git a/ycbcr_input_test.cpp b/ycbcr_input_test.cpp index 92ef33b..adfdeb9 100644 --- a/ycbcr_input_test.cpp +++ b/ycbcr_input_test.cpp @@ -41,7 +41,7 @@ TEST(YCbCrInputTest, Simple444) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -92,7 +92,7 @@ TEST(YCbCrInputTest, Interleaved444) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -145,7 +145,7 @@ TEST(YCbCrInputTest, FullRangeRec601) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -199,7 +199,7 @@ TEST(YCbCrInputTest, Rec709) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -255,7 +255,7 @@ TEST(YCbCrInputTest, Rec2020) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -310,7 +310,7 @@ TEST(YCbCrInputTest, ChangeFormat) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -391,7 +391,7 @@ TEST(YCbCrInputTest, Subsampling420) { }; float out_data[width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -453,7 +453,7 @@ TEST(YCbCrInputTest, Subsampling420WithNonCenteredSamples) { }; float out_data[width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -523,7 +523,7 @@ TEST(YCbCrInputTest, DifferentCbAndCrPositioning) { }; float out_data[width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -581,7 +581,7 @@ TEST(YCbCrInputTest, PBO) { glBufferData(GL_PIXEL_UNPACK_BUFFER_ARB, width * height * 3, data, GL_STREAM_DRAW); glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0); - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -638,7 +638,7 @@ TEST(YCbCrInputTest, CombinedCbAndCr) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -691,7 +691,7 @@ TEST(YCbCrInputTest, ExternalTexture) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -849,7 +849,7 @@ TEST(YCbCrInputTest, NoData) { float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -906,7 +906,7 @@ TEST(YCbCrInputTest, TenBitInterleaved) { (expanded_data[i * 3 + 2] << 20); } - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -969,7 +969,7 @@ TEST(YCbCrInputTest, TenBitPlanar) { }; float out_data[4 * width * height]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); ImageFormat format; format.color_space = COLORSPACE_sRGB; @@ -1119,7 +1119,7 @@ TEST(EffectChainTest, MipmapGenerationWorks) { format.gamma_curve = GAMMA_sRGB; float out_data[width * height * 4]; - EffectChainTester tester(NULL, width, height); + EffectChainTester tester(nullptr, width, height); YCbCrInput *input = new YCbCrInput(format, ycbcr_format, width, height, YCBCR_INPUT_INTERLEAVED); input->set_pixel_data(0, ycbcr_data); tester.get_chain()->add_input(input);