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

📄 tty_rate.c

📁 完整的EVRC压缩解压缩算法源码,通过C-C++编译后可以运行!
💻 C
📖 第 1 页 / 共 2 页
字号:
/* include portions of the contribution; and at the Organizational   */
/* Partner's sole discretion to permit others to reproduce in whole  */
/* or in part such contributions or the resulting Organizational     */
/* Partner's standards publication. The contributor must also be     */
/* willing to grant licenses under such contributor copyrights to    */
/* third parties on reasonable, non-discriminatory terms and         */
/* conditions, as appropriate.                                       */
/*                                                                   */
/*-------------------------------------------------------------------*/
/*                                                                   */
/* Notice:                                                           */
/* This contribution has been prepared by the contributor to assist  */
/* 3GPP2 Technical Specifications Group C. This document is offered  */
/* to 3GPP2 Technical Specifications Group C as a basis for          */
/* discussion and should not be construed as a binding proposal on   */
/* Lucent Technologies Inc. or any other company.  Specifically,     */
/* Lucent Technologies Inc. reserves the right to modify, amend, or  */
/* withdraw the statements contained herein.                         */
/*                                                                   */
/* Permission is granted to 3GPP2 Technical Specifications Group C   */
/* participants to copy any portion of this document for legitimate  */
/* purposes of 3GPP2 Technical Specifications Group C. Copying for   */
/* monetary gain or other non-3GPP2 Technical Specifications Group C */
/* purposes is prohibited.                                           */
/*                                                                   */
/*-------------------------------------------------------------------*/
/*                                                                   */
/* Grant of license Motorola Inc. grants a free, irrevocable license */
/* to 3GPP2 and its organizational partners to incorporate Motorola- */
/* supplied text or other copyrightable material contained in the    */
/* contribution and any modifications thereof in the creation of     */ 
/* 3GPP2 publications, to copyright and sell in organizational       */
/* partners name any organizational partners standards publications  */
/* even though it may include portions of the contribution; and at   */
/* the organizational partners sole discretion to permit others      */
/* to reproduce in whole or in part such contributions or the        */
/* resulting organizational partners standards publication. Motorola */
/* is also willing to grant licenses under such Motorola copyrights  */
/* to third parties on reasonable, non-discriminatory terms and      */
/* conditions, as appropriate.                                       */
/*                                                                   */
/* Notice:                                                           */
/* This document has been prepared by Motorola Inc. to assist the    */
/* 3GPP2 standards committee. This document is offered to the        */
/* committee as a basis for discussion and should not be considered  */
/* as a binding proposal on Motorola Inc.  or any other company.     */
/* Specifically, Motorola Inc. reserves the right to modify, amend,  */
/* or withdraw the statement contained herein. Permission is granted */
/* to 3GPP2 and its organizational partners to copy any portion of   */
/* this document for the legitimate purposes of the 3GPP2.  Copying  */
/* this document for monetary gain or other non-3GPP2 purpose is     */
/* prohibited.  Motorola Inc. may hold one or more patents of        */
/* copyrights that cover information contained in this contribution, */
/* and agrees that a license under those rights will be made         */
/* available on reasonable and non-discriminatory terms and          */
/* conditions, subject to receiving a reciprocal license in return.  */
/* Nothing contained herein shall be construed as conferring by      */
/* implication, estoppel, or otherwise any license or right under    */
/* any patent, whether or not the use of information herein          */
/* necessarily employs an invention of any existing or later issued  */
/* patent, or copyright.                                             */
/*                                                                   */
/* Notice                                                            */
/* Permission is granted to 3GPP2 participants to copy any portion of*/
/* this contribution for the legitimate purpose of the 3GPP2.        */
/* Copying this contribution for monetary gain or other non-3GPP2    */
/* purpose is prohibited.                                            */
/*                                                                   */
/*-------------------------------------------------------------------*/

/*************************************************************************
* tty_rate()
*   After a character is framed, tty_rate() decides if the character is
*   50 baud or 45.45 baud Baudot code.
**************************************************************************/

#include <stdio.h>
#include "typedef.h"
#include "tty.h"
#include "basic_op.h"


#define TTY_RATE_THRESH         63
#define TTY_RATE_THRESH_2       71
#define MAX_TTY_BAUD_COUNT      3


void tty_rate(
    Word16   *tty_baud_rate,     /* (i/o): prev/new tty baud rate    */
    Word16   tty_bit_len_hist[]  /* (i): bit len buffer              */
)
{
    Word16   i;
    Word16   char_len;

    static Word16    tty_baud_count = MAX_TTY_BAUD_COUNT;


    char_len = 0;                                           
    for( i=START_BIT_IDX ; i < STOP_BIT_IDX ; i++ )
    {
        char_len = add(char_len,tty_bit_len_hist[i]);
    }

    if( sub(char_len,TTY_RATE_THRESH) >= 0 )
    {
        i = TTY_45_BAUD;                                    

	/* 
	* Add the stop bit length and test the total
	* length.  If it is much too short for 45.45
	* baud, change it to 50 baud.
	*/
        char_len = add(char_len,tty_bit_len_hist[STOP_BIT_IDX]);
    if( sub(char_len,TTY_RATE_THRESH_2) < 0 )
	{
	    i = TTY_50_BAUD;
	}
    }
    else
    {
        i = TTY_50_BAUD;                                
    }
                                                        
    if( sub(i,*tty_baud_rate) == 0 )
    {
        tty_baud_count = MAX_TTY_BAUD_COUNT;            
    }
    else
    {
        /*
        *  Switch baud rates if the new rate occured
        *  3 characters in a row.
        */

        tty_baud_count = sub(tty_baud_count,1);
                                                            
        if( tty_baud_count <= 0 )
        {            
            *tty_baud_rate = i;                             
        }
    }


} /* end tty_rate() */


⌨️ 快捷键说明

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