2
/***************************************************************************
3
ADM_vidASharp - description
7
***************************************************************************/
10
Copyright (C) 2003 Donald A. Graft
11
Copyright (C) 2002 Marc Fauconneau
12
This program is free software; you can redistribute it and/or modify
13
it under the terms of the GNU General Public License as published by
14
the Free Software Foundation.
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30
#include <ADM_assert.h>
37
#include "ADM_toolkit/toolkit.hxx"
38
#include "ADM_editor/ADM_edit.hxx"
39
#include "ADM_video/ADM_genvideo.hxx"
40
#include"ADM_video/ADM_vidField.h"
41
#include"ADM_video/ADM_cache.h"
43
#include "ADM_toolkit/ADM_debugID.h"
44
#define MODULE_NAME MODULE_FILTER
45
#include "ADM_toolkit/ADM_debug.h"
47
#include "ADM_toolkit/ADM_cpuCap.h"
48
#include "ADM_filter/video_filters.h"
50
#include "ADM_vidASharp_param.h"
51
class ASharp : public AVDMGenericVideoStream
61
ASharp(AVDMGenericVideoStream *in,CONFcouple *couples) ;
66
char *printConf( void );
67
uint8_t configure(AVDMGenericVideoStream *in);
68
uint8_t getCoupledConf( CONFcouple **couples);
69
uint8_t getFrameNumberNoAlloc(uint32_t frame, uint32_t *len, ADMImage *data,uint32_t *flags);
72
BUILD_CREATE(asharp_create,ASharp);
73
static FILTER_PARAM asharp_param={4,{"t", "b","d", "bf"}};
76
SCRIPT_CREATE(asharp_script,ASharp,asharp_param);
77
//_______________________________________________
79
ASharp::ASharp(AVDMGenericVideoStream *in,CONFcouple *couples)
83
memcpy(&_info,_in->getInfo(),sizeof(_info));
89
_param=new ASHARP_PARAM;
106
vidCache=new VideoCache(5,in);
108
//________________________________________________________
109
void ASharp::update( void)
111
// parameters floating point to fixed point convertion
112
T = (int)(_param->t*(4<<7));
113
D = (int)(_param->d*(4<<7));
114
B = (int)(256-_param->b*64);
115
B2= (int)(256-_param->b*48);
117
// clipping (recommended for SIMD code)
119
if (T<-(4<<7)) T = -(4<<7); // yes, negatives values are accepted
124
if (T>(32*(4<<7))) T = (32*(4<<7));
125
if (D>(16*(4<<7))) D = (16*(4<<7));
127
if (B2>256) B2 = 256;
130
//________________________________________________________
131
uint8_t ASharp::getCoupledConf( CONFcouple **couples)
134
*couples=new CONFcouple(4);
135
#define CSET(x) (*couples)->setCouple((char *)#x,(_param->x))
142
//________________________________________________________
143
ASharp::~ASharp(void)
146
if(vidCache) delete vidCache;
153
extern uint8_t DIA_getASharp(ASHARP_PARAM *param, AVDMGenericVideoStream *in);
154
//________________________________________________________
155
uint8_t ASharp::configure(AVDMGenericVideoStream *in)
159
if( DIA_getASharp(_param, _in))
167
//________________________________________________________
168
char *ASharp::printConf( void )
173
sprintf((char *)buf," ASharp (MarcFD)");
177
//________________________________________________________
178
uint8_t ASharp::getFrameNumberNoAlloc(uint32_t frame, uint32_t *len,
179
ADMImage *data,uint32_t *flags)
185
if(frame>=_info.nb_frames) return 0;
186
src=vidCache->getImage(frame);
188
asharp_run_c( dst->GetWritePtr(PLANAR_Y),
189
dst->GetPitch(PLANAR_Y),
198
vidCache->unlockAll();
206
void asharp_run_c( uc* planeptr, int pitch,
207
int height, int width,
208
int T,int D, int B, int B2, bool bf )
210
uc* lineptr = new uc[width];
213
uc* cfp = planeptr+pitch;
215
memcpy(lp,planeptr,width);
216
for (y=1;y<height-1;y++) {
218
for (x=0;x<width-1;x++) {
240
if (abs(A-cfp[x])>dev) dev = abs(A-cfp[x]);
245
if (x%8>0) CHECK(lp[x-1])
247
if (x%8<7) CHECK(lp[x+1])
249
if (x%8>0) CHECK(last)
250
if (x%8<7) CHECK(cfp[x +1])
252
if (x%8>0) CHECK(cfp[x+p-1])
254
if (x%8<7) CHECK(cfp[x+p+1])
272
if (x%8==6) D2=(D2*B2)>>8;
273
if (x%8==7) D2=(D2*B)>>8;
274
if (x%8==0) D2=(D2*B)>>8;
275
if (x%8==1) D2=(D2*B2)>>8;
276
if (y%8==6) D2=(D2*B2)>>8;
277
if (y%8==7) D2=(D2*B)>>8;
278
if (y%8==0) D2=(D2*B)>>8;
279
if (y%8==1) D2=(D2*B2)>>8;
282
if (D>0) T2 = ((((dev<<7)*D2)>>16)+Da)<<4;
287
tmp = (((diff<<7)*T2)>>16)+cfp[x];
289
if (tmp < 0) tmp = 0;
290
if (tmp > 255) tmp = 255;
300
//**********************************