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

📄 lib_wmp_fx.c

📁 完整的EVRC压缩解压缩算法源码,通过C-C++编译后可以运行!
💻 C
📖 第 1 页 / 共 3 页
字号:
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS :                                                */
/*         _ (Word32)   delta:  the number of weighted operations.    */
/*===================================================================*/

Word32 WMP_fwc_fx (char func_name [])
	{
	 /*-------------------------------------------------------------------*/
	 
	 Word32	wmops;
	 Word16  funcid;

	 /*-------------------------------------------------------------------*/
	 
	 wmops = WMP_calcul_delta_WMOPS_fx ();
	 
	 funcid = WMP_hash_fx(func_name);

	 if (wmops > wc_fx[funcid])
	   {
	     wc_fx[funcid] = wmops;
	     strcpy(wc_fn_fx [funcid], func_name); 
	   } 

	 /*-------------------------------------------------------------------*/
	 
	 return wmops;
	 
	 /*-------------------------------------------------------------------*/
	}

/*----------------------------------------------------------------------------*/

/*===================================================================*/
/* FUNCTION  : WMP_calcul_stat_fx ().                                */
/*-------------------------------------------------------------------*/
/* PURPOSE   : These functions extract the counter status for the    */
/*             fixed point WMOPS at the end of each frame processing */
/*             and calculate the stats.                              */
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS  :                                                */
/*      _ (Word32)   frame:  the number of frames.                    */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS :                                                */
/*                      _ None.                                      */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS :                                          */
/*                      _ None.                                      */
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS :                                                */
/*    _ (Word40)  frame_wmops:   the number of weighted operations  */
/*                                for the current frame.             */
/*===================================================================*/

Word40 WMP_calcul_stat_fx (Word32 frame)
	{
	 /*-------------------------------------------------------------------*/
	 
	 Word32	 wmops;
	 Word40 frame_wmops;
	 
	 /*-------------------------------------------------------------------*/
	 /*                Extract the WMOPS for the current frame            */
	 /*-------------------------------------------------------------------*/
	 
	 wmops = WMP_calcul_total_WMOPS_fx ();
	 
	 /*-------------------------------------------------------------------*/
	 /*                    Worst Case per Frame Detection                 */
	 /*-------------------------------------------------------------------*/
	 
	 if (wmops > glob_wc_fx)
	   {
	     glob_wc_fx = wmops;
	     wc_frame_fx = frame;
	   }
	 
	 nbframe_fx++;
	 
	 frame_wmops = (Word40)wmops * 0.00005;
	 
	 total_wmops_fx += frame_wmops;
	 
	 /*-------------------------------------------------------------------*/
	 
	 return frame_wmops;
	 
	 /*-------------------------------------------------------------------*/
	}

/*----------------------------------------------------------------------------*/

/*===================================================================*/
/* FUNCTION  : WMP_swap_fx ().                                       */
/*-------------------------------------------------------------------*/
/* PURPOSE   : These functions swap two elements in the array.       */
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS  :                                                */
/*     _ (Word16) i    :  i firt element index.                      */
/*     _ (Word16) j    :  j second element index.                    */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS :                                                */
/*                      _ None.                                      */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS :                                          */
/*     _ (Word32  []) wc    :  array of the mesured worst case.       */
/*     _ (char   []) wc_fn :  array of the the name of the function. */
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS :                                                */
/*                      _ None.                                      */
/*===================================================================*/

void WMP_swap_fx (Word32 wc[], char wc_fn [NB_FUNC_MAX][255], Word16 i, Word16 j)
	{
	 /*-------------------------------------------------------------------*/
	 
	 Word32	temp_wc;
	 char 	tmp_str [255];

	 /*-------------------------------------------------------------------*/

	 temp_wc = wc[i];
	 wc[i]   = wc[j];
	 wc[j]   = temp_wc;

	 /*-------------------------------------------------------------------*/

	 strcpy (tmp_str,  wc_fn[i]);
	 strcpy (wc_fn[i], wc_fn[j]);
	 strcpy (wc_fn[j], tmp_str);

	 /*-------------------------------------------------------------------*/

	 return;

	 /*-------------------------------------------------------------------*/
	}

/*----------------------------------------------------------------------------*/

 
/*===================================================================*/
/* FUNCTION  : WMP_qsort_fx ().                                      */
/*-------------------------------------------------------------------*/
/* PURPOSE   : These functions reorder the Worst Case function  and  */
/*              name.                                                */
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS  :                                                */
/*     _ (Word16 ) left    :  lower index of the array.              */
/*     _ (Word16 ) right   :  higher index of the array.             */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS :                                                */
/*                      _ None.                                      */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS :                                          */
/*     _ (Word32  []) wc    :  array of the mesured wosrt case.       */
/*     _ (char   []) wc_fn :  array of the the name of the function. */
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS :                                                */
/*                      _ None.                                      */
/*===================================================================*/

void WMP_qsort_fx (Word32 wc[], char wc_fn [NB_FUNC_MAX][255], Word16 left,
		   Word16 right)
	{
	 /*-------------------------------------------------------------------*/
	 
	 Word16 i, last;	 

	 /*-------------------------------------------------------------------*/
	 /*           If the array is smaller than 2 just return              */
	 /*-------------------------------------------------------------------*/

	 if (left >= right)
	   return;
	 
	 /*-------------------------------------------------------------------*/
	 /*                      Move the element in wc[0]                    */
	 /*-------------------------------------------------------------------*/
	 
	 WMP_swap_fx (wc, wc_fn, left, (left+right)/2);
	 
	 /*-------------------------------------------------------------------*/
	 /*                             Splitting                             */
	 /*-------------------------------------------------------------------*/
	 
	 last = left;
	 
	 for (i = left+1; i <= right; i++)
	   if (wc[i] > wc[left])
	     WMP_swap_fx (wc, wc_fn, ++last, i);

	 /*-------------------------------------------------------------------*/
	 /*                         Restore the element                       */
	 /*-------------------------------------------------------------------*/

	 WMP_swap_fx  (wc, wc_fn, left, last);

	 WMP_qsort_fx (wc, wc_fn, left, last-1);

	 WMP_qsort_fx (wc, wc_fn, last+1, right);

	 /*-------------------------------------------------------------------*/
	 
	 return;
	 
	 /*-------------------------------------------------------------------*/
	}

/*----------------------------------------------------------------------------*/

/*===================================================================*/
/* FUNCTION  : WMP_print_stat_fx ().                                 */
/*-------------------------------------------------------------------*/
/* PURPOSE   : These functions print the stats for the fixed point   */
/*             WMOPS.                                                */
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS  :                                                */
/*                      _ None.                                      */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS :                                                */
/*                      _ None.                                      */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS :                                          */
/*                      _ None.                                      */
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS :                                                */
/*                      _ None.                                      */
/*===================================================================*/

void WMP_print_stat_fx (void)
	{
	 /*-------------------------------------------------------------------*/
	 
	 Word16	 i;
	 Word32	 tot_wc;
	 
	 /*-------------------------------------------------------------------*/
	 /*                 Print Average WMOPS and the WORST case            */
	 /*-------------------------------------------------------------------*/

	 fprintf (stdout, "\n\n  WMIPS FIXED POINT COMPLEXITY ESTIMATION\n");
	 fprintf (stdout, "\n  Average=%.2f", 
		  total_wmops_fx/(Word40) nbframe_fx);

	 fprintf (stdout, "  WorstCase=%.2f at frame %d", 
		  ((Word40) glob_wc_fx) * 0.00005,  wc_frame_fx);

	 /*-------------------------------------------------------------------*/
	 /*                  Calculate the WORST cummulate case               */
	 /*-------------------------------------------------------------------*/
	 
	 tot_wc = 0L;
	 for (i = 0; i < NB_FUNC_MAX; i++)
	   if (strcmp(wc_fn_fx [i], ""))
	     tot_wc += wc_fx[i];
		
	 /*-------------------------------------------------------------------*/
	 
	 fprintf (stdout, " Sum of WorstWC=%.2f", ((Word40) tot_wc) * 0.00005);
	 fprintf (stdout, "\n");

	 /*-------------------------------------------------------------------*/
	 /*                         Sorting of worst case                     */
	 /*-------------------------------------------------------------------*/

	 fprintf (stdout, "\n");

	 WMP_qsort_fx (wc_fx, wc_fn_fx, 0, NB_FUNC_MAX-1);

	 for (i = 0; i < NB_FUNC_MAX; i++)
	   if ((wc_fx[i] != 0) && (strcmp(wc_fn_fx [i], "")))
	     fprintf (stdout, "\n%s\t\t%.2f ", wc_fn_fx[i], wc_fx[i]*0.00005);

	 fprintf (stdout, "\n");

	 /*-------------------------------------------------------------------*/
	 
	 return;
	 
	 /*-------------------------------------------------------------------*/
	}

/*----------------------------------------------------------------------------*/

#endif

/*============================================================================*/
/*------------------------------------- END ----------------------------------*/
/*============================================================================*/

⌨️ 快捷键说明

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