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 f8e36ca..56a9951 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 69c1a6f..9266659 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 2c65724..2f72317 100644 (file)
@@ -23,7 +23,6 @@ enum YCbCrLumaCoefficients {
 };
 
 struct ImageFormat {
-       MovitPixelFormat pixel_format;
        ColorSpace color_space;
        GammaCurve gamma_curve;
 };
index d9a116d..1fbb6a2 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());