]> git.sesse.net Git - movit/commitdiff
Move pixel_format out of the ImageFormat struct, since it is only relevant for FlatInput.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 7 Oct 2012 10:54:32 +0000 (12:54 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 7 Oct 2012 10:54:32 +0000 (12:54 +0200)
flat_input.cpp
flat_input.h
image_format.h
main.cpp

index f8e36ca2f610eecc607d1da1bdfd291ae8c9a1ec..56a9951bb73ab070f0ad91b8b0f464bfe633055e 100644 (file)
@@ -5,8 +5,9 @@
 #include "util.h"
 #include "opengl.h"
 
-FlatInput::FlatInput(ImageFormat image_format, unsigned width, unsigned height)
+FlatInput::FlatInput(ImageFormat image_format, MovitPixelFormat pixel_format, unsigned width, unsigned height)
        : image_format(image_format),
+          pixel_format(pixel_format),
          needs_update(false),
          finalized(false),
          output_linear_gamma(false),
@@ -28,19 +29,19 @@ void FlatInput::finalize()
        } else {
                internal_format = GL_RGBA8;
        }
-       if (image_format.pixel_format == FORMAT_RGB) {
+       if (pixel_format == FORMAT_RGB) {
                format = GL_RGB;
                bytes_per_pixel = 3;
-       } else if (image_format.pixel_format == FORMAT_RGBA) {
+       } else if (pixel_format == FORMAT_RGBA) {
                format = GL_RGBA;
                bytes_per_pixel = 4;
-       } else if (image_format.pixel_format == FORMAT_BGR) {
+       } else if (pixel_format == FORMAT_BGR) {
                format = GL_BGR;
                bytes_per_pixel = 3;
-       } else if (image_format.pixel_format == FORMAT_BGRA) {
+       } else if (pixel_format == FORMAT_BGRA) {
                format = GL_BGRA;
                bytes_per_pixel = 4;
-       } else if (image_format.pixel_format == FORMAT_GRAYSCALE) {
+       } else if (pixel_format == FORMAT_GRAYSCALE) {
                format = GL_LUMINANCE;
                bytes_per_pixel = 1;
        } else {
index 69c1a6f14d00b2b5a64205133aad3853d23a31eb..9266659596ad8026f7993380c3cf1053a655714f 100644 (file)
@@ -7,7 +7,7 @@
 // comes from a single 2D array with chunky pixels.
 class FlatInput : public Input {
 public:
-       FlatInput(ImageFormat format, unsigned width, unsigned height);
+       FlatInput(ImageFormat format, MovitPixelFormat pixel_format, unsigned width, unsigned height);
 
        // Create the texture itself. We cannot do this in the constructor,
        // because we don't necessarily know all the settings (sRGB texture,
@@ -56,6 +56,7 @@ public:
 
 private:
        ImageFormat image_format;
+       MovitPixelFormat pixel_format;
        GLenum format;
        GLuint pbo, texture_num;
        bool needs_update, finalized;
index 2c65724c6af36b42ba836760d7bbb4bd746e587b..2f7231780875e6ec58e740669439ec60b3a57c02 100644 (file)
@@ -23,7 +23,6 @@ enum YCbCrLumaCoefficients {
 };
 
 struct ImageFormat {
-       MovitPixelFormat pixel_format;
        ColorSpace color_space;
        GammaCurve gamma_curve;
 };
index d9a116d56425c710b3ac06f9425faae7b3dd2ce6..1fbb6a2d0e25a7ea6a89dc6ab2f6c5501a940e0f 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -163,11 +163,10 @@ int main(int argc, char **argv)
        EffectChain chain(WIDTH, HEIGHT);
 
        ImageFormat inout_format;
-       inout_format.pixel_format = FORMAT_BGRA;
        inout_format.color_space = COLORSPACE_sRGB;
        inout_format.gamma_curve = GAMMA_sRGB;
 
-       FlatInput *input = new FlatInput(inout_format, WIDTH, HEIGHT);
+       FlatInput *input = new FlatInput(inout_format, FORMAT_BGRA, WIDTH, HEIGHT);
        chain.add_input(input);
        Effect *lift_gamma_gain_effect = chain.add_effect(new LiftGammaGainEffect());
        Effect *saturation_effect = chain.add_effect(new SaturationEffect());