Skip to content

Commit 74cb078

Browse files
committed
2003-10-01
0 parents  commit 74cb078

8 files changed

+1711
-0
lines changed

avisynth.h

+707
Large diffs are not rendered by default.

delogo.cpp

+542
Large diffs are not rendered by default.

delogo.h

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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

delogo.rc

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
//Microsoft Developer Studio generated resource script.
2+
//
3+
#include "resource.h"
4+
#define VS_VERSION_INFO 1
5+
#define APSTUDIO_READONLY_SYMBOLS
6+
/////////////////////////////////////////////////////////////////////////////
7+
//
8+
// Generated from the TEXTINCLUDE 2 resource.
9+
//
10+
#include "winres.h"
11+
12+
/////////////////////////////////////////////////////////////////////////////
13+
#undef APSTUDIO_READONLY_SYMBOLS
14+
15+
/////////////////////////////////////////////////////////////////////////////
16+
// ���{�� resources
17+
18+
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
19+
#ifdef _WIN32
20+
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
21+
#pragma code_page(932)
22+
#endif //_WIN32
23+
24+
#ifndef _MAC
25+
/////////////////////////////////////////////////////////////////////////////
26+
//
27+
// Version
28+
//
29+
30+
VS_VERSION_INFO VERSIONINFO
31+
FILEVERSION 0,0,1,0
32+
PRODUCTVERSION 0,0,1,0
33+
FILEFLAGSMASK 0x3fL
34+
#ifdef _DEBUG
35+
FILEFLAGS 0x1L
36+
#else
37+
FILEFLAGS 0x0L
38+
#endif
39+
FILEOS 0x4L
40+
FILETYPE 0x2L
41+
FILESUBTYPE 0x0L
42+
BEGIN
43+
BLOCK "StringFileInfo"
44+
BEGIN
45+
BLOCK "041104b0"
46+
BEGIN
47+
VALUE "Comments", "YUY2��p"
48+
VALUE "FileDescription", "���ߐ����S �t�B���^ Plugin for AviSynth 2.5\0"
49+
VALUE "FileVersion", "0.0.1.0\0"
50+
VALUE "InternalName", "deLogo\0"
51+
VALUE "LegalCopyright", "(C) MakKi\0"
52+
VALUE "OriginalFilename", "delogo.dll\0"
53+
VALUE "ProductName", "���ߐ����S �t�B���^\0"
54+
VALUE "ProductVersion", "0.01\0"
55+
END
56+
END
57+
BLOCK "VarFileInfo"
58+
BEGIN
59+
VALUE "Translation", 0x411, 1200
60+
END
61+
END
62+
63+
#endif // !_MAC
64+
65+
66+
#ifdef APSTUDIO_INVOKED
67+
/////////////////////////////////////////////////////////////////////////////
68+
//
69+
// TEXTINCLUDE
70+
//
71+
72+
1 TEXTINCLUDE DISCARDABLE
73+
BEGIN
74+
75+
END
76+
77+
2 TEXTINCLUDE DISCARDABLE
78+
BEGIN
79+
"#include ""winres.h""\r\n"
80+
"\0"
81+
END
82+
83+
3 TEXTINCLUDE DISCARDABLE
84+
BEGIN
85+
"\r\n"
86+
"\0"
87+
END
88+
89+
#endif // APSTUDIO_INVOKED
90+
91+
#endif // ���{�� resources
92+
/////////////////////////////////////////////////////////////////////////////
93+
94+
95+
96+
#ifndef APSTUDIO_INVOKED
97+
/////////////////////////////////////////////////////////////////////////////
98+
//
99+
// Generated from the TEXTINCLUDE 3 resource.
100+
//
101+
102+
103+
/////////////////////////////////////////////////////////////////////////////
104+
#endif // not APSTUDIO_INVOKED
105+

