1
/***************************************************************************
2
copyright : (C) 2007 by mean
3
email : fixounet@free.fr
5
* We hide some info the the "type"
9
3000-4000 filterFamilyClick Filter
10
8000-9000 Active Filter
13
***************************************************************************/
15
/***************************************************************************
17
* This program is free software; you can redistribute it and/or modify *
18
* it under the terms of the GNU General Public License as published by *
19
* the Free Software Foundation; either version 2 of the License, or *
20
* (at your option) any later version. *
22
***************************************************************************/
28
#include <sys/types.h>
33
#define Ui_Dialog Ui_mainFilterDialog
34
#include "ui_mainfilter.h"
36
#include "QStringListModel"
39
#include "ADM_toolkit/filesel.h"
42
#include "ADM_audiodevice/audio_out.h"
43
#include "ADM_audio/ADM_audiodef.h"
45
#include "ADM_assert.h"
46
#include "GUI_render.h"
47
#include "ADM_osSupport/ADM_cpuCap.h"
48
#include "ADM_toolkit/toolkit.hxx"
49
#include "ADM_editor/ADM_edit.hxx"
50
#include "ADM_video/ADM_genvideo.hxx"
51
#include "ADM_filter/video_filters.h"
52
#include "ADM_video/ADM_vidPartial.h"
53
#include "ADM_filter/vidVCD.h"
54
#include "ADM_userInterfaces/ADM_commonUI/DIA_factory.h"
55
/*******************************************************/
60
/******************************************************/
61
#define ALL_FILTER_BASE 1000
62
#define EXTERNAL_FILTER_BASE 2000
63
#define ACTIVE_FILTER_BASE 3000
64
/******************************************************/
65
extern FILTER videofilters[MAX_FILTER];
66
extern uint32_t nb_active_filter;
67
extern std::vector <FILTER_ENTRY> allfilters;
69
extern const char *filterGetNameFromTag(VF_FILTERS tag);
70
extern ADM_Composer *video_body;
71
extern AVDMGenericVideoStream *filterCreateFromTag(VF_FILTERS tag,CONFcouple *conf, AVDMGenericVideoStream *in) ;
72
/*******************************************************/
73
class filtermainWindow : public QDialog
79
// virtual ~filtermainWindow();
80
void buildActiveFilterList(void);
81
Ui_mainFilterDialog ui;
85
QListWidget *availableList;
86
QListWidget *activeList;
99
void configure(bool b);
100
void partial(bool b);
101
void activeDoubleClick( QListWidgetItem *item);
102
void allDoubleClick( QListWidgetItem *item);
103
void filterFamilyClick(QListWidgetItem *item);
104
void filterFamilyClick(int item);
107
int startFilter[NB_TREE];
108
int filterSize[NB_TREE];
109
void setSelected(int sel);
110
void displayFamily(uint32_t family);
111
void setupFilters(void);
114
\fn void setSelected(int sel)
115
\brief Set the sel line as selected in the active filter window
117
void filtermainWindow::setSelected( int sel)
120
activeList->setCurrentRow(sel-1);
125
\brief Retrieve the selected filter and add it to the active filters
127
void filtermainWindow::add( bool b)
129
/* Now that we have the tab, get the selection */
130
QListWidgetItem *item=availableList->currentItem();
134
int itag=item->type();
135
if(itag>=ALL_FILTER_BASE && itag < EXTERNAL_FILTER_BASE)
137
tag=allfilters[itag-ALL_FILTER_BASE].tag;
143
printf("Tag : %d\n",itag);
145
// Create our filter...
148
videofilters[nb_active_filter].filter = filterCreateFromTag (tag, NULL, videofilters[nb_active_filter - 1].filter);
149
if(!videofilters[nb_active_filter].filter-> configure (videofilters[nb_active_filter - 1].filter))
151
delete videofilters[nb_active_filter].filter;
154
videofilters[nb_active_filter].filter->getCoupledConf (&coup);
155
videofilters[nb_active_filter].tag = tag;
156
videofilters[nb_active_filter].conf = coup;
158
setSelected(nb_active_filter);
159
buildActiveFilterList();
165
\brief Remove selected filters from the active window list
167
void filtermainWindow::remove( bool b)
169
/* Get selection if any */
170
/* Now that we have the tab, get the selection */
171
QListWidgetItem *item=activeList->currentItem();
174
printf("No selection\n");
178
int itag=item->type();
179
ADM_assert(itag>ACTIVE_FILTER_BASE);
180
itag-=ACTIVE_FILTER_BASE;
181
/* Filter 0 is the decoder ...*/
182
printf("Rank : %d\n",itag);
185
if (videofilters[itag].conf)
187
delete videofilters[itag].conf;
188
videofilters[itag].conf = NULL;
190
// recreate derivated filters
191
for (uint32_t i = itag ; i < nb_active_filter-1; i++)
193
delete videofilters[i ].filter;
194
videofilters[i ].filter = filterCreateFromTag(videofilters[i+1].tag,
195
videofilters[i+1].conf,
196
videofilters[i - 1].filter);
197
videofilters[i ].conf = videofilters[i+1].conf;
198
videofilters[i ].tag = videofilters[i+1].tag;
200
/* Delete last filter which is now at last filter -1 */
201
delete videofilters[nb_active_filter - 1].filter;
202
videofilters[nb_active_filter - 1].filter = NULL;
204
buildActiveFilterList ();
205
if(nb_active_filter>1)
207
if(itag<nb_active_filter-1)
210
setSelected(nb_active_filter-1);
214
#define MAKE_BUTTON(button,call) \
215
void filtermainWindow::button( bool b) \
218
getFirstVideoFilter (); \
219
buildActiveFilterList (); \
221
MAKE_BUTTON(DVD,setDVD)
222
MAKE_BUTTON(VCD,setVCD)
223
MAKE_BUTTON(SVCD,setSVCD)
224
MAKE_BUTTON(halfD1,setHalfD1)
226
\fn configure( bool b)
227
\brief Configure the selected active filter
229
void filtermainWindow::configure( bool b)
231
/* Get selection if any */
232
/* Now that we have the tab, get the selection */
233
QListWidgetItem *item=activeList->currentItem();
236
printf("No selection\n");
240
int itag=item->type();
241
ADM_assert(itag>ACTIVE_FILTER_BASE);
242
itag-=ACTIVE_FILTER_BASE;
243
/* Filter 0 is the decoder ...*/
244
printf("Rank : %d\n",itag);
248
if(!videofilters[itag].filter->configure (videofilters[itag - 1].filter)) return;
249
/* Recreate chain if needed , config has changed */
251
videofilters[itag].filter->getCoupledConf (&couple);
252
videofilters[itag].conf = couple;
253
getFirstVideoFilter ();
254
buildActiveFilterList ();
258
\brief Move selected filter one place up
260
void filtermainWindow::up( bool b)
262
QListWidgetItem *item=activeList->currentItem();
265
printf("No selection\n");
269
int itag=item->type();
270
ADM_assert(itag>ACTIVE_FILTER_BASE);
271
itag-=ACTIVE_FILTER_BASE;
272
/* Filter 0 is the decoder ...*/
273
printf("Rank : %d\n",itag);
276
if (itag < 2) return;
277
// swap action parameter & action parameter -1
279
memcpy (&tmp, &videofilters[itag - 1], sizeof (FILTER));
280
memcpy (&videofilters[itag - 1],
281
&videofilters[itag], sizeof (FILTER));
282
memcpy (&videofilters[itag], &tmp, sizeof (FILTER));
283
getFirstVideoFilter ();
284
buildActiveFilterList ();
289
\brief Move selected filter one place down
291
void filtermainWindow::down( bool b)
293
QListWidgetItem *item=activeList->currentItem();
296
printf("No selection\n");
300
int itag=item->type();
301
ADM_assert(itag>ACTIVE_FILTER_BASE);
302
itag-=ACTIVE_FILTER_BASE;
303
/* Filter 0 is the decoder ...*/
304
printf("Rank : %d\n",itag);
307
if (((int) itag < (int) (nb_active_filter - 1)) && (itag))
309
// swap action parameter & action parameter -1
311
memcpy (&tmp, &videofilters[itag + 1], sizeof (FILTER));
312
memcpy (&videofilters[itag + 1],
313
&videofilters[itag], sizeof (FILTER));
314
memcpy (&videofilters[itag], &tmp, sizeof (FILTER));
315
getFirstVideoFilter ();
316
buildActiveFilterList ();
321
\fn filtermainWindow::filterFamilyClick( QListWidgetItem *item)
322
\brief Select family among color etc...
325
void filtermainWindow::filterFamilyClick(QListWidgetItem *item)
327
int family= ui.listFilterCategory->currentRow();
329
displayFamily(family);
331
void filtermainWindow::filterFamilyClick(int m)
336
void filtermainWindow::displayFamily(uint32_t family)
338
printf("Family :%u\n",family);
340
availableList->clear();
342
colorgrey.setRgb(myBg,myBg,myBg);
343
QBrush brush(colorgrey);
346
for (uint32_t i = 0; i < filterSize[family]; i++)
348
int r=startFilter[family]+i;
350
if (allfilters[r].viewable==1)
352
QString str; //="<b>";
353
str+=allfilters[r].name;
355
QListWidgetItem *item;
356
if(family==NB_TREE-1)
357
item=new QListWidgetItem(str,availableList,EXTERNAL_FILTER_BASE+i);
359
item=new QListWidgetItem(str,availableList,ALL_FILTER_BASE+r);
360
item->setToolTip(allfilters[r].description);
361
if(i&1) item->setBackground(brush);
362
availableList->addItem(item);
370
\fn filtermainWindow::activeDoubleClick( QListWidgetItem *item)
371
\brief One of the active window has been double clicked, call configure
373
void filtermainWindow::activeDoubleClick( QListWidgetItem *item)
379
\fn filtermainWindow::activeDoubleClick( QListWidgetItem *item)
380
\brief One of the active window has been double clicked, call configure
382
void filtermainWindow::allDoubleClick( QListWidgetItem *item)
388
\fn filtermainWindow::partial( bool b)
389
\brief Partialize one filter
391
void filtermainWindow::partial( bool b)
394
QListWidgetItem *item=activeList->currentItem();
397
printf("No selection\n");
401
int itag=item->type();
402
ADM_assert(itag>ACTIVE_FILTER_BASE);
403
itag-=ACTIVE_FILTER_BASE;
404
/* Filter 0 is the decoder ...*/
405
printf("Rank : %d\n",itag);
408
AVDMGenericVideoStream *replace;
410
conf = videofilters[itag].conf;
411
if (videofilters[itag].tag == VF_PARTIAL) // cannot recurse
413
GUI_Error_HIG (QT_TR_NOOP("The filter is already partial"), NULL);
416
replace =new ADMVideoPartial (videofilters[itag - 1].
418
videofilters[itag].tag,
420
if(replace->configure (videofilters[itag - 1].filter))
422
delete videofilters[itag].filter;
423
if (conf) delete conf;
424
videofilters[itag].filter = replace;
425
replace->getCoupledConf (&conf);
426
videofilters[itag].conf = conf;
427
videofilters[itag].tag = VF_PARTIAL;
428
getFirstVideoFilter ();
429
buildActiveFilterList ();
437
void filtermainWindow::setupFilters(void)
444
for (uint32_t i = 0; i < allfilters.size(); i++)
446
if (allfilters[i].viewable==1)
453
if(current_tree) filterSize[current_tree-1]=current_raw;
454
if(current_tree>=NB_TREE) break;
455
startFilter[current_tree]=i+1;
460
ADM_assert(NB_TREE==8);
461
startFilter[NB_TREE-1]=2000;
462
filterSize[NB_TREE-1]=0;
463
for(int i=0;i<NB_TREE;i++)
465
printf("%d Start at %d size :%d\n",i,startFilter[i],filterSize[i]);
470
\fn buildActiveFilterList(void)
471
\brief Build and display all active filters (may be empty)
473
void filtermainWindow::buildActiveFilterList(void)
479
QColor colorGrey,colorWhite;
480
colorGrey.setRgb(myBg,myBg,myBg);
481
colorWhite.setRgb(myFg,myFg,myFg);
482
QBrush brush(colorGrey);
483
QBrush brushW(colorWhite);
485
for (uint32_t i = 1; i < nb_active_filter; i++)
488
fil=videofilters[i].tag;
490
str =filterGetNameFromTag(fil);
491
str+= videofilters[i].filter->printConf ();
492
QListWidgetItem *item=new QListWidgetItem(str,activeList,ACTIVE_FILTER_BASE+i);
493
if(i&1) item->setBackground(brush);
494
else item->setBackground(brushW);
495
activeList->addItem(item);
502
filtermainWindow::filtermainWindow() : QDialog()
504
memset( startFilter,0,sizeof(int)*NB_TREE);
505
memset( filterSize,0,sizeof(int)*NB_TREE);
510
availableList=ui.listWidgetAvailable;
511
activeList=ui.listWidgetActive;
512
connect(ui.listFilterCategory,SIGNAL(itemDoubleClicked(QListWidgetItem *)),
513
this,SLOT(filterFamilyClick(QListWidgetItem *)));
514
connect(ui.listFilterCategory,SIGNAL(itemClicked(QListWidgetItem *)),
515
this,SLOT(filterFamilyClick(QListWidgetItem *)));
517
connect(activeList,SIGNAL(itemDoubleClicked(QListWidgetItem *)),this,SLOT(activeDoubleClick(QListWidgetItem *)));
518
connect(availableList,SIGNAL(itemDoubleClicked(QListWidgetItem *)),this,SLOT(allDoubleClick(QListWidgetItem *)));
520
connect((ui.toolButtonConfigure),SIGNAL(clicked(bool)),this,SLOT(configure(bool)));
521
connect((ui.toolButtonAdd),SIGNAL(clicked(bool)),this,SLOT(add(bool)));
522
connect((ui.pushButtonRemove),SIGNAL(clicked(bool)),this,SLOT(remove(bool)));
523
connect((ui.toolButtonUp),SIGNAL(clicked(bool)),this,SLOT(up(bool)));
524
connect((ui.toolButtonDown),SIGNAL(clicked(bool)),this,SLOT(down(bool)));
525
connect((ui.toolButtonPartial),SIGNAL(clicked(bool)),this,SLOT(partial(bool)));
526
connect(ui.buttonClose, SIGNAL(clicked(bool)), this, SLOT(accept()));
527
connect(ui.pushButtonDVD, SIGNAL(clicked(bool)), this, SLOT(DVD(bool)));
528
connect(ui.pushButtonVCD, SIGNAL(clicked(bool)), this, SLOT(VCD(bool)));
529
connect(ui.pushButtonSVCD, SIGNAL(clicked(bool)), this, SLOT(SVCD(bool)));
530
connect(ui.pushButtonHalfDVD, SIGNAL(clicked(bool)), this, SLOT(halfD1(bool)));
533
buildActiveFilterList();
535
/*******************************************************/
537
int GUI_handleVFilter(void);
538
static void updateFilterList (filtermainWindow *dialog);
541
\fn GUI_handleVFilter(void)
542
\brief Show the main filter window allowing user to add/remove/configure video filters
546
int GUI_handleVFilter(void)
548
filtermainWindow dialog;
549
if(QDialog::Accepted==dialog.exec())
556
\brief Partial callback to configure the swallowed filter
559
static void partialCb(void *cookie);
560
void partialCb(void *cookie)
562
void **params=(void **)cookie;
563
AVDMGenericVideoStream *son=(AVDMGenericVideoStream *)params[0];
564
AVDMGenericVideoStream *previous=(AVDMGenericVideoStream *)params[1];
565
son->configure(previous);
569
\brief Partial dialog
573
uint8_t DIA_getPartial(PARTIAL_CONFIG *param,AVDMGenericVideoStream *son,AVDMGenericVideoStream *previous)
575
#define PX(x) &(param->x)
576
void *params[2]={son,previous};
577
uint32_t fmax=previous->getInfo()->nb_frames;
580
diaElemUInteger start(PX(_start),QT_TR_NOOP("Partial Start Frame:"),0,fmax);
581
diaElemUInteger end(PX(_end),QT_TR_NOOP("Partial End Frame:"),0,fmax);
582
diaElemButton button(QT_TR_NOOP("Configure child"), partialCb,params);
584
diaElem *tabs[]={&start,&end,&button};
585
return diaFactoryRun(QT_TR_NOOP("Partial Video Filter"),3,tabs);