📄 codecapi.cpp
字号:
/*****************************************************************************
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
****************************************************************************/
#ifdef __SYMBIAN32__
#include <e32std.h>
#include <e32base.h>
GLDEF_C TInt E32Dll(TDllReason){ return KErrNone; }
#else
#endif
#define SUPPORTED_CODEC_VERSION 310
#include "Rules.h"
#include "Util.h"
#include "VideoCodec.h"
#if defined LINUX || defined __SYMBIAN32__
extern"C"{
#endif
//----------------------------
// communication functions
void *InitCodec(dword sx, dword sy, dword fcc, dword codec_version, void *profiler);
void CloseCodec(void *handle);
int DecodeFrame(void *handle, const void *buf, dword sz_in, const byte *&y, const byte *&u, const byte *&v, dword &pitch, bool dropping);
dword Version();
#if defined LINUX || defined __SYMBIAN32__
}
#endif
//----------------------------
dword Version(){
return SUPPORTED_CODEC_VERSION;
}
//----------------------------
#define FCC(a, b, c, d) dword((d<<24) | (c<<16) | (b<<8) | a)
//----------------------------
void *InitCodec(dword sx, dword sy, dword fcc, dword codec_version, void *profiler){
if(codec_version<SUPPORTED_CODEC_VERSION || codec_version>500)
return NULL;
{
//make the fcc lower-case
char *cp = (char*)&fcc;
for(int i=0; i<4; i++){
char &c = cp[i];
if(c>='A' && c<='Z')
c += 'a' - 'A';
}
}
switch(fcc){
case FCC('x', 'v', 'i', 'd'):
case FCC('d', 'i', 'v', 'x'):
case FCC('d', 'x', '5', '0'):
case FCC('3', 'i', 'v', '2'):
case FCC('3', 'i', 'v', 'x'):
break;
default:
return NULL;
}
C_mp4_decode *dec = CreateMp4Decode(sx, sy, profiler);
if(!dec){
#ifdef __PALMOS__
void Info(const char*, dword=0);
Info("Core MP4: not enough memory for initialization");
#endif
return NULL;
}
return dec;
}
//----------------------------
void CloseCodec(void *handle){
C_mp4_decode *dec = (C_mp4_decode*)handle;
delete dec;
}
//----------------------------
int DecodeFrame(void *handle, const void *buf, dword sz_in, const byte *&y, const byte *&u, const byte *&v, dword &pitch, bool dropping){
C_mp4_decode *dec = (C_mp4_decode*)handle;
S_yuv_image out;
if(!dec->Process((byte*)buf, sz_in, (int)dropping, out))
return 0;
y = out.y;
u = out.u;
v = out.v;
pitch = out.pitch;
return 1;
}
//----------------------------
#ifdef __PALMOS__
extern"C"
void *DllMain(dword ord){
switch(ord){
case 1: return (void*)&InitCodec;
case 2: return (void*)&CloseCodec;
case 3: return (void*)&DecodeFrame;
}
return NULL;
}
#endif
//----------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -