refresh frame fix, dblclk proxy viewer fix, vicon refresh fix for awdw resize, fix...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / filecr2.C
index 84b07aa86a22654a0684dff35db82ff9c9d8e22b..f7db2f01f7b830cef56a0ebfd44af8bc1dcf43bd 100644 (file)
 #include <unistd.h>
 
 
-extern "C"
-{
-extern char dcraw_info[1024];
-extern float **dcraw_data;
-extern int dcraw_alpha;
-extern float dcraw_matrix[9];
-int dcraw_main (int argc, const char **argv);
-}
-
-Mutex FileCR2::dcraw_lock;
+#define NODEPS
+#define NO_JASPER
+#define NO_JPEG
+#define NO_LCMS
+#include "dcraw.h"
 
 int FileCR2::dcraw_run(FileCR2 *file, int argc, const char **argv, VFrame *frame)
 {
-       dcraw_lock.lock("dcraw_run");
-        memset(dcraw_info, 0, sizeof(dcraw_info));
-        memset(dcraw_matrix, 0, sizeof(dcraw_matrix));
-       dcraw_data = !frame ? 0 : (float**) frame->get_rows();
-       dcraw_alpha = !frame ? 0 :
-               frame->get_color_model() == BC_RGBA_FLOAT ? 1 : 0;
-       int result = dcraw_main(argc, argv);
-       if( !result && file )
-               file->format_to_asset(dcraw_info);
-       if( !result && frame ) {
+       DCRaw dcraw;
+       if( frame ) {
+               dcraw.data = (float**) frame->get_rows();
+               dcraw.alpha = frame->get_color_model() == BC_RGBA_FLOAT ? 1 : 0;
+       }
+       int result = dcraw.main(argc, argv);
+       if( file )
+               file->format_to_asset(dcraw.info);
+       if( frame ) {
 // This was only used by the bayer interpolate plugin, which itself created
 // too much complexity to use effectively.
 // It required bypassing the cache any time a plugin parameter changed
@@ -61,14 +55,12 @@ int FileCR2::dcraw_run(FileCR2 *file, int argc, const char **argv, VFrame *frame
 // from dcraw or a plugin & replace it.
                char string[BCTEXTLEN];
                sprintf(string, "%f %f %f %f %f %f %f %f %f\n",
-                       dcraw_matrix[0], dcraw_matrix[1], dcraw_matrix[2],
-                       dcraw_matrix[3], dcraw_matrix[4], dcraw_matrix[5],
-                       dcraw_matrix[6], dcraw_matrix[7], dcraw_matrix[8]);
+                       dcraw.matrix[0], dcraw.matrix[1], dcraw.matrix[2],
+                       dcraw.matrix[3], dcraw.matrix[4], dcraw.matrix[5],
+                       dcraw.matrix[6], dcraw.matrix[7], dcraw.matrix[8]);
                frame->get_params()->update("DCRAW_MATRIX", string);
 // frame->dump_params();
        }
-
-       dcraw_lock.unlock();
        return result;
 }
 
@@ -140,11 +132,6 @@ int FileCR2::read_frame(VFrame *frame, char *path)
 {
 //printf("FileCR2::read_frame\n");
 
-       if(frame->get_color_model() == BC_RGBA_FLOAT)
-               dcraw_alpha = 1;
-       else
-               dcraw_alpha = 0;
-
 // Want to disable interpolation if an interpolation plugin is on, but
 // this is impractical because of the amount of caching.  The interpolation
 // could not respond to a change in the plugin settings and it could not
@@ -209,7 +196,7 @@ int FileCR2::get_best_colormodel(Asset *asset, int driver)
 // int64_t FileCR2::get_memory_usage()
 // {
 //     int64_t result = asset->width * asset->height * sizeof(float) * 3;
-//printf("FileCR2::get_memory_usage %d " _LD "\n", __LINE__, result);
+//printf("FileCR2::get_memory_usage %d %jd\n", __LINE__, result);
 //     return result;
 // }