Debian Codegraph @

src/filter/letterb0xed/letterb0xed.c

raw symbols SCIP
1 /* letterb0xed.c
2 * Copyright (C) 2007 Richard Spindler ([email protected])
3 * This file is a Frei0r plugin.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <math.h>
21 #include "frei0r.h"
22 #include <stdlib.h>
23 #include <stdio.h>
24
25 typedef struct letterb0xed_instance {
26 double value;
27 double bg_transparent;
28 int w, h;
29 int top, bottom;
30 int len;
31 uint32_t background;
32 } letterb0xed_instance_t;
33
34 int f0r_init()
35 {
36 return 1;
37 }
38 void f0r_deinit()
39 { /* empty */ }
40
41 void f0r_get_plugin_info( f0r_plugin_info_t* info )
42 {
43 info->name = "LetterB0xed";
44 info->author = "Richard Spindler";
45 info->plugin_type = F0R_PLUGIN_TYPE_FILTER;
46 info->color_model = F0R_COLOR_MODEL_RGBA8888;
47 info->frei0r_version = FREI0R_MAJOR_VERSION;
48 info->major_version = 0;
49 info->minor_version = 1;
50 info->num_params = 2;
51 info->explanation = "Adds Black Borders at top and bottom for Cinema Look";
52
53 }
54 void f0r_get_param_info( f0r_param_info_t* info, int param_index )
55 {
56 switch ( param_index ) {
57 case 0:
58 info->name = "Border Width";
59 info->type = F0R_PARAM_DOUBLE;
60 info->explanation = "";
61 break;
62 case 1:
63 info->name = "Transparency";
64 info->type = F0R_PARAM_BOOL;
65 info->explanation = "";
66 break;
67 }
68 }
69
70 f0r_instance_t f0r_construct(unsigned int width, unsigned int height)
71 {
72 letterb0xed_instance_t* inst = (letterb0xed_instance_t*)calloc(1, sizeof(*inst));
73 inst->w = width;
74 inst->h = height;
75 inst->len = width * height;
76 inst->value = 0.4;
77 inst->bg_transparent = 0.0;
78 inst->top = (int)( ( inst->h / 2 ) * inst->value );
79 inst->bottom = inst->h - inst->top;
80 inst->top *= inst->w;
81 inst->bottom *= inst->w;
82 inst->background = 0xFF000000;
83
84
85 return (f0r_instance_t)inst;
86 }
87 void f0r_destruct(f0r_instance_t instance)
88 {
89 letterb0xed_instance_t* inst = (letterb0xed_instance_t*)instance;
90 free(inst);
91 }
92 void f0r_set_param_value(f0r_instance_t instance,
93 f0r_param_t param, int param_index)
94 {
95 letterb0xed_instance_t* inst = (letterb0xed_instance_t*)instance;
96 switch ( param_index ) {
97 case 0:
98 inst->value = *((double*)param);
99 break;
100 case 1:
101 inst->bg_transparent = *((double*)param);
102 break;
103 }
104 inst->top = (int)( ( inst->h / 2 ) * inst->value );
105 inst->bottom = inst->h - inst->top;
106 inst->top *= inst->w;
107 inst->bottom *= inst->w;
108 inst->background = 0x00000000;
109 if ( inst->bg_transparent < 0.5 ) {
110 ((uint8_t*)(&inst->background))[3] = 0xFF;
111 }
112 }
113 void f0r_get_param_value(f0r_instance_t instance,
114 f0r_param_t param, int param_index)
115 {
116 letterb0xed_instance_t* inst = (letterb0xed_instance_t*)instance;
117 switch ( param_index ) {
118 case 0:
119 *((double*)param) = inst->value;
120 break;
121 case 1:
122 *((double*)param) = inst->bg_transparent;
123 break;
124 }
125 }
126 void f0r_update(f0r_instance_t instance, double time,
127 const uint32_t* inframe, uint32_t* outframe)
128 {
129 letterb0xed_instance_t* inst = (letterb0xed_instance_t*)instance;
130 int i;
131 for ( i = 0; i < inst->top; i++ ) {
132 outframe[i] = inst->background;
133 }
134 for ( i = inst->top; i < inst->bottom; i++ ) {
135 outframe[i] = inframe[i];
136 }
137 for ( i = inst->bottom; i < inst->len; i++ ) {
138 outframe[i] = inst->background;
139 }
140
141 }
142