improve delays created by vicon drawing locks, reset_cache segv fix, gang track toolt...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / file.C
index 13e1b457463a2876c411725d4c6ad2ff700c9336..f9571c9d1dddd60bb37704dda5a18d0e740c8200 100644 (file)
@@ -55,6 +55,7 @@
 #include "fileogg.h"
 #include "filepng.h"
 #include "fileppm.h"
+#include "fileref.h"
 #include "filescene.h"
 #include "filesndfile.h"
 #include "filetga.h"
 #include "samples.h"
 #include "vframe.h"
 
-//static int temp_debug = 0;
+#ifdef HAVE_OGG
 //suppress noref warning
 void *vorbis0_ov_callbacks[] = {
  &OV_CALLBACKS_DEFAULT, &OV_CALLBACKS_NOCLOSE,
  &OV_CALLBACKS_STREAMONLY, &OV_CALLBACKS_STREAMONLY_NOCLOSE,
 };
+#endif
 
 File::File()
 {
@@ -102,7 +104,6 @@ File::~File()
        }
 
        if( temp_frame ) {
-//printf("File::~File %d temp_debug=%d\n", __LINE__, --temp_debug);
                delete temp_frame;
        }
 
@@ -237,10 +238,12 @@ int File::get_options(FormatTools *format,
                FileTIFF::get_parameters(parent_window, asset, format_window,
                        audio_options, video_options, edl);
                break;
+#ifdef HAVE_OGG
        case FILE_OGG:
                FileOGG::get_parameters(parent_window, asset, format_window,
                        audio_options, video_options, edl);
                break;
+#endif
        default:
                break;
        }
@@ -362,8 +365,10 @@ const char *File::default_probes[] = {
        "CR2",
        "TGA",
        "TIFF",
+#ifdef HAVE_OGG
        "OGG",
        "Vorbis",
+#endif
        "MPEG",
        "EDL",
                "FFMPEG_Late", 
@@ -430,11 +435,14 @@ int File::probe()
                        return FILE_OK;
                }
                if( !strcmp(pref->name,"GIF") ) { // GIF file
-                       if( !FileGIF::check_sig(this->asset)) continue;
-                       file = new FileGIF(this->asset, this);
+                       if( FileGIFList::check_sig(this->asset) )
+                               file = new FileGIFList(this->asset, this);
+                       else if( FileGIF::check_sig(this->asset) )
+                               file = new FileGIF(this->asset, this);
+                       else continue;
                        return FILE_OK;
                }
-#ifdef HAVE_EXR
+#ifdef HAVE_OPENEXR
                if( !strcmp(pref->name,"EXR") ) { // EXR file
                        if( !FileEXR::check_sig(this->asset, data)) continue;
                        file = new FileEXR(this->asset, this);
@@ -461,6 +469,7 @@ int File::probe()
                        file = new FileTIFF(this->asset, this);
                        return FILE_OK;
                }
+#ifdef HAVE_OGG
                if( !strcmp(pref->name,"OGG") ) { // OGG file
                        if( !FileOGG::check_sig(this->asset) ) continue;
                        file = new FileOGG(this->asset, this);
@@ -471,6 +480,7 @@ int File::probe()
                        file = new FileVorbis(this->asset, this);
                        return FILE_OK;
                }
