]> git.sesse.net Git - movit/blobdiff - resample_effect.h
Remove the unused fields from ResampleEffect; if we make any changes here, it will...
[movit] / resample_effect.h
index 669d15b94569626d5b1a2bfc058b98162dd6f6be..5906a3c44ca41f499b17340e3fcc36fdaec80dfc 100644 (file)
 #include <epoxy/gl.h>
 #include <assert.h>
 #include <stddef.h>
+#include <memory>
 #include <string>
 
 #include "effect.h"
+#include "fp16.h"
 
 namespace movit {
 
@@ -28,9 +30,26 @@ class EffectChain;
 class Node;
 class SingleResamplePassEffect;
 
+// Public so that it can be benchmarked externally.
+template<class T>
+struct Tap {
+       T weight;
+       T pos;
+};
+struct ScalingWeights {
+       unsigned src_bilinear_samples;
+       unsigned dst_samples, num_loops;
+
+       // Exactly one of these is set.
+       std::unique_ptr<Tap<fp16_int_t>[]> bilinear_weights_fp16;
+       std::unique_ptr<Tap<float>[]> bilinear_weights_fp32;
+};
+ScalingWeights calculate_scaling_weights(unsigned src_size, unsigned dst_size, float zoom, float offset);
+
 class ResampleEffect : public Effect {
 public:
        ResampleEffect();
+       ~ResampleEffect();
 
        virtual std::string effect_type_id() const { return "ResampleEffect"; }
 
@@ -55,6 +74,9 @@ private:
        void update_size();
        void update_offset_and_zoom();
        
+       // Both of these are owned by us if owns_effects is true (before finalize()),
+       // and otherwise owned by the EffectChain.
+       bool owns_effects;
        SingleResamplePassEffect *hpass, *vpass;
        int input_width, input_height, output_width, output_height;
 
@@ -65,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);
@@ -80,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);
                }
        }
@@ -103,12 +125,19 @@ private:
        EffectChain *chain;
        Direction direction;
        GLuint texnum;
+       GLint uniform_sample_tex;
+       float uniform_num_loops, uniform_slice_height, uniform_sample_x_scale, uniform_sample_x_offset;
+       float uniform_whole_pixel_offset;
+       int uniform_num_samples;
+
        int input_width, input_height, output_width, output_height;
        float offset, zoom;
        int last_input_width, last_input_height, last_output_width, last_output_height;
        float last_offset, last_zoom;
        int src_bilinear_samples, num_loops;
        float slice_height;
+       int last_texture_width, last_texture_height;
+       GLuint last_texture_internal_format;
 };
 
 }  // namespace movit