titler rework, some code cleanup and fixes
[goodguy/history.git] / cinelerra-5.1 / cinelerra / asset.C
index 6aa73d7bc0941dc5c02a45237fed1c560595ea4d..d8db797b916d868632f89290e8e7b0ca7ae91108 100644 (file)
 
 #include "asset.h"
 #include "assets.h"
+#include "awindowgui.h"
 #include "bchash.h"
 #include "bcsignals.h"
 #include "clip.h"
+#include "cstrdup.h"
 #include "edl.h"
 #include "file.h"
 #include "filesystem.h"
@@ -86,13 +88,13 @@ int Asset::init_values()
        ff_video_options[0] = 0;
        ff_audio_bitrate = 0;
        ff_video_bitrate = 0;
-       ff_video_quality = 0;
+       ff_video_quality = -1;
 
        jpeg_quality = 80;
        aspect_ratio = -1;
-       interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
-       interlace_mode = BC_ILACE_MODE_UNDETECTED;
-       interlace_fixmethod = BC_ILACE_FIXMETHOD_NONE;
+       interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
+       interlace_mode = ILACE_MODE_UNDETECTED;
+       interlace_fixmethod = ILACE_FIXMETHOD_NONE;
 
        ampeg_bitrate = 256;
        ampeg_derivative = 3;
@@ -192,8 +194,8 @@ void Asset::copy_from(Asset *asset, int do_index)
 
 void Asset::copy_location(Asset *asset)
 {
-       strcpy(this->path, asset->path);
-       strcpy(this->folder, asset->folder);
+       strcpy(path, asset->path);
+       awindow_folder = asset->awindow_folder;
 }
 
 void Asset::copy_format(Asset *asset, int do_index)
@@ -318,21 +320,32 @@ char* Asset::get_compression_text(int audio, int video)
        return 0;
 }
 
-Asset& Asset::operator=(Asset &asset)
+int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
 {
-printf("Asset::operator=\n");
-       copy_location(&asset);
-       copy_format(&asset, 1);
-       return *this;
-}
-
-
-int Asset::equivalent(Asset &asset,
-       int test_audio,
-       int test_video)
-{
-       int result = (!strcmp(asset.path, path) &&
-               format == asset.format);
+       int result = format == asset.format ? 1 : 0;
+       if( result && strcmp(asset.path, path) ) {
+               char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
+               char *sp = out_path ? strrchr(out_path,'/') : 0;
+               if( sp ) *++sp = 0;
+               char *apath = FileSystem::basepath(asset.path);
+               char *tpath = FileSystem::basepath(this->path);
+               if( out_path ) {
+                       if( *apath != '/' ) {
+                               char *cp = cstrcat(2, out_path, apath);
+                               delete [] apath;  apath = FileSystem::basepath(cp);
+                               delete [] cp;
+                       }
+                       if( *tpath != '/' ) {
+                               char *cp = cstrcat(2, out_path, tpath);
+                               delete [] tpath;  tpath = FileSystem::basepath(cp);
+                               delete [] cp;
+                       }
+               }
+               if( strcmp(apath, tpath) ) result = 1;
+               delete [] apath;
+               delete [] tpath;
+               delete [] out_path;
+       }
 
        if(result && format == FILE_FFMPEG)
                result = !strcmp(fformat, asset.fformat);
@@ -379,19 +392,6 @@ int Asset::equivalent(Asset &asset,
        return result;
 }
 
-int Asset::operator==(Asset &asset)
-{
-
-       return equivalent(asset,
-               1,
-               1);
-}
-
-int Asset::operator!=(Asset &asset)
-{
-       return !(*this == asset);
-}
-
 int Asset::test_path(const char *path)
 {
        if(!strcasecmp(this->path, path))
@@ -464,7 +464,9 @@ int Asset::read(FileXML *file,
                        else
                        if(file->tag.title_is("FOLDER"))
                        {
-                               strcpy(folder, file->read_text());
+                               const char *string = file->tag.get_property("NUMBER");
+                               awindow_folder = string ? atoi(string) :
+                                       AWindowGUI::folder_number(file->read_text());
                        }
                        else
                        if(file->tag.title_is("VIDEO"))
@@ -537,11 +539,11 @@ int Asset::read_video(FileXML *file)
 
        interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
 
-       ilacemode_to_xmltext(string, BC_ILACE_MODE_NOTINTERLACED);
-       interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), BC_ILACE_MODE_NOTINTERLACED);
+       ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
+       interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
 
-       ilacefixmethod_to_xmltext(string, BC_ILACE_FIXMETHOD_NONE);
-       interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), BC_ILACE_FIXMETHOD_NONE);
+       ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
+       interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
 
        file->tag.get_property("REEL_NAME", reel_name);
        reel_number = file->tag.get_property("REEL_NUMBER", reel_number);
@@ -593,8 +595,8 @@ int Asset::write(FileXML *file,
        file->append_newline();
 
        file->tag.set_title("FOLDER");
+       file->tag.set_property("NUMBER", awindow_folder);
        file->append_tag();
-       file->append_text(folder);
        file->tag.set_title("/FOLDER");
        file->append_tag();
        file->append_newline();
@@ -831,9 +833,9 @@ void Asset::load_defaults(BC_Hash *defaults,
        jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
        aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
 
-       interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
-       interlace_mode          = BC_ILACE_MODE_UNDETECTED;
-       interlace_fixmethod     = BC_ILACE_FIXMETHOD_UPONE;
+       interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
+       interlace_mode          = ILACE_MODE_UNDETECTED;
+       interlace_fixmethod     = ILACE_FIXMETHOD_UPONE;
 
 // MPEG format information
        vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);