optimize codec selection and format changing code

force all transcode paths to use AST_FORMAT_SLINEAR as the frames pass through the bridge (can be disabled using the 'transcode_via_sln' setting in th 'options' setting in asteris.conf)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5376 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-04-04 03:28:38 +00:00
parent bbc8c2ce6f
commit e7bbe31f8f
4 changed files with 80 additions and 82 deletions

View File

@@ -437,16 +437,18 @@ int ast_translator_best_choice(int *dst, int *srcs)
{
/* Calculate our best source format, given costs, and a desired destination */
int x,y;
int best=-1;
int bestdst=0;
int best = -1;
int bestdst = 0;
int cur = 1;
int besttime=999999999;
if ((*dst) & (*srcs)) {
int besttime = INT_MAX;
int common;
if ((common = (*dst) & (*srcs))) {
/* We have a format in common */
for (y=0;y<MAX_FORMAT;y++) {
if ((cur & *dst) && (cur & *srcs)) {
for (y=0; y < MAX_FORMAT; y++) {
if (cur & common) {
/* This is a common format to both. Pick it if we don't have one already */
besttime=0;
besttime = 0;
bestdst = cur;
best = cur;
}
@@ -455,17 +457,16 @@ int ast_translator_best_choice(int *dst, int *srcs)
} else {
/* We will need to translate */
ast_mutex_lock(&list_lock);
for (y=0;y<MAX_FORMAT;y++) {
for (y=0; y < MAX_FORMAT; y++) {
if (cur & *dst)
for (x=0;x<MAX_FORMAT;x++) {
if (tr_matrix[x][y].step && /* There's a step */
(tr_matrix[x][y].cost < besttime) && /* We're better than what exists now */
(*srcs & (1 << x))) /* x is a valid source format */
{
best = 1 << x;
bestdst = cur;
besttime = tr_matrix[x][y].cost;
}
for (x=0; x < MAX_FORMAT; x++) {
if ((*srcs & (1 << x)) && /* x is a valid source format */
tr_matrix[x][y].step && /* There's a step */
(tr_matrix[x][y].cost < besttime)) { /* It's better than what we have so far */
best = 1 << x;
bestdst = cur;
besttime = tr_matrix[x][y].cost;
}
}
cur = cur << 1;
}