bug fixes, typos, and omits in yuv mod
authorGood Guy <good1.2guy@gmail.com>
Fri, 1 Dec 2017 18:42:50 +0000 (11:42 -0700)
committerGood Guy <good1.2guy@gmail.com>
Fri, 1 Dec 2017 18:42:50 +0000 (11:42 -0700)
15 files changed:
cinelerra-5.1/cinelerra/scopewindow.C
cinelerra-5.1/guicast/bccolors.h
cinelerra-5.1/guicast/test4.C
cinelerra-5.1/plugins/color3way/color3way.h
cinelerra-5.1/plugins/colorbalance/colorbalance.C
cinelerra-5.1/plugins/colorbalance/colorbalance.h
cinelerra-5.1/plugins/gradient/gradient.C
cinelerra-5.1/plugins/gradient/gradient.h
cinelerra-5.1/plugins/huesaturation/huesaturation.C
cinelerra-5.1/plugins/libeffecttv/effecttv.C
cinelerra-5.1/plugins/libeffecttv/effecttv.h
cinelerra-5.1/plugins/threshold/histogramengine.C
cinelerra-5.1/plugins/threshold/histogramengine.h
cinelerra-5.1/plugins/timefront/timefront.h
cinelerra-5.1/plugins/yuv/yuv.h

index 56dd5171319b96c809f6eacf76fcca9835b356a9..4713b95d8f8ad0b663bb7466afd7e4d37127e046 100644 (file)
@@ -193,7 +193,7 @@ void ScopeUnit::draw_point(unsigned char **rows,
        u_in,  \
        v_in) \
 { \
-       yuv.yuv_to_rgb_f(r, g, b, (float)y_in / 255, (float)(u_in - 0x80) / 255, (float)(v_in - 0x80) / 255); \
+       YUV::yuv.yuv_to_rgb_f(r, g, b, (float)y_in / 255, (float)(u_in - 0x80) / 255, (float)(v_in - 0x80) / 255); \
        HSV::rgb_to_hsv(r,  \
                g,  \
                b,  \
@@ -209,8 +209,6 @@ void ScopeUnit::process_package(LoadPackage *package)
 {
        ScopePackage *pkg = (ScopePackage*)package;
 
-
-       YUV yuv;
        float r, g, b;
        float h, s, v;
        int x, y;
index eed34fef482bcf4ee18c20ea87aebfff5d587a1e..ed3b6fe1e6e0506598985f2e5b8db308b319b113 100644 (file)
@@ -241,8 +241,8 @@ public:
 
        bc_always_inline void rgb_to_yuv_f(float r, float g, float b, float &y, float &u, float &v) {
                y = r * r_to_y + g * g_to_y + b * b_to_y + yminf;
-               u = r * r_to_u + g * g_to_u + b * b_to_u + uvminf;
-               v = r * r_to_v + g * g_to_v + b * b_to_v + uvminf;
+               u = r * r_to_u + g * g_to_u + b * b_to_u;
+               v = r * r_to_v + g * g_to_v + b * b_to_v;
        }
        bc_always_inline void rgb_to_yuv_8(float r, float g, float b, int &y, int &u, int &v) {
                float fy, fu, fv;  rgb_to_yuv_f(r, g, b, fy, fu, fv);
@@ -304,9 +304,8 @@ public:
 
        bc_always_inline void yuv_to_rgb_f(float &r, float &g, float &b, float y, float u, float v) {
                y = (y-yminf) / yrangef;
-               u = u-uvminf;  v = v-uvminf;
                r = y + v_to_r * v;
-               g = u + u_to_g * u + v_to_g * v;
+               g = y + u_to_g * u + v_to_g * v;
                b = y + u_to_b * u;
        }
 
index 79b8623e94696dd58a1f05e07da7104c7ab1bcae..ed0f3840b6bf3aa7d814b3c08c8bef676c5d9434 100644 (file)
@@ -111,6 +111,32 @@ void write_ppm(uint8_t *tp, int w, int h, const char *fmt, ...)
   }
 }
 
+int64_t tm = 0, tn = 0;
+
+static int diff_vframe(VFrame &afrm, VFrame &bfrm)
+{
+  int n = 0, m = 0;
+  int w = afrm.get_w(), h = afrm.get_h();
+  uint8_t **arows = afrm.get_rows();
+  uint8_t **brows = bfrm.get_rows();
+
+  for( int y=0; y<h; ++y ) {
+    uint8_t *ap = arows[y], *bp = brows[y];
+    for( int x=0; x<w; ++x ) {
+      for( int i=0; i<3; ++i ) {
+        int d = *ap++ - *bp++;
+        m += d;
+        if( d < 0 ) d = -d;
+        n += d;
+      }
+    }
+  }
+  int sz = h*w*3;
+  printf(" %d %d %f", m, n, (double)n/sz);
+  tm += m;  tn += n;
+  return n;
+}
+
 int main(int ac, char **av)
 {
        BC_Signals signals;
@@ -135,17 +161,18 @@ int main(int ac, char **av)
                        if( to_cmdl == BC_TRANSPARENCY || to_cmdl == BC_COMPRESSED ) continue;
                        if( to_cmdl == BC_A8 || to_cmdl == BC_A16 ) continue;
                        if( to_cmdl == BC_A_FLOAT || to_cmdl == 8 ) continue;
-                       printf("xfer_%s_to_%s\n", cmdl[fr_cmdl],cmdl[to_cmdl]);
+                       printf("xfer_%s_to_%s ", cmdl[fr_cmdl],cmdl[to_cmdl]);
                        VFrame bfrm(w, h, to_cmdl, -1);
                        bfrm.transfer_from(&afrm, 0);
                        test_window.draw(&bfrm);
                        VFrame cfrm(w, h, BC_RGB888, -1);
                        cfrm.transfer_from(&bfrm, 0);
-                       printf("xfer_%s_to_%s\n",cmdl[fr_cmdl],cmdl[to_cmdl]);
                        test_window.show_text(50,50, "xfer_%s_to_%s",cmdl[fr_cmdl],cmdl[to_cmdl]);
-//                     write_ppm(cfrm.get_data(), w,h, "/tmp/test/xfer_%s_to_%s.pgm",
-//                             cmdl[fr_cmdl],cmdl[to_cmdl]);
+                       write_ppm(cfrm.get_data(), w,h, "/tmp/test/xfer_%s_to_%s.pgm",
+                               cmdl[fr_cmdl],cmdl[to_cmdl]);
+                       diff_vframe(ifrm, cfrm);
 //                     usleep(100000);
+                       printf("\n");
                }
        }
        test_window.close_window();
index d771acc0d3d804f605b56501db98d2eeeae903a5..a70ac8d74646f62ffa039cf8503d479aba98325e 100644 (file)
@@ -80,7 +80,6 @@ public:
        Color3WayUnit(Color3WayMain *plugin, Color3WayEngine *server);
        void process_package(LoadPackage *package);
        Color3WayMain *plugin;
-       YUV yuv;
 };
 
 class Color3WayEngine : public LoadServer
index 31197408f29b76ac1d1450b972bbd66598308c95..c5e4db0ce8b04b97031f85523f6640f5180ac01e 100644 (file)
@@ -19,6 +19,7 @@
  *
  */
 
+#include "bccolors.h"
 #include "filexml.h"
 #include "clip.h"
 #include "colorbalance.h"
@@ -259,7 +260,7 @@ printf("PROCESS_F %f\n", cyan_f); \
                switch(input->get_color_model())
                {
                        case BC_RGB888:
-                               PROCESS(yuv.yuv_to_rgb_8, yuv.rgb_to_yuv_8,
+                               PROCESS(YUV::yuv.yuv_to_rgb_8, YUV::yuv.rgb_to_yuv_8,
                                        r_lookup_8, g_lookup_8, b_lookup_8,
                                        unsigned char, 0xff, 3, 0);
                                break;
@@ -269,7 +270,7 @@ printf("PROCESS_F %f\n", cyan_f); \
                                break;
 
                        case BC_YUV888:
-                               PROCESS(yuv.yuv_to_rgb_8, yuv.rgb_to_yuv_8,
+                               PROCESS(YUV::yuv.yuv_to_rgb_8, YUV::yuv.rgb_to_yuv_8,
                                        r_lookup_8, g_lookup_8, b_lookup_8,
                                        unsigned char, 0xff, 3, 1);
                                break;
@@ -279,25 +280,25 @@ printf("PROCESS_F %f\n", cyan_f); \
                                break;
 
                        case BC_RGBA8888:
-                               PROCESS(yuv.yuv_to_rgb_8, yuv.rgb_to_yuv_8,
+                               PROCESS(YUV::yuv.yuv_to_rgb_8, YUV::yuv.rgb_to_yuv_8,
                                        r_lookup_8, g_lookup_8, b_lookup_8,
                                        unsigned char, 0xff, 4, 0);
                                break;
 
                        case BC_YUVA8888:
-                               PROCESS(yuv.yuv_to_rgb_8, yuv.rgb_to_yuv_8,
+                               PROCESS(YUV::yuv.yuv_to_rgb_8, YUV::yuv.rgb_to_yuv_8,
                                        r_lookup_8, g_lookup_8, b_lookup_8,
                                        unsigned char, 0xff, 4, 1);
                                break;
 
                        case BC_YUV161616:
-                               PROCESS(yuv.yuv_to_rgb_16, yuv.rgb_to_yuv_16,
+                               PROCESS(YUV::yuv.yuv_to_rgb_16, YUV::yuv.rgb_to_yuv_16,
                                        r_lookup_16, g_lookup_16, b_lookup_16,
                                        u_int16_t, 0xffff, 3, 1);
                                break;
 
                        case BC_YUVA16161616:
-                               PROCESS(yuv.yuv_to_rgb_16, yuv.rgb_to_yuv_16,
+                               PROCESS(YUV::yuv.yuv_to_rgb_16, YUV::yuv.rgb_to_yuv_16,
                                        r_lookup_16, g_lookup_16, b_lookup_16,
                                        u_int16_t, 0xffff, 4, 1);
                                break;
index 69b5923a26b9dd8b7d8c6f53cbae52660e0f3f09..ecc4f18ac3e1ba9ec0992e262f6eb446b84d8d8f 100644 (file)
@@ -71,7 +71,6 @@ public:
        int last_frame;
        Condition input_lock, output_lock;
        VFrame *input, *output;
-       YUV yuv;
        float cyan_f, magenta_f, yellow_f;
 };
 
index 9b49f85c2770cf96b9c2e98bda86883d37e87f76..9cf1c152038a70ec1805ae1fc1e4c5f5459744f7 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdint.h>
 #include <string.h>
 
+#include "bccolors.h"
 #include "bcdisplayinfo.h"
 #include "clip.h"
 #include "bchash.h"
@@ -1327,14 +1328,14 @@ void GradientUnit::process_package(LoadPackage *package)
                {
                        int in1, in2, in3, in4;
                        int out1, out2, out3, out4;
-                       yuv.rgb_to_yuv_8(plugin->config.in_r,
+                       YUV::yuv.rgb_to_yuv_8(plugin->config.in_r,
                                plugin->config.in_g,
                                plugin->config.in_b,
                                in1,
                                in2,
                                in3);
                        in4 = plugin->config.in_a;
-                       yuv.rgb_to_yuv_8(plugin->config.out_r,
+                       YUV::yuv.rgb_to_yuv_8(plugin->config.out_r,
                                plugin->config.out_g,
                                plugin->config.out_b,
                                out1,
@@ -1349,14 +1350,14 @@ void GradientUnit::process_package(LoadPackage *package)
                {
                        int in1, in2, in3, in4;
                        int out1, out2, out3, out4;
-                       yuv.rgb_to_yuv_8(plugin->config.in_r,
+                       YUV::yuv.rgb_to_yuv_8(plugin->config.in_r,
                                plugin->config.in_g,
                                plugin->config.in_b,
                                in1,
                                in2,
                                in3);
                        in4 = plugin->config.in_a;
-                       yuv.rgb_to_yuv_8(plugin->config.out_r,
+                       YUV::yuv.rgb_to_yuv_8(plugin->config.out_r,
                                plugin->config.out_g,
                                plugin->config.out_b,
                                out1,
index db7cd327b020692f39c5aaf8ef5fcf2db0c2364c..f6d1d99450b1e8ebefe6cddc919caa851134102f 100644 (file)
@@ -284,7 +284,6 @@ public:
        void process_package(LoadPackage *package);
        GradientServer *server;
        GradientMain *plugin;
-       YUV yuv;
 };
 
 class GradientServer : public LoadServer
index f7f04f24c130c9c6ee6f07b2a601f0066b20bd37..4ecb1d61ff336ccd1a48935c3ac2be24a4e2e59c 100644 (file)
@@ -19,6 +19,7 @@
  *
  */
 
+#include "bccolors.h"
 #include "bcdisplayinfo.h"
 #include "clip.h"
 #include "bchash.h"
@@ -128,7 +129,6 @@ public:
        HueUnit(HueEffect *plugin, HueEngine *server);
        void process_package(LoadPackage *package);
        HueEffect *plugin;
-       YUV yuv;
 };
 
 class HueEffect : public PluginVClient
@@ -399,9 +399,9 @@ HueUnit::HueUnit(HueEffect *plugin, HueEngine *server)
                                u = (int)in_row[1]; \
                                v = (int)in_row[2]; \
                                if(max == 0xffff) \
-                                       yuv.yuv_to_rgb_16(r_i, g_i, b_i, y, u, v); \
+                                       YUV::yuv.yuv_to_rgb_16(r_i, g_i, b_i, y, u, v); \
                                else \
-                                       yuv.yuv_to_rgb_8(r_i, g_i, b_i, y, u, v); \
+                                       YUV::yuv.yuv_to_rgb_8(r_i, g_i, b_i, y, u, v); \
                                HSV::rgb_to_hsv((float)r_i / max, \
                                        (float)g_i / max, \
                                        (float)b_i / max, \
index 60f2c8a990fa236fda51213c63da4b2850ccda86..6ec0b5e7c92cb1ed28a7c2be467db246fee045ea 100644 (file)
@@ -39,7 +39,6 @@ EffectTV::EffectTV(int w, int h)
        diff = new unsigned char[w * h];
        diff2 = new unsigned char[w * h];
        yuv_init();
-       yuv = new YUV;
 }
 
 EffectTV::~EffectTV()
@@ -47,7 +46,6 @@ EffectTV::~EffectTV()
        delete [] background;
        delete [] diff;
        delete [] diff2;
-       delete yuv;
 }
 
 
index 473a4240f3be22751bba9e1366301c11659b5b0d..0093f7db9f5d7769e1e772a3d3e364d0adb9609d 100644 (file)
@@ -80,7 +80,6 @@ public:
        int GtoV[0x100];
        int BtoY[0x100];
        int BtoV[0x100];
-       YUV *yuv;
 };
 
 
index e7c69ff0a9a3d5cbda95450eb1f19f43707aeeb7..bdfab86c7800991648449a51545bb4ead923057e 100644 (file)
@@ -19,8 +19,8 @@
  *
  */
 
-#include "histogramengine.h"
 #include "bccolors.h"
+#include "histogramengine.h"
 #include "vframe.h"
 
 #include <stdio.h>
@@ -116,7 +116,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                        y = (row[0] << 8) | row[0];
                        u = (row[1] << 8) | row[1];
                        v = (row[2] << 8) | row[2];
-                       server->yuv->yuv_to_rgb_16(r, g, b, y, u, v);
+                       YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
                        HISTOGRAM_TAIL(3)
                        break;
                case BC_RGBA8888:
@@ -138,7 +138,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                        y = (row[0] << 8) | row[0];
                        u = (row[1] << 8) | row[1];
                        v = (row[2] << 8) | row[2];
-                       server->yuv->yuv_to_rgb_16(r, g, b, y, u, v);
+                       YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
                        HISTOGRAM_TAIL(4)
                        break;
                case BC_RGB161616:
@@ -153,7 +153,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                        y = row[0];
                        u = row[1];
                        v = row[2];
-                       server->yuv->yuv_to_rgb_16(r, g, b, y, u, v);
+                       YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
                        HISTOGRAM_TAIL(3)
                        break;
                case BC_RGBA16161616:
@@ -168,7 +168,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                        y = row[0];
                        u = row[1];
                        v = row[2];
-                       server->yuv->yuv_to_rgb_16(r, g, b, y, u, v);
+                       YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
                        HISTOGRAM_TAIL(4)
                        break;
        }
@@ -184,7 +184,6 @@ void HistogramUnit::process_package(LoadPackage *package)
 HistogramEngine::HistogramEngine(int total_clients, int total_packages)
  : LoadServer(total_clients, total_packages)
 {
-       yuv = new YUV;
        data = 0;
        for(int i = 0; i < 5; i++)
                accum[i] = new int64_t[HISTOGRAM_RANGE];
@@ -192,7 +191,6 @@ HistogramEngine::HistogramEngine(int total_clients, int total_packages)
 
 HistogramEngine::~HistogramEngine()
 {
-       delete yuv;
        for(int i = 0; i < 5; i++)
                delete [] accum[i];
 }
index 41603cb8f4fd5e2efe898e1b630331e6b959d6eb..6d4f67250428173438f6af6e0850ee53bf61a054 100644 (file)
@@ -56,7 +56,6 @@ public:
        LoadClient* new_client();
        LoadPackage* new_package();
        VFrame *data;
-       YUV *yuv;
        int64_t *accum[5];
 };
 
index 9eeb4ee2be43c097a6d45c0e75c32f47cb369634..54aa46e21560db9fb69858355da632f0d46a7692 100644 (file)
@@ -275,7 +275,6 @@ public:
        void process_package(LoadPackage *package);
        TimeFrontServer *server;
        TimeFrontMain *plugin;
-       YUV yuv;
 };
 
 class TimeFrontServer : public LoadServer
index b1e07d36ba7bc3a082d4578cb14e678fe85970d4..76be8dad7b996a3f3d5b57a417d9a9decdf21f96 100644 (file)
@@ -82,7 +82,6 @@ public:
        VFrame **output, **input;
        int last_frame;
        Mutex input_lock, output_lock;
-    YUV yuv;
 };