+#endif
 #ifdef HAVE_LIBZMPEG
                if( !strcmp(pref->name,"MPEG") ) { // MPEG file
                        if( !FileMPEG::check_sig(this->asset) ) continue;
@@ -551,9 +561,12 @@ int File::open_file(Preferences *preferences,
                break;
 
        case FILE_GIF:
-       case FILE_GIF_LIST:
                file = new FileGIF(this->asset, this);
                break;
+       case FILE_GIF_LIST:
+               file = new FileGIFList(this->asset, this);
+               break;
+
 #ifdef HAVE_OPENEXR
        case FILE_EXR:
        case FILE_EXR_LIST:
@@ -591,6 +604,7 @@ int File::open_file(Preferences *preferences,
                file = new FileMPEG(this->asset, this);
                break;
 #endif
+#ifdef HAVE_OGG
        case FILE_OGG:
                file = new FileOGG(this->asset, this);
                break;
@@ -598,11 +612,15 @@ int File::open_file(Preferences *preferences,
        case FILE_VORBIS:
                file = new FileVorbis(this->asset, this);
                break;
+#endif
 #ifdef HAVE_DV
        case FILE_RAWDV:
                file = new FileDV(this->asset, this);
                break;
 #endif
+       case FILE_REF:
+               file = new FileREF(this->asset, this);
+               break;
 // try plugins
        default:
                return 1;
@@ -683,17 +701,10 @@ void File::delete_temp_frame_buffer()
 
 int File::close_file(int ignore_thread)
 {
-       const int debug = 0;
-
-       if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
-
        if( !ignore_thread ) {
                stop_audio_thread();
                stop_video_thread();
        }
-
-
-       if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
        if( file ) {
 // The file's asset is a copy of the argument passed to open_file so the
 // user must copy lengths from the file's asset.
@@ -705,28 +716,18 @@ int File::close_file(int ignore_thread)
                file->close_file();
                delete file;
        }
-       if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
 
        delete_temp_samples_buffer();
        delete_temp_frame_buffer();
-       if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
-
-       if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
-
        reset_parameters();
-       if( debug ) printf("File::close_file file=%p %d\n", file, __LINE__);
        return 0;
 }
 
-
-
 int File::get_index(IndexFile *index_file, MainProgressBar *progress_bar)
 {
        return !file ? -1 : file->get_index(index_file, progress_bar);
 }
 
-
-
 int File::start_audio_thread(int buffer_size, int ring_buffers)
 {
        this->audio_ring_buffers = ring_buffers;
@@ -739,20 +740,16 @@ int File::start_audio_thread(int buffer_size, int ring_buffers)
        return 0;
 }
 
-int File::start_video_thread(int buffer_size,
-       int color_model,
-       int ring_buffers,
-       int compressed)
+int File::start_video_thread(int buffer_size, int color_model,
+               int ring_buffers, int compressed)
 {
        this->video_ring_buffers = ring_buffers;
        this->video_buffer_size = buffer_size;
 
        if( !video_thread ) {
                video_thread = new FileThread(this, 0, 1);
-               video_thread->start_writing(buffer_size,
-                       color_model,
-                       ring_buffers,
-                       compressed);
+               video_thread->start_writing(buffer_size, color_model,
+                               ring_buffers, compressed);
        }
        return 0;
 }
@@ -1181,6 +1178,7 @@ int File::read_frame(VFrame *frame, int is_thread)
 
                if( !temp_frame ) {
                        temp_frame = new VFrame(asset->width, asset->height, supported_colormodel, 0);
+                       temp_frame->clear_frame();
                }
 
 //                     printf("File::read_frame %d\n", __LINE__);
@@ -1247,6 +1245,8 @@ int File::strtoformat(const char *format)
        if( !strcasecmp(format, _(EXR_NAME)) ) return FILE_EXR;
        if( !strcasecmp(format, _(EXR_LIST_NAME)) ) return FILE_EXR_LIST;
        if( !strcasecmp(format, _(FLAC_NAME)) ) return FILE_FLAC;
+       if( !strcasecmp(format, _(GIF_NAME)) ) return FILE_GIF;
+       if( !strcasecmp(format, _(GIF_LIST_NAME)) ) return FILE_GIF_LIST;
        if( !strcasecmp(format, _(CR2_NAME)) ) return FILE_CR2;
        if( !strcasecmp(format, _(CR2_LIST_NAME)) ) return FILE_CR2_LIST;
        if( !strcasecmp(format, _(MPEG_NAME)) ) return FILE_MPEG;
@@ -1259,6 +1259,7 @@ int File::strtoformat(const char *format)
        if( !strcasecmp(format, _(RAWDV_NAME)) ) return FILE_RAWDV;
        if( !strcasecmp(format, _(FFMPEG_NAME)) ) return FILE_FFMPEG;
        if( !strcasecmp(format, _(DBASE_NAME)) ) return FILE_DB;
+       if( !strcasecmp(format, _(REF_NAME)) ) return FILE_REF;
 
        return 0;
 }
@@ -1283,6 +1284,8 @@ const char* File::formattostr(int format)
        case FILE_CR2:          return _(CR2_NAME);
        case FILE_CR2_LIST:     return _(CR2_LIST_NAME);
        case FILE_FLAC:         return _(FLAC_NAME);
+       case FILE_GIF:          return _(GIF_NAME);
+       case FILE_GIF_LIST:     return _(GIF_LIST_NAME);
        case FILE_EXR:          return _(EXR_NAME);
        case FILE_EXR_LIST:     return _(EXR_LIST_NAME);
 #ifdef HAVE_LIBZMPEG
@@ -1299,6 +1302,7 @@ const char* File::formattostr(int format)
        case FILE_RAWDV:        return _(RAWDV_NAME);
        case FILE_FFMPEG:       return _(FFMPEG_NAME);
        case FILE_DB:           return _(DBASE_NAME);
+       case FILE_REF:          return _(REF_NAME);
        }
        return _("Unknown");
 }
@@ -1390,6 +1394,7 @@ int File::get_best_colormodel(Asset *asset, int driver)
        case FILE_DB:           return FileDB::get_best_colormodel(asset, driver);
 #endif
        case FILE_FFMPEG:       return FileFFMPEG::get_best_colormodel(asset, driver);
+       case FILE_REF:          return FileREF::get_best_colormodel(asset, driver);
        }
 
        return BC_RGB888;
