Credit Andrew - fix vorbis audio which was scratchy and ensure aging plugin does...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / fileexr.C
index e84ef84d4bcc68987942b1d035b05575f91c16ee..a705f6c88c8b51eed59773db6201193ac3a23b47 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * CINELERRA
  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -50,8 +51,8 @@ public:
        ~EXRIStream();
 
        bool read (char c[], int n);
-       Imf::Int64 tellg ();
-       void seekg (Imf::Int64 pos);
+       uint64_t tellg ();
+       void seekg (uint64_t pos);
        void clear ();
 
 private:
@@ -67,8 +68,8 @@ public:
        ~EXROStream();
 
     virtual void write(const char c[], int n);
-    virtual Imf::Int64 tellp();
-    virtual void seekp(Imf::Int64 pos);
+    virtual uint64_t tellp();
+    virtual void seekp(uint64_t pos);
 
 private:
        VFrame *data;
@@ -106,12 +107,12 @@ bool EXRIStream::read(char c[], int n)
        return position >= size;
 }
 
-Imf::Int64 EXRIStream::tellg ()
+uint64_t EXRIStream::tellg ()
 {
        return position;
 }
 
-void EXRIStream::seekg(Imf::Int64 pos)
+void EXRIStream::seekg(uint64_t pos)
 {
        position = pos;
 }
@@ -141,12 +142,12 @@ void EXROStream::write(const char c[], int n)
        data->set_compressed_size(MAX(position, data->get_compressed_size()));
 }
 
-Imf::Int64 EXROStream::tellp()
+uint64_t EXROStream::tellp()
 {
        return position;
 }
 
-void EXROStream::seekp(Imf::Int64 pos)
+void EXROStream::seekp(uint64_t pos)
 {
        position = pos;
 }
@@ -281,7 +282,7 @@ int FileEXR::read_frame_header(char *path)
 //     EXRIStream exr_stream(buffer, size);
 //     Imf::InputFile file(exr_stream);
 
-
+       if( access(path, R_OK) ) return 1;
        Imf::InputFile file(path);
 
        Imath::Box2i dw = file.header().dataWindow();
@@ -311,6 +312,9 @@ int FileEXR::read_frame_header(char *path)
 
 int FileEXR::read_frame(VFrame *frame, VFrame *data)
 {
+
+    try {
+
        Imf::setGlobalThreadCount(file->cpus);
        EXRIStream exr_stream((char*)data->get_data(), data->get_compressed_size());
        Imf::InputFile file(exr_stream);
@@ -425,6 +429,10 @@ int FileEXR::read_frame(VFrame *frame, VFrame *data)
                }
        }
        return 0;
+    } catch (const std::exception &e) {
+    std::cerr << "error reading EXR image file:" << e.what() << std::endl;
+    return 1;
+    }
 }
 
 
@@ -506,6 +514,15 @@ int FileEXR::write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit)
        return 0;
 }
 
+int FileEXR::can_copy_from(Asset *asset, int64_t position)
+{
+       if(asset->format == FILE_EXR ||
+               asset->format == FILE_EXR_LIST)
+               return 1;
+
+       return 0;
+}
+
 FrameWriterUnit* FileEXR::new_writer_unit(FrameWriter *writer)
 {
        return new EXRUnit(this, writer);
@@ -532,6 +549,8 @@ EXRConfigVideo::EXRConfigVideo(BC_WindowBase *parent_window, Asset *asset)
 {
        this->parent_window = parent_window;
        this->asset = asset;
+// *** CONTEXT_HELP ***
+       context_help_set_keyword("Single File Rendering");
 }
 
 EXRConfigVideo::~EXRConfigVideo()