Trees | Indices | Help |
---|
|
1 # -*- Mode: Python -*- 2 # vi:si:et:sw=4:sts=4:ts=4 3 # 4 # Flumotion - a streaming media server 5 # Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com). 6 # All rights reserved. 7 8 # This file may be distributed and/or modified under the terms of 9 # the GNU General Public License version 2 as published by 10 # the Free Software Foundation. 11 # This file is distributed without any warranty; without even the implied 12 # warranty of merchantability or fitness for a particular purpose. 13 # See "LICENSE.GPL" in the source distribution for more information. 14 15 # Licensees having purchased or holding a valid Flumotion Advanced 16 # Streaming Server license may use this file in accordance with the 17 # Flumotion Advanced Streaming Server Commercial License Agreement. 18 # See "LICENSE.Flumotion" in the source distribution for more information. 19 20 # Headers in this file shall remain intact. 2123 """ Get the preferred 'standard' sample rate not exceeded maxrate""" 24 rates = [192000, 96000, 48000, 44100, 32000, 34000, 22050, 16000, 12000, 25 11025, 8000] 26 27 for rate in rates: 28 if rate <= maxrate: 29 return rate 30 31 return 80003234 # maybe better in a hashtable/associative array? 35 # ZAHEER: these really are "magic" limits that i found by trial and 36 # error used 37 # by libvorbis's encoder to determine what maximum samplerate it 38 # accepts for a bitrate, numchannels combo 39 # THOMAS: strangely enough they don't seem to be easily extractable from 40 # vorbis/lib/modes/setup_*.h 41 # might make sense to figure this out once and for all and verify 42 # GStreamer's behaviour as well 43 if channels == 2: 44 if bitrate >= 45000: 45 retval = 50000 46 elif bitrate >= 40000: 47 retval = 40000 48 elif bitrate >= 30000: 49 retval = 26000 50 elif bitrate >= 24000: 51 retval = 19000 52 elif bitrate >= 16000: 53 retval = 15000 54 elif bitrate >= 12000: 55 retval = 9000 56 else: 57 retval = -1 58 59 elif channels == 1: 60 if bitrate >= 32000: 61 retval = 50000 62 elif bitrate >= 24000: 63 retval = 40000 64 elif bitrate >= 16000: 65 retval = 26000 66 elif bitrate >= 12000: 67 retval = 15000 68 elif bitrate >= 8000: 69 retval = 9000 70 else: 71 retval = -1 72 73 return retval74
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Apr 11 07:40:33 2008 | http://epydoc.sourceforge.net |