1
+ //
2
+ // Copylight (C) 2003 MakKi
3
+ //
4
+ // AvisynthがGPLなため、このソフトもGPLになるらしいです。
5
+ //
6
+ // This program is free software; you can redistribute it and/or modify
7
+ // it under the terms of the GNU General Public License as published by
8
+ // the Free Software Foundation; either version 2 of the License, or
9
+ // (at your option) any later version.
10
+ //
11
+ // This program is distributed in the hope that it will be useful,
12
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ // GNU General Public License for more details.
15
+ //
16
+ // You should have received a copy of the GNU General Public License
17
+ // along with this program; if not, write to the Free Software
18
+ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
19
+ // http://www.gnu.org/copyleft/gpl.html .
20
+ //
21
+ //
22
+ #ifndef ___DELOGO_H
23
+ #define ___DELOGO_H
24
+
25
+ #include < windows.h>
26
+ #include " avisynth.h"
27
+ #include " logo.h"
28
+
29
+ #define LOGO_FADE_MAX 256
30
+ #define LOGO_DEFAULT_DEPTH 128
31
+
32
+ /* *******************************************************************
33
+ * Init関数
34
+ * Init_ErazeLOGO
35
+ * Init_AddLOGO
36
+ *********************************************************************/
37
+ extern AVSValue __cdecl Create_EraseLOGO (AVSValue args, void *user_data, IScriptEnvironment *env);
38
+ extern AVSValue __cdecl Create_AddLOGO (AVSValue args, void *user_data, IScriptEnvironment *env);
39
+
40
+ inline void Init_EraseLOGO (IScriptEnvironment* env)
41
+ {
42
+ env->AddFunction (" EraseLOGO" ," c[logofile]s[logoname]s[pos_x]i[pos_y]i[depth]i[start]i[fadein]i[fadeout]i[end]i" ,Create_EraseLOGO, 0 );
43
+ }
44
+ inline void Init_AddLOGO (IScriptEnvironment* env)
45
+ {
46
+ env->AddFunction (" AddLOGO" ," c[logofile]s[logoname]s[pos_x]i[pos_y]i[depth]i[start]i[fadein]i[fadeout]i[end]i" ,Create_AddLOGO, 0 );
47
+ }
48
+ enum {
49
+ LOGOFILE =1 , LOGONAME,
50
+ POS_X, POS_Y, DEPTH,
51
+ START, F_IN , F_OUT, END
52
+ };
53
+
54
+ /* ===================================================================
55
+ * class deLOGO_Base
56
+ *==================================================================*/
57
+
58
+ class deLOGO_Base : public GenericVideoFilter {
59
+
60
+ protected:
61
+ BYTE logodata[LOGO_MAXSIZE];
62
+ int _start, _fadein, _fadeout, _end;
63
+
64
+ LOGO_HEADER* lgh;
65
+
66
+ deLOGO_Base (const PClip& clip,const char * logofile,const char * logoname,int pos_x,int pos_y,
67
+ int depth,int start,int fadein,int fadeout,int end, IScriptEnvironment *env,const char * filtername) : GenericVideoFilter(clip)
68
+ {
69
+ const VideoInfo& vi = clip->GetVideoInfo ();
70
+
71
+ _start = start;
72
+ _fadein = fadein;
73
+ _fadeout = fadeout;
74
+ _end = end;
75
+
76
+ child->SetCacheHints (CACHE_NOTHING, 0 );
77
+
78
+ lgh = (LOGO_HEADER*)logodata;
79
+ try {
80
+ ReadLogoData (logofile,logoname);
81
+ if (pos_x!=0 || pos_y!=0 || depth!=LOGO_DEFAULT_DEPTH)
82
+ AdjustLogo (pos_x,pos_y,depth);
83
+ }
84
+ catch (char * err){
85
+ env->ThrowError (" %s: %s" ,filtername,err);
86
+ }
87
+ }
88
+ void ReadLogoData (const char * logofile,const char * logoname);
89
+ void AdjustLogo (int x,int y,int depth); // AviUtlオリジナルの色空間
90
+ void Logo_YUY2 ();
91
+ void Logo_YV420 (){};
92
+
93
+ int CalcFade (int n)// ,PVideoFrame &src)
94
+ {
95
+ if (n<_start || (_end<n && _end>=_start) ) // 範囲外
96
+ return 0 ;
97
+
98
+ int fade;
99
+
100
+ if (n < _start+_fadein) // フェードイン
101
+ fade = ((n -_start)*2 +1 )*LOGO_FADE_MAX / (_fadein *2 );
102
+ else if (n > _end-_fadeout && _end>=0 ) // フェードアウト
103
+ fade = ((_end - n)*2 +1 )*LOGO_FADE_MAX / (_fadeout *2 );
104
+ else // 通常
105
+ fade = LOGO_FADE_MAX;
106
+
107
+ return fade;
108
+ }
109
+
110
+ int Abs (int x)
111
+ { return ((x<0 )? -x : x); }
112
+ int Clamp (int n, int l, int h)
113
+ { return (n < l) ? l : (n > h) ? h : n; }
114
+
115
+ // ITU-R TB.601に沿ってAviUtlのYCから変換
116
+ int TB601_Y (int y)
117
+ { return ((y +(16 <<4 )) * 220 +128 )/ 256 ; }
118
+ int TB601_C (int c)
119
+ { return (c * 225 +128 )/ 256 ; }
120
+ public:
121
+
122
+ };
123
+
124
+
125
+ /* ===================================================================
126
+ * class ErazeLOGO
127
+ *==================================================================*/
128
+
129
+ class EraseLOGO_YUY2 : public deLOGO_Base {
130
+
131
+ public:
132
+ EraseLOGO_YUY2 (const PClip& clip,const char * logofile,const char * logoname,
133
+ int pos_x,int pos_y,int depth,int start,int fadein,int fadeout,int end,IScriptEnvironment *env)
134
+ : deLOGO_Base(clip,logofile,logoname,pos_x,pos_y,depth,start,fadein,fadeout,end,env,GetName())
135
+ { Logo_YUY2 (); }
136
+
137
+ static const char * GetName (){ return " EraseLOGO" ; }
138
+
139
+ PVideoFrame __stdcall GetFrame (int n, IScriptEnvironment *env);
140
+ };
141
+
142
+ /* ===================================================================
143
+ * class AddLOGO_YUY2
144
+ *==================================================================*/
145
+
146
+ class AddLOGO_YUY2 : public deLOGO_Base {
147
+
148
+ public:
149
+ AddLOGO_YUY2 (const PClip& clip,const char * logofile,const char * logoname,
150
+ int pos_x,int pos_y,int depth,int start,int fadein,int fadeout,int end,IScriptEnvironment *env)
151
+ : deLOGO_Base(clip,logofile,logoname,pos_x,pos_y,depth,start,fadein,fadeout,end,env,GetName())
152
+ { Logo_YUY2 (); }
153
+
154
+ static const char * GetName (){ return " AddLOGO" ; }
155
+
156
+ PVideoFrame __stdcall GetFrame (int n, IScriptEnvironment *env);
157
+ };
158
+
159
+
160
+ #endif
0 commit comments