/*
* CINELERRA
* Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
- *
+ *
* 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"
: PluginAClient(server)
{
reset();
-
+
}
DenoiseEffect::~DenoiseEffect()
{
-
+
delete_dsp();
}
iterations = 1;
}
-const char* DenoiseEffect::plugin_title() { return _("Denoise"); }
+const char* DenoiseEffect::plugin_title() { return N_("Denoise"); }
int DenoiseEffect::is_realtime() { return 1; }
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
{
if(i < filtlen)
*output_sequence++ = dot_product(input_sequence + i, filter, i + 1);
- else
+ else
if(i > lengthp5)
{
offset = i - lengthm4;
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
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];
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++)
{
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]);
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;
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)
}
-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;
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;
out_scale = output_level / 65535 * sqrt(window_size);
initialized = 1;
}
-
+
// Append input buffer
if(input_size + size > input_allocation)
{
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;
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;
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;
int i;
for (i = 2 * levels - 1; i >= 0; i--)
- delete values[i];
+ delete [] values[i];
delete values;
}
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;
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);
DenoiseWindow::DenoiseWindow(DenoiseEffect *plugin)
- : PluginClientWindow(plugin,
- 150,
- 50,
- 150,
- 50,
- 0)
+ : PluginClientWindow(plugin, 280, 50, 280, 50, 0)
{
this->plugin = 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));