Mndiff-dev
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
July 2007
- 1 participants
- 45 discussions
Author: michael
Date: Wed Jul 4 10:05:19 2007
New Revision: 56
Log:
next version from unknown date
Added:
trunk/2010/2010.cpp
- copied, changed from r55, /trunk/2010/2010.cc
trunk/2010/2_71x6.cpp
- copied, changed from r55, /trunk/2010/2_71x6.cc
trunk/2010/2_crypt.cpp
- copied, changed from r55, /trunk/2010/2_crypt.cc
trunk/2010/2_file.cpp
- copied, changed from r52, /trunk/2010/2_file.cc
trunk/2010/2_gfunc.cpp
- copied, changed from r55, /trunk/2010/2_gfunc.cc
trunk/2010/2_grafix.cpp
- copied, changed from r55, /trunk/2010/2_grafix.cc
trunk/2010/2_hw.cpp
- copied, changed from r55, /trunk/2010/2_hw.cc
trunk/2010/2_hw_mem.cpp
- copied unchanged from r52, /trunk/2010/2_hw_mem.cc
trunk/2010/2_mfunc.cpp
- copied unchanged from r52, /trunk/2010/2_mfunc.cc
trunk/2010/2_nag.cpp
- copied, changed from r54, /trunk/2010/2_nag.cc
trunk/2010/2_txt.cpp
- copied, changed from r55, /trunk/2010/2_txt.cc
trunk/2010/2_vc.cpp
- copied, changed from r55, /trunk/2010/2_vc.cc
Removed:
trunk/2010/2010.cc
trunk/2010/2_71x6.cc
trunk/2010/2_crypt.cc
trunk/2010/2_file.cc
trunk/2010/2_gfunc.cc
trunk/2010/2_grafix.cc
trunk/2010/2_hw.cc
trunk/2010/2_hw_mem.cc
trunk/2010/2_menu.cc
trunk/2010/2_mfunc.cc
trunk/2010/2_nag.cc
trunk/2010/2_txt.cc
trunk/2010/2_vc.cc
Modified:
trunk/2010/2010.h
trunk/2010/2_71x6.h
trunk/2010/2_all.h
trunk/2010/2_gfunc.h
trunk/2010/2_hw_asm.s
trunk/2010/2_txt.h
Copied: trunk/2010/2010.cpp (from r55, /trunk/2010/2010.cc)
==============================================================================
--- /trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cpp Wed Jul 4 10:05:19 2007
@@ -1,4 +1,4 @@
-//2010 0.1 Copyright (c) 1998 Michael Niedermayer
+//2010 0.1 Copyright (c) 1998 Michael Niedermayer
#include <stdlib.h>
#include <pc.h>
@@ -31,7 +31,7 @@
extern volatile int page_flip;
extern int vgax, vgay, xresvb, xresc, vb, mc;
extern int active_meteor;
- extern int yuvmode;
+ extern int yuvMode, grabYuvMode;
extern bool mmx;
// extern short *linesPerKeyTab;
// extern int *best1;
@@ -46,7 +46,8 @@
extern bool helpState;
extern bool allowDrop;
extern int reqPage, reqSubPage, reqChanNum;
- extern char *reqChanStr;
+ extern char reqChanStr[];
+ extern char findTxt[];
int maxBuf=2;
int some=0;
@@ -176,7 +177,7 @@ int main(int argc, char **argv){
NoFlip=1;
}
else if(stricmp(argv[i],"-NORGB")==0){
- yuvmode=2;
+ yuvMode=2;
}
else if(stricmp(argv[i],"-maxBuf")==0){
i++;
@@ -292,9 +293,9 @@ int main(int argc, char **argv){
vgax=mib->Xres;
vgay=mib->Yres;
-/* if(yuvmode!=0) mc=1;
+/* if(yuvMode!=0) mc=1;
else mc=2;
- if(yuvmode==2) mc2=1;
+ if(yuvMode==2) mc2=1;
else mc2=2;
*/
mc=mc2=1;
@@ -342,24 +343,52 @@ int main(int argc, char **argv){
decrypt();
showStuff();
- if(grabf==1) grab(), grabf=0;
+ if(grabf!=0 && TVStd!=TXTPAL) grab(), grabf=0;
for(int k=0; k<delay*1000000; k++);
copy_vidbuffer();
-
+ static char tab[256];
+ static int tabNdx;
+ static void *tabTo;
+ static TABTYPE tabType;
+ static bool tabActive=false;
+ static int tabLen;
while(kbhit()){
int key= getkey();
+ if(tabActive){
+ tab[tabNdx]=key;
+ tabNdx++;
+ if(key==K_Escape){
+ tabActive=false;
+ }
+ else if(key==K_Return || tabNdx>=tabLen){
+ tab[tabNdx]=0;
+ switch(tabType){
+ case TAB_DEZ : sscanf(tab, "%d", (int*)tabTo);
+ break;
+ case TAB_HEX : sscanf(tab, "%X", (int*)tabTo);
+ break;
+ case TAB_STR : sscanf(tab, "%s", (char*)tabTo);
+ break;
+ }
+
+ tabActive=false;
+ }
+ continue;
+ }
+
switch(menuLevel){
case mLNorm : switch(key){
case 'p' :
case 'P' : getkey();
break;
- case 'g' :
- case 'G' : key=0, grabf=1;
+ case 'g' : key=0, grabf=1;
+ break;
+ case 'G' : key=0, grabf=2;
break;
case 'q' :
case 'Q' : quit=true;
@@ -441,48 +470,74 @@ int main(int argc, char **argv){
break;
case '4' : some--; if(some<0) some=0;
break;
+ case 'a' :
+ case 'A' : if(TVStd!=TXTPAL) break;
+ tabActive=true;
+ tabTo=&reqPage;
+ tabLen=3;
+ tabType=TAB_HEX;
+ tabNdx=0;
+ break;
+ case 'f' : if(TVStd!=TXTPAL) break;
+ tabActive=true;
+ tabTo=&findTxt[1];
+ tabLen=120;
+ tabType=TAB_STR;
+ tabNdx=0;
+ findTxt[1]=0;
+ case 'F' : if(TVStd!=TXTPAL) break;
+ findTxt[0]=1;
+ break;
}
break;
case mLTVStd : switch(key){
case '1' : TVStd= PAL;
cryptStd= nix;
- if(yuvmode==1) yuvmode=0;
+ if(yuvMode==1) yuvMode=0;
+ grabYuvMode=yuvMode;
setStdScale();
contGrab();
break;
case '2' : TVStd= NTSC;
cryptStd= nix;
- if(yuvmode==1) yuvmode=0;
+ if(yuvMode==1) yuvMode=0;
+ grabYuvMode=yuvMode;
setStdScale();
contGrab();
break;
case '3' : TVStd= SECAM;
cryptStd= nix;
- if(yuvmode==1) yuvmode=0;
+ if(yuvMode==1) yuvMode=0;
+ grabYuvMode=yuvMode;
setStdScale();
contGrab();
break;
- case '4' : TVStd= PAL;
- cryptStd= vc;
- if(yuvmode==0) yuvmode=1;
+ case '4' : TVStd= TXTPAL;
+ cryptStd= nix;
+ if(yuvMode!=2) yuvMode=0, grabYuvMode=1;
+ else error(error_code(-988));
vSmoothState=false;
setStdScale();
contGrab();
break;
+#ifndef NO_CRYPT
case '5' : TVStd= PAL;
- cryptStd= nag;
- if(yuvmode==0) yuvmode=1;
+ cryptStd= vc;
+ if(yuvMode==0) yuvMode=1;
+ grabYuvMode=yuvMode;
vSmoothState=false;
setStdScale();
contGrab();
break;
- case '6' : TVStd= TXTPAL;
- cryptStd= nix;
- if(yuvmode==0) yuvmode=1;
+ case '6' : TVStd= PAL;
+ cryptStd= nag;
+ if(yuvMode==0) yuvMode=1;
+ grabYuvMode=yuvMode;
vSmoothState=false;
setStdScale();
contGrab();
break;
+#endif
}
menuLevel=mLNorm;
break;
Modified: trunk/2010/2010.h
==============================================================================
--- trunk/2010/2010.h (original)
+++ trunk/2010/2010.h Wed Jul 4 10:05:19 2007
@@ -37,6 +37,12 @@ enum MENULEVEL{
mLTXTChan,
};
+enum TABTYPE{
+ TAB_HEX,
+ TAB_DEZ,
+ TAB_STR,
+};
+
int error(error_code e);
void exitt(void);
Copied: trunk/2010/2_71x6.cpp (from r55, /trunk/2010/2_71x6.cc)
==============================================================================
--- /trunk/2010/2_71x6.cc (original)
+++ trunk/2010/2_71x6.cpp Wed Jul 4 10:05:19 2007
@@ -36,7 +36,7 @@ extern volatile u_char saa7196_buf[SAA71
extern volatile TVSTD TVStd;
extern volatile CRYPTSTD cryptStd;
extern volatile int x_field, y_field;
-extern volatile int xresc, yuvmode, mc;
+extern volatile int xresc, yuvMode, mc, grabYuvMode;
extern volatile VID2MEMBUF *vid2MemBuf, *actVid2MemBufp;
extern volatile int grabVid2MemBuf, actVid2MemBuf;
extern volatile int stride;
@@ -320,7 +320,7 @@ void setStdScale(void){
mc=1;
if(TVStd==TXTPAL){
- scales_y=0x0 , scalee_y=0x0 -288 + 20;
+ scales_y=0x0 + 100, scalee_y=0x0 -288 + 20 + 100;
xresc=vgax<<(mc+2);
wndx=768;
}
@@ -398,7 +398,12 @@ void setStdScale(void){
5 SECAM cross-colour reduction
4 Enable sync and clamping pulse
3:1 Luminance delay compensation */
- if(yuvmode==0){
+// write_saa7196(0x10, 0x04);
+ write_saa7196(0x10, 0x00);
+ /* 2 Select HREF Position
+ 1:0 Vertical noise reduction */
+
+ if(grabYuvMode==0){
/* if(oneField) write_saa7196(0x20, 0xF2);
else write_saa7196(0x20, 0x92);
a_saa7116->rt_mode_e=a_saa7116->rt_mode_o=
@@ -425,7 +430,7 @@ void setStdScale(void){
/* 7:0 [7:0] Pixel number per line on input */
write_saa7196(0x23, scales_x);/* 7:0 [7:0] Horizontal start position of scaling win*/
i=saa7196_buf[0x24] & 0xE0;
- if(TVStd==TXTPAL) i=4;
+ if(TVStd==TXTPAL) i=0x80;
write_saa7196(0x24, i | ((x_field>>6) & 0x0C) | (wndx>>8));
/* 7:5 Horizontal decimation filter
4 [8] Horizontal start position of scaling win
@@ -437,7 +442,7 @@ void setStdScale(void){
write_saa7196(0x26, y_field & 0xFF);
/* 7:0 [7:0] Line number per input field */
write_saa7196(0x27, scales_y);/* 7:0 [7:0] Vertical start of scaling window */
- if(TVStd==TXTPAL) i=0;
+ if(TVStd==TXTPAL) i=0x00;
else i=saa7196_buf[0x28] & 0xE0;
if(oneField) write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>8));
else write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>9));
@@ -553,10 +558,6 @@ void init_meteor(void){
2 S-VHS bit
1 GPSW2
0 GPSW1 */
-// write_saa7196(0x10, 0x04);
- write_saa7196(0x10, 0x00);
- /* 2 Select HREF Position
- 1:0 Vertical noise reduction */
write_saa7196(0x11, 0x2C);/* 7:0 Chrominance gain conrtol for QAM */
write_saa7196(0x14, 0x34);/* 7:0 Horizontal sync begin for 60hz */
//#ifdef notdef
@@ -678,3 +679,41 @@ void contGrab(void){
}
+void doTxtHack(int txtHackState){
+ switch(txtHackState){
+ case 8 ... 100:
+ write_saa7196(0x10, 0x00);
+ /* 2 Select HREF Position
+ 1:0 Vertical noise reduction */
+ write_saa7196(0x0F, 0x90);
+ /* 7 Automatic Field detection
+ 6 Field Select 0 = 50hz, 1=60hz
+ 5 SECAM cross-colour reduction
+ 4 Enable sync and clamping pulse
+ 3:1 Luminance delay compensation */
+ break;
+ case 7:
+ write_saa7196(0x10, 0x02);
+ /* 2 Select HREF Position
+ 1:0 Vertical noise reduction */
+ write_saa7196(0x0F, 0x50);
+ /* 7 Automatic Field detection
+ 6 Field Select 0 = 50hz, 1=60hz
+ 5 SECAM cross-colour reduction
+ 4 Enable sync and clamping pulse
+ 3:1 Luminance delay compensation */
+ break;
+ case 6:
+ write_saa7196(0x10, 0x02);
+ /* 2 Select HREF Position
+ 1:0 Vertical noise reduction */
+ write_saa7196(0x0F, 0x90);
+ /* 7 Automatic Field detection
+ 6 Field Select 0 = 50hz, 1=60hz
+ 5 SECAM cross-colour reduction
+ 4 Enable sync and clamping pulse
+ 3:1 Luminance delay compensation */
+
+ break;
+ }
+}
Modified: trunk/2010/2_71x6.h
==============================================================================
--- trunk/2010/2_71x6.h (original)
+++ trunk/2010/2_71x6.h Wed Jul 4 10:05:19 2007
@@ -218,5 +218,6 @@ void setCont(void);
void setStdScale(void);
void grab_next(VID2MEMBUF v2mb);
void grab_nix();
+void doTxtHack(int);
#endif
Modified: trunk/2010/2_all.h
==============================================================================
--- trunk/2010/2_all.h (original)
+++ trunk/2010/2_all.h Wed Jul 4 10:05:19 2007
@@ -2,6 +2,8 @@
#ifndef n2_all_h
#define n2_all_h
+#define NO_CRYPT
+
#define mabs(a) ((a)<0 ? -(a) : (a))
#define sign(a) ((a)<0 ? -1 : 1)
#define is_neg(a) ((a)<0 ? 0 : -1)
@@ -69,13 +71,27 @@ class color{
COL col;
color(void) { };
color(int y, int u, int v, byte yuv_mode) {init(y,u,v,yuv_mode);};
- void init(int y, int u, int v, byte yuv_mode){ // fix (yuv_mode==0)
- col.r=minmax(0, int( y + 1.375 *v ), 255);
- col.g=minmax(0, int( y - 0.703125*v - 0.34375 *u), 255);
- col.b=minmax(0, int( y + 1.734375*u), 255);
+ void init(int y, int u, int v, bool isRGB){
+ if(isRGB){
+ col.r=y;
+ col.g=u;
+ col.b=v;
+ y= minmax(0 , int( (+ .299120)*col.r + (+ .584954)*col.g + (+ 0.115935)*col.b), 255);
+ u= minmax(-128, int( (- .172465)*col.r + (- .337271)*col.g + (+ 0.509731)*col.b), 127);
+ v= minmax(-128, int( (+ .509731)*col.r + (- .536992)*col.g + (- 0.084317)*col.b), 127);
+ }
+ else{
+ col.r=minmax(0, int( y + 1.375 *v ), 255);
+ col.g=minmax(0, int( y - 0.703125*v - 0.34375 *u), 255);
+ col.b=minmax(0, int( y + 1.734375*u), 255);
+ }
+
const int r5= ((col.r>>3) & 0x1F);
const int g6= ((col.g>>2) & 0x3F);
const int b5= ((col.b>>3) & 0x1F);
+ col.rgb16= b5 | (g6<<5) | (r5<<11);
+ col.yuv= u | (y<<8) | (v<<16) | (y<<24);
+
/*
r=y + (+ 1.375 )*v
g=y + (- 0.703125)*v + (- 0.34375 )*u
@@ -104,12 +120,14 @@ class color{
(+ .338346)r + (+ .661664)g + =y + + (- 0.227444)*u
(+ .481203)r + (- .481203)g + = + v + (+ 0.165414)*u
(- .172465)r + (- .337271)g + (+ 0.509731)b= + + u
- (- .172465)(- 0.227444)r + (- .337271)(- 0.227444)g + (+ 0.509731)(- 0.227444)b= + + u(- 0.227444)
- (- .172465)(+ 0.165414)r + (- .337271)(+ 0.165414)g + (+ 0.509731)(+ 0.165414)b= + + u(+ 0.165414)
+ (+ .039226)r + (+ .076710)g + (- 0.115935)b= + + u(- 0.227444)
+ (- .028528)r + (- .055789)g + (+ 0.084317)b= + + u(+ 0.165414)
+
+ (+ .299120)r + (+ .584954)g + (+ 0.115935)b=y
+ (+ .509731)r + (- .536992)g + (- 0.084317)b= v
+ (- .172465)r + (- .337271)g + (+ 0.509731)b= u
*/
- col.rgb16= b5 | (g6<<5) | (r5<<11);
- col.yuv= u | (y<<8) | (v<<16) | (y<<24);
};
} ;
Copied: trunk/2010/2_crypt.cpp (from r55, /trunk/2010/2_crypt.cc)
==============================================================================
--- /trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cpp Wed Jul 4 10:05:19 2007
@@ -19,7 +19,7 @@ extern vgax, vgay, wndx, wndy, y_field,
extern VID2MEMBUF *actVid2MemBufp;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
-extern int yuvmode;
+extern int yuvMode;
extern volatile bool oneField;
extern int satur;
extern bool iState;
@@ -58,7 +58,7 @@ void decrypt(void){
if(iState){
T2=uclock();
color c;
- c.init(255, 0, 0, yuvmode);
+ c.init(255, 0, 0, false);
sprintf(textbuf[1],"%f DeCrypt", (float)(T2-T1)/UCLOCKS_PER_SEC);
gprint(infoPosX, infoPosY+=10, c.col, textbuf[0]);
gprint(infoPosX, infoPosY+=10, c.col, textbuf[1]);
@@ -218,7 +218,7 @@ static void decomb(int q){
static void vSmooth(void){
- if(yuvmode==0){
+ if(yuvMode==0){
/* asm(//"int $3 \n\t"
"1: \n\t"
"movl (%%esi ), %%eax \n\t" //U LINE
Copied: trunk/2010/2_file.cpp (from r52, /trunk/2010/2_file.cc)
==============================================================================
--- /trunk/2010/2_file.cc (original)
+++ trunk/2010/2_file.cpp Wed Jul 4 10:05:19 2007
@@ -12,7 +12,7 @@
extern byte font[4096];
extern VID2MEMBUF *actVid2MemBufp;
extern int g_mode;
- extern int yuvmode;
+ extern int yuvMode;
extern char *yuv2rgb_lut;
void grab(void){
@@ -46,7 +46,7 @@ void grab(void){
fwrite(&bmpi, sizeof(bmpi), 1, fg);
for(i=wndy-1; i>=0; i--){
- if(yuvmode==0){
+ if(yuvMode==0){
for(j=0; j<wndx; j++){
/* const int b= (actVid2MemBufp->b[ (j + i*vgax)<<1 ] & 0x1F) << 3;
const int g= ((actVid2MemBufp->b[ (j + i*vgax)<<1 ] & 0xE0) >> 3)
Copied: trunk/2010/2_gfunc.cpp (from r55, /trunk/2010/2_gfunc.cc)
==============================================================================
--- /trunk/2010/2_gfunc.cc (original)
+++ trunk/2010/2_gfunc.cpp Wed Jul 4 10:05:19 2007
@@ -12,9 +12,10 @@
extern int page_flip;
extern VID2MEMBUF *actVid2MemBufp;
extern byte *vidbuf;
- extern int yuvmode;
+ extern int yuvMode;
-static inline void memsetd(void *pt, u_long c, int num);
+static inline void memsetw(void *pt, u_short c, int num);
+static inline void memsetd(void *pt, u_long c, int num);
static inline void memsetd(void *pt, u_long c, int num){
@@ -28,6 +29,44 @@ static inline void memsetd(void *pt, u_l
}
+static inline void memsetw(void *pt, u_short c, int num){
+
+ asm(//"int $3 \n\t"
+ "rep \n\t"
+ "stosw \n\t"
+ :
+ : "a" (c), "D" (pt), "c" (num)
+ : "%ecx", "%edi");
+
+
+}
+
+void rect(int xs, int ys, int xe, int ye, const COL c){
+ if(xs<0) xs=0;
+ if(ys<0) ys=0;
+ if(xe>vgax) xe=vgax;
+ if(ye>vgay) ye=vgay;
+
+ if(xe<0) xs=0;
+ if(ye<0) ys=0;
+ if(xs>vgax) xe=vgax;
+ if(ys>vgay) ye=vgay;
+
+ if(yuvMode){
+ xs>>=1;
+ xe>>=1;
+ for(int y=ys; y<ye; y++){
+ memsetd( &actVid2MemBufp->b[(y*vgax +xs+xs) << mc], c.yuv, xe-xs);
+ }
+ }
+ else{
+ for(int y=ys; y<ye; y++){
+ memsetw( &actVid2MemBufp->b[(y*vgax +xs) << mc], c.rgb16, xe-xs);
+ }
+ }
+
+}
+
void xcliped_gprint(int xp, int yp, const COL c, int text){
int ix, iy;
int t3;
@@ -42,7 +81,7 @@ void xcliped_gprint(int xp, int yp, cons
else ix=-xp;
for(; ix<8 && ix+xp<vgax; ix++){
if(((t1>>(7-ix)) & 1) == 1){
- if(yuvmode!=0)
+ if(yuvMode!=0)
((long*) actVid2MemBufp->b)[(ix+t3)>>1]=c.yuv;
else
((short*)actVid2MemBufp->b)[(ix+t3) ]=c.rgb16;
@@ -88,7 +127,7 @@ void gprint(int xp, int yp, const COL c,
static int vgaxmc;
vgaxmc= vgax<<mc;
- if(yuvmode!=0){
+ if(yuvMode!=0){
asm(//"int $3\n\t"
"pushl %%ebp \n\t"
"pushl %%eax \n\t"
Modified: trunk/2010/2_gfunc.h
==============================================================================
--- trunk/2010/2_gfunc.h (original)
+++ trunk/2010/2_gfunc.h Wed Jul 4 10:05:19 2007
@@ -2,6 +2,7 @@
#ifndef n2_gfunc_h
#define n2_gfunc_h
+void rect(int xs, int ys, int xe, int ye, const COL c);
void gprint(int xp, int yp, const COL c, char *text);
void xcliped_gprint(int xp, int yp, const COL c, int text);
Copied: trunk/2010/2_grafix.cpp (from r55, /trunk/2010/2_grafix.cc)
==============================================================================
--- /trunk/2010/2_grafix.cc (original)
+++ trunk/2010/2_grafix.cpp Wed Jul 4 10:05:19 2007
@@ -15,7 +15,7 @@
extern int fysize;
extern byte font[4096];
extern int grabf;
- extern int yuvmode;
+ extern int yuvMode;
extern volatile int addr_errors, corr_errors;
extern int single;
extern int bright, contr, satur;
@@ -35,7 +35,7 @@ void showStuff(void){
color c;
if(helpState){
- char text[11][256]={ "F1/F2 Brightness s TVStandart",
+ char text[14][256]={ "F1/F2 Brightness s TVStandart",
"F3/F4 Contrast i debugInfo",
"F5/F6 Saturation h Help",
"g ScreenShot q Quit",
@@ -45,10 +45,13 @@ void showStuff(void){
"+ Page+ - Page-",
"right subPage+ left subPage-",
"up Channel+ down Channel-",
- "c txt Channel a num Page" };
+ "c txt Channel a num Page",
+ "g savePage G saveAll",
+ "e delUnSeen",
+ "f txt find F findNext"};
- for(int i=0; i<11; i++){
- c.init(255, 0, 0, yuvmode);
+ for(int i=0; i<14; i++){
+ c.init(255, 0, 0, false);
gprint(infoPosX, infoPosY+=10, c.col, text[i]);
}
infoPosY+=5;
@@ -57,7 +60,7 @@ void showStuff(void){
if(showCont!=0){
showCont--;
sprintf(textbuf,"%3.1f%% brightness", bright/2.55);
- c.init(255, 0, 0, yuvmode);
+ c.init(255, 0, 0, false);
gprint(infoPosX, infoPosY+=10, c.col, textbuf);
sprintf(textbuf,"%3.1f%% contrast" , contr/1.27);
@@ -68,11 +71,17 @@ void showStuff(void){
}
if(menuLevel==mLTVStd){
- char text[3][256]={ "1. PAL 4. VideoCrypt (PAL)",
- "2. NTSC 5. NagraVision (PAL/SECAM)",
- "3. SECAM 6. Pal-TeleText"};
+#ifdef NO_CRYPT
+ char text[3][256]={ "1. PAL 4. PAL-TeleText",
+ "2. NTSC",
+ "3. SECAM"};
+#else
+ char text[3][256]={ "1. PAL 4. PAL-TeleText",
+ "2. NTSC 5. VideoCrypt (PAL)",
+ "3. SECAM 6. NagraVision (PAL/secam)"};
+#endif
for(int i=0; i<3; i++){
- c.init(255, 0, 0, yuvmode);
+ c.init(255, 0, 0, false);
gprint(infoPosX, infoPosY+=10, c.col, text[i]);
}
infoPosY+=5;
@@ -82,7 +91,7 @@ void showStuff(void){
long T1=uclock();
if(iState){
- c.init(255, 0, 0, yuvmode);
+ c.init(255, 0, 0, false);
sprintf(textbuf,"%2.2f Fps",1/((float)(T1-T2)/UCLOCKS_PER_SEC));
gprint(infoPosX, infoPosY+=10, c.col, textbuf);
@@ -90,7 +99,7 @@ void showStuff(void){
sprintf(textbuf,"%d Buf", vid2MemBuf[0].num);
gprint(infoPosX+110, infoPosY , c.col, textbuf);
- if(yuvmode==0) sprintf(textbuf,"RGB16");
+ if(yuvMode==0) sprintf(textbuf,"RGB16");
else sprintf(textbuf,"YUV422");
gprint(infoPosX+170, infoPosY , c.col, textbuf);
Copied: trunk/2010/2_hw.cpp (from r55, /trunk/2010/2_hw.cc)
==============================================================================
--- /trunk/2010/2_hw.cc (original)
+++ trunk/2010/2_hw.cpp Wed Jul 4 10:05:19 2007
@@ -22,7 +22,7 @@
extern int bpp;
extern volatile int page_flip;
- extern volatile int yuvmode;
+ extern volatile int yuvMode;
extern volatile AllocList *alloclist;
extern volatile VID2MEMBUF *vid2MemBuf, *actVid2MemBufp;
extern volatile int grabVid2MemBuf, actVid2MemBuf;
@@ -53,7 +53,7 @@
void mem2vid(byte *to, byte *from, int num, int bpp){
- if(yuvmode!=0){
+ if(yuvMode!=0){
asm(//"int $3 \n\t"
"pushl %%ebp \n\t"
"movl %%eax, %%ebp \n\t"
@@ -303,7 +303,7 @@ void copy_vidbuffer(void){
char textBuf[128];
sprintf(textBuf, "%f vid2Mem", (float)(T2-T1)/UCLOCKS_PER_SEC);
color c;
- c.init(255, 0, 0, yuvmode);
+ c.init(255, 0, 0, false);
gprint(infoPosX, infoPosY+=10, c.col, textBuf);
T1=uclock();
infoPosY+=5;
Modified: trunk/2010/2_hw_asm.s
==============================================================================
--- trunk/2010/2_hw_asm.s (original)
+++ trunk/2010/2_hw_asm.s Wed Jul 4 10:05:19 2007
@@ -19,7 +19,8 @@
.globl _mc
.globl _xresc
.globl _vgay
-.globl _yuvmode
+.globl _yuvMode
+.globl _grabYuvMode
.globl _locklist
.globl _alloclist
.globl _vdslist
@@ -69,7 +70,8 @@ _mc: .long 0
_xresvb: .long 0
_xresc: .long 0
_vgay: .long 0
-_yuvmode: .long 0
+_yuvMode: .long 0
+_grabYuvMode: .long 0
_locklist: .long 0
_alloclist: .long 0
_vdslist: .long 0
Copied: trunk/2010/2_nag.cpp (from r54, /trunk/2010/2_nag.cc)
==============================================================================
--- /trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cpp Wed Jul 4 10:05:19 2007
@@ -30,7 +30,7 @@ extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
extern u_long asm_temp, asm_temp4;
extern bool iState;
-extern int yuvmode;
+extern int yuvMode;
extern bool mmx;
extern int infoPosX;
extern int infoPosY;
@@ -1010,7 +1010,7 @@ void nag_decrypt(void){
if(iState){
T2=uclock();
- c.init(255, 0, 0, yuvmode);
+ c.init(255, 0, 0, false);
gprint(infoPosX, infoPosY+=10, c.col, textbuf[0]);
gprint(infoPosX, infoPosY+=10, c.col, textbuf[1]);
gprint(infoPosX, infoPosY+=10, c.col, textbuf[2]);
Copied: trunk/2010/2_txt.cpp (from r55, /trunk/2010/2_txt.cc)
==============================================================================
--- /trunk/2010/2_txt.cc (original)
+++ trunk/2010/2_txt.cpp Wed Jul 4 10:05:19 2007
@@ -9,6 +9,9 @@
#include "2_crypt.h"
#include "2_gfunc.h"
#include "2_txt.h"
+#include "2_71x6.h"
+
+#define FORCE_ORDER true
extern int vgax, vgay, wndx, wndy, mc, x_field;
extern bool iState, helpState;
@@ -16,8 +19,9 @@ extern volatile scales_x, scalee_x;
extern volatile scales_y, scalee_y;
extern VID2MEMBUF *actVid2MemBufp;
extern int some;
-extern int yuvmode;
+extern int yuvMode;
extern int infoPosX, infoPosY;
+extern int grabf;
#define FREQ_TXT 6.9375E6
#define FIXP_SH 16
@@ -28,6 +32,38 @@ char reqChanStr[16];
int reqChanNum=0;
int reqPage=0x100;
int reqSubPage=0;
+char findTxt[128]={0,0,};
+
+ // FIX all langs and add graph to ascii if saved in text
+
+static int reMapTab[8][13]={
+ {0x9C, 0x24, 0x40, 0x1B, 0xAB, 0x1A, 0x18, 0x23, 0xC4, 0xAC, 0xBA, 0x00, 0xF6},
+ {0x23, 0x24, 0x15, 0x8E, 0x99, 0x9A, 0x5E, 0x5F, 0xA7, 0x84, 0x94, 0x81, 0xE1},
+
+ {0x9C, 0x24, 0x40, 0x1B, 0xAB, 0x1A, 0x18, 0x23, 0xC4, 0xAC, 0xBA, 0x00, 0xF6},
+ {0x9C, 0x24, 0x40, 0x1B, 0xAB, 0x1A, 0x18, 0x23, 0xC4, 0xAC, 0xBA, 0x00, 0xF6},
+ {0x9C, 0x24, 0x40, 0x1B, 0xAB, 0x1A, 0x18, 0x23, 0xC4, 0xAC, 0xBA, 0x00, 0xF6},
+ {0x9C, 0x24, 0x40, 0x1B, 0xAB, 0x1A, 0x18, 0x23, 0xC4, 0xAC, 0xBA, 0x00, 0xF6},
+ {0x9C, 0x24, 0x40, 0x1B, 0xAB, 0x1A, 0x18, 0x23, 0xC4, 0xAC, 0xBA, 0x00, 0xF6},
+ {0x9C, 0x24, 0x40, 0x1B, 0xAB, 0x1A, 0x18, 0x23, 0xC4, 0xAC, 0xBA, 0x00, 0xF6}
+ };
+
+static int isReMap[128]={
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 5, 6, 7, 8,
+ 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,11,12,13, 0 };
+
+static inline void txtCpy(char *to, u_char *from, int num){
+ for(int i=0; i<num; i++){
+ if((from[i]&0x80) && !(to[i]&0x80)) continue;
+ to[i]=from[i];
+ }
+}
static inline float atan3(const float f1, const float f2){
float out;
@@ -42,6 +78,15 @@ static inline float atan3(const float f1
return out;
}
+static inline void reMapCpy(char *to, char *from, int num, int land){
+ for(int i=0; i<num; i++){
+ char a= from[i] & 0x7F;
+ if(a<0x20) a=0x20;
+ if(isReMap[a]) to[i]=reMapTab[land][ isReMap[a] - 1 ];
+ else to[i]=a;
+ }
+}
+
static signed char corrHamm48[256]={
0x01, 0xff, 0x01, 0x01, 0xff, 0x00, 0x01, 0xff, 0xff, 0x02, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x07,
0xff, 0x00, 0x01, 0xff, 0x00, 0x00, 0xff, 0x00, 0x06, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x03, 0xff,
@@ -75,9 +120,10 @@ static inline int sample(byte *b, int fi
void txt_decrypt(void){
char textbuf[9][128];
- color c;
static int hammErr=0;
+ static int pages=0;
+ static int parities=0;
const double freqPix2= double(wndx) / double(x_field) * FREQ_PIX;
const int delta= int(freqPix2/FREQ_TXT*ONE_FIXP);
@@ -89,7 +135,8 @@ void txt_decrypt(void){
static CACHE1 *cache1=new CACHE1[1024];
static int cache1Size=0;
static bool first=true;
- static color txtCol[8];
+ static color txtColor[8];
+ static MAG mag[8];
if(first){
FILE *f= fopen("chaninf.txt", "rb");
if(f==NULL) error(TxtFile);
@@ -106,33 +153,37 @@ void txt_decrypt(void){
j^= j<<4;
fixParity[i]= i ^ (j&0x80) ^ 0x80;
}
- // FIX OVERFLOWS ...
- txtColor[0].init( 0, 0, 0, yuvmode);
- txtColor[1].init(255, 0, 0, yuvmode);
- txtColor[2].init(255, 0, 0, yuvmode);
- txtColor[3].init(255, 0, 0, yuvmode);
- txtColor[4].init(255, 0, 0, yuvmode);
- txtColor[5].init(255, 0, 0, yuvmode);
- txtColor[6].init(255, 0, 0, yuvmode);
- txtColor[7].init(255, 0, 0, yuvmode);
+ txtColor[0].init( 0, 0, 0, true);
+ txtColor[1].init(255, 0, 0, true);
+ txtColor[2].init( 0,255, 0, true);
+ txtColor[3].init(255,255, 0, true);
+ txtColor[4].init( 0, 0,255, true);
+ txtColor[5].init(255, 0,255, true);
+ txtColor[6].init( 0,255,255, true);
+ txtColor[7].init(255,255,255, true);
+
+ for(int i=0; i<8; i++) mag[i].pt=NULL;
first=false;
}
- static CACHE2 *mag[8]={NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
-
byte data[64];
+ int txtHack=4;
+ static int txtHackState=0;
+
int linep=-(vgax<<4);
for(int line=0; line<40; line++){
linep+=vgax<<4;
if(line==20) linep=vgax<<3;
+ if(txtHackState) break;
+
int avg=0;
- for(int x=0; x<50; x++){
+ for(int x=0; x<((10*delta)>>FIXP_SH); x++){
avg+=actVid2MemBufp->b[linep + (x<<1) + 1];
}
- avg/=50;
+ avg/=((10*delta)>>FIXP_SH);
// FIX ? optimize in fixp and lut ...
double si=0, co=0;
@@ -196,10 +247,16 @@ void txt_decrypt(void){
if(d0<0 || d1<0){ hammErr++; continue;}
+ if(line==0 || line==39) txtHack+=1000;
+ else txtHack--;
+
const int magAddr= d0 & 0x7;
const int rowAddr= (d0>>3) | (d1<<1);
+ printf("lrm %d %d %d\n", line, rowAddr, magAddr);
+
if(rowAddr==0){
+ mag[magAddr].pt=NULL;
const int d2= corrHamm48[ data[2] ];
const int d3= corrHamm48[ data[3] ];
const int d4= corrHamm48[ data[4] ];
@@ -209,11 +266,15 @@ void txt_decrypt(void){
const int d8= corrHamm48[ data[8] ];
const int d9= corrHamm48[ data[9] ];
- if(d2<0 || d3<0 || d4<0 || d5<0 || d6<0 || d7<0 || d8<0 || d9<0){ hammErr++; continue;}
+ if(d2<0 || d3<0 || d4<0 || d5<0 || d6<0 || d7<0 || d8<0 || d9<0){
+ hammErr++;
+ continue;
+ }
const int lsPage = d2 | (d3<<4);
const int subPage=(d4 | (d5<<4) | (d6<<8) | (d7<<12)) & 0x3F7F;
const int page =(magAddr<<8) | lsPage;
+ mag[magAddr].land= d9 & 0x7;
for(int i=10; i<BYTES; i++){
data[i]= fixParity[ data[i] ];
@@ -242,7 +303,7 @@ void txt_decrypt(void){
if(bestLen==0){
printf(" ERR Unknown Stuff: %32s\n", &data[10]);
- mag[magAddr]=NULL;
+ mag[magAddr].pt=NULL;
continue;
}
cache1Ndx=best;
@@ -253,20 +314,24 @@ void txt_decrypt(void){
}
if(cache1[cache1Ndx].pt[page]==NULL){
+ pages++;
cache1[cache1Ndx].pt[page]= new CACHE2;
cache1[cache1Ndx].pt[page]->next=NULL;
cache1[cache1Ndx].pt[page]->seen=false;
- memset(cache1[cache1Ndx].pt[page]->text, ' ', 40*LINES);
- mag[magAddr]= cache1[cache1Ndx].pt[page];
+ cache1[cache1Ndx].pt[page]->land=mag[magAddr].land;
+ memset(cache1[cache1Ndx].pt[page]->text, 0xFF, 40*LINES);
+ mag[magAddr].pt= cache1[cache1Ndx].pt[page];
+ mag[magAddr].order=0;
}
else{
CACHE2 *p=cache1[cache1Ndx].pt[page];
while(p->next!=NULL && p->next->sub<=subPage) p=p->next;
- if(p->sub==subPage) mag[magAddr]= p;
+ if(p->sub==subPage) mag[magAddr].pt= p, mag[magAddr].order=0;
else{
+ pages++;
CACHE2 *temp= new CACHE2;
- memset(temp->text, ' ', 40*LINES);
+ memset(temp->text, 0xFF, 40*LINES);
if(p->sub<subPage){
temp->next= p->next;
@@ -278,21 +343,27 @@ void txt_decrypt(void){
}
temp->seen=false;
- mag[magAddr]= temp;
+ mag[magAddr].pt= temp;
+ mag[magAddr].order=0;
}
}
- mag[magAddr]->sub=subPage;
- memcpy(&mag[magAddr]->text[rowAddr*40], data+10, 32);
+ mag[magAddr].pt->land=mag[magAddr].land;
+ mag[magAddr].pt->sub=subPage;
+ mag[magAddr].order=0;
+ txtCpy(&mag[magAddr].pt->text[rowAddr*40], data+10, 32);
}
else if(rowAddr<LINES){
- if(mag[magAddr]==NULL) continue;
+ if(FORCE_ORDER && mag[magAddr].order>=rowAddr) mag[magAddr].pt=NULL;
+ if(mag[magAddr].pt==NULL) continue;
+ mag[magAddr].order=rowAddr;
for(int i=2; i<BYTES; i++){
data[i]= fixParity[ data[i] ];
+ if(data[i]&0x80) parities++;
}
- memcpy(&mag[magAddr]->text[rowAddr*40], data+2, 40);
+ txtCpy(&mag[magAddr].pt->text[rowAddr*40], data+2, 40);
}
@@ -302,6 +373,13 @@ void txt_decrypt(void){
memset(actVid2MemBufp->b, 0, vgax*vgay<<mc);
+ if(txtHack>0 && txtHackState==0) txtHackState=14;
+
+ if(txtHackState>0){
+ doTxtHack(txtHackState);
+ txtHackState--;
+ }
+
if(iState || helpState) return;
static int lastReqPage=-1, lastReqSubPage=-1, lastReqChanNum=-1;
@@ -315,8 +393,8 @@ void txt_decrypt(void){
reqPage&=0x7FF;
if(reqSubPage<0) reqSubPage=0;
- if(reqChanNum<0) reqChanNum=0;
- if(reqChanNum>=cache1Size) reqChanNum=cache1Size-1;
+ if(reqChanNum<0 ) reqChanNum= cache1Size-1;
+ if(reqChanNum>=cache1Size) reqChanNum= 0;
int start=reqChanNum;
do{
@@ -328,42 +406,191 @@ void txt_decrypt(void){
if(cache1[reqChanNum].pt==NULL) return;
- start=reqPage;
- do{
- if(cache1[reqChanNum].pt[reqPage]!=NULL) break;
- reqPage+= seekPageDelta;
- reqPage&= 0x7FF;
- }while(start!=reqPage);
+ CACHE2 *p=NULL;
+ bool reqSearch=true;
+ if((findTxt[0]) && (findTxt[1])){
+ findTxt[0]=0;
- if(cache1[reqChanNum].pt[reqPage]==NULL) return;
+ bool found=false;
+ int start=reqPage;
+ int page=start+1;
+ const int len=strlen(&findTxt[1]);
+ while(page!=start){
+ p=cache1[reqChanNum].pt[page];
+ while(p!=NULL){
+ for(int i=0; i<LINES*40; i++)
+ if(!strnicmp(&findTxt[1], &p->text[i], min(LINES*40-i, len))){
+ found=true;
+ break;
+ }
+ if(found) break;
+ p=p->next;
+ }
+ if(found) break;
+ page++;
+ page&=0x7FF;
+ }
+ if(found){
+ reqPage=page;
+ reqSubPage=p->sub;
+ reqSearch=false;
+ }
+ }
+ if(reqSearch){
- CACHE2 *p=cache1[reqChanNum].pt[reqPage];
- CACHE2 *largep=p, *smallp=p;
+ start=reqPage;
+ do{
+ if(cache1[reqChanNum].pt[reqPage]!=NULL) break;
+ reqPage+= seekPageDelta;
+ reqPage&= 0x7FF;
+ }while(start!=reqPage);
- while(p!=NULL){
- if(p->sub==reqSubPage) break;
- largep=p;
- p=p->next;
+ if(cache1[reqChanNum].pt[reqPage]==NULL) return;
+
+ p=cache1[reqChanNum].pt[reqPage];
+ CACHE2 *firstp=p, *lastp=p, *largep=NULL, *smallp=NULL;
+
+ while(p!=NULL){
+ if(p->sub==reqSubPage) break;
+ if(p->sub<reqSubPage && (smallp==NULL || p->sub>smallp->sub)) smallp=p;
+ if(p->sub>reqSubPage && (largep==NULL || p->sub<largep->sub)) largep=p;
+ lastp=p;
+ p=p->next;
+ }
+
+ if(p==NULL){
+ if(largep==NULL) largep=firstp;
+ if(smallp==NULL) smallp=lastp;
+ if(seekSubPageDelta>0) p=largep;
+ else p=smallp;
+ }
+
+ reqSubPage=p->sub;
}
- if(p==NULL || p->sub!=reqSubPage){
- if(largep->sub<reqSubPage) largep=smallp;
- if(smallp->sub>reqSubPage) smallp=largep;
- if(seekSubPageDelta>0) p=largep;
- else p=smallp;
+ int yPos=0;
+ for(int line=0; line<LINES; line++){
+ int fgColorNdx=7;
+ int bgColorNdx=0;
+ bool flash=false;
+ bool graph=false;
+ bool contGraph=true;
+ int xs=0;
+ int xPos=10;
+
+ while(xs<40){
+ while(xs<40 && ( p->text[line*40 + xs] < 0x20
+ || ((p->text[line*40 + xs]&0x20) && graph) ) ){
+ const int d= p->text[line*40 + xs];
+ if(d<0x20){
+ if((d&0xF)<8){
+ fgColorNdx= d&0xF;
+ if(d&0x10) graph=true;
+ else graph=false;
+ }
+ else if(d==0x1C) bgColorNdx=0;
+ else if(d==0x1D) bgColorNdx=fgColorNdx;
+ else if(d==0x19) contGraph=true;
+ else if(d==0x1A) contGraph=false;
+ rect(xPos, yPos+1, xPos+9, yPos+13, txtColor[bgColorNdx].col);
+ }
+ else{
+ rect(xPos, yPos+1, xPos+9, yPos+13, txtColor[bgColorNdx].col);
+ if(contGraph){
+ if(d&0x01) rect(xPos , yPos+1, xPos+4, yPos+4 , txtColor[fgColorNdx].col);
+ if(d&0x02) rect(xPos+4, yPos+1, xPos+9, yPos+4 , txtColor[fgColorNdx].col);
+ if(d&0x04) rect(xPos , yPos+4, xPos+4, yPos+8 , txtColor[fgColorNdx].col);
+ if(d&0x08) rect(xPos+4, yPos+4, xPos+9, yPos+8 , txtColor[fgColorNdx].col);
+ if(d&0x10) rect(xPos , yPos+8, xPos+4, yPos+13, txtColor[fgColorNdx].col);
+ if(d&0x40) rect(xPos+4, yPos+8, xPos+9, yPos+13, txtColor[fgColorNdx].col);
+ }
+ else{
+ if(d&0x01) rect(xPos+1, yPos+2, xPos+4, yPos+4 , txtColor[fgColorNdx].col);
+ if(d&0x02) rect(xPos+5, yPos+2, xPos+9, yPos+4 , txtColor[fgColorNdx].col);
+ if(d&0x04) rect(xPos+1, yPos+5, xPos+4, yPos+8 , txtColor[fgColorNdx].col);
+ if(d&0x08) rect(xPos+5, yPos+5, xPos+9, yPos+8 , txtColor[fgColorNdx].col);
+ if(d&0x10) rect(xPos+1, yPos+9, xPos+4, yPos+13, txtColor[fgColorNdx].col);
+ if(d&0x40) rect(xPos+5, yPos+9, xPos+9, yPos+13, txtColor[fgColorNdx].col);
+ }
+ }
+
+ xPos+=9;
+ xs++;
+ }
+
+ int xe=xs;
+ if(xs>=40) break;
+
+ while(xe<40 && p->text[line*40 + xe] >= 0x20
+ && (!(p->text[line*40 + xe]&0x20) || !graph) ) xe++;
+ reMapCpy(textbuf[0], &p->text[line*40 + xs], xe-xs, p->land);
+
+
+ textbuf[0][xe-xs]=0;
+ rect(xPos, yPos+1, xPos+9*(xe-xs), yPos+13, txtColor[bgColorNdx].col);
+ gprint(xPos, yPos, txtColor[fgColorNdx].col, textbuf[0]);
+
+ xPos+=(xe-xs)*9;
+
+ xs=xe;
+ }
+
+ if(line==0){
+ sprintf(textbuf[0], " %d %d", pages, parities);
+ gprint(10+32*9, yPos, txtColor[7].col, textbuf[0]);
+ }
+
+ yPos+=12;
}
- reqSubPage=p->sub;
+ if(grabf){
+ char name[13]="12345678.123";
+ if(grabf==1)
+ sprintf(name, "%3X%3X.TXT", reqChanNum, reqPage);
+ else
+ sprintf(name, "%3X.TXT", reqChanNum);
- for(int i=0; i<LINES; i++){
-// int colorNdx=
+ FILE *f= fopen(name, "wb");
+ if(f==NULL) error(TxtFile);
- sprintf(textbuf[0],"%40s", &p->text[i*40]);
- c.init(255, 0, 0, yuvmode);
- gprint(10, infoPosY+=10, c.col, textbuf[0]);
+ char temp[LINES*40+1];
+
+ if(grabf==1){
+ CACHE2 *p=cache1[reqChanNum].pt[reqPage];
+ while(p!=NULL){
+ reMapCpy(temp, p->text, 40*LINES, p->land);
+ for(int y=0; y<LINES; y++){
+ for(int x=0; x<40; x++){
+ char a= temp[x + y*40];
+ fputc(a, f);
+ }
+ fputs("\n", f);
+ }
+ p=p->next;
+ fputs("\n", f);
+ }
+ }
+ else{
+ for(int page=0; page<0x800; page++){
+ CACHE2 *p=cache1[reqChanNum].pt[page];
+ while(p!=NULL){
+ reMapCpy(temp, p->text, 40*LINES, p->land);
+ for(int y=0; y<LINES; y++){
+ for(int x=0; x<40; x++){
+ char a= temp[x + y*40];
+ fputc(a, f);
+ }
+ fputs("\n", f);
+ }
+ p=p->next;
+ fputs("\n", f);
+ }
+ }
+ }
+ grabf=0;
}
-// printf("bad ham's %d\n", hammErr);
+
lastReqPage= reqPage;
@@ -372,6 +599,8 @@ void txt_decrypt(void){
infoPosY+=5;
+ if(parities>9999) parities-=9000;
+
}
Modified: trunk/2010/2_txt.h
==============================================================================
--- trunk/2010/2_txt.h (original)
+++ trunk/2010/2_txt.h Wed Jul 4 10:05:19 2007
@@ -9,6 +9,7 @@ struct CACHE2{
bool seen;
char text[LINES*40];
CACHE2 *next;
+ int land;
};
struct CACHE1{
@@ -16,6 +17,12 @@ struct CACHE1{
CACHE2 **pt;
};
+struct MAG{
+ CACHE2 *pt;
+ int order;
+ int land;
+};
+
void txt_decrypt(void);
#endif
Copied: trunk/2010/2_vc.cpp (from r55, /trunk/2010/2_vc.cc)
==============================================================================
--- /trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cpp Wed Jul 4 10:05:19 2007
@@ -57,7 +57,7 @@ extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
extern bool showPoints;
extern bool iState;
-extern int yuvmode;
+extern int yuvMode;
extern int some;
extern bool mmx;
extern int infoPosX;
@@ -782,7 +782,7 @@ void vc_decrypt(void){
sprintf(textbuf[4],"%f FindPhaseDiff2 / Drift", (float)(TPhaseDiff2_Drift)/UCLOCKS_PER_SEC);
sprintf(textbuf[5],"%f EdgeDetect", (float)(TEdgeDetect)/UCLOCKS_PER_SEC);
sprintf(textbuf[6],"%f Rotate / ColorFix", (float)(T2-T1-uclockWaste)/UCLOCKS_PER_SEC);
- c.init(255, 0, 0, yuvmode);
+ c.init(255, 0, 0, false);
gprint(infoPosX, infoPosY+=10, c.col, textbuf[0]);
gprint(infoPosX, infoPosY+=10, c.col, textbuf[1]);
gprint(infoPosX, infoPosY+=10, c.col, textbuf[2]);
1
0
[mndiff]: r55 - in trunk/2010: 2010.cc 2010.h 2_71x6.cc 2_all.h 2_crypt.cc 2_crypt.h 2_gfunc.cc 2_grafix.cc 2_hw.cc 2_txt.cc 2_txt.h 2_vc.cc makefile
by michael 04 Jul '07
by michael 04 Jul '07
04 Jul '07
Author: michael
Date: Wed Jul 4 09:50:51 2007
New Revision: 55
Log:
next version (unknown date)
Added:
trunk/2010/2_txt.cc
trunk/2010/2_txt.h
Modified:
trunk/2010/2010.cc
trunk/2010/2010.h
trunk/2010/2_71x6.cc
trunk/2010/2_all.h
trunk/2010/2_crypt.cc
trunk/2010/2_crypt.h
trunk/2010/2_gfunc.cc
trunk/2010/2_grafix.cc
trunk/2010/2_hw.cc
trunk/2010/2_vc.cc
trunk/2010/makefile
Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cc Wed Jul 4 09:50:51 2007
@@ -45,6 +45,8 @@
extern bool iState;
extern bool helpState;
extern bool allowDrop;
+ extern int reqPage, reqSubPage, reqChanNum;
+ extern char *reqChanStr;
int maxBuf=2;
int some=0;
@@ -113,6 +115,8 @@ int error(error_code e){
break;
case KeyFile : printg_t("\nKeyFile error!\n");
break;
+ case TxtFile : printg_t("\nTxtFile error!\n");
+ break;
case DatWrite : printg_t("\nDatWrite error!\n");
break;
case Align : printg_t("\nAlign error!\n");
@@ -405,6 +409,30 @@ int main(int argc, char **argv){
case 'd' :
case 'D' : allowDrop= !allowDrop;
break;
+ case '+' : reqPage++;
+ break;
+ case '-' : reqPage--;
+ break;
+ case K_Up : reqChanNum++;
+ break;
+ case K_Down : reqChanNum--;
+ break;
+ case K_Right : reqSubPage++;
+ break;
+ case K_Left : reqSubPage--;
+ break;
+ case K_Control_KPPlus : reqPage+=10;
+ break;
+ case K_Control_KPDash : reqPage-=10;
+ break;
+ case K_Control_Up : reqChanNum+=10;
+ break;
+ case K_Control_Down : reqChanNum-=10;
+ break;
+ case K_Control_Right : reqSubPage+=10;
+ break;
+ case K_Control_Left : reqSubPage-=10;
+ break;
case '1' : delay++;
break;
case '2' : delay--; if(delay<0) delay=0;
Modified: trunk/2010/2010.h
==============================================================================
--- trunk/2010/2010.h (original)
+++ trunk/2010/2010.h Wed Jul 4 09:50:51 2007
@@ -27,11 +27,14 @@ enum error_code{
KeyFile,
Align,
Nagra,
+ TxtFile,
};
enum MENULEVEL{
mLNorm,
mLTVStd,
+ mLTXTPage,
+ mLTXTChan,
};
int error(error_code e);
Modified: trunk/2010/2_71x6.cc
==============================================================================
--- trunk/2010/2_71x6.cc (original)
+++ trunk/2010/2_71x6.cc Wed Jul 4 09:50:51 2007
@@ -318,14 +318,17 @@ void setStdScale(void){
int i;
mc=1;
- xresc=vgax<<mc;
-
- wndx=vgax;
- if(TVStd==TXTPAL)
- scales_y=0x1 , scalee_y=0x1;
- else
+ if(TVStd==TXTPAL){
+ scales_y=0x0 , scalee_y=0x0 -288 + 20;
+ xresc=vgax<<(mc+2);
+ wndx=768;
+ }
+ else{
scales_y=0x11, scalee_y=0x11;
+ xresc=vgax<<mc;
+ wndx=vgax;
+ }
if(TVStd==NTSC)
y_field=240-scales_y+scalee_y, x_field=640-scales_x+scalee_x;
@@ -336,8 +339,9 @@ void setStdScale(void){
else oneField=false;
int yrest;
- if((cryptStd!=nag && TVStd!=TXTPAL) || vgay-70 > y_field) yrest= vgay;
- else yrest= vgay << 1;
+ if(TVStd==TXTPAL) yrest= 40;
+ else if(cryptStd!=nag || vgay-70 > y_field) yrest= vgay;
+ else yrest= vgay << 1;
if (!oneField && yrest>y_field*2){
outy= y_field*2;
@@ -351,28 +355,35 @@ void setStdScale(void){
outy= yrest;
}
- if(TVStd==TXTPAL) wndx=vgax;
-
- if(wndx > vgax){
+ if(wndx > vgax && TVStd!=TXTPAL){
// outy= int( double(outy) * double(x_field) / double(vgax) ); // ?! JOKE
wndx= vgax;
}
if(wndx>x_field) wndx=x_field; // no scaling !?
- wndx =(wndx + 7) & 0x3F8;
- outy=(outy + 1) & 0x3FE;
+ wndx =(wndx + 7) & 0x3F8;
+ outy =(outy + 1) & 0x3FE;
- if(wndx > vgax ) vgax -=8;
+ if(wndx > vgax ) wndx-=8;
if(outy > yrest) outy-=2;
- if(!oneField) stride=(vgax + vgax - wndx)<<mc;
- else stride=(vgax - wndx)<<mc;
+ if(TVStd==TXTPAL) stride=((vgax<<3) - wndx)<<mc;
+ else if(!oneField) stride=((vgax<<1) - wndx)<<mc;
+ else stride=( vgax - wndx)<<mc;
if((cryptStd!=nag && TVStd!=TXTPAL) || vgay-70 > y_field) wndy= outy;
else wndy= outy >> 1;
+ if(TVStd==TXTPAL) write_saa7196(0x06, 0xC6);
+ else write_saa7196(0x06, 0x46);
+ /* 7 Input mode =0 CVBS, =1 S-Video
+ 6 Pre filter
+ 5:4 Aperture Bandpass characteristics
+ 3:2 Coring range for high freq
+ 1:0 Aperture bandpass filter weights */
+
if(TVStd==SECAM) write_saa7196(0x0D, 0x85);
else write_saa7196(0x0D, 0x84);
/* 7 VTR/TV mode bit = 1->VTR mode
@@ -414,7 +425,7 @@ void setStdScale(void){
/* 7:0 [7:0] Pixel number per line on input */
write_saa7196(0x23, scales_x);/* 7:0 [7:0] Horizontal start position of scaling win*/
i=saa7196_buf[0x24] & 0xE0;
- i=(some<<5) & 0xE0;
+ if(TVStd==TXTPAL) i=4;
write_saa7196(0x24, i | ((x_field>>6) & 0x0C) | (wndx>>8));
/* 7:5 Horizontal decimation filter
4 [8] Horizontal start position of scaling win
@@ -426,9 +437,8 @@ void setStdScale(void){
write_saa7196(0x26, y_field & 0xFF);
/* 7:0 [7:0] Line number per input field */
write_saa7196(0x27, scales_y);/* 7:0 [7:0] Vertical start of scaling window */
-// i=saa7196_buf[0x28] & 0xE0;
if(TVStd==TXTPAL) i=0;
- else i=0x80;
+ else i=saa7196_buf[0x28] & 0xE0;
if(oneField) write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>8));
else write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>9));
/* 7 Adaptive filter switch
@@ -529,17 +539,6 @@ void init_meteor(void){
write_saa7196(0x04, 0xB6);/* 7:0 Horizontal Sync Clamp Stop for 50hz */
write_saa7196(0x05, 0xF4);/* 7:0 Horizontal Sync Start after PH1 for 50hz */
-
-#ifndef NoColorDeco
- write_saa7196(0x06, 0x46); //46
-#else
- write_saa7196(0x06, 0xC6); //46
-#endif
- /* 7 Input mode =0 CVBS, =1 S-Video
- 6 Pre filter
- 5:4 Aperture Bandpass characteristics
- 3:2 Coring range for high freq
- 1:0 Aperture bandpass filter weights */
write_saa7196(0x07, 0x00);/* 7:0 Hue */
write_saa7196(0x08, 0x7F);/* 7:3 Colour-killer threshold QAM (PAL, NTSC) */
write_saa7196(0x09, 0x7F);/* 7:3 Colour-killer threshold SECAM */
@@ -554,12 +553,8 @@ void init_meteor(void){
2 S-VHS bit
1 GPSW2
0 GPSW1 */
-//write_saa7196(0x10, 0x02);
-#ifndef NoColorDeco
+// write_saa7196(0x10, 0x04);
write_saa7196(0x10, 0x00);
-#else
- write_saa7196(0x10, 0x04);
-#endif
/* 2 Select HREF Position
1:0 Vertical noise reduction */
write_saa7196(0x11, 0x2C);/* 7:0 Chrominance gain conrtol for QAM */
Modified: trunk/2010/2_all.h
==============================================================================
--- trunk/2010/2_all.h (original)
+++ trunk/2010/2_all.h Wed Jul 4 09:50:51 2007
@@ -68,15 +68,48 @@ class color{
public:
COL col;
color(void) { };
+ color(int y, int u, int v, byte yuv_mode) {init(y,u,v,yuv_mode);};
void init(int y, int u, int v, byte yuv_mode){ // fix (yuv_mode==0)
- col.yuv= u | (y<<8) | (v<<16) | (y<<24);
col.r=minmax(0, int( y + 1.375 *v ), 255);
- col.g=minmax(0, int( y - 0.703125*v - 0.34375*u ), 255);
+ col.g=minmax(0, int( y - 0.703125*v - 0.34375 *u), 255);
col.b=minmax(0, int( y + 1.734375*u), 255);
const int r5= ((col.r>>3) & 0x1F);
const int g6= ((col.g>>2) & 0x3F);
const int b5= ((col.b>>3) & 0x1F);
+/*
+ r=y + (+ 1.375 )*v
+ g=y + (- 0.703125)*v + (- 0.34375 )*u
+ b=y + (+ 1.734375)*u
+
+ r =y + (+ 1.375 )*v
+ (-1)r + g= + (- 2.078125)*v + (- 0.34375 )*u
+ (-1)r + b= + (- 1.375 )*v + (+ 1.734375)*u
+
+ r =y + (+ 1.375 )*v
+ (-1)r + g= + (- 2.078125)*v + (- 0.34375 )*u
+ (-1)r + b= + (- 1.375 )*v + (+ 1.734375)*u
+ (+ .481203)r + (- .481203)g= + v + (+ 0.165414)*u
+
+ r =y + (+ 1.375 )*v
+ (-1)r + g= + (- 2.078125)*v + (- 0.34375 )*u
+ (-1)r + b= + (- 1.375 )*v + (+ 1.734375)*u
+ (+ .481203)r + (- .481203)g= + v + (+ 0.165414)*u
+ (+ .661654)r + (- .661664)g= + (+ 1.375 )v + (+ 0.227444)*u
+ (- .661654)r + (+ .661664)g= + (- 1.375 )v + (- 0.227444)*u
+
+ (+ .338346)r + (+ .661664)g + =y + + (- 0.227444)*u
+ (+ .481203)r + (- .481203)g + = + v + (+ 0.165414)*u
+ (- .338346)r + (- .661664)g + b= + + (+ 1.961819)*u
+
+ (+ .338346)r + (+ .661664)g + =y + + (- 0.227444)*u
+ (+ .481203)r + (- .481203)g + = + v + (+ 0.165414)*u
+ (- .172465)r + (- .337271)g + (+ 0.509731)b= + + u
+ (- .172465)(- 0.227444)r + (- .337271)(- 0.227444)g + (+ 0.509731)(- 0.227444)b= + + u(- 0.227444)
+ (- .172465)(+ 0.165414)r + (- .337271)(+ 0.165414)g + (+ 0.509731)(+ 0.165414)b= + + u(+ 0.165414)
+ */
+
col.rgb16= b5 | (g6<<5) | (r5<<11);
+ col.yuv= u | (y<<8) | (v<<16) | (y<<24);
};
} ;
Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cc Wed Jul 4 09:50:51 2007
@@ -7,6 +7,7 @@
#include "2_crypt.h"
#include "2_vc.h"
#include "2_nag.h"
+#include "2_txt.h"
#include "2_71x6.h"
#include "2_gfunc.h"
@@ -52,6 +53,7 @@ void decrypt(void){
if(cryptStd==vc) vc_decrypt();
else if(cryptStd==nag) nag_decrypt();
+ else if(TVStd==TXTPAL) txt_decrypt();
if(iState){
T2=uclock();
Modified: trunk/2010/2_crypt.h
==============================================================================
--- trunk/2010/2_crypt.h (original)
+++ trunk/2010/2_crypt.h Wed Jul 4 09:50:51 2007
@@ -5,6 +5,10 @@
#define max_x 900
#define max_y 700
+#define FREQ_CHROM 4433618.75
+#define FREQ_HS 15625.0
+#define FREQ_PIX (FREQ_HS * 1888.0 * 0.5)
+
void decrypt(void);
#endif
Modified: trunk/2010/2_gfunc.cc
==============================================================================
--- trunk/2010/2_gfunc.cc (original)
+++ trunk/2010/2_gfunc.cc Wed Jul 4 09:50:51 2007
@@ -5,7 +5,7 @@
#include "2_all.h"
#include "2_gfunc.h"
- extern int vgax, vgay, xresc;
+ extern int vgax, vgay, xresc, mc;
extern int fysize;
extern byte font[4096];
extern int g_mode;
@@ -86,6 +86,8 @@ void gprint(int xp, int yp, const COL c,
//FIX ME TEST reg, imm is NP
+ static int vgaxmc;
+ vgaxmc= vgax<<mc;
if(yuvmode!=0){
asm(//"int $3\n\t"
"pushl %%ebp \n\t"
@@ -154,7 +156,7 @@ void gprint(int xp, int yp, const COL c,
"popl %%eax \n\t"
"popl %%ebp \n\t"
:
- : "m" (fysize), "m"(xresc), "m" (&font), "m" (clipyp), "m" (clipym),
+ : "m" (fysize), "m"(vgaxmc), "m" (&font), "m" (clipyp), "m" (clipym),
"a" (c.yuv), "c" (text), "d" (((u_long)actVid2MemBufp->b)+((xp+yp*vgax)<<1))
: "%ebx", "%ecx", "%edx", "%esi", "%edi");
}else{
@@ -213,7 +215,7 @@ void gprint(int xp, int yp, const COL c,
"jmp 10b \n\t"
"9: \n\t"
:
- : "m" (fysize), "m"(xresc), "m" (&font), "m" (clipyp), "m" (clipym),
+ : "m" (fysize), "m"(vgaxmc), "m" (&font), "m" (clipyp), "m" (clipym),
"a" (c.rgb16), "c" (text), "d" (((u_long)actVid2MemBufp->b)+((xp+yp*vgax)<<1))
: "%ebx", "%ecx", "%edx", "%esi", "%edi");
}
Modified: trunk/2010/2_grafix.cc
==============================================================================
--- trunk/2010/2_grafix.cc (original)
+++ trunk/2010/2_grafix.cc Wed Jul 4 09:50:51 2007
@@ -35,13 +35,19 @@ void showStuff(void){
color c;
if(helpState){
- char text[6][256]={ "F1/F2 Brightness s TVStandart",
- "F3/F4 Contrast i debugInfo",
- "F5/F6 Saturation h Help",
- "g ScreenShot q Quit",
- "v smoothIterlace p Pause",
- "d allowDrop"};
- for(int i=0; i<6; i++){
+ char text[11][256]={ "F1/F2 Brightness s TVStandart",
+ "F3/F4 Contrast i debugInfo",
+ "F5/F6 Saturation h Help",
+ "g ScreenShot q Quit",
+ "v smoothIterlace p Pause",
+ "d allowDrop",
+ " TELETXT:",
+ "+ Page+ - Page-",
+ "right subPage+ left subPage-",
+ "up Channel+ down Channel-",
+ "c txt Channel a num Page" };
+
+ for(int i=0; i<11; i++){
c.init(255, 0, 0, yuvmode);
gprint(infoPosX, infoPosY+=10, c.col, text[i]);
}
Modified: trunk/2010/2_hw.cc
==============================================================================
--- trunk/2010/2_hw.cc (original)
+++ trunk/2010/2_hw.cc Wed Jul 4 09:50:51 2007
@@ -39,6 +39,7 @@
extern bool strangeRgb16;
extern bool iState;
extern int infoPosX, infoPosY;
+ extern TVSTD TVStd;
bool drop=false;
bool allowDrop=true;
@@ -309,25 +310,27 @@ void copy_vidbuffer(void){
}
if(!drop || !allowDrop){
+ const int goodx= TVStd!=TXTPAL ? wndx : vgax;
+ const int goody= TVStd!=TXTPAL ? wndy : vgay;
if(page_flip==0){
int p=0;
- for(int y=0; y<wndy; y++){
- mem2vid(vidbuf+p, actVid2MemBufp->b+p, wndx, bpp);
+ for(int y=0; y<goody; y++){
+ mem2vid(vidbuf+p, actVid2MemBufp->b+p, goodx, bpp);
p+=vgax<<1;
}
}else if(page_flip==2){
int p=0;
- for(int y=0; y<wndy; y++){
- mem2vid(vidbuf+xresvb*vgay+p, actVid2MemBufp->b+p, wndx, bpp);
+ for(int y=0; y<goody; y++){
+ mem2vid(vidbuf+xresvb*vgay+p, actVid2MemBufp->b+p, goodx, bpp);
p+=vgax<<1;
}
page_flip=1;
set_start_disp(0, vgay);
}else{
int p=0;
- for(int y=0; y<wndy; y++){
- mem2vid(vidbuf+p, actVid2MemBufp->b+p, wndx, bpp);
+ for(int y=0; y<goody; y++){
+ mem2vid(vidbuf+p, actVid2MemBufp->b+p, goodx, bpp);
p+=vgax<<1;
}
page_flip=2;
Added: trunk/2010/2_txt.cc
==============================================================================
--- (empty file)
+++ trunk/2010/2_txt.cc Wed Jul 4 09:50:51 2007
@@ -0,0 +1,378 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+
+#include <string.h>
+#include <stdio.h>
+#include <math.h>
+#include <ctype.h>
+#include "2_all.h"
+#include "2010.h"
+#include "2_crypt.h"
+#include "2_gfunc.h"
+#include "2_txt.h"
+
+extern int vgax, vgay, wndx, wndy, mc, x_field;
+extern bool iState, helpState;
+extern volatile scales_x, scalee_x;
+extern volatile scales_y, scalee_y;
+extern VID2MEMBUF *actVid2MemBufp;
+extern int some;
+extern int yuvmode;
+extern int infoPosX, infoPosY;
+
+#define FREQ_TXT 6.9375E6
+#define FIXP_SH 16
+#define ONE_FIXP (1<<FIXP_SH)
+#define BYTES 42
+
+char reqChanStr[16];
+int reqChanNum=0;
+int reqPage=0x100;
+int reqSubPage=0;
+
+static inline float atan3(const float f1, const float f2){
+ float out;
+ // ?! atan2 crashes
+ asm(//"int $3\n\t"
+ "fpatan \n\t"
+ : "=t"(out)
+ : "0"(f2), "u"(f1)
+ : "st(1)"
+ );
+
+ return out;
+}
+
+static signed char corrHamm48[256]={
+ 0x01, 0xff, 0x01, 0x01, 0xff, 0x00, 0x01, 0xff, 0xff, 0x02, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x07,
+ 0xff, 0x00, 0x01, 0xff, 0x00, 0x00, 0xff, 0x00, 0x06, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x03, 0xff,
+ 0xff, 0x0c, 0x01, 0xff, 0x04, 0xff, 0xff, 0x07, 0x06, 0xff, 0xff, 0x07, 0xff, 0x07, 0x07, 0x07,
+ 0x06, 0xff, 0xff, 0x05, 0xff, 0x00, 0x0d, 0xff, 0x06, 0x06, 0x06, 0xff, 0x06, 0xff, 0xff, 0x07,
+ 0xff, 0x02, 0x01, 0xff, 0x04, 0xff, 0xff, 0x09, 0x02, 0x02, 0xff, 0x02, 0xff, 0x02, 0x03, 0xff,
+ 0x08, 0xff, 0xff, 0x05, 0xff, 0x00, 0x03, 0xff, 0xff, 0x02, 0x03, 0xff, 0x03, 0xff, 0x03, 0x03,
+ 0x04, 0xff, 0xff, 0x05, 0x04, 0x04, 0x04, 0xff, 0xff, 0x02, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x07,
+ 0xff, 0x05, 0x05, 0x05, 0x04, 0xff, 0xff, 0x05, 0x06, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x03, 0xff,
+ 0xff, 0x0c, 0x01, 0xff, 0x0a, 0xff, 0xff, 0x09, 0x0a, 0xff, 0xff, 0x0b, 0x0a, 0x0a, 0x0a, 0xff,
+ 0x08, 0xff, 0xff, 0x0b, 0xff, 0x00, 0x0d, 0xff, 0xff, 0x0b, 0x0b, 0x0b, 0x0a, 0xff, 0xff, 0x0b,
+ 0x0c, 0x0c, 0xff, 0x0c, 0xff, 0x0c, 0x0d, 0xff, 0xff, 0x0c, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x07,
+ 0xff, 0x0c, 0x0d, 0xff, 0x0d, 0xff, 0x0d, 0x0d, 0x06, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x0d, 0xff,
+ 0x08, 0xff, 0xff, 0x09, 0xff, 0x09, 0x09, 0x09, 0xff, 0x02, 0x0f, 0xff, 0x0a, 0xff, 0xff, 0x09,
+ 0x08, 0x08, 0x08, 0xff, 0x08, 0xff, 0xff, 0x09, 0x08, 0xff, 0xff, 0x0b, 0xff, 0x0e, 0x03, 0xff,
+ 0xff, 0x0c, 0x0f, 0xff, 0x04, 0xff, 0xff, 0x09, 0x0f, 0xff, 0x0f, 0x0f, 0xff, 0x0e, 0x0f, 0xff,
+ 0x08, 0xff, 0xff, 0x05, 0xff, 0x0e, 0x0d, 0xff, 0xff, 0x0e, 0x0f, 0xff, 0x0e, 0x0e, 0xff, 0x0e };
+
+static signed char fixParity[256];
+
+static inline int sample(byte *b, int fixpPos){
+ const int ndx = fixpPos>>FIXP_SH;
+ const int frac = fixpPos & (ONE_FIXP-1);
+
+ const int a1= int(b[ ndx<<1 ]) * (ONE_FIXP - frac);
+ const int a2= int(b[(ndx<<1) + 2]) * ( frac);
+
+ return (a1+a2) >> FIXP_SH;
+}
+
+
+void txt_decrypt(void){
+ char textbuf[9][128];
+ color c;
+
+ static int hammErr=0;
+
+ const double freqPix2= double(wndx) / double(x_field) * FREQ_PIX;
+ const int delta= int(freqPix2/FREQ_TXT*ONE_FIXP);
+ const double angDelta= FREQ_TXT/freqPix2*PI;
+
+// byte rawMagic[16]={255, 0, 255, 0, 255, 0, 255, 0,
+// 255, 255, 255, 0, 0, 255, 0, 0 };
+
+ static CACHE1 *cache1=new CACHE1[1024];
+ static int cache1Size=0;
+ static bool first=true;
+ static color txtCol[8];
+ if(first){
+ FILE *f= fopen("chaninf.txt", "rb");
+ if(f==NULL) error(TxtFile);
+ while(!feof(f)){
+ fscanf(f, "%11[^\n]\n", cache1[cache1Size].chan);
+ cache1[cache1Size].pt= NULL;
+ cache1Size++;
+ }
+
+ for(int i=0; i<256; i++){
+ int j=i&0x7F;
+ j^= j+j;
+ j^= j<<2;
+ j^= j<<4;
+ fixParity[i]= i ^ (j&0x80) ^ 0x80;
+ }
+ // FIX OVERFLOWS ...
+ txtColor[0].init( 0, 0, 0, yuvmode);
+ txtColor[1].init(255, 0, 0, yuvmode);
+ txtColor[2].init(255, 0, 0, yuvmode);
+ txtColor[3].init(255, 0, 0, yuvmode);
+ txtColor[4].init(255, 0, 0, yuvmode);
+ txtColor[5].init(255, 0, 0, yuvmode);
+ txtColor[6].init(255, 0, 0, yuvmode);
+ txtColor[7].init(255, 0, 0, yuvmode);
+ first=false;
+ }
+
+ static CACHE2 *mag[8]={NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
+
+ byte data[64];
+
+ int linep=-(vgax<<4);
+ for(int line=0; line<40; line++){
+ linep+=vgax<<4;
+ if(line==20) linep=vgax<<3;
+
+
+ int avg=0;
+ for(int x=0; x<50; x++){
+ avg+=actVid2MemBufp->b[linep + (x<<1) + 1];
+ }
+ avg/=50;
+
+ // FIX ? optimize in fixp and lut ...
+ double si=0, co=0;
+ double ang=0;
+ for(int x=0; x<10; x++){
+ const int amp= actVid2MemBufp->b[linep + (x<<1) + 1];
+ si+= sin(ang)*(amp-avg);
+ co+= cos(ang)*(amp-avg);
+ ang+= angDelta;
+ }
+ int xFixp= int(atan3(si,co)/PI*freqPix2/FREQ_TXT*ONE_FIXP);
+
+
+ const int magic= 0xAAE4;
+
+ int r=0;
+ int x=xFixp>>FIXP_SH;
+ while(x < 70){
+ r=(r<<1) & 0xFFFF;
+
+ int score= sample( &actVid2MemBufp->b[linep + 1], xFixp );
+
+ if(score > avg) r|=1;
+ actVid2MemBufp->b[linep + (x<<1) + 1]= (r&1)*255;
+ xFixp+=delta;
+ x=xFixp>>FIXP_SH;
+ if(r==magic) break;
+ }
+
+ if(x>=70) continue;
+
+/*
+ actVid2MemBufp->b[linep + (x<<1) ]= 128;
+ actVid2MemBufp->b[linep + (x<<1) + 1]= 255;
+ actVid2MemBufp->b[linep + (x<<1) + 2]= 0 ;
+ actVid2MemBufp->b[linep + (x<<1) + 3]= 255;
+
+ continue;
+*/
+ r=0;
+
+ for(int decoded=1; decoded<=(BYTES<<3); decoded++){
+ r>>=1;
+
+ int score= sample( &actVid2MemBufp->b[linep + 1], xFixp );
+
+ if(score > avg) r|=0x80;
+ actVid2MemBufp->b[linep + (x<<1) + 1]= (r&0x80)/0x80*255;
+
+ if(!(decoded & 0x07)){
+ data[(decoded>>3) - 1]=r;
+ r=0;
+ }
+
+ xFixp+=delta;
+ x=xFixp>>FIXP_SH;
+ }
+
+ const int d0= corrHamm48[ data[0] ];
+ const int d1= corrHamm48[ data[1] ];
+
+ if(d0<0 || d1<0){ hammErr++; continue;}
+
+ const int magAddr= d0 & 0x7;
+ const int rowAddr= (d0>>3) | (d1<<1);
+
+ if(rowAddr==0){
+ const int d2= corrHamm48[ data[2] ];
+ const int d3= corrHamm48[ data[3] ];
+ const int d4= corrHamm48[ data[4] ];
+ const int d5= corrHamm48[ data[5] ];
+ const int d6= corrHamm48[ data[6] ];
+ const int d7= corrHamm48[ data[7] ];
+ const int d8= corrHamm48[ data[8] ];
+ const int d9= corrHamm48[ data[9] ];
+
+ if(d2<0 || d3<0 || d4<0 || d5<0 || d6<0 || d7<0 || d8<0 || d9<0){ hammErr++; continue;}
+
+ const int lsPage = d2 | (d3<<4);
+ const int subPage=(d4 | (d5<<4) | (d6<<8) | (d7<<12)) & 0x3F7F;
+ const int page =(magAddr<<8) | lsPage;
+
+ for(int i=10; i<BYTES; i++){
+ data[i]= fixParity[ data[i] ];
+ }
+
+ int bestLen=0;
+ int best=0;
+ int cache1Ndx;
+ for(cache1Ndx=0; cache1Ndx<cache1Size; cache1Ndx++){
+ for(int tryp=10; tryp<BYTES-8; tryp++){
+ for(int pos=0;; pos++){
+ if(pos+tryp>=BYTES-8) break;
+ if(cache1[cache1Ndx].chan[pos] == 0) {
+ if(pos>bestLen){
+ bestLen=pos;
+ best=cache1Ndx;
+ }
+ break;
+ }
+ if( toupper(cache1[cache1Ndx].chan[pos]) != toupper(data[tryp+pos])
+ && cache1[cache1Ndx].chan[pos] != 0x20
+ && cache1[cache1Ndx].chan[pos] != 0x0D) break;
+ }
+ }
+ }
+
+ if(bestLen==0){
+ printf(" ERR Unknown Stuff: %32s\n", &data[10]);
+ mag[magAddr]=NULL;
+ continue;
+ }
+ cache1Ndx=best;
+
+ if(cache1[cache1Ndx].pt==NULL){
+ cache1[cache1Ndx].pt= new CACHE2*[0x800];
+ for(int i=0; i<0x800; i++) cache1[cache1Ndx].pt[i]=NULL;
+ }
+
+ if(cache1[cache1Ndx].pt[page]==NULL){
+ cache1[cache1Ndx].pt[page]= new CACHE2;
+ cache1[cache1Ndx].pt[page]->next=NULL;
+ cache1[cache1Ndx].pt[page]->seen=false;
+ memset(cache1[cache1Ndx].pt[page]->text, ' ', 40*LINES);
+ mag[magAddr]= cache1[cache1Ndx].pt[page];
+ }
+ else{
+ CACHE2 *p=cache1[cache1Ndx].pt[page];
+ while(p->next!=NULL && p->next->sub<=subPage) p=p->next;
+
+ if(p->sub==subPage) mag[magAddr]= p;
+ else{
+ CACHE2 *temp= new CACHE2;
+ memset(temp->text, ' ', 40*LINES);
+
+ if(p->sub<subPage){
+ temp->next= p->next;
+ p->next= temp;
+ }
+ else{
+ temp->next= cache1[cache1Ndx].pt[page];
+ cache1[cache1Ndx].pt[page]= temp;
+ }
+
+ temp->seen=false;
+ mag[magAddr]= temp;
+ }
+ }
+
+ mag[magAddr]->sub=subPage;
+ memcpy(&mag[magAddr]->text[rowAddr*40], data+10, 32);
+
+ }
+ else if(rowAddr<LINES){
+ if(mag[magAddr]==NULL) continue;
+
+ for(int i=2; i<BYTES; i++){
+ data[i]= fixParity[ data[i] ];
+ }
+ memcpy(&mag[magAddr]->text[rowAddr*40], data+2, 40);
+
+ }
+
+
+ }
+
+
+ memset(actVid2MemBufp->b, 0, vgax*vgay<<mc);
+
+ if(iState || helpState) return;
+
+ static int lastReqPage=-1, lastReqSubPage=-1, lastReqChanNum=-1;
+
+ // FIX reqChanStr
+ // FIX add noAutoSeek
+
+ const int seekChanDelta= (reqChanNum < lastReqChanNum) ? -1 : 1;
+ const int seekPageDelta= (reqPage < lastReqPage ) ? -1 : 1;
+ const int seekSubPageDelta= (reqSubPage < lastReqSubPage) ? -1 : 1;
+
+ reqPage&=0x7FF;
+ if(reqSubPage<0) reqSubPage=0;
+ if(reqChanNum<0) reqChanNum=0;
+ if(reqChanNum>=cache1Size) reqChanNum=cache1Size-1;
+
+ int start=reqChanNum;
+ do{
+ if(cache1[reqChanNum].pt!=NULL) break;
+ reqChanNum+= seekChanDelta;
+ if(reqChanNum<0 ) reqChanNum= cache1Size-1;
+ if(reqChanNum>=cache1Size) reqChanNum= 0;
+ }while(start!=reqChanNum);
+
+ if(cache1[reqChanNum].pt==NULL) return;
+
+ start=reqPage;
+ do{
+ if(cache1[reqChanNum].pt[reqPage]!=NULL) break;
+ reqPage+= seekPageDelta;
+ reqPage&= 0x7FF;
+ }while(start!=reqPage);
+
+ if(cache1[reqChanNum].pt[reqPage]==NULL) return;
+
+ CACHE2 *p=cache1[reqChanNum].pt[reqPage];
+ CACHE2 *largep=p, *smallp=p;
+
+ while(p!=NULL){
+ if(p->sub==reqSubPage) break;
+ largep=p;
+ p=p->next;
+ }
+
+ if(p==NULL || p->sub!=reqSubPage){
+ if(largep->sub<reqSubPage) largep=smallp;
+ if(smallp->sub>reqSubPage) smallp=largep;
+ if(seekSubPageDelta>0) p=largep;
+ else p=smallp;
+ }
+
+ reqSubPage=p->sub;
+
+ for(int i=0; i<LINES; i++){
+// int colorNdx=
+
+ sprintf(textbuf[0],"%40s", &p->text[i*40]);
+ c.init(255, 0, 0, yuvmode);
+ gprint(10, infoPosY+=10, c.col, textbuf[0]);
+
+ }
+// printf("bad ham's %d\n", hammErr);
+
+
+ lastReqPage= reqPage;
+ lastReqSubPage=reqSubPage;
+ lastReqChanNum=reqChanNum;
+
+ infoPosY+=5;
+
+}
+
+
+
Added: trunk/2010/2_txt.h
==============================================================================
--- (empty file)
+++ trunk/2010/2_txt.h Wed Jul 4 09:50:51 2007
@@ -0,0 +1,21 @@
+//2010 0.1 Copyright (C) Michael Niedermayer 1998
+#ifndef n2_txt_h
+#define n2_txt_h
+
+#define LINES 25
+
+struct CACHE2{
+ int sub;
+ bool seen;
+ char text[LINES*40];
+ CACHE2 *next;
+};
+
+struct CACHE1{
+ char chan[12];
+ CACHE2 **pt;
+};
+
+void txt_decrypt(void);
+
+#endif
Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cc Wed Jul 4 09:50:51 2007
@@ -14,9 +14,6 @@
#include "2010.h"
#define FREQ_SMP 2.1e7
-#define FREQ_CHROM 4433618.75
-#define FREQ_HS 15625.0
-#define FREQ_PIX (FREQ_HS * 1888.0 * 0.5)
#define POINT_LAND 765.0
#define NO_POINT_LAND1 145.0 // GUESSED!
#define NO_POINT_LAND2 145.0 // GUESSED!
Modified: trunk/2010/makefile
==============================================================================
--- trunk/2010/makefile (original)
+++ trunk/2010/makefile Wed Jul 4 09:50:51 2007
@@ -14,7 +14,7 @@ AFLAGS = -f coff
O = 2010.o 2_file.o 2_grafix.o 2_hw.o 2_gfunc.o \
2_hw_asm.o 2_71x6.o 2_hw_mem.o 2_crypt.o 2_vc.o 2_nag.o\
- 2_nag_a.o 2_vc_a.o 2_glob_a.o
+ 2_nag_a.o 2_vc_a.o 2_glob_a.o 2_txt.o
2010 : $(O) ; gcc $(CFLAGS) -o 2010 $(O)
clean: ; del $(O) 2010
@@ -28,10 +28,11 @@ clean: ; del $(O) 2010
2_71x6.h 2_mmx.h
2_hw_mem.o : 2_hw_mem.cc 2_all.h 2_hw_mem.h 2010.h
2_71x6.o : 2_71x6.cc 2_all.h 2_71x6.h 2_hw.h 2_hw_mem.h 2010.h 2_hw_asm.h
-2_crypt.o : 2_crypt.cc 2_all.h 2_crypt.h 2_71x6.h 2_vc.h 2_nag.h
+2_crypt.o : 2_crypt.cc 2_all.h 2_crypt.h 2_71x6.h 2_vc.h 2_nag.h 2_txt.h
2_vc.o : 2_vc.cc 2_all.h 2_vc.h 2_crypt.h 2_gfunc.h 2_vc_a.h
2_nag.o : 2_nag.cc 2_all.h 2_nag.h 2_crypt.h 2_gfunc.h 2_mmx.h 2_nag_a.h\
2010.h 2_hw_mem.h
+2_txt.o : 2_txt.cc 2_all.h 2_txt.h 2_crypt.h 2_gfunc.h 2010.h
2_hw_asm.o : 2_hw_asm.s
1
0
[mndiff]: r54 - in trunk/2010: 2010.cc 2_71x6.cc 2_71x6.h 2_crypt.cc 2_grafix.cc 2_hw.cc 2_nag.cc 2_nag.h 2_vc.cc
by michael 04 Jul '07
by michael 04 Jul '07
04 Jul '07
Author: michael
Date: Wed Jul 4 09:37:52 2007
New Revision: 54
Log:
version from 1998-11-01 20:54
Modified:
trunk/2010/2010.cc
trunk/2010/2_71x6.cc
trunk/2010/2_71x6.h
trunk/2010/2_crypt.cc
trunk/2010/2_grafix.cc
trunk/2010/2_hw.cc
trunk/2010/2_nag.cc
trunk/2010/2_nag.h
trunk/2010/2_vc.cc
Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cc Wed Jul 4 09:37:52 2007
@@ -12,6 +12,7 @@
#include <crt0.h>
#include <ctype.h>
#include <signal.h>
+#include <time.h>
#include "2_all.h"
#include "2010.h"
#include "2_hw.h"
@@ -43,10 +44,12 @@
extern TVSTD TVStd;
extern bool iState;
extern bool helpState;
+ extern bool allowDrop;
int maxBuf=2;
int some=0;
+
int _crt0_startup_flags = _CRT0_FLAG_NEARPTR | _CRT0_FLAG_NONMOVE_SBRK;
int grabf;
int fysize;
@@ -56,8 +59,17 @@ int _crt0_startup_flags = _CRT0_FLAG_NEA
int *yuv2RgbLut;
int edge_lut[256];
MENULEVEL menuLevel=mLNorm;
+ int infoPosX;
int infoPosY;
bool strangeRgb16= true; // commandLineOpt FIX
+ long uclockWaste;
+
+static inline void getUclockWaste(void){
+ long T1=uclock();
+ for(int i=0; i<1000; i++) uclock();
+ uclockWaste= (uclock()-T1)/1000;
+ printf("uclockWaste %d\n", int(uclockWaste));
+}
void printg_t(char *text){
close_hw();
@@ -314,12 +326,14 @@ int main(int argc, char **argv){
init_hw();
init_meteor();
+ getUclockWaste();
static int delay=0;
bool quit=false;
while(!quit){
infoPosY=0;
+ infoPosX=10;
decrypt();
showStuff();
@@ -337,6 +351,9 @@ int main(int argc, char **argv){
switch(menuLevel){
case mLNorm : switch(key){
+ case 'p' :
+ case 'P' : getkey();
+ break;
case 'g' :
case 'G' : key=0, grabf=1;
break;
@@ -385,6 +402,9 @@ int main(int argc, char **argv){
case 'h' :
case 'H' : helpState= !helpState;
break;
+ case 'd' :
+ case 'D' : allowDrop= !allowDrop;
+ break;
case '1' : delay++;
break;
case '2' : delay--; if(delay<0) delay=0;
@@ -424,7 +444,13 @@ int main(int argc, char **argv){
case '5' : TVStd= PAL;
cryptStd= nag;
if(yuvmode==0) yuvmode=1;
- //if(oneField && yuvmode==2) error(MemAlloc);
+ vSmoothState=false;
+ setStdScale();
+ contGrab();
+ break;
+ case '6' : TVStd= TXTPAL;
+ cryptStd= nix;
+ if(yuvmode==0) yuvmode=1;
vSmoothState=false;
setStdScale();
contGrab();
Modified: trunk/2010/2_71x6.cc
==============================================================================
--- trunk/2010/2_71x6.cc (original)
+++ trunk/2010/2_71x6.cc Wed Jul 4 09:37:52 2007
@@ -43,14 +43,13 @@ extern volatile int stride;
extern volatile bool oneField;
extern int wndx, wndy, outy;
extern int single;
+extern int some;
extern int vgax, vgay;
int v_smooth=1;
int bright=0x80, satur=0x40, contr=0x40;
-//int scales_x=0x03, scales_y= 0x11;
-//int scalee_x=0x03, scalee_y= 0x11;
int scales_x=0x03, scales_y= 0x11;
int scalee_x=0x03, scalee_y= 0x11;
@@ -318,24 +317,27 @@ void setStdScale(void){
saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
int i;
-/* if(yuvmode!=0) mc=1;
- else mc=2;*/
mc=1;
xresc=vgax<<mc;
wndx=vgax;
+ if(TVStd==TXTPAL)
+ scales_y=0x1 , scalee_y=0x1;
+ else
+ scales_y=0x11, scalee_y=0x11;
+
if(TVStd==NTSC)
y_field=240-scales_y+scalee_y, x_field=640-scales_x+scalee_x;
else
y_field=288-scales_y+scalee_y, x_field=768-scales_x+scalee_x;
- if(vgay-70 <= y_field && cryptStd!=nag) oneField=true;
- else oneField=false;
+ if(vgay-70 <= y_field && (cryptStd!=nag && TVStd!=TXTPAL)) oneField=true;
+ else oneField=false;
int yrest;
- if(cryptStd!=nag || vgay-70 > y_field) yrest= vgay;
- else yrest= vgay << 1;
+ if((cryptStd!=nag && TVStd!=TXTPAL) || vgay-70 > y_field) yrest= vgay;
+ else yrest= vgay << 1;
if (!oneField && yrest>y_field*2){
outy= y_field*2;
@@ -349,6 +351,8 @@ void setStdScale(void){
outy= yrest;
}
+ if(TVStd==TXTPAL) wndx=vgax;
+
if(wndx > vgax){
// outy= int( double(outy) * double(x_field) / double(vgax) ); // ?! JOKE
wndx= vgax;
@@ -365,8 +369,8 @@ void setStdScale(void){
if(!oneField) stride=(vgax + vgax - wndx)<<mc;
else stride=(vgax - wndx)<<mc;
- if(cryptStd!=nag || vgay-70 > y_field) wndy= outy;
- else wndy= outy >> 1;
+ if((cryptStd!=nag && TVStd!=TXTPAL) || vgay-70 > y_field) wndy= outy;
+ else wndy= outy >> 1;
if(TVStd==SECAM) write_saa7196(0x0D, 0x85);
@@ -410,6 +414,7 @@ void setStdScale(void){
/* 7:0 [7:0] Pixel number per line on input */
write_saa7196(0x23, scales_x);/* 7:0 [7:0] Horizontal start position of scaling win*/
i=saa7196_buf[0x24] & 0xE0;
+ i=(some<<5) & 0xE0;
write_saa7196(0x24, i | ((x_field>>6) & 0x0C) | (wndx>>8));
/* 7:5 Horizontal decimation filter
4 [8] Horizontal start position of scaling win
@@ -421,7 +426,9 @@ void setStdScale(void){
write_saa7196(0x26, y_field & 0xFF);
/* 7:0 [7:0] Line number per input field */
write_saa7196(0x27, scales_y);/* 7:0 [7:0] Vertical start of scaling window */
- i=saa7196_buf[0x28] & 0xE0;
+// i=saa7196_buf[0x28] & 0xE0;
+ if(TVStd==TXTPAL) i=0;
+ else i=0x80;
if(oneField) write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>8));
else write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>9));
/* 7 Adaptive filter switch
@@ -436,6 +443,7 @@ void setStdScale(void){
printf("%d %d %d %d %d %d %d %d\n",vgax, vgay , wndx, wndy, outy,
y_field , x_field, stride);
+ // FIX (clear vga mem)
}
void init_meteor(void){
Modified: trunk/2010/2_71x6.h
==============================================================================
--- trunk/2010/2_71x6.h (original)
+++ trunk/2010/2_71x6.h Wed Jul 4 09:37:52 2007
@@ -11,6 +11,7 @@
enum TVSTD{
PAL,
+ TXTPAL,
NTSC,
SECAM,
};
Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cc Wed Jul 4 09:37:52 2007
@@ -1,11 +1,16 @@
//2010 0.1 Copyright (C) Michael Niedermayer 1998
#include <string.h>
+#include <stdio.h>
+#include <time.h>
#include "2_all.h"
#include "2_crypt.h"
#include "2_vc.h"
#include "2_nag.h"
#include "2_71x6.h"
+#include "2_gfunc.h"
+
+#define COMB_FIX 256
extern volatile TVSTD TVStd;
extern volatile CRYPTSTD cryptStd;
@@ -16,6 +21,9 @@ extern volatile int scales_y, scalee_y;
extern int yuvmode;
extern volatile bool oneField;
extern int satur;
+extern bool iState;
+extern int infoPosX, infoPosY;
+extern int some;
static void vSmooth(void);
static void decomb(int q);
@@ -27,20 +35,40 @@ bool showPoints=false;
void decrypt(void){
+ long T1=0, T2;
+ char textbuf[2][128];
+ if(iState){
+ T1=uclock();
+ }
+
if( cryptStd == nag && satur!=0 ) decomb(0);
if( cryptStd == vc && satur!=0 ) decomb(1);
+ if(iState){
+ T2=uclock();
+ sprintf(textbuf[0],"%f DeComb", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ T1=T2;
+ }
+
if(cryptStd==vc) vc_decrypt();
else if(cryptStd==nag) nag_decrypt();
+ if(iState){
+ T2=uclock();
+ color c;
+ c.init(255, 0, 0, yuvmode);
+ sprintf(textbuf[1],"%f DeCrypt", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[0]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[1]);
+ infoPosY+=5;
+ }
+
if(!oneField && vSmoothState) vSmooth();
}
static void decomb(int q){
- int linep, llinep, line, i;
- int j, k;
int temp[max_x];
const int outy1= outy>>1;
@@ -48,43 +76,105 @@ static void decomb(int q){
const int o=oneField ? 0 : 1;
const int end=oneField ? outy : outy1;
- for(i=0; i<wndx; i++){
- temp[i]=0;
- }
+ for(int i=0; i<wndx; i++) temp[i]=128<<8;
if(q==1){
- linep= stride*256;
- if(o) linep+=vgax<<1;
- for(line=256; line>=0; line--){
- for(i=0; i<wndx; i++){
+ int linep= stride*256;
+ if(o) linep+=vgax<<1;
+ for(int line=256; line>=0; line--){
+ asm(//"int $3 \n\t"
+ "pushl %%ebp \n\t" //U
+ "movl %%eax, %%ebp \n\t" // V 1
+ "addl %%ebp, %%edi \n\t" //U
+ "addl %%ebp, %%esi \n\t" // V 1
+ "addl %%ebp, %%esi \n\t" //U 1
+ "negl %%ebp \n\t" //UV 1
+ "1: \n\t"
+ "xorl %%eax, %%eax \n\t" //U
+ "xorl %%ebx, %%ebx \n\t" // V 1
+ "movb (%%edi, %%ebp ), %%al \n\t" //U
+ "movb 2(%%edi, %%ebp ), %%bl \n\t" // V 1
+ "addb $128, %%al \n\t" //U
+ "addb $128, %%bl \n\t" // V 1
+ "shll $9, %%eax \n\t" //U
+ "movl (%%esi, %%ebp, 2), %%ecx \n\t" // V 1
+ "shll $9, %%ebx \n\t" //U
+ "subl %%ecx, %%eax \n\t" // V 1
+ "movl 4(%%esi, %%ebp, 2), %%edx \n\t" //U
+ "cmpl %%ecx, %%eax \n\t" // V 1
+ "sbbl %%ecx, %%ecx \n\t" //U
+ "subl %%edx, %%ebx \n\t" // V 1
+ "andl %0, %%ecx \n\t" //U
+ "cmpl %%edx, %%ebx \n\t" // V 1
+ "sbbl %%edx, %%edx \n\t" //U
+ "addl %%ecx, %%eax \n\t" // V 1
+ "andl %0, %%edx \n\t" //U
+ "movl %%eax, (%%esi, %%ebp, 2) \n\t" // V 1
+ "addl %%edx, %%ebx \n\t" //U 1
+ "movl %%ebx, 4(%%esi, %%ebp, 2) \n\t" //U
- j = char(actVid2MemBufp->b[linep + (i<<1)]);
- j=(j + j) - temp[i];
- if(j<temp[i] && (line&2)) j++;
- if (j> 127) j= 127;
- else if(j<-128) j=-128;
- temp[i] = j;
- }
- linep-=stride;
- }
+ "addl $4, %%ebp \n\t" // V 1
+ " jnc 1b \n\t" //U 1
+ "popl %%ebp \n\t" //U
+ :
+ : "i" (COMB_FIX), "a" ((wndx<<1) - 2),
+ "D" (actVid2MemBufp->b + linep + 2), "S" (int(temp) + 4)
+ : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
+ linep-=stride;
+ }
}
- linep= 0;
+ int linep= 0;
if(o) linep+=vgax<<1;
- for(line=0; line<end; line++){
- for(i=0; i<wndx; i++){
+ for(int line=0; line<end; line++){
+ asm(//"int $3 \n\t"
+ "pushl %%ebp \n\t" //U
+ "movl %%eax, %%ebp \n\t" // V 1
+ "addl %%ebp, %%edi \n\t" //U
+ "addl %%ebp, %%esi \n\t" // V 1
+ "addl %%ebp, %%esi \n\t" //U 1
+ "negl %%ebp \n\t" //UV 1
+ "1: \n\t"
+ "xorl %%eax, %%eax \n\t" //U
+ "xorl %%ebx, %%ebx \n\t" // V 1
+ "movb (%%edi, %%ebp ), %%al \n\t" //U
+ "movb 2(%%edi, %%ebp ), %%bl \n\t" // V 1
+ "addb $128, %%al \n\t" //U
+ "addb $128, %%bl \n\t" // V 1
+ "shll $9, %%eax \n\t" //U
+ "movl (%%esi, %%ebp, 2), %%ecx \n\t" // V 1
+ "shll $9, %%ebx \n\t" //U
+ "subl %%ecx, %%eax \n\t" // V 1
+ "movl 4(%%esi, %%ebp, 2), %%edx \n\t" //U
+ "cmpl %%ecx, %%eax \n\t" // V 1
+ "sbbl %%ecx, %%ecx \n\t" //U
+ "subl %%edx, %%ebx \n\t" // V 1
+ "andl %0, %%ecx \n\t" //U
+ "cmpl %%edx, %%ebx \n\t" // V 1
+ "sbbl %%edx, %%edx \n\t" //U
+ "addl %%ecx, %%eax \n\t" // V 1
+ "andl %0, %%edx \n\t" //U
+ "movl %%eax, (%%esi, %%ebp, 2) \n\t" // V 1
+ "addl %%edx, %%ebx \n\t" //U
+ "subb $128, %%ah \n\t" // V 1
+ "movl %%ebx, 4(%%esi, %%ebp, 2) \n\t" //U
+ "subb $128, %%bh \n\t" // V 1
+ "movb %%ah, (%%edi, %%ebp ) \n\t" //U
+ "movb %%bh, 2(%%edi, %%ebp ) \n\t" // V 1
- j = char(actVid2MemBufp->b[linep + (i<<1)]);
- j=(j + j) - temp[i];
- if(j<temp[i] && (line&2)) j++;
- if (j> 127) j= 127;
- else if(j<-128) j=-128;
- temp[i] = j;
- actVid2MemBufp->b[linep + (i<<1)] = (char)(j);
- }
+ "addl $4, %%ebp \n\t" //U
+ " jnc 1b \n\t" // V 1
+ "popl %%ebp \n\t" //U
+ :
+ : "i" (COMB_FIX), "a" ((wndx<<1) - 2),
+ "D" (actVid2MemBufp->b + linep + 2), "S" (int(temp) + 4)
+ : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
linep+=stride;
}
+
+
+
/*
asm(//"int $3 \n\t"
"1: \n\t"
Modified: trunk/2010/2_grafix.cc
==============================================================================
--- trunk/2010/2_grafix.cc (original)
+++ trunk/2010/2_grafix.cc Wed Jul 4 09:37:52 2007
@@ -20,9 +20,11 @@
extern int single;
extern int bright, contr, satur;
extern MENULEVEL menuLevel;
+ extern int infoPosX;
extern int infoPosY;
extern VID2MEMBUF *vid2MemBuf;
extern int some;
+ extern bool allowDrop;
bool helpState=true;
bool iState=false;
@@ -33,14 +35,15 @@ void showStuff(void){
color c;
if(helpState){
- char text[5][256]={ "F1/F2 Brightness s TVStandart",
+ char text[6][256]={ "F1/F2 Brightness s TVStandart",
"F3/F4 Contrast i debugInfo",
"F5/F6 Saturation h Help",
"g ScreenShot q Quit",
- "v smoothIterlace"};
- for(int i=0; i<5; i++){
+ "v smoothIterlace p Pause",
+ "d allowDrop"};
+ for(int i=0; i<6; i++){
c.init(255, 0, 0, yuvmode);
- gprint(10, infoPosY+=10, c.col, text[i]);
+ gprint(infoPosX, infoPosY+=10, c.col, text[i]);
}
infoPosY+=5;
}
@@ -50,21 +53,21 @@ void showStuff(void){
sprintf(textbuf,"%3.1f%% brightness", bright/2.55);
c.init(255, 0, 0, yuvmode);
- gprint(10, infoPosY+=10, c.col, textbuf);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf);
sprintf(textbuf,"%3.1f%% contrast" , contr/1.27);
- gprint(10, infoPosY+=10, c.col, textbuf);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf);
sprintf(textbuf,"%3.1f%% saturation", satur/1.27);
- gprint(10, infoPosY+=10, c.col, textbuf);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf);
infoPosY+=5;
}
if(menuLevel==mLTVStd){
char text[3][256]={ "1. PAL 4. VideoCrypt (PAL)",
"2. NTSC 5. NagraVision (PAL/SECAM)",
- "3. SECAM"};
+ "3. SECAM 6. Pal-TeleText"};
for(int i=0; i<3; i++){
c.init(255, 0, 0, yuvmode);
- gprint(10, infoPosY+=10, c.col, text[i]);
+ gprint(infoPosX, infoPosY+=10, c.col, text[i]);
}
infoPosY+=5;
}
@@ -76,23 +79,28 @@ void showStuff(void){
c.init(255, 0, 0, yuvmode);
sprintf(textbuf,"%2.2f Fps",1/((float)(T1-T2)/UCLOCKS_PER_SEC));
- gprint(10, infoPosY+=10, c.col, textbuf);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf);
- sprintf(textbuf,"%d Buffers", vid2MemBuf[0].num);
- gprint(120, infoPosY , c.col, textbuf);
+ sprintf(textbuf,"%d Buf", vid2MemBuf[0].num);
+ gprint(infoPosX+110, infoPosY , c.col, textbuf);
if(yuvmode==0) sprintf(textbuf,"RGB16");
else sprintf(textbuf,"YUV422");
- gprint(220, infoPosY , c.col, textbuf);
+ gprint(infoPosX+170, infoPosY , c.col, textbuf);
+
+ if(allowDrop){
+ sprintf(textbuf,"allowDrop");
+ gprint(infoPosX+230, infoPosY , c.col, textbuf);
+ }
sprintf(textbuf,"%d Corrupted Fields", corr_errors);
- gprint(10, infoPosY+=10, c.col, textbuf);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf);
sprintf(textbuf,"%d Address error's", addr_errors);
- gprint(10, infoPosY+=10, c.col, textbuf);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf);
sprintf(textbuf,"%d Some", some);
- gprint(10, infoPosY+=10, c.col, textbuf);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf);
infoPosY+=5;
}
Modified: trunk/2010/2_hw.cc
==============================================================================
--- trunk/2010/2_hw.cc (original)
+++ trunk/2010/2_hw.cc Wed Jul 4 09:37:52 2007
@@ -1,7 +1,7 @@
//2010 0.1 Copyright (C) Michael Niedermayer 1998
#include <stdlib.h>
-#include <stdio.h> //FIX ME (ONLY TEMP NEEDED)
+#include <stdio.h>
#include <pc.h>
#include <go32.h>
#include <dpmi.h>
@@ -15,6 +15,7 @@
#include "2_hw_mem.h"
#include "2_71x6.h"
#include "2_mmx.h"
+#include "2_gfunc.h"
#include "2010.h"
extern byte lock_start, lock_end;
@@ -36,7 +37,11 @@
extern int in_int;
extern volatile int frames;
extern bool strangeRgb16;
+ extern bool iState;
+ extern int infoPosX, infoPosY;
+ bool drop=false;
+ bool allowDrop=true;
int g_mode=0;
extern u_short my_cs, my_ds;
asm("__esp: .long 0\n\t");
@@ -46,7 +51,6 @@
int VID2MEMBUF::num;
void mem2vid(byte *to, byte *from, int num, int bpp){
- int i;
if(yuvmode!=0){
asm(//"int $3 \n\t"
@@ -293,30 +297,48 @@ void set_start_disp(int x, int y){
void copy_vidbuffer(void){
- if(page_flip==0){
- int p=0;
- for(int y=0; y<wndy; y++){
- mem2vid(vidbuf+p, actVid2MemBufp->b+p, wndx, bpp);
- p+=vgax<<1;
- }
- }else if(page_flip==2){
- int p=0;
- for(int y=0; y<wndy; y++){
- mem2vid(vidbuf+xresvb*vgay+p, actVid2MemBufp->b+p, wndx, bpp);
- p+=vgax<<1;
- }
- page_flip=1;
- set_start_disp(0, vgay);
- }else{
- int p=0;
- for(int y=0; y<wndy; y++){
- mem2vid(vidbuf+p, actVid2MemBufp->b+p, wndx, bpp);
- p+=vgax<<1;
+ static long T1=0, T2=0;
+ if(iState){
+ char textBuf[128];
+ sprintf(textBuf, "%f vid2Mem", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ color c;
+ c.init(255, 0, 0, yuvmode);
+ gprint(infoPosX, infoPosY+=10, c.col, textBuf);
+ T1=uclock();
+ infoPosY+=5;
+ }
+
+ if(!drop || !allowDrop){
+
+ if(page_flip==0){
+ int p=0;
+ for(int y=0; y<wndy; y++){
+ mem2vid(vidbuf+p, actVid2MemBufp->b+p, wndx, bpp);
+ p+=vgax<<1;
+ }
+ }else if(page_flip==2){
+ int p=0;
+ for(int y=0; y<wndy; y++){
+ mem2vid(vidbuf+xresvb*vgay+p, actVid2MemBufp->b+p, wndx, bpp);
+ p+=vgax<<1;
+ }
+ page_flip=1;
+ set_start_disp(0, vgay);
+ }else{
+ int p=0;
+ for(int y=0; y<wndy; y++){
+ mem2vid(vidbuf+p, actVid2MemBufp->b+p, wndx, bpp);
+ p+=vgax<<1;
+ }
+ page_flip=2;
+ set_start_disp(0, 0);
}
- page_flip=2;
- set_start_disp(0, 0);
}
+ drop=false;
+ if(iState){
+ T2=uclock();
+ }
if( vid2MemBuf[actVid2MemBuf].state==Working ){
vid2MemBuf[actVid2MemBuf].state=Empty;
Modified: trunk/2010/2_nag.cc
==============================================================================
--- trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cc Wed Jul 4 09:37:52 2007
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
+#include <math.h>
#include "2_all.h"
#include "2_crypt.h"
#include "2_vc.h"
@@ -19,7 +20,11 @@
#define dwnSmp 1
-extern vgax, vgay, wndx, wndy, outy, y_field;
+#define FREQ_CHROM 4433618.75
+#define FREQ_HS 15625.0
+#define PHASE_DRIFT_PER_LINE (-fmod(FREQ_CHROM/FREQ_HS*4.0, 1.0)/4.0*PI*2.0)
+
+extern vgax, vgay, wndx, wndy, outy, y_field, x_field;
extern VID2MEMBUF *actVid2MemBufp;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
@@ -27,9 +32,11 @@ extern u_long asm_temp, asm_temp4;
extern bool iState;
extern int yuvmode;
extern bool mmx;
+extern int infoPosX;
+extern int infoPosY;
+extern int some;
+extern bool drop;
-static int alg2Lines;
-static short *linesPerKeyTab=NULL;
static int *decoLine=NULL;
static int decoLines;
static int keyTable[256];
@@ -44,8 +51,22 @@ static int nagEnd1;
static int nagSize1;
static int nagSize2;
static int nagSizeAll;
+static int rawWssThreshold=10000;
-static inline void getPerm(const int key, int * const perm){
+// fix inlines
+
+static int qsortHelper(const void *x0, const void *x1){
+ SINFO *sInfo0 = (SINFO*)(x0);
+ SINFO *sInfo1 = (SINFO*)(x1);
+ int r;
+ r=sInfo0->line0 - sInfo1->line0;
+ if(r!=0) return r;
+ r=sInfo0->line1 - sInfo1->line1;
+ if(r!=0) return r;
+ return sInfo0->key - sInfo1->key;
+}
+
+static void getPerm(const int key, int * const cle2enc){
int keyNdx= (key >> 7) & 0xFF;
const int keyInc= ((key & 0x7F) << 1) + 1;
int buffer[32];
@@ -53,13 +74,13 @@ static inline void getPerm(const int key
for(int i=0; i<32; i++) buffer[i]= i;
for(int i=0; i<255; i++){
- perm[i]= buffer[ keyTable[keyNdx] ];
+ cle2enc[i]= buffer[ keyTable[keyNdx] ];
buffer[ keyTable[keyNdx] ]= i + 32;
keyNdx= (keyNdx + keyInc) & 0xFF;
}
for(int i=0; i<32; i++){
- perm[i+255]= buffer[i];
+ cle2enc[i+255]= buffer[i];
}
}
@@ -169,115 +190,6 @@ static inline int nagLineLogi2Phys(const
return phys;
}
-static inline void mod4Fix(byte *p, const int type){
- asm(//"int $3 \n\t"
- "cmpl $2, %%edi \n\t"
- " jb 1f \n\t"
- "cmpl $3, %%edi \n\t"
- " jb 2f \n\t"
- "3: \n\t"
- " movb (%%esi, %%ecx), %%al \n\t"
- " movb 4(%%esi, %%ecx), %%bl \n\t"
-
- " movb 2(%%esi, %%ecx), %%ah \n\t"
- " movb 6(%%esi, %%ecx), %%bh \n\t"
- "7: \n\t"
- " xorb $-1, %%al \n\t"
- " xorb $-1, %%bl \n\t"
-
- " xorb $-1, %%ah \n\t"
- " xorb $-1, %%bh \n\t"
-
- " movb %%al, 2(%%esi, %%ecx) \n\t"
- " movb %%bl, 6(%%esi, %%ecx) \n\t"
-
- " movb %%ah, (%%esi, %%ecx) \n\t"
- " movb %%bh, 4(%%esi, %%ecx) \n\t"
-
- " movb 8(%%esi, %%ecx), %%al \n\t"
- " movb 12(%%esi, %%ecx), %%bl \n\t"
-
- " movb 10(%%esi, %%ecx), %%ah \n\t"
- " movb 14(%%esi, %%ecx), %%bh \n\t"
-
- " addl $8, %%ecx \n\t"
- "jnc 7b \n\t"
- " jmp 8f \n\t"
-
- "2: \n\t"
- " movl (%%esi, %%ecx), %%eax \n\t"
- " movl 4(%%esi, %%ecx), %%ebx \n\t"
- "7: \n\t"
- " xorl $0x00FF00FF, %%eax \n\t"
- " xorl $0x00FF00FF, %%ebx \n\t"
-
- " movl %%eax, (%%esi, %%ecx) \n\t"
- " movl %%ebx, 4(%%esi, %%ecx) \n\t"
-
- " movl 8(%%esi, %%ecx), %%eax \n\t"
- " movl 12(%%esi, %%ecx), %%ebx \n\t"
-
- " addl $8, %%ecx \n\t"
- "jnc 7b \n\t"
- " jmp 8f \n\t"
-
- "1: \n\t"
- " movb (%%esi, %%ecx), %%al \n\t"
- " movb 4(%%esi, %%ecx), %%bl \n\t"
-
- " movb 2(%%esi, %%ecx), %%ah \n\t"
- " movb 6(%%esi, %%ecx), %%bh \n\t"
- "7: \n\t"
- " movb %%al, 2(%%esi, %%ecx) \n\t" // AGI 1 CYC
- " movb %%bl, 6(%%esi, %%ecx) \n\t"
-
- " movb %%ah, (%%esi, %%ecx) \n\t"
- " movb %%bh, 4(%%esi, %%ecx) \n\t"
-
- " movb 8(%%esi, %%ecx), %%al \n\t"
- " movb 12(%%esi, %%ecx), %%bl \n\t"
-
- " movb 10(%%esi, %%ecx), %%ah \n\t"
- " movb 14(%%esi, %%ecx), %%bh \n\t"
-
- " addl $8, %%ecx \n\t"
- "jnc 7b \n\t"
-
- "8: \n\t"
-
- :
- : "S" (int(p) + (wndx<<2) ),
- "D" (type) ,
- "c" (-wndx<<2)
- : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
-
- /*
-
-
- const bool xchg[4]={false, true, false, true};
- const int neg [4]={ 0, 0, -1, -1};
-
-
- if(xchg[type]){
- for(int x=0; x<(wndx<<1); x+=4){
- const byte u= p[x ];
- const byte v= p[x+2];
-
- p[x ]= (v^neg[type]) - neg[type];
- p[x+2]= (u^neg[type]) - neg[type];
- }
- }else{
- for(int x=0; x<(wndx<<1); x+=4){
- const byte u= p[x ];
- const byte v= p[x+2];
-
- p[x ]= (u^neg[type]) - neg[type];
- p[x+2]= (v^neg[type]) - neg[type];
-
- }
- } */
-}
-
static inline void corrV(byte * p1, byte * p2, const int type, int *vPhase){
const bool xchg[4]={false, true, false, true};
const int neg [4]={ 0, 0, -1, -1};
@@ -326,37 +238,57 @@ void nag_decrypt(void){
nagSizeAll= nagSize1 + nagSize2;
char textbuf[10][128];
color c;
- long T1, T2;
const int dwnSmpSize= mmx ? dwnSmp : dwnSmp-1;
+ long T1, T2;
+ T1=uclock();
if(nagSizeAll!=NAG_LINES) error(Nagra);
- T1=uclock();
-
printf("%d %d\n", sizeof(u_short), sizeof(BEST2) );
printf("HALLOX\n");
static bool first=true;
+ static char *sinPerLineMulX=new char[(NAG_LINES+32)<<8];
+ static char *cosPerLineMulX=new char[(NAG_LINES+32)<<8];
+ static long long *sinPerLine=new long long[NAG_LINES+32];
+ static long long *cosPerLine=new long long[NAG_LINES+32];
+
if(first){
- decoLines=14;
+ decoLines=32;
decoLine=new int[decoLines];
- decoLine[ 0]= 91;
- decoLine[ 1]=103;
- decoLine[ 2]=112;
- decoLine[ 3]=124;
- decoLine[ 4]=131;
- decoLine[ 5]=145;
- decoLine[ 6]=152;
- decoLine[ 7]=163;
- decoLine[ 8]=175;
- decoLine[ 9]=181;
- decoLine[10]=194;
- decoLine[11]=200;
- decoLine[12]=213;
- decoLine[13]=222;
-
- alg2Lines=80;
+ decoLine[ 0]= 14;
+ decoLine[ 1]= 33;
+ decoLine[ 2]= 47;
+ decoLine[ 3]= 64;
+ decoLine[ 4]= 81;
+ decoLine[ 5]= 84;
+ decoLine[ 6]= 90;
+ decoLine[ 7]= 95;
+ decoLine[ 8]=103;
+ decoLine[ 9]=106;
+ decoLine[10]=110;
+ decoLine[11]=115;
+ decoLine[12]=121;
+ decoLine[13]=125;
+ decoLine[14]=127;
+ decoLine[15]=136;
+ decoLine[16]=142;
+ decoLine[17]=145;
+ decoLine[18]=149;
+ decoLine[19]=153;
+ decoLine[20]=161;
+ decoLine[21]=165;
+ decoLine[22]=172;
+ decoLine[23]=176;
+ decoLine[24]=180;
+ decoLine[25]=185;
+ decoLine[26]=189;
+ decoLine[27]=195;
+ decoLine[28]=211;
+ decoLine[29]=227;
+ decoLine[30]=243;
+ decoLine[31]=259;
FILE *f= fopen("key.txt", "r");
if(f==NULL) error(KeyFile);
@@ -364,13 +296,25 @@ void nag_decrypt(void){
if( fscanf(f, "%d", &keyTable[i])!=1 ) error(KeyFile);
fclose(f);
+ const float a=PHASE_DRIFT_PER_LINE;
+ for(int l=0; l<NAG_LINES+32; l++){
+ for(int v=0; v<256; v++){
+ int r=v;
+ if(v>127) r=v-256;
+ sinPerLineMulX[v + (l<<8)]= char(sin(a*l)*r);
+ cosPerLineMulX[v + (l<<8)]= char(cos(a*l)*r);
+ }
+ sinPerLine[l]= int(sin(a*l)*255) & 0xFFFF;
+ cosPerLine[l]= int(cos(a*l)*255) & 0xFFFF;
+ }
+
+
f=fopen("2010.dat", "rb");
if(f!=NULL){
- int decoLines2, alg2Lines2;
+ int s=0;
+ int decoLines2;
fread(&decoLines2, sizeof(int), 1, f);
- fread(&alg2Lines2, sizeof(int), 1, f);
if(decoLines2!=decoLines) goto badFile;
- if(alg2Lines2!=alg2Lines) goto badFile;
int decoLine2[NAG_LINES];
fread(decoLine2, sizeof(int), decoLines2, f);
@@ -378,20 +322,20 @@ void nag_decrypt(void){
int best2Size;
int keysListSize;
- int linesPerKeyTabSize;
fread(&best2Size, sizeof(int), 1, f);
fread(&keysListSize, sizeof(int), 1, f);
- fread(&linesPerKeyTabSize, sizeof(int), 1, f);
- best1= new int[decoLines * NAG_LINES];
+ best1= new int[decoLines * NAG_LINES * 33];
best2= new BEST2[best2Size];
keysList= new u_short[keysListSize];
- linesPerKeyTab= new short[linesPerKeyTabSize];
- fread(best1, sizeof(int), decoLines * NAG_LINES, f);
- fread(best2, sizeof(BEST2), best2Size , f);
- fread(keysList, sizeof(u_short), keysListSize , f);
- fread(linesPerKeyTab, sizeof(short), linesPerKeyTabSize , f);
+ fread(best1, sizeof(int), decoLines * NAG_LINES * 33, f);
+ fread(best2, sizeof(BEST2), best2Size , f);
+ fread(keysList, sizeof(u_short), keysListSize , f);
+
+ for(int i=0; i<decoLines * NAG_LINES * 33; i++) s+=best1[i];
+ for(int i=0; i<best2Size ; i++) s+=best2[i].line;
+ for(int i=0; i<keysListSize ; i++) s+=keysList[i];
badFile:;
fclose(f);
@@ -399,6 +343,102 @@ void nag_decrypt(void){
}
if(best1==NULL){
+ int best2Size=0;
+ int keysListSize=0;
+ int best2i=0;
+ int keysListi=0;
+ for(int phase=0; phase<2; phase++){
+ if(phase==1){
+ best1= new int[NAG_LINES * decoLines * 33];
+ for(int i=0; i<NAG_LINES * decoLines * 33; i++) best1[i]=-1;
+ best2= new BEST2[best2Size];
+ keysList= new u_short[keysListSize];
+ }
+ for(int wssLine=0; wssLine<33; wssLine++){
+ for(int dl=0; dl<decoLines; dl++){
+ int sInfos=0;
+ SINFO *sInfo= new SINFO[KEYS];
+ int *cle2enc= new int[NAG_LINES];
+ for(int key=0; key<KEYS; key++){
+ int keyNdx= (key >> 7) & 0xFF;
+// const int keyInc= ((key & 0x7F) << 1) + 1;
+
+ if(keyTable[keyNdx]!=wssLine && wssLine!=32) continue;
+ getPerm(key, cle2enc);
+
+ if(phase==0) keysListSize++;
+ int clearLine;
+ for(clearLine=0; clearLine<NAG_LINES; clearLine++){
+ if(cle2enc[clearLine] == decoLine[dl]) break;
+ }
+ if(clearLine==NAG_LINES) asm("int $3\n\t");
+
+ int line0= cle2enc[(clearLine-1<0)
+ ? (clearLine+2) : (clearLine-1)];
+ int line1= cle2enc[(clearLine+1>=NAG_LINES)
+ ? (clearLine-2) : (clearLine+1)];
+
+ if(line1<line0){
+ const int t=line0;
+ line0=line1;
+ line1=t;
+ }
+
+ sInfo[sInfos]=(SINFO){line0: line0, line1: line1, key: key};
+ sInfos++;
+ }
+ delete [] sInfo;
+ delete [] cle2enc;
+ qsort(sInfo, sInfos, sizeof(SINFO), qsortHelper);
+
+ if(phase==0){
+ u_long last0=510;
+ u_long last1=510;
+ for(int i=0; i<sInfos; i++){
+ if(last0!=sInfo[i].line0 || last1!=sInfo[i].line1){
+ last0=sInfo[i].line0;
+ last1=sInfo[i].line1;
+ best2Size++;
+ }
+ }
+ }
+ else{
+ u_long last0=510;
+ u_long last1=510;
+ int best1i=-1;
+ for(int sInfoi=0; sInfoi<sInfos; sInfoi++){
+ if(sInfo[sInfoi].line0 != last0){
+ last0= sInfo[sInfoi].line0;
+ best1i= wssLine*NAG_LINES*decoLines + dl*NAG_LINES + last0;
+ best1[best1i]=best2i;
+ last1=510;
+ }
+ if(sInfo[sInfoi].line1 != last1){
+ last1= sInfo[sInfoi].line1;
+ best2[best2i]=(BEST2){line: last1, keyNdx: keysListi};
+ best2i++;
+ if(keysListi>0) keysList[keysListi-1]|=KEYS;
+ }
+ keysList[keysListi]=sInfo[sInfoi].key;
+ keysListi++;
+ }
+ if(keysListi>0) keysList[keysListi-1]|=KEYS;
+ }
+ }
+ }
+ }
+
+ for(int best1i=NAG_LINES*decoLines*33-1; best1i>=0; best1i--){
+ if(best1[best1i]==-1) best1[best1i]= best2i;
+ else best2i=best1[best1i];
+ }
+
+
+
+
+ /*
+
+
bool *state= new bool[NAG_LINES * NAG_LINES * decoLines];
int *keysTempStart= new int[NAG_LINES * NAG_LINES * decoLines];
@@ -443,11 +483,11 @@ void nag_decrypt(void){
// fix compression for keysList
int keysListSize= KEYS*decoLines;
- best1= new int[NAG_LINES * decoLines];
+ best1= new int[NAG_LINES * decoLines * 33];
best2= new BEST2[best2Size];
keysList= new u_short[keysListSize];
- for(int i=0; i<NAG_LINES * decoLines; i++){
+ for(int i=0; i<NAG_LINES * decoLines * 33; i++){
best1[i]=-1;
}
@@ -489,74 +529,22 @@ void nag_decrypt(void){
delete [] keysTempStart;
delete [] state;
- const int startW= (NAG_LINES-alg2Lines)>>1;
- const int endW= (NAG_LINES+alg2Lines)>>1;
- int linesPerKeyTabSize=0;
- int minLines=1000;
- for(int key=0; key<KEYS; key++){
- int perm[NAG_LINES];
- getPerm(key, perm);
- int lines=0;
- for(int clearLine=1; clearLine<NAG_LINES; clearLine++){
- int l1=perm[clearLine ];
- int l2=perm[clearLine-1];
- if( l1 >= startW && l1 < endW && l2 >= startW && l2 < endW){
- linesPerKeyTabSize++;
- lines++;
- }
- }
- if(lines<minLines) minLines=lines; // linesPerKeyTabSize bigger then nes.
- }
- linesPerKeyTab= new short[linesPerKeyTabSize+1];
-
- printf("minLines %d\n", minLines);
-
- int linesPerKeyTabP=0;
- for(int key=0; key<KEYS; key++){
- int perm[NAG_LINES];
- getPerm(key, perm);
- int lines=0;
- for(int clearLine=1; clearLine<NAG_LINES; clearLine++){
- int l1=perm[clearLine ];
- int l2=perm[clearLine-1];
- if( l1 >= startW && l1 < endW && l2 >= startW && l2 < endW){
- if(l1>l2){
- int lt=l1;
- l1=l2;
- l2=lt;
- }
- l1-=startW;
- l2-=startW;
- l1*=alg2Lines;
- linesPerKeyTab[linesPerKeyTabP]=l1+l2;
- linesPerKeyTabP++;
- lines++;
- if(lines>=minLines) break;
- }
- }
- linesPerKeyTab[linesPerKeyTabP]|=1<<15;
-
- }
- linesPerKeyTab[linesPerKeyTabP]=-1;
+ */
- linesPerKeyTabSize=linesPerKeyTabP+1;
f=fopen("2010.dat", "wb");
if(f==NULL) error(DatWrite);
fwrite(&decoLines, sizeof(int), 1, f);
- fwrite(&alg2Lines, sizeof(int), 1, f);
fwrite(decoLine, sizeof(int), decoLines, f);
fwrite(&best2Size, sizeof(int), 1, f);
fwrite(&keysListSize, sizeof(int), 1, f);
- fwrite(&linesPerKeyTabSize, sizeof(int), 1, f);
- fwrite(best1, sizeof(int), decoLines * NAG_LINES, f);
- fwrite(best2, sizeof(BEST2), best2Size , f);
- fwrite(keysList, sizeof(u_short), keysListSize , f);
- fwrite(linesPerKeyTab, sizeof(short), linesPerKeyTabSize , f);
+ fwrite(best1, sizeof(int), decoLines * NAG_LINES * 33, f);
+ fwrite(best2, sizeof(BEST2), best2Size , f);
+ fwrite(keysList, sizeof(u_short), keysListSize , f);
fclose(f);
@@ -564,6 +552,29 @@ void nag_decrypt(void){
}
first=false;
+ const int wssStartX=int(double(7 -scales_x+3)/x_field*wndx + .5);
+ const int wssEndX= int(double(164 -scales_x+3)/x_field*wndx + .5);
+ const int wssLenX= wssEndX - wssStartX;
+
+ static wssDat[max_x];
+
+ static int lastVgaX=0;
+ static wssThreshold=0;
+ if(lastVgaX!=vgax){
+ const byte wssRaw[53]= {1,1,1,1,1, 0,0,0, 1,1,1, 0,0,0, 1,1,1, 0,0,0,
+ 1,1,1, 0,0,0, 1,1,1, 0,0,0, 1,1,1,1, 0,0,0,
+ 1,1,1,1, 0,0,0,0,0, 1,1,1,1,1};
+ const float delta= 53.0 / float(wssLenX);
+ float pos=0;
+ for(int i=wssStartX; i<wssEndX; i++){
+ pos+= delta;
+ wssDat[i]= wssRaw[int(pos)]*255;
+ }
+
+ wssThreshold= rawWssThreshold*wssLenX>>7;
+ lastVgaX=vgax;
+ }
+
BESTCOEFFS *bestCoeffs= new BESTCOEFFS[decoLines];
for(int i=0; i<decoLines; i++){
bestCoeffs[i].coeff[0]=
@@ -583,6 +594,37 @@ void nag_decrypt(void){
T1=T2;
}
+ bool isWss;
+ int wssLine=0;
+ {
+ int minSum=0x7FFFFFFF;
+ for(int line=0; line<32; line++){
+ int sum=0;
+ byte * const linep= actVid2MemBufp->b + nagLineLogi2Phys(line)*(vgax<<1);
+ for(int x=wssStartX; x<wssEndX; x++){
+ sum+= mabs( int(linep[(x<<1) + 1]) - int(wssDat[x]) );
+ }
+ if(sum<minSum){
+ minSum=sum;
+ wssLine=line;
+ }
+ }
+/*
+ byte * const linep= actVid2MemBufp->b + nagLineLogi2Phys(wssLine)*(vgax<<1);
+ for(int x=wssStartX; x<wssEndX; x++){
+ linep[(x<<1) + 1]= (byte)(mabs( int(linep[(x<<1) + 1]) - int(wssDat[x]) ));
+ }
+ */
+
+ if(minSum < wssThreshold){
+ isWss=true;
+ actVid2MemBufp->b[nagLineLogi2Phys(wssLine)*(vgax<<1) + (wssStartX<<1) + 3]=0;
+ actVid2MemBufp->b[nagLineLogi2Phys(wssLine)*(vgax<<1) + (wssStartX<<1) + 5]=255;
+ }
+ else isWss=false;
+ }
+ if(!isWss) wssLine=32;
+
byte * const lowRes=(byte*) newAlign( wndx>>dwnSmpSize, 8);
for(int line=0; line<NAG_LINES; line++){
byte * const linep= actVid2MemBufp->b + nagLineLogi2Phys(line)*(vgax<<1);
@@ -621,8 +663,8 @@ void nag_decrypt(void){
limit(bestCoeffs[dL].line[0], 0, 285);
#endif
- int l= best1[ bestCoeffs[dL].line[0] + dL*NAG_LINES ];
- int r= best1[ bestCoeffs[dL].line[0] + 1 + dL*NAG_LINES ];
+ int l= best1[ bestCoeffs[dL].line[0] + dL*NAG_LINES + wssLine*decoLines*NAG_LINES];
+ int r= best1[ bestCoeffs[dL].line[0] + 1 + dL*NAG_LINES + wssLine*decoLines*NAG_LINES];
if(l == r) continue;
r--;
@@ -645,107 +687,50 @@ void nag_decrypt(void){
}
bool didSome;
- int lastLowKey=-1;
+ int lastLowKey=0xFFFF;
int bestKey=0;
int bestNum=0;
+ int maxKeys=0;
do{
didSome=false;
- u_short lowKey=0xFFFF;
+ int lowKey=0xFFFF;
int lowNum=0;
- for(int kLP=0; kLP<keysListPoses; kLP++){
- if(keysListPos[kLP]==-1) continue;
+ for(int kLPi=0; kLPi<keysListPoses; kLPi++){
- if( int(keysList[ keysListPos[kLP] ] & (KEYS-1) )==lastLowKey ){
- if( (keysList[ keysListPos[kLP] ] & KEYS)==KEYS ){
- keysListPos[kLP]=-1;
+ if( (keysList[ keysListPos[kLPi] ] & (KEYS-1))==lastLowKey ){
+ if( (keysList[ keysListPos[kLPi] ] & KEYS)==KEYS ){
+ keysListPoses--;
+ keysListPos[kLPi]= keysListPos[keysListPoses];
continue;
}
- keysListPos[kLP]++;
+ keysListPos[kLPi]++;
+ maxKeys++;
}
-
- if( int(keysList[ keysListPos[kLP] ] & (KEYS-1)) == lowKey ){
+
+ if( (keysList[ keysListPos[kLPi] ] & (KEYS-1)) == lowKey ){
lowNum++;
+ if(lowNum>bestNum){
+ bestNum=lowNum;
+ bestKey=lowKey;
+ }
}
- if( int(keysList[ keysListPos[kLP] ] & (KEYS-1)) < lowKey ){
- lowKey= int(keysList[ keysListPos[kLP] ] & (KEYS-1));
+ else if( (keysList[ keysListPos[kLPi] ] & (KEYS-1)) < lowKey ){
+ lowKey= keysList[ keysListPos[kLPi] ] & (KEYS-1);
lowNum=0;
}
didSome= true;
}
lastLowKey=lowKey;
-// printf("KEY %d %d\n", lowNum, lowKey);
- if(lowNum>bestNum){
- bestNum=lowNum;
- bestKey=lowKey;
- }
}while(didSome);
delete [] keysListPos;
- if(iState){
- T2=uclock();
- sprintf(textbuf[3],"%f FindKey", (float)(T2-T1)/UCLOCKS_PER_SEC);
- T1=T2;
- }
-
- if(bestNum<3){
- short *coeff= new short[alg2Lines*alg2Lines];
-
- byte *lowRes= new byte[alg2Lines*wndx>>dwnSmpSize];
-
- const int startW= (NAG_LINES-alg2Lines)>>1;
- const int endW= (NAG_LINES+alg2Lines)>>1;
-
- for(int line=0; line<alg2Lines; line++){
- const int physLine= nagLineLogi2Phys(line+startW);
- byte * const linep= actVid2MemBufp->b + physLine*(vgax<<1);
- byte * const lowResp= lowRes + line*(wndx>>dwnSmpSize);
- doDwnSmp(lowResp ,linep);
- }
-
- int coeffp=0;
- int line0p=0;
- for(int line0=0; line0<alg2Lines; line0++){
- int line1p=0;
- for(int line1=line0; line1<alg2Lines; line1++){
- BESTCOEFFS out;
- out.coeff[0]=
- out.coeff[1]=100000;
- nagraCorr(int(line0p), int(line1p), wndx>>dwnSmpSize, int(&out), 0);
- coeff[coeffp + line1]=short(out.coeff[0]);
- line1p+= wndx>>dwnSmpSize;
- }
- coeffp+= alg2Lines;
- line0p+= wndx>>dwnSmpSize;
- }
- if(mmx) asm("emms\n\t");
-
- int linesPerKeyTabP=0;
- bestNum=100000;
- int key=0;
- int num=0;
- for(;;){
- if(linesPerKeyTab[linesPerKeyTabP]==-1) break;
- num+= coeff[ linesPerKeyTab[linesPerKeyTabP] & !(1<<15) ];
-
- if(linesPerKeyTab[linesPerKeyTabP] & (1<<15) ){
- if(num<bestNum){
- bestNum=num;
- bestKey=key;
- num=0;
- }
- key++;
- }
- linesPerKeyTabP++;
- }
-
- delete [] lowRes;
- delete [] coeff;
- }
+ if(bestNum<2) drop=true;
if(iState){
T2=uclock();
- sprintf(textbuf[4],"%f Algo2", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[6],"%2d%6d%6s", bestNum, maxKeys, isWss ? "WSS" : "NoWSS");
+ sprintf(textbuf[3],"%f FindKey", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
}
@@ -756,7 +741,6 @@ void nag_decrypt(void){
delete [] bestCoeffs; // kill this
-
byte *lastV[2]={NULL, NULL};
int lastVType[2];
int vPhase=0;
@@ -777,50 +761,157 @@ void nag_decrypt(void){
if(vPhase>0) vPhase=1;
else vPhase=0;
+ const bool xchg[4]={false, true, false, true};
+ const int neg [4]={ 0, 0, -1, -1};
- byte *lowDriftLinep= actVid2MemBufp->b; // initalize in case nothing found else PF
- int firstI=0;
- for(int i=0; i<NAG_LINES; i++){
- if(perm[i]>=32 && i-perm[i]<=0){
- const cleMod4= (i + vPhase ) & 3;
- const encMod4= (perm[i] + vPhase ) & 3;
+ char *pGood=(char*)(actVid2MemBufp->b);
+ for(int line=NAG_LINES-1; line>0; line--){
+
+ char *p= (char*)(actVid2MemBufp->b + nagLineLogi2Phys( perm[line] ) * (vgax<<1));
+
+ if(perm[line]>=32){
+ const cleMod4= (line + vPhase ) & 3;
+ const encMod4= (perm[line] + vPhase ) & 3;
const type= cleMod4 ^ encMod4;
- lowDriftLinep= actVid2MemBufp->b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
+ const int l=(line-perm[line]+32)<<8;
- if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, type);
+ pGood= p;
- firstI= i;
- break;
- }
- }
-
- for(int clearLine=0 ;clearLine<NAG_LINES; clearLine++){
- byte * const linep= actVid2MemBufp->b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
+ if(mmx){
+ long long colorAsmDataTab[4];
+ colorAsmDataTab[2]=0x00FF000000FF0000LL;
+ colorAsmDataTab[3]=0xFF00FF00FF00FF00LL;
- if(perm[clearLine]>=32 && clearLine-perm[clearLine]<=0
- && firstI!=clearLine){
- const cleMod4= (clearLine + vPhase ) & 3;
- const encMod4= (perm[clearLine] + vPhase ) & 3;
- const type= cleMod4 ^ encMod4;
+ if(xchg[type]){
+ colorAsmDataTab[0]=
+ cosPerLine[l>>8] + (sinPerLine[l>>8]<<16)
+ +( cosPerLine[l>>8] <<32) + (sinPerLine[l>>8]<<48);
+ colorAsmDataTab[1]=
+ ((0xFFFFLL - sinPerLine[l>>8])<<7 ) + (cosPerLine[l>>8]<<23)
+ +((0xFFFFLL - sinPerLine[l>>8])<<39) + (cosPerLine[l>>8]<<55);
+ if((perm[line] & 1) ^ vPhase){
+ colorAsmDataTab[0]^=0xFFFF0000FFFF0000LL;
+ colorAsmDataTab[1]^=0x0000FFFF0000FFFFLL;
+ }
+ }
+ else{
+ colorAsmDataTab[0]=
+ ((0xFFFFLL - sinPerLine[l>>8]) ) + (cosPerLine[l>>8]<<16)
+ +((0xFFFFLL - sinPerLine[l>>8])<<32) + (cosPerLine[l>>8]<<48);
+ colorAsmDataTab[1]=
+ ( cosPerLine[l>>8] <<7 ) + (sinPerLine[l>>8]<<23)
+ +( cosPerLine[l>>8] <<39) + (sinPerLine[l>>8]<<55);
+ if((perm[line] & 1) ^ vPhase){
+ colorAsmDataTab[0]^=0x0000FFFF0000FFFFLL;
+ colorAsmDataTab[1]^=0xFFFF0000FFFF0000LL;
+ }
+ }
- lowDriftLinep= actVid2MemBufp->b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
- if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, type);
+ if(neg[type]){
+ colorAsmDataTab[0]^=0xFFFFFFFFFFFFFFFFLL;
+ colorAsmDataTab[1]^=0xFFFFFFFFFFFFFFFFLL;
+ }
+
+ asm("movq (%%eax), %%mm1 \n\t"
+ "movq 8(%%eax), %%mm2 \n\t"
+ "movq 16(%%eax), %%mm3 \n\t"
+ "movq 24(%%eax), %%mm4 \n\t"
+
+ "movq (%%esi, %%ecx), %%mm0 \n\t"
+ "movq %%mm1, %%mm5 \n\t"
+ "movq %%mm0, %%mm6 \n\t"
+ "psllw $8, %%mm0 \n\t"
+ "pmaddwd %%mm0, %%mm5 \n\t"
+ "pmaddwd %%mm2, %%mm0 \n\t"
+ "1: \n\t"
+ // Stall 1 Cyc
+ ".byte 0x0f, 0xdb, 0xeb \n\t" // no more bugs PLEEEEZE "pand %%mm3, %%mm5 \n\t"
+ ".byte 0x0f, 0xdb, 0xf4 \n\t" // no more bugs PLEEEEZE "pand %%mm4, %%mm6 \n\t"
+
+ "psrld $23, %%mm0 \n\t"
+ "por %%mm6, %%mm5 \n\t"
+
+ "por %%mm5, %%mm0 \n\t"
+
+ "movq %%mm0, (%%esi, %%ecx) \n\t"
+
+ "movq 8(%%esi, %%ecx), %%mm0 \n\t"
+ "movq %%mm1, %%mm5 \n\t"
+
+ "movq %%mm0, %%mm6 \n\t"
+ "psllw $8, %%mm0 \n\t"
+
+ "pmaddwd %%mm0, %%mm5 \n\t"
+ "addl $8, %%ecx \n\t"
+
+ "pmaddwd %%mm2, %%mm0 \n\t"
+ " jnc 1b \n\t"
+ "emms \n\t"
+ :
+ : "a" (int(colorAsmDataTab)),
+ "S" (int(p) + (wndx<<1)),
+ "c" (-wndx<<1)
+ : "%eax", "%ecx");
+ }
+ else{
+ for(int x=0; x<wndx; x+=4){
+ const int u= int(* p );
+ const int v= int(*(p+2));
+
+ char u1;
+ char v1;
+ if((perm[line] & 1) ^ vPhase){
+ u1=+ cosPerLineMulX[l+u] - sinPerLineMulX[l+v];
+ v1=+ sinPerLineMulX[l+u] + cosPerLineMulX[l+v];
+ }
+ else{
+ u1=+ cosPerLineMulX[l+u] + sinPerLineMulX[l+v];
+ v1=- sinPerLineMulX[l+u] + cosPerLineMulX[l+v];
+ }
+
+ if(xchg[type]){
+ * p = *(p+4)= (v1^neg[type]) - neg[type];
+ *(p+2)= *(p+6)= (u1^neg[type]) - neg[type];
+
+ p +=8;
+
+ }else{
+ * p = *(p+4)= (u1^neg[type]) - neg[type];
+ *(p+2)= *(p+6)= (v1^neg[type]) - neg[type];
+
+ p +=8;
+
+ }
+ }
+ }
}
else{
- for(int x=0; x<(wndx<<1); x+=4){
- linep[x ]= lowDriftLinep[x ];
- linep[x+2]= lowDriftLinep[x+2];
- }
+ asm("1: \n\t"
+ "movb (%%esi, %%ecx), %%al \n\t"
+ "movb 2(%%esi, %%ecx), %%bl \n\t"
+ "movb %%al, (%%edi, %%ecx) \n\t"
+ "movb %%bl, 2(%%edi, %%ecx) \n\t"
+ "movb 4(%%esi, %%ecx), %%al \n\t"
+ "movb 6(%%esi, %%ecx), %%bl \n\t"
+ "movb %%al, 4(%%edi, %%ecx) \n\t"
+ "movb %%bl, 6(%%edi, %%ecx) \n\t"
+ "movb 8(%%edi, %%ecx), %%al \n\t"
+ "addl $8, %%ecx \n\t"
+ " jnc 1b \n\t"
+ :
+ : "D" (int(p ) + (wndx<<1)),
+ "S" (int(pGood) + (wndx<<1)) ,
+ "c" (-wndx<<1)
+ : "%eax", "%ebx", "%ecx");
}
}
-
if(iState){
T2=uclock();
- sprintf(textbuf[5],"%f ColorDeco", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[4],"%f ColorDeco", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
}
@@ -854,7 +945,7 @@ void nag_decrypt(void){
for(int i=0; i<NAG_LINES; i++){
const int encodLine= nagLineLogi2Phys(perm[i]);
- const int clearLine= i;
+ const int clearLine= i << ((outy==wndy) ? 1 : 0);
enc2cleVec[ encodLine ]= clearLine;
cle2encVec[ clearLine ]= encodLine;
@@ -912,28 +1003,26 @@ void nag_decrypt(void){
if(iState){
T2=uclock();
- sprintf(textbuf[6],"%f ReOrder", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[5],"%f ReOrder", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
}
-
-
-
-
if(iState){
- T2=uclock();
+ T2=uclock();
c.init(255, 0, 0, yuvmode);
- gprint(80, 80, c.col, textbuf[0]);
- gprint(90, 90, c.col, textbuf[1]);
- gprint(100, 100, c.col, textbuf[2]);
- gprint(110, 110, c.col, textbuf[3]);
- gprint(120, 120, c.col, textbuf[4]);
- gprint(130, 130, c.col, textbuf[5]);
- gprint(140, 140, c.col, textbuf[6]);
-/* gprint(150, 150, c.col, textbuf[7]);
- gprint(160, 160, c.col, textbuf[8]);
- gprint(170, 170, c.col, textbuf[9]);*/
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[0]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[1]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[2]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[3]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[4]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[5]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[6]);
+/* gprint(infoPosX, infoPosY+=10, c.col, textbuf[8]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[7]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[8]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[9]);*/
+ infoPosY+=5;
T1=T2;
}
Modified: trunk/2010/2_nag.h
==============================================================================
--- trunk/2010/2_nag.h (original)
+++ trunk/2010/2_nag.h Wed Jul 4 09:37:52 2007
@@ -16,6 +16,12 @@ struct BESTCOEFFS{
int coeff[2];
};
+struct SINFO{
+ unsigned line0:9;
+ unsigned line1:9;
+ unsigned key:15;
+};
+
void nag_decrypt(void);
#endif
Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cc Wed Jul 4 09:37:52 2007
@@ -36,6 +36,8 @@
#define DWN_SMP 1
#define MAX_DRIFT 2
#define DRIFT_TAB {1200, 400, 0, 400, 1200}
+//#define MAX_DRIFT 3
+//#define DRIFT_TAB {2400, 1200, 400, 0, 400, 1200, 2400}
#define PHASE_CMP_STEP 3
#define BAD_THRESHOLD1 0.8
#define BAD_THRESHOLD2 200
@@ -61,6 +63,10 @@ extern bool iState;
extern int yuvmode;
extern int some;
extern bool mmx;
+extern int infoPosX;
+extern int infoPosY;
+extern long uclockWaste;
+
static inline float atan3(const float f1, const float f2){
float out;
@@ -80,7 +86,6 @@ void vc_decrypt(void){
int addapBuff[max_x];
char textbuf[9][128];
long T1=0, T2;
- long alg1=0, alg2=0, alg3=0;
color c;
const int lowResSize= mmx ? DWN_SMP : (DWN_SMP-1);
@@ -133,12 +138,15 @@ void vc_decrypt(void){
int *convVec= new int[vcDiff>>(PHASE_CMP_STEP-1)];
+ long TCorr=0, TReSmp=0, TUVDetect=0, TPhaseDiff1=0,
+ TPhaseDiff2_Drift=0, TEdgeDetect=0;
+
if(iState){
T1=uclock();
}
static int edgeLut[512];
- static int phaseLut[128];
+ static int phaseLut[256];
static bool first= true;
static byte phasePerCutP[256];
@@ -155,8 +163,8 @@ void vc_decrypt(void){
edgeLut[i]=int( log(j*EDGE_LOG_COEFF)*EDGE_COEFF );
}
- for(int i=0; i<128; i++){
- const int j= max(min(i, PHASE_LIMIT), 1);
+ for(int i=0; i<256; i++){
+ const int j= max(min(mabs(i-128), PHASE_LIMIT), 1);
phaseLut[i]=int( pow(j, PHASE_EXP)*PHASE_COEFF );
}
@@ -181,8 +189,8 @@ void vc_decrypt(void){
bool *black= new bool[wndy];
- int llinep=-(vgax<<2);
- int linep=-(vgax<<1);
+ byte * llinep=&actVid2MemBufp->b[ -(vgax<<2) ];
+ byte * linep= &actVid2MemBufp->b[ -(vgax<<1) ];
for(int line=0; line<wndy; line++){
llinep+=vgax<<1;
linep+=vgax<<1;
@@ -217,7 +225,7 @@ void vc_decrypt(void){
"popl %%ebp \n\t"
:
: "I" (DWN_SMP), "i" (1<<DWN_SMP),
- "S" (actVid2MemBufp->b + linep + 1 + (vcStartX<<1)) ,
+ "S" (linep + 1 + (vcStartX<<1)) ,
"d" (vcDiff>>DWN_SMP) ,
"D" (lowRes[1])
: "%eax", "%ebx", "%edx", "%esi", "%edi");
@@ -249,7 +257,7 @@ void vc_decrypt(void){
"popl %%ebp \n\t"
:
: "I" (DWN_SMP), "i" (1<<DWN_SMP),
- "S" (actVid2MemBufp->b + linep + 1 + (vcStartX<<1)) ,
+ "S" (linep + 1 + (vcStartX<<1)) ,
"d" (vcDiff>>DWN_SMP) ,
"D" (lowRes[1])
: "%eax", "%ebx", "%edx", "%esi", "%edi");
@@ -260,7 +268,7 @@ void vc_decrypt(void){
if(iState){
T2=uclock();
- alg3+=T2-T1;
+ TReSmp+=T2-T1-uclockWaste;
T1=T2;
}
@@ -323,18 +331,24 @@ void vc_decrypt(void){
< bestDiff )
black[line]=true;
+ if(iState){
+ T2=uclock();
+ TCorr+=T2-T1-uclockWaste;
+ T1=T2;
+ }
+
if(line>2){
int sumI=0;
for(int x=-2; x<2; x+=2){
const int nx= x + (vcDiff & ~1);
- const int ul= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + x)<<1) + 0]);
- const int vl= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + x)<<1) + 2]);
- const int un= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 0]);
- const int vn= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 2]);
+ const int ul= char(linep[ (((vcStartX & ~1) + x)<<1) + 0]);
+ const int vl= char(linep[ (((vcStartX & ~1) + x)<<1) + 2]);
+ const int un= char(linep[ (((vcStartX & ~1) + nx)<<1) + 0]);
+ const int vn= char(linep[ (((vcStartX & ~1) + nx)<<1) + 2]);
sumI+= ul*vn - vl*un;
-// actVid2MemBufp->b[linep + (((vcStartX & ~1) - x)<<1) + 1]=255;
-// actVid2MemBufp->b[linep + (((vcStartX & ~1) - nx)<<1) + 1]=255;
+// linep[ (((vcStartX & ~1) - x)<<1) + 1]=255;
+// linep[ (((vcStartX & ~1) - nx)<<1) + 1]=255;
}
if(line>10 && line<250){
@@ -353,7 +367,7 @@ void vc_decrypt(void){
if(iState){
T2=uclock();
- alg1+=T2-T1;
+ TUVDetect+=T2-T1-uclockWaste;
T1=T2;
}
}
@@ -361,7 +375,8 @@ void vc_decrypt(void){
deleteAlign(lowRes[0]);
deleteAlign(lowRes[1]);
- byte *dir=new byte[257*(wndy + 1)];
+ byte *dir=new byte[(wndy + 1)<<8];
+ int *bestDir=new int[wndy + 1];
const int driftPenalty[MAX_DRIFT*2+1]= DRIFT_TAB;
@@ -371,10 +386,8 @@ void vc_decrypt(void){
byte *newPhaseErr=new byte[256], *lastPhaseErr=new byte[256];
memset(lastPhaseErr, 0, 256);
- long tst1=0, tst2=0, tst3=0;
-
- llinep=-(vgax<<2);
- linep=-(vgax<<1);
+ llinep=&actVid2MemBufp->b[ -(vgax<<2) ];
+ linep= &actVid2MemBufp->b[ -(vgax<<1) ];
for(int line=0; line<wndy; line++){
llinep+=vgax<<1;
linep+=vgax<<1;
@@ -383,7 +396,7 @@ void vc_decrypt(void){
memset(newPhaseErr, 0, 256);
bool noLeft=true;
- dir[line*257 + 256]=0;
+ bestDir[line]=-1;
if(line==0) continue;
@@ -394,22 +407,23 @@ void vc_decrypt(void){
for(int x=0; x<vcDiff; x+= 1<<PHASE_CMP_STEP){
int nx= x + (relCutPX & ~1);
if(nx>=vcDiff) nx-= (vcDiff & ~1);
- const int ul= char(actVid2MemBufp->b[llinep + (((vcStartX & ~1) + x)<<1) + 0]);
- const int vl= char(actVid2MemBufp->b[llinep + (((vcStartX & ~1) + x)<<1) + 2]);
- const int un= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 0]);
- const int vn= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 2]);
+ const int ul= char(llinep[ (((vcStartX & ~1) + x)<<1) + 0]);
+ const int vl= char(llinep[ (((vcStartX & ~1) + x)<<1) + 2]);
+ const int un= char( linep[ (((vcStartX & ~1) + nx)<<1) + 0]);
+ const int vn= char( linep[ (((vcStartX & ~1) + nx)<<1) + 2]);
const int p= x>>(PHASE_CMP_STEP-1);
convVec[p ]= ul*un + vl*vn;
convVec[p+1]= ul*vn - vl*un;
chromAmp+= mabs(un) + mabs(vn);
}
+ if(line<4) chromAmp=1;
-// actVid2MemBufp->b[linep + ((vcStartX + 0)<<1) + 1]=255;
-// actVid2MemBufp->b[linep + ((vcStartX + relCutPX)<<1) + 1]=200;
+// linep[ ((vcStartX + 0)<<1) + 1]=255;
+// linep[ ((vcStartX + relCutPX)<<1) + 1]=200;
if(iState){
T2=uclock();
- tst1+=T2-T1;
+ TPhaseDiff1+=T2-T1-uclockWaste;
T1=T2;
}
@@ -504,32 +518,46 @@ void vc_decrypt(void){
const byte a= (line & 1) ^ ( vScore>0 ) ? -ang: ang;
const byte phase1= a + phasePerCutP[ lastCutP ];
-
- for(int newCutP= newCutPStart; newCutP <= newCutPEnd; newCutP++){
- int val= lastVal[lastCutP] - driftPenalty[drift];
- const byte phaseErr= phase1 + phasePerCutP[ newCutP ];
-
- if(chromAmp>AMP_THRESHOLD && line>4)
- val-= phaseLut[ mabs( char(phaseErr - 128) ) ]
- + phaseLut[ mabs( char(phaseErr - lastPhaseErr[lastCutP]) ) ];// useless without phase errors from decomb-filter
- else actVid2MemBufp->b[linep + ((vcStartX - 1)<<1) + 1]=255;
+ // FIX (ASM_OPTIMIZE)
+ if(chromAmp>AMP_THRESHOLD){
+ for(int newCutP= newCutPStart; newCutP <= newCutPEnd; newCutP++){
+ const byte phaseErr= phase1 + phasePerCutP[ newCutP ];
+ const int val= lastVal[lastCutP] - driftPenalty[drift]
+ - phaseLut[ phaseErr ]
+ - phaseLut[ (phaseErr - lastPhaseErr[lastCutP] + 128) & 0xFF];// useless without phase errors from decomb-filter
- if(newVal[newCutP] < val){
- newVal[newCutP]= val;
- dir[line*257 + newCutP]= lastCutP;
- newPhaseErr[newCutP]= phaseErr;
+ if(newVal[newCutP] < val){
+ newVal[newCutP]= val;
+ dir[(line<<8) + newCutP]= lastCutP;
+ newPhaseErr[newCutP]= phaseErr;
- noLeft=false;
+ noLeft=false;
+ }
+ drift++;
+ }
+ }
+ else{
+ linep[ ((vcStartX - 1)<<1) + 1]=255;
+ for(int newCutP= newCutPStart; newCutP <= newCutPEnd; newCutP++){
+ const byte phaseErr= phase1 + phasePerCutP[ newCutP ];
+ const int val= lastVal[lastCutP] - driftPenalty[drift];
+
+ if(newVal[newCutP] < val){
+ newVal[newCutP]= val;
+ dir[(line<<8) + newCutP]= lastCutP;
+ newPhaseErr[newCutP]= phaseErr;
+
+ noLeft=false;
+ }
+ drift++;
}
- drift++;
}
-
}
}
if(iState){
T2=uclock();
- tst2+=T2-T1;
+ TPhaseDiff2_Drift+=T2-T1-uclockWaste;
T1=T2;
}
@@ -537,7 +565,7 @@ void vc_decrypt(void){
for(int newCutP = 0; newCutP < 256; newCutP++){
if(!noLeft && newVal[newCutP]==0) continue;
- const byte * const p= &actVid2MemBufp->b[ linep + ((cutP2X[ newCutP ] + vcStartX)<<1) + 1 - 4 ];
+ const byte * const p= &linep[ ((cutP2X[ newCutP ] + vcStartX)<<1) + 1 - 4 ];
const int diff=edgeLut[ mabs( + int(* p ) + int(*(p+2))
- int(*(p+4)) - int(*(p+6)) ) ];
@@ -547,7 +575,7 @@ void vc_decrypt(void){
if(newVal[256] < newVal[newCutP]){
newVal[256]= newVal[newCutP];
- dir[line*257 + 256]= max(1, newCutP); // FIX (QUICKHACK)
+ bestDir[line]= newCutP;
}
}
@@ -555,7 +583,7 @@ void vc_decrypt(void){
if(iState){
T2=uclock();
- tst3+=T2-T1;
+ TEdgeDetect+=T2-T1-uclockWaste;
T1=T2;
}
@@ -566,13 +594,6 @@ void vc_decrypt(void){
byte *tempErr=lastPhaseErr;
lastPhaseErr=newPhaseErr;
newPhaseErr=tempErr;
-
- if(iState){
- T2=uclock();
- alg2+=T2-T1;
- T1=T2;
- }
-
}
delete [] convVec;
@@ -586,11 +607,11 @@ void vc_decrypt(void){
if(showPoints){
int bestCutP=-1;
for(int line=wndy-1; line>0; line--){
- if(dir[line*257 + 256]==0){
+ if(bestDir[line]==-1){
bestCutP=-1;
continue;
}
- if(bestCutP==-1) bestCutP= dir[line*257 + 256];
+ if(bestCutP==-1) bestCutP= bestDir[line];
if(bestCutP<0 || bestCutP>=256){
printf("one%d\n", bestCutP);
bestCutP=-1;
@@ -602,23 +623,16 @@ void vc_decrypt(void){
actVid2MemBufp->b[(line * vgax<<1) + ((vcStartX + bestX)<<1)+3]=0;
actVid2MemBufp->b[(line * vgax<<1) + ((vcStartX + bestX)<<1)+5]=255;
- bestCutP= dir[line*257 + bestCutP];
+ bestCutP= dir[(line<<8) + bestCutP];
}
}
-
- if(iState){
- T2=uclock();
- sprintf(textbuf[3],"%f Misc", (float)(T2-T1)/UCLOCKS_PER_SEC);
- T1=T2;
- }
-
int cutpp[1000];
byte copy_buff[max_x<<1];
int bestCutP=-1;
- linep=(wndy-1) * (vgax<<1);
- llinep=wndy * (vgax<<1);
+ linep= &actVid2MemBufp->b[ (wndy-1) * (vgax<<1) ];
+ llinep=&actVid2MemBufp->b[ wndy * (vgax<<1) ];
for(int line=wndy-2; line>0; line--){
linep-= vgax<<1;
llinep-= vgax<<1;
@@ -626,19 +640,19 @@ void vc_decrypt(void){
cutpp[line]=0;
if(black[line]){
- actVid2MemBufp->b[linep + ((vcStartX - 4)<<1) + 1]=255;
- actVid2MemBufp->b[linep + ((vcStartX - 4)<<1) + 3]=255;
+ linep[ ((vcStartX - 4)<<1) + 1 ]=255;
+ linep[ ((vcStartX - 4)<<1) + 3 ]=255;
}
if(showPoints){
- actVid2MemBufp->b[linep+(vcStartX<<1)+1]=255;
- actVid2MemBufp->b[linep+(vcStartX<<1)+3]=0;
+ linep[ (vcStartX<<1)+1 ]=255;
+ linep[ (vcStartX<<1)+3 ]=0;
}
- if(dir[line*257 + 256]==0){
+ if(bestDir[line]==-1){
bestCutP=-1;
continue;
}
- if(bestCutP==-1) bestCutP=dir[line*257 + 256];
+ if(bestCutP==-1) bestCutP=dir[(line<<8) + 256];
if(bestCutP<0 || bestCutP>=256){
printf("two%d\n", bestCutP);
@@ -658,7 +672,7 @@ void vc_decrypt(void){
const char c2= cos2PerCutP[ cutP ];
if( (line & 1) ^ ( vScore>0 ) ){
- char *p= (char*)( &actVid2MemBufp->b[ linep+((vcStartX & ~1)<<1) ] );
+ char *p= (char*)( &linep[ ((vcStartX & ~1)<<1) ] );
int x=0;
for(; x<cutX; x+=4){
const char u= * p;
@@ -708,33 +722,48 @@ void vc_decrypt(void){
-// actVid2MemBufp->b[linep+((vcStartX)<<1)+1]= 255;
+// linep[ ((vcStartX)<<1)+1 ]= 255;
- memcpy(copy_buff, actVid2MemBufp->b + linep + (vcStartX<<1), vcDiff<<1);
+ memcpy(copy_buff, linep + (vcStartX<<1), vcDiff<<1);
- memcpy(actVid2MemBufp->b + linep + (vcStartX<<1), copy_buff + (cutX<<1),
- (vcDiff-cutX)<<1);
- memcpy(actVid2MemBufp->b + linep + (vcStartX<<1) + ((vcDiff-cutX)<<1),
- copy_buff,
- cutX<<1);
+ memcpy(linep + (vcStartX<<1), copy_buff + (cutX<<1), (vcDiff-cutX)<<1);
+ memcpy(linep + (vcStartX<<1) + ((vcDiff-cutX)<<1), copy_buff, cutX<<1);
- if( (line & 1) ^ ( vScore>0 ) ^ 1 ){
- char *pl= (char*)( &actVid2MemBufp->b[llinep+ ((vcStartX<<1) & ~3) ] );
- char *pn= (char*)( &actVid2MemBufp->b[ linep+ ((vcStartX<<1) & ~3) ] );
- for(int x=0; x<vcDiff; x+=4){
+ if( !( (line & 1) ^ ( vScore>0 ) ) ){
+ char *pl= (char*)( &llinep[ ((vcStartX<<1) & ~3) ] );
+ char *pn= (char*)( &linep[ ((vcStartX<<1) & ~3) ] );
+/* for(int x=0; x<vcDiff; x+=4){
* pn = *(pn+4)= * pl;
*(pn+2)= *(pn+6)= *(pl+2);
pn+=8;
pl+=8;
- }
+ }*/
+ asm("1: \n\t"
+ "movb (%%esi, %%ecx), %%al \n\t"
+ "movb 2(%%esi, %%ecx), %%bl \n\t"
+ "movb %%al, (%%edi, %%ecx) \n\t"
+ "movb %%bl, 2(%%edi, %%ecx) \n\t"
+// "movb 4(%%esi, %%ecx), %%al \n\t"
+// "movb 6(%%esi, %%ecx), %%bl \n\t"
+ "movb %%al, 4(%%edi, %%ecx) \n\t"
+ "movb %%bl, 6(%%edi, %%ecx) \n\t"
+// "movb 8(%%edi, %%ecx), %%al \n\t"
+ "addl $8, %%ecx \n\t"
+ " jnc 1b \n\t"
+ :
+ : "D" (int(pn) + (vcDiff<<1)),
+ "S" (int(pl) + (vcDiff<<1)) ,
+ "c" (-vcDiff<<1)
+ : "%eax", "%ebx", "%ecx");
}
cutpp[line]=cutX;
- bestCutP= dir[line*257 + bestCutP];
+ bestCutP= dir[(line<<8) + bestCutP];
}
+/*
float avgCutP=0;
for(int line=50; line<200; line++){
avgCutP+=float(cutpp[line]);
@@ -742,36 +771,36 @@ void vc_decrypt(void){
avgCutP/=(200.0-50.0);
printf("avg%f\n", avgCutP-float(vcDiff)/2.0);
-
+ */
printf("vScore %d\n", vScore);
if(iState){
T2=uclock();
- sprintf(textbuf[0],"%f Corr", (float)(alg1)/UCLOCKS_PER_SEC);
- sprintf(textbuf[1],"%f Edge-Search", (float)(alg2)/UCLOCKS_PER_SEC);
- sprintf(textbuf[2],"%f ReSample", (float)(alg3)/UCLOCKS_PER_SEC);
- sprintf(textbuf[4],"%f Rotate", (float)(T2-T1)/UCLOCKS_PER_SEC);
- sprintf(textbuf[5],"%f tst1", (float)(tst1)/UCLOCKS_PER_SEC);
- sprintf(textbuf[6],"%f tst2", (float)(tst2)/UCLOCKS_PER_SEC);
- sprintf(textbuf[7],"%f tst3", (float)(tst3)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[0],"%f ReSample", (float)(TReSmp)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[1],"%f Correlate", (float)(TCorr)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[2],"%f UVDetect", (float)(TUVDetect)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[3],"%f FindPhaseDiff1", (float)(TPhaseDiff1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[4],"%f FindPhaseDiff2 / Drift", (float)(TPhaseDiff2_Drift)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[5],"%f EdgeDetect", (float)(TEdgeDetect)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[6],"%f Rotate / ColorFix", (float)(T2-T1-uclockWaste)/UCLOCKS_PER_SEC);
c.init(255, 0, 0, yuvmode);
- gprint(80, 80, c.col, textbuf[0]);
- gprint(90, 90, c.col, textbuf[1]);
- gprint(100, 100, c.col, textbuf[2]);
- gprint(110, 110, c.col, textbuf[3]);
- gprint(120, 120, c.col, textbuf[4]);
- gprint(130, 130, c.col, textbuf[5]);
- gprint(140, 140, c.col, textbuf[6]);
- gprint(150, 150, c.col, textbuf[7]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[0]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[1]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[2]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[3]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[4]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[5]);
+ gprint(infoPosX, infoPosY+=10, c.col, textbuf[6]);
+ infoPosY+=5;
T1=T2;
}
+ delete [] bestDir;
delete [] dir;
delete [] black;
-// delete [] phaseDiff;
}
1
0
Author: michael
Date: Wed Jul 4 09:30:32 2007
New Revision: 53
Log:
next version from unknown date
Modified:
trunk/2010/2_crypt.cc
trunk/2010/2_vc.cc
Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cc Wed Jul 4 09:30:32 2007
@@ -53,9 +53,9 @@ static void decomb(int q){
}
if(q==1){
- linep= stride*128;
+ linep= stride*256;
if(o) linep+=vgax<<1;
- for(line=128; line>=0; line--){
+ for(line=256; line>=0; line--){
for(i=0; i<wndx; i++){
j = char(actVid2MemBufp->b[linep + (i<<1)]);
Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cc Wed Jul 4 09:30:32 2007
@@ -24,11 +24,6 @@
// ? POINT_LAND + NO_POINT_LAND(1|2) = 910 (FIFO SIZE)
// ? NO_POINT_LAND + POINT_LAND = 1065 (PHASE ~+-60deg)
- // 142 142 16
- // 143 143 14
- // 144 144 12
- // 145 145 10
-
#define NO_POINT_LAND (NO_POINT_LAND1 + NO_POINT_LAND2 + NO_POINT_LAND3)
#define PHASE_POINT (fmod(FREQ_CHROM / (FREQ_SMP/3.0), 1.0) * PI * 2.0)
#define PHASE_SMP (fmod(FREQ_CHROM / (FREQ_SMP ), 1.0) * PI * 2.0)
@@ -36,16 +31,24 @@
* (POINT_LAND + NO_POINT_LAND), 1.0) * PI * 2.0)
-#define FIX_POINT 10
#define STEP_START 16
#define STEP_END 2
-#define VC_DEAD 7.5
#define DWN_SMP 1
#define MAX_DRIFT 2
+#define DRIFT_TAB {1200, 400, 0, 400, 1200}
#define PHASE_CMP_STEP 3
#define BAD_THRESHOLD1 0.8
#define BAD_THRESHOLD2 200
-#define PHASE_DIFF_TH 35
+#define EDGE_LIMIT 70
+#define MAX_EDGE 500
+#define EDGE_LOG_COEFF 10
+#define PHASE_EXP 4
+#define PHASE_LIMIT 40
+#define MAX_PHASE_PENALTY 1000
+#define AMP_THRESHOLD 200
+
+#define PHASE_COEFF (MAX_PHASE_PENALTY/pow(PHASE_LIMIT, PHASE_EXP))
+#define EDGE_COEFF (MAX_EDGE/log(EDGE_LIMIT*EDGE_LOG_COEFF))
#define NUM_PHASE_SMP (vcDiff>>PHASE_CMP_STEP)
@@ -59,11 +62,9 @@ extern int yuvmode;
extern int some;
extern bool mmx;
-// FIX ABS ??
-
static inline float atan3(const float f1, const float f2){
float out;
- // ? don't know what atan2 does ( crashes )
+ // ?! atan2 crashes
asm(//"int $3\n\t"
"fpatan \n\t"
: "=t"(out)
@@ -82,25 +83,10 @@ void vc_decrypt(void){
long alg1=0, alg2=0, alg3=0;
color c;
- int tempScore[2]={0 ,0};
-
- for(int i=0; i<360; i++){
- double d=i;
-
-// asm("int $3\n\t");
- double a=atan2(cos(d/180*PI), sin(d/180*PI));
- double a2=atan3(cos(d/180*PI), sin(d/180*PI));
- if(a<0.0) a+=PI*2;
- if(a2<0.0) a2+=PI*2;
- printf("xyz %f %f\n",a,a2);
- }
-
const int lowResSize= mmx ? DWN_SMP : (DWN_SMP-1);
printf("xx%f %f %f\n", PHASE_POINT/PI*180, PHASE_SEG/PI*180, PHASE_SMP/PI*180);
- double temp[1000][2];
-
int vScore=0;
// showPoints=true;
@@ -113,7 +99,6 @@ void vc_decrypt(void){
static int cutP2X[256];
static int x2CutP[max_x];
-// static byte atanLut[ 1<< (ATAN_LUT_SIZE<<1) ]
static int wndxBak= -1;
if(wndx != wndxBak){
@@ -132,11 +117,12 @@ void vc_decrypt(void){
}
const int vcEndX= vcStartX + int( double(POINT_LAND + NO_POINT_LAND)
* freqPix2 / FREQ_SMP + .5);
+
printf("vcEndX %d\n",vcEndX);
if(vcEndX>wndx) error(error_code(-123));
const int vcDiff=vcEndX - vcStartX;
- const int minDist= cutP2X[0]-1;
+ const int minDist= cutP2X[0];
cutPointX[0]=0;
@@ -152,28 +138,38 @@ void vc_decrypt(void){
}
static int edgeLut[512];
+ static int phaseLut[128];
static bool first= true;
- static int score[40];
static byte phasePerCutP[256];
+ static char sin1PerCutP[256];
+ static char cos1PerCutP[256];
+ static char sin2PerCutP[256];
+ static char cos2PerCutP[256];
if(first){
some=10;
- edgeLut[0]=0;
- for(int i=1; i<512; i++){
- const int j= min(i, 70);
- edgeLut[i]=int( log(j*10)*100.0 );
+ for(int i=0; i<512; i++){
+ const int j= min(i+1, EDGE_LIMIT);
+ edgeLut[i]=int( log(j*EDGE_LOG_COEFF)*EDGE_COEFF );
+ }
+
+ for(int i=0; i<128; i++){
+ const int j= max(min(i, PHASE_LIMIT), 1);
+ phaseLut[i]=int( pow(j, PHASE_EXP)*PHASE_COEFF );
}
- first=false;
for(int cutP=0; cutP<256; cutP++){
- const double phase= PHASE_SMP*(NO_POINT_LAND1 + NO_POINT_LAND3 + 1) + PHASE_POINT*cutP;
+ const double phase= PHASE_SMP*(NO_POINT_LAND1 + NO_POINT_LAND3) + PHASE_POINT*cutP;
phasePerCutP[cutP]= (byte)( phase * 128 / PI );
- printf("ppcp %d %d\n", cutP, phasePerCutP[cutP]*360/256);
+ sin1PerCutP[cutP]= char(sin( -phase + PHASE_SEG )*127);
+ cos1PerCutP[cutP]= char(cos( -phase + PHASE_SEG )*127);
+ sin2PerCutP[cutP]= char(sin( -phase )*127);
+ cos2PerCutP[cutP]= char(cos( -phase )*127);
}
- for(int i=0; i<40; i++) score[i]=0;
+ first=false;
}
@@ -184,8 +180,6 @@ void vc_decrypt(void){
const float cosSegPhase2= cos(PHASE_SEG*2);
bool *black= new bool[wndy];
- int *phaseDiff= new int[(vcDiff*wndy)>>PHASE_CMP_STEP];
- int *chromAmp= new int[wndy];
int llinep=-(vgax<<2);
int linep=-(vgax<<1);
@@ -325,22 +319,23 @@ void vc_decrypt(void){
firstPass=false;
}
- if( int( avgDiff*BAD_THRESHOLD1/double(avgDiffNum) ) - BAD_THRESHOLD2
+ if( int( avgDiff*BAD_THRESHOLD1/float(avgDiffNum) ) - BAD_THRESHOLD2
< bestDiff )
black[line]=true;
if(line>2){
int sumI=0;
- for(int x=-4; x<0; x+=2){
+ for(int x=-2; x<2; x+=2){
const int nx= x + (vcDiff & ~1);
const int ul= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + x)<<1) + 0]);
const int vl= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + x)<<1) + 2]);
const int un= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 0]);
const int vn= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 2]);
sumI+= ul*vn - vl*un;
+// actVid2MemBufp->b[linep + (((vcStartX & ~1) - x)<<1) + 1]=255;
+// actVid2MemBufp->b[linep + (((vcStartX & ~1) - nx)<<1) + 1]=255;
}
-// actVid2MemBufp->b[linep + (((vcStartX & ~1) - 4)<<1) + 1]=255;
if(line>10 && line<250){
if(line & 1){
@@ -363,17 +358,21 @@ void vc_decrypt(void){
}
}
- delete [] convVec;
deleteAlign(lowRes[0]);
deleteAlign(lowRes[1]);
- int *dir=new int[257*(wndy + 1)];
+ byte *dir=new byte[257*(wndy + 1)];
- const int driftPenalty[MAX_DRIFT*2+1]={10000, 1000, 0, 1000, 10000};
+ const int driftPenalty[MAX_DRIFT*2+1]= DRIFT_TAB;
int *newVal=new int[257], *lastVal=new int[257];
memset(lastVal, 0, 257<<2);
+ byte *newPhaseErr=new byte[256], *lastPhaseErr=new byte[256];
+ memset(lastPhaseErr, 0, 256);
+
+ long tst1=0, tst2=0, tst3=0;
+
llinep=-(vgax<<2);
linep=-(vgax<<1);
for(int line=0; line<wndy; line++){
@@ -381,16 +380,17 @@ void vc_decrypt(void){
linep+=vgax<<1;
memset(newVal, 0, 257<<2);
+ memset(newPhaseErr, 0, 256);
bool noLeft=true;
- dir[line*257 + 256]=-1;
+ dir[line*257 + 256]=0;
if(line==0) continue;
int relCutPX= cutPointX[line] - cutPointX[line-1];
if(relCutPX<0) relCutPX+=vcDiff;
- chromAmp[line]=0;
+ int chromAmp=1;
for(int x=0; x<vcDiff; x+= 1<<PHASE_CMP_STEP){
int nx= x + (relCutPX & ~1);
if(nx>=vcDiff) nx-= (vcDiff & ~1);
@@ -401,27 +401,36 @@ void vc_decrypt(void){
const int p= x>>(PHASE_CMP_STEP-1);
convVec[p ]= ul*un + vl*vn;
convVec[p+1]= ul*vn - vl*un;
- chromAmp[line]+= un*un + vn*vn;
+ chromAmp+= mabs(un) + mabs(vn);
}
-
+
// actVid2MemBufp->b[linep + ((vcStartX + 0)<<1) + 1]=255;
// actVid2MemBufp->b[linep + ((vcStartX + relCutPX)<<1) + 1]=200;
+ if(iState){
+ T2=uclock();
+ tst1+=T2-T1;
+ T1=T2;
+ }
+
int sumR0=0, sumI0=0;
int sumR1=0, sumI1=0;
- for(int x=0; x<vcDiff; x+= 1<<PHASE_CMP_STEP){
- const int p= x>>(PHASE_CMP_STEP-1);
- if(x+relCutPX<vcDiff){
+
+ {
+ int x=0;
+ for(; x<vcDiff-relCutPX; x+= 1<<PHASE_CMP_STEP){
+ const int p= x>>(PHASE_CMP_STEP-1);
sumR0+= convVec[p ];
sumI0+= convVec[p+1];
}
- else{
+ for(; x<vcDiff; x+= 1<<PHASE_CMP_STEP){
+ const int p= x>>(PHASE_CMP_STEP-1);
sumR1+= convVec[p ];
sumI1+= convVec[p+1];
}
}
- const float s= ( (line & 1) ^ ( vScore>0 ) ) ? 1 : -1;
+ const float s= ( (line & 1) ^ ( vScore>0 ) ) ? -1 : 1;
int sumR0C= int( sumR0*cosSegPhase + sumI0*sinSegPhase*s);
int sumI0C= int(-sumR0*sinSegPhase*s + sumI0*cosSegPhase);
@@ -433,114 +442,131 @@ void vc_decrypt(void){
int ssR0=sumR0, ssI0=sumI0;
int ffR1=0 , ffI1=0;
int ssR1=sumR1, ssI1=sumI1;
- const int phaseP= line*vcDiff>>PHASE_CMP_STEP;
- for(int x=0; x<vcDiff; x+= 1<<PHASE_CMP_STEP){
- const int p= x>>(PHASE_CMP_STEP-1);
- const int q= x>> PHASE_CMP_STEP;
- if(x+relCutPX<vcDiff){
- ssR0-=convVec[p ];
- ssI0-=convVec[p+1];
- const int r= ffR0 + sumR1C;
- const int i= ffI0 + sumI1C;
+ int lastPhasePos=0;
+
+ byte ang=0;
+ if(!black[line]){
+ for(int lastCutP = 0; lastCutP < 256; lastCutP++){
+ if(lastVal[lastCutP]==0) continue;
- phaseDiff[phaseP + q ]= int( atan3(i, r)/PI*128 ) & 0xFF;
-/*
- phaseDiff[phaseP + q ]= ffR0 ;//+ sumR1C;
- phaseDiff[phaseP + q+1]= ffI0 ;//+ sumI1C;
- phaseDiff[phaseP + q+2]= ssR0;
- phaseDiff[phaseP + q+3]= ssI0;
- */
- ffR0+=convVec[p ];
- ffI0+=convVec[p+1];
- }
- else{
- ssR1-=convVec[p ];
- ssI1-=convVec[p+1];
+ const int newPhasePos= cutP2X[ lastCutP ] & ((-1) << PHASE_CMP_STEP);
- const int r= ffR1 + sumR0C;
- const int i= ffI1 + sumI0C;
+ if( newPhasePos >= lastPhasePos ){
- phaseDiff[phaseP + q ]= int( atan3(i, r)/PI*128 ) & 0xFF;
-/*
- phaseDiff[phaseP + q ]= ffR1 ;//+ sumR0C;
- phaseDiff[phaseP + q+1]= ffI1 ;//+ sumI0C;
- phaseDiff[phaseP + q+2]= ssR1;
- phaseDiff[phaseP + q+3]= ssI1;
- */
- ffR1+=convVec[p ];
- ffI1+=convVec[p+1];
- }
- }
+ for(; lastPhasePos <= newPhasePos; lastPhasePos += (1<<PHASE_CMP_STEP)){
+ const bool isLast= lastPhasePos == newPhasePos;
+
+ const int p= lastPhasePos>>(PHASE_CMP_STEP-1);
+
+ if(lastPhasePos+relCutPX<vcDiff){
+ ssR0-=convVec[p ];
+ ssI0-=convVec[p+1];
+
+ if(isLast){
+ const int r= ssR0 + sumR1C + int( ffR0*cosSegPhase2 + ffI0*sinSegPhase2*s);
+ const int i= ssI0 + sumI1C + int(-ffR0*sinSegPhase2*s + ffI0*cosSegPhase2);
- for(int lastCutP = 0; lastCutP < 256; lastCutP++){
- if(black[line] || lastVal[lastCutP]==0) continue;
+ ang= (byte)( atan3(i, r)/PI*128 );
+ }
- int newXTemp= cutPointX[line] - cutPointX[line-1] + cutP2X[lastCutP];
- if(newXTemp < 0 ) newXTemp+= vcDiff;
- if(newXTemp >= vcDiff) newXTemp-= vcDiff;
- if(newXTemp >= vcDiff) newXTemp-= vcDiff;
+ ffR0+=convVec[p ];
+ ffI0+=convVec[p+1];
+ }
+ else{
+ ssR1-=convVec[p ];
+ ssI1-=convVec[p+1];
+
+ if(isLast){
+ const int r= ssR1 + sumR0C + int( ffR0*cosSegPhase2 + ffI0*sinSegPhase2*s);
+ const int i= ssI1 + sumI0C + int(-ffR0*sinSegPhase2*s + ffI0*cosSegPhase2);
- const int newCutPStart= max(x2CutP[ newXTemp ] - MAX_DRIFT, 0);
- const int newCutPEnd= min(x2CutP[ newXTemp ] + MAX_DRIFT, 256);
+ ang= (byte)( atan3(i, r)/PI*128 );
+ }
- int drift= newCutPStart - (x2CutP[ newXTemp ] - MAX_DRIFT);
+ ffR1+=convVec[p ];
+ ffI1+=convVec[p+1];
+ }
- const int p= (line*vcDiff>>PHASE_CMP_STEP)
- +(cutP2X[ lastCutP ]>>PHASE_CMP_STEP);
+ }
+ }
- int a= phaseDiff[p ];
- if( (line & 1) ^ ( vScore>0 ) ) a= -a;
+ int newXTemp= cutPointX[line] - cutPointX[line-1] + cutP2X[lastCutP];
+ if(newXTemp < 0 ) newXTemp+= vcDiff;
+ if(newXTemp >= vcDiff) newXTemp-= vcDiff;
+ if(newXTemp >= vcDiff) newXTemp-= vcDiff;
- const int phase1= a + phasePerCutP[ lastCutP ];
+ const int newCutPStart= max(x2CutP[ newXTemp ] - MAX_DRIFT, 0);
+ const int newCutPEnd= min(x2CutP[ newXTemp ] + MAX_DRIFT, 256);
+
+ int drift= newCutPStart - (x2CutP[ newXTemp ] - MAX_DRIFT);
+
+ const byte a= (line & 1) ^ ( vScore>0 ) ? -ang: ang;
+
+ const byte phase1= a + phasePerCutP[ lastCutP ];
- for(int newCutP= newCutPStart; newCutP <= newCutPEnd; newCutP++){
- int val= lastVal[lastCutP] - driftPenalty[drift];
- int phase= phase1 + phasePerCutP[ newCutP ];
- phase&= 0xFF;
- phase= mabs( phase - 128 );
- if(chromAmp[line]>3000 && phase>=PHASE_DIFF_TH) val-=100000;
- if(chromAmp[line]<=3000)
- actVid2MemBufp->b[linep + ((vcStartX - 1)<<1) + 1]=255;
-
- if(newVal[newCutP] < val){
- newVal[newCutP]= val;
- dir[line*257 + newCutP]= lastCutP;
+ for(int newCutP= newCutPStart; newCutP <= newCutPEnd; newCutP++){
+ int val= lastVal[lastCutP] - driftPenalty[drift];
+ const byte phaseErr= phase1 + phasePerCutP[ newCutP ];
- noLeft=false;
+ if(chromAmp>AMP_THRESHOLD && line>4)
+ val-= phaseLut[ mabs( char(phaseErr - 128) ) ]
+ + phaseLut[ mabs( char(phaseErr - lastPhaseErr[lastCutP]) ) ];// useless without phase errors from decomb-filter
+ else actVid2MemBufp->b[linep + ((vcStartX - 1)<<1) + 1]=255;
+
+ if(newVal[newCutP] < val){
+ newVal[newCutP]= val;
+ dir[line*257 + newCutP]= lastCutP;
+ newPhaseErr[newCutP]= phaseErr;
+
+ noLeft=false;
+ }
+ drift++;
}
- drift++;
+
}
+ }
+ if(iState){
+ T2=uclock();
+ tst2+=T2-T1;
+ T1=T2;
}
- for(int newCutP = 0; newCutP < 256; newCutP++){
- if(black[line]) continue;
- if(!noLeft && newVal[newCutP]==0) continue;
+ if(!black[line]){
+ for(int newCutP = 0; newCutP < 256; newCutP++){
+ if(!noLeft && newVal[newCutP]==0) continue;
- const int newX= cutP2X[ newCutP ];
+ const byte * const p= &actVid2MemBufp->b[ linep + ((cutP2X[ newCutP ] + vcStartX)<<1) + 1 - 4 ];
- const int diff=edgeLut[ mabs(
- +actVid2MemBufp->b[linep + ((vcStartX + newX - 2)<<1) + 1]
- +actVid2MemBufp->b[linep + ((vcStartX + newX - 1)<<1) + 1]
- -actVid2MemBufp->b[linep + ((vcStartX + newX )<<1) + 1]
- -actVid2MemBufp->b[linep + ((vcStartX + newX + 1)<<1) + 1] ) ];
+ const int diff=edgeLut[ mabs( + int(* p ) + int(*(p+2))
+ - int(*(p+4)) - int(*(p+6)) ) ];
+
+ if(newVal[newCutP]==0) newVal[newCutP] = diff + 1000000000;
+ else newVal[newCutP] += diff;
- if(newVal[newCutP]==0) newVal[newCutP] = diff + 1000000000;
- else newVal[newCutP] += diff;
+ if(newVal[256] < newVal[newCutP]){
+ newVal[256]= newVal[newCutP];
+ dir[line*257 + 256]= max(1, newCutP); // FIX (QUICKHACK)
+ }
- if(newVal[256] < newVal[newCutP]){
- newVal[256]= newVal[newCutP];
- dir[line*257 + 256]= newCutP;
}
-
}
+ if(iState){
+ T2=uclock();
+ tst3+=T2-T1;
+ T1=T2;
+ }
int *tempVal=lastVal;
lastVal=newVal;
newVal=tempVal;
+ byte *tempErr=lastPhaseErr;
+ lastPhaseErr=newPhaseErr;
+ newPhaseErr=tempErr;
+
if(iState){
T2=uclock();
alg2+=T2-T1;
@@ -549,23 +575,18 @@ void vc_decrypt(void){
}
+ delete [] convVec;
+
delete [] newVal;
delete [] lastVal;
-
- if(iState){
- T2=uclock();
- sprintf(textbuf[0],"%f Corr", (float)(alg1)/UCLOCKS_PER_SEC);
- sprintf(textbuf[1],"%f Edge-Search", (float)(alg2)/UCLOCKS_PER_SEC);
- sprintf(textbuf[2],"%f ReSample", (float)(alg3)/UCLOCKS_PER_SEC);
- T1=T2;
- }
-
+ delete [] newPhaseErr;
+ delete [] lastPhaseErr;
if(showPoints){
int bestCutP=-1;
for(int line=wndy-1; line>0; line--){
- if(dir[line*257 + 256]==-1){
+ if(dir[line*257 + 256]==0){
bestCutP=-1;
continue;
}
@@ -597,8 +618,10 @@ void vc_decrypt(void){
int bestCutP=-1;
linep=(wndy-1) * (vgax<<1);
+ llinep=wndy * (vgax<<1);
for(int line=wndy-2; line>0; line--){
linep-= vgax<<1;
+ llinep-= vgax<<1;
cutpp[line]=0;
@@ -611,7 +634,7 @@ void vc_decrypt(void){
actVid2MemBufp->b[linep+(vcStartX<<1)+1]=255;
actVid2MemBufp->b[linep+(vcStartX<<1)+3]=0;
}
- if(dir[line*257 + 256]==-1){
+ if(dir[line*257 + 256]==0){
bestCutP=-1;
continue;
}
@@ -627,47 +650,66 @@ void vc_decrypt(void){
int cutX= (showPoints ? cutPointX[line] : bestX );
-/*
- const int cutP= min(x2CutP[cutX], 0); // fix ? ness, max?
+ const int cutP= max(x2CutP[cutX], 0); // fix ? ness, min?
+
+ const char s1= sin1PerCutP[ cutP ];
+ const char c1= cos1PerCutP[ cutP ];
+ const char s2= sin2PerCutP[ cutP ];
+ const char c2= cos2PerCutP[ cutP ];
- const float s1= sin( -float(phasePerCutP[ cutP ] + some)/128*PI + PHASE_SEG );
- const float c1= cos( -float(phasePerCutP[ cutP ] + some)/128*PI + PHASE_SEG );
- const float s2= sin( -float(phasePerCutP[ cutP ] + some)/128*PI );
- const float c2= cos( -float(phasePerCutP[ cutP ] + some)/128*PI );
+ if( (line & 1) ^ ( vScore>0 ) ){
+ char *p= (char*)( &actVid2MemBufp->b[ linep+((vcStartX & ~1)<<1) ] );
+ int x=0;
+ for(; x<cutX; x+=4){
+ const char u= * p;
+ const char v= *(p+2);
- for(int x=0; x<vcDiff; x+=2){
- const char u=char(actVid2MemBufp->b[linep+((vcStartX + x)<<1) ]);
- const char v=char(actVid2MemBufp->b[linep+((vcStartX + x)<<1)+2]);
- char u1, v1;
+ const char u1=(char)(( - v*c1 - u*s1)>>7);
+ const char v1=(char)(( + v*s1 - u*c1)>>7);
- float s, c;
- if(x<cutP){
- s= s1;
- c= c1;
- }
- else{
- s= s2;
- c= c2;
+ if( (vcDiff - cutX) & 1 ){
+ * p = v1;
+ *(p+2)= u1;
+ *(p+4)= v1;
+ *(p+6)= u1;
+ }
+ else{
+ * p = u1;
+ *(p+2)= v1;
+ *(p+4)= u1;
+ *(p+6)= v1;
+ }
+ p+=8;
}
+ for(; x<vcDiff; x+=4){
+ const char u= * p;
+ const char v= *(p+2);
- if( (line & 1) ^ ( vScore>0 ) ){
- v1=(char)( -u*c - v*s );
- u1=(char)( -v*c + u*s );
- }
- else{
- v1=(char)( -u*c + v*s );
- u1=(char)( -v*c - u*s );
+ const char u1=(char)(( - v*c2 - u*s2)>>7);
+ const char v1=(char)(( + v*s2 - u*c2)>>7);
+
+ if( cutX & 1 ){
+ * p = v1;
+ *(p+2)= u1;
+ *(p+4)= v1;
+ *(p+6)= u1;
+ }
+ else{
+ * p = u1;
+ *(p+2)= v1;
+ *(p+4)= u1;
+ *(p+6)= v1;
+ }
+ p+=8;
}
+ }
- printf("uv %d %d %d %d \n", u,v,u1,v1);
- actVid2MemBufp->b[linep+((vcStartX + x)<<1) ]= u1;
- actVid2MemBufp->b[linep+((vcStartX + x)<<1)+2]= v1;
- }
- cutX&= ~1;
- */
+
+// actVid2MemBufp->b[linep+((vcStartX)<<1)+1]= 255;
+
memcpy(copy_buff, actVid2MemBufp->b + linep + (vcStartX<<1), vcDiff<<1);
memcpy(actVid2MemBufp->b + linep + (vcStartX<<1), copy_buff + (cutX<<1),
@@ -676,67 +718,30 @@ void vc_decrypt(void){
copy_buff,
cutX<<1);
+ if( (line & 1) ^ ( vScore>0 ) ^ 1 ){
+ char *pl= (char*)( &actVid2MemBufp->b[llinep+ ((vcStartX<<1) & ~3) ] );
+ char *pn= (char*)( &actVid2MemBufp->b[ linep+ ((vcStartX<<1) & ~3) ] );
+ for(int x=0; x<vcDiff; x+=4){
+ * pn = *(pn+4)= * pl;
+ *(pn+2)= *(pn+6)= *(pl+2);
+ pn+=8;
+ pl+=8;
+ }
+ }
+
cutpp[line]=cutX;
bestCutP= dir[line*257 + bestCutP];
}
- for(int line=80; line<200; line++){
- if( (line & 1) ^ ( vScore>0 ) ) printf(" e");
- else printf(" o");
-
- const int p= (cutpp[line-1]>>PHASE_CMP_STEP)
- + (line*vcDiff>>PHASE_CMP_STEP) ;
- int a= phaseDiff[p ];
-
- int relCutp= cutpp[line-1] + cutpp[line];
- if(relCutp>=vcDiff) relCutp-=vcDiff;
-
- printf("c%03d %03d %03d %03d\n", relCutp, a*180/128, x2CutP[cutpp[line-1]], x2CutP[cutpp[line]]);
- //SIGSEGV
-
- const int cut1= x2CutP[ cutpp[line-1] ];
- const int cut2= x2CutP[ cutpp[line ] ];
-
- if(cut1<30 || cut1>220) continue;
- if(cut2<30 || cut2>220) continue;
-
- for(int offset=-20; offset<20; offset++){
- int diff;
- if( (line & 1) ^ ( vScore>0 ) ){
- diff= phasePerCutP[ cut1 + offset ]
- + phasePerCutP[ cut2 + offset ]
- - a;
- }
- else{
- diff= phasePerCutP[ cut1 + offset ]
- + phasePerCutP[ cut2 + offset ]
- + a;
- }
-
- diff&= 0xFF;
-
- diff=mabs( diff-128 );
- if(diff<PHASE_DIFF_TH && chromAmp[line]>3000) diff=1;
- else if(chromAmp[line]>3000) diff=100000;
- else diff=0;
- score[offset+20]+=diff;
- }
-
-// int cutP2=cutpp[line] - cutpp[line-2];
-// if(cutP2<0) cutP2+= vcDiff;
- }
-
- for(int i=0; i<40; i++)
- printf("score %d %d\n", score[i], i-20);
-
- double avgCutP=0;
+ float avgCutP=0;
for(int line=50; line<200; line++){
- avgCutP+=double(cutpp[line]);
+ avgCutP+=float(cutpp[line]);
}
+
avgCutP/=(200.0-50.0);
- printf("avg%f\n", avgCutP-double(vcDiff)/2.0);
+ printf("avg%f\n", avgCutP-float(vcDiff)/2.0);
printf("vScore %d\n", vScore);
@@ -744,21 +749,29 @@ void vc_decrypt(void){
if(iState){
T2=uclock();
+ sprintf(textbuf[0],"%f Corr", (float)(alg1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[1],"%f Edge-Search", (float)(alg2)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[2],"%f ReSample", (float)(alg3)/UCLOCKS_PER_SEC);
sprintf(textbuf[4],"%f Rotate", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[5],"%f tst1", (float)(tst1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[6],"%f tst2", (float)(tst2)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[7],"%f tst3", (float)(tst3)/UCLOCKS_PER_SEC);
c.init(255, 0, 0, yuvmode);
gprint(80, 80, c.col, textbuf[0]);
gprint(90, 90, c.col, textbuf[1]);
gprint(100, 100, c.col, textbuf[2]);
gprint(110, 110, c.col, textbuf[3]);
gprint(120, 120, c.col, textbuf[4]);
- T1=T2;
+ gprint(130, 130, c.col, textbuf[5]);
+ gprint(140, 140, c.col, textbuf[6]);
+ gprint(150, 150, c.col, textbuf[7]);
+ T1=T2;
}
delete [] dir;
delete [] black;
- delete [] phaseDiff;
- delete [] chromAmp;
+// delete [] phaseDiff;
}
1
0
[mndiff]: r52 - in trunk/2010: 2010.cc 2_71x6.cc 2_all.h 2_all_a.asm 2_crypt.cc 2_file.cc 2_grafix.cc 2_nag.cc 2_nag_a.asm 2_vc.cc 2_vc_a.asm 2_vc_a.h 2d
by michael 04 Jul '07
by michael 04 Jul '07
04 Jul '07
Author: michael
Date: Wed Jul 4 09:25:09 2007
New Revision: 52
Log:
next version (unknown date)
Modified:
trunk/2010/2010.cc
trunk/2010/2_71x6.cc
trunk/2010/2_all.h
trunk/2010/2_all_a.asm
trunk/2010/2_crypt.cc
trunk/2010/2_file.cc
trunk/2010/2_grafix.cc
trunk/2010/2_nag.cc
trunk/2010/2_nag_a.asm
trunk/2010/2_vc.cc
trunk/2010/2_vc_a.asm
trunk/2010/2_vc_a.h
trunk/2010/2d
Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cc Wed Jul 4 09:25:09 2007
@@ -32,10 +32,11 @@
extern int active_meteor;
extern int yuvmode;
extern bool mmx;
- extern int *best1;
- extern BEST2 *best2;
- extern u_short *keysList;
- extern int *decoLine;
+// extern short *linesPerKeyTab;
+// extern int *best1;
+// extern BEST2 *best2;
+// extern u_short *keysList;
+// extern int *decoLine;
extern int bright, contr, satur;
extern int showCont;
extern CRYPTSTD cryptStd;
@@ -44,6 +45,7 @@
extern bool helpState;
int maxBuf=2;
+ int some=0;
int _crt0_startup_flags = _CRT0_FLAG_NEARPTR | _CRT0_FLAG_NONMOVE_SBRK;
int grabf;
@@ -111,6 +113,7 @@ int error(error_code e){
" -m n (Meteor Card) in case there are more than 1 (:\n"
" -NoFlip (Disable Page-Fliping)\n"
" -NoMMX (Disable MMX-Support)\n"
+ " -MaxBuf (num of Buffers)\n"
" -? / -h (This stuff)\n");
break;
default : printg_t("\nUnknown error!");
@@ -122,10 +125,6 @@ int error(error_code e){
void exitt(void){
close_hw();
- delete [] decoLine;
- delete [] best1;
- delete [] best2;
- delete [] keysList;
}
int main(int argc, char **argv){
@@ -333,11 +332,9 @@ int main(int argc, char **argv){
- if(kbhit()){
+ while(kbhit()){
int key= getkey();
- while(kbhit()) getkey();
-
switch(menuLevel){
case mLNorm : switch(key){
case 'g' :
@@ -392,6 +389,10 @@ int main(int argc, char **argv){
break;
case '2' : delay--; if(delay<0) delay=0;
break;
+ case '3' : some++;
+ break;
+ case '4' : some--; if(some<0) some=0;
+ break;
}
break;
case mLTVStd : switch(key){
Modified: trunk/2010/2_71x6.cc
==============================================================================
--- trunk/2010/2_71x6.cc (original)
+++ trunk/2010/2_71x6.cc Wed Jul 4 09:25:09 2007
@@ -17,6 +17,7 @@
//#define wait_time 0.010
#define wait_time 0.020
+//#define NoColorDeco
extern meteor meteors[8];
extern __Go32_Info_Block _go32_info_block;
@@ -48,8 +49,8 @@ extern int vgax, vgay;
int v_smooth=1;
int bright=0x80, satur=0x40, contr=0x40;
-//int scales_x=0x03, scales_y= 0x10; 3 / 574 / 3 nag 800600
-//int scalee_x=0x03, scalee_y= 0x12;
+//int scales_x=0x03, scales_y= 0x11;
+//int scalee_x=0x03, scalee_y= 0x11;
int scales_x=0x03, scales_y= 0x11;
int scalee_x=0x03, scalee_y= 0x11;
@@ -521,7 +522,11 @@ void init_meteor(void){
write_saa7196(0x05, 0xF4);/* 7:0 Horizontal Sync Start after PH1 for 50hz */
+#ifndef NoColorDeco
write_saa7196(0x06, 0x46); //46
+#else
+ write_saa7196(0x06, 0xC6); //46
+#endif
/* 7 Input mode =0 CVBS, =1 S-Video
6 Pre filter
5:4 Aperture Bandpass characteristics
@@ -541,9 +546,12 @@ void init_meteor(void){
2 S-VHS bit
1 GPSW2
0 GPSW1 */
-write_saa7196(0x10, 0x00); //BAK
//write_saa7196(0x10, 0x02);
-// write_saa7196(0x10, 0x04);
+#ifndef NoColorDeco
+ write_saa7196(0x10, 0x00);
+#else
+ write_saa7196(0x10, 0x04);
+#endif
/* 2 Select HREF Position
1:0 Vertical noise reduction */
write_saa7196(0x11, 0x2C);/* 7:0 Chrominance gain conrtol for QAM */
Modified: trunk/2010/2_all.h
==============================================================================
--- trunk/2010/2_all.h (original)
+++ trunk/2010/2_all.h Wed Jul 4 09:25:09 2007
@@ -10,6 +10,8 @@
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
+#define minmax(a,b,c) ((a)>(b) ? (a) : ( (b)<(c) ? (b) : (c) ))
+
#define limit(a,b,c) if( (a)<(b) || (a)>(c) ) error(-201)
@@ -25,6 +27,7 @@
struct COL{
long yuv;
short rgb16;
+ byte r, g, b;
};
/*
@@ -65,12 +68,15 @@ class color{
public:
COL col;
color(void) { };
- void init(byte y, byte u, byte v, byte yuv_mode){
+ void init(int y, int u, int v, byte yuv_mode){ // fix (yuv_mode==0)
col.yuv= u | (y<<8) | (v<<16) | (y<<24);
- const int r= (int( y + 1.375 *v )>>3) & 0x1F;
- const int g= (int( y - 0.703125*v - 0.34375*u )>>2) & 0x1F;
- const int b= (int( y + 1.734375*u)>>3) & 0x1F;
- col.rgb16= b | (g<<5) | (r<<11);
+ col.r=minmax(0, int( y + 1.375 *v ), 255);
+ col.g=minmax(0, int( y - 0.703125*v - 0.34375*u ), 255);
+ col.b=minmax(0, int( y + 1.734375*u), 255);
+ const int r5= ((col.r>>3) & 0x1F);
+ const int g6= ((col.g>>2) & 0x3F);
+ const int b5= ((col.b>>3) & 0x1F);
+ col.rgb16= b5 | (g6<<5) | (r5<<11);
};
} ;
Modified: trunk/2010/2_all_a.asm
==============================================================================
--- trunk/2010/2_all_a.asm (original)
+++ trunk/2010/2_all_a.asm Wed Jul 4 09:25:09 2007
@@ -1,13 +1,19 @@
; 2010 0.1 Copyright (C) Michael Niedermayer 1998
-%define par1 (esp + 28)
-%define par2 (esp + 32)
-%define par3 (esp + 36)
-%define par4 (esp + 40)
-%define par5 (esp + 44)
-%define par6 (esp + 48)
-%define par7 (esp + 52)
-%define par8 (esp + 56)
+%define par_5 (esp + 04)
+%define par_4 (esp + 08)
+%define par_3 (esp + 12)
+%define par_2 (esp + 16)
+%define par_1 (esp + 20)
+%define par0 (esp + 24)
+%define par1 (esp + 28)
+%define par2 (esp + 32)
+%define par3 (esp + 36)
+%define par4 (esp + 40)
+%define par5 (esp + 44)
+%define par6 (esp + 48)
+%define par7 (esp + 52)
+%define par8 (esp + 56)
;%define int3 db 0xCC
Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cc Wed Jul 4 09:25:09 2007
@@ -18,17 +18,17 @@ extern volatile bool oneField;
extern int satur;
static void vSmooth(void);
-static void decomb(void);
+static void decomb(int q);
bool vSmoothState=true;
-int show_points=0;
+bool showPoints=false;
asm("__esp: .long 0\n\t");
void decrypt(void){
- if( cryptStd == nag && satur!=0 ) decomb();
-// decomb();
+ if( cryptStd == nag && satur!=0 ) decomb(0);
+ if( cryptStd == vc && satur!=0 ) decomb(1);
if(cryptStd==vc) vc_decrypt();
else if(cryptStd==nag) nag_decrypt();
@@ -38,8 +38,7 @@ void decrypt(void){
}
-static void decomb(void){
- int segs=1;
+static void decomb(int q){
int linep, llinep, line, i;
int j, k;
int temp[max_x];
@@ -48,32 +47,43 @@ static void decomb(void){
const int stride=oneField ? (vgax<<1) : (vgax<<2);
const int o=oneField ? 0 : 1;
const int end=oneField ? outy : outy1;
- const int segSize= end/segs;
- int startp= 0;
- for(int seg=0; seg<segs; seg++){
+ for(i=0; i<wndx; i++){
+ temp[i]=0;
+ }
+ if(q==1){
+ linep= stride*128;
+ if(o) linep+=vgax<<1;
+ for(line=128; line>=0; line--){
for(i=0; i<wndx; i++){
- temp[i]=0;
+
+ j = char(actVid2MemBufp->b[linep + (i<<1)]);
+ j=(j + j) - temp[i];
+ if(j<temp[i] && (line&2)) j++;
+ if (j> 127) j= 127;
+ else if(j<-128) j=-128;
+ temp[i] = j;
}
+ linep-=stride;
+ }
+ }
- linep= startp;
- if(o) linep+=vgax<<1;
- for(line=0; line<segSize; line++){
- for(i=0; i<wndx; i++){
+ linep= 0;
+ if(o) linep+=vgax<<1;
+ for(line=0; line<end; line++){
+ for(i=0; i<wndx; i++){
- j = char(actVid2MemBufp->b[linep + (i<<1)]);
- j=(j + j) - temp[i];
- if(j<temp[i]) j++;
- if (j> 127) j= 127;
- else if(j<-128) j=-128;
- temp[i] = j;
- actVid2MemBufp->b[linep + (i<<1)] = (char)(j);
- }
- linep+=stride;
- }
- startp+= segSize*stride;
+ j = char(actVid2MemBufp->b[linep + (i<<1)]);
+ j=(j + j) - temp[i];
+ if(j<temp[i] && (line&2)) j++;
+ if (j> 127) j= 127;
+ else if(j<-128) j=-128;
+ temp[i] = j;
+ actVid2MemBufp->b[linep + (i<<1)] = (char)(j);
}
+ linep+=stride;
+ }
/*
asm(//"int $3 \n\t"
Modified: trunk/2010/2_file.cc
==============================================================================
--- trunk/2010/2_file.cc (original)
+++ trunk/2010/2_file.cc Wed Jul 4 09:25:09 2007
@@ -10,13 +10,12 @@
extern int vgax, vgay, wndx, wndy;
extern int fysize;
extern byte font[4096];
- extern VID2MEMBUF actVid2MemBufp;
+ extern VID2MEMBUF *actVid2MemBufp;
extern int g_mode;
extern int yuvmode;
extern char *yuv2rgb_lut;
void grab(void){
-/*
int i, j;
FILE *fg;
char grab_name[16];
@@ -47,24 +46,42 @@ void grab(void){
fwrite(&bmpi, sizeof(bmpi), 1, fg);
for(i=wndy-1; i>=0; i--){
- for(j=0; j<wndx; j++){
- if(yuvmode==0) fwrite((void*)(&actVid2MemBufp.b[(j + i*vgax)<<2]), 1, 3, fg);
- else {
- if(j>=wndx>>1) break;
+ if(yuvmode==0){
+ for(j=0; j<wndx; j++){
+/* const int b= (actVid2MemBufp->b[ (j + i*vgax)<<1 ] & 0x1F) << 3;
+ const int g= ((actVid2MemBufp->b[ (j + i*vgax)<<1 ] & 0xE0) >> 3)
+ +((actVid2MemBufp->b[((j + i*vgax)<<1)+1] & 0x07) << 5);
+ const int r= actVid2MemBufp->b[((j + i*vgax)<<1)+1] & 0xF8;
+*/
+ const int b= (actVid2MemBufp->b[ (j + i*vgax)<<1 ] & 0x1F) << 3;
+ const int g= ((actVid2MemBufp->b[ (j + i*vgax)<<1 ] & 0xE0) >> 2)
+ +((actVid2MemBufp->b[((j + i*vgax)<<1)+1] & 0x03) << 6);
+ const int r= (actVid2MemBufp->b[((j + i*vgax)<<1)+1] & 0x7C) << 1;
- mem2vid(fwbuf, (s_yuv*)(&actVid2MemBufp.b[(j + (i*vgax>>1))<<2]), 2, 32);
+ const int bgr= b + (g<<8) + (r<<16);
- fwbuf[3]=fwbuf[4];
- fwbuf[4]=fwbuf[5];
- fwbuf[5]=fwbuf[6];
+ fwrite(&bgr, 1, 3, fg);
+ }
+ }
+ else{
+ for(j=0; j<wndx; j+=2){
+ const int u = char(actVid2MemBufp->b[ ((j + i*vgax)<<1) ]);
+ const int y1= actVid2MemBufp->b[ ((j + i*vgax)<<1) + 1 ];
+ const int v = char(actVid2MemBufp->b[ ((j + i*vgax)<<1) + 2 ]);
+ const int y2= actVid2MemBufp->b[ ((j + i*vgax)<<1) + 3 ];
+ color c[2];
+ c[0].init(y1, u, v, 1);
+ c[1].init(y2, u, v, 1);
+ byte bgr2[6]={ c[0].col.b, c[0].col.g, c[0].col.r,
+ c[1].col.b, c[1].col.g, c[1].col.r };
- fwrite(fwbuf, 1, 6, fg);
+ fwrite(bgr2, 1, 6, fg);
}
}
}
fclose(fg);
- */
+
}
long fsize(FILE *f){
Modified: trunk/2010/2_grafix.cc
==============================================================================
--- trunk/2010/2_grafix.cc (original)
+++ trunk/2010/2_grafix.cc Wed Jul 4 09:25:09 2007
@@ -22,6 +22,7 @@
extern MENULEVEL menuLevel;
extern int infoPosY;
extern VID2MEMBUF *vid2MemBuf;
+ extern int some;
bool helpState=true;
bool iState=false;
@@ -78,13 +79,20 @@ void showStuff(void){
gprint(10, infoPosY+=10, c.col, textbuf);
sprintf(textbuf,"%d Buffers", vid2MemBuf[0].num);
- gprint(150, infoPosY , c.col, textbuf);
+ gprint(120, infoPosY , c.col, textbuf);
+
+ if(yuvmode==0) sprintf(textbuf,"RGB16");
+ else sprintf(textbuf,"YUV422");
+ gprint(220, infoPosY , c.col, textbuf);
sprintf(textbuf,"%d Corrupted Fields", corr_errors);
gprint(10, infoPosY+=10, c.col, textbuf);
sprintf(textbuf,"%d Address error's", addr_errors);
gprint(10, infoPosY+=10, c.col, textbuf);
+
+ sprintf(textbuf,"%d Some", some);
+ gprint(10, infoPosY+=10, c.col, textbuf);
infoPosY+=5;
}
Modified: trunk/2010/2_nag.cc
==============================================================================
--- trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cc Wed Jul 4 09:25:09 2007
@@ -1,5 +1,7 @@
//2010 0.1 Copyright (C) Michael Niedermayer 1998
+//FIX search multiply (use deltas)
+
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -21,18 +23,19 @@ extern vgax, vgay, wndx, wndy, outy, y_f
extern VID2MEMBUF *actVid2MemBufp;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
-extern int one_field;
extern u_long asm_temp, asm_temp4;
extern bool iState;
extern int yuvmode;
extern bool mmx;
-int *decoLine=NULL;
-int decoLines;
-int keyTable[256];
-int *best1=NULL;
-BEST2 *best2=NULL;
-u_short *keysList=NULL;
+static int alg2Lines;
+static short *linesPerKeyTab=NULL;
+static int *decoLine=NULL;
+static int decoLines;
+static int keyTable[256];
+static int *best1=NULL;
+static BEST2 *best2=NULL;
+static u_short *keysList=NULL;
static int outy1;
static int nagStart2;
static int nagEnd2;
@@ -154,11 +157,15 @@ static inline void doDwnSmp(byte * const
static inline int nagLineLogi2Phys(const int logi){
int phys;
+#ifdef CHECK
if(logi>=287) error(-100);
+#endif
if(logi<32) phys= nagStart1 + ( logi <<1);
else phys= nagStart2 + ((logi-32)<<1);
+#ifdef CHECK
if(phys>=576) error(-101);
+#endif
return phys;
}
@@ -244,8 +251,8 @@ static inline void mod4Fix(byte *p, cons
"c" (-wndx<<2)
: "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
-
- /*
+ /*
+
const bool xchg[4]={false, true, false, true};
const int neg [4]={ 0, 0, -1, -1};
@@ -268,33 +275,44 @@ static inline void mod4Fix(byte *p, cons
p[x+2]= (v^neg[type]) - neg[type];
}
- } */
-}
+ } */
+}
-void corrV(byte * p1, byte * p2, const int type, int *vPhase){
+static inline void corrV(byte * p1, byte * p2, const int type, int *vPhase){
const bool xchg[4]={false, true, false, true};
const int neg [4]={ 0, 0, -1, -1};
- for(int x=0; x<(wndx<<1); x+=4){
- int u1= char(p1[x ]); // perhaps u><v
- int v1= char(p1[x+2]);
+ if(xchg[type]){
- int u2= char(p2[x ]); // perhaps u><v
- int v2= char(p2[x+2]);
+ for(int x=0; x<(wndx<<1); x+=32){ // 32 FASTER until asm
+ int v1= char(p1[x ]);
+ int u1= char(p1[x+2]);
- if(xchg[type]){
- const int t=u1;
- u1=v1;
- v1=t;
+ const int u2= char(p2[x ]);
+ const int v2= char(p2[x+2]);
+
+ u1=(u1^neg[type]) - neg[type];
+ v1=(v1^neg[type]) - neg[type];
+
+ *vPhase+= mabs(u1-u2) + mabs(v1-v2);
+ *vPhase-= mabs(u1+u2) + mabs(v1+v2);
}
+ }
+ else{
+ for(int x=0; x<(wndx<<1); x+=32){ // 32 FASTER until asm
+ int u1= char(p1[x ]);
+ int v1= char(p1[x+2]);
- u1=(u1^neg[type]) - neg[type];
- v1=(v1^neg[type]) - neg[type];
+ const int u2= char(p2[x ]);
+ const int v2= char(p2[x+2]);
- *vPhase+= mabs(u1-u2) + mabs(v1-v2);
- *vPhase-= mabs(u1+u2) + mabs(v1+v2);
+ u1=(u1^neg[type]) - neg[type];
+ v1=(v1^neg[type]) - neg[type];
+
+ *vPhase+= mabs(u1-u2) + mabs(v1-v2);
+ *vPhase-= mabs(u1+u2) + mabs(v1+v2);
+ }
}
-
}
void nag_decrypt(void){
@@ -338,17 +356,21 @@ void nag_decrypt(void){
decoLine[12]=213;
decoLine[13]=222;
+ alg2Lines=80;
+
FILE *f= fopen("key.txt", "r");
if(f==NULL) error(KeyFile);
for(int i=0; i<256; i++)
if( fscanf(f, "%d", &keyTable[i])!=1 ) error(KeyFile);
fclose(f);
-
+
f=fopen("2010.dat", "rb");
if(f!=NULL){
- int decoLines2;
+ int decoLines2, alg2Lines2;
fread(&decoLines2, sizeof(int), 1, f);
+ fread(&alg2Lines2, sizeof(int), 1, f);
if(decoLines2!=decoLines) goto badFile;
+ if(alg2Lines2!=alg2Lines) goto badFile;
int decoLine2[NAG_LINES];
fread(decoLine2, sizeof(int), decoLines2, f);
@@ -356,16 +378,20 @@ void nag_decrypt(void){
int best2Size;
int keysListSize;
- fread(&best2Size, sizeof(int), 1, f);
- fread(&keysListSize, sizeof(int), 1, f);
+ int linesPerKeyTabSize;
+ fread(&best2Size, sizeof(int), 1, f);
+ fread(&keysListSize, sizeof(int), 1, f);
+ fread(&linesPerKeyTabSize, sizeof(int), 1, f);
- best1= new int[decoLines * NAG_LINES];
- best2= new BEST2[best2Size];
- keysList= new u_short[keysListSize];
+ best1= new int[decoLines * NAG_LINES];
+ best2= new BEST2[best2Size];
+ keysList= new u_short[keysListSize];
+ linesPerKeyTab= new short[linesPerKeyTabSize];
- fread(best1, sizeof(int), decoLines * NAG_LINES, f);
- fread(best2, sizeof(BEST2), best2Size , f);
- fread(keysList, sizeof(u_short), keysListSize , f);
+ fread(best1, sizeof(int), decoLines * NAG_LINES, f);
+ fread(best2, sizeof(BEST2), best2Size , f);
+ fread(keysList, sizeof(u_short), keysListSize , f);
+ fread(linesPerKeyTab, sizeof(short), linesPerKeyTabSize , f);
badFile:;
fclose(f);
@@ -463,18 +489,74 @@ void nag_decrypt(void){
delete [] keysTempStart;
delete [] state;
+ const int startW= (NAG_LINES-alg2Lines)>>1;
+ const int endW= (NAG_LINES+alg2Lines)>>1;
+ int linesPerKeyTabSize=0;
+ int minLines=1000;
+ for(int key=0; key<KEYS; key++){
+ int perm[NAG_LINES];
+ getPerm(key, perm);
+ int lines=0;
+ for(int clearLine=1; clearLine<NAG_LINES; clearLine++){
+ int l1=perm[clearLine ];
+ int l2=perm[clearLine-1];
+ if( l1 >= startW && l1 < endW && l2 >= startW && l2 < endW){
+ linesPerKeyTabSize++;
+ lines++;
+ }
+ }
+ if(lines<minLines) minLines=lines; // linesPerKeyTabSize bigger then nes.
+ }
+ linesPerKeyTab= new short[linesPerKeyTabSize+1];
+
+ printf("minLines %d\n", minLines);
+
+ int linesPerKeyTabP=0;
+ for(int key=0; key<KEYS; key++){
+ int perm[NAG_LINES];
+ getPerm(key, perm);
+ int lines=0;
+ for(int clearLine=1; clearLine<NAG_LINES; clearLine++){
+ int l1=perm[clearLine ];
+ int l2=perm[clearLine-1];
+ if( l1 >= startW && l1 < endW && l2 >= startW && l2 < endW){
+ if(l1>l2){
+ int lt=l1;
+ l1=l2;
+ l2=lt;
+ }
+ l1-=startW;
+ l2-=startW;
+ l1*=alg2Lines;
+ linesPerKeyTab[linesPerKeyTabP]=l1+l2;
+ linesPerKeyTabP++;
+ lines++;
+ if(lines>=minLines) break;
+ }
+ }
+ linesPerKeyTab[linesPerKeyTabP]|=1<<15;
+
+ }
+ linesPerKeyTab[linesPerKeyTabP]=-1;
+
+ linesPerKeyTabSize=linesPerKeyTabP+1;
+
f=fopen("2010.dat", "wb");
if(f==NULL) error(DatWrite);
fwrite(&decoLines, sizeof(int), 1, f);
+ fwrite(&alg2Lines, sizeof(int), 1, f);
+
fwrite(decoLine, sizeof(int), decoLines, f);
- fwrite(&best2Size, sizeof(int), 1, f);
- fwrite(&keysListSize, sizeof(int), 1, f);
+ fwrite(&best2Size, sizeof(int), 1, f);
+ fwrite(&keysListSize, sizeof(int), 1, f);
+ fwrite(&linesPerKeyTabSize, sizeof(int), 1, f);
- fwrite(best1, sizeof(int), decoLines * NAG_LINES, f);
- fwrite(best2, sizeof(BEST2), best2Size , f);
- fwrite(keysList, sizeof(u_short), keysListSize , f);
+ fwrite(best1, sizeof(int), decoLines * NAG_LINES, f);
+ fwrite(best2, sizeof(BEST2), best2Size , f);
+ fwrite(keysList, sizeof(u_short), keysListSize , f);
+ fwrite(linesPerKeyTab, sizeof(short), linesPerKeyTabSize , f);
fclose(f);
@@ -535,7 +617,9 @@ void nag_decrypt(void){
bestCoeffs[dL].line[1]= bestCoeffs[dL].line[0];
bestCoeffs[dL].line[0]= t;
}
+#ifdef CHECK
limit(bestCoeffs[dL].line[0], 0, 285);
+#endif
int l= best1[ bestCoeffs[dL].line[0] + dL*NAG_LINES ];
int r= best1[ bestCoeffs[dL].line[0] + 1 + dL*NAG_LINES ];
@@ -598,16 +682,77 @@ void nag_decrypt(void){
delete [] keysListPos;
- int perm[NAG_LINES];
- getPerm(bestKey, perm);
- printf("%X\n", bestKey);
-
if(iState){
T2=uclock();
sprintf(textbuf[3],"%f FindKey", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
}
+ if(bestNum<3){
+ short *coeff= new short[alg2Lines*alg2Lines];
+
+ byte *lowRes= new byte[alg2Lines*wndx>>dwnSmpSize];
+
+ const int startW= (NAG_LINES-alg2Lines)>>1;
+ const int endW= (NAG_LINES+alg2Lines)>>1;
+
+ for(int line=0; line<alg2Lines; line++){
+ const int physLine= nagLineLogi2Phys(line+startW);
+ byte * const linep= actVid2MemBufp->b + physLine*(vgax<<1);
+ byte * const lowResp= lowRes + line*(wndx>>dwnSmpSize);
+ doDwnSmp(lowResp ,linep);
+ }
+
+ int coeffp=0;
+ int line0p=0;
+ for(int line0=0; line0<alg2Lines; line0++){
+ int line1p=0;
+ for(int line1=line0; line1<alg2Lines; line1++){
+ BESTCOEFFS out;
+ out.coeff[0]=
+ out.coeff[1]=100000;
+ nagraCorr(int(line0p), int(line1p), wndx>>dwnSmpSize, int(&out), 0);
+ coeff[coeffp + line1]=short(out.coeff[0]);
+ line1p+= wndx>>dwnSmpSize;
+ }
+ coeffp+= alg2Lines;
+ line0p+= wndx>>dwnSmpSize;
+ }
+ if(mmx) asm("emms\n\t");
+
+ int linesPerKeyTabP=0;
+ bestNum=100000;
+ int key=0;
+ int num=0;
+ for(;;){
+ if(linesPerKeyTab[linesPerKeyTabP]==-1) break;
+ num+= coeff[ linesPerKeyTab[linesPerKeyTabP] & !(1<<15) ];
+
+ if(linesPerKeyTab[linesPerKeyTabP] & (1<<15) ){
+ if(num<bestNum){
+ bestNum=num;
+ bestKey=key;
+ num=0;
+ }
+ key++;
+ }
+ linesPerKeyTabP++;
+ }
+
+ delete [] lowRes;
+ delete [] coeff;
+ }
+
+ if(iState){
+ T2=uclock();
+ sprintf(textbuf[4],"%f Algo2", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ T1=T2;
+ }
+
+ int perm[NAG_LINES];
+ getPerm(bestKey, perm);
+ printf("%X\n", bestKey);
+
delete [] bestCoeffs; // kill this
@@ -616,7 +761,7 @@ void nag_decrypt(void){
int lastVType[2];
int vPhase=0;
for(int i=0; i<NAG_LINES; i++){
- if(perm[i]>=32 && i-perm[i]<=0){
+ if(perm[i]>=32 && i-perm[i]<=-16){ // fewer to test (FASTER)
const cleMod4= (i ) & 3;
const encMod4= (perm[i]) & 3;
const type= cleMod4 ^ encMod4;
@@ -767,7 +912,7 @@ void nag_decrypt(void){
if(iState){
T2=uclock();
- sprintf(textbuf[4],"%f ReOrder", (float)(T2-T1)/UCLOCKS_PER_SEC);
+ sprintf(textbuf[6],"%f ReOrder", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
}
@@ -785,8 +930,8 @@ void nag_decrypt(void){
gprint(110, 110, c.col, textbuf[3]);
gprint(120, 120, c.col, textbuf[4]);
gprint(130, 130, c.col, textbuf[5]);
-/* gprint(140, 140, c.col, textbuf[6]);
- gprint(150, 150, c.col, textbuf[7]);
+ gprint(140, 140, c.col, textbuf[6]);
+/* gprint(150, 150, c.col, textbuf[7]);
gprint(160, 160, c.col, textbuf[8]);
gprint(170, 170, c.col, textbuf[9]);*/
T1=T2;
Modified: trunk/2010/2_nag_a.asm
==============================================================================
--- trunk/2010/2_nag_a.asm (original)
+++ trunk/2010/2_nag_a.asm Wed Jul 4 09:25:09 2007
@@ -58,7 +58,7 @@ _nagraCorr__Fiiiii:
test eax, eax
jz NEAR NoMMX
- movq mm3, [mmx_zero]
+ pxor mm3, mm3
movq mm0, [esp + esi]
movq mm5, mm3
@@ -200,5 +200,4 @@ ret
xyz times 8 dd 0
align8
-mmx_zero times 2 dd 0
mmx_clip times 8 db 0
Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cc Wed Jul 4 09:25:09 2007
@@ -3,119 +3,266 @@
#include <stdio.h>
#include <time.h>
#include <string.h>
+#include <math.h>
#include "2_all.h"
#include "2_crypt.h"
#include "2_vc.h"
#include "2_71x6.h"
#include "2_gfunc.h"
#include "2_vc_a.h"
+#include "2_hw_mem.h"
+#include "2010.h"
+
+#define FREQ_SMP 2.1e7
+#define FREQ_CHROM 4433618.75
+#define FREQ_HS 15625.0
+#define FREQ_PIX (FREQ_HS * 1888.0 * 0.5)
+#define POINT_LAND 765.0
+#define NO_POINT_LAND1 145.0 // GUESSED!
+#define NO_POINT_LAND2 145.0 // GUESSED!
+#define NO_POINT_LAND3 10.0 // GUESSED!
+ // ? POINT_LAND + NO_POINT_LAND(1|2) = 910 (FIFO SIZE)
+ // ? NO_POINT_LAND + POINT_LAND = 1065 (PHASE ~+-60deg)
-#define addap_start 16
-#define addap_end 2
-#define vc_dead 7.5
-#define check 1
+ // 142 142 16
+ // 143 143 14
+ // 144 144 12
+ // 145 145 10
-extern vgax, vgay, wndx, wndy;
+#define NO_POINT_LAND (NO_POINT_LAND1 + NO_POINT_LAND2 + NO_POINT_LAND3)
+#define PHASE_POINT (fmod(FREQ_CHROM / (FREQ_SMP/3.0), 1.0) * PI * 2.0)
+#define PHASE_SMP (fmod(FREQ_CHROM / (FREQ_SMP ), 1.0) * PI * 2.0)
+#define PHASE_SEG (fmod(FREQ_CHROM / FREQ_SMP \
+ * (POINT_LAND + NO_POINT_LAND), 1.0) * PI * 2.0)
+
+
+#define FIX_POINT 10
+#define STEP_START 16
+#define STEP_END 2
+#define VC_DEAD 7.5
+#define DWN_SMP 1
+#define MAX_DRIFT 2
+#define PHASE_CMP_STEP 3
+#define BAD_THRESHOLD1 0.8
+#define BAD_THRESHOLD2 200
+#define PHASE_DIFF_TH 35
+
+#define NUM_PHASE_SMP (vcDiff>>PHASE_CMP_STEP)
+
+extern int vgax, vgay, wndx, wndy, x_field;
extern VID2MEMBUF *actVid2MemBufp;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
-extern int one_field;
-extern int show_points;
+extern bool showPoints;
extern bool iState;
extern int yuvmode;
-extern int edge_lut[256];
-
+extern int some;
+extern bool mmx;
-static int *new_val=new int[max_x], *last_val=new int[max_x];
+// FIX ABS ??
-static byte copy_buff[max_x<<1];
+static inline float atan3(const float f1, const float f2){
+ float out;
+ // ? don't know what atan2 does ( crashes )
+ asm(//"int $3\n\t"
+ "fpatan \n\t"
+ : "=t"(out)
+ : "0"(f2), "u"(f1)
+ : "st(1)"
+ );
+ return out;
+}
void vc_decrypt(void){
- int i, j, k=0, l;
- int line, cutp, diff, linep, llinep, add_step, start_step;
- int edgep;
- int bestp=0, bestdiff;
- int diffall;
- int temp;
- int cutpoint[max_y];
- int addap_buff[max_x];
- int drift;
- int best_edge=0;
- int best_val, best_edge_val;
- int best_dir=0;
+ int cutPointX[max_y];
+ int addapBuff[max_x];
char textbuf[9][128];
long T1=0, T2;
long alg1=0, alg2=0, alg3=0;
color c;
- show_points=1;
- const int vc_endx=wndx;
- const int vc_startx=int(double(22-scales_x+3)/double(768-scales_x+scalee_x)*wndx);
+ int tempScore[2]={0 ,0};
- const int vc_diff=vc_endx - vc_startx;
+ for(int i=0; i<360; i++){
+ double d=i;
- int *dir=new int[vc_diff*(wndy + 1)];
+// asm("int $3\n\t");
+ double a=atan2(cos(d/180*PI), sin(d/180*PI));
+ double a2=atan3(cos(d/180*PI), sin(d/180*PI));
+ if(a<0.0) a+=PI*2;
+ if(a2<0.0) a2+=PI*2;
+ printf("xyz %f %f\n",a,a2);
+ }
- const int mindist=int(double(vc_diff) / vc_dead);
+ const int lowResSize= mmx ? DWN_SMP : (DWN_SMP-1);
- cutpoint[0]=0;
+ printf("xx%f %f %f\n", PHASE_POINT/PI*180, PHASE_SEG/PI*180, PHASE_SMP/PI*180);
- char *datbuf[2];
+ double temp[1000][2];
- datbuf[0]= new char[vc_diff];
- datbuf[1]= new char[vc_diff];
+ int vScore=0;
+
+// showPoints=true;
+
+ const double freqPix2= double(wndx) / double(x_field) * FREQ_PIX;
+ printf("xy%d %d\n", wndx, x_field);
+
+ // 18
+ const int vcStartX=int(double(16 -scales_x+3)/x_field*wndx + .5);
+
+ static int cutP2X[256];
+ static int x2CutP[max_x];
+// static byte atanLut[ 1<< (ATAN_LUT_SIZE<<1) ]
+
+ static int wndxBak= -1;
+ if(wndx != wndxBak){
+ for(int x=0; x<max_x; x++){
+
+ const int cutP=int( double(x) / ( 3.0 * freqPix2) * FREQ_SMP
+ - (NO_POINT_LAND1 + NO_POINT_LAND3/2)/3.0 + .5);
+ x2CutP[x]= cutP;
+ }
+ for(int cutP=0; cutP<256; cutP++){
+ const int x=int( double(cutP*3 + NO_POINT_LAND1 + NO_POINT_LAND3/2)
+ * freqPix2 / FREQ_SMP + .5);
+ cutP2X[cutP]= x;
+ }
+ wndxBak=wndx;
+ }
+ const int vcEndX= vcStartX + int( double(POINT_LAND + NO_POINT_LAND)
+ * freqPix2 / FREQ_SMP + .5);
+ printf("vcEndX %d\n",vcEndX);
+ if(vcEndX>wndx) error(error_code(-123));
+ const int vcDiff=vcEndX - vcStartX;
+
+ const int minDist= cutP2X[0]-1;
+
+ cutPointX[0]=0;
+
+ char *lowRes[2];
+
+ lowRes[0]= (char*)newAlign(vcDiff, 8);
+ lowRes[1]= (char*)newAlign(vcDiff, 8);
+
+ int *convVec= new int[vcDiff>>(PHASE_CMP_STEP-1)];
if(iState){
T1=uclock();
}
- for(i = 0; i < vc_diff; i++) last_val[i]=1;
+ static int edgeLut[512];
+ static bool first= true;
+ static int score[40];
- llinep=-(vgax<<2);
- linep=-(vgax<<1);
- edgep=0;
- for(line=0; line<wndy; line++){
+ static byte phasePerCutP[256];
+
+ if(first){
+ some=10;
+
+ edgeLut[0]=0;
+ for(int i=1; i<512; i++){
+ const int j= min(i, 70);
+ edgeLut[i]=int( log(j*10)*100.0 );
+ }
+ first=false;
+
+ for(int cutP=0; cutP<256; cutP++){
+ const double phase= PHASE_SMP*(NO_POINT_LAND1 + NO_POINT_LAND3 + 1) + PHASE_POINT*cutP;
+ phasePerCutP[cutP]= (byte)( phase * 128 / PI );
+ printf("ppcp %d %d\n", cutP, phasePerCutP[cutP]*360/256);
+ }
+
+ for(int i=0; i<40; i++) score[i]=0;
+
+ }
+
+ const float sinSegPhase= sin(PHASE_SEG);
+ const float cosSegPhase= cos(PHASE_SEG);
+
+ const float sinSegPhase2= sin(PHASE_SEG*2);
+ const float cosSegPhase2= cos(PHASE_SEG*2);
+
+ bool *black= new bool[wndy];
+ int *phaseDiff= new int[(vcDiff*wndy)>>PHASE_CMP_STEP];
+ int *chromAmp= new int[wndy];
+
+ int llinep=-(vgax<<2);
+ int linep=-(vgax<<1);
+ for(int line=0; line<wndy; line++){
llinep+=vgax<<1;
linep+=vgax<<1;
- bestdiff=0x1FFFFFFF;
- diffall=0;
- start_step=0;
- char *dtemp = datbuf[0];
- datbuf[0] = datbuf[1];
- datbuf[1] = dtemp;
+ char *dTemp = lowRes[0];
+ lowRes[0] = lowRes[1];
+ lowRes[1] = dTemp;
- asm(//"int $3 \n\t"
- "pushl %%ebp \n\t"
+ if(mmx){
+ asm(//"int $3 \n\t"
+ "pushl %%ebp \n\t"
- "1: \n\t"
- "movw (%%edi), %%ax \n\t" // U load 32 byte in L1-cache
- "xorl %%ebx, %%ebx \n\t" // V 1
- "movl %1, %%ebp \n\t" // U
- "xorl %%eax, %%eax \n\t" // V 1
- "2: \n\t"
- "addl %%eax, %%ebx \n\t" // U
- "xorl %%eax, %%eax \n\t" // V 1
- "movb (%%esi), %%al \n\t" // U
- "addl $2, %%esi \n\t" // V 1
- "decl %%ebp \n\t" // U
- " jnz 2b \n\t" // V 1
- "addl $2, %%edi \n\t" // U
- "addl %%eax, %%ebx \n\t" // V 1
- "shrl %0, %%ebx \n\t" // U
- "decl %%edx \n\t" // V 1
- "movw %%bx, -2(%%edi) \n\t" // U
- " jnz 1b \n\t" // V 1
+ "1: \n\t"
+ "movb (%%edi), %%al \n\t" // U load 32 byte in L1-cache
+ "xorl %%ebx, %%ebx \n\t" // V 1
+ "movl %1, %%ebp \n\t" // U
+ "xorl %%eax, %%eax \n\t" // V 1
+ "2: \n\t"
+ "addl %%eax, %%ebx \n\t" // U
+ "xorl %%eax, %%eax \n\t" // V 1
+ "movb (%%esi), %%al \n\t" // U
+ "addl $2, %%esi \n\t" // V 1
+ "decl %%ebp \n\t" // U
+ " jnz 2b \n\t" // V 1
+ "incl %%edi \n\t" // U
+ "addl %%eax, %%ebx \n\t" // V 1
+ "shrl %0, %%ebx \n\t" // U
+ "decl %%edx \n\t" // V 1
+ "movb %%bl, -1(%%edi) \n\t" // U
+ " jnz 1b \n\t" // V 1
- "popl %%ebp \n\t"
- :
- : "I" (check), "i" (1<<check),
- "S" (actVid2MemBufp->b + linep + 1 + (vc_startx<<1)) ,
- "d" (vc_diff>>check) ,
- "D" (datbuf[1])
- : "%eax", "%ebx", "%edx", "%esi", "%edi");
+ "popl %%ebp \n\t"
+ :
+ : "I" (DWN_SMP), "i" (1<<DWN_SMP),
+ "S" (actVid2MemBufp->b + linep + 1 + (vcStartX<<1)) ,
+ "d" (vcDiff>>DWN_SMP) ,
+ "D" (lowRes[1])
+ : "%eax", "%ebx", "%edx", "%esi", "%edi");
+
+ }
+ else{
+ asm(//"int $3 \n\t"
+ "pushl %%ebp \n\t"
+
+ "1: \n\t"
+ "movw (%%edi), %%ax \n\t" // U load 32 byte in L1-cache
+ "xorl %%ebx, %%ebx \n\t" // V 1
+ "movl %1, %%ebp \n\t" // U
+ "xorl %%eax, %%eax \n\t" // V 1
+ "2: \n\t"
+ "addl %%eax, %%ebx \n\t" // U
+ "xorl %%eax, %%eax \n\t" // V 1
+ "movb (%%esi), %%al \n\t" // U
+ "addl $2, %%esi \n\t" // V 1
+ "decl %%ebp \n\t" // U
+ " jnz 2b \n\t" // V 1
+ "addl $2, %%edi \n\t" // U
+ "addl %%eax, %%ebx \n\t" // V 1
+ "shrl %0, %%ebx \n\t" // U
+ "decl %%edx \n\t" // V 1
+ "movw %%bx, -2(%%edi) \n\t" // U
+ " jnz 1b \n\t" // V 1
+
+ "popl %%ebp \n\t"
+ :
+ : "I" (DWN_SMP), "i" (1<<DWN_SMP),
+ "S" (actVid2MemBufp->b + linep + 1 + (vcStartX<<1)) ,
+ "d" (vcDiff>>DWN_SMP) ,
+ "D" (lowRes[1])
+ : "%eax", "%ebx", "%edx", "%esi", "%edi");
+ }
+
+ black[line]=false; //fix this
if(iState){
T2=uclock();
@@ -125,138 +272,274 @@ void vc_decrypt(void){
if(line==0) continue;
- for(add_step=addap_start; add_step>addap_end; add_step>>=1){
- start_step>>=1;
- if(add_step==(addap_start>>1) && start_step==0){
- add_step=addap_start;
- start_step=addap_start>>1;
- }
- for(cutp=start_step; cutp<vc_diff; cutp+=add_step){
- if(cutp==start_step || start_step==0 || cutp+add_step>=vc_diff
- || bestdiff+(bestdiff>>1) > addap_buff[cutp - (add_step>>1)]
- || bestdiff+(bestdiff>>1) > addap_buff[cutp + (add_step>>1)]){
+ int bestDiff=0x1FFFFFFF;
+ int avgDiff=0; // for detecting bad lines
+ int avgDiffNum=0; // for detecting bad lines
+ int bestCutPX=0;
+ bool firstPass=true;
+ for(int step=STEP_START; step>STEP_END; step>>=1){
- diff = vc_corr(
- int(datbuf[1] + ((( + cutp) << (1-check))&~1)),
- int(datbuf[0] + ((( - cutp + vc_diff + cutp) << (1-check))&~1)),
- -(( cutp << (1-check) ) & ~1),
- int(datbuf[1] + ((( cutp + vc_diff - cutp) << (1-check))&~1)),
- int(datbuf[0] + ((( + vc_diff - cutp) << (1-check))&~1)),
- -(( (vc_diff-cutp) << (1-check) ) & ~1) ) ;
+ const int cutPStart= firstPass ? 0 : step>>1;
- if(bestdiff>diff){
- bestdiff=diff;
- bestp=cutp;
+ for(int cutP=cutPStart; cutP<vcDiff; cutP+=step){
+ if(firstPass || cutP+step>=vcDiff || cutP==step>>1
+ || bestDiff+(bestDiff>>1) > addapBuff[ cutP - (step>>1) ]
+ || bestDiff+(bestDiff>>1) > addapBuff[ cutP + (step>>1) ]){
+
+ int diff;
+ if(mmx){
+ diff = vc_corr_mmx(
+ int(lowRes[1] ),
+ int(lowRes[0] + (( vcDiff - cutP) >> DWN_SMP)),
+ cutP >> DWN_SMP ,
+ int(lowRes[1] + (( cutP ) >> DWN_SMP)),
+ int(lowRes[0] ),
+ (vcDiff-cutP) >> DWN_SMP );
+ asm("emms\n\t");
}
- addap_buff[cutp]=diff;
- if(start_step==0) diffall+=diff;
+ else{
+ diff = vc_corr(
+ int(lowRes[1] + ((( + cutP) >> (DWN_SMP-1))&~1)),
+ int(lowRes[0] + ((( vcDiff ) >> (DWN_SMP-1))&~1)),
+ -(( cutP >> (DWN_SMP-1) ) & ~1),
+ int(lowRes[1] + ((( vcDiff ) >> (DWN_SMP-1))&~1)),
+ int(lowRes[0] + ((( vcDiff - cutP) >> (DWN_SMP-1))&~1)),
+ -(( (vcDiff-cutP) >> (DWN_SMP-1) ) & ~1) );
+
+ }
+
+ if(bestDiff>diff){
+ bestDiff=diff;
+ bestCutPX=cutP;
+ }
+
+ avgDiff+=diff;
+ avgDiffNum++;
+
+ addapBuff[cutP]=diff;
}
- else addap_buff[cutp]=0x7FFFFFFF;
+ else addapBuff[cutP]=0x1FFFFFFF;
}
+ if(firstPass) step<<=1;
+ firstPass=false;
}
- bestp+= cutpoint[line-1];
- if(bestp>=vc_diff) bestp-=vc_diff;
- cutpoint[line]=bestp;
- if(bestdiff==0) bestdiff++;
- temp=diffall * addap_start * 32 / (vc_diff * bestdiff);
- if(temp<42) drift=wndx;
- else if(temp<56) drift=addap_end;
- else drift=(addap_end>>1) | 1;
+ if( int( avgDiff*BAD_THRESHOLD1/double(avgDiffNum) ) - BAD_THRESHOLD2
+ < bestDiff )
+ black[line]=true;
+
+ if(line>2){
+
+ int sumI=0;
+ for(int x=-4; x<0; x+=2){
+ const int nx= x + (vcDiff & ~1);
+ const int ul= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + x)<<1) + 0]);
+ const int vl= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + x)<<1) + 2]);
+ const int un= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 0]);
+ const int vn= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 2]);
+ sumI+= ul*vn - vl*un;
+ }
+// actVid2MemBufp->b[linep + (((vcStartX & ~1) - 4)<<1) + 1]=255;
+
+ if(line>10 && line<250){
+ if(line & 1){
+ vScore+= sumI;
+ }else{
+ vScore-= sumI;
+ }
+ }
+
+ }
+
+ bestCutPX+= cutPointX[line-1];
+ if(bestCutPX>=vcDiff) bestCutPX-=vcDiff;
+ cutPointX[line]=bestCutPX;
if(iState){
T2=uclock();
alg1+=T2-T1;
T1=T2;
}
+ }
- edgep +=vc_diff;
+ delete [] convVec;
+ deleteAlign(lowRes[0]);
+ deleteAlign(lowRes[1]);
- best_edge_val=0;
+ int *dir=new int[257*(wndy + 1)];
- for(i = 0; i < vc_diff; i++){
- l= i + cutpoint[line];
- if(l >= vc_diff) l-=vc_diff;
- if(l < mindist || l >= vc_diff - mindist){
- new_val[i]=0;
- dir[edgep + i]=best_edge; //FIX ME (not nes)
+ const int driftPenalty[MAX_DRIFT*2+1]={10000, 1000, 0, 1000, 10000};
+
+ int *newVal=new int[257], *lastVal=new int[257];
+ memset(lastVal, 0, 257<<2);
+
+ llinep=-(vgax<<2);
+ linep=-(vgax<<1);
+ for(int line=0; line<wndy; line++){
+ llinep+=vgax<<1;
+ linep+=vgax<<1;
+
+ memset(newVal, 0, 257<<2);
+ bool noLeft=true;
+
+ dir[line*257 + 256]=-1;
+
+ if(line==0) continue;
+
+ int relCutPX= cutPointX[line] - cutPointX[line-1];
+ if(relCutPX<0) relCutPX+=vcDiff;
+
+ chromAmp[line]=0;
+ for(int x=0; x<vcDiff; x+= 1<<PHASE_CMP_STEP){
+ int nx= x + (relCutPX & ~1);
+ if(nx>=vcDiff) nx-= (vcDiff & ~1);
+ const int ul= char(actVid2MemBufp->b[llinep + (((vcStartX & ~1) + x)<<1) + 0]);
+ const int vl= char(actVid2MemBufp->b[llinep + (((vcStartX & ~1) + x)<<1) + 2]);
+ const int un= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 0]);
+ const int vn= char(actVid2MemBufp->b[ linep + (((vcStartX & ~1) + nx)<<1) + 2]);
+ const int p= x>>(PHASE_CMP_STEP-1);
+ convVec[p ]= ul*un + vl*vn;
+ convVec[p+1]= ul*vn - vl*un;
+ chromAmp[line]+= un*un + vn*vn;
+ }
+
+// actVid2MemBufp->b[linep + ((vcStartX + 0)<<1) + 1]=255;
+// actVid2MemBufp->b[linep + ((vcStartX + relCutPX)<<1) + 1]=200;
+
+ int sumR0=0, sumI0=0;
+ int sumR1=0, sumI1=0;
+ for(int x=0; x<vcDiff; x+= 1<<PHASE_CMP_STEP){
+ const int p= x>>(PHASE_CMP_STEP-1);
+ if(x+relCutPX<vcDiff){
+ sumR0+= convVec[p ];
+ sumI0+= convVec[p+1];
}
- else if(drift==wndx){
- new_val[i]=1;
- dir[edgep + i]=best_edge;
+ else{
+ sumR1+= convVec[p ];
+ sumI1+= convVec[p+1];
+ }
+ }
+
+ const float s= ( (line & 1) ^ ( vScore>0 ) ) ? 1 : -1;
+
+ int sumR0C= int( sumR0*cosSegPhase + sumI0*sinSegPhase*s);
+ int sumI0C= int(-sumR0*sinSegPhase*s + sumI0*cosSegPhase);
+ int sumR1C= int( sumR1*cosSegPhase + sumI1*sinSegPhase*s);
+ int sumI1C= int(-sumR1*sinSegPhase*s + sumI1*cosSegPhase);
+
+
+ int ffR0=0 , ffI0=0;
+ int ssR0=sumR0, ssI0=sumI0;
+ int ffR1=0 , ffI1=0;
+ int ssR1=sumR1, ssI1=sumI1;
+ const int phaseP= line*vcDiff>>PHASE_CMP_STEP;
+ for(int x=0; x<vcDiff; x+= 1<<PHASE_CMP_STEP){
+ const int p= x>>(PHASE_CMP_STEP-1);
+ const int q= x>> PHASE_CMP_STEP;
+ if(x+relCutPX<vcDiff){
+ ssR0-=convVec[p ];
+ ssI0-=convVec[p+1];
+
+ const int r= ffR0 + sumR1C;
+ const int i= ffI0 + sumI1C;
+
+ phaseDiff[phaseP + q ]= int( atan3(i, r)/PI*128 ) & 0xFF;
+/*
+ phaseDiff[phaseP + q ]= ffR0 ;//+ sumR1C;
+ phaseDiff[phaseP + q+1]= ffI0 ;//+ sumI1C;
+ phaseDiff[phaseP + q+2]= ssR0;
+ phaseDiff[phaseP + q+3]= ssI0;
+ */
+ ffR0+=convVec[p ];
+ ffI0+=convVec[p+1];
}
else{
+ ssR1-=convVec[p ];
+ ssI1-=convVec[p+1];
- diff=0;
- int edge_x= l == 0 ? (l - 2) + vc_diff : (l - 2);
- do{
- if((edge_x++) >= vc_diff) edge_x-= vc_diff;
- diff+= actVid2MemBufp->b[linep + ((vc_startx + edge_x)<<1) + 1];
- }while( edge_x != l );
- do{
- if((edge_x++) >= vc_diff) edge_x-= vc_diff;
- diff-= actVid2MemBufp->b[linep + ((vc_startx + edge_x)<<1) + 1];
- }while( edge_x != l + 2);
+ const int r= ffR1 + sumR0C;
+ const int i= ffI1 + sumI0C;
- diff= edge_lut[ mabs(diff) ];
+ phaseDiff[phaseP + q ]= int( atan3(i, r)/PI*128 ) & 0xFF;
+/*
+ phaseDiff[phaseP + q ]= ffR1 ;//+ sumR0C;
+ phaseDiff[phaseP + q+1]= ffI1 ;//+ sumI0C;
+ phaseDiff[phaseP + q+2]= ssR1;
+ phaseDiff[phaseP + q+3]= ssI1;
+ */
+ ffR1+=convVec[p ];
+ ffI1+=convVec[p+1];
+ }
+ }
+
+ for(int lastCutP = 0; lastCutP < 256; lastCutP++){
+ if(black[line] || lastVal[lastCutP]==0) continue;
- new_val[i]= diff;
+ int newXTemp= cutPointX[line] - cutPointX[line-1] + cutP2X[lastCutP];
+ if(newXTemp < 0 ) newXTemp+= vcDiff;
+ if(newXTemp >= vcDiff) newXTemp-= vcDiff;
+ if(newXTemp >= vcDiff) newXTemp-= vcDiff;
- best_val=0;
+ const int newCutPStart= max(x2CutP[ newXTemp ] - MAX_DRIFT, 0);
+ const int newCutPEnd= min(x2CutP[ newXTemp ] + MAX_DRIFT, 256);
- for(j = i - (drift<<2); j < i + (drift<<2); j++){
- k=j;
- int drift_p;
- const int drift_t=mabs(j - i);
- if(drift_t <= 1 ) drift_p= 0;
- else if(drift_t <= drift ) drift_p= 2;
- else if(drift_t <= drift<<1) drift_p=10;
- else if(drift_t <= drift*3 ) drift_p=20;
- else drift_p=40;
+ int drift= newCutPStart - (x2CutP[ newXTemp ] - MAX_DRIFT);
- if(k < 0 ) k+= vc_diff;
- else if(k >= vc_diff) k-= vc_diff;
+ const int p= (line*vcDiff>>PHASE_CMP_STEP)
+ +(cutP2X[ lastCutP ]>>PHASE_CMP_STEP);
- if(last_val[k] - drift_p > best_val){
- best_val=last_val[k] - drift_p;
- best_dir=k;
- if(best_edge_val < best_val){
- best_edge_val=best_val;
- best_edge=best_dir;
- }
- }
+ int a= phaseDiff[p ];
+ if( (line & 1) ^ ( vScore>0 ) ) a= -a;
- }
+ const int phase1= a + phasePerCutP[ lastCutP ];
+
+ for(int newCutP= newCutPStart; newCutP <= newCutPEnd; newCutP++){
+ int val= lastVal[lastCutP] - driftPenalty[drift];
+ int phase= phase1 + phasePerCutP[ newCutP ];
+ phase&= 0xFF;
+ phase= mabs( phase - 128 );
+ if(chromAmp[line]>3000 && phase>=PHASE_DIFF_TH) val-=100000;
+ if(chromAmp[line]<=3000)
+ actVid2MemBufp->b[linep + ((vcStartX - 1)<<1) + 1]=255;
+
+ if(newVal[newCutP] < val){
+ newVal[newCutP]= val;
+ dir[line*257 + newCutP]= lastCutP;
- if(best_val!=0){
- new_val[i]+= best_val;
- dir[edgep + i]= best_dir;
- }else{
- new_val[i]=0;
- dir[edgep + i]= 0; //FIX ME (Not Nes)
- for(j=k+1; i<vc_diff ; j++){
- if(j >= vc_diff) j-=vc_diff;
- if(last_val[j]==0){
- i++;
- l= i + cutpoint[line];
- if(l >= vc_diff) l-=vc_diff;
- new_val[i]=0;
- dir[edgep + i]= 0; //FIX ME (Not Nes)
- }
- else break;
- }
- if(i >= vc_diff && best_edge_val==0){
- i=0;
- drift=wndx;
- }
+ noLeft=false;
}
+ drift++;
}
+
}
- int *temp_val=last_val;
- last_val=new_val;
- new_val=temp_val;
+ for(int newCutP = 0; newCutP < 256; newCutP++){
+ if(black[line]) continue;
+ if(!noLeft && newVal[newCutP]==0) continue;
+
+ const int newX= cutP2X[ newCutP ];
+
+ const int diff=edgeLut[ mabs(
+ +actVid2MemBufp->b[linep + ((vcStartX + newX - 2)<<1) + 1]
+ +actVid2MemBufp->b[linep + ((vcStartX + newX - 1)<<1) + 1]
+ -actVid2MemBufp->b[linep + ((vcStartX + newX )<<1) + 1]
+ -actVid2MemBufp->b[linep + ((vcStartX + newX + 1)<<1) + 1] ) ];
+
+ if(newVal[newCutP]==0) newVal[newCutP] = diff + 1000000000;
+ else newVal[newCutP] += diff;
+
+ if(newVal[256] < newVal[newCutP]){
+ newVal[256]= newVal[newCutP];
+ dir[line*257 + 256]= newCutP;
+ }
+
+ }
+
+
+ int *tempVal=lastVal;
+ lastVal=newVal;
+ newVal=tempVal;
if(iState){
T2=uclock();
@@ -266,6 +549,10 @@ void vc_decrypt(void){
}
+ delete [] newVal;
+ delete [] lastVal;
+
+
if(iState){
T2=uclock();
sprintf(textbuf[0],"%f Corr", (float)(alg1)/UCLOCKS_PER_SEC);
@@ -274,56 +561,187 @@ void vc_decrypt(void){
T1=T2;
}
- i=best_edge;
- for(line=wndy-1; line>0; line--){
- if(show_points==0){
- cutpoint[line]+=i;
- if(cutpoint[line] >= vc_diff) cutpoint[line]-= vc_diff;
- }
- else{
- j=cutpoint[line]+i;
- if(j >= vc_diff) j-= vc_diff;
- actVid2MemBufp->b[(line * vgax<<1) + ((vc_startx + j)<<1)+1]=255;
- actVid2MemBufp->b[(line * vgax<<1) + ((vc_startx + j)<<1)+3]=0;
+
+ if(showPoints){
+ int bestCutP=-1;
+ for(int line=wndy-1; line>0; line--){
+ if(dir[line*257 + 256]==-1){
+ bestCutP=-1;
+ continue;
+ }
+ if(bestCutP==-1) bestCutP= dir[line*257 + 256];
+ if(bestCutP<0 || bestCutP>=256){
+ printf("one%d\n", bestCutP);
+ bestCutP=-1;
+ continue;
+ }
+
+ const int bestX= cutP2X[ bestCutP ];
+ actVid2MemBufp->b[(line * vgax<<1) + ((vcStartX + bestX)<<1)+1]=255;
+ actVid2MemBufp->b[(line * vgax<<1) + ((vcStartX + bestX)<<1)+3]=0;
+ actVid2MemBufp->b[(line * vgax<<1) + ((vcStartX + bestX)<<1)+5]=255;
+
+ bestCutP= dir[line*257 + bestCutP];
}
- i=dir[vc_diff*line + i];
}
+
if(iState){
T2=uclock();
sprintf(textbuf[3],"%f Misc", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
}
- linep=-(vgax<<1);
-// vc_diff&= ~1;
- for(line=0; line<wndy; line++){
+ int cutpp[1000];
+ byte copy_buff[max_x<<1];
-// cutpoint[line]&= ~1;
+ int bestCutP=-1;
+ linep=(wndy-1) * (vgax<<1);
+ for(int line=wndy-2; line>0; line--){
+ linep-= vgax<<1;
- linep+=vgax<<1;
- if(show_points!=0){
- actVid2MemBufp->b[linep+(vc_startx<<1)+1]=255;
- actVid2MemBufp->b[linep+(vc_startx<<1)+3]=0;
+ cutpp[line]=0;
+
+ if(black[line]){
+ actVid2MemBufp->b[linep + ((vcStartX - 4)<<1) + 1]=255;
+ actVid2MemBufp->b[linep + ((vcStartX - 4)<<1) + 3]=255;
}
- memcpy(copy_buff, actVid2MemBufp->b + linep + (vc_startx<<1), vc_diff<<1);
- memcpy(actVid2MemBufp->b + linep + (vc_startx<<1), copy_buff + (cutpoint[line]<<1),
- (vc_diff-cutpoint[line])<<1);
- memcpy(actVid2MemBufp->b + linep + (vc_startx<<1) + ((vc_diff-cutpoint[line])<<1),
- copy_buff,
- cutpoint[line]<<1);
+
+ if(showPoints){
+ actVid2MemBufp->b[linep+(vcStartX<<1)+1]=255;
+ actVid2MemBufp->b[linep+(vcStartX<<1)+3]=0;
+ }
+ if(dir[line*257 + 256]==-1){
+ bestCutP=-1;
+ continue;
+ }
+ if(bestCutP==-1) bestCutP=dir[line*257 + 256];
+
+ if(bestCutP<0 || bestCutP>=256){
+ printf("two%d\n", bestCutP);
+ bestCutP=-1;
+ continue;
+ }
+
+ const int bestX= cutP2X[ bestCutP ];
+
+ int cutX= (showPoints ? cutPointX[line] : bestX );
+
/*
- if(show_points!=0){
- for(i=0; i<vc_diff; i++){
- j=dir[line * vc_diff + i];
- if(j<0 || j>=vc_diff) j=0;
+ const int cutP= min(x2CutP[cutX], 0); // fix ? ness, max?
- actVid2MemBufp->b[linep + ((vc_startx + j) <<1)+1]=255;
+ const float s1= sin( -float(phasePerCutP[ cutP ] + some)/128*PI + PHASE_SEG );
+ const float c1= cos( -float(phasePerCutP[ cutP ] + some)/128*PI + PHASE_SEG );
+ const float s2= sin( -float(phasePerCutP[ cutP ] + some)/128*PI );
+ const float c2= cos( -float(phasePerCutP[ cutP ] + some)/128*PI );
+
+ for(int x=0; x<vcDiff; x+=2){
+ const char u=char(actVid2MemBufp->b[linep+((vcStartX + x)<<1) ]);
+ const char v=char(actVid2MemBufp->b[linep+((vcStartX + x)<<1)+2]);
+ char u1, v1;
+
+ float s, c;
+ if(x<cutP){
+ s= s1;
+ c= c1;
}
- }
- */
+ else{
+ s= s2;
+ c= c2;
+ }
+
+
+ if( (line & 1) ^ ( vScore>0 ) ){
+ v1=(char)( -u*c - v*s );
+ u1=(char)( -v*c + u*s );
+ }
+ else{
+ v1=(char)( -u*c + v*s );
+ u1=(char)( -v*c - u*s );
+ }
+
+ printf("uv %d %d %d %d \n", u,v,u1,v1);
+ actVid2MemBufp->b[linep+((vcStartX + x)<<1) ]= u1;
+ actVid2MemBufp->b[linep+((vcStartX + x)<<1)+2]= v1;
+
+ }
+
+ cutX&= ~1;
+ */
+ memcpy(copy_buff, actVid2MemBufp->b + linep + (vcStartX<<1), vcDiff<<1);
+
+ memcpy(actVid2MemBufp->b + linep + (vcStartX<<1), copy_buff + (cutX<<1),
+ (vcDiff-cutX)<<1);
+ memcpy(actVid2MemBufp->b + linep + (vcStartX<<1) + ((vcDiff-cutX)<<1),
+ copy_buff,
+ cutX<<1);
+
+ cutpp[line]=cutX;
+
+
+ bestCutP= dir[line*257 + bestCutP];
}
+ for(int line=80; line<200; line++){
+ if( (line & 1) ^ ( vScore>0 ) ) printf(" e");
+ else printf(" o");
+
+ const int p= (cutpp[line-1]>>PHASE_CMP_STEP)
+ + (line*vcDiff>>PHASE_CMP_STEP) ;
+ int a= phaseDiff[p ];
+
+ int relCutp= cutpp[line-1] + cutpp[line];
+ if(relCutp>=vcDiff) relCutp-=vcDiff;
+
+ printf("c%03d %03d %03d %03d\n", relCutp, a*180/128, x2CutP[cutpp[line-1]], x2CutP[cutpp[line]]);
+ //SIGSEGV
+
+ const int cut1= x2CutP[ cutpp[line-1] ];
+ const int cut2= x2CutP[ cutpp[line ] ];
+
+ if(cut1<30 || cut1>220) continue;
+ if(cut2<30 || cut2>220) continue;
+
+ for(int offset=-20; offset<20; offset++){
+ int diff;
+ if( (line & 1) ^ ( vScore>0 ) ){
+ diff= phasePerCutP[ cut1 + offset ]
+ + phasePerCutP[ cut2 + offset ]
+ - a;
+ }
+ else{
+ diff= phasePerCutP[ cut1 + offset ]
+ + phasePerCutP[ cut2 + offset ]
+ + a;
+ }
+
+ diff&= 0xFF;
+
+ diff=mabs( diff-128 );
+ if(diff<PHASE_DIFF_TH && chromAmp[line]>3000) diff=1;
+ else if(chromAmp[line]>3000) diff=100000;
+ else diff=0;
+ score[offset+20]+=diff;
+ }
+
+// int cutP2=cutpp[line] - cutpp[line-2];
+// if(cutP2<0) cutP2+= vcDiff;
+ }
+
+ for(int i=0; i<40; i++)
+ printf("score %d %d\n", score[i], i-20);
+
+ double avgCutP=0;
+ for(int line=50; line<200; line++){
+ avgCutP+=double(cutpp[line]);
+ }
+ avgCutP/=(200.0-50.0);
+ printf("avg%f\n", avgCutP-double(vcDiff)/2.0);
+
+
+ printf("vScore %d\n", vScore);
+
+
if(iState){
T2=uclock();
sprintf(textbuf[4],"%f Rotate", (float)(T2-T1)/UCLOCKS_PER_SEC);
@@ -338,7 +756,9 @@ void vc_decrypt(void){
delete [] dir;
- delete [] datbuf[0];
- delete [] datbuf[1];
+ delete [] black;
+ delete [] phaseDiff;
+ delete [] chromAmp;
}
+
Modified: trunk/2010/2_vc_a.asm
==============================================================================
--- trunk/2010/2_vc_a.asm (original)
+++ trunk/2010/2_vc_a.asm Wed Jul 4 09:25:09 2007
@@ -4,9 +4,11 @@
segment .data
+extern _mmx
extern esp_save
extern _asm_temp
global _vc_corr__Fiiiiii
+global _vc_corr_mmx__Fiiiiii
%define line1a par1
%define line1b par2
@@ -15,6 +17,13 @@ global _vc_corr__Fiiiiii
%define line2b par5
%define count2 par6
+%define mline1a par_1
+%define mline1b par0
+%define mcount1 par1
+%define mline2a par2
+%define mline2b par3
+%define mcount2 par4
+
_vc_corr__Fiiiiii:
push ebx
@@ -139,5 +148,157 @@ skip2:
ret
+_vc_corr_mmx__Fiiiiii:
+; int3
+ push ebx
+ push esi
+
+ push edi
+ push ecx
+
+ mov esi, [mline1a]
+ mov edi, [mline1b]
+
+ mov ebx, edi
+ mov ecx, [mcount1]
+
+ and ecx, -8
+ and ebx, 7
+
+ shl ebx, 3
+ and edi, -8
+
+ add esi, ecx
+
+ movd mm6, ebx
+ pxor mm7, mm7
+
+ xor ebx, -1
+ add edi, ecx
+
+ add ebx, 65
+ xor ecx, -1
+
+ inc ecx
+
+ movd mm5, ebx
+ pxor mm4,mm4
+
+ cmp ecx, 8
+ jb skipMMX1
+
+ movq mm3, [ecx + edi ]
+
+ movq mm1, [ecx + edi + 8]
+ psrlq mm3, mm6
+
+ movq mm0, [ecx + esi ]
+ psllq mm1, mm5
+
+ por mm1, mm3
+
+MMXLoop:
+ movq mm2, mm0 ; U
+ psubusb mm0, mm1 ; V 1
+ movq mm3, [ecx + edi + 8 ] ; U
+ psubusb mm1, mm2 ; V 1
+ por mm1, mm0 ; U
+ psrlq mm3, mm6 ; V 1
+ movq mm2, mm1 ; U
+ punpcklbw mm1, mm4 ; V 1
+ punpckhbw mm2, mm4 ; U
+ paddusw mm7, mm1 ; V 1
+ movq mm1, [ecx + edi + 16] ; U
+ paddusw mm7, mm2 ; V 1
+ movq mm0, [ecx + esi + 8 ] ; U
+ psllq mm1, mm5 ; V 1
+ por mm1, mm3 ; U
+ add ecx, 8 ; V 1
+ jnc MMXLoop ; U 1
+
+skipMMX1:
+
+ mov esi, [mline2b]
+ mov edi, [mline2a]
+
+ mov ebx, edi
+ mov ecx, [mcount2]
+
+ and ecx, -8
+ and ebx, 7
+
+ shl ebx, 3
+ and edi, -8
+
+ add esi, ecx
+
+ movd mm6, ebx
+
+ xor ebx, -1
+ add edi, ecx
+
+ add ebx, 65
+ xor ecx, -1
+
+ inc ecx
+
+ movd mm5, ebx
+
+ cmp ecx, 8
+ jb skipMMX2
+
+ movq mm3, [ecx + edi ]
+
+ movq mm1, [ecx + edi + 8]
+ psrlq mm3, mm6
+
+ movq mm0, [ecx + esi ]
+ psllq mm1, mm5
+
+ por mm1, mm3
+
+MMXLoop2:
+ movq mm2, mm0 ; U
+ psubusb mm0, mm1 ; V 1
+ movq mm3, [ecx + edi + 8 ] ; U
+ psubusb mm1, mm2 ; V 1
+ por mm1, mm0 ; U
+ psrlq mm3, mm6 ; V 1
+ movq mm2, mm1 ; U
+ punpcklbw mm1, mm4 ; V 1
+ punpckhbw mm2, mm4 ; U
+ paddusw mm7, mm1 ; V 1
+ movq mm1, [ecx + edi + 16] ; U
+ paddusw mm7, mm2 ; V 1
+ movq mm0, [ecx + esi + 8 ] ; U
+ psllq mm1, mm5 ; V 1
+ por mm1, mm3 ; U
+ add ecx, 8 ; V 1
+ jnc MMXLoop2 ; U 1
+
+skipMMX2:
+
+ movq mm0, mm7
+ psrlq mm7, 32
+
+ paddusw mm7, mm0
+
+ movq mm0, mm7
+ psrlq mm7, 16
+
+ paddusw mm7, mm0
+
+ movd eax, mm7
+
+ and eax, 0xFFFF
+ pop ecx
+
+ pop edi
+ pop esi
+
+ pop ebx
+
+ret
+
Modified: trunk/2010/2_vc_a.h
==============================================================================
--- trunk/2010/2_vc_a.h (original)
+++ trunk/2010/2_vc_a.h Wed Jul 4 09:25:09 2007
@@ -3,5 +3,6 @@
#define n2_vc_a_h
int vc_corr(int, int, int, int, int, int);
+int vc_corr_mmx(int, int, int, int, int, int);
#endif
Modified: trunk/2010/2d
==============================================================================
--- trunk/2010/2d (original)
+++ trunk/2010/2d Wed Jul 4 09:25:09 2007
@@ -1,2 +1,10 @@
-fix asm_code in bfd stuff
-deComb overFlow
+load ?
+vsmooth
+vc color
+vc rightdrift ?
+
+vc (black like)
+vc exact start/end lines (last one not in 300x400)
+vc use amp to reject phase
+crypt decomb (math proofs and fixPoint Arith)
+double2float
1
0
[mndiff]: r51 - in trunk/2010: 2010.cc 2_71x6.cc 2_hw_mem.cc 2_nag.cc 2_vc.cc makefile
by michael 04 Jul '07
by michael 04 Jul '07
04 Jul '07
Author: michael
Date: Wed Jul 4 09:13:01 2007
New Revision: 51
Log:
version from 1998-07-25 20:43
Modified:
trunk/2010/2010.cc
trunk/2010/2_71x6.cc
trunk/2010/2_hw_mem.cc
trunk/2010/2_nag.cc
trunk/2010/2_vc.cc
trunk/2010/makefile
Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cc Wed Jul 4 09:13:01 2007
@@ -305,7 +305,7 @@ int main(int argc, char **argv){
if(page_flip==0) i= vgax * vgay * vb;
else i= vgax * vgay * vb << 1;
- vidbuf=(byte*)( map(mib->PhysBase, mib->PhysBase+i) - __djgpp_base_address);
+ vidbuf=(byte*)(map(mib->PhysBase, mib->PhysBase+i)) - __djgpp_base_address;
r.x.ax=0x4F02;
r.x.bx=vid | 16384;
Modified: trunk/2010/2_71x6.cc
==============================================================================
--- trunk/2010/2_71x6.cc (original)
+++ trunk/2010/2_71x6.cc Wed Jul 4 09:13:01 2007
@@ -85,7 +85,7 @@ int scan_pci_meteors(void){
write_pci(bus, dev, 0, PCI_IO_latency, 1, latency);
u=read_pci(bus, dev, 0, PCI_IO_base, 4) & (~0xFF); //fix me 4kb boundray
- meteors[i].saa7116=(saa7116*)(map(u, u+sizeof(saa7116)) - __djgpp_base_address);
+ meteors[i].saa7116=(saa7116*)( (char*)map(u, u+sizeof(saa7116)) - __djgpp_base_address );
printf("IRQ: %X INT: %X BUS: %X DEV: %X MemMap: %X\n",meteors[i].irq, meteors[i].intt, bus, dev, int(u));
// printf("%X %X\n",_go32_info_block.master_interrupt_controller_base, _go32_info_block.slave_interrupt_controller_base);
@@ -597,7 +597,7 @@ static void start_grab(void){
wait(wait_time);
- VID2MEMBUF grabVid2MemBufp= vid2MemBuf[ grabVid2MemBuf ];
+ volatile VID2MEMBUF grabVid2MemBufp= vid2MemBuf[ grabVid2MemBuf ];
if(oneField){
a_saa7116->dma.even[0]= a_saa7116->dma.odd [0]=
Modified: trunk/2010/2_hw_mem.cc
==============================================================================
--- trunk/2010/2_hw_mem.cc (original)
+++ trunk/2010/2_hw_mem.cc Wed Jul 4 09:13:01 2007
@@ -45,7 +45,7 @@ void locklin(void *start, void *end){
while(llp2!=NULL && llp2->next!=NULL) llp2=llp2->next;
meminfo.address=(unsigned long)(start);
- meminfo.size=(unsigned long)(end - start);
+ meminfo.size=(unsigned long)(int(end) - int(start));
if(__dpmi_lock_linear_region(&meminfo)!=0) error(Lock);
if(llp2!=NULL) llp2->next=llp;
@@ -68,7 +68,7 @@ void unlocklin(void *start, void *end){
if(llp==NULL) error(error_code(-8));
meminfo.address=(u_long)(start);
- meminfo.size=(u_long)(end - start);
+ meminfo.size=(u_long)(int(end) - int(start));
__dpmi_unlock_linear_region(&meminfo);
if(llp->start<start){
@@ -88,11 +88,11 @@ void unlocklin(void *start, void *end){
}
void lock(void *start, void *end){
- locklin(start + __djgpp_base_address, end + __djgpp_base_address);
+ locklin((char*)start + __djgpp_base_address, (char*)end + __djgpp_base_address);
}
void unlock(void *start, void *end){
- unlocklin(start + __djgpp_base_address, end + __djgpp_base_address);
+ unlocklin((char*)start + __djgpp_base_address, (char*)end + __djgpp_base_address);
}
void unlockall(void){
@@ -102,7 +102,7 @@ void unlockall(void){
llp=locklist;
while(llp!=NULL){
meminfo.address=(u_long)(llp->start);
- meminfo.size=(u_long)(llp->end - llp->start);
+ meminfo.size=(u_long)(int(llp->end) - int(llp->start));
__dpmi_unlock_linear_region(&meminfo);
llp2=llp;
llp=llp->next;
@@ -249,8 +249,8 @@ void allocCont(VID2MEMBUF *v2mb, int siz
for(int k=0; k<tryi; k++){
v2mb[*num-left+k].b=
(byte*)( map( vds_info.phys + slack + size*k
- , vds_info.phys + slack + size*k + size) // FIX ?-1
- - __djgpp_base_address);
+ , vds_info.phys + slack + size*k + size))
+ - __djgpp_base_address; // FIX ?-1
v2mb[*num-left+k].phys= vds_info.phys + size*k + slack;
}
Modified: trunk/2010/2_nag.cc
==============================================================================
--- trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cc Wed Jul 4 09:13:01 2007
@@ -163,32 +163,119 @@ static inline int nagLineLogi2Phys(const
}
static inline void mod4Fix(byte *p, const int type){
+ asm(//"int $3 \n\t"
+ "cmpl $2, %%edi \n\t"
+ " jb 1f \n\t"
+ "cmpl $3, %%edi \n\t"
+ " jb 2f \n\t"
+ "3: \n\t"
+ " movb (%%esi, %%ecx), %%al \n\t"
+ " movb 4(%%esi, %%ecx), %%bl \n\t"
+
+ " movb 2(%%esi, %%ecx), %%ah \n\t"
+ " movb 6(%%esi, %%ecx), %%bh \n\t"
+ "7: \n\t"
+ " xorb $-1, %%al \n\t"
+ " xorb $-1, %%bl \n\t"
+
+ " xorb $-1, %%ah \n\t"
+ " xorb $-1, %%bh \n\t"
+
+ " movb %%al, 2(%%esi, %%ecx) \n\t"
+ " movb %%bl, 6(%%esi, %%ecx) \n\t"
+
+ " movb %%ah, (%%esi, %%ecx) \n\t"
+ " movb %%bh, 4(%%esi, %%ecx) \n\t"
+
+ " movb 8(%%esi, %%ecx), %%al \n\t"
+ " movb 12(%%esi, %%ecx), %%bl \n\t"
+
+ " movb 10(%%esi, %%ecx), %%ah \n\t"
+ " movb 14(%%esi, %%ecx), %%bh \n\t"
+
+ " addl $8, %%ecx \n\t"
+ "jnc 7b \n\t"
+ " jmp 8f \n\t"
+
+ "2: \n\t"
+ " movl (%%esi, %%ecx), %%eax \n\t"
+ " movl 4(%%esi, %%ecx), %%ebx \n\t"
+ "7: \n\t"
+ " xorl $0x00FF00FF, %%eax \n\t"
+ " xorl $0x00FF00FF, %%ebx \n\t"
+
+ " movl %%eax, (%%esi, %%ecx) \n\t"
+ " movl %%ebx, 4(%%esi, %%ecx) \n\t"
+
+ " movl 8(%%esi, %%ecx), %%eax \n\t"
+ " movl 12(%%esi, %%ecx), %%ebx \n\t"
+
+ " addl $8, %%ecx \n\t"
+ "jnc 7b \n\t"
+ " jmp 8f \n\t"
+
+ "1: \n\t"
+ " movb (%%esi, %%ecx), %%al \n\t"
+ " movb 4(%%esi, %%ecx), %%bl \n\t"
+
+ " movb 2(%%esi, %%ecx), %%ah \n\t"
+ " movb 6(%%esi, %%ecx), %%bh \n\t"
+ "7: \n\t"
+ " movb %%al, 2(%%esi, %%ecx) \n\t" // AGI 1 CYC
+ " movb %%bl, 6(%%esi, %%ecx) \n\t"
+
+ " movb %%ah, (%%esi, %%ecx) \n\t"
+ " movb %%bh, 4(%%esi, %%ecx) \n\t"
+
+ " movb 8(%%esi, %%ecx), %%al \n\t"
+ " movb 12(%%esi, %%ecx), %%bl \n\t"
+
+ " movb 10(%%esi, %%ecx), %%ah \n\t"
+ " movb 14(%%esi, %%ecx), %%bh \n\t"
+
+ " addl $8, %%ecx \n\t"
+ "jnc 7b \n\t"
+
+ "8: \n\t"
+
+ :
+ : "S" (int(p) + (wndx<<2) ),
+ "D" (type) ,
+ "c" (-wndx<<2)
+ : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
+
+
+ /*
+
const bool xchg[4]={false, true, false, true};
const int neg [4]={ 0, 0, -1, -1};
- for(int x=0; x<(vgax<<1); x+=4){
- const byte u= p[x ];
- const byte v= p[x+2];
- if(xchg[type]){
+ if(xchg[type]){
+ for(int x=0; x<(wndx<<1); x+=4){
+ const byte u= p[x ];
+ const byte v= p[x+2];
+
p[x ]= (v^neg[type]) - neg[type];
p[x+2]= (u^neg[type]) - neg[type];
- }else{
- p[x ]= (u^neg[type]) - neg[type];
- p[x+2]= (v^neg[type]) - neg[type];
}
+ }else{
+ for(int x=0; x<(wndx<<1); x+=4){
+ const byte u= p[x ];
+ const byte v= p[x+2];
- }
-
-
+ p[x ]= (u^neg[type]) - neg[type];
+ p[x+2]= (v^neg[type]) - neg[type];
+ }
+ } */
}
void corrV(byte * p1, byte * p2, const int type, int *vPhase){
const bool xchg[4]={false, true, false, true};
const int neg [4]={ 0, 0, -1, -1};
- for(int x=0; x<(vgax<<1); x+=4){
+ for(int x=0; x<(wndx<<1); x+=4){
int u1= char(p1[x ]); // perhaps u><v
int v1= char(p1[x+2]);
@@ -577,7 +664,7 @@ void nag_decrypt(void){
if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, type);
}
else{
- for(int x=0; x<(vgax<<1); x+=4){
+ for(int x=0; x<(wndx<<1); x+=4){
linep[x ]= lowDriftLinep[x ];
linep[x+2]= lowDriftLinep[x+2];
}
Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cc Wed Jul 4 09:13:01 2007
@@ -49,7 +49,7 @@ void vc_decrypt(void){
long alg1=0, alg2=0, alg3=0;
color c;
-// show_points=1;
+ show_points=1;
const int vc_endx=wndx;
const int vc_startx=int(double(22-scales_x+3)/double(768-scales_x+scalee_x)*wndx);
Modified: trunk/2010/makefile
==============================================================================
--- trunk/2010/makefile (original)
+++ trunk/2010/makefile Wed Jul 4 09:13:01 2007
@@ -1,7 +1,7 @@
.SUFFIXES: .c .cc .h .o .asm .S .s
CFLAGS = -g
-CFLAGS = -O3 -m486 -fomit-frame-pointer -g -Wall -Wstrict-prototypes -malign-double -ffast-math -funroll-loops -fno-default-inline
+CFLAGS = -O3 -mpentium -fomit-frame-pointer -g -Wall -Wstrict-prototypes -malign-double -ffast-math -funroll-loops -fno-default-inline
AFLAGS = -f coff
.c.o: ; gcc $(CFLAGS) -c $<
1
0
Author: michael
Date: Wed Jul 4 09:08:11 2007
New Revision: 50
Log:
version from 1998-07-09 13:18
Modified:
trunk/2010/2_nag.cc
trunk/2010/2_vc.cc
Modified: trunk/2010/2_nag.cc
==============================================================================
--- trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cc Wed Jul 4 09:08:11 2007
@@ -162,13 +162,13 @@ static inline int nagLineLogi2Phys(const
return phys;
}
-static inline void mod4Fix(byte * p, const int type){
+static inline void mod4Fix(byte *p, const int type){
const bool xchg[4]={false, true, false, true};
const int neg [4]={ 0, 0, -1, -1};
for(int x=0; x<(vgax<<1); x+=4){
- const byte u= p[x ]; // perhaps u><v
- const byte v= p[x+2];
+ const byte u= p[x ];
+ const byte v= p[x+2];
if(xchg[type]){
p[x ]= (v^neg[type]) - neg[type];
@@ -256,7 +256,7 @@ void nag_decrypt(void){
for(int i=0; i<256; i++)
if( fscanf(f, "%d", &keyTable[i])!=1 ) error(KeyFile);
fclose(f);
-
+
f=fopen("2010.dat", "rb");
if(f!=NULL){
int decoLines2;
@@ -529,7 +529,7 @@ void nag_decrypt(void){
int lastVType[2];
int vPhase=0;
for(int i=0; i<NAG_LINES; i++){
- if(perm[i]>=32 && mabs(perm[i]-32 - i)<5){
+ if(perm[i]>=32 && i-perm[i]<=0){
const cleMod4= (i ) & 3;
const encMod4= (perm[i]) & 3;
const type= cleMod4 ^ encMod4;
@@ -549,7 +549,7 @@ void nag_decrypt(void){
byte *lowDriftLinep= actVid2MemBufp->b; // initalize in case nothing found else PF
int firstI=0;
for(int i=0; i<NAG_LINES; i++){
- if(perm[i]>=32 && mabs(perm[i]-32 - i)<5){
+ if(perm[i]>=32 && i-perm[i]<=0){
const cleMod4= (i + vPhase ) & 3;
const encMod4= (perm[i] + vPhase ) & 3;
const type= cleMod4 ^ encMod4;
@@ -562,11 +562,11 @@ void nag_decrypt(void){
break;
}
}
-
+
for(int clearLine=0 ;clearLine<NAG_LINES; clearLine++){
byte * const linep= actVid2MemBufp->b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
- if(perm[clearLine]>=32 && mabs(perm[clearLine]-32 - clearLine)<5
+ if(perm[clearLine]>=32 && clearLine-perm[clearLine]<=0
&& firstI!=clearLine){
const cleMod4= (clearLine + vPhase ) & 3;
const encMod4= (perm[clearLine] + vPhase ) & 3;
@@ -705,644 +705,5 @@ void nag_decrypt(void){
T1=T2;
}
-
-
-
-#ifdef 0
-
-
-
-
-
-
-
-
-
-
- printf("%d %d %d %d %d %d %d\n", nagStart2, nagEnd2, nagStart1, nagEnd1,
- nagSize1, nagSize2, nagSizeAll);
-
- const int corrBlock= 16000 / ( 2*( (wndx >> dwnSmpSize ) + sizeof(COEFFSLINE)) + 100);
-
- T1=uclock();
-
- char *lowRes= (char*) new double[(wndx * nagSizeAll >> dwnSmpSize)/8 + 3]; // align 8
- LINEINF *lineInf= new LINEINF [nagSizeAll];
- BLOCK *block= new BLOCK [nagSizeAll];
- COEFFSLINE *coeffsLine= new COEFFSLINE [nagSizeAll];
- SORTEDCOEFF *sortedCoeff= new SORTEDCOEFF[nagSizeAll*L_ENT];
- char *bufferInfo= new char [nagSizeAll];
-
- for(int i=0; i<nagSizeAll; i++){
- if(i<=nagSize2) bufferInfo[i]=1; // 31 free slots
- else bufferInfo[i]=int(double(i-nagSize2)/nagSize1*NAGRA_BUFFER+.5);
-// printf("%d %d\n", bufferInfo[i],i);
- }
-
- int line= ( vgax<<1 ) * nagStart1;
- int lowResLine= 0;
- int blockp;
- for(blockp=0; blockp<nagSizeAll; blockp++){
- block[blockp].end[0]=
- block[blockp].end[1]= blockp;
- block[blockp].limit[0]=
- block[blockp].limit[1]= blockp-nagSize1+1;
- block[blockp].ent= 1;
- lineInf[blockp].block= blockp;
- lineInf[blockp].next[0]=
- lineInf[blockp].next[1]= 0xFFFF;
- lineInf[blockp].nextCoeff[0]=
- lineInf[blockp].nextCoeff[1]= 0xFFFF;
-
-
- if(blockp==nagSize1) line= ( vgax<<1 ) * nagStart2;
-
- int avg;
- if(mmx){
- asm(//"int $3 \n\t"
- "pushl %%ebp \n\t"
- "cmpb (%%eax), %%cl \n\t"
- " je 5f \n\t"
- "movb %%cl, 3f-1 \n\t"
- "movb %%cl, (%%eax) \n\t"
- "movl $1, %%eax \n\t"
- "shll %%cl, %%eax \n\t"
- "movl %%eax, 4f-4 \n\t"
-
- "5: \n\t"
- "xor %%ecx, %%ecx \n\t"
-
- "1: \n\t"
- "movb (%%edi), %%al \n\t" // U load 32 byte in L1-cache
- "xorl %%ebx, %%ebx \n\t" // V 1
- "movl $0xFFFF, %%ebp \n\t" // U
- "4: \n\t"
- "xorl %%eax, %%eax \n\t" // V 1
- "2: \n\t"
- "addl %%eax, %%ebx \n\t" // U
- "xorl %%eax, %%eax \n\t" // V 1
- "movb (%%esi), %%al \n\t" // U
- "addl $2, %%esi \n\t" // V 1
- "decl %%ebp \n\t" // U
- " jnz 2b \n\t" // V 1
- "incl %%edi \n\t" // U
- "addl %%eax, %%ebx \n\t" // V 1
- "shrl $5, %%ebx \n\t" // U 1
- "3: \n\t"
- "addl %%ebx, %%ecx \n\t" // U
- "decl %%edx \n\t" // V 1
- "movb %%bl, -1(%%edi) \n\t" // U
- " jnz 1b \n\t" // V 1
-
- "popl %%ebp \n\t"
- : "=c" (avg)
- : "c" (dwnSmp), "a"(&lastDwnSmp),
- "S" (actVid2MemBufp->b + line + 1) ,
- "d" (wndx>>dwnSmp) ,
- "D" (lowRes + lowResLine)
- : "%eax", "%ebx", "%edx", "%esi", "%edi");
-
- }
- else{
- asm(//"int $3 \n\t"
- "pushl %%ebp \n\t"
- "cmpb (%%eax), %%cl \n\t"
- " je 5f \n\t"
- "movb %%cl, 3f-1 \n\t"
- "movb %%cl, (%%eax) \n\t"
- "movl $1, %%eax \n\t"
- "shll %%cl, %%eax \n\t"
- "movl %%eax, 4f-4 \n\t"
-
- "5: \n\t"
- "xor %%ecx, %%ecx \n\t"
-
-
- "1: \n\t"
- "movw (%%edi), %%ax \n\t" // U load 32 byte in L1-cache
- "xorl %%ebx, %%ebx \n\t" // V 1
- "movl $0xFFFF, %%ebp \n\t" // U
- "4: \n\t"
- "xorl %%eax, %%eax \n\t" // V 1
- "2: \n\t"
- "addl %%eax, %%ebx \n\t" // U
- "xorl %%eax, %%eax \n\t" // V 1
- "movb (%%esi), %%al \n\t" // U
- "addl $2, %%esi \n\t" // V 1
- "decl %%ebp \n\t" // U
- " jnz 2b \n\t" // V 1
- "addl $2, %%edi \n\t" // U
- "addl %%eax, %%ebx \n\t" // V 1
- "shrl $5, %%ebx \n\t" // U 1
- "3: \n\t"
- "addl %%ebx, %%ecx \n\t" // U
- "decl %%edx \n\t" // V 1
- "movw %%bx, -2(%%edi) \n\t" // U
- " jnz 1b \n\t" // V 1
-
- "popl %%ebp \n\t"
- : "=c" (avg)
- : "c" (dwnSmp), "a"(&lastDwnSmp),
- "S" (actVid2MemBufp->b + line + 1) ,
- "d" (wndx>>dwnSmp) ,
- "D" (lowRes + lowResLine)
- : "%eax", "%ebx", "%edx", "%esi", "%edi");
- }
-
- if(avg>blackThreshold)
- lineInf[blockp].state= eSingle;
- else
- lineInf[blockp].state= eBlack;
-
- line+= vgax<<2;
- lowResLine+= wndx >> dwnSmpSize;
- }
-
-
- printf("HALLO1\n");
-
- int corrLoops=0;
-
- bool first=true;
- bool didSome;
- long T_corr=0, T_radix=0, T_merge=0;
- do{
- didSome=false;
-
- /* clear coeffs */
- for(int i=0; i<nagSizeAll; i++){
- for(int j=0; j<L_ENT; j++){
- if(lineInf[i].state>=eSingle)
- coeffsLine[i].coeff[j]= DO_COEFF;
- else
- coeffsLine[i].coeff[j]= DONT_COEFF;
- coeffsLine[i].line[j]= 0xFFFF;
- }
- }
- printf("HALLOA\n");
-
- /* corr calc */
-
- int s_line0, s_line1;
- int s_linep0, s_linep1;
- int line0, line1;
- int linep0, linep1;
-
- s_linep0=0;
- for(s_line0= 0; s_line0 < nagSizeAll; s_line0 += corrBlock){
- s_linep1 = s_linep0;
-
- for(s_line1= s_line0; s_line1 < nagSizeAll; s_line1 += corrBlock){
-
- linep0 = s_linep1 - (wndx >> dwnSmpSize);
- for(line0= s_line1; line0 < min(nagSizeAll, s_line1 + corrBlock); line0++){
-
- linep0 += wndx >> dwnSmpSize;
-
- if(coeffsLine[line0].coeff[0]==DONT_COEFF) continue;
-
- if(s_line0 == s_line1){
- linep1 = linep0 + (wndx>>dwnSmpSize);
- line1 = line0 + 1;
- if(line1 >= nagSizeAll || line1 >= s_line1 + corrBlock) continue;
- }
- else{
- linep1 = s_linep0;
- line1 = s_line0;
- }
-
- asm_temp=(u_long)(coeffsLine + line0);
- asm_temp4=line0;
-
-// printf("%d %d %d %d %d %d %d %d %d\n", corrBlock, line0, line1,
-// linep0, linep1, s_line0, s_line1, s_linep0, s_linep1);
- nagra_corr(min(nagSizeAll, s_line0 + corrBlock),
- wndx >> dwnSmpSize,
- linep0,
- linep1 - (wndx >> dwnSmpSize),
- line1,
- int(coeffsLine),
- int(lowRes) );
-
- }
- s_linep1 += (wndx >> dwnSmpSize) * corrBlock;
-
- }
- s_linep0 += (wndx >> dwnSmpSize) * corrBlock;
-
- }
-
- if(mmx) asm("emms \n\t");
- printf("HALLOB\n");
-
- if(iState){
- T2=uclock();
- T_corr+=T2-T1;
- T1=T2;
- }
- // save line info ...
- /* radix sort */
- int coeffSize= 0;
- int stat[2][257];
- for(int i=0; i<257; i++){
- stat[0][i]=
- stat[1][i]=0;
- }
- for(int i=0; i<nagSizeAll; i++){
-
- for(int j=0; j<L_ENT; j++){
- if(coeffsLine[i].line[j]==0xFFFF) break;
- stat[0][ ( coeffsLine[i].coeff[j] & 0xFF ) + 1 ]++;
- stat[1][ ( (coeffsLine[i].coeff[j] >> 8) ) + 1 ]++;
- coeffSize++;
- }
-// if(coeffsLine[i].line[min(j, L_ENT-1)]==0xFFFF) continue;
-
- if(first){
- lineInf[i].nextCoeff[0]= coeffsLine[i].coeff[0]; //
- lineInf[i].nextCoeff[1]= coeffsLine[i].coeff[1]; // for line integration
- lineInf[i].next[0]= coeffsLine[i].line[0]; //
- lineInf[i].next[1]= coeffsLine[i].line[1]; //
- }
- coeffsLine[i].line[L_ENT-1]|= LAST_MASK; // mark last coeff per line
-
- }
- for(int i=2; i<256; i++){
- stat[0][i]+= stat[0][i-1];
- stat[1][i]+= stat[1][i-1];
- }
- TEMPSORT *tempSort= new TEMPSORT[coeffSize];
- for(int i=0; i<nagSizeAll; i++){
- for(int j=0; j<L_ENT; j++){
- if(coeffsLine[i].line[j]==0xFFFF) break;
- tempSort[ stat[0][ coeffsLine[i].coeff[j] & 0xFF ] ].coeff=
- coeffsLine[i].coeff[j];
- tempSort[ stat[0][ coeffsLine[i].coeff[j] & 0xFF ] ].line[0]=i;
- tempSort[ stat[0][ coeffsLine[i].coeff[j] & 0xFF ] ].line[1]=
- coeffsLine[i].line[j];
-
- stat[0][ coeffsLine[i].coeff[j] & 0xFF ]++;
- }
- }
- for(int i=0; i<coeffSize; i++){
- sortedCoeff[ stat[1][ tempSort[i].coeff >> 8 ] ].line[0]=
- tempSort[i].line[0];
- sortedCoeff[ stat[1][ tempSort[i].coeff >> 8 ] ].line[1]=
- tempSort[i].line[1];
-
- stat[1][ tempSort[i].coeff >> 8 ]++;
- }
-
- delete [] tempSort;
-
- if(iState){
- T2=uclock();
- T_radix+=T2-T1;
- T1=T2;
- }
- printf("HALLOC\n");
-
- for(int coeffp=0; coeffp<coeffSize; coeffp++){
- if( sortedCoeff[coeffp].line[0]==0xFFFF
- || sortedCoeff[coeffp].line[1]==0xFFFF ) break;
-
- int line0= sortedCoeff[coeffp].line[0];
- int line1= sortedCoeff[coeffp].line[1];
-
- STATE state0= lineInf[ line0 & (~LAST_MASK) ].state;
- STATE state1= lineInf[ line1 & (~LAST_MASK) ].state;
-
- // last_mask is saved in opposit line
- if(line0 & LAST_MASK){
- if(state1 >= eSingle) break;
- }
- if(line1 & LAST_MASK){
- if(state0 >= eSingle) break;
- }
-
- line0 &= ~LAST_MASK;
- line1 &= ~LAST_MASK;
-
- // eBlack eMiddle eSingle eEnd
- if(state0>state1){
- const STATE tempS= state0;
- state0= state1;
- state1= tempS;
- const int tempL= line0;
- line0= line1;
- line1= tempL;
- }
-
- const int block0= lineInf[ line0 ].block;
- const int block1= lineInf[ line1 ].block;
-
- if(state0==eBlack) continue;
-
- if(state0==eMiddle){
- if(state1==eSingle) continue; // fix line integration
- else continue;
- }
-
- if(line0<0 || line0>=nagSizeAll) printf("line0 %d\n", line0);
- if(line1<0 || line1>=nagSizeAll) printf("line1 %d\n", line1);
- if(block0<0 || block0>=blockp ) printf("block0 %d %d\n", block0, blockp);
- if(block1<0 || block1>=blockp ) printf("block1 %d %d\n", block1, blockp);
-
- if(block1==block0) continue;
-
- // block + line / line + line / block + block
-
- const int whichEnd[2]= { line0==block[block0].end[0] ? 0 : 1,
- line1==block[block1].end[0] ? 0 : 1 };
-
- const int limit[2]= { max(block[block0].limit[ whichEnd[0] ^ 1 ],
- block[block1].limit[ whichEnd[1] ]
- -block[block0].ent ),
- max(block[block1].limit[ whichEnd[1] ^ 1 ],
- block[block0].limit[ whichEnd[0] ]
- -block[block1].ent ) };
-
- const int ori= limit[0] < limit[1] ? 0 : 1;
-
- const int end=limit[ori] + block[block0].ent + block[block1].ent;
-
- if(end > nagSizeAll)
- continue;
-
- const int start=min( block[block0].limit[0],
- block[block1].limit[0] );
-
- int slots=0;
- {
- int i;
- for(i=start; i<end; i++){
- if( i >= block[block0].limit[0]
- && i < block[block0].limit[0] + block[block0].ent) slots++;
- if( i >= block[block1].limit[0]
- && i < block[block1].limit[0] + block[block1].ent) slots++;
- if( i >= limit[ori] && i < end ) slots--;
- if(i>=0 && bufferInfo[i] + slots > NAGRA_BUFFER) break;
- }
- if(i<end) continue;
- }
-
- // from here merge is certain
-
- for(int i=start; i<end; i++){
- if( i >= block[block0].limit[0]
- && i < block[block0].limit[0] + block[block0].ent) slots++;
- if( i >= block[block1].limit[0]
- && i < block[block1].limit[0] + block[block1].ent) slots++;
- if( i >= limit[ori] && i < end ) slots--;
- if(i>=0) bufferInfo[i]+= slots;
- }
-
- const int newBlock= min(block0, block1);
- const int freeBlock= max(block0, block1);
-
- lineInf[ line0 ].next[1] = lineInf[ line0 ].next[0];
- lineInf[ line1 ].next[1] = lineInf[ line1 ].next[0];
-
- lineInf[ line0 ].next[0] = line1;
- lineInf[ line1 ].next[0] = line0;
-
- lineInf[ line0 ].state=
- lineInf[ line1 ].state= eMiddle;
-
- const int oriBlock[2]= { ori==0 ? block0 : block1,
- ori==0 ? block1 : block0 };
-
- BLOCK temp;
- temp.end[0]= block[ oriBlock[0] ].end[ whichEnd[ori ] ^ 1 ];
- temp.end[1]= block[ oriBlock[1] ].end[ whichEnd[ori ^ 1] ^ 1 ];
-
- lineInf[ temp.end[0] ].state=
- lineInf[ temp.end[1] ].state= eEnd;
-
- lineInf[ temp.end[0] ].block=
- lineInf[ temp.end[1] ].block= newBlock;
-
- temp.ent= block[block0].ent + block[block1].ent;
- temp.limit[0]= limit[ori ];
- temp.limit[1]= limit[ori ^ 1];
-
- block[newBlock]= temp;
-
- blockp--;
- if(freeBlock != blockp){
- block[freeBlock]= block[blockp];
- lineInf[ block[freeBlock].end[0] ].block= freeBlock;
- lineInf[ block[freeBlock].end[1] ].block= freeBlock;
- }
-
- didSome= true;
-
- }
- printf("HALLOD\n");
-
- if(iState){
- T2=uclock();
- T_merge+=T2-T1;
- T1=T2;
- }
-
- corrLoops++;
- first= false;
- }while(didSome==true);
-
- printf("blockp %d\n", blockp);
-
- if(iState){
- sprintf(textbuf[0],"%f Corr", (float)(T_corr)/UCLOCKS_PER_SEC);
- sprintf(textbuf[1],"%f Radix Sort", (float)(T_radix)/UCLOCKS_PER_SEC);
- sprintf(textbuf[2],"%f Block Handling", (float)(T_merge)/UCLOCKS_PER_SEC);
- T2=uclock();
- T1=T2;
- }
- printf("HALLO2\n");
-
-
- if(iState){
- T2=uclock();
- sprintf(textbuf[3],"%f Stat", (float)(T2-T1)/UCLOCKS_PER_SEC);
- T1=T2;
- }
-
- qsort(block, blockp, sizeof(BLOCK), qsort_block);
-
- if(iState){
- T2=uclock();
- sprintf(textbuf[4],"%f Sort", (float)(T2-T1)/UCLOCKS_PER_SEC);
- T1=T2;
- }
-
- int forwVec[outy];
- int bakwVec[outy];
-
- for(int i=0; i<outy; i++){
- forwVec[i]=
- bakwVec[i]=-1;
- }
-
- int ordLine=0;
- for(int i=0; i<blockp; i++){
- int line= block[i].end[0];
- int linePrev=-3;
- int trueLine;
- for(int j=0; j<block[i].ent; j++){
-// printf(" %d %d\n", i, line);
- if(lineInf[line].next[0] == linePrev){
- linePrev=line;
- line= lineInf[line].next[1];
- }
- else{
- linePrev=line;
- line= lineInf[line].next[0];
- }
- if(linePrev < nagSize1) trueLine=( linePrev <<1) + nagStart1;
- else trueLine=((linePrev-nagSize1)<<1) + nagStart2;
-
- if(forwVec[trueLine] != -1) printf("fatal forw %d\n", trueLine);
- if(bakwVec[ordLine ] != -1) printf("fatal bakw %d\n", ordLine);
-
- forwVec[trueLine] = ordLine;
- bakwVec[ordLine ] = trueLine;
-
- if(wndy == outy) ordLine +=2;
- else ordLine ++;
- }
- }
- printf("HALLO3\n");
-
- if(iState){
- T2=uclock();
- sprintf(textbuf[5],"%f Built Vecs", (float)(T2-T1)/UCLOCKS_PER_SEC);
- T1=T2;
- }
-
- // fix stuff below (old)
- byte copy_buff[max_x<<1];
-
- for(int i=0; i<outy; i++){
- if(bakwVec[i] == -1 || bakwVec[i] == i) continue;
- int k;
- int j=i;
- do{
- k = j;
- j = forwVec[j];
- } while(j != i && j != -1);
- const int open= ( (j == -1) ? 1 : 0 );
-
- if(open == 0){
- memcpy(copy_buff, actVid2MemBufp->cl + i * vgax, wndx << 1);
- j = i;
- do{
- k = j;
- j = bakwVec[j];
- forwVec[k] = k;
- bakwVec[k] = k;
-// printf("closed %d %d\n", j, k );
- if(j != i) memcpy(actVid2MemBufp->cl + k * vgax, actVid2MemBufp->cl + j * vgax, wndx << 1);
- } while(j != i);
- memcpy(actVid2MemBufp->cl + k * vgax, copy_buff, wndx << 1);
- }
- else{
- j = k;
- do{
- k = j;
- j = bakwVec[j];
- forwVec[k] = k;
- bakwVec[k] = k;
-// printf("open %d %d\n", j, k );
- if(j != -1) memcpy(actVid2MemBufp->cl + k * vgax, actVid2MemBufp->cl + j * vgax, wndx << 1);
- } while(j != -1);
- }
-
- }
-
- if(outy == wndy){
- for(int i=0; i<outy; i+=2){
- memcpy(actVid2MemBufp->cl + (i+1) * vgax, actVid2MemBufp->cl + i * vgax, wndx << 1);
- }
- }
-
-/*
- linep=0;
- for(line=0; line<yresst1; line++){
- linep+=vgax<<1;
- int allnor=0;
- int allinv=0;
- for(i=0; i<wndx; i+=2){
- register int x=actVid2MemBufp->b[ linep + (i<<1) - (vgax<<1) + 2 ];
- register int y=actVid2MemBufp->b[ linep + (i<<1) + 2 ];
- if(x>127) x-=256;
- if(y>127) y-=256;
- allnor+=mabs(x-y);
- allinv+=mabs(x+y);
- }
- if(allinv < allnor){
- actVid2MemBufp->cl[line * vgax + 4 ].lum=255;
- actVid2MemBufp->cl[line * vgax + 5 ].lum=0;
- for(i=0; i<wndx; i+=2){
- register int x=actVid2MemBufp->b[ linep + (i<<1) + 2 ];
- if(x>127) x-=256;
- actVid2MemBufp->b[ 2 + linep + (i<<1) ]=char(-x);
- }
- }
-
- }
- printf("HALLO4\n");
-
- linep=0;
- for(line=0; line<yresst1; line++){
- linep+=vgax<<1;
- int allnor=0;
- int allinv=0;
- for(i=0; i<wndx; i+=2){
- register int x=actVid2MemBufp->b[ linep + (i<<1) - (vgax<<1) ];
- register int y=actVid2MemBufp->b[ linep + (i<<1) ];
- if(x>127) x-=256;
- if(y>127) y-=256;
- allnor+=mabs(x-y);
- allinv+=mabs(x+y);
- }
- if(allinv < allnor){
- actVid2MemBufp->cl[line * vgax + 6 ].lum=255;
- actVid2MemBufp->cl[line * vgax + 7 ].lum=0;
- for(i=0; i<wndx; i+=2){
- register int x=actVid2MemBufp->b[ linep + (i<<1) ];
- if(x>127) x-=256;
- actVid2MemBufp->b[ linep + (i<<1) ]=char(-x);
- }
- }
-
- }
-*/
-
- line=0;
- int block_noblack= blockp;
- for(int i=0; i<blockp; i++){
-// printf("%d %d %d\n", i, block[i].up_limit, block[i].avg);
- line+= block[i].ent;
-
- actVid2MemBufp->cl[line * vgax ].lum=255;
- actVid2MemBufp->cl[line * vgax + 1 ].lum=0;
- if(lineInf[ block[i].end[0] ].state == 0){
- actVid2MemBufp->cl[line * vgax + 2 ].lum=255;
- actVid2MemBufp->cl[line * vgax + 3 ].lum=0;
- block_noblack--;
- }
- }
-
-
- delete [] lowRes;
- delete [] block;
- delete [] lineInf;
- delete [] coeffsLine;
- delete [] sortedCoeff;
- delete [] bufferInfo;
-
-#endif
-
}
Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cc Wed Jul 4 09:08:11 2007
@@ -49,7 +49,7 @@ void vc_decrypt(void){
long alg1=0, alg2=0, alg3=0;
color c;
- show_points=1;
+// show_points=1;
const int vc_endx=wndx;
const int vc_startx=int(double(22-scales_x+3)/double(768-scales_x+scalee_x)*wndx);
1
0
[mndiff]: r49 - in trunk/2010: 2010.cc 2_crypt.cc 2_grafix.cc 2_hw.cc 2_hw_mem.cc 2_hw_mem.h 2_nag.cc makefile
by michael 04 Jul '07
by michael 04 Jul '07
04 Jul '07
Author: michael
Date: Wed Jul 4 09:06:09 2007
New Revision: 49
Log:
next version (unknown date)
Modified:
trunk/2010/2010.cc
trunk/2010/2_crypt.cc
trunk/2010/2_grafix.cc
trunk/2010/2_hw.cc
trunk/2010/2_hw_mem.cc
trunk/2010/2_hw_mem.h
trunk/2010/2_nag.cc
trunk/2010/makefile
Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cc Wed Jul 4 09:06:09 2007
@@ -423,7 +423,7 @@ int main(int argc, char **argv){
case '5' : TVStd= PAL;
cryptStd= nag;
if(yuvmode==0) yuvmode=1;
- if(oneField && yuvmode==2) error(MemAlloc);
+ //if(oneField && yuvmode==2) error(MemAlloc);
vSmoothState=false;
setStdScale();
contGrab();
Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cc Wed Jul 4 09:06:09 2007
@@ -43,7 +43,6 @@ static void decomb(void){
int linep, llinep, line, i;
int j, k;
int temp[max_x];
- int amp[max_x];
const int outy1= outy>>1;
const int stride=oneField ? (vgax<<1) : (vgax<<2);
@@ -56,38 +55,12 @@ static void decomb(void){
for(i=0; i<wndx; i++){
temp[i]=0;
- amp[i]=0;
- }
-
- linep= startp;
- if(o) linep+=vgax<<1;
- for(line=0; line<segSize; line++){
- for(i=0; i<wndx; i+=2){
- j = char(actVid2MemBufp->b[linep + (i<<1) ]);
- j= (j + j) - temp[i];
- temp[i] = j;
- if(line & 1) amp[i]-=j;
- else amp[i]+=j;
- }
- linep+=stride;
- }
-
- for(i=0; i<wndx; i++){
- temp[i]= amp[i]/segSize;
}
linep= startp;
if(o) linep+=vgax<<1;
for(line=0; line<segSize; line++){
for(i=0; i<wndx; i++){
-/*
- j = char(actVid2MemBufp->b[linep + (i<<1)]);
- j=(j + j) - temp[i];
- temp[i] = j;
- if (j> 127) j= 127;
- else if(j<-128) j=-128;
- actVid2MemBufp->b[linep + (i<<1)] = (char)(j);
- */
j = char(actVid2MemBufp->b[linep + (i<<1)]);
j=(j + j) - temp[i];
@@ -96,10 +69,6 @@ static void decomb(void){
else if(j<-128) j=-128;
temp[i] = j;
actVid2MemBufp->b[linep + (i<<1)] = (char)(j);
-
-
-
-
}
linep+=stride;
}
@@ -146,22 +115,9 @@ static void decomb(void){
}
static void vSmooth(void){
-/*
- for(int x=0; x < wndx; x++){
- ((s_rgb*)actVid2MemBufp.b)[x + y*vgax].r=( (((s_rgb*)actVid2MemBufp.b)[x + y *vgax].r >> 1)
- + (((s_rgb*)actVid2MemBufp.b)[x + (y+1)*vgax].r )
- + (((s_rgb*)actVid2MemBufp.b)[x + (y+2)*vgax].r >> 1) ) >> 1;
- ((s_rgb*)actVid2MemBufp.b)[x + y*vgax].g=( (((s_rgb*)actVid2MemBufp.b)[x + y *vgax].g >> 1)
- + (((s_rgb*)actVid2MemBufp.b)[x + (y+1)*vgax].g )
- + (((s_rgb*)actVid2MemBufp.b)[x + (y+2)*vgax].g >> 1) ) >> 1;
- ((s_rgb*)actVid2MemBufp.b)[x + y*vgax].b=( (((s_rgb*)actVid2MemBufp.b)[x + y *vgax].b >> 1)
- + (((s_rgb*)actVid2MemBufp.b)[x + (y+1)*vgax].b )
- + (((s_rgb*)actVid2MemBufp.b)[x + (y+2)*vgax].b >> 1) ) >> 1;
- }
- */
-/*
+
if(yuvmode==0){
- asm(//"int $3 \n\t"
+ /* asm(//"int $3 \n\t"
"1: \n\t"
"movl (%%esi ), %%eax \n\t" //U LINE
"movl (%%esi,%%edi,2), %%ebx \n\t" // V 1 LINE + 2
@@ -183,7 +139,7 @@ static void vSmooth(void){
: "D" (vgax<<2), "S" (actVid2MemBufp->b),
"c" (vgax * (wndy-2) )
: "%eax", "%ebx", "%ecx", "%esi");
-
+ */
}
else{
asm(//"int $3 \n\t"
@@ -219,5 +175,5 @@ static void vSmooth(void){
}
- */
+
}
Modified: trunk/2010/2_grafix.cc
==============================================================================
--- trunk/2010/2_grafix.cc (original)
+++ trunk/2010/2_grafix.cc Wed Jul 4 09:06:09 2007
@@ -21,6 +21,7 @@
extern int bright, contr, satur;
extern MENULEVEL menuLevel;
extern int infoPosY;
+ extern VID2MEMBUF *vid2MemBuf;
bool helpState=true;
bool iState=false;
@@ -71,10 +72,14 @@ void showStuff(void){
long T1=uclock();
if(iState){
- sprintf(textbuf,"%2.2f Fps",1/((float)(T1-T2)/UCLOCKS_PER_SEC));
c.init(255, 0, 0, yuvmode);
+
+ sprintf(textbuf,"%2.2f Fps",1/((float)(T1-T2)/UCLOCKS_PER_SEC));
gprint(10, infoPosY+=10, c.col, textbuf);
+ sprintf(textbuf,"%d Buffers", vid2MemBuf[0].num);
+ gprint(150, infoPosY , c.col, textbuf);
+
sprintf(textbuf,"%d Corrupted Fields", corr_errors);
gprint(10, infoPosY+=10, c.col, textbuf);
Modified: trunk/2010/2_hw.cc
==============================================================================
--- trunk/2010/2_hw.cc (original)
+++ trunk/2010/2_hw.cc Wed Jul 4 09:06:09 2007
@@ -38,7 +38,6 @@
extern bool strangeRgb16;
int g_mode=0;
- int m_mode=0;
extern u_short my_cs, my_ds;
asm("__esp: .long 0\n\t");
@@ -174,153 +173,6 @@ void mem2vid(byte *to, byte *from, int n
: "b" (yuv2RgbLut), "S" (from), "D" (to), "c" (num<<1)
: "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
-
-
-/*
- num>>=1;
- if(bpp==32){
- U Y1 V Y2
-
- esi from
- ebp to
- edi lut
- ecx counter
- eax (Y1 Y1 Y1 Y1 + LUT[ U ] + LUT[ V ]) | (Y2 Y2 Y2 Y2 + LUT[ U ] + LUT[ V ])
- ebx Y1 Y1 Y1 Y1 + LUT[ U ] + LUT[ V ]
- edx Y2 Y2 Y2 Y2 + LUT[ U ] + LUT[ V ]
- esp
- asm(//"int $3 \n\t"
- "pushl %%ebp \n\t"
- "movl %%eax, %%ebp \n\t"
- "movl %%esp, (__esp) \n\t"
-
- "1: \n\t"
- "nop \n\t" // U
- "movl (%%esi), %%eax \n\t" // V 1
- "movl %%eax, %%ebx \n\t" // U
- "movl %%eax, %%edx \n\t" // V 1
- "shrl $16, %%ebx \n\t" // U
- "andl $0x000000FF, %%eax \n\t" // V 1
- "andl $0x000000FF, %%ebx \n\t" // U
- "andl $0xFE00FE00, %%edx \n\t" // V 1
- "shrl $1, %%edx \n\t" // U
- "movl (%%edi, %%eax, 4), %%eax \n\t" // V 1
- "movl 1024(%%edi, %%ebx, 4), %%ebx \n\t" // U
- "movl %%edx, %%esp \n\t" // V 1
- "shrl $8, %%edx \n\t" // U
- "addl %%ebx, %%eax \n\t" // V 1
- "orl %%edx, %%esp \n\t" // U
- "addl $8, %%ebp \n\t" // V 1
- "movl %%esp, %%ebx \n\t" // U
- "movl %%esp, %%edx \n\t" // V 1
- "shll $16, %%ebx \n\t" // U
- "andl $0x0000FFFF, %%edx \n\t" // V 1
- "orl %%edx, %%ebx \n\t" // U
- "movl %%esp, %%edx \n\t" // V 1
- "shrl $16, %%edx \n\t" // U
- "andl $0xFFFF0000, %%esp \n\t" // V 1
- "orl %%esp, %%edx \n\t" // U
- "addl %%eax, %%ebx \n\t" // V 1
- "addl %%eax, %%edx \n\t" // U
- "movl %%ebx, %%eax \n\t" // V 1
- "orl %%edx, %%eax \n\t" // U
- "addl $4, %%esi \n\t" // V 1
- "test $0x00808080, %%eax \n\t" // U
- " jz 2f \n\t" // V 1
-
- "movl %%ebx, %%eax \n\t" // U
- "nop \n\t" // V 1
- "test $0x00800000, %%eax \n\t" // U
- " jz 10f \n\t" // V 1
- "test $0x00400000, %%eax \n\t" // U
- " jz 11f \n\t" // V 1
- "andl $0xFF00FFFF, %%ebx \n\t" // U
- "jmp 10f \n\t" // V 1
- "11: \n\t"
- "orl $0x00FF0000, %%ebx \n\t" // U
- "10: \n\t"
- "test $0x00008000, %%eax \n\t" // U
- " jz 20f \n\t" // V 1
- "test $0x00004000, %%eax \n\t" // U
- " jz 21f \n\t" // V 1
- "andl $0xFFFF00FF, %%ebx \n\t" // U
- "jmp 20f \n\t" // V 1
- "21: \n\t"
- "orl $0x0000FF00, %%ebx \n\t" // U
- "20: \n\t"
- "test $0x00000080, %%eax \n\t" // U
- " jz 30f \n\t" // V 1
- "test $0x00000040, %%eax \n\t" // U
- " jz 31f \n\t" // V 1
- "andl $0xFFFFFF00, %%ebx \n\t" // U
- "jmp 30f \n\t" // V 1
- "31: \n\t"
- "orl $0x000000FF, %%ebx \n\t" // U
- "30: \n\t"
- "movl %%edx, %%eax \n\t" // U
- "nop \n\t" // V 1
- "test $0x00800000, %%eax \n\t" // U
- " jz 40f \n\t" // V 1
- "test $0x00400000, %%eax \n\t" // U
- " jz 41f \n\t" // V 1
- "andl $0xFF00FFFF, %%edx \n\t" // U
- "jmp 40f \n\t" // V 1
- "41: \n\t"
- "orl $0x00FF0000, %%edx \n\t" // U
- "40: \n\t"
- "test $0x00008000, %%eax \n\t" // U
- " jz 50f \n\t" // V 1
- "test $0x00004000, %%eax \n\t" // U
- " jz 51f \n\t" // V 1
- "andl $0xFFFF00FF, %%edx \n\t" // U
- "jmp 50f \n\t" // V 1
- "51: \n\t"
- "orl $0x0000FF00, %%edx \n\t" // U
- "50: \n\t"
- "test $0x00000080, %%eax \n\t" // U
- " jz 60f \n\t" // V 1
- "test $0x00000040, %%eax \n\t" // U
- " jz 61f \n\t" // V 1
- "andl $0xFFFFFF00, %%edx \n\t" // U
- "jmp 60f \n\t" // V 1
- "61: \n\t"
- "orl $0x000000FF, %%edx \n\t" // U
- "60: \n\t"
-
- "andl $0xFF7F7F7F, %%ebx \n\t" // U
- "andl $0xFF7F7F7F, %%edx \n\t" // V 1
-
- "2: \n\t"
- "addl %%ebx, %%ebx \n\t" // U
- "addl %%edx, %%edx \n\t" // V 1
- "movl %%ebx, -8(%%ebp) \n\t" // U
- "movl %%edx, -4(%%ebp) \n\t" // V 1
- "decl %%ecx \n\t" // U
- " jnz 1b \n\t" // V 1
- "movl (__esp), %%esp \n\t"
- "popl %%ebp \n\t"
- :
- : "m" (vgax<<1),
- "D" (yuv2rgb_lut), "S" (from), "a" (to), "c" (num)
- : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
-
-
-
-
-
- }
- else{
- for(i=0; i<num; i++){
- to[i*6 ]= (byte)( from[i].y1 + yuv2rgb_lut[(int(from[i].u)<<1) + 1 ] );
- to[i*6+1]= (byte)( from[i].y1 + yuv2rgb_lut[(int(from[i].v)<<1) + 512] + yuv2rgb_lut[int(from[i].u)<<1] );
- to[i*6+2]= (byte)( from[i].y1 + yuv2rgb_lut[(int(from[i].v)<<1) + 513] );
- to[i*6+3]= (byte)( from[i].y2 + yuv2rgb_lut[(int(from[i].u)<<1) + 1 ] );
- to[i*6+4]= (byte)( from[i].y2 + yuv2rgb_lut[(int(from[i].v)<<1) + 512] + yuv2rgb_lut[int(from[i].u)<<1] );
- to[i*6+5]= (byte)( from[i].y2 + yuv2rgb_lut[(int(from[i].v)<<1) + 513] );
- }
- }
- */
-
}else{
if(strangeRgb16){
asm("addl %%ecx, %%esi \n\t"
@@ -354,7 +206,6 @@ void mem2vid(byte *to, byte *from, int n
void close_hw(void){
__dpmi_regs r;
- __dpmi_paddr address;
close_meteor();
unlockall();
@@ -383,8 +234,6 @@ void sig_handler(int i){
void end_func(void){}
void init_hw(void){
- __dpmi_regs r;
- __dpmi_paddr address;
my_cs=_go32_my_cs();
my_ds=_go32_my_ds();
@@ -443,7 +292,6 @@ void set_start_disp(int x, int y){
}
void copy_vidbuffer(void){
- int i, j;
if(page_flip==0){
int p=0;
Modified: trunk/2010/2_hw_mem.cc
==============================================================================
--- trunk/2010/2_hw_mem.cc (original)
+++ trunk/2010/2_hw_mem.cc Wed Jul 4 09:06:09 2007
@@ -18,6 +18,24 @@
extern volatile VdsList *vdslist;
extern volatile MapList *maplist;
+bool checkAlign(void *p, int align){
+ if(int(p) & (align-1)) return false;
+ else return true;
+}
+
+void *newAlign(int size, int align){
+ int v= int(new char[size + align + 3]);
+ printf("anew %d\n", v);
+ int v2= ( (v+align-1+4) & ~(align-1) );
+ ((int*)v2)[-1]= v;
+ return (void*)v2;
+}
+
+void deleteAlign(void *v){
+ printf("adel %d\n", int(((char**)v)[-1]) );
+ delete [] ((char**)v)[-1];
+}
+
void locklin(void *start, void *end){
volatile LockList *llp, *llp2;
__dpmi_meminfo meminfo;
Modified: trunk/2010/2_hw_mem.h
==============================================================================
--- trunk/2010/2_hw_mem.h (original)
+++ trunk/2010/2_hw_mem.h Wed Jul 4 09:06:09 2007
@@ -35,6 +35,9 @@ struct AllocList{
volatile AllocList *next;
};
+bool checkAlign(void *p, int align);
+void *newAlign(int size, int align);
+void deleteAlign(void *v);
void locklin(void *, void *);
void unlocklin(void *, void *);
void lock(void *, void *);
Modified: trunk/2010/2_nag.cc
==============================================================================
--- trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cc Wed Jul 4 09:06:09 2007
@@ -12,6 +12,7 @@
#include "2_gfunc.h"
#include "2_mmx.h"
#include "2_nag_a.h"
+#include "2_hw_mem.h"
#include "2010.h"
#define dwnSmp 1
@@ -41,25 +42,6 @@ static int nagSize1;
static int nagSize2;
static int nagSizeAll;
-bool checkAlign(void *p, int align){ // FIX SHOULD BE SOMEWHERE ELSE
- if(int(p) & (align-1)) return false;
- else return true;
-}
-
-
-void *newAlign(int size, int align){ // FIX SHOULD BE SOMEWHERE ELSE
- int v= int(new char[size + align + 3]);
- printf("anew %d\n", v);
- int v2= ( (v+align-1+4) & ~(align-1) );
- ((int*)v2)[-1]= v;
- return (void*)v2;
-}
-
-void deleteAlign(void *v){ // FIX SHOULD BE SOMEWHERE ELSE
- printf("adel %d\n", int(((char**)v)[-1]) );
- delete [] ((char**)v)[-1];
-}
-
static inline void getPerm(const int key, int * const perm){
int keyNdx= (key >> 7) & 0xFF;
const int keyInc= ((key & 0x7F) << 1) + 1;
@@ -564,7 +546,8 @@ void nag_decrypt(void){
else vPhase=0;
- byte *lowDriftLinep= NULL;
+ byte *lowDriftLinep= actVid2MemBufp->b; // initalize in case nothing found else PF
+ int firstI=0;
for(int i=0; i<NAG_LINES; i++){
if(perm[i]>=32 && mabs(perm[i]-32 - i)<5){
const cleMod4= (i + vPhase ) & 3;
@@ -575,6 +558,7 @@ void nag_decrypt(void){
if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, type);
+ firstI= i;
break;
}
}
@@ -582,7 +566,8 @@ void nag_decrypt(void){
for(int clearLine=0 ;clearLine<NAG_LINES; clearLine++){
byte * const linep= actVid2MemBufp->b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
- if(perm[clearLine]>=32 && mabs(perm[clearLine]-32 - clearLine)<5){
+ if(perm[clearLine]>=32 && mabs(perm[clearLine]-32 - clearLine)<5
+ && firstI!=clearLine){
const cleMod4= (clearLine + vPhase ) & 3;
const encMod4= (perm[clearLine] + vPhase ) & 3;
const type= cleMod4 ^ encMod4;
@@ -624,7 +609,7 @@ void nag_decrypt(void){
actVid2MemBufp->b[p3*(vgax<<1)+i*20+101+j]=255;
}
}
-*/
+ */
delete [] bestCoeffs;
int enc2cleVec[max_x];
Modified: trunk/2010/makefile
==============================================================================
--- trunk/2010/makefile (original)
+++ trunk/2010/makefile Wed Jul 4 09:06:09 2007
@@ -31,7 +31,7 @@ clean: ; del $(O) 2010
2_crypt.o : 2_crypt.cc 2_all.h 2_crypt.h 2_71x6.h 2_vc.h 2_nag.h
2_vc.o : 2_vc.cc 2_all.h 2_vc.h 2_crypt.h 2_gfunc.h 2_vc_a.h
2_nag.o : 2_nag.cc 2_all.h 2_nag.h 2_crypt.h 2_gfunc.h 2_mmx.h 2_nag_a.h\
- 2010.h
+ 2010.h 2_hw_mem.h
2_hw_asm.o : 2_hw_asm.s
1
0
Author: michael
Date: Wed Jul 4 08:49:51 2007
New Revision: 48
Log:
version from 1998-07-08
Removed:
trunk/2010/2010.cur
trunk/2010/2_menu.h
trunk/2010/2_mfunc.h
trunk/2010/2_mouse.cc
trunk/2010/2_mouse.h
trunk/2010/2_move.cc
trunk/2010/2_move.h
trunk/2010/2_wins.cc
trunk/2010/2_wins.h
Modified:
trunk/2010/2010.cc
trunk/2010/2010.h
trunk/2010/2_71x6.cc
trunk/2010/2_71x6.h
trunk/2010/2_all.h
trunk/2010/2_crypt.cc
trunk/2010/2_file.cc
trunk/2010/2_gfunc.cc
trunk/2010/2_gfunc.h
trunk/2010/2_grafix.cc
trunk/2010/2_grafix.h
trunk/2010/2_hw.cc
trunk/2010/2_hw.h
trunk/2010/2_hw_asm.s
trunk/2010/2_hw_mem.cc
trunk/2010/2_hw_mem.h
trunk/2010/2_nag.cc
trunk/2010/2_vc.cc
trunk/2010/makefile
Modified: trunk/2010/2010.cc
==============================================================================
--- trunk/2010/2010.cc (original)
+++ trunk/2010/2010.cc Wed Jul 4 08:49:51 2007
@@ -8,47 +8,54 @@
#include <sys/nearptr.h>
#include <unistd.h>
#include <conio.h>
+#include <keys.h>
#include <crt0.h>
+#include <ctype.h>
#include <signal.h>
#include "2_all.h"
#include "2010.h"
#include "2_hw.h"
#include "2_hw_mem.h"
-#include "2_mouse.h"
#include "2_file.h"
-#include "2_menu.h"
#include "2_grafix.h"
+#include "2_crypt.h"
#include "2_71x6.h"
#include "2_nag.h"
- extern mouse_sprites cursor;
+ extern volatile bool oneField;
+ extern bool vSmoothState;
extern int g_mode;
- extern xxx dispbuf, *doubleBuff;
+ extern VID2MEMBUF *vid2MemBuf, *actVid2MemBufp;
extern byte *vidbuf;
- extern int mouse_x, mouse_y, mouse_b;
extern volatile int page_flip;
extern int vgax, vgay, xresvb, xresc, vb, mc;
extern int active_meteor;
- extern int me, mx, my;
extern int yuvmode;
- extern byte *mouse_buff[2];
- extern int single;
- extern int grabf;
- extern int mmx;
+ extern bool mmx;
extern int *best1;
extern BEST2 *best2;
extern u_short *keysList;
extern int *decoLine;
+ extern int bright, contr, satur;
+ extern int showCont;
+ extern CRYPTSTD cryptStd;
+ extern TVSTD TVStd;
+ extern bool iState;
+ extern bool helpState;
+
+ int maxBuf=2;
int _crt0_startup_flags = _CRT0_FLAG_NEARPTR | _CRT0_FLAG_NONMOVE_SBRK;
- int buttons=0, xpos=0, ypos=0, lxpos=0, lypos=0;
+ int grabf;
int fysize;
byte font[4096];
- int NoInt8=0;
int vid=0;
int bpp;
- char *yuv2rgb_lut;
+ int *yuv2RgbLut;
int edge_lut[256];
+ MENULEVEL menuLevel=mLNorm;
+ int infoPosY;
+ bool strangeRgb16= true; // commandLineOpt FIX
void printg_t(char *text){
close_hw();
@@ -80,18 +87,10 @@ int error(error_code e){
break;
case DPMI : printg_t("\nDPMI Error!\n");
break;
- case NoMouse : printg_t("\nNo Mouse?!\n");
- break;
- case MouseHand : printg_t("\nMouse Handler error!\n");
- break;
case NoFont : printg_t("\nNo 2010.Fnt?!\n");
break;
case Font : printg_t("\n2010.Fnt is damaged!\n");
break;
- case NoCursor : printg_t("\nNo 2010.Cur?!\n");
- break;
- case Cursor : printg_t("\n2010.Cur is damaged!\n");
- break;
case FileWrite : printg_t("\nFile-Write Error!\n");
break;
case MemAlloc : printg_t("\nMemory allocation error!\n");
@@ -111,7 +110,6 @@ int error(error_code e){
"options: -v n (Video-mode)\n"
" -m n (Meteor Card) in case there are more than 1 (:\n"
" -NoFlip (Disable Page-Fliping)\n"
- " -NoInt8 (Disable Int8-Handler)\n"
" -NoMMX (Disable MMX-Support)\n"
" -? / -h (This stuff)\n");
break;
@@ -132,8 +130,6 @@ void exitt(void){
int main(int argc, char **argv){
int NoFlip=0;
- int key;
- int i, j;
char buf[256];
__dpmi_regs r;
ModeInfoBlock *mib;
@@ -152,32 +148,30 @@ int main(int argc, char **argv){
signal(SIGSEGV, sig_handler);
signal(SIGTRAP, sig_handler);
- for(i=1;i<argc;i++){
+ for(int i=1;i<argc;i++){
if(stricmp(argv[i],"-v")==0){
- i++;
- sscanf(argv[i],"%d",&vid);
+ i++;
+ sscanf(argv[i],"%d",&vid);
}
else if(stricmp(argv[i],"-m")==0){
- i++;
- sscanf(argv[i],"%d",&active_meteor);
+ i++;
+ sscanf(argv[i],"%d",&active_meteor);
}
else if(stricmp(argv[i],"-NoFlip")==0){
- NoFlip=1;
+ NoFlip=1;
}
else if(stricmp(argv[i],"-NORGB")==0){
- yuvmode=2;
- }
- else if(stricmp(argv[i],"-Single")==0){
- single=1;
+ yuvmode=2;
}
- else if(stricmp(argv[i],"-NoInt8")==0){
- NoInt8=1;
+ else if(stricmp(argv[i],"-maxBuf")==0){
+ i++;
+ sscanf(argv[i],"%d",&maxBuf);
}
else if(stricmp(argv[i],"-NoMMX")==0){
- mmx=0;
+ mmx=0;
}
else if(stricmp(argv[i],"-?")==0 || stricmp(argv[i],"-H")==0){
- error(Help);
+ error(Help);
}
/* else if(stricmp(argv[i],"-v")==0){
i++;
@@ -198,31 +192,15 @@ int main(int argc, char **argv){
if((f=fopen("2010.fnt", "rb"))==NULL) error(NoFont);
fysize=fsize(f)>>8;
if(fysize==0) error(Font);
- for(i=0; i<256; i++) fread(font+(i<<4),1,fysize,f);
- fclose(f);
-
- printf("2010.Cur...\n");
- if((f=fopen("2010.cur", "rb"))==NULL) error(NoCursor);
- cursor.x=fgetc(f);
- cursor.y=fgetc(f);
- cursor.hotx=fgetc(f);
- cursor.hoty=fgetc(f);
- cursor.z=fgetc(f); //ERROR could be readed in struct direct
- if(cursor.x*cursor.y*cursor.z!=fsize(f)-5) error(Cursor);
- cursor.data=new byte[cursor.x*cursor.y*cursor.z];
- fread(cursor.data, 1, cursor.x*cursor.y*cursor.z, f);
+ for(int i=0; i<256; i++) fread(font+(i<<4),1,fysize,f);
fclose(f);
+
+ if(scan_pci_meteors() == 0) error(NoMeteor);
+// if(active_meteor>=i) active_meteor=0;
+// printf("%d Meteor(s) Detected!\n", i);
- mouse_buff[0]=new byte[cursor.x * cursor.y << 2];
- mouse_buff[1]=new byte[cursor.x * cursor.y << 2];
-
- i=scan_pci_meteors();
- if(i==0) error(NoMeteor);
- if(active_meteor>=i) active_meteor=0;
- printf("%d Meteor(s) Detected!\n", i);
-
- for(i=0; i<256; i++){
- j=i-2;
+ for(int i=0; i<256; i++){
+ int j=i-2;
if(j<0) j=0;
if(j>5 ) j=(j>>1) + 3;
@@ -233,23 +211,34 @@ int main(int argc, char **argv){
}
printf("Building YUV to RGB LookUp Tables!\n");
- yuv2rgb_lut=new char[256*4*2];
- for(i=0; i<256; i++){
- if(i>=128) j=i-256;
- else j=i;
- double d= double(j);
+ yuv2RgbLut=new int[128*4*2];
+ for(int i=0; i<128; i++){
+ int j;
+ if(i>=64) j=i-128;
+ else j=i;
+ double uv= double(j);
- yuv2rgb_lut[(i<<2) ]= short( d * ( 1.734375) * 0.5 );
- yuv2rgb_lut[(i<<2) + 1 ]= short( d * (-0.34375 ) * 0.5 )
- + is_pos(yuv2rgb_lut[(i<<2) ]);
- yuv2rgb_lut[(i<<2) + 2 ]= is_pos(yuv2rgb_lut[(i<<2) + 1 ]);
- yuv2rgb_lut[(i<<2) + 3 ]= 0;
+ int vr= int( uv * 1.375 ) & 0x1FF;
+ int vg= int(-uv * 0.703125 * 2) & 0x3FF;
+ int ug= int(-uv * 0.34375 * 2) & 0x3FF;
+ int ub= int( uv * 1.734375 ) & 0x1FF;
+ int yn= i;
+ int yg= i<<1;
- yuv2rgb_lut[(i<<2) + 1024]= 0;
- yuv2rgb_lut[(i<<2) + 1025]= short( d * (-0.703125) * 0.5 );
- yuv2rgb_lut[(i<<2) + 1026]= short( d * ( 1.375 ) * 0.5 )
- + is_pos(yuv2rgb_lut[(i<<2) + 1025]);
- yuv2rgb_lut[(i<<2) + 1027]= 0;
+// 565565
+// 655655
+
+// B R G
+// G B R
+
+ yuv2RgbLut[(i<<1) ]= ub +(ug<<21) ;
+ yuv2RgbLut[(i<<1) + 1 ]= ug +(ub<<11) ;
+ yuv2RgbLut[(i<<1) + 256 ]= yn +(yn<<11) ;
+ yuv2RgbLut[(i<<1) + 257 ]= yg ;
+ yuv2RgbLut[(i<<1) + 512 ]= (vr<<11) +(vg<<21) ;
+ yuv2RgbLut[(i<<1) + 513 ]= vg +(vr<<22);
+ yuv2RgbLut[(i<<1) + 768 ]= +(yg<<21) ;
+ yuv2RgbLut[(i<<1) + 769 ]= +(yn<<11) +(yn<<22);
}
if((vib=get_vesa_info())==0) error(NoVESA);
@@ -258,9 +247,9 @@ int main(int argc, char **argv){
printf("VESA %d.%d detected!\n", (vib->ver>>8) & 255, vib->ver & 255);
- for(i=256;i<512;i++){
+ for(int i=256;i<512;i++){
if((mib=get_mode_info(i))!=0){
- if((mib->ModeAttrib & (8+16+128))==8+16+128 && (mib->bpp==24 || mib->bpp==32)
+ if((mib->ModeAttrib & (8+16+128))==8+16+128 && mib->bpp==16
&& mib->model==6 && (mib->Xres & 0x3F8) == mib->Xres
&& (mib->Yres & 0x3FF) == mib->Yres){
// FIX ME 3FF statt 3F8 OK?
@@ -280,7 +269,7 @@ int main(int argc, char **argv){
if((mib=get_mode_info(vid))==0) error(VESA);
- if(!((mib->ModeAttrib & (8+16+128))==8+16+128 && (mib->bpp==24 || mib->bpp==32)
+ if(!((mib->ModeAttrib & (8+16+128))==8+16+128 && mib->bpp==16
&& mib->model==6 && (mib->Xres & 0x3F8) == mib->Xres
&& (mib->Yres & 0x3FE) == mib->Yres))
error(VESA);
@@ -288,10 +277,12 @@ int main(int argc, char **argv){
vgax=mib->Xres;
vgay=mib->Yres;
- if(yuvmode!=0) mc=1;
+/* if(yuvmode!=0) mc=1;
else mc=2;
if(yuvmode==2) mc2=1;
else mc2=2;
+*/
+ mc=mc2=1;
xresc=vgax<<mc;
bpp=mib->bpp;
vb=bpp>>3;
@@ -301,19 +292,16 @@ int main(int argc, char **argv){
printf("Allocating Physical Continous Buffers...\n");
- xxx *a;
- if(single==0)
- a= alloc_cont(vgax * vgay << mc2, 2);
+ vid2MemBuf=(VID2MEMBUF*)(int(&vid2MemBuf)+4);
+
+ if(vgay<370) // +100 for out of array (optimizations...)
+ allocCont(vid2MemBuf, (vgax * vgay << 2)+100, &maxBuf);
else
- a= alloc_cont(vgax * vgay << mc2, 1);
+ allocCont(vid2MemBuf, (vgax * vgay << 1)+100, &maxBuf);
- doubleBuff=(xxx*)(int(&doubleBuff)+4);
- dispbuf= // dispbuf just cheap copy
- doubleBuff[0]= a[0];
- doubleBuff[1]= a[1];
- doubleBuff[0].state=
- doubleBuff[1].state= Empty;
+ actVid2MemBufp= &vid2MemBuf[0];
+ int i;
if(page_flip==0) i= vgax * vgay * vb;
else i= vgax * vgay * vb << 1;
@@ -325,26 +313,127 @@ int main(int argc, char **argv){
if(r.x.ax!=0x4F) error(VESA);
g_mode=1;
- setmenu();
init_hw();
init_meteor();
- setmpos();
+ static int delay=0;
- key=0;
- while(key==0){
- draw_dispbuf();
-
- xpos=mouse_x;
- ypos=mouse_y;
- buttons=mouse_b;
-
- m_buttons();
-
- lxpos=xpos;
- lypos=ypos;
+ bool quit=false;
+ while(!quit){
- if(kbhit()) key=getkey();
- if(key=='g' || key=='G') key=0, grabf=1;
+ infoPosY=0;
+
+ decrypt();
+ showStuff();
+
+ if(grabf==1) grab(), grabf=0;
+
+ for(int k=0; k<delay*1000000; k++);
+
+ copy_vidbuffer();
+
+
+
+ if(kbhit()){
+ int key= getkey();
+
+ while(kbhit()) getkey();
+
+ switch(menuLevel){
+ case mLNorm : switch(key){
+ case 'g' :
+ case 'G' : key=0, grabf=1;
+ break;
+ case 'q' :
+ case 'Q' : quit=true;
+ break;
+ case K_F1 : bright--;
+ showCont=10;
+ if(bright<0) bright=0;
+ setCont();
+ break;
+ case K_F2 : bright++;
+ showCont=10;
+ if(bright>255) bright=255;
+ setCont();
+ break;
+ case K_F3 : contr--;
+ showCont=10;
+ if(contr<0) contr=0;
+ setCont();
+ break;
+ case K_F4 : contr++;
+ showCont=10;
+ if(contr>127) contr=127;
+ setCont();
+ break;
+ case K_F5 : satur--;
+ showCont=10;
+ if(satur<0) satur=0;
+ setCont();
+ break;
+ case K_F6 : satur++;
+ showCont=10;
+ if(satur>127) satur=127;
+ setCont();
+ break;
+ case 's' :
+ case 'S' : menuLevel=mLTVStd, helpState=false;
+ break;
+ case 'i' :
+ case 'I' : iState= !iState;
+ break;
+ case 'v' :
+ case 'V' : vSmoothState= !vSmoothState;
+ break;
+ case 'h' :
+ case 'H' : helpState= !helpState;
+ break;
+ case '1' : delay++;
+ break;
+ case '2' : delay--; if(delay<0) delay=0;
+ break;
+ }
+ break;
+ case mLTVStd : switch(key){
+ case '1' : TVStd= PAL;
+ cryptStd= nix;
+ if(yuvmode==1) yuvmode=0;
+ setStdScale();
+ contGrab();
+ break;
+ case '2' : TVStd= NTSC;
+ cryptStd= nix;
+ if(yuvmode==1) yuvmode=0;
+ setStdScale();
+ contGrab();
+ break;
+ case '3' : TVStd= SECAM;
+ cryptStd= nix;
+ if(yuvmode==1) yuvmode=0;
+ setStdScale();
+ contGrab();
+ break;
+ case '4' : TVStd= PAL;
+ cryptStd= vc;
+ if(yuvmode==0) yuvmode=1;
+ vSmoothState=false;
+ setStdScale();
+ contGrab();
+ break;
+ case '5' : TVStd= PAL;
+ cryptStd= nag;
+ if(yuvmode==0) yuvmode=1;
+ if(oneField && yuvmode==2) error(MemAlloc);
+ vSmoothState=false;
+ setStdScale();
+ contGrab();
+ break;
+ }
+ menuLevel=mLNorm;
+ break;
+
+ }
+ }
}
exit(0);
Modified: trunk/2010/2010.h
==============================================================================
--- trunk/2010/2010.h (original)
+++ trunk/2010/2010.h Wed Jul 4 08:49:51 2007
@@ -3,7 +3,7 @@
#ifndef n2010_h
#define n2010_h
-typedef enum{
+enum error_code{
CommLine,
Help,
NoVDS,
@@ -17,12 +17,8 @@ typedef enum{
FileRead,
FileWrite,
Map,
- NoMouse,
- MouseHand,
NoFont,
Font,
- NoCursor,
- Cursor,
MemAlloc,
FileMax,
Lock,
@@ -31,7 +27,12 @@ typedef enum{
KeyFile,
Align,
Nagra,
-} error_code;
+};
+
+enum MENULEVEL{
+ mLNorm,
+ mLTVStd,
+};
int error(error_code e);
void exitt(void);
Modified: trunk/2010/2_71x6.cc
==============================================================================
--- trunk/2010/2_71x6.cc (original)
+++ trunk/2010/2_71x6.cc Wed Jul 4 08:49:51 2007
@@ -32,16 +32,16 @@ extern volatile int addr_errors;
extern volatile int corr_errors;
extern volatile int frames, fields;
extern volatile u_char saa7196_buf[SAA7196_regs];
-extern volatile tv_form std;
-extern volatile crypt_form crypt;
-extern volatile int x_field, y_field, one_field;
+extern volatile TVSTD TVStd;
+extern volatile CRYPTSTD cryptStd;
+extern volatile int x_field, y_field;
extern volatile int xresc, yuvmode, mc;
-extern volatile xxx dispbuf, *doubleBuff;
+extern volatile VID2MEMBUF *vid2MemBuf, *actVid2MemBufp;
+extern volatile int grabVid2MemBuf, actVid2MemBuf;
extern volatile int stride;
+extern volatile bool oneField;
extern int wndx, wndy, outy;
extern int single;
-extern int init_menu;
-extern int nagra_mode;
extern int vgax, vgay;
@@ -205,32 +205,21 @@ void meteor_int_handler(void){
// asm("int $3\n\t");
- int grabbingOne=0;
- while(doubleBuff[grabbingOne].state != Grabbing && grabbingOne<2)
- grabbingOne++;
-
- int emptyOne=0;
- while(doubleBuff[emptyOne].state!=Empty && emptyOne<2) emptyOne++;
-
-
a_saa7116->capt_ctl_a|=0x0F30;
if( a_saa7116->ints_ctl.stat_odd == 1 && fields<11111
&& a_saa7116->ints_ctl.stat_even == 0 && fields>=2
&& a_saa7116->ints_ctl.stat_start == 0 ){
fields=0;
+ if( vid2MemBuf[ grabVid2MemBuf ].state == Grabbing )
+ vid2MemBuf[ grabVid2MemBuf ].state= Grabbed;
- if(grabbingOne!=2) doubleBuff[grabbingOne].state= Grabbed;
+ grabVid2MemBuf++;
+ if( grabVid2MemBuf >= vid2MemBuf[0].num ) grabVid2MemBuf= 0;
- if(emptyOne!=2){
- if(single==0){
- doubleBuff[emptyOne].state= Grabbing;
- }
- else{
- doubleBuff[0].state=
- doubleBuff[1].state= Grabbing;
- }
- grab_next(doubleBuff[emptyOne]);
+ if( vid2MemBuf[ grabVid2MemBuf ].state == Empty ){
+ vid2MemBuf[ grabVid2MemBuf ].state= Grabbing;
+ grab_next( vid2MemBuf[ grabVid2MemBuf ] );
}
else{
fields=11111;
@@ -239,18 +228,20 @@ void meteor_int_handler(void){
done_even: 1, done_odd: 1, VRSTN: 1, fifo_en: 1,
corr_even: 1, corr_odd: 1, aerr_even: 1, aerr_odd: 1,
res1: 0, corr_dis: 0, range_en: 1, res2: 0};
- if(grabbingOne!=2) grab_next(doubleBuff[grabbingOne^1]);
- else asm("int $3\n\t");
+ grab_next( vid2MemBuf[ grabVid2MemBuf ] );
}
}
- else if( a_saa7116->ints_ctl.stat_start==1 && fields>=11111 && emptyOne!=2){
+ else if( a_saa7116->ints_ctl.stat_start==1 && fields>=11111
+ && vid2MemBuf[ grabVid2MemBuf ].state == Empty ){
fields=0;
a_saa7116->capt_ctl=(capt_c){
cont_even: 1, cont_odd: 1, sing_even: 0, sing_odd: 0,
done_even: 1, done_odd: 1, VRSTN: 1, fifo_en: 1,
corr_even: 1, corr_odd: 1, aerr_even: 1, aerr_odd: 1,
res1: 0, corr_dis: 0, range_en: 1, res2: 0};
+ vid2MemBuf[ grabVid2MemBuf ].state= Grabbing;
}
+
a_saa7116->ints_ctl_a|=0x7;
}
@@ -286,27 +277,27 @@ void close_meteor(void){
metmode=0;
}
-void grab_next(xxx x){
+void grab_next(VID2MEMBUF v2mb){
saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
a_saa7116->dma_end.even=
a_saa7116->dma_end.odd= 0;
- if(one_field==1){
+ if(oneField){
a_saa7116->dma.even[0]= a_saa7116->dma.odd [0]=
a_saa7116->dma.even[1]= a_saa7116->dma.odd [1]=
- a_saa7116->dma.even[2]= a_saa7116->dma.odd [2]= x.phys;
+ a_saa7116->dma.even[2]= a_saa7116->dma.odd [2]= v2mb.phys;
}else{
a_saa7116->dma.even[0]=
a_saa7116->dma.even[1]=
- a_saa7116->dma.even[2]= x.phys;
+ a_saa7116->dma.even[2]= v2mb.phys;
a_saa7116->dma.odd [0]=
a_saa7116->dma.odd [1]=
- a_saa7116->dma.odd [2]= x.phys + xresc;
+ a_saa7116->dma.odd [2]= v2mb.phys + xresc;
}
a_saa7116->dma_end.even=
- a_saa7116->dma_end.odd= x.phys + xresc*outy - 1;
+ a_saa7116->dma_end.odd= v2mb.phys + xresc*outy - 1;
}
@@ -314,7 +305,7 @@ void meteor_int_handler_end(void){
}
-void setcont(void){
+void setCont(void){
write_saa7196(0x12, satur);/*7:0 Chrominance saturation control for VRAM port */
write_saa7196(0x13, contr);/*7:0 Luminance contract control for VRAM port */
@@ -322,34 +313,34 @@ void setcont(void){
}
-void setstd_scale(void){
+void setStdScale(void){
saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
int i;
- init_menu=1;
- if(yuvmode!=0) mc=1;
- else mc=2;
+/* if(yuvmode!=0) mc=1;
+ else mc=2;*/
+ mc=1;
xresc=vgax<<mc;
wndx=vgax;
- if(std==NTSC)
+ if(TVStd==NTSC)
y_field=240-scales_y+scalee_y, x_field=640-scales_x+scalee_x;
else
y_field=288-scales_y+scalee_y, x_field=768-scales_x+scalee_x;
- if(vgay-70 <= y_field && nagra_mode==0) one_field=1;
- else one_field=0;
+ if(vgay-70 <= y_field && cryptStd!=nag) oneField=true;
+ else oneField=false;
int yrest;
- if(nagra_mode==0 || vgay-70 > y_field) yrest= vgay;
+ if(cryptStd!=nag || vgay-70 > y_field) yrest= vgay;
else yrest= vgay << 1;
- if (one_field==0 && yrest>y_field*2){
+ if (!oneField && yrest>y_field*2){
outy= y_field*2;
wndx= int( double(wndx) * double(outy) / double(yrest) );
}
- else if(one_field==1 && yrest>y_field ){
+ else if(oneField && yrest>y_field ){
outy= y_field;
wndx= int( double(wndx) * double(outy) / double(yrest) );
}
@@ -370,36 +361,40 @@ void setstd_scale(void){
if(wndx > vgax ) vgax -=8;
if(outy > yrest) outy-=2;
- if(one_field==0) stride=(vgax + vgax - wndx)<<mc;
- else stride=(vgax - wndx)<<mc;
+ if(!oneField) stride=(vgax + vgax - wndx)<<mc;
+ else stride=(vgax - wndx)<<mc;
- if(nagra_mode==0 || vgay-70 > y_field) wndy= outy;
+ if(cryptStd!=nag || vgay-70 > y_field) wndy= outy;
else wndy= outy >> 1;
- if(std==SECAM) write_saa7196(0x0D, 0x85);
- else write_saa7196(0x0D, 0x84);
+ if(TVStd==SECAM) write_saa7196(0x0D, 0x85);
+ else write_saa7196(0x0D, 0x84);
/* 7 VTR/TV mode bit = 1->VTR mode
3 Realtime output mode select bit
2 HREF position select
1 Status byte select
0 SECAM mode bit */
- if(std==SECAM) write_saa7196(0x0F, 0xB0);
- else write_saa7196(0x0F, 0x90);
+ if(TVStd==SECAM) write_saa7196(0x0F, 0xB0);
+ else write_saa7196(0x0F, 0x90);
/* 7 Automatic Field detection
6 Field Select 0 = 50hz, 1=60hz
5 SECAM cross-colour reduction
4 Enable sync and clamping pulse
3:1 Luminance delay compensation */
if(yuvmode==0){
- if(one_field==1) write_saa7196(0x20, 0xF2);
- else write_saa7196(0x20, 0x92);
+/* if(oneField) write_saa7196(0x20, 0xF2);
+ else write_saa7196(0x20, 0x92);
a_saa7116->rt_mode_e=a_saa7116->rt_mode_o=
- (rt_mode){mode: 0x00, route: 0x393939};
+ (rt_mode){mode: 0x00, route: 0x393939};*/
+ if(oneField) write_saa7196(0x20, 0xF0);
+ else write_saa7196(0x20, 0x90);
+ a_saa7116->rt_mode_e=a_saa7116->rt_mode_o=
+ (rt_mode){mode: 0x01, route: 0xeeeeee};
}
else{
- if(one_field==1) write_saa7196(0x20, 0xF1);
- else write_saa7196(0x20, 0x91);
+ if(oneField) write_saa7196(0x20, 0xF1);
+ else write_saa7196(0x20, 0x91);
a_saa7116->rt_mode_e=a_saa7116->rt_mode_o=
(rt_mode){mode: 0x41, route: 0xeeeeee};
}
@@ -419,15 +414,15 @@ void setstd_scale(void){
4 [8] Horizontal start position of scaling win
3:2 [9:8] Pixel number per line on input
1:0 [9:8] Pixel number per line on output */
- if(one_field==1) write_saa7196(0x25, outy & 0xFF);
- else write_saa7196(0x25, (outy>>1) & 0xFF);
+ if(oneField) write_saa7196(0x25, outy & 0xFF);
+ else write_saa7196(0x25, (outy>>1) & 0xFF);
/* 7:0 [7:0] Line number per output field */
write_saa7196(0x26, y_field & 0xFF);
/* 7:0 [7:0] Line number per input field */
write_saa7196(0x27, scales_y);/* 7:0 [7:0] Vertical start of scaling window */
i=saa7196_buf[0x28] & 0xE0;
- if(one_field==1) write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>8));
- else write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>9));
+ if(oneField) write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>8));
+ else write_saa7196(0x28, i | ((y_field>>6) & 0x0C) | (outy>>9));
/* 7 Adaptive filter switch
6:5 Vertical luminance data processing
4 [8] Vertical start of scaling window
@@ -583,8 +578,8 @@ write_saa7196(0x10, 0x00); //BAK
1 Transparent data transfer
0 Extended formats enable bit */
- setcont();
- setstd_scale();
+ setCont();
+ setStdScale();
// for(int c=0; c<0x30; c++){
// printf("%X, %X, %X\n",c, read_saa7196(c), saa7196_buf[c]);
@@ -602,15 +597,13 @@ static void start_grab(void){
wait(wait_time);
- xxx grab_dispbuf= doubleBuff[0].phys==dispbuf.phys ?
- doubleBuff[1] : doubleBuff[0];
-
-
- if(one_field==1){
+ VID2MEMBUF grabVid2MemBufp= vid2MemBuf[ grabVid2MemBuf ];
+
+ if(oneField){
a_saa7116->dma.even[0]= a_saa7116->dma.odd [0]=
a_saa7116->dma.even[1]= a_saa7116->dma.odd [1]=
a_saa7116->dma.even[2]= a_saa7116->dma.odd [2]=
- grab_dispbuf.phys;
+ grabVid2MemBufp.phys;
a_saa7116->stride.even[0]=a_saa7116->stride.odd[0]=
a_saa7116->stride.even[1]=a_saa7116->stride.odd[1]=
a_saa7116->stride.even[2]=a_saa7116->stride.odd[2]=
@@ -619,18 +612,18 @@ static void start_grab(void){
a_saa7116->dma.even[0]=
a_saa7116->dma.even[1]=
a_saa7116->dma.even[2]=
- grab_dispbuf.phys;
+ grabVid2MemBufp.phys;
a_saa7116->dma.odd [0]=
a_saa7116->dma.odd [1]=
a_saa7116->dma.odd [2]=
- grab_dispbuf.phys + xresc;
+ grabVid2MemBufp.phys + xresc;
a_saa7116->stride.even[0]=a_saa7116->stride.odd[0]=
a_saa7116->stride.even[1]=a_saa7116->stride.odd[1]=
a_saa7116->stride.even[2]=a_saa7116->stride.odd[2]=
stride;
}
a_saa7116->dma_end.even=
- a_saa7116->dma_end.odd= grab_dispbuf.phys + xresc*outy - 1;
+ a_saa7116->dma_end.odd= grabVid2MemBufp.phys + xresc*outy - 1;
@@ -647,10 +640,10 @@ static void start_grab(void){
}
-void cont_grab(void){
+void contGrab(void){
saa7116 *a_saa7116=(saa7116*)meteors[active_meteor].saa7116;
- if(one_field==1){
+ if(oneField){
a_saa7116->stride.even[0]=a_saa7116->stride.odd[0]=
a_saa7116->stride.even[1]=a_saa7116->stride.odd[1]=
a_saa7116->stride.even[2]=a_saa7116->stride.odd[2]=
Modified: trunk/2010/2_71x6.h
==============================================================================
--- trunk/2010/2_71x6.h (original)
+++ trunk/2010/2_71x6.h Wed Jul 4 08:49:51 2007
@@ -9,17 +9,17 @@
#define SAA7196_regs 49
-typedef enum{
+enum TVSTD{
PAL,
NTSC,
SECAM,
-} tv_form;
+};
-typedef enum{
+enum CRYPTSTD{
nix,
vc,
nag,
-} crypt_form;
+};
/*
pci_cmd; //04-05
@@ -210,12 +210,12 @@ void init_meteor(void);
void close_meteor(void);
void meteor_int_handler(void);
void meteor_int_handler_end(void);
-void cont_grab(void);
+void contGrab(void);
void write_saa7196(u_char reg, u_char data);
u_char read_saa7196(u_char reg);
-void setcont(void);
-void setstd_scale(void);
-void grab_next(xxx x);
+void setCont(void);
+void setStdScale(void);
+void grab_next(VID2MEMBUF v2mb);
void grab_nix();
#endif
Modified: trunk/2010/2_all.h
==============================================================================
--- trunk/2010/2_all.h (original)
+++ trunk/2010/2_all.h Wed Jul 4 08:49:51 2007
@@ -21,6 +21,13 @@
#define dword unsigned long
#define ll long long
+
+struct COL{
+ long yuv;
+ short rgb16;
+};
+
+/*
struct s_yuv{
byte u, y1, v, y2;
};
@@ -38,40 +45,33 @@ union s_col{
s_yuv yuv;
u_long a;
};
+ */
-typedef enum{
+enum VID2MEMBUFSTATE{
Empty,
Working,
Grabbing,
Grabbed,
-} BUFFSTATE;
+};
-struct xxx{
- union{
- s_yuv *yuv;
- s_rgb *rgb;
- s_cl *cl;
- byte *b;
- };
+struct VID2MEMBUF{
+ byte *b;
int phys;
- BUFFSTATE state;
+ VID2MEMBUFSTATE state;
+ static int num;
};
class color{
public:
- s_col c;
+ COL col;
color(void) { };
- void init(byte y, byte u, byte v, byte yuv_mode)
- { if(yuv_mode!=0){
- c.yuv.y1=c.yuv.y2=y;
- c.yuv.u=u;
- c.yuv.v=v;
- }else{
- c.rgb.r= (byte)( y + 1.375 *v);
- c.rgb.g= (byte)( y - 0.703125*v - 0.34375*u);
- c.rgb.b= (byte)( y + 1.734375*u);
- }
- };
+ void init(byte y, byte u, byte v, byte yuv_mode){
+ col.yuv= u | (y<<8) | (v<<16) | (y<<24);
+ const int r= (int( y + 1.375 *v )>>3) & 0x1F;
+ const int g= (int( y - 0.703125*v - 0.34375*u )>>2) & 0x1F;
+ const int b= (int( y + 1.734375*u)>>3) & 0x1F;
+ col.rgb16= b | (g<<5) | (r<<11);
+ };
} ;
#endif
Modified: trunk/2010/2_crypt.cc
==============================================================================
--- trunk/2010/2_crypt.cc (original)
+++ trunk/2010/2_crypt.cc Wed Jul 4 08:49:51 2007
@@ -7,31 +7,33 @@
#include "2_nag.h"
#include "2_71x6.h"
-extern volatile tv_form std;
-extern volatile crypt_form crypt;
+extern volatile TVSTD TVStd;
+extern volatile CRYPTSTD cryptStd;
extern vgax, vgay, wndx, wndy, y_field, outy;
-extern xxx dispbuf;
+extern VID2MEMBUF *actVid2MemBufp;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
-extern int one_field, v_smooth, yuvmode;
+extern int yuvmode;
+extern volatile bool oneField;
extern int satur;
-static void vsmooth(void);
+static void vSmooth(void);
static void decomb(void);
+bool vSmoothState=true;
int show_points=0;
asm("__esp: .long 0\n\t");
void decrypt(void){
-// if( crypt == nag && satur!=0 ) decomb();
- decomb();
+ if( cryptStd == nag && satur!=0 ) decomb();
+// decomb();
- if(crypt==vc) vc_decrypt();
- else if(crypt==nag) nag_decrypt();
+ if(cryptStd==vc) vc_decrypt();
+ else if(cryptStd==nag) nag_decrypt();
- if(one_field==0 && v_smooth==1) vsmooth();
+ if(!oneField && vSmoothState) vSmooth();
}
@@ -44,9 +46,9 @@ static void decomb(void){
int amp[max_x];
const int outy1= outy>>1;
- const int stride=one_field ? (vgax<<1) : (vgax<<2);
- const int o=one_field ? 0 : 1;
- const int end=one_field ? outy : outy1;
+ const int stride=oneField ? (vgax<<1) : (vgax<<2);
+ const int o=oneField ? 0 : 1;
+ const int end=oneField ? outy : outy1;
const int segSize= end/segs;
int startp= 0;
@@ -61,7 +63,7 @@ static void decomb(void){
if(o) linep+=vgax<<1;
for(line=0; line<segSize; line++){
for(i=0; i<wndx; i+=2){
- j = char(dispbuf.b[linep + (i<<1) ]);
+ j = char(actVid2MemBufp->b[linep + (i<<1) ]);
j= (j + j) - temp[i];
temp[i] = j;
if(line & 1) amp[i]-=j;
@@ -79,21 +81,21 @@ static void decomb(void){
for(line=0; line<segSize; line++){
for(i=0; i<wndx; i++){
/*
- j = char(dispbuf.b[linep + (i<<1)]);
+ j = char(actVid2MemBufp->b[linep + (i<<1)]);
j=(j + j) - temp[i];
temp[i] = j;
if (j> 127) j= 127;
else if(j<-128) j=-128;
- dispbuf.b[linep + (i<<1)] = (char)(j);
+ actVid2MemBufp->b[linep + (i<<1)] = (char)(j);
*/
- j = char(dispbuf.b[linep + (i<<1)]);
+ j = char(actVid2MemBufp->b[linep + (i<<1)]);
j=(j + j) - temp[i];
if(j<temp[i]) j++;
if (j> 127) j= 127;
else if(j<-128) j=-128;
temp[i] = j;
- dispbuf.b[linep + (i<<1)] = (char)(j);
+ actVid2MemBufp->b[linep + (i<<1)] = (char)(j);
@@ -137,27 +139,27 @@ static void decomb(void){
" jnz 1b \n\t" // V 1
:
- : "D" (one_field==1 ? (vgax<<1) : (vgax<<2)), "S" (dispbuf.b),
+ : "D" (oneField ? (vgax<<1) : (vgax<<2)), "S" (actVid2MemBufp->b),
"d" (vgax * wndy>>1)
: "%eax", "%ebx", "%ecx", "%edx", "%esi");
*/
}
-static void vsmooth(void){
+static void vSmooth(void){
/*
for(int x=0; x < wndx; x++){
- dispbuf.rgb[x + y*vgax].r=( (dispbuf.rgb[x + y *vgax].r >> 1)
- + (dispbuf.rgb[x + (y+1)*vgax].r )
- + (dispbuf.rgb[x + (y+2)*vgax].r >> 1) ) >> 1;
- dispbuf.rgb[x + y*vgax].g=( (dispbuf.rgb[x + y *vgax].g >> 1)
- + (dispbuf.rgb[x + (y+1)*vgax].g )
- + (dispbuf.rgb[x + (y+2)*vgax].g >> 1) ) >> 1;
- dispbuf.rgb[x + y*vgax].b=( (dispbuf.rgb[x + y *vgax].b >> 1)
- + (dispbuf.rgb[x + (y+1)*vgax].b )
- + (dispbuf.rgb[x + (y+2)*vgax].b >> 1) ) >> 1;
+ ((s_rgb*)actVid2MemBufp.b)[x + y*vgax].r=( (((s_rgb*)actVid2MemBufp.b)[x + y *vgax].r >> 1)
+ + (((s_rgb*)actVid2MemBufp.b)[x + (y+1)*vgax].r )
+ + (((s_rgb*)actVid2MemBufp.b)[x + (y+2)*vgax].r >> 1) ) >> 1;
+ ((s_rgb*)actVid2MemBufp.b)[x + y*vgax].g=( (((s_rgb*)actVid2MemBufp.b)[x + y *vgax].g >> 1)
+ + (((s_rgb*)actVid2MemBufp.b)[x + (y+1)*vgax].g )
+ + (((s_rgb*)actVid2MemBufp.b)[x + (y+2)*vgax].g >> 1) ) >> 1;
+ ((s_rgb*)actVid2MemBufp.b)[x + y*vgax].b=( (((s_rgb*)actVid2MemBufp.b)[x + y *vgax].b >> 1)
+ + (((s_rgb*)actVid2MemBufp.b)[x + (y+1)*vgax].b )
+ + (((s_rgb*)actVid2MemBufp.b)[x + (y+2)*vgax].b >> 1) ) >> 1;
}
*/
-
+/*
if(yuvmode==0){
asm(//"int $3 \n\t"
"1: \n\t"
@@ -178,7 +180,7 @@ static void vsmooth(void){
"movl %%ebx, -4(%%esi ) \n\t" //U LINE
" jnz 1b \n\t" // V 1
:
- : "D" (vgax<<2), "S" (dispbuf.b),
+ : "D" (vgax<<2), "S" (actVid2MemBufp->b),
"c" (vgax * (wndy-2) )
: "%eax", "%ebx", "%ecx", "%esi");
@@ -211,10 +213,11 @@ static void vsmooth(void){
"movl %%ebx, -4(%%esi ) \n\t" //U LINE
" jnz 1b \n\t" // V 1
:
- : "D" (vgax<<1), "S" (dispbuf.b),
+ : "D" (vgax<<1), "S" (actVid2MemBufp->b),
"c" (vgax * (wndy-2) >> 1)
: "%eax", "%ebx", "%ecx", "%esi");
}
+ */
}
Modified: trunk/2010/2_file.cc
==============================================================================
--- trunk/2010/2_file.cc (original)
+++ trunk/2010/2_file.cc Wed Jul 4 08:49:51 2007
@@ -10,12 +10,13 @@
extern int vgax, vgay, wndx, wndy;
extern int fysize;
extern byte font[4096];
- extern xxx dispbuf;
+ extern VID2MEMBUF actVid2MemBufp;
extern int g_mode;
extern int yuvmode;
extern char *yuv2rgb_lut;
void grab(void){
+/*
int i, j;
FILE *fg;
char grab_name[16];
@@ -47,11 +48,11 @@ void grab(void){
fwrite(&bmpi, sizeof(bmpi), 1, fg);
for(i=wndy-1; i>=0; i--){
for(j=0; j<wndx; j++){
- if(yuvmode==0) fwrite((void*)(&dispbuf.rgb[j + i*vgax]), 1, 3, fg);
+ if(yuvmode==0) fwrite((void*)(&actVid2MemBufp.b[(j + i*vgax)<<2]), 1, 3, fg);
else {
if(j>=wndx>>1) break;
- mem2vid(fwbuf, dispbuf.yuv + j + (i*vgax>>1), 2, 32);
+ mem2vid(fwbuf, (s_yuv*)(&actVid2MemBufp.b[(j + (i*vgax>>1))<<2]), 2, 32);
fwbuf[3]=fwbuf[4];
fwbuf[4]=fwbuf[5];
@@ -63,7 +64,7 @@ void grab(void){
}
fclose(fg);
-
+ */
}
long fsize(FILE *f){
Modified: trunk/2010/2_gfunc.cc
==============================================================================
--- trunk/2010/2_gfunc.cc (original)
+++ trunk/2010/2_gfunc.cc Wed Jul 4 08:49:51 2007
@@ -6,13 +6,11 @@
#include "2_gfunc.h"
extern int vgax, vgay, xresc;
- extern int buttons, xpos, ypos, lxpos, lypos;
extern int fysize;
extern byte font[4096];
- extern int me, mx, my;
extern int g_mode;
extern int page_flip;
- extern xxx dispbuf;
+ extern VID2MEMBUF *actVid2MemBufp;
extern byte *vidbuf;
extern int yuvmode;
@@ -30,7 +28,7 @@ static inline void memsetd(void *pt, u_l
}
-void xcliped_gprint(int xp, int yp, const s_col c, int text){
+void xcliped_gprint(int xp, int yp, const COL c, int text){
int ix, iy;
int t3;
byte t1;
@@ -45,18 +43,19 @@ void xcliped_gprint(int xp, int yp, cons
for(; ix<8 && ix+xp<vgax; ix++){
if(((t1>>(7-ix)) & 1) == 1){
if(yuvmode!=0)
- dispbuf.yuv[(ix+t3)/2]=c.yuv; //FIX ME
- else
- dispbuf.rgb[(ix+t3)]=c.rgb;
+ ((long*) actVid2MemBufp->b)[(ix+t3)>>1]=c.yuv;
+ else
+ ((short*)actVid2MemBufp->b)[(ix+t3) ]=c.rgb16;
}
}
}
}
-void gprint(int xp, int yp, const s_col c, char *text){
+void gprint(int xp, int yp, const COL c, char *text){
static int clipyp, clipym;
int i, t=0, tp=0;
+
if(xp<0){
if(xp+int(strlen(text))*9+1<0) return;
i=(-xp+1)/9+1;
@@ -156,7 +155,7 @@ void gprint(int xp, int yp, const s_col
"popl %%ebp \n\t"
:
: "m" (fysize), "m"(xresc), "m" (&font), "m" (clipyp), "m" (clipym),
- "a" (c.yuv), "c" (text), "d" (((u_long)dispbuf.cl)+((xp+yp*vgax)<<1))
+ "a" (c.yuv), "c" (text), "d" (((u_long)actVid2MemBufp->b)+((xp+yp*vgax)<<1))
: "%ebx", "%ecx", "%edx", "%esi", "%edi");
}else{
asm(//"int $3\n\t"
@@ -175,47 +174,47 @@ void gprint(int xp, int yp, const s_col
"movb (%%ebx), %%bl \n\t"
"testb $128, %%ebx \n\t"
" jz 1f \n\t"
- "movl %%eax, (%%edx,%%esi)\n\t"
+ "movw %%ax, (%%edx,%%esi) \n\t"
"1: \n\t"
"testb $64, %%bl \n\t"
" jz 2f \n\t"
- "movl %%eax, 4(%%edx,%%esi)\n\t"
+ "movw %%ax, 2(%%edx,%%esi)\n\t"
"2: \n\t"
"testb $32, %%bl \n\t"
" jz 3f \n\t"
- "movl %%eax, 8(%%edx,%%esi)\n\t"
+ "movw %%ax, 4(%%edx,%%esi)\n\t"
"3: \n\t"
"testb $16, %%bl \n\t"
" jz 4f \n\t"
- "movl %%eax,12(%%edx,%%esi)\n\t"
+ "movw %%ax, 6(%%edx,%%esi)\n\t"
"4: \n\t"
"testb $8, %%bl \n\t"
" jz 5f \n\t"
- "movl %%eax,16(%%edx,%%esi)\n\t"
+ "movw %%ax, 8(%%edx,%%esi)\n\t"
"5: \n\t"
"testb $4, %%bl \n\t"
" jz 6f \n\t"
- "movl %%eax,20(%%edx,%%esi)\n\t"
+ "movw %%ax,10(%%edx,%%esi)\n\t"
"6: \n\t"
"testb $2, %%bl \n\t"
" jz 7f \n\t"
- "movl %%eax,24(%%edx,%%esi)\n\t"
+ "movw %%ax,12(%%edx,%%esi)\n\t"
"7: \n\t"
"testb $1, %%bl \n\t"
" jz 8f \n\t"
- "movl %%eax,28(%%edx,%%esi)\n\t"
+ "movw %%ax,14(%%edx,%%esi)\n\t"
"8: \n\t"
"incl %%edi \n\t"
"addl %1, %%esi \n\t"
"cmpl %3, %%edi \n\t"
" jb 0b \n\t"
- "addl $36, %%edx \n\t"
+ "addl $18, %%edx \n\t"
"incl %%ecx \n\t"
"jmp 10b \n\t"
"9: \n\t"
:
: "m" (fysize), "m"(xresc), "m" (&font), "m" (clipyp), "m" (clipym),
- "a" (c.rgb), "c" (text), "d" (((u_long)dispbuf.cl)+((xp+yp*vgax)<<2))
+ "a" (c.rgb16), "c" (text), "d" (((u_long)actVid2MemBufp->b)+((xp+yp*vgax)<<1))
: "%ebx", "%ecx", "%edx", "%esi", "%edi");
}
if(t!=0){
@@ -224,164 +223,3 @@ void gprint(int xp, int yp, const s_col
}
}
-void dot(const int x, const int y, const s_col c){
-
- if(x>0 && x<vgax && y>0 && y<vgay){
- if(yuvmode!=0){
- dispbuf.cl[y*vgax+x].lum=c.yuv.y1;
- dispbuf.cl[(y*vgax+x) | 1 ].chrom=c.yuv.v;
- dispbuf.cl[(y*vgax+x) & (~1)].chrom=c.yuv.u;
- }else{
- dispbuf.rgb[y*vgax+x].r=c.rgb.r;
- dispbuf.rgb[y*vgax+x].g=c.rgb.g;
- dispbuf.rgb[y*vgax+x].b=c.rgb.b;
- }
- }
-}
-/*
-void line(int x1, int y1, int x2, int y2, const s_yuv c){
- int t;
-
- if(x1<0){
- if(x2<0) return;
- else y1=(int)((float)(y1-y2)/((float)(x2-x1)+.1E-4)*(float)x2+y2), x1=0;
- }
- else if(x1>=vgax){
- if(x2>=vgax) return;
- else y1=(int)((float)(y1-y2)/((float)(x2-x1)+.1E-4)*(float)(x2-vgax+1)+y2), x1=vgax-1;
- }
- if(x2<0) y2=(int)((float)(y2-y1)/((float)(x1-x2)+.1E-4)*(float)x1+y1), x2=0;
- else if(x2>=vgax)
- y2=(int)((float)(y2-y1)/((float)(x1-x2)+.1E-4)*(float)(x1-vgax+1)+y1), x2=vgax-1;
-
-
- if(y1<0){
- if(y2<0) return;
- else x1=(int)((float)(x1-x2)/((float)(y2-y1)+.1E-4)*(float)y2+x2), y1=0;
- }
- else if(y1>=vgay){
- if(y2>=vgay) return;
- else
- x1=(int)((float)(x1-x2)/((float)(y2-y1)+.1E-4)*(float)(y2-vgay+1)+x2), y1=vgay-1;
- }
- if(y2<0) x2=(int)((float)(x2-x1)/((float)(y1-y2)+.1E-4)*(float)y1+x1), y2=0;
- else if(y2>=vgay)
- x2=(int)((float)(x2-x1)/((float)(y1-y2)+.1E-4)*(float)(y1-vgay+1)+x1), y2=vgay-1;
-
- if(x1==x2 && y1==y2) return;
-
- if(mabs(x1-x2)>mabs(y1-y2)){
- register int fl,delta;
- if(x1>x2) t=x1,x1=x2,x2=t,t=y1,y1=y2,y2=t,t=1;
- delta=(y1-y2)*(1<<16)/(x1-x2);
-
- for(fl=y1<<16; x1<x2; x1++){
- fl+=delta;
- dispbuf.yuv[(x1+(fl>>16)*vgax)>>1]=c; //FIX ME
- }
- }else {
- register int fl,delta;
- if(y1>y2) t=y1,y1=y2,y2=t,t=x1,x1=x2,x2=t,t=1;
- delta=(x1-x2)*(1<<10)/(y1-y2) + (vgax<<10);
- fl=(x1+y1*vgax)<<10;
- y2-=y1;
- for(; y2!=0; y2--){
- fl+=delta;
- dispbuf.yuv[(fl>>10)>>1]=c; //FIX ME
- }
-
- }
-}
- */
-
-void hline(register int x1, int y1, register int x2, const s_yuv c){
- int t;
- u_long *a=(u_long *)(&c);
-
- if(x1>x2) t=x1, x1=x2, x2=t;
-
- if(x1<0){
- x1=0;
- if(x2<0) return;
- }
- if(x2>=vgax){
- x2=vgax-1;
- if(x1>=vgax) return;
- }
- if(y1<0 || y1>=vgay) return;
-
- x1+=y1*vgax;
- memset(dispbuf.cl + x1, *a, ((x2+y1*vgax)-x1+1)<<1); //FIX HLINE
-}
-/*
-void vline(const int x1, register int y1, register int y2, const s_yuv c){
- int t;
-
- if(y1>y2) t=y1, y1=y2, y2=t;
-
- if(y1<0){
- y1=0;
- if(y2<0) return;
- }
- if(y2>=vgay){
- y2=vgay-1;
- if(y1>=vgay) return;
- }
- if(x1<0 || x1>=vgax) return;
-
- y1=y1*vgax+x1;
- y2=(y2-2)*vgax+x1;
- for(; y1<y2; y1+=vgax){
- dispbuf[y1]=c;
- dispbuf[y1+=vgax]=c;
- dispbuf[y1+=vgax]=c;
- dispbuf[y1+=vgax]=c;
- }
- y2+=vgax<<1;
- for(; y1<y2; y1+=vgax){
- dispbuf[y1]=c;
- }
-}
-*/
-
-void rect(int x1, int y1, int x2, int y2, const s_col c){
- u_long *a=(u_long *)(&c.yuv);
- int t;
-/*
- if(x1>x2) t=x1,x1=x2,x2=t;
- if(y1>y2) t=y1,y1=y2,y2=t; */
-
-
- if(x1<0){
- if(x2<0) return;
- x1=0;
- }
- else if(x2>=vgax){
- if(x1>=vgax) return;
- x2=vgax-1;
- }
- if(y1<0){
- if(y2<0) return;
- y1=0;
- }
- else if(y2>=vgay){
- if(y1>=vgay)
- y2=vgay-1;
- }
- y1*=xresc;
- y2*=xresc;
-
- t=x1 & (~1);
- if(yuvmode!=0){
- for(; y1<=y2; y1+=xresc){
- if(x1 & 1 == 1) {}
- memsetd((byte*)dispbuf.cl +y1 +(t<<1), *a, ((x2-x1)>>1));
- if(x2 & 1 == 1) {}
- }
- }else{
- for(; y1<=y2; y1+=xresc){
- memsetd((byte*)dispbuf.cl +y1 +(x1<<2), *a, x2-x1);
- }
- }
-
-}
Modified: trunk/2010/2_gfunc.h
==============================================================================
--- trunk/2010/2_gfunc.h (original)
+++ trunk/2010/2_gfunc.h Wed Jul 4 08:49:51 2007
@@ -2,15 +2,7 @@
#ifndef n2_gfunc_h
#define n2_gfunc_h
-void gprint(int xp, int yp, const s_col c, char *text);
-void xcliped_gprint(int xp, int yp, const s_col c, int text);
-void dot(const int x, const int y, const s_col c);
-void line(int x1, int y1, int x2, int y2, const s_col c);
-
-void hline(register int x1, int y1, register int x2, const s_col c);
-
-void vline(const int x1, register int y1, register int y2, const s_col c);
-
-void rect(int x1, int y1, int x2, int y2, const s_col c);
+void gprint(int xp, int yp, const COL c, char *text);
+void xcliped_gprint(int xp, int yp, const COL c, int text);
#endif
Modified: trunk/2010/2_grafix.cc
==============================================================================
--- trunk/2010/2_grafix.cc (original)
+++ trunk/2010/2_grafix.cc Wed Jul 4 08:49:51 2007
@@ -5,79 +5,85 @@
#include <string.h>
#include "2_all.h"
#include "2_grafix.h"
+#include "2010.h"
#include "2_gfunc.h"
#include "2_hw.h"
-#include "2_menu.h"
#include "2_file.h"
-#include "2_wins.h"
#include "2_crypt.h"
extern int xres, yres, xresc;
- extern int buttons, xpos, ypos, lxpos, lypos;
extern int fysize;
extern byte font[4096];
- extern int me, mx, my;
extern int grabf;
- extern xxx dispbuf, grab_dispbuf;
- extern menu menu_main[];
extern int yuvmode;
extern volatile int addr_errors, corr_errors;
extern int single;
- int infox, infoy;
- int istate=1;
- int conty_b, conty_s, conty_c, contx_b, contx_s, contx_c;
- int cstate=1;
+ extern int bright, contr, satur;
+ extern MENULEVEL menuLevel;
+ extern int infoPosY;
- long T1,T2,T3;
+ bool helpState=true;
+ bool iState=false;
+ int showCont=0;
-void draw_dispbuf(void){
+void showStuff(void){
char textbuf[256];
color c;
- T2=uclock();
-
- decrypt();
-
- if(istate==1){
- T1=uclock();
- sprintf(textbuf,"%f Decrypt", (float)(T1-T2)/UCLOCKS_PER_SEC);
- c.init(255, 0, 0, yuvmode);
- gprint(30, 30, c.c, textbuf);
-
- sprintf(textbuf,"%f Fps",1/((float)(T1-T3)/UCLOCKS_PER_SEC));
- c.init(255, 0, 0, yuvmode);
- gprint(50, 50, c.c, textbuf);
-
- sprintf(textbuf,"%d Corrupted Fields", corr_errors);
- c.init(255, 0, 0, yuvmode);
- gprint(60, 60, c.c, textbuf);
+ if(helpState){
+ char text[5][256]={ "F1/F2 Brightness s TVStandart",
+ "F3/F4 Contrast i debugInfo",
+ "F5/F6 Saturation h Help",
+ "g ScreenShot q Quit",
+ "v smoothIterlace"};
+ for(int i=0; i<5; i++){
+ c.init(255, 0, 0, yuvmode);
+ gprint(10, infoPosY+=10, c.col, text[i]);
+ }
+ infoPosY+=5;
+ }
- sprintf(textbuf,"%d Address error's", addr_errors);
+ if(showCont!=0){
+ showCont--;
+ sprintf(textbuf,"%3.1f%% brightness", bright/2.55);
c.init(255, 0, 0, yuvmode);
- gprint(70, 70, c.c, textbuf);
- T3=T2=T1;
+ gprint(10, infoPosY+=10, c.col, textbuf);
+ sprintf(textbuf,"%3.1f%% contrast" , contr/1.27);
+ gprint(10, infoPosY+=10, c.col, textbuf);
+ sprintf(textbuf,"%3.1f%% saturation", satur/1.27);
+ gprint(10, infoPosY+=10, c.col, textbuf);
+ infoPosY+=5;
}
- if(grabf==1) grab(), grabf=0;
-
- if(me!=0) disp_menu(menu_main, mx+4, my+4, 0); // +4 for mistakely menu hit
-
- if(me==0 && istate==1){
- // print info
-
+ if(menuLevel==mLTVStd){
+ char text[3][256]={ "1. PAL 4. VideoCrypt (PAL)",
+ "2. NTSC 5. NagraVision (PAL/SECAM)",
+ "3. SECAM"};
+ for(int i=0; i<3; i++){
+ c.init(255, 0, 0, yuvmode);
+ gprint(10, infoPosY+=10, c.col, text[i]);
+ }
+ infoPosY+=5;
}
- if(cstate==1) drawc();
+ static long T2=uclock();
+ long T1=uclock();
- if(istate==1){
- T2=uclock();
- sprintf(textbuf,"%f Misc",(float)(T2-T1)/UCLOCKS_PER_SEC);
+ if(iState){
+ sprintf(textbuf,"%2.2f Fps",1/((float)(T1-T2)/UCLOCKS_PER_SEC));
c.init(255, 0, 0, yuvmode);
- gprint(40, 40, c.c, textbuf);
+ gprint(10, infoPosY+=10, c.col, textbuf);
+
+ sprintf(textbuf,"%d Corrupted Fields", corr_errors);
+ gprint(10, infoPosY+=10, c.col, textbuf);
+
+ sprintf(textbuf,"%d Address error's", addr_errors);
+ gprint(10, infoPosY+=10, c.col, textbuf);
+ infoPosY+=5;
}
- copy_vidbuffer();
+ T2=T1;
}
Modified: trunk/2010/2_grafix.h
==============================================================================
--- trunk/2010/2_grafix.h (original)
+++ trunk/2010/2_grafix.h Wed Jul 4 08:49:51 2007
@@ -2,6 +2,6 @@
#ifndef n2_grafix_h
#define n2_grafix_h
-void draw_dispbuf(void);
+void showStuff(void);
#endif
Modified: trunk/2010/2_hw.cc
==============================================================================
--- trunk/2010/2_hw.cc (original)
+++ trunk/2010/2_hw.cc Wed Jul 4 08:49:51 2007
@@ -14,59 +14,171 @@
#include "2_hw_asm.h"
#include "2_hw_mem.h"
#include "2_71x6.h"
-#include "2_mouse.h"
#include "2_mmx.h"
#include "2010.h"
- extern int NoInt8;
-
extern byte lock_start, lock_end;
- extern dword old_int8_vect_offset;
- extern word old_int8_vect_selector;
- extern byte int8_handler;
extern int bpp;
- extern volatile long timer_count;
- extern volatile __dpmi_regs mouse_regs;
- extern volatile int mouse_handler_enable;
extern volatile int page_flip;
extern volatile int yuvmode;
extern volatile AllocList *alloclist;
- extern volatile int fresh_cursor;
- extern volatile xxx dispbuf, *doubleBuff;
+ extern volatile VID2MEMBUF *vid2MemBuf, *actVid2MemBufp;
+ extern volatile int grabVid2MemBuf, actVid2MemBuf;
extern volatile int one_field;
extern volatile int active_meteor;
extern volatile meteor meteors[8];
extern volatile int fields;
- extern int mouse_x, mouse_y, mouse_b;
- extern int mouse_lx, mouse_ly;
extern byte *vidbuf;
- extern int vgax, vgay, xresc, xresvb, vb, mc;
- extern mouse_sprites cursor;
- extern char *yuv2rgb_lut;
- extern byte *mouse_buff[2];
- extern int amb; //active_mouse_buffer
+ extern int vgax, vgay, xresc, xresvb, vb, mc, wndy, wndx;
+ extern int *yuv2RgbLut;
extern int single;
extern int in_int;
- extern int mouse_tim;
- extern int mouse_ltim;
extern volatile int frames;
+ extern bool strangeRgb16;
int g_mode=0;
int m_mode=0;
extern u_short my_cs, my_ds;
asm("__esp: .long 0\n\t");
- static inline void setdot(int xx, int yy, s_col c);
- static inline s_col getdot(int xx, int yy);
+ asm("__temp1: .long 0\n\t");
-void mem2vid(byte *to, s_yuv *from, int num, int bpp){
+ int VID2MEMBUF::num;
+
+void mem2vid(byte *to, byte *from, int num, int bpp){
int i;
if(yuvmode!=0){
+ asm(//"int $3 \n\t"
+ "pushl %%ebp \n\t"
+ "movl %%eax, %%ebp \n\t"
+ "movl %%esp, (__esp) \n\t"
+
+ "addl %%ecx, %%esi \n\t"
+ "addl %%ecx, %%edi \n\t"
+ "negl %%ecx \n\t"
+ "movl (%%esi, %%ecx), %%eax \n\t"
+ "movl %%esi, (__temp1) \n\t"
+
+ "1: \n\t"
+ "movl %%eax, %%edx \n\t"
+ "andl $0xFE, %%eax \n\t"
+
+ "movl %%edx, %%ebp \n\t"
+ "andl $0xFE00, %%edx \n\t"
+
+ "shrl $8, %%edx \n\t"
+ "movl (%%ebx, %%eax, 4), %%esp \n\t"
+
+ "shrl $16, %%ebp \n\t"
+ "movl 4(%%ebx, %%eax, 4), %%eax \n\t"
+
+ "movl 1024(%%ebx, %%edx, 4), %%esi \n\t"
+ "movl 1028(%%ebx, %%edx, 4), %%edx \n\t"
+
+ "addl %%esi, %%esp \n\t"
+ "addl %%edx, %%eax \n\t"
+
+ "movl %%ebp, %%edx \n\t"
+ "andl $0xFE, %%ebp \n\t"
+
+ "shrl $8, %%edx \n\t"
+ "andl $0x7FEFF9FF, %%esp \n\t"
+
+ "andl $0xFE, %%edx \n\t"
+ "movl 2048(%%ebx, %%ebp, 4), %%esi \n\t"
+
+ "andl $0x7FCFFBFF, %%eax \n\t"
+ "movl 2052(%%ebx, %%ebp, 4), %%ebp \n\t"
+
+ "addl %%esi, %%esp \n\t"
+ "addl %%ebp, %%eax \n\t"
+
+ "andl $0x7FEFF9FF, %%esp \n\t"
+ "movl 3072(%%ebx, %%edx, 4), %%esi \n\t"
+
+ "andl $0x7FCFFBFF, %%eax \n\t"
+ "movl 3076(%%ebx, %%edx, 4), %%edx \n\t"
+
+ "addl %%esi, %%esp \n\t"
+ "addl %%edx, %%eax \n\t"
+
+ "test $0x600C0180, %%esp \n\t"
+ " jz 2f \n\t"
+
+ "movl %%esp, %%esi \n\t"
+ "movl %%esp, %%edx \n\t"
+
+ "shrl $7, %%esi \n\t"
+ "andl $0x40080100, %%edx \n\t"
+
+ "shrl $8, %%edx \n\t"
+ "andl $0x00400801, %%esi \n\t"
+
+ "addl $0xEFDFFBFF, %%edx \n\t"
+ "addl $0xEFDFFBFF, %%esi \n\t"
+
+ "xorl $0x10200400, %%edx \n\t"
+ "xorl $0xEFDFFBFF, %%esi \n\t"
+
+ "orl %%esi, %%esp \n\t"
+
+ "andl %%edx, %%esp \n\t"
+
+ "2: \n\t"
+ "test $0x600C0300, %%eax \n\t"
+ " jz 3f \n\t"
+
+ "movl %%eax, %%esi \n\t"
+ "movl %%eax, %%edx \n\t"
+
+ "shrl $8, %%esi \n\t"
+ "andl $0x40080200, %%edx \n\t"
+
+ "shrl $9, %%edx \n\t"
+ "andl $0x00200401, %%esi \n\t"
+
+ "addl $0xEFEFFDFF, %%edx \n\t"
+ "addl $0xEFEFFDFF, %%esi \n\t"
+
+ "xorl $0x10100200, %%edx \n\t"
+ "xorl $0xEFEFFDFF, %%esi \n\t"
+
+ "orl %%esi, %%eax \n\t"
+
+ "andl %%edx, %%eax \n\t"
+
+ "3: \n\t"
+
+ "shrl $2, %%esp \n\t"
+ "movl (__temp1), %%esi \n\t"
+
+ "shll $3, %%eax \n\t"
+ "andl $0x07E0F81F, %%esp \n\t"
+
+ "andl $0xF81F07E0, %%eax \n\t"
+
+ "orl %%eax, %%esp \n\t"
+
+ "movl %%esp, (%%edi, %%ecx) \n\t"
+
+ "movl 4(%%esi, %%ecx), %%eax \n\t"
+ "addl $4, %%ecx \n\t"
+
+ "jnc 1b \n\t"
+
+ "movl (__esp), %%esp \n\t"
+ "popl %%ebp \n\t"
+ :
+ : "b" (yuv2RgbLut), "S" (from), "D" (to), "c" (num<<1)
+ : "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
+
+
+
+/*
num>>=1;
if(bpp==32){
-/*
U Y1 V Y2
esi from
@@ -77,7 +189,6 @@ void mem2vid(byte *to, s_yuv *from, int
ebx Y1 Y1 Y1 Y1 + LUT[ U ] + LUT[ V ]
edx Y2 Y2 Y2 Y2 + LUT[ U ] + LUT[ V ]
esp
- */
asm(//"int $3 \n\t"
"pushl %%ebp \n\t"
"movl %%eax, %%ebp \n\t"
@@ -197,7 +308,6 @@ void mem2vid(byte *to, s_yuv *from, int
-
}
else{
for(i=0; i<num; i++){
@@ -209,160 +319,43 @@ void mem2vid(byte *to, s_yuv *from, int
to[i*6+5]= (byte)( from[i].y2 + yuv2rgb_lut[(int(from[i].v)<<1) + 513] );
}
}
+ */
+
}else{
- if(bpp==32) memcpy(to, from, num<<2);
- else{
- if(num>>2==0) return;
- asm("//int $3 \n\t"
- "0: \n\t"
- "movl (%%esi), %%eax \n\t" // U
- "movl 4(%%esi), %%edx \n\t" // V 1
- "rorl $8, %%edx \n\t" // UV 1
- "movl %%edx, %%ebx \n\t" // U
- "andl $0xff000000, %%edx \n\t" // V 1
- "orl %%edx, %%eax \n\t" // U
- "andl $0x0000ffff, %%ebx \n\t" // V 1
+ if(strangeRgb16){
+ asm("addl %%ecx, %%esi \n\t"
+ "addl %%ecx, %%edi \n\t"
+ "negl %%ecx \n\t"
+
+ "movl (%%esi, %%ecx), %%eax \n\t"
+ "1: \n\t"
+ " movl %%eax, %%ebx \n\t"
+ " andl $0xFFE0FFE0, %%eax \n\t"
- "movl %%eax, (%%edi) \n\t" // U
- "movl 8(%%esi), %%edx \n\t" // V 1
- "rorl $16, %%edx \n\t" // UV 1
- "movl %%edx, %%eax \n\t" // U
- "andl $0xffff0000, %%edx \n\t" // V 1
- "orl %%edx, %%ebx \n\t" // U
- "andl $0x000000ff, %%eax \n\t" // V 1
+ " shll $1, %%eax \n\t"
+ " andl $0x001F001F, %%ebx \n\t"
- "movl %%ebx, 4(%%edi) \n\t" // U
- "movl 12(%%esi), %%edx \n\t" // V 1
- "rorl $24, %%edx \n\t" // UV 1
- "orl %%edx, %%eax \n\t" // U
+ " orl %%eax, %%ebx \n\t"
+ " movl 4(%%esi, %%ecx), %%eax \n\t"
- "addl $16, %%esi \n\t" // V 1
- "movl %%eax, 8(%%edi) \n\t" // U
- "addl $12, %%edi \n\t" // V 1
- "decl %%ecx \n\t" // U
- " jnz 0b \n\t" // V 1
+ " movl %%ebx, (%%edi, %%ecx) \n\t"
+ " addl $4, %%ecx \n\t"
+
+ "jnc 1b \n\t"
:
- : "S" (from), "D" (to), "c" (num>>2)
+ : "d" (vgax<<1), "S" (from), "D" (to), "c" (num<<1)
: "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi");
-
}
- }
-}
-
-void disabled_call_mouse_handler(void){
-
- if(mouse_handler_enable==0) return;
- mouse_handler_enable=0;
- mouse_regs.x.ax=0;
- mouse_handler();
- mouse_regs.x.ax=1;
- mouse_handler_enable=1;
-}
-
-void mouse_handler(void){
- int i, j, k, l;
- color c;
-
- if((mouse_handler_enable==0 && mouse_regs.x.ax!=0) || in_int!=0) return;
- in_int++;
-
- mouse_b=mouse_regs.x.bx;
- mouse_x=mouse_regs.x.cx;
- mouse_y=mouse_regs.x.dx;
-
- if(mouse_x>=vgax) mouse_x=vgax-1;
- if(mouse_y>=vgay) mouse_y=vgay-1;
-
- for(j=0; j < cursor.y && mouse_y + j - cursor.hoty < vgay; j++){
- if(j + mouse_y - cursor.hoty>=0){
- for(i=0 ; i < cursor.x && mouse_x + i - cursor.hotx < vgax; i++){
- if( i + mouse_x - cursor.hotx>=0){
- k=cursor.data[i + (j + mouse_tim*cursor.y)*cursor.x];
-
- int d_x=mouse_x - mouse_lx + i;
- int d_y=mouse_y - mouse_ly + j;
- if( d_x >= 0 && d_x < cursor.x
- && d_y >= 0 && d_y < cursor.y && fresh_cursor==0)
- c.c.a=*(u_long *)(mouse_buff[amb] + (d_x + d_y*cursor.x)*vb);
- else
- c.c=getdot(mouse_x + i - cursor.hotx, mouse_y + j - cursor.hoty);
-
- *(u_long *)(mouse_buff[amb^1] + (i + j*cursor.x)*vb)=c.c.a;
-
- if(k!=255)
- c.c.rgb.r= c.c.rgb.g= c.c.rgb.b= k<<3;
-
- setdot(mouse_x + i - cursor.hotx, mouse_y + j - cursor.hoty, c.c);
-
- }
- }
- }
- }
-
- for(j=0; j < cursor.y && mouse_ly + j - cursor.hoty < vgay; j++){
- if(j + mouse_ly - cursor.hoty>=0){
- for(i=0; i < cursor.x && mouse_lx + i - cursor.hotx < vgax; i++){
- if( i + mouse_lx - cursor.hotx>=0){
- k=i - mouse_x + mouse_lx;
- l=j - mouse_y + mouse_ly;
- if( k<0 || k>=cursor.x
- || l<0 || l>=cursor.y){
-
- if(cursor.data[i + (j + mouse_ltim*cursor.y)*cursor.x]!=255
- && fresh_cursor==0){
- c.c.a=*(u_long *)(mouse_buff[amb] + (i + j*cursor.x)*vb);
- setdot(mouse_lx + i - cursor.hotx, mouse_ly + j - cursor.hoty, c.c);
- }
- }
- }
- }
+ else{
+ memcpy(to, from, num<<1);
}
}
-
- amb^=1;
- fresh_cursor=0;
- mouse_lx=mouse_x;
- mouse_ly=mouse_y;
- mouse_ltim=mouse_tim;
- mouse_tim=timer_count % cursor.z;
-
-
- in_int--;
-}
-
-static inline void setdot(int xx, int yy, s_col c){
- int ppvb=xx*vb + yy*xresvb;
-
- if(page_flip==1) ppvb+=xresvb*vgay;
-
- vidbuf[ppvb ]=c.rgb.b;
- vidbuf[ppvb+1]=c.rgb.g;
- vidbuf[ppvb+2]=c.rgb.r;
-}
-
-static inline s_col getdot(int xx, int yy){
- int ppvb=xx*vb + yy*xresvb;
-
- if(page_flip==1) ppvb+=xresvb*vgay;
-
- return *(s_col* )(vidbuf + ppvb);;
}
void close_hw(void){
__dpmi_regs r;
__dpmi_paddr address;
- if(m_mode==1){
- r.x.ax=0;
- __dpmi_int(0x33, &r); //reset mouse
-
- address.offset32=old_int8_vect_offset;
- address.selector=old_int8_vect_selector;
- __dpmi_set_protected_mode_interrupt_vector(8, &address);
-
- }
- m_mode=0;
-
close_meteor();
unlockall();
unmapall();
@@ -391,71 +384,17 @@ void end_func(void){}
void init_hw(void){
__dpmi_regs r;
- static _go32_dpmi_seginfo mouse_info;
__dpmi_paddr address;
my_cs=_go32_my_cs();
my_ds=_go32_my_ds();
- r.x.ax=0;
- __dpmi_int(0x33, &r); //reset mouse
- if(r.x.ax==0) error(NoMouse);
-
- r.x.ax=7;
- r.x.cx=0;
- r.x.dx=vgax;
- __dpmi_int(0x33, &r); //set horizontal cursor range
-
- r.x.ax=8;
- r.x.cx=0;
- r.x.dx=vgay;
- __dpmi_int(0x33, &r); //set vertical cursor range
-
- r.x.ax=4;
- r.x.cx=0;
- r.x.dx=0;
- __dpmi_int(0x33, &r); //set mouse pos
-
- // set Mouse Handler
-
save_selectors();
- if(__dpmi_get_protected_mode_interrupt_vector(8, &address)!=0) error(DPMI);
- old_int8_vect_offset =address.offset32;
- old_int8_vect_selector=address.selector;
-
- m_mode=1;
-
-
lock(&lock_start, &lock_end);
- lock(&disabled_call_mouse_handler, &end_func);
-
- lock(cursor.data , cursor.data + cursor.x * cursor.y * cursor.z);
-
- lock(mouse_buff[0] , mouse_buff[0] + (cursor.x * cursor.y<<2) );
- lock(mouse_buff[1] , mouse_buff[1] + (cursor.x * cursor.y<<2) );
-
lock(meteor_int_handler, meteor_int_handler_end);
-
- address.offset32=(unsigned long)(&int8_handler);
- address.selector=my_cs;
- if(NoInt8==0)
- if(__dpmi_set_protected_mode_interrupt_vector(8, &address)!=0) error(DPMI);
-
-
- mouse_info.pm_offset=(unsigned long) mouse_handler;
-
- if((_go32_dpmi_allocate_real_mode_callback_retf(&mouse_info, (__dpmi_regs*)(&mouse_regs)))
- !=0) error(MouseHand);
-
- r.x.ax=0x0c;
- r.x.cx=1+2+4+8+16+32+64;
- r.x.es=mouse_info.rm_segment;
- r.x.dx=mouse_info.rm_offset;
- __dpmi_int(0x33, &r); //set Handler
-
}
VesaInfoBlock *get_vesa_info(void)
@@ -507,74 +446,42 @@ void copy_vidbuffer(void){
int i, j;
if(page_flip==0){
- for(i=0; i<vgay; i++){
- mem2vid(vidbuf + i*xresvb, (s_yuv*)((byte*)(dispbuf.yuv) + i*xresc), vgax, bpp);
-
- if(mouse_y - cursor.hoty <= i && mouse_y + cursor.y - cursor.hoty > i){
- disabled_call_mouse_handler();
- mouse_handler_enable=0;
- int mouse__x =mouse_x - cursor.hotx;
- int mouse__xe=mouse_x + cursor.x - cursor.hotx;
- int mouse__ye=mouse_y + cursor.y - cursor.hoty;
-
- if(mouse__x<0) mouse__x=0;
- else if(mouse__xe>=vgax) mouse__xe=vgax-1;
- if(mouse__ye>=vgay) mouse__ye=vgay-1;
-
- j=mouse__xe & (~1);
-
- for(; i < vgay && i < mouse__ye; i++ ){
- mem2vid(vidbuf + i*xresvb, (s_yuv*)((byte*)(dispbuf.yuv) + i*xresc), mouse__x, bpp);
- mem2vid(vidbuf + i*xresvb + j*vb,
- (s_yuv*)((byte*)(dispbuf.yuv) + (i*xresc + (j<<mc))),
- vgax - j - 1, bpp);
- }
- i--;
- mouse_handler_enable=1;
- }
+ int p=0;
+ for(int y=0; y<wndy; y++){
+ mem2vid(vidbuf+p, actVid2MemBufp->b+p, wndx, bpp);
+ p+=vgax<<1;
}
}else if(page_flip==2){
- mem2vid(vidbuf+xresvb*vgay, dispbuf.yuv, vgax*vgay, bpp);
+ int p=0;
+ for(int y=0; y<wndy; y++){
+ mem2vid(vidbuf+xresvb*vgay+p, actVid2MemBufp->b+p, wndx, bpp);
+ p+=vgax<<1;
+ }
page_flip=1;
- fresh_cursor=1;
- disabled_call_mouse_handler();
set_start_disp(0, vgay);
}else{
- mem2vid(vidbuf, dispbuf.yuv, vgax*vgay, bpp);
+ int p=0;
+ for(int y=0; y<wndy; y++){
+ mem2vid(vidbuf+p, actVid2MemBufp->b+p, wndx, bpp);
+ p+=vgax<<1;
+ }
page_flip=2;
- fresh_cursor=1;
- disabled_call_mouse_handler();
set_start_disp(0, 0);
}
- if(single==0){
-
- int workingOne=0;
- while(doubleBuff[workingOne].state!=Working && workingOne<2) workingOne++;
- if(workingOne==2) workingOne=0; // should be only at start
- doubleBuff[workingOne].state=Empty;
-
- int nextOne= workingOne^1;
- if(doubleBuff[nextOne].state==Empty) nextOne=0; // not critical
-
- while(doubleBuff[nextOne].state != Grabbed);
-
- doubleBuff[nextOne].state= Working;
-
- dispbuf= doubleBuff[nextOne];
+ if( vid2MemBuf[actVid2MemBuf].state==Working ){
+ vid2MemBuf[actVid2MemBuf].state=Empty;
}
- else{
- doubleBuff[0].state=
- doubleBuff[1].state=Empty;
+ actVid2MemBuf++;
+ if(actVid2MemBuf >= vid2MemBuf[0].num) actVid2MemBuf=0;
- while(doubleBuff[0].state != Grabbed);
+ while( vid2MemBuf[ actVid2MemBuf ].state!= Grabbed );
- doubleBuff[0].state=
- doubleBuff[1].state=Working;
+ vid2MemBuf[ actVid2MemBuf ].state= Working;
- dispbuf= doubleBuff[0];
- }
+
+ actVid2MemBufp= &vid2MemBuf[ actVid2MemBuf ];
/*
printf("%X, %X\n", meteors[active_meteor].saa7116->capt_ctl_a,
Modified: trunk/2010/2_hw.h
==============================================================================
--- trunk/2010/2_hw.h (original)
+++ trunk/2010/2_hw.h Wed Jul 4 08:49:51 2007
@@ -89,7 +89,7 @@ void sig_handler(int i);
void end_func(void);
u_long read_pci(int,int,int,int,int);
void write_pci(int,int,int,int,int,u_long);
-void mem2vid(byte *to, s_yuv *from, int num, int bpp);
+void mem2vid(byte *to, byte *from, int num, int bpp);
int check_mmx(void);
#endif
Modified: trunk/2010/2_hw_asm.s
==============================================================================
--- trunk/2010/2_hw_asm.s (original)
+++ trunk/2010/2_hw_asm.s Wed Jul 4 08:49:51 2007
@@ -3,26 +3,15 @@
_lock_start:
.globl _lock_start
-.globl _timer_count
-.globl _old_int8_vect_offset
-.globl _old_int8_vect_selector
-.globl _int8_handler
.globl _meteor_handler
.globl _lock_end
.globl _save_selectors__Fv
-.globl _mouse_regs
-.globl _mouse_handler_enable
.globl _in_int
-.globl _mouse_lx
-.globl _mouse_ly
-.globl _mouse_tim
-.globl _mouse_ltim
-.globl _mouse_x
-.globl _mouse_y
-.globl _mouse_b
.globl _page_flip
-.globl _dispbuf
-.globl _doubleBuff
+.globl _vid2MemBuf
+.globl _actVid2MemBufp
+.globl _actVid2MemBuf
+.globl _grabVid2MemBuf
.globl _vidbuf
.globl _vgax
.globl _xresvb
@@ -30,7 +19,6 @@
.globl _mc
.globl _xresc
.globl _vgay
-.globl _cursor
.globl _yuvmode
.globl _locklist
.globl _alloclist
@@ -48,20 +36,16 @@
.globl _frames
.globl _fields
.globl _saa7196_buf
-.globl _std
+.globl _TVStd
.globl _x_field
.globl _y_field
-.globl _one_field
-.globl _amb
-.globl _mouse_buff
-.globl _fresh_cursor
+.globl _oneField
.globl _stride
.globl _single
-.globl _crypt
+.globl _cryptStd
.globl _wndx
.globl _wndy
.globl _outy
-.globl _nagra_mode
.globl _mmx
.globl _my_cs
.globl _my_ds
@@ -71,30 +55,13 @@
.align 4
-_timer_count: .long 0
-_mouse_handler_enable: .long 1
_in_int: .long 0
-_mouse_lx: .long 0
-_mouse_ly: .long 0
-_mouse_tim: .long 0
-_mouse_ltim: .long 0
-_mouse_x: .long 0
-_mouse_y: .long 0
-_mouse_b: .long 0
_page_flip: .long 0
-_dispbuf: .long 0
-.long 0
-.long 0
-.long 0
-_doubleBuff: .long 1234
-.long 0
-.long 0
-.long 0
-.long 0
-.long 0
-.long 0
-.long 0
-.long 4321
+_actVid2MemBufp: .long 0
+_actVid2MemBuf: .long 0
+_grabVid2MemBuf: .long 0
+_vid2MemBuf: .long 0
+.space 64, 0
_vidbuf: .long 0
_vgax: .long 0
_vb: .long 0
@@ -119,28 +86,21 @@ _corr_errors: .long 0
_frames: .long 0
_fields: .long 0
_saa7196_buf: .space 52, 0
-_std: .long 0
+_TVStd: .long 0
_x_field: .long 0
_y_field: .long 0
-_one_field: .long 0
-_amb: .long 0
-_mouse_buff: .long 0
- .long 0
-_fresh_cursor: .long 1
+_oneField: .long 0
_stride: .long 0
_single: .long 0
-_crypt: .long 0
+_cryptStd: .long 0
_wndx: .long 0
_wndy: .long 0
_outy: .long 0
-_nagra_mode: .long 0
_mmx: .long 1
_my_cs: .word 0
_my_ds: .word 0
_meteors: .space 0x80, 0
-_cursor: .space 0x40, 0
-_mouse_regs: .space 0x40, 0
_ds: .word 0
_es: .word 0
@@ -205,35 +165,6 @@ _real_int__FsP11__dpmi_regs:
ret
.align 4
-_int8_handler:
-
- pushal
- pushw %ds
- pushw %es
- pushw %fs
- pushw %gs
-
- movw %cs:_ds, %ds
- movw _es, %es
- movw _fs, %fs
- movw _gs, %gs
-
- incl _timer_count
-
- call _disabled_call_mouse_handler__Fv
-
- popw %gs
- popw %fs
- popw %es
- popw %ds
- popal
-
-.byte 0xEA
-_old_int8_vect:
-_old_int8_vect_offset: .long 0
-_old_int8_vect_selector: .word 0
-
-.align 4
_meteor_handler:
// int $3
Modified: trunk/2010/2_hw_mem.cc
==============================================================================
--- trunk/2010/2_hw_mem.cc (original)
+++ trunk/2010/2_hw_mem.cc Wed Jul 4 08:49:51 2007
@@ -11,7 +11,8 @@
#include "2_hw_mem.h"
#include "2010.h"
- extern volatile xxx dispbuf, last_dispbuf, grab_dispbuf;
+ extern volatile VID2MEMBUF *vid2MemBuf, actVid2MemBufp;
+ extern volatile int actVid2MemBuf, grabVid2MemBuf;
extern volatile LockList *locklist;
extern volatile AllocList *alloclist;
extern volatile VdsList *vdslist;
@@ -193,8 +194,7 @@ void dpmi_freeall(volatile AllocList **a
}
-xxx *alloc_cont(int size, int num){
- static xxx ret[2];
+void allocCont(VID2MEMBUF *v2mb, int size, int *num){
u_long addr;
size= (size + 4095) & (~4095); //round up to next 4096 boundray
@@ -205,72 +205,61 @@ xxx *alloc_cont(int size, int num){
addr=(u_long)map(2048*1024, 2048*1024 + 1024*1024); //check if mapping of RAM is ok
unmap((void*)addr);
- bool both;
- if(num==2){
- both=true;
- size<<=1;
- }else
- both=false;
-
dds vds_info;
- for(int i=0; i<num; i++){
- int slack=0;
- for(;;){
- vds_info= vds_alloc(size + slack);
+ int left=*num;
+ for(int tryi=left; tryi>0; tryi=min(tryi-1, left) ){
+ for(int slack=0; ; slack+=4096){
+ vds_info= vds_alloc(size*tryi + slack);
if(vds_info.phys==0xFFFFFFFF){
- if(!both) error(MemAlloc);
- both=false;
- size>>=1;
- slack=0;
+ break;
}else{
- printf("AllocatedContVDS %d, at Address %lX\n", size + slack , vds_info.phys);
+ printf("AllocatedContVDS %d, at Address %lX\n", size*tryi + slack , vds_info.phys);
fflush(stdout);
const int j=~(1024*1024*4-1);
- if(both){
- if( ( ((vds_info.phys + slack ) & j)
- ==((vds_info.phys + slack + (size>>1)-1) & j) )
- && ( ((vds_info.phys + slack + (size>>1) ) & j)
- ==((vds_info.phys + slack + size -1) & j) ) ) break;
- }else{
- if( ((vds_info.phys + slack ) & j)
- == ((vds_info.phys + slack + size-1) & j) ) break;
+
+ int i;
+ for(i=0; i<tryi; i++){
+ if( ((vds_info.phys + slack + size*i ) & j)
+ != ((vds_info.phys + slack + size*i + size-1) & j) ) break;
+ }
+ if(i==tryi){
+ printf("Success!\n");
+ fflush(stdout);
+
+ for(int k=0; k<tryi; k++){
+ v2mb[*num-left+k].b=
+ (byte*)( map( vds_info.phys + slack + size*k
+ , vds_info.phys + slack + size*k + size) // FIX ?-1
+ - __djgpp_base_address);
+
+ v2mb[*num-left+k].phys= vds_info.phys + size*k + slack;
+ }
+
+ left-=tryi;
+ tryi++;
+
+ break;
}
printf("4MB Boundray violation!\n");
fflush(stdout);
vds_free(&vds_info);
+
}
- slack+=4096;
}
+ }
- if(both){
- size>>=1;
-
- ret[0].b= (byte*)(map(
- vds_info.phys + slack , vds_info.phys + slack + size)
- - __djgpp_base_address);
-
- ret[1].b= (byte*)(map(
- vds_info.phys + slack + size, vds_info.phys + slack + size + size)
- - __djgpp_base_address);
- ret[0].phys= vds_info.phys + slack;
- ret[1].phys= vds_info.phys + slack + size;
- break;
- }else{
- ret[i].b= (byte*)(map(
- vds_info.phys + slack , vds_info.phys + slack + size)
- - __djgpp_base_address);
- ret[i].phys= vds_info.phys + slack;
- }
+ *num-=left;
+ if(*num==0) error(MemAlloc);
+ v2mb[0].num= *num;
+ for(int i=0; i<*num; i++){
+ v2mb[0].state= Empty;
}
- if(num==1) ret[1]= ret[0];
-
- return ret;
}
void checkVDS(void){
Modified: trunk/2010/2_hw_mem.h
==============================================================================
--- trunk/2010/2_hw_mem.h (original)
+++ trunk/2010/2_hw_mem.h Wed Jul 4 08:49:51 2007
@@ -44,7 +44,7 @@ void dpmi_addlinlock(volatile AllocList
u_long dpmi_alloclinlock(volatile AllocList **al);
void dpmi_freelinlock(volatile AllocList *old, volatile AllocList **al);
void dpmi_freeall(volatile AllocList **al);
-xxx *alloc_cont(int size, int num);
+void allocCont(VID2MEMBUF *v2mb, int size, int *num);
void checkVDS(void);
u_long getphys(u_long);
dds vds_alloc(int size);
Modified: trunk/2010/2_nag.cc
==============================================================================
--- trunk/2010/2_nag.cc (original)
+++ trunk/2010/2_nag.cc Wed Jul 4 08:49:51 2007
@@ -17,12 +17,12 @@
#define dwnSmp 1
extern vgax, vgay, wndx, wndy, outy, y_field;
-extern xxx dispbuf;
+extern VID2MEMBUF *actVid2MemBufp;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
extern int one_field;
extern u_long asm_temp, asm_temp4;
-extern int istate;
+extern bool iState;
extern int yuvmode;
extern bool mmx;
@@ -421,12 +421,12 @@ void nag_decrypt(void){
byte * const decoLowRes=(byte*) newAlign( (wndx>>dwnSmpSize) * decoLines, 8);
for(int dL=0; dL<decoLines; dL++){
- byte * const linep= dispbuf.b + nagLineLogi2Phys(decoLine[dL])*(vgax<<1);
+ byte * const linep= actVid2MemBufp->b + nagLineLogi2Phys(decoLine[dL])*(vgax<<1);
byte * const lowResp= decoLowRes + dL*(wndx>>dwnSmpSize);
doDwnSmp(lowResp ,linep);
}
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[0],"%f ReSample decoLines", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -434,7 +434,7 @@ void nag_decrypt(void){
byte * const lowRes=(byte*) newAlign( wndx>>dwnSmpSize, 8);
for(int line=0; line<NAG_LINES; line++){
- byte * const linep= dispbuf.b + nagLineLogi2Phys(line)*(vgax<<1);
+ byte * const linep= actVid2MemBufp->b + nagLineLogi2Phys(line)*(vgax<<1);
// printf("%d\n", line);
doDwnSmp(lowRes, linep);
// printf("xxX\n");
@@ -452,7 +452,7 @@ void nag_decrypt(void){
deleteAlign(lowRes);
printf("H2\n");
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[1],"%f Corr", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -485,7 +485,7 @@ void nag_decrypt(void){
}
printf("H3\n");
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[2],"%f GenKeyPointers", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -533,7 +533,7 @@ void nag_decrypt(void){
getPerm(bestKey, perm);
printf("%X\n", bestKey);
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[3],"%f FindKey", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -553,10 +553,10 @@ void nag_decrypt(void){
const type= cleMod4 ^ encMod4;
if(lastV[type&1^1] != NULL){
- byte *b=dispbuf.b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
+ byte *b=actVid2MemBufp->b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
corrV( b, lastV[type&1^1], type ^ lastVType[type&1^1], &vPhase );
}
- lastV[type&1]= dispbuf.b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
+ lastV[type&1]= actVid2MemBufp->b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
lastVType[type&1]= type;
}
}
@@ -571,7 +571,7 @@ void nag_decrypt(void){
const encMod4= (perm[i] + vPhase ) & 3;
const type= cleMod4 ^ encMod4;
- lowDriftLinep= dispbuf.b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
+ lowDriftLinep= actVid2MemBufp->b + nagLineLogi2Phys( perm[i] ) * (vgax<<1);
if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, type);
@@ -580,14 +580,14 @@ void nag_decrypt(void){
}
for(int clearLine=0 ;clearLine<NAG_LINES; clearLine++){
- byte * const linep= dispbuf.b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
+ byte * const linep= actVid2MemBufp->b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
if(perm[clearLine]>=32 && mabs(perm[clearLine]-32 - clearLine)<5){
const cleMod4= (clearLine + vPhase ) & 3;
const encMod4= (perm[clearLine] + vPhase ) & 3;
const type= cleMod4 ^ encMod4;
- lowDriftLinep= dispbuf.b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
+ lowDriftLinep= actVid2MemBufp->b + nagLineLogi2Phys( perm[clearLine] ) * (vgax<<1);
if(cleMod4!=encMod4) mod4Fix(lowDriftLinep, type);
}
@@ -601,7 +601,7 @@ void nag_decrypt(void){
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[5],"%f ColorDeco", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -611,7 +611,7 @@ void nag_decrypt(void){
/*
for(int i=0; i<NAG_LINES; i++){
const int p=nagLineLogi2Phys(i);
- dispbuf.b[p*(vgax<<1)+i*2+1]=255;
+ actVid2MemBufp->b[p*(vgax<<1)+i*2+1]=255;
}
for(int i=0; i<decoLines; i++){
@@ -619,9 +619,9 @@ void nag_decrypt(void){
const int p2=nagLineLogi2Phys(bestCoeffs[i].line[0]);
const int p3=nagLineLogi2Phys(bestCoeffs[i].line[1]);
for(int j=0; j<20; j++){
- dispbuf.b[p1*(vgax<<1)+i*20+101+j]=255;
- dispbuf.b[p2*(vgax<<1)+i*20+101+j]=255;
- dispbuf.b[p3*(vgax<<1)+i*20+101+j]=255;
+ actVid2MemBufp->b[p1*(vgax<<1)+i*20+101+j]=255;
+ actVid2MemBufp->b[p2*(vgax<<1)+i*20+101+j]=255;
+ actVid2MemBufp->b[p3*(vgax<<1)+i*20+101+j]=255;
}
}
*/
@@ -656,7 +656,7 @@ void nag_decrypt(void){
const bool open= (j == -1);
if(!open){
- memcpy(copyBuff, dispbuf.cl + i * vgax, wndx << 1);
+ memcpy(copyBuff, actVid2MemBufp->b + (i * vgax<<1), wndx << 1);
j = i;
do{
k = j;
@@ -664,9 +664,10 @@ void nag_decrypt(void){
enc2cleVec[k] = k;
cle2encVec[k] = k;
// printf("closed %d %d\n", j, k );
- if(j != i) memcpy(dispbuf.cl + k * vgax, dispbuf.cl + j * vgax, wndx << 1);
+ if(j != i) memcpy(actVid2MemBufp->b + (k * vgax<<1),
+ actVid2MemBufp->b + (j * vgax<<1), wndx << 1);
} while(j != i);
- memcpy(dispbuf.cl + k * vgax, copyBuff, wndx << 1);
+ memcpy(actVid2MemBufp->b + (k * vgax<<1), copyBuff, wndx << 1);
}
else{
j = k;
@@ -676,7 +677,8 @@ void nag_decrypt(void){
enc2cleVec[k] = k;
cle2encVec[k] = k;
// printf("open %d %d\n", j, k );
- if(j != -1) memcpy(dispbuf.cl + k * vgax, dispbuf.cl + j * vgax, wndx << 1);
+ if(j != -1) memcpy( actVid2MemBufp->b + (k * vgax<<1)
+ , actVid2MemBufp->b + (j * vgax<<1), wndx << 1);
} while(j != -1);
}
@@ -684,13 +686,14 @@ void nag_decrypt(void){
if(outy == wndy){
for(int i=0; i<outy; i+=2){
- memcpy(dispbuf.cl + (i+1) * vgax, dispbuf.cl + i * vgax, wndx << 1);
+ memcpy(actVid2MemBufp->b + ((i+1) * vgax<<1),
+ actVid2MemBufp->b + (i * vgax<<1) , wndx << 1);
}
}
delete [] copyBuff;
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[4],"%f ReOrder", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -701,19 +704,19 @@ void nag_decrypt(void){
- if(istate==1){
+ if(iState){
T2=uclock();
c.init(255, 0, 0, yuvmode);
- gprint(80, 80, c.c, textbuf[0]);
- gprint(90, 90, c.c, textbuf[1]);
- gprint(100, 100, c.c, textbuf[2]);
- gprint(110, 110, c.c, textbuf[3]);
- gprint(120, 120, c.c, textbuf[4]);
- gprint(130, 130, c.c, textbuf[5]);
-/* gprint(140, 140, c.c, textbuf[6]);
- gprint(150, 150, c.c, textbuf[7]);
- gprint(160, 160, c.c, textbuf[8]);
- gprint(170, 170, c.c, textbuf[9]);*/
+ gprint(80, 80, c.col, textbuf[0]);
+ gprint(90, 90, c.col, textbuf[1]);
+ gprint(100, 100, c.col, textbuf[2]);
+ gprint(110, 110, c.col, textbuf[3]);
+ gprint(120, 120, c.col, textbuf[4]);
+ gprint(130, 130, c.col, textbuf[5]);
+/* gprint(140, 140, c.col, textbuf[6]);
+ gprint(150, 150, c.col, textbuf[7]);
+ gprint(160, 160, c.col, textbuf[8]);
+ gprint(170, 170, c.col, textbuf[9]);*/
T1=T2;
}
@@ -809,7 +812,7 @@ void nag_decrypt(void){
"popl %%ebp \n\t"
: "=c" (avg)
: "c" (dwnSmp), "a"(&lastDwnSmp),
- "S" (dispbuf.b + line + 1) ,
+ "S" (actVid2MemBufp->b + line + 1) ,
"d" (wndx>>dwnSmp) ,
"D" (lowRes + lowResLine)
: "%eax", "%ebx", "%edx", "%esi", "%edi");
@@ -855,7 +858,7 @@ void nag_decrypt(void){
"popl %%ebp \n\t"
: "=c" (avg)
: "c" (dwnSmp), "a"(&lastDwnSmp),
- "S" (dispbuf.b + line + 1) ,
+ "S" (actVid2MemBufp->b + line + 1) ,
"d" (wndx>>dwnSmp) ,
"D" (lowRes + lowResLine)
: "%eax", "%ebx", "%edx", "%esi", "%edi");
@@ -947,7 +950,7 @@ void nag_decrypt(void){
if(mmx) asm("emms \n\t");
printf("HALLOB\n");
- if(istate==1){
+ if(iState){
T2=uclock();
T_corr+=T2-T1;
T1=T2;
@@ -1007,7 +1010,7 @@ void nag_decrypt(void){
delete [] tempSort;
- if(istate==1){
+ if(iState){
T2=uclock();
T_radix+=T2-T1;
T1=T2;
@@ -1152,7 +1155,7 @@ void nag_decrypt(void){
}
printf("HALLOD\n");
- if(istate==1){
+ if(iState){
T2=uclock();
T_merge+=T2-T1;
T1=T2;
@@ -1164,7 +1167,7 @@ void nag_decrypt(void){
printf("blockp %d\n", blockp);
- if(istate==1){
+ if(iState){
sprintf(textbuf[0],"%f Corr", (float)(T_corr)/UCLOCKS_PER_SEC);
sprintf(textbuf[1],"%f Radix Sort", (float)(T_radix)/UCLOCKS_PER_SEC);
sprintf(textbuf[2],"%f Block Handling", (float)(T_merge)/UCLOCKS_PER_SEC);
@@ -1174,7 +1177,7 @@ void nag_decrypt(void){
printf("HALLO2\n");
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[3],"%f Stat", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -1182,7 +1185,7 @@ void nag_decrypt(void){
qsort(block, blockp, sizeof(BLOCK), qsort_block);
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[4],"%f Sort", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -1226,7 +1229,7 @@ void nag_decrypt(void){
}
printf("HALLO3\n");
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[5],"%f Built Vecs", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -1246,7 +1249,7 @@ void nag_decrypt(void){
const int open= ( (j == -1) ? 1 : 0 );
if(open == 0){
- memcpy(copy_buff, dispbuf.cl + i * vgax, wndx << 1);
+ memcpy(copy_buff, actVid2MemBufp->cl + i * vgax, wndx << 1);
j = i;
do{
k = j;
@@ -1254,9 +1257,9 @@ void nag_decrypt(void){
forwVec[k] = k;
bakwVec[k] = k;
// printf("closed %d %d\n", j, k );
- if(j != i) memcpy(dispbuf.cl + k * vgax, dispbuf.cl + j * vgax, wndx << 1);
+ if(j != i) memcpy(actVid2MemBufp->cl + k * vgax, actVid2MemBufp->cl + j * vgax, wndx << 1);
} while(j != i);
- memcpy(dispbuf.cl + k * vgax, copy_buff, wndx << 1);
+ memcpy(actVid2MemBufp->cl + k * vgax, copy_buff, wndx << 1);
}
else{
j = k;
@@ -1266,7 +1269,7 @@ void nag_decrypt(void){
forwVec[k] = k;
bakwVec[k] = k;
// printf("open %d %d\n", j, k );
- if(j != -1) memcpy(dispbuf.cl + k * vgax, dispbuf.cl + j * vgax, wndx << 1);
+ if(j != -1) memcpy(actVid2MemBufp->cl + k * vgax, actVid2MemBufp->cl + j * vgax, wndx << 1);
} while(j != -1);
}
@@ -1274,7 +1277,7 @@ void nag_decrypt(void){
if(outy == wndy){
for(int i=0; i<outy; i+=2){
- memcpy(dispbuf.cl + (i+1) * vgax, dispbuf.cl + i * vgax, wndx << 1);
+ memcpy(actVid2MemBufp->cl + (i+1) * vgax, actVid2MemBufp->cl + i * vgax, wndx << 1);
}
}
@@ -1285,20 +1288,20 @@ void nag_decrypt(void){
int allnor=0;
int allinv=0;
for(i=0; i<wndx; i+=2){
- register int x=dispbuf.b[ linep + (i<<1) - (vgax<<1) + 2 ];
- register int y=dispbuf.b[ linep + (i<<1) + 2 ];
+ register int x=actVid2MemBufp->b[ linep + (i<<1) - (vgax<<1) + 2 ];
+ register int y=actVid2MemBufp->b[ linep + (i<<1) + 2 ];
if(x>127) x-=256;
if(y>127) y-=256;
allnor+=mabs(x-y);
allinv+=mabs(x+y);
}
if(allinv < allnor){
- dispbuf.cl[line * vgax + 4 ].lum=255;
- dispbuf.cl[line * vgax + 5 ].lum=0;
+ actVid2MemBufp->cl[line * vgax + 4 ].lum=255;
+ actVid2MemBufp->cl[line * vgax + 5 ].lum=0;
for(i=0; i<wndx; i+=2){
- register int x=dispbuf.b[ linep + (i<<1) + 2 ];
+ register int x=actVid2MemBufp->b[ linep + (i<<1) + 2 ];
if(x>127) x-=256;
- dispbuf.b[ 2 + linep + (i<<1) ]=char(-x);
+ actVid2MemBufp->b[ 2 + linep + (i<<1) ]=char(-x);
}
}
@@ -1311,20 +1314,20 @@ void nag_decrypt(void){
int allnor=0;
int allinv=0;
for(i=0; i<wndx; i+=2){
- register int x=dispbuf.b[ linep + (i<<1) - (vgax<<1) ];
- register int y=dispbuf.b[ linep + (i<<1) ];
+ register int x=actVid2MemBufp->b[ linep + (i<<1) - (vgax<<1) ];
+ register int y=actVid2MemBufp->b[ linep + (i<<1) ];
if(x>127) x-=256;
if(y>127) y-=256;
allnor+=mabs(x-y);
allinv+=mabs(x+y);
}
if(allinv < allnor){
- dispbuf.cl[line * vgax + 6 ].lum=255;
- dispbuf.cl[line * vgax + 7 ].lum=0;
+ actVid2MemBufp->cl[line * vgax + 6 ].lum=255;
+ actVid2MemBufp->cl[line * vgax + 7 ].lum=0;
for(i=0; i<wndx; i+=2){
- register int x=dispbuf.b[ linep + (i<<1) ];
+ register int x=actVid2MemBufp->b[ linep + (i<<1) ];
if(x>127) x-=256;
- dispbuf.b[ linep + (i<<1) ]=char(-x);
+ actVid2MemBufp->b[ linep + (i<<1) ]=char(-x);
}
}
@@ -1337,11 +1340,11 @@ void nag_decrypt(void){
// printf("%d %d %d\n", i, block[i].up_limit, block[i].avg);
line+= block[i].ent;
- dispbuf.cl[line * vgax ].lum=255;
- dispbuf.cl[line * vgax + 1 ].lum=0;
+ actVid2MemBufp->cl[line * vgax ].lum=255;
+ actVid2MemBufp->cl[line * vgax + 1 ].lum=0;
if(lineInf[ block[i].end[0] ].state == 0){
- dispbuf.cl[line * vgax + 2 ].lum=255;
- dispbuf.cl[line * vgax + 3 ].lum=0;
+ actVid2MemBufp->cl[line * vgax + 2 ].lum=255;
+ actVid2MemBufp->cl[line * vgax + 3 ].lum=0;
block_noblack--;
}
}
Modified: trunk/2010/2_vc.cc
==============================================================================
--- trunk/2010/2_vc.cc (original)
+++ trunk/2010/2_vc.cc Wed Jul 4 08:49:51 2007
@@ -16,12 +16,12 @@
#define check 1
extern vgax, vgay, wndx, wndy;
-extern xxx dispbuf;
+extern VID2MEMBUF *actVid2MemBufp;
extern volatile int scales_x, scalee_x;
extern volatile int scales_y, scalee_y;
extern int one_field;
extern int show_points;
-extern int istate;
+extern bool iState;
extern int yuvmode;
extern int edge_lut[256];
@@ -66,7 +66,7 @@ void vc_decrypt(void){
datbuf[0]= new char[vc_diff];
datbuf[1]= new char[vc_diff];
- if(istate==1){
+ if(iState){
T1=uclock();
}
@@ -111,13 +111,13 @@ void vc_decrypt(void){
"popl %%ebp \n\t"
:
: "I" (check), "i" (1<<check),
- "S" (dispbuf.b + linep + 1 + (vc_startx<<1)) ,
+ "S" (actVid2MemBufp->b + linep + 1 + (vc_startx<<1)) ,
"d" (vc_diff>>check) ,
"D" (datbuf[1])
: "%eax", "%ebx", "%edx", "%esi", "%edi");
- if(istate==1){
+ if(iState){
T2=uclock();
alg3+=T2-T1;
T1=T2;
@@ -165,7 +165,7 @@ void vc_decrypt(void){
else drift=(addap_end>>1) | 1;
- if(istate==1){
+ if(iState){
T2=uclock();
alg1+=T2-T1;
T1=T2;
@@ -192,11 +192,11 @@ void vc_decrypt(void){
int edge_x= l == 0 ? (l - 2) + vc_diff : (l - 2);
do{
if((edge_x++) >= vc_diff) edge_x-= vc_diff;
- diff+= dispbuf.b[linep + ((vc_startx + edge_x)<<1) + 1];
+ diff+= actVid2MemBufp->b[linep + ((vc_startx + edge_x)<<1) + 1];
}while( edge_x != l );
do{
if((edge_x++) >= vc_diff) edge_x-= vc_diff;
- diff-= dispbuf.b[linep + ((vc_startx + edge_x)<<1) + 1];
+ diff-= actVid2MemBufp->b[linep + ((vc_startx + edge_x)<<1) + 1];
}while( edge_x != l + 2);
diff= edge_lut[ mabs(diff) ];
@@ -258,7 +258,7 @@ void vc_decrypt(void){
last_val=new_val;
new_val=temp_val;
- if(istate==1){
+ if(iState){
T2=uclock();
alg2+=T2-T1;
T1=T2;
@@ -266,7 +266,7 @@ void vc_decrypt(void){
}
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[0],"%f Corr", (float)(alg1)/UCLOCKS_PER_SEC);
sprintf(textbuf[1],"%f Edge-Search", (float)(alg2)/UCLOCKS_PER_SEC);
@@ -283,13 +283,13 @@ void vc_decrypt(void){
else{
j=cutpoint[line]+i;
if(j >= vc_diff) j-= vc_diff;
- dispbuf.b[(line * vgax<<1) + ((vc_startx + j)<<1)+1]=255;
- dispbuf.b[(line * vgax<<1) + ((vc_startx + j)<<1)+3]=0;
+ actVid2MemBufp->b[(line * vgax<<1) + ((vc_startx + j)<<1)+1]=255;
+ actVid2MemBufp->b[(line * vgax<<1) + ((vc_startx + j)<<1)+3]=0;
}
i=dir[vc_diff*line + i];
}
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[3],"%f Misc", (float)(T2-T1)/UCLOCKS_PER_SEC);
T1=T2;
@@ -303,13 +303,13 @@ void vc_decrypt(void){
linep+=vgax<<1;
if(show_points!=0){
- dispbuf.b[linep+(vc_startx<<1)+1]=255;
- dispbuf.b[linep+(vc_startx<<1)+3]=0;
+ actVid2MemBufp->b[linep+(vc_startx<<1)+1]=255;
+ actVid2MemBufp->b[linep+(vc_startx<<1)+3]=0;
}
- memcpy(copy_buff, dispbuf.b + linep + (vc_startx<<1), vc_diff<<1);
- memcpy(dispbuf.b + linep + (vc_startx<<1), copy_buff + (cutpoint[line]<<1),
+ memcpy(copy_buff, actVid2MemBufp->b + linep + (vc_startx<<1), vc_diff<<1);
+ memcpy(actVid2MemBufp->b + linep + (vc_startx<<1), copy_buff + (cutpoint[line]<<1),
(vc_diff-cutpoint[line])<<1);
- memcpy(dispbuf.b + linep + (vc_startx<<1) + ((vc_diff-cutpoint[line])<<1),
+ memcpy(actVid2MemBufp->b + linep + (vc_startx<<1) + ((vc_diff-cutpoint[line])<<1),
copy_buff,
cutpoint[line]<<1);
/*
@@ -318,21 +318,21 @@ void vc_decrypt(void){
j=dir[line * vc_diff + i];
if(j<0 || j>=vc_diff) j=0;
- dispbuf.b[linep + ((vc_startx + j) <<1)+1]=255;
+ actVid2MemBufp->b[linep + ((vc_startx + j) <<1)+1]=255;
}
}
*/
}
- if(istate==1){
+ if(iState){
T2=uclock();
sprintf(textbuf[4],"%f Rotate", (float)(T2-T1)/UCLOCKS_PER_SEC);
c.init(255, 0, 0, yuvmode);
- gprint(80, 80, c.c, textbuf[0]);
- gprint(90, 90, c.c, textbuf[1]);
- gprint(100, 100, c.c, textbuf[2]);
- gprint(110, 110, c.c, textbuf[3]);
- gprint(120, 120, c.c, textbuf[4]);
+ gprint(80, 80, c.col, textbuf[0]);
+ gprint(90, 90, c.col, textbuf[1]);
+ gprint(100, 100, c.col, textbuf[2]);
+ gprint(110, 110, c.col, textbuf[3]);
+ gprint(120, 120, c.col, textbuf[4]);
T1=T2;
}
Modified: trunk/2010/makefile
==============================================================================
--- trunk/2010/makefile (original)
+++ trunk/2010/makefile Wed Jul 4 08:49:51 2007
@@ -12,29 +12,22 @@ AFLAGS = -f coff
.asm.o: ; nasm $(AFLAGS) $<
-O = 2010.o 2_file.o 2_menu.o 2_grafix.o 2_hw.o 2_mfunc.o 2_mouse.o 2_gfunc.o \
- 2_move.o 2_hw_asm.o 2_71x6.o 2_hw_mem.o 2_wins.o 2_crypt.o 2_vc.o 2_nag.o\
+O = 2010.o 2_file.o 2_grafix.o 2_hw.o 2_gfunc.o \
+ 2_hw_asm.o 2_71x6.o 2_hw_mem.o 2_crypt.o 2_vc.o 2_nag.o\
2_nag_a.o 2_vc_a.o 2_glob_a.o
2010 : $(O) ; gcc $(CFLAGS) -o 2010 $(O)
clean: ; del $(O) 2010
-2010.o : 2010.cc 2_all.h 2010.h 2_file.h 2_mouse.h 2_hw.h 2_grafix.h\
- 2_menu.h 2_mfunc.h 2_move.h 2_71x6.h 2_hw_mem.h\
- 2_nag.h
+2010.o : 2010.cc 2_all.h 2010.h 2_file.h 2_hw.h 2_grafix.h\
+ 2_71x6.h 2_hw_mem.h 2_nag.h
2_file.o : 2_file.cc 2_all.h 2_file.h 2010.h 2_hw.h
2_gfunc.o : 2_gfunc.cc 2_all.h 2_gfunc.h 2010.h
-2_grafix.o : 2_grafix.cc 2_all.h 2_grafix.h 2_gfunc.h 2_menu.h 2_hw.h 2_file.h\
- 2_wins.h
-2_menu.o : 2_menu.cc 2_all.h 2_menu.h 2_mfunc.h 2_gfunc.h
-2_mfunc.o : 2_mfunc.cc 2_all.h 2_mfunc.h 2_menu.h 2_71x6.h 2010.h
-2_mouse.o : 2_mouse.cc 2_all.h 2_mouse.h 2_move.h
-2_hw.o : 2_hw.cc 2_all.h 2_hw.h 2010.h 2_mouse.h 2_hw_asm.h 2_hw_mem.h\
+2_grafix.o : 2_grafix.cc 2_all.h 2_grafix.h 2010.h 2_gfunc.h 2_hw.h 2_file.h
+2_hw.o : 2_hw.cc 2_all.h 2_hw.h 2010.h 2_hw_asm.h 2_hw_mem.h\
2_71x6.h 2_mmx.h
2_hw_mem.o : 2_hw_mem.cc 2_all.h 2_hw_mem.h 2010.h
-2_move.o : 2_move.cc 2_all.h 2_move.h 2010.h
2_71x6.o : 2_71x6.cc 2_all.h 2_71x6.h 2_hw.h 2_hw_mem.h 2010.h 2_hw_asm.h
-2_wins.o : 2_wins.cc 2_all.h 2_wins.h 2_gfunc.h 2_71x6.h
2_crypt.o : 2_crypt.cc 2_all.h 2_crypt.h 2_71x6.h 2_vc.h 2_nag.h
2_vc.o : 2_vc.cc 2_all.h 2_vc.h 2_crypt.h 2_gfunc.h 2_vc_a.h
2_nag.o : 2_nag.cc 2_all.h 2_nag.h 2_crypt.h 2_gfunc.h 2_mmx.h 2_nag_a.h\
1
0
Author: michael
Revision: 46
Property Name: svn:log
Action: modified
Property diff:
--- old property value
+++ new property value
@@ -1 +1 @@
-version from july 1998
+version from 1998-07-01
1
0