📄 tty_dec.c
字号:
if( sub(num,best_num) > 0 )
{
best_num = num;
best_counter = counter_hist[i];
best_char = char_hist[i];
best_rate = tty_rate_hist[i];
}
}
}
/* If best guess is silence */
if( ((best_counter & (TTY_SILENCE|NON_TTY|TTY_EIGHTH_RATE|TTY_ONSET)) != 0)
|| ( sub(best_counter,counter_hist[CURRENT_FRAME+1]) == 0
&& sub(best_char,char_hist[CURRENT_FRAME+1]) == 0 )
)
{
/* Fix only this FER */
counter_hist[CURRENT_FRAME] = best_counter;
char_hist[CURRENT_FRAME] = best_char;
tty_rate_hist[CURRENT_FRAME] = best_rate;
}
else
{
/*** BEGIN: Not included in SMV TTY code ***/
if( counter_hist[CURRENT_FRAME+1] == NON_TTY )
{
DEBUG(1,fprintf(stdout,"tty_dec(): Force NON_TTY, silence missing.\n");)
counter_hist[CURRENT_FRAME] = NON_TTY;
char_hist[CURRENT_FRAME] = 0;
}
else
{
/*** END: Not included in SMV TTY code ***/
/* else fix a character's worth of frames */
if( best_rate == 0 )
{
/* Correct min of 7 frames for 45.45 baud */
error = sub(CURRENT_FRAME,7);
}
else
{
/* Correct min of 6 frames 50 baud */
error = sub(CURRENT_FRAME,6);
}
for( i=CURRENT_FRAME ; i >= 0 ; i-- )
{
if( sub(i,error) > 0
|| sub(counter_hist[i],best_counter) == 0
|| (counter_hist[i] & (TTY_FER|NON_TTY)) != 0 )
{
counter_hist[i] = best_counter;
char_hist[i] = best_char;
tty_rate_hist[i] = best_rate;
}
else if( sub(counter_hist[i],best_counter) != 0
&& (counter_hist[i] & COUNTER_BETWEEN_START_STOP) != 0 )
{
break;
}
}
}
}
}
/* if eighth rate, keep doing what was done in the last frame */
if( sub(counter_hist[CURRENT_FRAME],TTY_EIGHTH_RATE) == 0 )
{
counter_hist[CURRENT_FRAME] = counter_hist[CURRENT_FRAME+1];
char_hist[CURRENT_FRAME] = char_hist[CURRENT_FRAME+1];
tty_rate_hist[CURRENT_FRAME] = tty_rate_hist[CURRENT_FRAME+1];
}
/*****************************************************************
* If NON_TTY is coming and there is trailing silence, get rid
* of the silence. This helps return to NON_TTY if there was
* a false alarm
******************************************************************/
if( sub(counter_hist[0],NON_TTY) == 0 )
{
for( i=1 ; i <= CURRENT_FRAME ; i++ )
{
if( counter_hist[i] == TTY_SILENCE )
{
counter_hist[i] = NON_TTY;
}
else
{
break;
}
}
}
/*** BEGIN: Not included in SMV TTY code ***/
/*****************************************************************
* Anticipate the transition from NON_TTY to TTY_SILENCE by
* looking ahead when the mode is NON_TTY and vote on the presence
* of TTY_SILENCE. If there is a majority of TTY_SILENCE, change
* the rest of the history buffer from NON_TTY to TTY_SILENCE.
******************************************************************/
/*
* Added if() statement to improve performance in poor C/I conditions
* Do not convert to silence if the output is already silence.
*/
if( counter_hist[CURRENT_FRAME] != TTY_SILENCE )
{
/* Count the number of silence frames */
error = 0;
for( i=0 ; i <= CONVERT_TO_SILENCE_THRESH+1 ; i++ )
{
if( counter_hist[CONVERT_TO_SILENCE_THRESH+1-i] == TTY_SILENCE )
{
error++;
}
else if( counter_hist[CONVERT_TO_SILENCE_THRESH+1-i] == NON_TTY )
{
/* Start over if NON_TTY in middle of silence */
error = 0;
}
}
/* Convert NON_TTY, 8th rate, and FERs to silence */
if( error >= CONVERT_TO_SILENCE_THRESH )
{
for( i=0 ; i <= CURRENT_FRAME ; i++ )
{
if( counter_hist[i] == NON_TTY
|| counter_hist[i] == TTY_EIGHTH_RATE
|| counter_hist[i] == TTY_FER
)
{
counter_hist[i] = TTY_SILENCE;
char_hist[i] = TTY_SILENCE_CHAR;
}
}
}
}
/*** END: Not included in SMV TTY code ***/
/*----------------------------------------------------------------*/
DEBUG(1,
for( i=0 ; i < TTY_BUF_SIZE ; i++ )
{
if( counter_hist[i] == NON_TTY )
fprintf(stdout,"( non )");
else if( counter_hist[i] == TTY_FER )
fprintf(stdout,"( FER )");
else if( counter_hist[i] == TTY_SILENCE && char_hist[i] == TTY_SILENCE_CHAR)
fprintf(stdout," slnce ");
else if( counter_hist[i] == TTY_ONSET && char_hist[i] == TTY_ONSET_CHAR)
fprintf(stdout," onset ");
else if( counter_hist[i] == TTY_EIGHTH_RATE )
fprintf(stdout,"( 8th )");
else
fprintf(stdout,"(%2d,%2d)",10*tty_rate_hist[i]+counter_hist[i],char_hist[i]);
}
fprintf(stdout,"__\n");
if( counter_hist[CURRENT_FRAME] == TTY_FER )
{
fprintf(stdout,"Uncorrected FER.\n");
counter_hist[CURRENT_FRAME] = TTY_SILENCE;
char_hist[CURRENT_FRAME] = TTY_SILENCE_CHAR;
}
)/* end DEBUG() */
/*----------------------------------------------------------------*/
} /* end if(subframe == 0) */
else
{
/* If acb_gain is non-zero at any time in the frame, declare NON_TTY */
if( acb_gain != 0 && !fer_flag )
{
counter_hist[0] = NON_TTY;
char_hist[0] = 0;
}
}
/* Generate the Baudot signal */
i = tty_gen( buf,
length,
subframe,
num_subfr,
counter_hist,
char_hist,
tty_rate_hist );
return(i);
} /* end tty_dec() */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -