fix audio big btn replay, new proj path, proxy fix, updated Features5
[goodguy/history.git] / cinelerra-5.1 / guicast / test4.C
index 0c2c2fdd1e9b3885ae54d8ebf8a2464879459c6d..de94fad8d709e1c24304b8ef9660d2f2296d3dbf 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#include "bcwindowbase.h"
 #include "bcwindow.h"
 #include "bcsignals.h"
-#include "colors.h"
+#include "bccolors.h"
 #include "fonts.h"
 #include "thread.h"
 #include "vframe.h"
@@ -81,7 +82,7 @@ const char *cmdl[] = {
  "yuv422p", "rgb888", "rgba8888", "rgb161616", "rgba16161616", "yuv888", "yuva8888", "yuv161616",
  "yuva16161616", "yuv411p", "uvy422", "yuv422", "argb8888", "abgr8888", "a8", "a16",
  "yuv101010", "vyu888", "uyva8888", "yuv444p", "yuv410p", "rgb_float", "rgba_float", "a_float",
- "rgb_floatp", "rgba_floatp",
+ "rgb_floatp", "rgba_floatp", "yuv420pi", "ayuv16161616", "grey8", "grey16", "gbrp",
 };
 
 void write_pgm(uint8_t *tp, int w, int h, const char *fmt, ...)
@@ -106,8 +107,34 @@ void write_ppm(uint8_t *tp, int w, int h, const char *fmt, ...)
   if( fp ) {
     fprintf(fp,"P6\n%d %d\n255\n",w,h);
     fwrite(tp,3*w,h,fp);
-    fclose(fp);
+    if( fp != stdout ) fclose(fp);
+  }
+}
+
+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)
@@ -124,26 +151,28 @@ int main(int ac, char **av)
        close(fd);
        int w = ifrm.get_w(), h = ifrm.get_h();
        TestWindow test_window(100, 100, w, h);
-       for( int fr_cmdl=1; fr_cmdl<=32; ++fr_cmdl ) {
+       for( int fr_cmdl=1; fr_cmdl<=38; ++fr_cmdl ) {
                if( fr_cmdl == BC_TRANSPARENCY || fr_cmdl == BC_COMPRESSED ) continue;
                if( fr_cmdl == BC_A8 || fr_cmdl == BC_A16 ) continue;
                if( fr_cmdl == BC_A_FLOAT || fr_cmdl == 8 ) continue;
                VFrame afrm(w, h, fr_cmdl, -1);
                afrm.transfer_from(&ifrm, 0);
-               for( int to_cmdl=1; to_cmdl<=32; ++to_cmdl ) {
+               for( int to_cmdl=1; to_cmdl<=38; ++to_cmdl ) {
                        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 ", 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();