Add back 2 patches for histogram and overlayframe that are working correctly and...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / menuveffects.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 "asset.h"
23 #include "bchash.h"
24 #include "edl.h"
25 #include "edlsession.h"
26 #include "file.h"
27 #include "mainmenu.h"
28 #include "mainsession.h"
29 #include "mwindow.h"
30 #include "mwindowgui.h"
31 #include "menuveffects.h"
32 #include "patchbay.h"
33 #include "tracks.h"
34 #include "units.h"
35 #include "vpluginarray.h"
36
37
38 MenuVEffects::MenuVEffects(MWindow *mwindow)
39  : MenuEffects(mwindow)
40 {
41         thread = new MenuVEffectThread(mwindow, this);
42 }
43
44 MenuVEffects::~MenuVEffects()
45 {
46         delete thread;
47 }
48
49 MenuVEffectThread::MenuVEffectThread(MWindow *mwindow, MenuVEffects *menu_item)
50  : MenuEffectThread(mwindow, menu_item)
51 {
52 }
53
54 MenuVEffectThread::~MenuVEffectThread()
55 {
56 }
57
58 int MenuVEffectThread::get_recordable_tracks(Asset *asset)
59 {
60         asset->layers = mwindow->edl->tracks->recordable_video_tracks();
61         return asset->layers;
62 }
63
64 int MenuVEffectThread::get_derived_attributes(Asset *asset, BC_Hash *defaults)
65 {
66
67         asset->load_defaults(defaults, "VEFFECT_", 1, 1, 1, 0, 0);
68
69 // Fix asset for video only
70         if(!File::renders_video(asset)) {
71                 asset->format = FILE_FFMPEG;
72                 strcpy(asset->vcodec, "mp4");
73         }
74
75         asset->audio_data = 0;
76         asset->video_data = 1;
77
78         return 0;
79 }
80
81 int MenuVEffectThread::save_derived_attributes(Asset *asset, BC_Hash *defaults)
82 {
83         asset->save_defaults(defaults, "VEFFECT_", 1, 1, 1, 0, 0);
84         return 0;
85 }
86
87 PluginArray* MenuVEffectThread::create_plugin_array()
88 {
89         return new VPluginArray();
90 }
91
92 int64_t MenuVEffectThread::to_units(double position, int round)
93 {
94         if(round)
95                 return Units::round(position * mwindow->edl->session->frame_rate);
96         else
97                 return (int64_t)(position * mwindow->edl->session->frame_rate);
98
99         return 0;
100 }
101
102 int MenuVEffectThread::fix_menu(char *title)
103 {
104         mwindow->gui->mainmenu->add_veffect(title);
105         return 0;
106 }
107
108 MenuVEffectItem::MenuVEffectItem(MenuVEffects *menueffect, const char *string)
109  : MenuEffectItem(menueffect, string)
110 {
111 }