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

📄 histogram_system.c

📁 ZPAV (H265) PC(X86) demo ZPAV (H265) 是 音视频 压缩解压 协议
💻 C
字号:

/*
///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//   Copyright (C) 2006-2008  Beijing,  pengzhen (pengzhenxp@yahoo.com.cn)   //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////
*/

static inline void energy_histogram( UINT *hist_data )
{
	int i = 0 ; 
	
	while( i< HISTTOGRAM_COUNT )
	{
		*hist_data = ( (*hist_data) * i ) ;	hist_data++; i++ ; 
	}

}

static inline void get_histogram( HistogramContext* hist, void* data, 
					              int width, int height, int stride )
{
	
	UINT *hist_data = (UINT*)hist->m_pHistogram  ;
	UINT *hist_pos  = (UINT*)hist->m_pHistogramPos  ;

	BYTE*  pix  = (BYTE*)data ;
	
	//int len = (1<<16)/(width * height) ; 
	int stride_diff = stride-width;
	int i , j ;
	
	// init data 
	for(i=0;i< HISTTOGRAM_COUNT ; i++)
	{
		*hist_data = 0 ;	 hist_data++;
		*hist_pos  = i ;	 hist_pos++;
	}
	
	hist_data = (UINT*)hist->m_pHistogram  ;
	hist_pos  = (UINT*)hist->m_pHistogramPos  ;

    // get data 
	i = height ;
	while( i-- )
	{
		j = width ; 
		while( j-- ) 
		{ 
			hist_data[*pix] ++ ; pix ++ ; 
		}
		pix += stride_diff ; 
	}

}


static inline void norm_histogram( void* hist_data_src0, int dh )
{

	//UINT *hist_dest = (UINT*)histogram_dest ; 
	UINT *hist_data_src  = (UINT*)hist_data_src0 ; 

	int i ;

	UINT max_h = 0 , sh ;

	i = HISTTOGRAM_COUNT ; 
	while( i -- ) 
	{
		max_h = MAX( *hist_data_src , max_h ) ; hist_data_src++ ;
	}

	hist_data_src  = (UINT*)hist_data_src0 ;
	sh = ( dh << 16 )/max_h ;
	i = HISTTOGRAM_COUNT ; 
	while( i -- ) 
	{
		*hist_data_src = ( (*hist_data_src) * sh ) >> 16 ;	hist_data_src++;
	}

}


void draw_histogram( BYTE color, void* hist_data0,   
					 BYTE* data, int stride, int dx0, int dy0, int dw, int dh )
{
	UINT *hist_data     = (UINT*)hist_data0 ; 

	int ddx       = dw ;
	int hist_swd  = (1<<16)/ddx ; /* HISTTOGRAM_COUNT = 1<<8 */ 
	//int hist_shd  = (dh) ; /* hist_shd == 1 */

	int x       = 0 ;
	int hist_id = 0 ; 

	int x0, y0 ; 
	int x1, y1 ; 
	
	x0 =  dx0+x; 
    y0 =  dy0+dh-hist_data[(hist_id>>8)]; 
	while ( x <= ddx )  
	{

		hist_id += hist_swd ;  x++ ; /* next */
 
		x1 =  dx0+x ; 
        y1 =  dy0+dh-hist_data[(hist_id>>8)];  

		line_interpolation_data_b( color, data, stride, x0, y0, x1, y1 ) ;

		x0 =  x1 ; 
        y0 =  y1 ; 

	}
	
}





⌨️ 快捷键说明

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