| 1 | /* RGB.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 <stdlib.h> |
| 21 | #include <assert.h> |
| 22 | |
| 23 | #include "frei0r.h"cxx . . $ `<file>/include/frei0r.h`/ |
| 24 | |
| 25 | typedef struct RGB_instancecxx . . $ RGB_instance# |
| 26 | { |
| 27 | unsigned int widthcxx . . $ RGB_instance#width.; |
| 28 | unsigned int heightcxx . . $ RGB_instance#height.; |
| 29 | } RGB_instance_tcxx . . $ RGB_instance_t#; |
| 30 | |
| 31 | int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).() |
| 32 | { |
| 33 | return 1; |
| 34 | } |
| 35 | |
| 36 | void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).() |
| 37 | { /* no initialization required */ } |
| 38 | |
| 39 | void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t#* RGBInfo) |
| 40 | { |
| 41 | RGBInfo->namecxx . . $ f0r_plugin_info#name. = "RGB"; |
| 42 | RGBInfo->authorcxx . . $ f0r_plugin_info#author. = "Richard Spindler"; |
| 43 | RGBInfo->plugin_typecxx . . $ f0r_plugin_info#plugin_type. = F0R_PLUGIN_TYPE_MIXER3cxx . . $ `include/frei0r.h:253:9`!; |
| 44 | RGBInfo->color_modelcxx . . $ f0r_plugin_info#color_model. = F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!; |
| 45 | RGBInfo->frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version. = FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`!; |
| 46 | RGBInfo->major_versioncxx . . $ f0r_plugin_info#major_version. = 0; |
| 47 | RGBInfo->minor_versioncxx . . $ f0r_plugin_info#minor_version. = 9; |
| 48 | RGBInfo->num_paramscxx . . $ f0r_plugin_info#num_params. = 0; |
| 49 | RGBInfo->explanationcxx . . $ f0r_plugin_info#explanation. = "Averages each Input and uses each as R, G or B channel of the Output"; |
| 50 | } |
| 51 | |
| 52 | void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t#* info, int param_index) |
| 53 | { |
| 54 | /* no params */ |
| 55 | } |
| 56 | |
| 57 | f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned int width, unsigned int height) |
| 58 | { |
| 59 | RGB_instance_tcxx . . $ RGB_instance_t#* inst = (RGB_instance_tcxx . . $ RGB_instance_t#*)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(*inst)); |
| 60 | inst->widthcxx . . $ RGB_instance#width. = width; inst->heightcxx . . $ RGB_instance#height. = height; |
| 61 | return (f0r_instance_tcxx . . $ f0r_instance_t#)inst; |
| 62 | } |
| 63 | |
| 64 | void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# instance) |
| 65 | { |
| 66 | freecxx . . $ free(5d22bdacc48458e8).(instance); |
| 67 | } |
| 68 | |
| 69 | void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, |
| 70 | f0r_param_tcxx . . $ f0r_param_t# param, int param_index) |
| 71 | { /* no params */ } |
| 72 | |
| 73 | void f0r_get_param_valuecxx . . $ f0r_get_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, |
| 74 | f0r_param_tcxx . . $ f0r_param_t# param, int param_index) |
| 75 | { /* no params */ } |
| 76 | |
| 77 | |
| 78 | void f0r_update2cxx . . $ f0r_update2(1b234bc88d3943d5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, |
| 79 | double time, |
| 80 | const uint32_tcxx . . $ uint32_t#* inframe1, |
| 81 | const uint32_tcxx . . $ uint32_t#* inframe2, |
| 82 | const uint32_tcxx . . $ uint32_t#* inframe3, |
| 83 | uint32_tcxx . . $ uint32_t#* outframe) |
| 84 | { |
| 85 | assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(instance); |
| 86 | RGB_instance_tcxx . . $ RGB_instance_t#* inst = (RGB_instance_tcxx . . $ RGB_instance_t#*)instance; |
| 87 | unsigned int w = inst->widthcxx . . $ RGB_instance#width.; |
| 88 | unsigned int h = inst->heightcxx . . $ RGB_instance#height.; |
| 89 | unsigned int x,y; |
| 90 | |
| 91 | uint32_tcxx . . $ uint32_t#* dst = outframe; |
| 92 | const uint32_tcxx . . $ uint32_t#* src1 = inframe1; |
| 93 | const uint32_tcxx . . $ uint32_t#* src2 = inframe2; |
| 94 | const uint32_tcxx . . $ uint32_t#* src3 = inframe3; |
| 95 | for(y=0;y<h;++y) |
| 96 | for(x=0;x<w;++x) { |
| 97 | int tmpbw1; |
| 98 | int tmpbw2; |
| 99 | int tmpbw3; |
| 100 | unsigned char* tmpc1 = (unsigned char*)src1; |
| 101 | unsigned char* tmpc2 = (unsigned char*)src2; |
| 102 | unsigned char* tmpc3 = (unsigned char*)src3; |
| 103 | tmpbw1 = (tmpc1[0] + tmpc1[1] + tmpc1[2]) / 3; |
| 104 | tmpbw2 = (tmpc2[0] + tmpc2[1] + tmpc2[2]) / 3; |
| 105 | tmpbw3 = (tmpc3[0] + tmpc3[1] + tmpc3[2]) / 3; |
| 106 | |
| 107 | *dst++ = ( 0xff000000 ) | (tmpbw3 << 16)| (tmpbw2 << 8)| (tmpbw1); |
| 108 | |
| 109 | src1++; |
| 110 | src2++; |
| 111 | src3++; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 |