X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fdenoise%2Fdenoise.C;h=238f9ad0ecb23e162296ee2eed936669b60f35b8;hb=7e5a0760f40ff787cc3d93cb7768a901ebe52809;hp=063a23f429067e8c150f37911e931bdab8f48968;hpb=c76ba7b82b876025995364912d35f300a59ec200;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/denoise/denoise.C b/cinelerra-5.1/plugins/denoise/denoise.C index 063a23f4..238f9ad0 100644 --- a/cinelerra-5.1/plugins/denoise/denoise.C +++ b/cinelerra-5.1/plugins/denoise/denoise.C @@ -2,21 +2,21 @@ /* * CINELERRA * Copyright (C) 2008 Adam Williams - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ #include "bcdisplayinfo.h" @@ -49,12 +49,12 @@ DenoiseEffect::DenoiseEffect(PluginServer *server) : PluginAClient(server) { reset(); - + } DenoiseEffect::~DenoiseEffect() { - + delete_dsp(); } @@ -126,7 +126,7 @@ void DenoiseEffect::reset() iterations = 1; } -const char* DenoiseEffect::plugin_title() { return _("Denoise"); } +const char* DenoiseEffect::plugin_title() { return N_("Denoise"); } int DenoiseEffect::is_realtime() { return 1; } @@ -188,10 +188,10 @@ double DenoiseEffect::dot_product(double *data, double *filter, char filtlen) return sum; } -int DenoiseEffect::convolve_dec_2(double *input_sequence, +int DenoiseEffect::convolve_dec_2(double *input_sequence, int64_t length, - double *filter, - int filtlen, + double *filter, + int filtlen, double *output_sequence) { // convolve the input sequence with the filter and decimate by two @@ -205,7 +205,7 @@ int DenoiseEffect::convolve_dec_2(double *input_sequence, { if(i < filtlen) *output_sequence++ = dot_product(input_sequence + i, filter, i + 1); - else + else if(i > lengthp5) { offset = i - lengthm4; @@ -219,10 +219,10 @@ int DenoiseEffect::convolve_dec_2(double *input_sequence, return 0; } -int64_t DenoiseEffect::decompose_branches(double *in_data, - int64_t length, - WaveletFilters *decomp_filter, - double *out_low, +int64_t DenoiseEffect::decompose_branches(double *in_data, + int64_t length, + WaveletFilters *decomp_filter, + double *out_low, double *out_high) { // Take input data and filters and form two branches of half the @@ -232,16 +232,16 @@ int64_t DenoiseEffect::decompose_branches(double *in_data, return (length / 2); } -int DenoiseEffect::wavelet_decomposition(double *in_data, - int64_t in_length, +int DenoiseEffect::wavelet_decomposition(double *in_data, + int64_t in_length, double **out_data) { for(int i = 0; i < levels; i++) { - in_length = decompose_branches(in_data, - in_length, - decomp_filter, - out_data[2 * i], + in_length = decompose_branches(in_data, + in_length, + decomp_filter, + out_data[2 * i], out_data[(2 * i) + 1]); in_data = out_data[2 * i]; @@ -249,12 +249,12 @@ int DenoiseEffect::wavelet_decomposition(double *in_data, return 0; } -int DenoiseEffect::tree_copy(double **output, - double **input, - int length, +int DenoiseEffect::tree_copy(double **output, + double **input, + int length, int levels) { - register int i, j, k, l, m; + int i, j, k, l, m; for(i = 0, k = 1; k < levels; i++, k++) { @@ -288,12 +288,12 @@ int DenoiseEffect::threshold(int window_size, double gammas, int levels) double *coeff_r, *coeff_l; int length; - for(i = 0; i < levels; i++) + for(i = 0; i < levels; i++) { length = (window_size >> (i + 1)) + 5; threshold = sqrt(2 * log(length) / log(2)) * gammas / sqrt(length); - for(j = 0; j < length; j++) + for(j = 0; j < length; j++) { coeff_r = &(ex_coeff_r->values[(2 * i) + 1][j]); coeff_l = &(ex_coeff_rn->values[(2 * i) + 1][j]); @@ -303,12 +303,12 @@ int DenoiseEffect::threshold(int window_size, double gammas, int levels) cvb = abs_coeff_r - threshold; cv *= cvb; - if(abs_coeff_r > threshold) + if(abs_coeff_r > threshold) { *coeff_r = cv; *coeff_l = 0.0; } - else + else { *coeff_l = *coeff_r; *coeff_r = 0.0; @@ -340,16 +340,16 @@ double DenoiseEffect::dot_product_odd(double *data, double *filter, int filtlen) return sum; } -int DenoiseEffect::convolve_int_2(double *input_sequence, - int64_t length, - double *filter, - int filtlen, - int sum_output, +int DenoiseEffect::convolve_int_2(double *input_sequence, + int64_t length, + double *filter, + int filtlen, + int sum_output, double *output_sequence) // insert zeros between each element of the input sequence and // convolve with the filter to interpolate the data { - register int i, j; + int i, j; int endpoint = length + filtlen - 2; if (sum_output) @@ -380,23 +380,23 @@ int DenoiseEffect::convolve_int_2(double *input_sequence, } -int64_t DenoiseEffect::reconstruct_branches(double *in_low, - double *in_high, +int64_t DenoiseEffect::reconstruct_branches(double *in_low, + double *in_high, int64_t in_length, - WaveletFilters *recon_filter, + WaveletFilters *recon_filter, double *output) { // take input data and filters and form two branches of half the // original length. length of branches is returned - convolve_int_2(in_low, in_length, recon_filter->h, + convolve_int_2(in_low, in_length, recon_filter->h, recon_filter->length, 0, output); - convolve_int_2(in_high, in_length, recon_filter->g, + convolve_int_2(in_high, in_length, recon_filter->g, recon_filter->length, 1, output); return in_length * 2; } -int DenoiseEffect::wavelet_reconstruction(double **in_data, - int64_t in_length, +int DenoiseEffect::wavelet_reconstruction(double **in_data, + int64_t in_length, double *out_data) { double *output; @@ -408,18 +408,18 @@ int DenoiseEffect::wavelet_reconstruction(double **in_data, for(i = levels - 1; i > 0; i--) { output = in_data[2 * (i - 1)]; - in_length = reconstruct_branches(in_data[2 * i], + in_length = reconstruct_branches(in_data[2 * i], in_data[(2 * i) + 1], - in_length, - recon_filter, + in_length, + recon_filter, output); } // destination of the last branch reconstruction is the output data - reconstruct_branches(in_data[0], - in_data[1], - in_length, - recon_filter, + reconstruct_branches(in_data[0], + in_data[1], + in_length, + recon_filter, out_data); return 0; @@ -473,7 +473,7 @@ int DenoiseEffect::process_realtime(int64_t size, Samples *input_ptr, Samples *o out_scale = output_level / 65535 * sqrt(window_size); initialized = 1; } - + // Append input buffer if(input_size + size > input_allocation) { @@ -486,8 +486,8 @@ int DenoiseEffect::process_realtime(int64_t size, Samples *input_ptr, Samples *o input_buffer = new_input; input_allocation = input_size + size; } - memcpy(input_buffer + input_size, - input_ptr->get_data(), + memcpy(input_buffer + input_size, + input_ptr->get_data(), size * sizeof(double)); input_size += size; @@ -536,8 +536,8 @@ int DenoiseEffect::process_realtime(int64_t size, Samples *input_ptr, Samples *o if(output_size >= WINDOW_BORDER) { - for(int i = 0, j = output_size - WINDOW_BORDER; - i < WINDOW_BORDER; + for(int i = 0, j = output_size - WINDOW_BORDER; + i < WINDOW_BORDER; i++, j++) { double src_level = (double)i / WINDOW_BORDER; @@ -552,16 +552,16 @@ int DenoiseEffect::process_realtime(int64_t size, Samples *input_ptr, Samples *o else { // First buffer has no crossfade - memcpy(output_buffer + output_size, - dsp_out, + memcpy(output_buffer + output_size, + dsp_out, sizeof(double) * window_size); output_size += window_size; } // Shift input buffer forward - for(int i = window_size - WINDOW_BORDER, j = 0; - i < input_size; + for(int i = window_size - WINDOW_BORDER, j = 0; + i < input_size; i++, j++) input_buffer[j] = input_buffer[i]; input_size -= window_size - WINDOW_BORDER; @@ -640,7 +640,7 @@ WaveletCoeffs::WaveletCoeffs(double alpha, double beta) tcosa = cos(alpha - beta); tsina = sin(alpha - beta); -// calculate last four wavelet coefficients c = a(0), d = a(1), +// calculate last four wavelet coefficients c = a(0), d = a(1), // e = a(2), and f = a(3) values[2] = (1.0 + tcosa + tsina) / 2.0; values[3] = (1.0 + tcosa - tsina) / 2.0; @@ -724,10 +724,10 @@ int DenoiseConfig::equivalent(DenoiseConfig &that) return EQUIV(level, that.level); } -void DenoiseConfig::interpolate(DenoiseConfig &prev, - DenoiseConfig &next, - int64_t prev_frame, - int64_t next_frame, +void DenoiseConfig::interpolate(DenoiseConfig &prev, + DenoiseConfig &next, + int64_t prev_frame, + int64_t next_frame, int64_t current_frame) { double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame); @@ -762,7 +762,7 @@ DenoiseWindow::DenoiseWindow(DenoiseEffect *plugin) void DenoiseWindow::create_objects() { int x = 10, y = 10; - + add_subwindow(new BC_Title(x, y, _("Level:"))); x += 70; add_subwindow(scale = new DenoiseLevel(plugin, x, y));