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

📄 timer.h

📁 用MPEG-4对YUV视频文件编码压缩成divx视频文件
💻 H
字号:
#ifndef _ENCORE_TIMER_H
#define _ENCORE_TIMER_H
#include "../user_macro.h"

#if defined(_PROFILING_)

#include "../portab.h"

uint64_t count_frames;

#ifndef _TRIMEDIA

#ifdef WIN32
static __inline int64_t
read_counter()
{
	int64_t ts;
	uint32_t ts1, ts2;

	__asm {
		rdtsc
		mov ts1, eax
		mov ts2, edx
	}

	ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);

	return ts;
}
#else  /*WIN32*/
/* rdtsc command most likely not supported, */
/* so just dummy code here  */
static __inline int64_t
read_counter()
{
	return 0;
}
#endif /* WIN32 */

extern void start_timer();
extern void start_global_timer();
extern void stop_dct_timer();
extern void stop_idct_timer();
extern void stop_motion_timer();
extern void stop_comp_timer();
extern void stop_edges_timer();
extern void stop_inter_timer();
extern void stop_quant_timer();
extern void stop_iquant_timer();
extern void stop_conv_timer();
extern void stop_transfer_timer();
extern void stop_coding_timer();
extern void stop_prediction_timer();
extern void stop_interlacing_timer();
extern void stop_global_timer();
extern void init_timer();
extern void write_timer();

#else /* _TRIMEDIA  */
/*
#undef abs(a)
#include "../clock.h"
#include <tm1/tmProcessor.h>
#include <tsaClock.h>
*/
struct ts
{
	int64_t current;
	int64_t global;
	int64_t overall;
	int64_t dct;
	int64_t idct;
	int64_t quant;
	int64_t iquant;
	int64_t motion;
	int64_t comp;
	int64_t edges;
	int64_t inter;
	int64_t conv;
	int64_t trans;
	int64_t prediction;
	int64_t coding;
	int64_t interlacing;
	int64_t cost;
};
struct ts tim;

/*
   对于200MHzCPU,CYCLES()所使用的低分辨率时钟最大计时为21s
*/
static void inline
start_timer()
{
	tim.current=CYCLES(); 
}

static void inline
stop_cost_timer()
{      
	tim.cost = CYCLES()-tim.current;
}

/* set everything to zero */
static void inline
init_timer()
{       
	count_frames = 0;
	start_timer();
	stop_cost_timer();
/*	tim.cost =0;*/

	tim.dct = tim.quant = tim.idct = tim.iquant = tim.motion =tim.comp = tim.conv =
		tim.edges = tim.inter = tim.interlacing = tim.trans = tim.prediction =
		tim.coding = tim.overall = 0;
}



static void inline
start_global_timer()
{
	tim.global=CYCLES();
}

static void inline
stop_dct_timer()
{      
	tim.dct+=CYCLES()-tim.current;
}

static void inline
stop_idct_timer()
{
	tim.idct+=CYCLES()-tim.current;
}

static void inline
stop_quant_timer()
{
	tim.quant+=CYCLES()-tim.current;
}

static void inline
stop_iquant_timer()
{       
	tim.iquant+=CYCLES()-tim.current;
}

static void inline
stop_motion_timer()
{
	tim.motion+=CYCLES()-tim.current;
}

static void inline
stop_comp_timer()
{
	tim.comp+=CYCLES()-tim.current;
}

static void inline
stop_edges_timer()
{
	tim.edges+=CYCLES()-tim.current;
}

static void inline
stop_inter_timer()
{       
	tim.inter+=CYCLES()-tim.current;
}

static void inline
stop_conv_timer()
{
	tim.conv+=CYCLES()-tim.current;
}

static void inline
stop_transfer_timer()
{
	tim.trans+=CYCLES()-tim.current;
}

static void inline
stop_prediction_timer()
{
	tim.prediction+=CYCLES()-tim.current;
}

static void inline
stop_coding_timer()
{   
	tim.coding+=CYCLES()-tim.current;
}

static void inline
stop_interlacing_timer()
{          
	tim.interlacing+=CYCLES()-tim.current;
}

static void inline
stop_global_timer()
{         
	tim.overall+=CYCLES()-tim.global;
}       
extern void write_timer();
#endif/*  _TRIMEDIA */
     
#else    /*_PROFILING_*/
static __inline void
start_timer()
{
}
static __inline void
start_global_timer()
{
}
static __inline void
stop_dct_timer()
{
}
static __inline void
stop_idct_timer()
{
}
static __inline void
stop_motion_timer()
{
}
static __inline void
stop_comp_timer()
{
}
static __inline void
stop_edges_timer()
{
}
static __inline void
stop_inter_timer()
{
}
static __inline void
stop_quant_timer()
{
}
static __inline void
stop_iquant_timer()
{
}
static __inline void
stop_conv_timer()
{
}
static __inline void
stop_transfer_timer()
{
}
static __inline void
init_timer()
{
}
static __inline void
write_timer()
{
}
static __inline void
stop_coding_timer()
{
}
static __inline void
stop_interlacing_timer()
{
}
static __inline void
stop_prediction_timer()
{
}
static __inline void
stop_global_timer()
{
}
#endif   /* _PROFILING_ */

#endif							/* _TIMER_H_ */

⌨️ 快捷键说明

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