public void CompareToIsImplemented() { BitRate bitpersecond = BitRate.FromBitsPerSecond(1); Assert.Equal(0, bitpersecond.CompareTo(bitpersecond)); Assert.True(bitpersecond.CompareTo(BitRate.Zero) > 0); Assert.True(BitRate.Zero.CompareTo(bitpersecond) < 0); }
public void EqualsIsImplemented() { var a = BitRate.FromBitsPerSecond(1); var b = BitRate.FromBitsPerSecond(2); Assert.True(a.Equals(a)); Assert.False(a.Equals(b)); Assert.False(a.Equals(null)); }
public override int GetHashCode() { var hashCode = 1182625657; hashCode = hashCode * -1521134295 + Codec.GetHashCode(); hashCode = hashCode * -1521134295 + ChannelLayout.GetHashCode(); hashCode = hashCode * -1521134295 + SampleRate.GetHashCode(); hashCode = hashCode * -1521134295 + BitsPerChannel.GetHashCode(); hashCode = hashCode * -1521134295 + BitRate.GetHashCode(); return(hashCode); }
public void ArithmeticOperators() { BitRate v = BitRate.FromBitsPerSecond(1); AssertEx.EqualTolerance(-1, -v.BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(2, (BitRate.FromBitsPerSecond(3) - v).BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(2, (v + v).BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(10, (v * 10).BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(10, (10 * v).BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(2, (BitRate.FromBitsPerSecond(10) / 5).BitsPerSecond, BitsPerSecondTolerance); AssertEx.EqualTolerance(2, BitRate.FromBitsPerSecond(10) / BitRate.FromBitsPerSecond(5), BitsPerSecondTolerance); }
/// <summary> /// Returns a string that represents the current object. /// </summary> /// <returns>A string that represents the current object.</returns> /// <since_tizen> 3 </since_tizen> public override string ToString() { var toString = $@"MimeType={ MimeType.ToString() }, Channel={ Channel.ToString() }, SampleRate={ SampleRate }, Bit={ Bit.ToString() }, BitRate={ BitRate.ToString() }, BitDepth={ BitDepth.ToString() }, AacType={ AacType.ToString()}"; if (AudioChannelMap != null) { toString += ", AudioChannelMap=" + $"{string.Join(",", AudioChannelMap)}"; } return(toString); }
public override int GetHashCode() { var hashCode = -1742922824; hashCode = hashCode * -1521134295 + Codec.GetHashCode(); hashCode = hashCode * -1521134295 + CodecProfile.GetHashCode(); hashCode = hashCode * -1521134295 + Size.GetHashCode(); hashCode = hashCode * -1521134295 + FrameRateNum.GetHashCode(); hashCode = hashCode * -1521134295 + FrameRateDen.GetHashCode(); hashCode = hashCode * -1521134295 + BitRate.GetHashCode(); return(hashCode); }
public void EqualityOperators() { BitRate a = BitRate.FromBitsPerSecond(1); BitRate b = BitRate.FromBitsPerSecond(2); // ReSharper disable EqualExpressionComparison Assert.True(a == a); Assert.True(a != b); Assert.False(a == b); Assert.False(a != a); // ReSharper restore EqualExpressionComparison }
private void FuckupBitrate(bool enable) { Player p = PlayerWrappers.GetLocalPlayer(); if (enable) { m_originalBitrate = p.vrcPlayer.USpeaker().Bitrate; p.vrcPlayer.USpeaker().Bitrate = BitRate.BitRate_8K; } else { p.vrcPlayer.USpeaker().Bitrate = m_originalBitrate; } }
public void A() { Assert.Equal(100, BitRate.Parse("100bps").Value); Assert.Equal(100, BitRate.Parse("100 bps").Value); Assert.Equal(1, BitRate.Parse("1mbs").Mbps); Assert.Equal(128, BitRate.Parse("128kbs").Kbps); Assert.Equal(0.5, BitRate.Parse("0.5 mbs").Mbps); Assert.Equal(1, BitRate.Parse("1 mbs").Mbps); Assert.Equal(128, BitRate.Parse("128 kbs").Kbps); Assert.Equal(621, BitRate.Parse("0.621 mbs").Kbps); }
public void ComparisonOperators() { BitRate oneBitPerSecond = BitRate.FromBitsPerSecond(1); BitRate twoBitsPerSecond = BitRate.FromBitsPerSecond(2); Assert.True(oneBitPerSecond < twoBitsPerSecond); Assert.True(oneBitPerSecond <= twoBitsPerSecond); Assert.True(twoBitsPerSecond > oneBitPerSecond); Assert.True(twoBitsPerSecond >= oneBitPerSecond); Assert.False(oneBitPerSecond > twoBitsPerSecond); Assert.False(oneBitPerSecond >= twoBitsPerSecond); Assert.False(twoBitsPerSecond < oneBitPerSecond); Assert.False(twoBitsPerSecond <= oneBitPerSecond); }
// Token: 0x06004C39 RID: 19513 RVA: 0x001979D0 File Offset: 0x00195DD0 public void Initialize(BandMode bandMode, BitRate bitrate, FrameDuration duration) { OpusCodec.BitRates bitrate2 = (OpusCodec.BitRates)Enum.GetValues(typeof(OpusCodec.BitRates)).GetValue((int)bitrate); OpusCodec.Opus_Delay delay = (OpusCodec.Opus_Delay)Enum.GetValues(typeof(OpusCodec.Opus_Delay)).GetValue((int)duration); Debug.Log(string.Concat(new string[] { "OpusCodec: Initialize (", bitrate2.ToString(), ", ", delay.ToString(), ")" })); this.InitSettings(48000, (int)bitrate2, (int)delay, FragLabs.Audio.Codecs.Opus.Application.Voip); this.CreateEncoders(); }
public override int GetHashCode() { unchecked { var hashCode = (FullPath != null ? FullPath.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Filename != null ? Filename.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Extension != null ? Extension.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (FormatName != null ? FormatName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (BitRate != null ? BitRate.GetHashCode() : 0); hashCode = (hashCode * 397) ^ FileSize.GetHashCode(); hashCode = (hashCode * 397) ^ DurationInSecs.GetHashCode(); hashCode = (hashCode * 397) ^ VideoStream.GetHashCode(); hashCode = (hashCode * 397) ^ AudioStream.GetHashCode(); return(hashCode); } }
/// Asset initialization (editor only) public void Initialize(AudioClip source, BitRate bitRate) { _channelCount = source.channels; _sampleRate = source.frequency; _bitRate = bitRate; _length = source.length; _textures = new Texture2D[_channelCount]; var format = bitRate == BitRate.High ? TextureFormat.RGBAHalf : TextureFormat.RGBA32; for (var i = 0; i < _channelCount; i++) { _textures[i] = BakeClip(source, i, format); } }
public static void Main(string[] args) { // Console.WriteLine("Please enter the string:"); string[] lines = File.ReadAllLines(fileToEncode); var encodedStrings = new List <BitArray>(); // Build the Huffman tree var i = 0; var wholeText = ""; foreach (string line in lines) { wholeText += line; } Console.WriteLine(i++); HuffmanTree huffmanTree = new HuffmanTree(); huffmanTree.Build(wholeText); BitArray encoded = huffmanTree.Encode(wholeText); encodedStrings.Add(encoded); Console.Write("Encoded: "); Console.WriteLine(); string decoded = huffmanTree.Decode(encoded); foreach (var encodedString in encodedStrings) { byte[] bytes = new byte [encodedString.Length / 8 + (encodedString.Length % 8 == 0 ? 0 : 1)]; encodedString.CopyTo(bytes, 0); File.WriteAllBytes(encodedFileName, bytes); } Console.WriteLine("Compression Ratio: " + CompressionRatio.CalculateHuffman(wholeText, encoded). ToString()); Console.WriteLine("Source BitRate: " + BitRate.Calculate(wholeText).ToString()); Console.WriteLine("Coded BitRate: " + BitRate.Calculate(wholeText, encoded).ToString()); Console.WriteLine("Saving Percentage (File): " + SavingPercentage. CalculateFile(Path.Combine(Environment.CurrentDirectory, fileToEncode), Path.Combine(Environment.CurrentDirectory, encodedFileName)).ToString() + "%"); Console.WriteLine("Saving Percentage: " + SavingPercentage. CalculateHuffmanSavingPercentage(wholeText , encoded).ToString() + "%"); Console.WriteLine("Compression Ratio (File): " + CompressionRatio.CalculateFile (Path.Combine(Environment.CurrentDirectory, fileToEncode), Path.Combine(Environment.CurrentDirectory, encodedFileName)).ToString()); }
static void Main(string[] args) { var encoder = new VideoEncoder(AVCodecID.H264, new VideoFormat(100, 100, AVPixelFormat.Yuv420p, 16), new VideoEncoderParameters { BitRate = BitRate.FromKBitPerSecond(1080), FrameRate = new Fraction(15), GopSize = 15, ResampleFlags = SwsFlags.FastBilinear } ); var memory = new System.IO.MemoryStream(); using (var writer = new MediaWriter(memory).AddEncoder(encoder).Initialize()) { } }
public static int GetBitRate(BitRate bitRate) { int actualBitRate; switch (bitRate) { case BitRate.Low: actualBitRate = 8; break; default: actualBitRate = 16; break; } return(actualBitRate); }
public void ParseTests() { Assert.Equal(1, BitRate.Parse("1").Value); Assert.Equal(1, BitRate.Parse("1000").Kbps); Assert.Equal(1, BitRate.Parse("1000000").Mbps); Assert.Equal(128, BitRate.Parse("128000").Kbps); Assert.Equal(128, BitRate.Parse("128Kb/s").Kbps); // Kb/s Assert.Equal(1, BitRate.Parse("1Mb/s").Mbps); // Mb/s Assert.Equal(128, BitRate.Parse("128 Kb/s").Kbps); // Kb/s Assert.Equal(1, BitRate.Parse("1 Mb/s").Mbps); // Mb/s Assert.Equal(1.5, BitRate.FromMbps(1.5).Mbps); Assert.Equal(1500, BitRate.FromKbps(1.5d).Value); }
/// <summary> /// 番組の表示方法に従って番組の情報を返す /// </summary> /// <returns>番組の表示方法に従った番組の情報</returns> public virtual string GetChannelView() { string view = parentHeadline.HeadlineViewType; if (view.Length != 0) { view = view.Replace("[[RANK]]", Rank) .Replace("[[TITLE]]", Title) .Replace("[[PLAYING]]", Playing) .Replace("[[LISTENER]]", ((Listener != Channel.UNKNOWN_LISTENER_NUM) ? Listener.ToString() : "na")) .Replace("[[LISTENERTOTAL]]", ((ListenerTotal != Channel.UNKNOWN_LISTENER_NUM) ? ListenerTotal.ToString() : "na")) .Replace("[[CATEGORY]]", Category) .Replace("[[BIT]]", ((BitRate != Channel.UNKNOWN_BITRATE) ? BitRate.ToString() : "na")); } return(view); }
public void BitRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() { var quantity = new BitRate(1, BitRateUnit.BitPerSecond); QuantityInfo <BitRateUnit> quantityInfo = quantity.QuantityInfo; Assert.Equal(BitRate.Zero, quantityInfo.Zero); Assert.Equal("BitRate", quantityInfo.Name); Assert.Equal(QuantityType.BitRate, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues <BitRateUnit>().Except(new[] { BitRateUnit.Undefined }).ToArray(); var unitNames = units.Select(x => x.ToString()); // Obsolete members #pragma warning disable 618 Assert.Equal(units, quantityInfo.Units); Assert.Equal(unitNames, quantityInfo.UnitNames); #pragma warning restore 618 }
public override string ToString() { if (Type == "Video") { return(string.Format("Video: {0} / {1:0} kbps / {2}\n", CodecName, BitRate.FromBitsPerSecond((double)Bitrate).KilobitsPerSecond, Description)); } else if (Type == "Audio") { return(string.Format("Audio: {0} / {1} / {2}\n", LanguageName, CodecName, Description)); } else if (Type == "Subtitle") { return(string.Format("Subtitle: {0} / {1:0.00} kbps\n", LanguageName, BitRate.FromBitsPerSecond((double)Bitrate).KilobitsPerSecond)); } return(""); }
public void StartRec(int selectedNumber, VideoCodec selectedCodec, BitRate selectedBitRate, int selectedfps, string folderPath) { if (selectedNumber < screenNamesList.Count) { isScreenCapture = true; sourceNumber = selectedNumber; } else { isScreenCapture = false; sourceNumber = selectedNumber - screenNamesList.Count; } videoCodec = selectedCodec; bitRate = selectedBitRate; fps = selectedfps; this.InitRec(folderPath); }
static void Main(string[] args) { string sourceFileName = "test1.txt"; string compressedFileName = "CompressedFile.txt"; string decompressedFileName = "DecompressedFile.txt"; string source = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, sourceFileName), Encoding.Default); (string compressed, Dictionary <char, ProbabilityInterval> probabilityIntervals) = ArithmeticCoder.Coding(source); //string decompressed = ArithmeticCoder.Decoding(compressed, probabilityIntervals, source.Length); int numOfBytes = compressed.Length / 8; byte[] bytesArray = new byte[numOfBytes]; for (int i = 0; i < numOfBytes; ++i) { bytesArray[i] = Convert.ToByte(compressed.Substring(8 * i, 8), 2); } using (FileStream fs = File.Create(Path.Combine(Environment.CurrentDirectory, compressedFileName))) { fs.Write(bytesArray, 0, bytesArray.Length); } //var compressedFromFileBytes = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, compressedFileName)); //var binaryCompressedStr = string.Join("", compressedFromFileBytes.Select(x => Convert.ToString(x, 2).PadLeft(8, '0'))); //string decompressed = Decoding(binaryCompressedStr, 4); //using (FileStream fs = File.Create(Path.Combine(Environment.CurrentDirectory, decompressedFileName))) //{ // byte[] bytes = Encoding.UTF8.GetBytes(decompressed); // fs.Write(bytes, 0, bytes.Length); //} Console.WriteLine("Compression Ratio: " + CompressionRatio.Calculate(source.Length, bytesArray.Length).ToString()); Console.WriteLine("Compression Ratio (File): " + CompressionRatio.CalculateFile(Path.Combine(Environment.CurrentDirectory, sourceFileName), Path.Combine(Environment.CurrentDirectory, "CompressedFile.txt")).ToString()); Console.WriteLine("Source BitRate: " + BitRate.Calculate(source).ToString()); Console.WriteLine("Coded BitRate: " + BitRate.Calculate(source.Length, compressed.Length).ToString()); Console.WriteLine("Saving Percentage: " + SavingPercentage.Calculate(source.Length, bytesArray.Length).ToString()); Console.WriteLine("Saving Percentage (File): " + SavingPercentage.CalculateFile(Path.Combine(Environment.CurrentDirectory, sourceFileName), Path.Combine(Environment.CurrentDirectory, "CompressedFile.txt")).ToString() + "%"); }
static void Main(string[] args) { string sourceFileName = "test.txt"; string compressedFileName = "CompressedFile.txt"; string decompressedFileName = "DecompressedFile.txt"; string allText = File.ReadAllText(Path.Combine(Environment.CurrentDirectory, sourceFileName), Encoding.Default); string compressed = Compress(allText); //string decompressed = Decompress(compressed, alphabet); int numOfBytes = compressed.Length / 8; byte[] bytesArray = new byte[numOfBytes]; for (int i = 0; i < numOfBytes; ++i) { bytesArray[i] = Convert.ToByte(compressed.Substring(8 * i, 8), 2); } using (FileStream fs = File.Create(Path.Combine(Environment.CurrentDirectory, compressedFileName))) { fs.Write(bytesArray, 0, bytesArray.Length); } var compressedFromFileBytes = File.ReadAllBytes(Path.Combine(Environment.CurrentDirectory, compressedFileName)); string decompressed = Decompress(compressedFromFileBytes); using (FileStream fs = File.Create(Path.Combine(Environment.CurrentDirectory, decompressedFileName))) { byte[] bytes = Encoding.UTF8.GetBytes(decompressed); fs.Write(bytes, 0, bytes.Length); } Console.WriteLine("Compression Ratio: " + CompressionRatio.Calculate(allText.Length, bytesArray.Length).ToString()); Console.WriteLine("Compression Ratio (File): " + CompressionRatio.CalculateFile(Path.Combine(Environment.CurrentDirectory, sourceFileName), Path.Combine(Environment.CurrentDirectory, "CompressedFile.txt")).ToString()); Console.WriteLine("Source BitRate: " + BitRate.Calculate(allText).ToString()); Console.WriteLine("Coded BitRate: " + BitRate.Calculate(allText.Length, compressed.Length).ToString()); Console.WriteLine("Saving Percentage: " + SavingPercentage.Calculate(allText.Length, bytesArray.Length).ToString()); Console.WriteLine("Saving Percentage (File): " + SavingPercentage.CalculateFile(Path.Combine(Environment.CurrentDirectory, sourceFileName), Path.Combine(Environment.CurrentDirectory, "CompressedFile.txt")).ToString() + "%"); }
public static BitRate MegabytesPerSecond <T>(this T value) => BitRate.FromMegabytesPerSecond(Convert.ToDecimal(value));
public static BitRate KilobitsPerSecond <T>(this T value) => BitRate.FromKilobitsPerSecond(Convert.ToDecimal(value));
public void NumberToPebibitsPerSecondTest() => Assert.Equal(BitRate.FromPebibitsPerSecond(2), 2.PebibitsPerSecond());
public void NumberToMegabytesPerSecondTest() => Assert.Equal(BitRate.FromMegabytesPerSecond(2), 2.MegabytesPerSecond());
public void NumberToKilobytesPerSecondTest() => Assert.Equal(BitRate.FromKilobytesPerSecond(2), 2.KilobytesPerSecond());
public void NumberToGigabitsPerSecondTest() => Assert.Equal(BitRate.FromGigabitsPerSecond(2), 2.GigabitsPerSecond());
public void NumberToExbibytesPerSecondTest() => Assert.Equal(BitRate.FromExbibytesPerSecond(2), 2.ExbibytesPerSecond());