📄 gui.cpp
字号:
process.run = 0;
for (i=0; i<process.leftfile; i++)
process.run += process.length[i];
process.trackleft = (int)((process.run + process.leftlba * BUFFER_SIZE) * TRACK_PITCH / process.total);
SendMessage(hTrack, TBM_SETPOS, (WPARAM) true, process.trackleft);
SendMessage(hTrack, TBM_SETSEL, (WPARAM) true, (LPARAM) MAKELONG(process.trackleft, process.trackright));
}
}
break;
case ID_LEFT_ARROW:
if (IsWindowEnabled(hTrack))
{
SetFocus(hWnd);
if (WaitForSingleObject(hThread, 0)==WAIT_OBJECT_0)
{
Display_Flag = true;
process.locate = LOCATE_BACKWARD;
hThread = CreateThread(NULL, 0, MPEG2Dec, 0, 0, &threadId);
}
}
break;
case ID_RIGHT_ARROW:
if (IsWindowEnabled(hTrack))
{
SetFocus(hWnd);
if (WaitForSingleObject(hThread, 0)==WAIT_OBJECT_0)
{
Display_Flag = true;
process.locate = LOCATE_FORWARD;
hThread = CreateThread(NULL, 0, MPEG2Dec, 0, 0, &threadId);
}
}
break;
case ID_RIGHT_BUTTON:
if (IsWindowEnabled(hTrack))
{
SetFocus(hWnd);
if ((process.file>process.leftfile) || (process.file==process.leftfile && process.lba>process.leftlba))
{
process.rightfile = process.file;
process.rightlba = process.lba;
process.run = 0;
for (i=0; i<process.rightfile; i++)
process.run += process.length[i];
process.trackright = (int)((process.run + (__int64)process.rightlba*BUFFER_SIZE)*TRACK_PITCH/process.total);
SendMessage(hTrack, TBM_SETPOS, (WPARAM) true, process.trackright);
SendMessage(hTrack, TBM_SETSEL, (WPARAM) true, (LPARAM) MAKELONG(process.trackleft, process.trackright));
}
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_HSCROLL:
SetFocus(hWnd);
if (WaitForSingleObject(hThread, 0)==WAIT_OBJECT_0)
{
Display_Flag = true;
process.startloc = process.start = process.total*SendMessage(hTrack, TBM_GETPOS, 0, 0)/TRACK_PITCH;
process.startfile = 0; process.run = 0;
while (process.startloc > process.length[process.startfile])
{
process.startloc -= process.length[process.startfile];
process.run += process.length[process.startfile];
process.startfile++;
}
process.end = process.total - BUFFER_SIZE;
process.endfile = File_Limit - 1;
process.endloc = (process.length[File_Limit-1]/BUFFER_SIZE-1)*BUFFER_SIZE;
process.locate = LOCATE_SCROLL;
hThread = CreateThread(NULL, 0, MPEG2Dec, 0, 0, &threadId);
}
break;
case WM_KEYDOWN:
if (IsWindowEnabled(hTrack))
{
switch (wParam)
{
case VK_LEFT:
if (WaitForSingleObject(hThread, 0)==WAIT_OBJECT_0)
{
Display_Flag = true;
process.locate = LOCATE_BACKWARD;
hThread = CreateThread(NULL, 0, MPEG2Dec, 0, 0, &threadId);
}
break;
case VK_RIGHT:
if (WaitForSingleObject(hThread, 0)==WAIT_OBJECT_0)
{
Display_Flag = true;
process.locate = LOCATE_FORWARD;
hThread = CreateThread(NULL, 0, MPEG2Dec, 0, 0, &threadId);
}
break;
}
}
break;
case WM_SIZE:
if (!IsIconic(hWnd))
ShowStatistics(0);
if (DDOverlay_Flag)
IDirectDrawSurface_UpdateOverlay(lpOverlay, NULL, lpPrimary, NULL, DDOVER_HIDE, NULL);
break;
case WM_MOVE:
if (!IsIconic(hWnd))
ShowStatistics(0);
if (Check_Flag)
{
if (DDOverlay_Flag && Store_Flag==STORE_YUY2)
RenderYUY2();
else
RenderRGB24();
}
break;
case WM_PAINT:
if (Check_Flag && Store_Flag==STORE_RGB24)
RenderRGB24();
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
ReleaseDC(hWnd, hdc);
break;
case WM_DROPFILES:
char seq, *ext;
DragQueryFile((HDROP)wParam, 0, szInput, sizeof(szInput));
DragFinish((HDROP)wParam);
ext = strrchr(szInput, '.');
if (ext!=NULL)
{
if (!_strnicmp(ext, ".d2v", 4))
goto D2V_PROCESS;
if (!_strnicmp(ext, ".wav", 4))
{
if (Check_Flag)
break;
if (!CheckWAV())
{
DialogBox(hInst, (LPCTSTR)IDD_ERROR, hWnd, (DLGPROC)About);
break;
}
if (PopFileDlg(szOutput, hWnd, SAVE_WAV))
{
DialogBox(hInst, (LPCTSTR)IDD_DELAY, hWnd, (DLGPROC)Delay);
ShowStatistics(1);
if (!threadId || WaitForSingleObject(hThread, INFINITE)==WAIT_OBJECT_0)
hThread = CreateThread(NULL, 0, ProcessWAV, 0, 0, &threadId);
}
break;
}
}
while (File_Limit)
{
File_Limit--;
_close(Infile[File_Limit]);
}
while (_findfirst(szInput, &seqfile) != -1L)
{
strcpy(Infilename[File_Limit], szInput);
Infile[File_Limit] = _open(szInput, _O_RDONLY | _O_BINARY);
File_Limit++;
strncpy(&seq, szInput+strlen(szInput)-5, 1);
if (seq<'9')
seq++;
else
break;
strncpy(szInput+strlen(szInput)-5, &seq, 1);
}
ResizeWindow(INIT_WIDTH, INIT_HEIGHT);
Recovery();
if (File_Limit)
{
process.rightfile = File_Limit-1;
process.rightlba = (int)(process.length[File_Limit-1]/BUFFER_SIZE);
process.end = process.total - BUFFER_SIZE;
process.endfile = File_Limit - 1;
process.endloc = (process.length[File_Limit-1]/BUFFER_SIZE - 1)*BUFFER_SIZE;
process.locate = LOCATE_INIT;
if (!threadId || WaitForSingleObject(hThread, INFINITE)==WAIT_OBJECT_0)
hThread = CreateThread(NULL, 0, MPEG2Dec, 0, 0, &threadId);
}
break;
case WM_DESTROY:
strcat(szPath, "DVD2AVI.ini");
GetWindowRect(hWnd, &wrect);
if ((INIFile = fopen(szPath, "w")) != NULL)
{
fprintf(INIFile, "INI_Version=%d\n", INI_Version);
fprintf(INIFile, "INIT_X=%d\n", wrect.left);
fprintf(INIFile, "INIT_Y=%d\n", wrect.top);
fprintf(INIFile, "iDCT_Algorithm=%d\n", iDCT_Flag);
fprintf(INIFile, "YUVRGB_Scale=%d\n", Scale_Flag);
fprintf(INIFile, "Field_Operation=%d\n", FO_Flag);
fprintf(INIFile, "Track_Number=%d\n", Track_Flag);
fprintf(INIFile, "Channel_Format=%d\n", Format_Flag);
fprintf(INIFile, "AC3=%d\n", AC3_Flag);
fprintf(INIFile, "DR_Control=%d\n", DRC_Flag);
fprintf(INIFile, "DS_Downmix=%d\n", DSDown_Flag);
fprintf(INIFile, "MPA=%d\n", MPA_Flag);
fprintf(INIFile, "SRC_Precision=%d\n", SRC_Flag);
fprintf(INIFile, "Norm_Ratio=%d\n", 100 * Normalization_Flag + Norm_Ratio);
fprintf(INIFile, "Process_Priority=%d\n", Priority_Flag);
fclose(INIFile);
}
Recovery();
for (i=0; i<8; i++)
free(p_block[i]);
free(p_fTempArray);
ReleaseDC(hWnd, hDC);
DeleteObject(hBrush);
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return false;
}
LRESULT CALLBACK VideoList(HWND hVideoListDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int i, j;
switch (message)
{
case WM_INITDIALOG:
if (File_Limit)
for (i=0; i<File_Limit; i++)
SendDlgItemMessage(hVideoListDlg, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)Infilename[i]);
else
OpenVideoFile(hVideoListDlg);
if (File_Limit)
SendDlgItemMessage(hVideoListDlg, IDC_LIST, LB_SETCURSEL, File_Limit-1, 0);
return true;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_ADD:
OpenVideoFile(hVideoListDlg);
if (File_Limit)
SendDlgItemMessage(hVideoListDlg, IDC_LIST, LB_SETCURSEL, File_Limit-1, 0);
break;
case ID_DEL:
if (File_Limit)
{
i= SendDlgItemMessage(hVideoListDlg, IDC_LIST, LB_GETCURSEL, 0, 0);
SendDlgItemMessage(hVideoListDlg, IDC_LIST, LB_DELETESTRING, i, 0);
_close(Infile[i]);
File_Limit--;
for (j=i; j<File_Limit; j++)
{
Infile[j] = Infile[j+1];
strcpy(Infilename[j], Infilename[j+1]);
}
SendDlgItemMessage(hVideoListDlg, IDC_LIST, LB_SETCURSEL, i>=File_Limit ? File_Limit-1 : i, 0);
}
break;
case IDOK:
case IDCANCEL:
EndDialog(hVideoListDlg, 0);
ResizeWindow(INIT_WIDTH, INIT_HEIGHT);
Recovery();
if (File_Limit)
{
process.rightfile = File_Limit-1;
process.rightlba = (int)(process.length[File_Limit-1]/BUFFER_SIZE);
process.end = process.total - BUFFER_SIZE;
process.endfile = File_Limit - 1;
process.endloc = (process.length[File_Limit-1]/BUFFER_SIZE - 1)*BUFFER_SIZE;
process.locate = LOCATE_INIT;
if (!threadId || WaitForSingleObject(hThread, INFINITE)==WAIT_OBJECT_0)
hThread = CreateThread(NULL, 0, MPEG2Dec, 0, 0, &threadId);
}
return true;
}
break;
}
return false;
}
static void OpenVideoFile(HWND hVideoListDlg)
{
char seq;
if (PopFileDlg(szInput, hVideoListDlg, OPEN_VOB))
{
while (_findfirst(szInput, &seqfile) != -1L)
{
SendDlgItemMessage(hVideoListDlg, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)szInput);
strcpy(Infilename[File_Limit], szInput);
Infile[File_Limit] = _open(szInput, _O_RDONLY | _O_BINARY);
File_Limit++;
strncpy(&seq, szInput+strlen(szInput)-5, 1);
if (seq<'9')
seq++;
else
break;
strncpy(szInput+strlen(szInput)-5, &seq, 1);
}
}
}
LRESULT CALLBACK AudioList(HWND hAudioListDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int i, j;
switch (message)
{
case WM_INITDIALOG:
File_Limit = 0;
OpenAudioFile(hAudioListDlg);
return true;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case ID_ADD:
OpenAudioFile(hAudioListDlg);
break;
case ID_DEL:
if (File_Limit)
{
i= SendDlgItemMessage(hAudioListDlg, IDC_LIST, LB_GETCURSEL, 0, 0);
SendDlgItemMessage(hAudioListDlg, IDC_LIST, LB_DELETESTRING, i, 0);
File_Limit--;
for (j=i; j<File_Limit; j++)
{
strcpy(Infilename[j], Infilename[j+1]);
strcpy(Outfilename[j], Outfilename[j+1]);
SoundDelay[j] = SoundDelay[j+1];
}
SendDlgItemMessage(hAudioListDlg, IDC_LIST, LB_SETCURSEL, i>=File_Limit ? File_Limit-1 : i, 0);
}
break;
case IDOK:
case IDCANCEL:
EndDialog(hAudioListDlg, 0);
if (File_Limit)
{
ShowStatistics(1);
if (!threadId || WaitForSingleObject(hThread, INFINITE)==WAIT_OBJECT_0)
hThread = CreateThread(NULL, 0, ProcessWAV, (void *)File_Limit, 0, &threadId);
}
return true;
}
break;
}
return false;
}
static void OpenAudioFile(HWND hAudioListDlg)
{
if (PopFileDlg(szInput, hAudioListDlg, OPEN_WAV))
{
if (!CheckWAV())
{
DialogBox(hInst, (LPCTSTR)IDD_ERROR, hAudioListDlg, (DLGPROC)About);
return;
}
if (PopFileDlg(szOutput, hAudioListDlg, SAVE_WAV))
{
strcpy(Infilename[File_Limit], szInput);
strcpy(Outfilename[File_Limit], szOutput);
DialogBox(hInst, (LPCTSTR)IDD_DELAY, hWnd, (DLGPROC)Delay);
sprintf(szBuffer, "%s %dms", szInput, SoundDelay[File_Limit]);
SendDlgItemMessage(hAudioListDlg, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)szBuffer);
File_Limit++;
}
}
if (File_Limit)
SendDlgItemMessage(hAudioListDlg, IDC_LIST, LB_SETCURSEL, File_Limit-1, 0);
}
DWORD WINAPI ProcessWAV(LPVOID n)
{
int i;
Stop_Flag = false;
EnableMenuItem(hMenu, IDM_OPEN, MF_GRAYED);
EnableMenuItem(hMenu, IDM_PROCESS_WAV, MF_GRAYED);
EnableMenuItem(hMenu, IDM_LOAD_D2V, MF_GRAYED);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -