Reported by Fedora team for gcc-13 and Andrew created patch here
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / overlaydirect.C
1 #include "overlayframe.h"
2 #include "overlaydirect.h"
3
4 /* Direct translate / blend **********************************************/
5
6 DirectPackage::DirectPackage()
7 {
8 }
9
10 DirectUnit::DirectUnit(DirectEngine *server)
11  : LoadClient(server)
12 {
13         this->engine = server;
14 }
15
16 DirectUnit::~DirectUnit()
17 {
18 }
19
20 void DirectUnit::process_package(LoadPackage *package)
21 {
22         pkg = (DirectPackage*)package;
23         output = engine->output;
24         input = engine->input;
25         mode = engine->mode;
26         fade = BC_CModels::has_alpha(input->get_color_model()) &&
27                 mode == TRANSFER_REPLACE ? 1.f : engine->alpha;
28         ix = engine->in_x1;
29         ox = engine->out_x1;
30         ow = engine->out_x2 - ox;
31         iy = engine->in_y1 - engine->out_y1;
32
33         switch(input->get_color_model()) {
34         case BC_RGB_FLOAT:      rgb_float();    break;
35         case BC_RGBA_FLOAT:     rgba_float();   break;
36         case BC_RGB888:         rgb888();       break;
37         case BC_YUV888:         yuv888();       break;
38         case BC_RGBA8888:       rgba8888();     break;
39         case BC_YUVA8888:       yuva8888();     break;
40         case BC_RGB161616:      rgb161616();    break;
41         case BC_YUV161616:      yuv161616();    break;
42         case BC_RGBA16161616:   rgba16161616(); break;
43         case BC_YUVA16161616:   yuva16161616();  break;
44         }
45 }
46
47 DirectEngine::DirectEngine(int cpus)
48  : LoadServer(cpus, cpus)
49 {
50 }
51
52 DirectEngine::~DirectEngine()
53 {
54 }
55
56 void DirectEngine::init_packages()
57 {
58         if(in_x1 < 0) { out_x1 -= in_x1; in_x1 = 0; }
59         if(in_y1 < 0) { out_y1 -= in_y1; in_y1 = 0; }
60         if(out_x1 < 0) { in_x1 -= out_x1; out_x1 = 0; }
61         if(out_y1 < 0) { in_y1 -= out_y1; out_y1 = 0; }
62         if(out_x2 > output->get_w()) out_x2 = output->get_w();
63         if(out_y2 > output->get_h()) out_y2 = output->get_h();
64         int out_w = out_x2 - out_x1;
65         int out_h = out_y2 - out_y1;
66         if( !out_w || !out_h ) return;
67
68         int rows = out_h;
69         int pkgs = get_total_packages();
70         int row1 = out_y1, row2 = row1;
71         for(int i = 0; i < pkgs; row1=row2 ) {
72                 DirectPackage *package = (DirectPackage*)get_package(i);
73                 row2 = ++i * rows / pkgs + out_y1;
74                 package->out_row1 = row1;
75                 package->out_row2 = row2;
76         }
77 }
78
79 LoadClient* DirectEngine::new_client()
80 {
81         return new DirectUnit(this);
82 }
83
84 LoadPackage* DirectEngine::new_package()
85 {
86         return new DirectPackage;
87 }
88
89