complex.c
上传用户:csczyc
上传日期:2021-02-19
资源大小:1051k
文件大小:2k
- /* Complexity counting functions */
- #include <stdio.h>
- #include "spbstd.h"
- extern int complexity, saturation;
- #define MAX_CMPLX 50
- int cm_max[MAX_CMPLX];//mark
- int max_complexity;//mark
- int prev_complexity;//mark
- int sat_cnt[MAX_CMPLX];//mark
- int prev_saturation = 0;//mark
- static int frame = 0;//mark
- int cm_index;
- /* Complexity_count: update max counter for current index */
- int complexity_count()
- {
- int temp;//mark
- /* Check maximum complexity for current index */
- temp = complexity - prev_complexity;
- if (temp > cm_max[cm_index])
- cm_max[cm_index] = temp;
- /* Check for saturations */
- temp = saturation - prev_saturation;
- if (temp > 0) {
- sat_cnt[cm_index] += temp;
- printf("%d saturations in frame %d, index %dn",
- (int) temp, (int) frame, (int) cm_index);
- }
- /* Increment index and previous value */
- cm_index++;
- prev_complexity = complexity;
- prev_saturation = saturation;
- /* Check overall total complexity */
- if (complexity > max_complexity)
- max_complexity = complexity;
- return(0);
- }
- /* Complexity_reset: reset counters */
- int complexity_reset()
- {
- cm_index = 0;
- complexity = 0;
- prev_complexity = 0;
- frame++;
- return(0);
- }
- /* Complexity_print: print final complexity */
- #define C_MOPS ((1.0/1000000)*8000/180) /* convert complexity to WMOPS */
- int complexity_print()
- {
- int i;
- int cm_total = 0;//mark
- printf("Worst case total WMOPS = %6.2f, saturations = %dn",
- max_complexity*C_MOPS, saturation);
- printf("Individual cases:n");
- for (i = 0; i < MAX_CMPLX; i++) {
- if (cm_max[i] == 0) {
- printf("Sum of worst cases = %6.2fn",cm_total*C_MOPS);
- break;
- }
- else
- printf("%6.2f %dn",cm_max[i]*C_MOPS,(int) sat_cnt[i]);
- cm_total += cm_max[i];
- }
- return(0);
- }
-