📄 m2decdll.cpp
字号:
// m2decdll.cpp : Defines the initialization routines for the DLL.
//
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "config.h"
#include "global.h"
#include "io.h"
#include "math.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <fcntl.h>
#include "io.h"
#include "windowsx.h"
#include <math.h>
static AFX_EXTENSION_MODULE M2decdllDLL = { NULL, NULL };
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved);
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("M2DECDLL.DLL Initializing!\n");
// Extension DLL one-time initialization
if (!AfxInitExtensionModule(M2decdllDLL, hInstance))
return 0;
// Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result.
new CDynLinkLibrary(M2decdllDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("M2DECDLL.DLL Terminating!\n");
// Terminate the library before destructors are called
AfxTermExtensionModule(M2decdllDLL);
}
return 1; // ok
}
extern "C" HANDLE WINAPI OpenMpeg(char* infile,void *Cal)
{
// ::MessageBox(NULL,NULL,"OpenMpeg1",MB_OK);
HANDLE filehandle=OpenMpeg2(infile, NULL);
return filehandle;
}
extern "C" BOOL WINAPI GetHeader(HANDLE filehandle, header_data *head)
{
// ::MessageBox(NULL,NULL,"GetHeader",MB_OK);
long total;
char temp[16];
total=head->totalframe;
memset(head,1,sizeof(header_data));
// if()
if(!filehandle)
{
head->totalframe=0;
return false;
}
OK_ID=false;
memset(temp,0,16);
lseek(ld->Infile,-16l,SEEK_END);
read(ld->Infile,temp,16);
int i=0;
while(1)
{
if((temp[i]=='0')&&(temp[i+1]=='0')&&(temp[i+2]=='o')&&(temp[i+3]=='k'))
{
break;
}
if(i>8)
break;
i++;
}
if(i>8)
{
OK_ID=false;
}
else
{
OK_ID=true;
}
lseek(ld->Infile,0l,SEEK_SET);
GetHeader1(filehandle);
GetTotal(filehandle,&total);
TotalFrame=total;
head->headsize=sizeof(header_data);
head->totalframe=total;
head->aspect_ratio_information=aspect_ratio_information;
head->bit_rate=bit_rate;
head->chroma_format=chroma_format;
head->color_primaries=color_primaries;
head->display_horizontal_size=display_horizontal_size;
head->display_vertical_size=display_vertical_size;
head->frame_rate=frame_rate;
if(fabs(factor-1.000)>0.001)
head->horizontal_size=WIDTHBYTES((int)((double)horizontal_size*factor))*8;
else
head->horizontal_size=horizontal_size;
head->matrix_coefficients=matrix_coefficients;
head->mb_height=mb_height;
head->mb_width=mb_width;
head->transfer_characteristics=transfer_characteristics;
head->vertical_size=vertical_size;
head->video_format=video_format;
return true;
}
extern "C" short WINAPI MpegDecode(HANDLE filehandle,long frameno,long framenum,short Mode,unsigned char* dst,long stride)
{
// ::MessageBox(NULL,NULL,"MpegDecode",MB_OK);
if(!filehandle)
return 0;
short num=DecodeMpeg2(filehandle,dst,framenum,frameno+1,Mode,stride);
return num;
}
extern "C" void WINAPI CloseMpeg(HANDLE filehandle)
{
// ::MessageBox(NULL,NULL,"CloseMpeg",MB_OK);
CloseMpeg2(filehandle);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -