complex.c
资源名称:melpfix.rar [点击查看]
上传用户:cxx_68
上传日期:2021-02-21
资源大小:161k
文件大小:3k
源码类别:
语音压缩
开发平台:
Visual C++
- /*
- 2.4 kbps MELP Proposed Federal Standard speech coder
- Fixed-point C code, version 1.0
- Copyright (c) 1998, Texas Instruments, Inc.
- Texas Instruments has intellectual property rights on the MELP
- algorithm. The Texas Instruments contact for licensing issues for
- commercial and non-government use is William Gordon, Director,
- Government Contracts, Texas Instruments Incorporated, Semiconductor
- Group (phone 972 480 7442).
- The fixed-point version of the voice codec Mixed Excitation Linear
- Prediction (MELP) is based on specifications on the C-language software
- simulation contained in GSM 06.06 which is protected by copyright and
- is the property of the European Telecommunications Standards Institute
- (ETSI). This standard is available from the ETSI publication office
- tel. +33 (0)4 92 94 42 58. ETSI has granted a license to United States
- Department of Defense to use the C-language software simulation contained
- in GSM 06.06 for the purposes of the development of a fixed-point
- version of the voice codec Mixed Excitation Linear Prediction (MELP).
- Requests for authorization to make other use of the GSM 06.06 or
- otherwise distribute or modify them need to be addressed to the ETSI
- Secretariat fax: +33 493 65 47 16.
- */
- /* Complexity counting functions */
- #include <stdio.h>
- #include "spbstd.h"
- extern int complexity, saturation;
- #define MAX_CMPLX 50
- long cm_max[MAX_CMPLX];
- long max_complexity;
- long prev_complexity;
- long sat_cnt[MAX_CMPLX];
- long prev_saturation = 0;
- static long frame = 0;
- int cm_index;
- /* Complexity_count: update max counter for current index */
- int complexity_count()
- {
- long temp;
- /* 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;
- long cm_total = 0;
- 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);
- }