-
Notifications
You must be signed in to change notification settings - Fork 114
/
unstackField.cpp
133 lines (118 loc) · 4.55 KB
/
unstackField.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/** *************************************************************************
\fn unstackFieldFilter.cpp
\brief
copyright : (C) 2009 by mean
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#include "ADM_default.h"
#include "ADM_coreVideoFilter.h"
/**
\class unstackFieldFilter
*/
class unstackFieldFilter : public ADM_coreVideoFilter
{
protected:
ADMImage *current;
public:
unstackFieldFilter(ADM_coreVideoFilter *previous,CONFcouple *conf);
~unstackFieldFilter();
virtual const char *getConfiguration(void); /// Return current configuration as a human readable string
virtual bool getNextFrame(uint32_t *fn,ADMImage *image); /// Return the next image
// virtual FilterInfo *getInfo(void); /// Return picture parameters after this filter
virtual bool getCoupledConf(CONFcouple **couples) ; /// Return the current filter configuration
virtual void setCoupledConf(CONFcouple *couples);
virtual bool configure(void) {return true;} /// Start graphical user interface
};
// Add the hook to make it valid plugin
DECLARE_VIDEO_FILTER( unstackFieldFilter, // Class
1,0,0, // Version
ADM_UI_ALL, // UI
VF_INTERLACING, // Category
"unstackField", // internal name (must be uniq!)
QT_TRANSLATE_NOOP("unstackfield","Unstack Fields"), // Display name
QT_TRANSLATE_NOOP("unstackfield","Weave top and bottom halves.") // Description
);
// Now implements the interesting parts
/**
\fn unstackFieldFilter
\brief constructor
*/
unstackFieldFilter::unstackFieldFilter( ADM_coreVideoFilter *in,CONFcouple *setup) : ADM_coreVideoFilter(in,setup)
{
UNUSED_ARG(setup);
// By default the info field contains the output of previous filter
// Tweak it here if you change fps, duration, width,...
current=new ADMImageDefault(info.width,info.height);
}
/**
\fn unstackFieldFilter
\brief destructor
*/
unstackFieldFilter::~unstackFieldFilter()
{
delete current;
current=NULL;
}
/**
\fn getFrame
\brief Get a processed frame
*/
bool unstackFieldFilter::getNextFrame(uint32_t *fn,ADMImage *image)
{
// since we do nothing, just get the output of previous filter
if(false==previousFilter->getNextFrame(fn,current))
{
ADM_warning("unstackField : Cannot get frame\n");
return false;
}
// do in place flip
image->copyInfo(current);
for(int i=PLANAR_Y;i<PLANAR_LAST;i++)
{
ADM_PLANE plane=(ADM_PLANE)i;
uint32_t srcPitch=current->GetPitch(plane);
uint32_t dstPitch=image->GetPitch(plane);
uint8_t *src=current->GetReadPtr(plane);
uint8_t *dst=image->GetWritePtr(plane);
uint32_t w=info.width;
uint32_t h=info.height;
if(plane)
{
w>>=1;
h>>=1;
}
// Even
BitBlit(dst, dstPitch*2,src,srcPitch,w,h/2);
BitBlit(dst+dstPitch, dstPitch*2,src+(srcPitch*h)/2,srcPitch,w,h/2);
}
return true;
}
/**
\fn getCoupledConf
\brief Return our current configuration as couple name=value
*/
bool unstackFieldFilter::getCoupledConf(CONFcouple **couples)
{
*couples=new CONFcouple(0); // Even if we dont have configuration we must allocate one
return true;
}
void unstackFieldFilter::setCoupledConf(CONFcouple *couples)
{
}
/**
\fn getConfiguration
\brief Return current setting as a string
*/
const char *unstackFieldFilter::getConfiguration(void)
{
return "Unstack Field.";
}
// Normally not needed :virtual FilterInfo *getInfo(void)
//EOF