interp bilinear fix
[goodguy/history.git] / cinelerra-5.1 / cinelerra / sharedlocation.C
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #include "edl.h"
23 #include "filexml.h"
24 #include "language.h"
25 #include "plugin.h"
26 #include "sharedlocation.h"
27 #include "track.h"
28 #include "tracks.h"
29 #include "transportque.h"
30
31 // plugin locations
32
33
34 #include <string.h>
35
36
37
38 SharedLocation::SharedLocation()
39 {
40         this->module = -1;
41         this->plugin = -1;
42 }
43
44 SharedLocation::SharedLocation(int module, int plugin)
45 {
46         this->module = module;
47         this->plugin = plugin;
48 }
49
50 void SharedLocation::save(FileXML *file)
51 {
52         file->tag.set_title("SHARED_LOCATION");
53         if(module >= 0) file->tag.set_property("SHARED_MODULE", (int64_t)module);
54         if(plugin >= 0) file->tag.set_property("SHARED_PLUGIN", (int64_t)plugin);
55         file->append_tag();
56         file->tag.set_title("/SHARED_LOCATION");
57         file->append_tag();
58         file->append_newline();
59 }
60
61 void SharedLocation::load(FileXML *file)
62 {
63         module = -1;
64         plugin = -1;
65
66         module = file->tag.get_property("SHARED_MODULE", (int64_t)module);
67         plugin = file->tag.get_property("SHARED_PLUGIN", (int64_t)plugin);
68 }
69
70 int SharedLocation::get_type()
71 {
72         if(plugin < 0)
73                 return PLUGIN_SHAREDMODULE;
74         else
75                 return PLUGIN_SHAREDPLUGIN;
76 }
77
78
79 int SharedLocation::operator==(const SharedLocation &that)
80 {
81 //printf("SharedLocation::operator== called\n");
82         if(
83                 module == that.module &&
84                 plugin == that.plugin
85         ) return 1;
86         else
87         return 0;
88 }
89
90 int SharedLocation::equivalent(SharedLocation *that)
91 {
92         if(
93                 module == that->module &&
94                 plugin == that->plugin
95         ) return 1;
96         else
97         return 0;
98
99 }
100
101 SharedLocation& SharedLocation::operator=(const SharedLocation &that)
102 {
103 //printf("SharedLocation::operator= called\n");
104         this->plugin = that.plugin;
105         this->module = that.module;
106         return *this;
107 }
108
109 void SharedLocation::copy_from(SharedLocation *that)
110 {
111         this->plugin = that->plugin;
112         this->module = that->module;
113 }
114
115
116 void SharedLocation::calculate_title(char *string,
117         EDL *edl,
118         double position,
119         int convert_units,
120         int plugin_type,
121         int use_nudge)
122 {
123         if(plugin_type == PLUGIN_SHAREDPLUGIN)
124         {
125                 Track *track = 0;
126                 Plugin *plugin = 0;
127
128                 track = edl->tracks->get_item_number(module);
129                 if(track && this->plugin >= 0)
130                 {
131                         plugin = track->get_current_plugin(position,
132                                 this->plugin,
133                                 PLAY_FORWARD,
134                                 convert_units,
135                                 use_nudge);
136                 }
137
138                 char track_title[BCTEXTLEN];
139                 char plugin_title[BCTEXTLEN];
140
141                 if(track)
142                         strcpy(track_title, track->title);
143                 else
144                         sprintf(track_title, _("None"));
145
146                 if(plugin)
147                         strcpy(plugin_title, _(plugin->title));
148                 else
149                         sprintf(plugin_title, _("None"));
150
151                 sprintf(string, "%s: %s", track_title, plugin_title);
152         }
153         else
154         if(plugin_type == PLUGIN_SHAREDMODULE)
155         {
156                 Track *track = 0;
157                 track = edl->tracks->get_item_number(module);
158
159                 if(track)
160                         strcpy(string, track->title);
161                 else
162                         sprintf(string, _("None"));
163 //printf("SharedLocation::calculate_title %p %s\n", string);
164         }
165 }
166
167
168