Some work on DCI naming. Clean up compacted / aligned image handling somewhat.
[dcpomatic.git] / src / lib / util.h
index ed13cd43cba51bf95f2cad930381bf81f24d7d5a..bd7675a8af28ae05676aba327794ef37b2b6105f 100644 (file)
@@ -121,9 +121,35 @@ struct Position
        int y;
 };
 
+/** A rectangle */
+struct Rectangle
+{
+       Rectangle ()
+               : x (0)
+               , y (0)
+               , w (0)
+               , h (0)
+       {}
+
+       Rectangle (int x_, int y_, int w_, int h_)
+               : x (x_)
+               , y (y_)
+               , w (w_)
+               , h (h_)
+       {}
+
+       int x;
+       int y;
+       int w;
+       int h;
+
+       Rectangle intersection (Rectangle const & other) const;
+};
+
 extern std::string crop_string (Position, Size);
 extern int dcp_audio_sample_rate (int);
 extern std::string colour_lut_index_to_name (int index);
+extern int round_up (int, int);
 
 /** @class Socket
  *  @brief A class to wrap a boost::asio::ip::tcp::socket with some things
@@ -165,20 +191,5 @@ private:
        int _buffer_data;
 };
 
-#define SCALEBITS 10
-#define ONE_HALF  (1 << (SCALEBITS - 1))
-#define FIX(x)    ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-#define RGB_TO_Y_CCIR(r, g, b) \
-((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
-  FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
-
-#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
-(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 +         \
-     FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
-#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
-(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 -           \
-   FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
-
 #endif
+