no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / overlaydirect.C
1 /*
2  * This program is free software; you can redistribute it and/or modify it
3  * under the terms of the GNU General Public License as published
4  * by the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful, but
8  * WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  * General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public
13  * License along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
15  * USA
16  */
17
18 #include "overlayframe.h"
19 #include "overlaydirect.h"
20
21 /* Direct translate / blend **********************************************/
22
23 DirectPackage::DirectPackage()
24 {
25 }
26
27 DirectUnit::DirectUnit(DirectEngine *server)
28  : LoadClient(server)
29 {
30         this->engine = server;
31 }
32
33 DirectUnit::~DirectUnit()
34 {
35 }
36
37 void DirectUnit::process_package(LoadPackage *package)
38 {
39         pkg = (DirectPackage*)package;
40         output = engine->output;
41         input = engine->input;
42         mode = engine->mode;
43         fade = BC_CModels::has_alpha(input->get_color_model()) &&
44                 mode == TRANSFER_REPLACE ? 1.f : engine->alpha;
45         ix = engine->in_x1;
46         ox = engine->out_x1;
47         ow = engine->out_x2 - ox;
48         iy = engine->in_y1 - engine->out_y1;
49
50         switch(input->get_color_model()) {
51         case BC_RGB_FLOAT:      rgb_float();    break;
52         case BC_RGBA_FLOAT:     rgba_float();   break;
53         case BC_RGB888:         rgb888();       break;
54         case BC_YUV888:         yuv888();       break;
55         case BC_RGBA8888:       rgba8888();     break;
56         case BC_YUVA8888:       yuva8888();     break;
57         case BC_RGB161616:      rgb161616();    break;
58         case BC_YUV161616:      yuv161616();    break;
59         case BC_RGBA16161616:   rgba16161616(); break;
60         case BC_YUVA16161616:   yuva16161616();  break;
61         }
62 }
63
64 DirectEngine::DirectEngine(int cpus)
65  : LoadServer(cpus, cpus)
66 {
67 }
68
69 DirectEngine::~DirectEngine()
70 {
71 }
72
73 void DirectEngine::init_packages()
74 {
75         if(in_x1 < 0) { out_x1 -= in_x1; in_x1 = 0; }
76         if(in_y1 < 0) { out_y1 -= in_y1; in_y1 = 0; }
77         if(out_x1 < 0) { in_x1 -= out_x1; out_x1 = 0; }
78         if(out_y1 < 0) { in_y1 -= out_y1; out_y1 = 0; }
79         if(out_x2 > output->get_w()) out_x2 = output->get_w();
80         if(out_y2 > output->get_h()) out_y2 = output->get_h();
81         int out_w = out_x2 - out_x1;
82         int out_h = out_y2 - out_y1;
83         if( !out_w || !out_h ) return;
84
85         int rows = out_h;
86         int pkgs = get_total_packages();
87         int row1 = out_y1, row2 = row1;
88         for(int i = 0; i < pkgs; row1=row2 ) {
89                 DirectPackage *package = (DirectPackage*)get_package(i);
90                 row2 = ++i * rows / pkgs + out_y1;
91                 package->out_row1 = row1;
92                 package->out_row2 = row2;
93         }
94 }
95
96 LoadClient* DirectEngine::new_client()
97 {
98         return new DirectUnit(this);
99 }
100
101 LoadPackage* DirectEngine::new_package()
102 {
103         return new DirectPackage;
104 }
105
106