/*
* 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"
class DecimateRate : public BC_TextBox
{
public:
- DecimateRate(Decimate *plugin,
- DecimateWindow *gui,
- int x,
+ DecimateRate(Decimate *plugin,
+ DecimateWindow *gui,
+ int x,
int y);
int handle_event();
Decimate *plugin;
class DecimateRateMenu : public BC_ListBox
{
public:
- DecimateRateMenu(Decimate *plugin,
- DecimateWindow *gui,
- int x,
+ DecimateRateMenu(Decimate *plugin,
+ DecimateWindow *gui,
+ int x,
int y);
int handle_event();
Decimate *plugin;
{
public:
DecimateDifference(Decimate *plugin,
- int x,
+ int x,
int y);
int handle_event();
Decimate *plugin;
{
public:
DecimateAvgDifference(Decimate *plugin,
- int x,
+ int x,
int y);
int handle_event();
Decimate *plugin;
double c[8][8];
int fdct_ready;
-// each difference is the difference between the previous frame and the
+// each difference is the difference between the previous frame and the
// subscripted frame
int64_t differences[TOTAL_FRAMES];
DecimateWindow::DecimateWindow(Decimate *plugin)
- : PluginClientWindow(plugin,
- 210,
- 160,
- 200,
- 160,
+ : PluginClientWindow(plugin,
+ 210,
+ 160,
+ 200,
+ 160,
0)
{
this->plugin = plugin;
BC_Title *title;
add_subwindow(title = new BC_Title(x, y, _("Input frames per second:")));
y += 30;
- add_subwindow(rate = new DecimateRate(plugin,
- this,
- x,
+ add_subwindow(rate = new DecimateRate(plugin,
+ this,
+ x,
y));
- add_subwindow(rate_menu = new DecimateRateMenu(plugin,
- this,
- x + rate->get_w() + 5,
+ add_subwindow(rate_menu = new DecimateRateMenu(plugin,
+ this,
+ x + rate->get_w() + 5,
y));
y += 30;
add_subwindow(title = new BC_Title(x, y, _("Last frame dropped: ")));
// y += 30;
// add_subwindow(difference = new DecimateDifference(plugin,
-// x,
+// x,
// y));
// y += 30;
// add_subwindow(avg_difference = new DecimateAvgDifference(plugin,
-// x,
+// x,
// y));
show_window();
flush();
-DecimateRate::DecimateRate(Decimate *plugin,
- DecimateWindow *gui,
- int x,
+DecimateRate::DecimateRate(Decimate *plugin,
+ DecimateWindow *gui,
+ int x,
int y)
- : BC_TextBox(x,
- y,
+ : BC_TextBox(x,
+ y,
90,
1,
(float)plugin->config.input_rate)
// DecimateDifference::DecimateDifference(Decimate *plugin,
-// int x,
+// int x,
// int y)
// : BC_CheckBox(x, y, plugin->config.least_difference, "Drop least difference")
// {
// plugin->send_configure_change();
// return 1;
// }
-//
-//
-//
-//
+//
+//
+//
+//
// DecimateAvgDifference::DecimateAvgDifference(Decimate *plugin,
-// int x,
+// int x,
// int y)
// : BC_CheckBox(x, y, plugin->config.averaged_frames, "Drop averaged frames")
// {
// this->plugin = plugin;
// }
-//
+//
// int DecimateAvgDifference::handle_event()
// {
// plugin->config.averaged_frames = get_value();
// plugin->send_configure_change();
// return 1;
// }
-//
+//
-DecimateRateMenu::DecimateRateMenu(Decimate *plugin,
- DecimateWindow *gui,
- int x,
+DecimateRateMenu::DecimateRateMenu(Decimate *plugin,
+ DecimateWindow *gui,
+ int x,
int y)
: BC_ListBox(x,
y,
Decimate::Decimate(PluginServer *server)
: PluginVClient(server)
{
-
+
bzero(frames, sizeof(VFrame*) * TOTAL_FRAMES);
for(int i = 0; i < TOTAL_FRAMES; i++)
differences[i] = -1;
Decimate::~Decimate()
{
-
+
if(frames[0])
{
for(int i = 0; i < TOTAL_FRAMES; i++)
for(int i = 0; i < lookahead_size; i++)
{
// Drop least different frame from sequence
- if(config.least_difference &&
+ if(config.least_difference &&
differences[i] >= 0 &&
differences[i] < min_difference)
{
// Normalize requested position to input rate
if(!lookahead_size)
{
- lookahead_end = (int64_t)((double)start_position *
- config.input_rate /
+ lookahead_end = (int64_t)((double)start_position *
+ config.input_rate /
frame_rate);
}
while(lookahead_size < TOTAL_FRAMES)
{
// Import frame into next lookahead slot
- read_frame(frames[lookahead_size],
- 0,
- lookahead_end,
+ read_frame(frames[lookahead_size],
+ 0,
+ lookahead_end,
config.input_rate,
0);
// Fill difference buffer
if(lookahead_size > 0)
- differences[lookahead_size] =
- calculate_difference(frames[lookahead_size - 1],
+ differences[lookahead_size] =
+ calculate_difference(frames[lookahead_size - 1],
frames[lookahead_size]);
// Increase counters relative to input rate
// Decimate one if last frame in buffer and lookahead_end is behind predicted
// end.
int64_t decimated_end = (int64_t)((double)(start_position + TOTAL_FRAMES) *
- config.input_rate /
+ config.input_rate /
frame_rate);
if(lookahead_size >= TOTAL_FRAMES &&
lookahead_end < decimated_end)
if(!frames[0])
{
- for(int i = 0; i < TOTAL_FRAMES; i++)
- {
- frames[i] = new VFrame(0,
- -1,
- frame->get_w(),
- frame->get_h(),
- frame->get_color_model(),
- -1);
+ for(int i = 0; i < TOTAL_FRAMES; i++) {
+ frames[i] = new VFrame(frame->get_w(), frame->get_h(),
+ frame->get_color_model(), 0);
}
}
-const char* Decimate::plugin_title() { return _("Decimate"); }
+const char* Decimate::plugin_title() { return N_("Decimate"); }
int Decimate::is_realtime() { return 1; }
NEW_WINDOW_MACRO(Decimate, DecimateWindow)