[asterisk-commits] russell: trunk r46330 - in /trunk: ./ main/translate.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Oct 26 09:35:35 MST 2006


Author: russell
Date: Thu Oct 26 11:35:34 2006
New Revision: 46330

URL: http://svn.digium.com/view/asterisk?rev=46330&view=rev
Log:
Merged revisions 46329 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r46329 | russell | 2006-10-26 11:31:05 -0500 (Thu, 26 Oct 2006) | 11 lines

- If the source has no audio or no video portion, do not call powerof() to
  get the format index.
- Don't run through the audio and video loops if there is no audio or video
  portion of the source
If 0 is passed to powerof, it will return -1.  This value of -1 was then being
used as an array index in these loops, which caused a crash on some systems.
Other than this issue, this code works as we expected it to.  If a format is
not in the source, and we have to translation path to it, it is not offered in
the list of acceptable destination formats.
(fixes issue #8231)

........

Modified:
    trunk/   (props changed)
    trunk/main/translate.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/translate.c
URL: http://svn.digium.com/view/asterisk/trunk/main/translate.c?rev=46330&r1=46329&r2=46330&view=diff
==============================================================================
--- trunk/main/translate.c (original)
+++ trunk/main/translate.c Thu Oct 26 11:35:34 2006
@@ -740,17 +740,29 @@
 {
 	unsigned int res = dest;
 	unsigned int x;
-	unsigned int src_audio = powerof(src & AST_FORMAT_AUDIO_MASK);
-	unsigned int src_video = powerof(src & AST_FORMAT_VIDEO_MASK);
+	unsigned int src_audio = src & AST_FORMAT_AUDIO_MASK;
+	unsigned int src_video = src & AST_FORMAT_VIDEO_MASK;
 
 	/* if we don't have a source format, we just have to try all
 	   possible destination formats */
 	if (!src)
 		return dest;
 
+	/* If we have a source audio format, get its format index */
+	if (src_audio)
+		src_audio = powerof(src_audio);
+
+	/* If we have a source video format, get its format index */
+	if (src_video)
+		src_video = powerof(src_video);
+
 	AST_LIST_LOCK(&translators);
 
-	for (x = 1; x < AST_FORMAT_MAX_AUDIO; x <<= 1) {
+	/* For a given source audio format, traverse the list of
+	   known audio formats to determine whether there exists
+	   a translation path from the source format to the
+	   destination format. */
+	for (x = 1; src_audio && x < AST_FORMAT_MAX_AUDIO; x <<= 1) {
 		/* if this is not a desired format, nothing to do */
 		if (!dest & x)
 			continue;
@@ -766,8 +778,11 @@
 			res &= ~x;
 	}
 
-	/* roll over into video formats */
-	for (; x < AST_FORMAT_MAX_VIDEO; x <<= 1) {
+	/* For a given source video format, traverse the list of
+	   known video formats to determine whether there exists
+	   a translation path from the source format to the
+	   destination format. */
+	for (; src_video && x < AST_FORMAT_MAX_VIDEO; x <<= 1) {
 		/* if this is not a desired format, nothing to do */
 		if (!dest & x)
 			continue;



More information about the asterisk-commits mailing list