⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 edge.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: edge.cpp,v 1.2.32.1 2004/07/09 02:00:18 hubbe Exp $ *  * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. *  * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks.  You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL.  Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. *  * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. *  * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. *  * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. *  * Technology Compatibility Kit Test Suite(s) Location: *    http://www.helixcommunity.org/content/tck *  * Contributor(s): *  * ***** END LICENSE BLOCK ***** */#include "hxtypes.h"#include "hxcom.h"#include "edge.h"#include "hlxclib/math.h"// Lookup tables to perform luma image enhancementint soft_core_2d[LUT_LENGTH];int clip_softcore_post[CLIP_TABLE_LENGTH];int soft_core_2d88[LUT_LENGTH];#define lut_soft_core_2d (soft_core_2d+OFFSET_SOFTCORE)#define lut_soft_core_2d88 (soft_core_2d88+OFFSET_SOFTCORE)#define lut_clip_softcore_post (clip_softcore_post+OFFSET_CLIP_SOFTCORE)float g_fCurrentSharpness = 0.0;INT16 g_nCurrentExpand = 0 ;void HXEXPORTENTRYPOINT(SetSharpnessAdjustments)(float Sharpness, INT16 nExpand){    //Initialize edge enhancemnt lookup table    //adjust the Sharpness parameter input range [-1,1] to output range [0,MAX_B]    g_fCurrentSharpness = Sharpness;    g_nCurrentExpand = nExpand;    Sharpness += 1.0;        if(nExpand)    {	Sharpness *= (ZOOM_BOOST*MAX_B/2.0);    }    else    {	Sharpness *= (MAX_B/2.0);    }    Inittriangleluts(DEFT_C,DEFT_A,Sharpness);   }void HXEXPORTENTRYPOINT(GetSharpnessAdjustments)(float* pSharpness, INT16* pnExpand){    *pSharpness = g_fCurrentSharpness;    *pnExpand	= g_nCurrentExpand;}void HXEXPORTENTRYPOINT(Enhance)(UCHAR *yuv420in, INT32 inheight, INT32  inwidth, INT32 pitchSrc, float Sharpness){    int     row, curBuf, prevBuf;    unsigned char  *pLuma;    static int  helper[2][2][HELPER_MAXLEN];        static int first_fl=1;    float tolerance=(float)0.1;    int tmp1;	    if ((inwidth > HELPER_MAXLEN) || (inheight <16))	{		return ;	}    //if Sharpness is -1.0 (or close) do not do any edge enhancement    if(((Sharpness+1.0)<tolerance) && ((Sharpness+1.0)>-tolerance))    {	return ;    }    if(first_fl==1)    {			//Initialize constant edge enhancemnt lookup table to defaults for the first time	/*Inittriangleluts(DEFT_C,DEFT_A,DEFT_B);*/	Inittrianglelutsconst();	//initialize clipping table	Initcliplut();	first_fl=0;	}    curBuf = 0;         // Point to "current" line buffer    pLuma = yuv420in;    // Point to beginning of current line    DiffNonLin2Dconst( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );    DiffNonLin2Dconst( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	    for (row = 1; row < inheight-9; row=row+8) {	//(1)	prevBuf = curBuf;   // Point to previous line buffer	curBuf ^= 1;        // Add 1 modulo 2	pLuma +=pitchSrc;   // Advance pointer to next row	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );        DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(2)	prevBuf = curBuf;           curBuf ^= 1;       	pLuma +=pitchSrc;  	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(3)	prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc;  	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(4)	prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc;   	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(5)	prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc;   	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(6)	prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//2edge pixels------------------	//(7)        prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc;	DiffNonLin2Dconst( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2Dconst( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );        Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(8)        prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc;	DiffNonLin2Dconst( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2Dconst( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );        Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );    }    tmp1=(inheight-((inheight>>3)<<3))-1;    switch(tmp1)    {    case 6:	 //(1)	prevBuf = curBuf;   	curBuf ^= 1;        	pLuma +=pitchSrc;			DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );    case 5:	//(2)	prevBuf = curBuf;  	curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );    case 4:	//(3)	prevBuf = curBuf;  	curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );    case 3:	//(4)	prevBuf = curBuf;   	curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );        case 2:	//(5)	prevBuf = curBuf;   	curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );    case 1:	//(6)	prevBuf = curBuf;   	curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2D( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2D( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );    case 0:	break;    }    return ;}void HXEXPORTENTRYPOINT(EnhanceUniform)(UCHAR *yuv420in, INT32 inheight, INT32  inwidth, INT32 pitchSrc, float Sharpness){    int     row, curBuf, prevBuf;    unsigned char  *pLuma;    static int  helper[2][2][HELPER_MAXLEN];        static int first_fl=1;    float tolerance=(float)0.1;    int tmp1;	        if ((inwidth > HELPER_MAXLEN) || (inheight <16))    {	return ;	    }    //if Sharpness is -1.0 (or close) don not do any edge enhancement    if(((Sharpness+1.0)<tolerance) && ((Sharpness+1.0)>-tolerance))    {	return ;    }    if(first_fl==1)    {			//Initialize edge enhancemnt lookup table to defaults for the first time	Inittriangleluts(DEFT_C,DEFT_A,DEFT_B);	//initialize clipping table	Initcliplut();	first_fl=0;    }    curBuf = 0;         // Point to "current" line buffer    pLuma = yuv420in;    // Point to beginning of current line    DiffNonLin2Duniform( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );    DiffNonLin2Duniform( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	    for (row = 1; row < inheight-9; row=row+8) {	//(1)	prevBuf = curBuf;   // Point to previous line buffer        curBuf ^= 1;        // Add 1 modulo 2	pLuma +=pitchSrc;   // Advance pointer to next row        DiffNonLin2Duniform( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );        DiffNonLin2Duniform( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(2)	prevBuf = curBuf;   	curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2Duniform( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2Duniform( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(3)	prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2Duniform( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2Duniform( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(4)	prevBuf = curBuf;           curBuf ^= 1;       	pLuma +=pitchSrc; 	DiffNonLin2Duniform( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2Duniform( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(5)	prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2Duniform( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2Duniform( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(6)	prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc; 	DiffNonLin2Duniform( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2Duniform( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );	Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//2edge pixels------------------	//(7)        prevBuf = curBuf;          curBuf ^= 1;        	pLuma +=pitchSrc;	DiffNonLin2Duniform( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2Duniform( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );        Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );	//(8)        prevBuf = curBuf;           curBuf ^= 1;        	pLuma +=pitchSrc;	DiffNonLin2Duniform( &pLuma[pitchSrc], &pLuma[1], helper[curBuf][0], inwidth-1 );	DiffNonLin2Duniform( &pLuma[pitchSrc+1], &pLuma[0], helper[curBuf][1], inwidth-1 );        Add2DHelper( (int *)helper[curBuf], (int *)helper[prevBuf], &pLuma[1], inwidth-2 );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -