]> git.sesse.net Git - movit/commitdiff
Do not send NULL to glTexSubImage2D if there is no input data set; it is illegal...
authorSteinar H. Gunderson <steinar+vlc@gunderson.no>
Wed, 24 Feb 2016 00:32:49 +0000 (01:32 +0100)
committerSteinar H. Gunderson <steinar+vlc@gunderson.no>
Wed, 24 Feb 2016 00:32:49 +0000 (01:32 +0100)
flat_input.cpp
flat_input_test.cpp
ycbcr_input.cpp
ycbcr_input_test.cpp

index 0f6f39565a2ccd6282679043e747f30c927594ee..8f24d86f9347b408b8edb2a9f24c677155b35591 100644 (file)
@@ -66,7 +66,7 @@ void FlatInput::set_gl_state(GLuint glsl_program_num, const string& prefix, unsi
        glActiveTexture(GL_TEXTURE0 + *sampler_num);
        check_error();
 
        glActiveTexture(GL_TEXTURE0 + *sampler_num);
        check_error();
 
-       if (texture_num == 0) {
+       if (texture_num == 0 && (pbo != 0 || pixel_data != NULL)) {
                // Translate the input format to OpenGL's enums.
                GLint internal_format;
                GLenum format;
                // Translate the input format to OpenGL's enums.
                GLint internal_format;
                GLenum format;
index 741b7c709c63e582b0e301238a6a4adfa684416d..2fb807e945d18f1ad3bcc26eb4b28c6d7b05db6a 100644 (file)
@@ -320,4 +320,24 @@ TEST(FlatInput, ExternalTexture) {
        expect_equal(expected_data, out_data, 4, size);
 }
 
        expect_equal(expected_data, out_data, 4, size);
 }
 
+TEST(FlatInput, NoData) {
+       const int width = 2;
+       const int height = 4;
+
+       float out_data[width * height];
+
+       EffectChainTester tester(NULL, width, height);
+
+       ImageFormat format;
+       format.color_space = COLORSPACE_sRGB;
+       format.gamma_curve = GAMMA_LINEAR;
+
+       FlatInput *input = new FlatInput(format, FORMAT_GRAYSCALE, GL_FLOAT, width, height);
+       tester.get_chain()->add_input(input);
+
+       tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+
+       // Don't care what the output was, just that it does not crash.
+}
+
 }  // namespace movit
 }  // namespace movit
index 071ce134833151b33bbb9cce800c1971143106dc..b0ca69291198fc69b7badc37b35b30d92741930c 100644 (file)
@@ -62,7 +62,7 @@ void YCbCrInput::set_gl_state(GLuint glsl_program_num, const string& prefix, uns
                glActiveTexture(GL_TEXTURE0 + *sampler_num + channel);
                check_error();
 
                glActiveTexture(GL_TEXTURE0 + *sampler_num + channel);
                check_error();
 
-               if (texture_num[channel] == 0) {
+               if (texture_num[channel] == 0 && (pbos[channel] != 0 || pixel_data[channel] != NULL)) {
                        GLenum format, internal_format;
                        if (channel == 1 && ycbcr_input_splitting == YCBCR_INPUT_SPLIT_Y_AND_CBCR) {
                                format = GL_RG;
                        GLenum format, internal_format;
                        if (channel == 1 && ycbcr_input_splitting == YCBCR_INPUT_SPLIT_Y_AND_CBCR) {
                                format = GL_RG;
index 463cb7e2d3771180c0d8fe06a65e62bd7931678e..a5032af657de73935aabaef79983b3d7603a28c7 100644 (file)
@@ -688,4 +688,35 @@ TEST(YCbCrTest, WikipediaJPEGMatrices) {
        EXPECT_NEAR(128.0, offset[2] * 255.0, 1e-3);
 }
 
        EXPECT_NEAR(128.0, offset[2] * 255.0, 1e-3);
 }
 
+TEST(YCbCrInputTest, NoData) {
+       const int width = 1;
+       const int height = 5;
+
+       float out_data[4 * width * height];
+
+       EffectChainTester tester(NULL, width, height);
+
+       ImageFormat format;
+       format.color_space = COLORSPACE_sRGB;
+       format.gamma_curve = GAMMA_sRGB;
+
+       YCbCrFormat ycbcr_format;
+       ycbcr_format.luma_coefficients = YCBCR_REC_601;
+       ycbcr_format.full_range = false;
+       ycbcr_format.num_levels = 256;
+       ycbcr_format.chroma_subsampling_x = 1;
+       ycbcr_format.chroma_subsampling_y = 1;
+       ycbcr_format.cb_x_position = 0.5f;
+       ycbcr_format.cb_y_position = 0.5f;
+       ycbcr_format.cr_x_position = 0.5f;
+       ycbcr_format.cr_y_position = 0.5f;
+
+       YCbCrInput *input = new YCbCrInput(format, ycbcr_format, width, height);
+       tester.get_chain()->add_input(input);
+
+       tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_sRGB);
+
+       // Don't care what the output was, just that it does not crash.
+}
+
 }  // namespace movit
 }  // namespace movit