@@ -1434,6 +1439,8 @@ int File::renders_video(int format)
        case FILE_CR2_LIST:
        case FILE_EXR:
        case FILE_EXR_LIST:
+       case FILE_GIF:
+       case FILE_GIF_LIST:
        case FILE_PNG:
        case FILE_PNG_LIST:
        case FILE_PPM:
@@ -1507,24 +1514,27 @@ const char* File::get_tag(int format)
        case FILE_RAWDV:        return "dv";
        case FILE_DB:           return "db";
        case FILE_EXR:          return "exr";
-       case FILE_EXR_LIST:     return "exr";
+       case FILE_EXR_LIST:     return "exrs";
        case FILE_FLAC:         return "flac";
        case FILE_JPEG:         return "jpg";
-       case FILE_JPEG_LIST:    return "jpg";
+       case FILE_JPEG_LIST:    return "jpgs";
        case FILE_OGG:          return "ogg";
+       case FILE_GIF:          return "gif";
+       case FILE_GIF_LIST:     return "gifs";
        case FILE_PCM:          return "pcm";
        case FILE_PNG:          return "png";
-       case FILE_PNG_LIST:     return "png";
+       case FILE_PNG_LIST:     return "pngs";
        case FILE_PPM:          return "ppm";
-       case FILE_PPM_LIST:     return "ppm";
+       case FILE_PPM_LIST:     return "ppms";
        case FILE_TGA:          return "tga";
-       case FILE_TGA_LIST:     return "tga";
+       case FILE_TGA_LIST:     return "tgas";
        case FILE_TIFF:         return "tif";
-       case FILE_TIFF_LIST:    return "tif";
+       case FILE_TIFF_LIST:    return "tifs";
        case FILE_VMPEG:        return "m2v";
        case FILE_VORBIS:       return "ogg";
        case FILE_WAV:          return "wav";
        case FILE_FFMPEG:       return "ffmpg";
+       case FILE_REF:          return "ref";
        }
        return 0;
 }
@@ -1564,27 +1574,12 @@ const char* File::get_prefix(int format)
        case FILE_CR2_LIST:     return "CR2_LIST";
        case FILE_GIF_LIST:     return "GIF_LIST";
        case FILE_DB:           return "DB";
+       case FILE_REF:          return "REF";
        }
        return _("UNKNOWN");
 }
 
 
-PackagingEngine *File::new_packaging_engine(Asset *asset)
-{
-       PackagingEngine *result;
-       switch( asset->format ) {
-       case FILE_OGG:
-               result = (PackagingEngine*)new PackagingEngineOGG();
-               break;
-       default:
-               result = (PackagingEngine*) new PackagingEngineDefault();
-               break;
-       }
-
-       return result;
-}
-
-
 int File::record_fd()
 {
        return file ? file->record_fd() : -1;