dll.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
#include "delogo.h"
23+
24+
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
25+
{
26+
Init_EraseLOGO(env);
27+
Init_AddLOGO(env);
28+
return "DeLOGO plugin";
29+
}
30+

logo.h

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*====================================================================
2+
* ロゴパターン logo.h
3+
*
4+
*
5+
*
6+
* [ロゴデータファイル構造]
7+
*
8+
* "logo file x.xx\n" // ファイルヘッダ文字列:バージョン情報とか(31byte)
9+
* +----
10+
* | ファイルに含まれるロゴデータの数(1byte)
11+
* +----
12+
* | LOGO_HEADER // データヘッダ
13+
* +----
14+
* |
15+
* : LOGO_PIXEL[h*w] // ピクセル情報:サイズはLOGO_HEADERのw,hから算出
16+
* :
17+
* +----
18+
* | LOGO_HEADER
19+
* +----
20+
* |
21+
* : LOGO_PIXEL[h*w]
22+
* :
23+
*
24+
*===================================================================*/
25+
#ifndef ___LOGO_H
26+
#define ___LOGO_H
27+
28+
/* ロゴファイルヘッダ
29+
* 31BYTEの文字列
30+
* データ数 1BYTE
31+
*/
32+
#define LOGO_FILE_HEADER "<logo data file ver0.1>\0\0\0\0\0\0\0\0\0\0\0"
33+
#define LOGO_FILE_HEADER_STR_SIZE 31
34+
35+
36+
/* ロゴデータ最大サイズ:
37+
* ロゴデータをプロファイルに保存しないようにしたため、
38+
* サイズ制限は実質なくなった
39+
*/
40+
#define LOGO_MAXPIXEL (21840)
41+
#define LOGO_MAXSIZE (0x40000)
42+
43+
/* 不透明度最大値 */
44+
#define LOGO_MAX_DP 1000
45+
46+
/* ロゴ名最大文字数(終端\0含む) */
47+
#define LOGO_MAX_NAME 32
48+
49+
/*--------------------------------------------------------------------
50+
* LOGO_HEADER 構造体
51+
* ロゴの基本的な情報を記録
52+
*-------------------------------------------------------------------*/
53+
typedef struct {
54+
char name[LOGO_MAX_NAME]; /* 名称 */
55+
short x, y; /* 基本位置 */
56+
short h, w; /* ロゴ高さ・幅 */
57+
int reserve[2]; /* 拡張用に予約 */
58+
} LOGO_HEADER;
59+
60+
/*--------------------------------------------------------------------
61+
* LOGO_PIXEL 構造体
62+
* ロゴの各ピクセルごとの情報を記録
63+
*-------------------------------------------------------------------*/
64+
typedef struct {
65+
short dp_y; /* 不透明度(輝度) */
66+
short y; /* 輝度 0~4096 */
67+
short dp_cb; /* 不透明度(青) */
68+
short cb; /* 色差(青) -2048~2048 */
69+
short dp_cr; /* 不透明度(赤) */
70+
short cr; /* 色差(赤) -2048~2048 */
71+
} LOGO_PIXEL;
72+
73+
74+
/*--------------------------------------------------------------------
75+
* ロゴデータ全体のサイズ
76+
*-------------------------------------------------------------------*/
77+
#define LOGO_DATASIZE(ptr) \
78+
(sizeof(LOGO_HEADER)+((LOGO_HEADER *)ptr)->h*((LOGO_HEADER *)ptr)->w*sizeof(LOGO_PIXEL))
79+
80+
/*--------------------------------------------------------------------
81+
* ロゴデータのサイズ(ヘッダ無し)
82+
*-------------------------------------------------------------------*/
83+
#define LOGO_PIXELSIZE(ptr) \
84+
(((LOGO_HEADER *)ptr)->h*((LOGO_HEADER *)ptr)->w*sizeof(LOGO_PIXEL))
85+
86+
87+
#endif

0 commit comments

Comments
 (0)