// !$*UTF8*$!
{
	archiveVersion = 1;
	classes = {
	};
	objectVersion = 46;
	objects = {

/* Begin PBXBuildFile section */
		45C38ED41C0749A60041CFE5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C38ED11C0749A60041CFE5 /* AppDelegate.swift */; };
		45C38ED51C0749A60041CFE5 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 45C38ED21C0749A60041CFE5 /* Info.plist */; };
		45C38ED61C0749A60041CFE5 /* ExampleTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C38ED31C0749A60041CFE5 /* ExampleTableViewController.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
		455DCBF41C0744F2003D6355 /* AutosizingTableExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AutosizingTableExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
		45C38ED11C0749A60041CFE5 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
		45C38ED21C0749A60041CFE5 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
		45C38ED31C0749A60041CFE5 /* ExampleTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleTableViewController.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
		455DCBF11C0744F2003D6355 /* Frameworks */ = {
			isa = PBXFrameworksBuildPhase;
			buildActionMask = 2147483647;
			files = (
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
		455DCBEB1C0744F2003D6355 = {
			isa = PBXGroup;
			children = (
				45C38ED21C0749A60041CFE5 /* Info.plist */,
				45C38ED11C0749A60041CFE5 /* AppDelegate.swift */,
				45C38ED31C0749A60041CFE5 /* ExampleTableViewController.swift */,
				455DCBF51C0744F2003D6355 /* Products */,
			);
			sourceTree = "<group>";
		};
		455DCBF51C0744F2003D6355 /* Products */ = {
			isa = PBXGroup;
			children = (
				455DCBF41C0744F2003D6355 /* AutosizingTableExample.app */,
			);
			name = Products;
			sourceTree = "<group>";
		};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
		455DCBF31C0744F2003D6355 /* AutosizingTableExample */ = {
			isa = PBXNativeTarget;
			buildConfigurationList = 455DCC061C0744F3003D6355 /* Build configuration list for PBXNativeTarget "AutosizingTableExample" */;
			buildPhases = (
				455DCBF01C0744F2003D6355 /* Sources */,
				455DCBF11C0744F2003D6355 /* Frameworks */,
				455DCBF21C0744F2003D6355 /* Resources */,
			);
			buildRules = (
			);
			dependencies = (
			);
			name = AutosizingTableExample;
			productName = AutosizingTableTest1;
			productReference = 455DCBF41C0744F2003D6355 /* AutosizingTableExample.app */;
			productType = "com.apple.product-type.application";
		};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
		455DCBEC1C0744F2003D6355 /* Project object */ = {
			isa = PBXProject;
			attributes = {
				LastSwiftUpdateCheck = 0710;
				LastUpgradeCheck = 0710;
				ORGANIZATIONNAME = Eonil;
				TargetAttributes = {
					455DCBF31C0744F2003D6355 = {
						CreatedOnToolsVersion = 7.1.1;
					};
				};
			};
			buildConfigurationList = 455DCBEF1C0744F2003D6355 /* Build configuration list for PBXProject "AutosizingTableExample" */;
			compatibilityVersion = "Xcode 3.2";
			developmentRegion = English;
			hasScannedForEncodings = 0;
			knownRegions = (
				en,
				Base,
			);
			mainGroup = 455DCBEB1C0744F2003D6355;
			productRefGroup = 455DCBF51C0744F2003D6355 /* Products */;
			projectDirPath = "";
			projectRoot = "";
			targets = (
				455DCBF31C0744F2003D6355 /* AutosizingTableExample */,
			);
		};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
		455DCBF21C0744F2003D6355 /* Resources */ = {
			isa = PBXResourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				45C38ED51C0749A60041CFE5 /* Info.plist in Resources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
		455DCBF01C0744F2003D6355 /* Sources */ = {
			isa = PBXSourcesBuildPhase;
			buildActionMask = 2147483647;
			files = (
				45C38ED41C0749A60041CFE5 /* AppDelegate.swift in Sources */,
				45C38ED61C0749A60041CFE5 /* ExampleTableViewController.swift in Sources */,
			);
			runOnlyForDeploymentPostprocessing = 0;
		};
/* End PBXSourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
		455DCC041C0744F3003D6355 /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
				CLANG_CXX_LIBRARY = "libc++";
				CLANG_ENABLE_MODULES = YES;
				CLANG_ENABLE_OBJC_ARC = YES;
				CLANG_WARN_BOOL_CONVERSION = YES;
				CLANG_WARN_CONSTANT_CONVERSION = YES;
				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
				CLANG_WARN_EMPTY_BODY = YES;
				CLANG_WARN_ENUM_CONVERSION = YES;
				CLANG_WARN_INT_CONVERSION = YES;
				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
				CLANG_WARN_UNREACHABLE_CODE = YES;
				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
				COPY_PHASE_STRIP = NO;
				DEBUG_INFORMATION_FORMAT = dwarf;
				ENABLE_STRICT_OBJC_MSGSEND = YES;
				ENABLE_TESTABILITY = YES;
				GCC_C_LANGUAGE_STANDARD = gnu99;
				GCC_DYNAMIC_NO_PIC = NO;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_OPTIMIZATION_LEVEL = 0;
				GCC_PREPROCESSOR_DEFINITIONS = (
					"DEBUG=1",
					"$(inherited)",
				);
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				IPHONEOS_DEPLOYMENT_TARGET = 9.1;
				MTL_ENABLE_DEBUG_INFO = YES;
				ONLY_ACTIVE_ARCH = YES;
				SDKROOT = iphoneos;
				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
				TARGETED_DEVICE_FAMILY = "1,2";
			};
			name = Debug;
		};
		455DCC051C0744F3003D6355 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ALWAYS_SEARCH_USER_PATHS = NO;
				CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
				CLANG_CXX_LIBRARY = "libc++";
				CLANG_ENABLE_MODULES = YES;
				CLANG_ENABLE_OBJC_ARC = YES;
				CLANG_WARN_BOOL_CONVERSION = YES;
				CLANG_WARN_CONSTANT_CONVERSION = YES;
				CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
				CLANG_WARN_EMPTY_BODY = YES;
				CLANG_WARN_ENUM_CONVERSION = YES;
				CLANG_WARN_INT_CONVERSION = YES;
				CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
				CLANG_WARN_UNREACHABLE_CODE = YES;
				CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
				COPY_PHASE_STRIP = NO;
				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
				ENABLE_NS_ASSERTIONS = NO;
				ENABLE_STRICT_OBJC_MSGSEND = YES;
				GCC_C_LANGUAGE_STANDARD = gnu99;
				GCC_NO_COMMON_BLOCKS = YES;
				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
				GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
				GCC_WARN_UNDECLARED_SELECTOR = YES;
				GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
				GCC_WARN_UNUSED_FUNCTION = YES;
				GCC_WARN_UNUSED_VARIABLE = YES;
				IPHONEOS_DEPLOYMENT_TARGET = 9.1;
				MTL_ENABLE_DEBUG_INFO = NO;
				SDKROOT = iphoneos;
				TARGETED_DEVICE_FAMILY = "1,2";
				VALIDATE_PRODUCT = YES;
			};
			name = Release;
		};
		455DCC071C0744F3003D6355 /* Debug */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				INFOPLIST_FILE = Info.plist;
				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
				PRODUCT_BUNDLE_IDENTIFIER = Eonil.AutosizingTableTest1;
				PRODUCT_NAME = AutosizingTableExample;
			};
			name = Debug;
		};
		455DCC081C0744F3003D6355 /* Release */ = {
			isa = XCBuildConfiguration;
			buildSettings = {
				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
				INFOPLIST_FILE = Info.plist;
				IPHONEOS_DEPLOYMENT_TARGET = 9.0;
				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
				PRODUCT_BUNDLE_IDENTIFIER = Eonil.AutosizingTableTest1;
				PRODUCT_NAME = AutosizingTableExample;
			};
			name = Release;
		};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
		455DCBEF1C0744F2003D6355 /* Build configuration list for PBXProject "AutosizingTableExample" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				455DCC041C0744F3003D6355 /* Debug */,
				455DCC051C0744F3003D6355 /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
		455DCC061C0744F3003D6355 /* Build configuration list for PBXNativeTarget "AutosizingTableExample" */ = {
			isa = XCConfigurationList;
			buildConfigurations = (
				455DCC071C0744F3003D6355 /* Debug */,
				455DCC081C0744F3003D6355 /* Release */,
			);
			defaultConfigurationIsVisible = 0;
			defaultConfigurationName = Release;
		};
/* End XCConfigurationList section */
	};
	rootObject = 455DCBEC1C0744F2003D6355 /* Project object */;
}

{'repo_name': 'eonil/CocoaProgrammaticHowtoCollection', 'stars': '212', 'repo_language': 'Swift', 'file_name': 'Bootstrapping.xcscheme', 'mime_type': 'text/xml', 'hash': -8049280438551870960, 'source_dataset': 'data'}


using System;
using GitUI;
using NUnit.Framework;

namespace GitExtUtilsTests
{
    [TestFixture]
    public class Win32ApiTests
    {
        [Test]
        public void LParam_to_Point_restores_original_point(
            [Values(short.MinValue, -1, 0, 1, short.MaxValue)] short x,
            [Values(short.MinValue, -1, 0, 1, short.MaxValue)] short y)
        {
            var point = ToLParam(x, y).ToPoint();

            Assert.That(point.X, Is.EqualTo(x));
            Assert.That(point.Y, Is.EqualTo(y));
        }

        [Test]
        public void LParam_to_point_in_ICSharpCode_restores_original_point(
            [Values(short.MinValue, -1, 0, 1, short.MaxValue)] short x,
            [Values(short.MinValue, -1, 0, 1, short.MaxValue)] short y)
        {
            var point = ICSharpCode.TextEditor.Util.Win32Util.ToPoint(ToLParam(x, y));

            Assert.That(point.X, Is.EqualTo(x));
            Assert.That(point.Y, Is.EqualTo(y));
        }

        private static IntPtr ToLParam(short x, short y) =>
            new IntPtr(
                x & 0x0000_FFFF |
                (y & 0x0000_FFFF) << 16);
    }
}

{'repo_name': 'gitextensions/gitextensions', 'stars': '5043', 'repo_language': 'C#', 'file_name': 'AssemblyInfo.cs', 'mime_type': 'text/plain', 'hash': 1188594916852707018, 'source_dataset': 'data'}


/****************************************************************************
 * NVorbis                                                                  *
 * Copyright (C) 2014, Andrew Ward <afward@gmail.com>                       *
 *                                                                          *
 * See COPYING for license terms (Ms-PL).                                   *
 *                                                                          *
 ***************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace NVorbis
{
    class VorbisStreamDecoder : IVorbisStreamStatus, IDisposable
    {
        internal int _upperBitrate;
        internal int _nominalBitrate;
        internal int _lowerBitrate;

        internal string _vendor;
        internal string[] _comments;

        internal int _channels;
        internal int _sampleRate;
        internal int Block0Size;
        internal int Block1Size;

        internal VorbisCodebook[] Books;
        internal VorbisTime[] Times;
        internal VorbisFloor[] Floors;
        internal VorbisResidue[] Residues;
        internal VorbisMapping[] Maps;
        internal VorbisMode[] Modes;

        int _modeFieldBits;

        #region Stat Fields

        internal long _glueBits;
        internal long _metaBits;
        internal long _bookBits;
        internal long _timeHdrBits;
        internal long _floorHdrBits;
        internal long _resHdrBits;
        internal long _mapHdrBits;
        internal long _modeHdrBits;
        internal long _wasteHdrBits;

        internal long _modeBits;
        internal long _floorBits;
        internal long _resBits;
        internal long _wasteBits;

        internal long _samples;

        internal int _packetCount;

        internal System.Diagnostics.Stopwatch _sw = new System.Diagnostics.Stopwatch();

        #endregion

        IPacketProvider _packetProvider;
        DataPacket _parameterChangePacket;

        List<int> _pagesSeen;
        int _lastPageSeen;

        bool _eosFound;

        object _seekLock = new object();

        internal VorbisStreamDecoder(IPacketProvider packetProvider)
        {
            _packetProvider = packetProvider;
            _packetProvider.ParameterChange += SetParametersChanging;

            _pagesSeen = new List<int>();
            _lastPageSeen = -1;
        }

        internal bool TryInit()
        {
            // try to process the stream header...
            if (!ProcessStreamHeader(_packetProvider.PeekNextPacket()))
            {
                return false;
            }

            // seek past the stream header packet
            _packetProvider.GetNextPacket().Done();

            // load the comments header...
            var packet = _packetProvider.GetNextPacket();
            if (!LoadComments(packet))
            {
                throw new InvalidDataException("Comment header was not readable!");
            }
            packet.Done();

            // load the book header...
            packet = _packetProvider.GetNextPacket();
            if (!LoadBooks(packet))
            {
                throw new InvalidDataException("Book header was not readable!");
            }
            packet.Done();

            // get the decoding logic bootstrapped
            InitDecoder();

            return true;
        }

        void SetParametersChanging(object sender, ParameterChangeEventArgs e)
        {
            _parameterChangePacket = e.FirstPacket;
        }

        public void Dispose()
        {
            if (_packetProvider != null)
            {
                var temp = _packetProvider;
                _packetProvider = null;
                temp.ParameterChange -= SetParametersChanging;
                temp.Dispose();
            }
        }

        #region Header Decode

        void ProcessParameterChange(DataPacket packet)
        {
            _parameterChangePacket = null;

            // try to do a stream header...
            var wasPeek = false;
            var doFullReset = false;
            if (ProcessStreamHeader(packet))
            {
                packet.Done();
                wasPeek = true;
                doFullReset = true;
                packet = _packetProvider.PeekNextPacket();
                if (packet == null) throw new InvalidDataException("Couldn't get next packet!");
            }

            // try to do a comment header...
            if (LoadComments(packet))
            {
                if (wasPeek)
                {
                    _packetProvider.GetNextPacket().Done();
                }
                else
                {
                    packet.Done();
                }
                wasPeek = true;
                packet = _packetProvider.PeekNextPacket();
                if (packet == null) throw new InvalidDataException("Couldn't get next packet!");
            }

            // try to do a book header...
            if (LoadBooks(packet))
            {
                if (wasPeek)
                {
                    _packetProvider.GetNextPacket().Done();
                }
                else
                {
                    packet.Done();
                }
            }

            ResetDecoder(doFullReset);
        }

        bool ProcessStreamHeader(DataPacket packet)
        {
            if (!packet.ReadBytes(7).SequenceEqual(new byte[] { 0x01, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 }))
            {
                // don't mark the packet as done... it might be used elsewhere
                _glueBits += packet.Length * 8;
                return false;
            }

            if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen);

            _glueBits += 56;

            var startPos = packet.BitsRead;

            if (packet.ReadInt32() != 0) throw new InvalidDataException("Only Vorbis stream version 0 is supported.");

            _channels = packet.ReadByte();
            _sampleRate = packet.ReadInt32();
            _upperBitrate = packet.ReadInt32();
            _nominalBitrate = packet.ReadInt32();
            _lowerBitrate = packet.ReadInt32();

            Block0Size = 1 << (int)packet.ReadBits(4);
            Block1Size = 1 << (int)packet.ReadBits(4);

            if (_nominalBitrate == 0)
            {
                if (_upperBitrate > 0 && _lowerBitrate > 0)
                {
                    _nominalBitrate = (_upperBitrate + _lowerBitrate) / 2;
                }
            }

            _metaBits += packet.BitsRead - startPos + 8;

            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;

            return true;
        }

        bool LoadComments(DataPacket packet)
        {
            if (!packet.ReadBytes(7).SequenceEqual(new byte[] { 0x03, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 }))
            {
                return false;
            }

            if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen);

            _glueBits += 56;

            _vendor = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32()));

            _comments = new string[packet.ReadInt32()];
            for (int i = 0; i < _comments.Length; i++)
            {
                _comments[i] = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32()));
            }

            _metaBits += packet.BitsRead - 56;
            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;

            return true;
        }

        bool LoadBooks(DataPacket packet)
        {
            if (!packet.ReadBytes(7).SequenceEqual(new byte[] { 0x05, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 }))
            {
                return false;
            }

            if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen);

            var bits = packet.BitsRead;

            _glueBits += packet.BitsRead;

            // get books
            Books = new VorbisCodebook[packet.ReadByte() + 1];
            for (int i = 0; i < Books.Length; i++)
            {
                Books[i] = VorbisCodebook.Init(this, packet, i);
            }

            _bookBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get times
            Times = new VorbisTime[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Times.Length; i++)
            {
                Times[i] = VorbisTime.Init(this, packet);
            }

            _timeHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get floor
            Floors = new VorbisFloor[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Floors.Length; i++)
            {
                Floors[i] = VorbisFloor.Init(this, packet);
            }

            _floorHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get residue
            Residues = new VorbisResidue[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Residues.Length; i++)
            {
                Residues[i] = VorbisResidue.Init(this, packet);
            }

            _resHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get map
            Maps = new VorbisMapping[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Maps.Length; i++)
            {
                Maps[i] = VorbisMapping.Init(this, packet);
            }

            _mapHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get mode settings
            Modes = new VorbisMode[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Modes.Length; i++)
            {
                Modes[i] = VorbisMode.Init(this, packet);
            }

            _modeHdrBits += packet.BitsRead - bits;

            // check the framing bit
            if (!packet.ReadBit()) throw new InvalidDataException();

            ++_glueBits;

            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;

            _modeFieldBits = Utils.ilog(Modes.Length - 1);

            return true;
        }

        #endregion

        #region Data Decode

        float[] _prevBuffer;
        RingBuffer _outputBuffer;
        Queue<int> _bitsPerPacketHistory;
        Queue<int> _sampleCountHistory;
        int _preparedLength;
        internal bool _clipped = false;

        Stack<DataPacket> _resyncQueue;

        long _currentPosition;
        long _reportedPosition;

        VorbisMode _mode;
        bool _prevFlag, _nextFlag;
        bool[] _noExecuteChannel;
        VorbisFloor.PacketData[] _floorData;
        float[][] _residue;
        bool _isParameterChange;

        void InitDecoder()
        {
            _currentPosition = 0L;

            _resyncQueue = new Stack<DataPacket>();

            _bitsPerPacketHistory = new Queue<int>();
            _sampleCountHistory = new Queue<int>();

            ResetDecoder(true);
        }

        void ResetDecoder(bool isFullReset)
        {
            // this is called when:
            //  - init (true)
            //  - parameter change w/ stream header (true)
            //  - parameter change w/o stream header (false)
            //  - the decoder encounters a "hiccup" in the data stream (false)
            //  - a seek happens (false)

            // save off the existing "good" data
            if (_preparedLength > 0)
            {
                SaveBuffer();
            }
            if (isFullReset)
            {
                _noExecuteChannel = new bool[_channels];
                _floorData = new VorbisFloor.PacketData[_channels];

                _residue = new float[_channels][];
                for (int i = 0; i < _channels; i++)
                {
                    _residue[i] = new float[Block1Size];
                }

                _outputBuffer = new RingBuffer(Block1Size * 2 * _channels);
                _outputBuffer.Channels = _channels;
            }
            else
            {
                _outputBuffer.Clear();
            }
            _preparedLength = 0;
        }

        void SaveBuffer()
        {
            var buf = new float[_preparedLength * _channels];
            ReadSamples(buf, 0, buf.Length);
            _prevBuffer = buf;
        }

        bool UnpackPacket(DataPacket packet)
        {
            // make sure we're on an audio packet
            if (packet.ReadBit())
            {
                // we really can't do anything... count the bits as waste
                return false;
            }

            // get mode and prev/next flags
            var modeBits = _modeFieldBits;
            _mode = Modes[(int)packet.ReadBits(_modeFieldBits)];
            if (_mode.BlockFlag)
            {
                _prevFlag = packet.ReadBit();
                _nextFlag = packet.ReadBit();
                modeBits += 2;
            }
            else
            {
                _prevFlag = _nextFlag = false;
            }

            if (packet.IsShort) return false;

            var startBits = packet.BitsRead;

            var halfBlockSize = _mode.BlockSize / 2;

            // read the noise floor data (but don't decode yet)
            for (int i = 0; i < _channels; i++)
            {
                _floorData[i] = _mode.Mapping.ChannelSubmap[i].Floor.UnpackPacket(packet, _mode.BlockSize, i);
                _noExecuteChannel[i] = !_floorData[i].ExecuteChannel;

                // go ahead and clear the residue buffers
                Array.Clear(_residue[i], 0, halfBlockSize);
            }

            // make sure we handle no-energy channels correctly given the couplings...
            foreach (var step in _mode.Mapping.CouplingSteps)
            {
                if (_floorData[step.Angle].ExecuteChannel || _floorData[step.Magnitude].ExecuteChannel)
                {
                    _floorData[step.Angle].ForceEnergy = true;
                    _floorData[step.Magnitude].ForceEnergy = true;
                }
            }

            var floorBits = packet.BitsRead - startBits;
            startBits = packet.BitsRead;

            foreach (var subMap in _mode.Mapping.Submaps)
            {
                for (int j = 0; j < _channels; j++)
                {
                    if (_mode.Mapping.ChannelSubmap[j] != subMap)
                    {
                        _floorData[j].ForceNoEnergy = true;
                    }
                }

                var rTemp = subMap.Residue.Decode(packet, _noExecuteChannel, _channels, _mode.BlockSize);
                for (int c = 0; c < _channels; c++)
                {
                    var r = _residue[c];
                    var rt = rTemp[c];
                    for (int i = 0; i < halfBlockSize; i++)
                    {
                        r[i] += rt[i];
                    }
                }
            }

            _glueBits += 1;
            _modeBits += modeBits;
            _floorBits += floorBits;
            _resBits += packet.BitsRead - startBits;
            _wasteBits += 8 * packet.Length - packet.BitsRead;

            _packetCount += 1;

            return true;
        }

        void DecodePacket()
        {
            // inverse coupling
            var steps = _mode.Mapping.CouplingSteps;
            var halfSizeW = _mode.BlockSize / 2;
            for (int i = steps.Length - 1; i >= 0; i--)
            {
                if (_floorData[steps[i].Angle].ExecuteChannel || _floorData[steps[i].Magnitude].ExecuteChannel)
                {
                    var magnitude = _residue[steps[i].Magnitude];
                    var angle = _residue[steps[i].Angle];

                    // we only have to do the first half; MDCT ignores the last half
                    for (int j = 0; j < halfSizeW; j++)
                    {
                        float newM, newA;

                        if (magnitude[j] > 0)
                        {
                            if (angle[j] > 0)
                            {
                                newM = magnitude[j];
                                newA = magnitude[j] - angle[j];
                            }
                            else
                            {
                                newA = magnitude[j];
                                newM = magnitude[j] + angle[j];
                            }
                        }
                        else
                        {
                            if (angle[j] > 0)
                            {
                                newM = magnitude[j];
                                newA = magnitude[j] + angle[j];
                            }
                            else
                            {
                                newA = magnitude[j];
                                newM = magnitude[j] - angle[j];
                            }
                        }

                        magnitude[j] = newM;
                        angle[j] = newA;
                    }
                }
            }

            // apply floor / dot product / MDCT (only run if we have sound energy in that channel)
            for (int c = 0; c < _channels; c++)
            {
                var floorData = _floorData[c];
                var res = _residue[c];
                if (floorData.ExecuteChannel)
                {
                    _mode.Mapping.ChannelSubmap[c].Floor.Apply(floorData, res);
                    Mdct.Reverse(res, _mode.BlockSize);
                }
                else
                {
                    // since we aren't doing the IMDCT, we have to explicitly clear the back half of the block
                    Array.Clear(res, halfSizeW, halfSizeW);
                }
            }
        }

        int OverlapSamples()
        {
            // window
            var window = _mode.GetWindow(_prevFlag, _nextFlag);
            // this is applied as part of the lapping operation

            // now lap the data into the buffer...

            var sizeW = _mode.BlockSize;
            var right = sizeW;
            var center = right >> 1;
            var left = 0;
            var begin = -center;
            var end = center;

            if (_mode.BlockFlag)
            {
                // if the flag is true, it's a long block
                // if the flag is false, it's a short block
                if (!_prevFlag)
                {
                    // previous block was short
                    left = Block1Size / 4 - Block0Size / 4;  // where to start in pcm[][]
                    center = left + Block0Size / 2;     // adjust the center so we're correctly clearing the buffer...
                    begin = Block0Size / -2 - left;     // where to start in _outputBuffer[,]
                }

                if (!_nextFlag)
                {
                    // next block is short
                    right -= sizeW / 4 - Block0Size / 4;
                    end = sizeW / 4 + Block0Size / 4;
                }
            }
            // short blocks don't need any adjustments

            var idx = _outputBuffer.Length / _channels + begin;
            for (var c = 0; c < _channels; c++)
            {
                _outputBuffer.Write(c, idx, left, center, right, _residue[c], window);
            }

            var newPrepLen = _outputBuffer.Length / _channels - end;
            var samplesDecoded = newPrepLen - _preparedLength;
            _preparedLength = newPrepLen;

            return samplesDecoded;
        }

        void UpdatePosition(int samplesDecoded, DataPacket packet)
        {
            _samples += samplesDecoded;

            if (packet.IsResync)
            {
                // during a resync, we have to go through and watch for the next "marker"
                _currentPosition = -packet.PageGranulePosition;
                // _currentPosition will now be end of the page...  wait for the value to change, then go back and repopulate the granule positions accordingly...
                _resyncQueue.Push(packet);
            }
            else
            {
                if (samplesDecoded > 0)
                {
                    _currentPosition += samplesDecoded;
                    packet.GranulePosition = _currentPosition;

                    if (_currentPosition < 0)
                    {
                        if (packet.PageGranulePosition > -_currentPosition)
                        {
                            // we now have a valid granuleposition...  populate the queued packets' GranulePositions
                            var gp = _currentPosition - samplesDecoded;
                            while (_resyncQueue.Count > 0)
                            {
                                var pkt = _resyncQueue.Pop();

                                var temp = pkt.GranulePosition + gp;
                                pkt.GranulePosition = gp;
                                gp = temp;
                            }
                        }
                        else
                        {
                            packet.GranulePosition = -samplesDecoded;
                            _resyncQueue.Push(packet);
                        }
                    }
                    else if (packet.IsEndOfStream && _currentPosition > packet.PageGranulePosition)
                    {
                        var diff = (int)(_currentPosition - packet.PageGranulePosition);
                        if (diff >= 0)
                        {
                            _preparedLength -= diff;
                            _currentPosition -= diff;
                        }
                        else
                        {
                            // uh-oh.  We're supposed to have more samples to this point...
                            _preparedLength = 0;
                        }
                        packet.GranulePosition = packet.PageGranulePosition;
                        _eosFound = true;
                    }
                }
            }
        }

        void DecodeNextPacket()
        {
            _sw.Start();

            DataPacket packet = null;
            try
            {
                // get the next packet
                var packetProvider = _packetProvider;
                if (packetProvider != null)
                {
                    packet = packetProvider.GetNextPacket();
                }

                // if the packet is null, we've hit the end or the packet reader has been disposed...
                if (packet == null)
                {
                    _eosFound = true;
                    return;
                }

                // keep our page count in sync
                if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen);

                // check for resync
                if (packet.IsResync)
                {
                    ResetDecoder(false); // if we're a resync, our current decoder state is invalid...
                }

                // check for parameter change
                if (packet == _parameterChangePacket)
                {
                    _isParameterChange = true;
                    ProcessParameterChange(packet);
                    return;
                }

                if (!UnpackPacket(packet))
                {
                    packet.Done();
                    _wasteBits += 8 * packet.Length;
                    return;
                }
                packet.Done();

                // we can now safely decode all the data without having to worry about a corrupt or partial packet

                DecodePacket();
                var samplesDecoded = OverlapSamples();

                // we can do something cool here...  mark down how many samples were decoded in this packet
                if (packet.GranuleCount.HasValue == false)
                {
                    packet.GranuleCount = samplesDecoded;
                }

                // update our position

                UpdatePosition(samplesDecoded, packet);

                // a little statistical housekeeping...
                var sc = Utils.Sum(_sampleCountHistory) + samplesDecoded;

                _bitsPerPacketHistory.Enqueue((int)packet.BitsRead);
                _sampleCountHistory.Enqueue(samplesDecoded);

                while (sc > _sampleRate)
                {
                    _bitsPerPacketHistory.Dequeue();
                    sc -= _sampleCountHistory.Dequeue();
                }
            }
            catch
            {
                if (packet != null)
                {
                    packet.Done();
                }
                throw;
            }
            finally
            {
                _sw.Stop();
            }
        }

        internal int GetPacketLength(DataPacket curPacket, DataPacket lastPacket)
        {
            // if we don't have a previous packet, or we're re-syncing, this packet has no audio data to return
            if (lastPacket == null || curPacket.IsResync) return 0;

            // make sure they are audio packets
            if (curPacket.ReadBit()) return 0;
            if (lastPacket.ReadBit()) return 0;

            // get the current packet's information
            var modeIdx = (int)curPacket.ReadBits(_modeFieldBits);
            if (modeIdx < 0 || modeIdx >= Modes.Length) return 0;
            var mode = Modes[modeIdx];

            // get the last packet's information
            modeIdx = (int)lastPacket.ReadBits(_modeFieldBits);
            if (modeIdx < 0 || modeIdx >= Modes.Length) return 0;
            var prevMode = Modes[modeIdx];

            // now calculate the totals...
            return mode.BlockSize / 4 + prevMode.BlockSize / 4;
        }

        #endregion

        internal int ReadSamples(float[] buffer, int offset, int count)
        {
            int samplesRead = 0;

            lock (_seekLock)
            {
                if (_prevBuffer != null)
                {
                    // get samples from the previous buffer's data
                    var cnt = Math.Min(count, _prevBuffer.Length);
                    Buffer.BlockCopy(_prevBuffer, 0, buffer, offset, cnt * sizeof(float));

                    // if we have samples left over, rebuild the previous buffer array...
                    if (cnt < _prevBuffer.Length)
                    {
                        var buf = new float[_prevBuffer.Length - cnt];
                        Buffer.BlockCopy(_prevBuffer, cnt * sizeof(float), buf, 0, (_prevBuffer.Length - cnt) * sizeof(float));
                        _prevBuffer = buf;
                    }
                    else
                    {
                        // if no samples left over, clear the previous buffer
                        _prevBuffer = null;
                    }

                    // reduce the desired sample count & increase the desired sample offset
                    count -= cnt;
                    offset += cnt;
                    samplesRead = cnt;
                }
                else if (_isParameterChange)
                {
                    throw new InvalidOperationException("Currently pending a parameter change.  Read new parameters before requesting further samples!");
                }

                int minSize = count + Block1Size * _channels;
                _outputBuffer.EnsureSize(minSize);

                while (_preparedLength * _channels < count && !_eosFound && !_isParameterChange)
                {
                    DecodeNextPacket();

                    // we can safely assume the _prevBuffer was null when we entered this loop
                    if (_prevBuffer != null)
                    {
                        // uh-oh... something is wrong...
                        return ReadSamples(buffer, offset, _prevBuffer.Length);
                    }
                }

                if (_preparedLength * _channels < count)
                {
                    // we can safely assume we've read the last packet...
                    count = _preparedLength * _channels;
                }

                _outputBuffer.CopyTo(buffer, offset, count);
                _preparedLength -= count / _channels;
                _reportedPosition = _currentPosition - _preparedLength;
            }

            return samplesRead + count;
        }

        internal bool IsParameterChange
        {
            get { return _isParameterChange; }
            set
            {
                if (value) throw new InvalidOperationException("Only clearing is supported!");
                _isParameterChange = value;
            }
        }

        internal bool CanSeek
        {
            get { return _packetProvider.CanSeek; }
        }

        internal void SeekTo(long granulePos)
        {
            if (!_packetProvider.CanSeek) throw new NotSupportedException();

            if (granulePos < 0) throw new ArgumentOutOfRangeException("granulePos");

            DataPacket packet;
            if (granulePos > 0)
            {
                packet = _packetProvider.FindPacket(granulePos, GetPacketLength);
                if (packet == null) throw new ArgumentOutOfRangeException("granulePos");
            }
            else
            {
                packet = _packetProvider.GetPacket(4);
            }

            lock (_seekLock)
            {
                // seek the stream
                _packetProvider.SeekToPacket(packet, 1);

                // now figure out where we are and how many samples we need to discard...
                // note that we use the granule position of the "current" packet, since it will be discarded no matter what

                // get the packet that we'll decode next
                var dataPacket = _packetProvider.PeekNextPacket();

                // now read samples until we are exactly at the granule position requested
                CurrentPosition = dataPacket.GranulePosition;
                var cnt = (int)((granulePos - CurrentPosition) * _channels);
                if (cnt > 0)
                {
                    var seekBuffer = new float[cnt];
                    while (cnt > 0)
                    {
                        var temp = ReadSamples(seekBuffer, 0, cnt);
                        if (temp == 0) break;   // we're at the end...
                        cnt -= temp;
                    }
                }
            }
        }

        internal long CurrentPosition
        {
            get { return _reportedPosition; }
            private set
            {
                _reportedPosition = value;
                _currentPosition = value;
                _preparedLength = 0;
                _eosFound = false;

                ResetDecoder(false);
                _prevBuffer = null;
            }
        }

        internal long GetLastGranulePos()
        {
            return _packetProvider.GetGranuleCount();
        }

        internal long ContainerBits
        {
            get { return _packetProvider.ContainerBits; }
        }

        public void ResetStats()
        {
            // only reset the stream info...  don't mess with the container, book, and hdr bits...

            _clipped = false;
            _packetCount = 0;
            _floorBits = 0L;
            _glueBits = 0L;
            _modeBits = 0L;
            _resBits = 0L;
            _wasteBits = 0L;
            _samples = 0L;
            _sw.Reset();
        }

        public int EffectiveBitRate
        {
            get
            {
                if (_samples == 0L) return 0;

                var decodedSeconds = (double)(_currentPosition - _preparedLength) / _sampleRate;

                return (int)(AudioBits / decodedSeconds);
            }
        }

        public int InstantBitRate
        {
            get
            {
                var samples = _sampleCountHistory.Sum();
                if (samples > 0)
                {
                    return (int)((long)_bitsPerPacketHistory.Sum() * _sampleRate / samples);
                }
                else
                {
                    return -1;
                }
            }
        }

        public TimeSpan PageLatency
        {
            get
            {
                return TimeSpan.FromTicks(_sw.ElapsedTicks / PagesRead);
            }
        }

        public TimeSpan PacketLatency
        {
            get
            {
                return TimeSpan.FromTicks(_sw.ElapsedTicks / _packetCount);
            }
        }

        public TimeSpan SecondLatency
        {
            get
            {
                return TimeSpan.FromTicks((_sw.ElapsedTicks / _samples) * _sampleRate);
            }
        }

        public long OverheadBits
        {
            get
            {
                return _glueBits + _metaBits + _timeHdrBits + _wasteHdrBits + _wasteBits + _packetProvider.ContainerBits;
            }
        }

        public long AudioBits
        {
            get
            {
                return _bookBits + _floorHdrBits + _resHdrBits + _mapHdrBits + _modeHdrBits + _modeBits + _floorBits + _resBits;
            }
        }

        public int PagesRead
        {
            get { return _pagesSeen.IndexOf(_lastPageSeen) + 1; }
        }

        public int TotalPages
        {
            get { return _packetProvider.GetTotalPageCount(); }
        }

        public bool Clipped
        {
            get { return _clipped; }
        }
    }
}

{'repo_name': 'MafiaHub/MafiaUnity', 'stars': '196', 'repo_language': 'C#', 'file_name': 'Makefile', 'mime_type': 'text/plain', 'hash': 2969536848807745161, 'source_dataset': 'data'}


/*!
 * Express - response
 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var fs = require('fs')
  , http = require('http')
  , path = require('path')
  , connect = require('connect')
  , utils = connect.utils
  , parseRange = require('./utils').parseRange
  , res = http.ServerResponse.prototype
  , send = connect.static.send
  , mime = require('mime')
  , basename = path.basename
  , join = path.join;

/**
 * Send a response with the given `body` and optional `headers` and `status` code.
 *
 * Examples:
 *
 *     res.send();
 *     res.send(new Buffer('wahoo'));
 *     res.send({ some: 'json' });
 *     res.send('
some html
');
 *     res.send('Sorry, cant find that', 404);
 *     res.send('text', { 'Content-Type': 'text/plain' }, 201);
 *     res.send(404);
 *
 * @param {String|Object|Number|Buffer} body or status
 * @param {Object|Number} headers or status
 * @param {Number} status
 * @return {ServerResponse}
 * @api public
 */

res.send = function(body, headers, status){
  // allow status as second arg
  if ('number' == typeof headers) {
    status = headers,
    headers = null;
  }

  // default status
  status = status || this.statusCode;

  // allow 0 args as 204
  if (!arguments.length || undefined === body) status = 204;

  // determine content type
  switch (typeof body) {
    case 'number':
      if (!this.header('Content-Type')) {
        this.contentType('.txt');
      }
      body = http.STATUS_CODES[status = body];
      break;
    case 'string':
      if (!this.header('Content-Type')) {
        this.charset = this.charset || 'utf-8';
        this.contentType('.html');
      }
      break;
    case 'boolean':
    case 'object':
      if (Buffer.isBuffer(body)) {
        if (!this.header('Content-Type')) {
          this.contentType('.bin');
        }
      } else {
        return this.json(body, headers, status);
      }
      break;
  }

  // populate Content-Length
  if (undefined !== body && !this.header('Content-Length')) {
    this.header('Content-Length', Buffer.isBuffer(body)
      ? body.length
      : Buffer.byteLength(body));
  }

  // merge headers passed
  if (headers) {
    var fields = Object.keys(headers);
    for (var i = 0, len = fields.length; i < len; ++i) {
      var field = fields[i];
      this.header(field, headers[field]);
    }
  }

  // strip irrelevant headers
  if (204 == status || 304 == status) {
    this.removeHeader('Content-Type');
    this.removeHeader('Content-Length');
    body = '';
  }

  // respond
  this.statusCode = status;
  this.end('HEAD' == this.req.method ? null : body);
  return this;
};

/**
 * Send JSON response with `obj`, optional `headers`, and optional `status`.
 *
 * Examples:
 *
 *     res.json(null);
 *     res.json({ user: 'tj' });
 *     res.json('oh noes!', 500);
 *     res.json('I dont have that', 404);
 *
 * @param {Mixed} obj
 * @param {Object|Number} headers or status
 * @param {Number} status
 * @return {ServerResponse}
 * @api public
 */

res.json = function(obj, headers, status){
  var body = JSON.stringify(obj)
    , callback = this.req.query.callback
    , jsonp = this.app.enabled('jsonp callback');

  this.charset = this.charset || 'utf-8';
  this.header('Content-Type', 'application/json');

  if (callback && jsonp) {
    this.header('Content-Type', 'text/javascript');
    body = callback.replace(/[^\w$.]/g, '') + '(' + body + ');';
  }

  return this.send(body, headers, status);
};

/**
 * Set status `code`.
 *
 * @param {Number} code
 * @return {ServerResponse}
 * @api public
 */

res.status = function(code){
  this.statusCode = code;
  return this;
};

/**
 * Transfer the file at the given `path`. Automatically sets
 * the _Content-Type_ response header field. `next()` is called
 * when `path` is a directory, or when an error occurs.
 *
 * Options:
 *
 *   - `maxAge` defaulting to 0
 *   - `root`   root directory for relative filenames
 *
 * @param {String} path
 * @param {Object|Function} options or fn
 * @param {Function} fn
 * @api public
 */

res.sendfile = function(path, options, fn){
  var next = this.req.next;
  options = options || {};

  // support function as second arg
  if ('function' == typeof options) {
    fn = options;
    options = {};
  }

  options.path = encodeURIComponent(path);
  options.callback = fn;
  send(this.req, this, next, options);
};

/**
 * Set _Content-Type_ response header passed through `mime.lookup()`.
 *
 * Examples:
 *
 *     var filename = 'path/to/image.png';
 *     res.contentType(filename);
 *     // res.headers['Content-Type'] is now "image/png"
 *
 *     res.contentType('.html');
 *     res.contentType('html');
 *     res.contentType('json');
 *     res.contentType('png');
 *
 * @param {String} type
 * @return {String} the resolved mime type
 * @api public
 */

res.contentType = function(type){
  return this.header('Content-Type', mime.lookup(type));
};

/**
 * Set _Content-Disposition_ header to _attachment_ with optional `filename`.
 *
 * @param {String} filename
 * @return {ServerResponse}
 * @api public
 */

res.attachment = function(filename){
  if (filename) this.contentType(filename);
  this.header('Content-Disposition', filename
    ? 'attachment; filename="' + basename(filename) + '"'
    : 'attachment');
  return this;
};

/**
 * Transfer the file at the given `path`, with optional
 * `filename` as an attachment and optional callback `fn(err)`,
 * and optional `fn2(err)` which is invoked when an error has
 * occurred after header has been sent.
 *
 * @param {String} path
 * @param {String|Function} filename or fn
 * @param {Function} fn
 * @param {Function} fn2
 * @api public
 */

res.download = function(path, filename, fn, fn2){
  var self = this;

  // support callback as second arg
  if ('function' == typeof filename) {
    fn2 = fn;
    fn = filename;
    filename = null;
  }

  // transfer the file
  this.attachment(filename || path).sendfile(path, function(err){
    var sentHeader = self._header;
    if (err) {
      if (!sentHeader) self.removeHeader('Content-Disposition');
      if (sentHeader) {
        fn2 && fn2(err);
      } else if (fn) {
        fn(err);
      } else {
        self.req.next(err);
      }
    } else if (fn) {
      fn();
    }
  });
};

/**
 * Set or get response header `name` with optional `val`.
 *
 * @param {String} name
 * @param {String} val
 * @return {ServerResponse} for chaining
 * @api public
 */

res.header = function(name, val){
  if (1 == arguments.length) return this.getHeader(name);
  this.setHeader(name, val);
  return this;
};

/**
 * Clear cookie `name`.
 *
 * @param {String} name
 * @param {Object} options
 * @api public
 */

res.clearCookie = function(name, options){
  var opts = { expires: new Date(1) };
  this.cookie(name, '', options
    ? utils.merge(options, opts)
    : opts);
};

/**
 * Set cookie `name` to `val`, with the given `options`.
 *
 * Options:
 *
 *    - `maxAge`   max-age in milliseconds, converted to `expires`
 *    - `path`     defaults to the "basepath" setting which is typically "/"
 *
 * Examples:
 *
 *    // "Remember Me" for 15 minutes
 *    res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });
 *
 *    // save as above
 *    res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })
 *
 * @param {String} name
 * @param {String} val
 * @param {Options} options
 * @api public
 */

res.cookie = function(name, val, options){
  options = options || {};
  if ('maxAge' in options) options.expires = new Date(Date.now() + options.maxAge);
  if (undefined === options.path) options.path = this.app.set('basepath');
  var cookie = utils.serializeCookie(name, val, options);
  this.header('Set-Cookie', cookie);
};

/**
 * Redirect to the given `url` with optional response `status`
 * defauling to 302.
 *
 * The given `url` can also be the name of a mapped url, for
 * example by default express supports "back" which redirects
 * to the _Referrer_ or _Referer_ headers or the application's
 * "basepath" setting. Express also supports "basepath" out of the box,
 * which can be set via `app.set('basepath', '/blog');`, and defaults
 * to '/'.
 *
 * Redirect Mapping:
 *
 *  To extend the redirect mapping capabilities that Express provides,
 *  we may use the `app.redirect()` method:
 *
 *     app.redirect('google', 'http://google.com');
 *
 *  Now in a route we may call:
 *
 *     res.redirect('google');
 *
 *  We may also map dynamic redirects:
 *
 *      app.redirect('comments', function(req, res){
 *          return '/post/' + req.params.id + '/comments';
 *      });
 *
 *  So now we may do the following, and the redirect will dynamically adjust to
 *  the context of the request. If we called this route with _GET /post/12_ our
 *  redirect _Location_ would be _/post/12/comments_.
 *
 *      app.get('/post/:id', function(req, res){
 *        res.redirect('comments');
 *      });
 *
 *  Unless an absolute `url` is given, the app's mount-point
 *  will be respected. For example if we redirect to `/posts`,
 *  and our app is mounted at `/blog` we will redirect to `/blog/posts`.
 *
 * @param {String} url
 * @param {Number} code
 * @api public
 */

res.redirect = function(url, status){
  var app = this.app
    , req = this.req
    , base = app.set('basepath') || app.route
    , status = status || 302
    , head = 'HEAD' == req.method
    , body;

  // Setup redirect map
  var map = {
      back: req.header('Referrer', base)
    , home: base
  };

  // Support custom redirect map
  map.__proto__ = app.redirects;

  // Attempt mapped redirect
  var mapped = 'function' == typeof map[url]
    ? map[url](req, this)
    : map[url];

  // Perform redirect
  url = mapped || url;

  // Relative
  if (!~url.indexOf('://')) {
    // Respect mount-point
    if ('/' != base && 0 != url.indexOf(base)) url = base + url;

    // Absolute
    var host = req.headers.host
      , tls = req.connection.encrypted;
    url = 'http' + (tls ? 's' : '') + '://' + host + url;
  }

  // Support text/{plain,html} by default
  if (req.accepts('html')) {
    body = '
' + http.STATUS_CODES[status] + '. Redirecting to ' + url + '
';
    this.header('Content-Type', 'text/html');
  } else {
    body = http.STATUS_CODES[status] + '. Redirecting to ' + url;
    this.header('Content-Type', 'text/plain');
  }

  // Respond
  this.statusCode = status;
  this.header('Location', url);
  this.end(head ? null : body);
};

/**
 * Assign the view local variable `name` to `val` or return the
 * local previously assigned to `name`.
 *
 * @param {String} name
 * @param {Mixed} val
 * @return {Mixed} val
 * @api public
 */

res.local = function(name, val){
  this._locals = this._locals || {};
  return undefined === val
    ? this._locals[name]
    : this._locals[name] = val;
};

/**
 * Assign several locals with the given `obj`,
 * or return the locals.
 *
 * @param {Object} obj
 * @return {Object|Undefined}
 * @api public
 */

res.locals =
res.helpers = function(obj){
  if (obj) {
    for (var key in obj) {
      this.local(key, obj[key]);
    }
  } else {
    return this._locals;
  }
};

{'repo_name': 'rwaldron/dmv', 'stars': '117', 'repo_language': 'JavaScript', 'file_name': 'index.jade', 'mime_type': 'text/plain', 'hash': 6922446389381936429, 'source_dataset': 'data'}


<annotation>
<folder>widerface</folder>
<filename>57--Angler_57_Angler_peoplefishing_57_360.jpg</filename>
<source>
<database>wider face Database</database>
<annotation>PASCAL VOC2007</annotation>
<image>flickr</image>
<flickrid>-1</flickrid>
</source>
<owner>
<flickrid>yanyu</flickrid>
<name>yanyu</name>
</owner>
<size>
<width>1024</width>
<height>777</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>face</name>
<pose>Unspecified</pose>
<truncated>1</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>246</xmin>
<ymin>52</ymin>
<xmax>304</xmax>
<ymax>118</ymax>
</bndbox>
<lm>
<x1>268.688</x1>
<y1>65.402</y1>
<x2>287.371</x2>
<y2>76.196</y2>
<x3>272.424</x3>
<y3>81.594</y3>
<x4>258.308</x4>
<y4>89.482</y4>
<x5>274.085</x5>
<y5>97.786</y5>
<visible>1</visible>
<blur>0.67</blur>
</lm>
<has_lm>1</has_lm>
</object>
</annotation>

{'repo_name': 'ShiqiYu/libfacedetection.train', 'stars': '384', 'repo_language': 'Python', 'file_name': '0--Parade_0_Parade_marchingband_1_351.xml', 'mime_type': 'text/plain', 'hash': 717155374089348645, 'source_dataset': 'data'}


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.matchstic.reprovisiond</string>
	<key>MachServices</key>
	<dict>
		<key>com.matchstic.reprovisiond</key>
		<true/>
	</dict>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/bin/reprovisiond</string>
	</array>
	<key>UserName</key>
	<string>mobile</string>
	<key>RunAtLoad</key>
	<true/>
	<key>KeepAlive</key>
	<true/>
</dict>
</plist>

{'repo_name': 'Matchstic/ReProvision', 'stars': '452', 'repo_language': 'C', 'file_name': 'IDEWorkspaceChecks.plist', 'mime_type': 'text/xml', 'hash': 2667929657086722729, 'source_dataset': 'data'}


/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1994, 1995, 1996 by Ralf Baechle
 */
#ifndef	_ASM_CACHECTL
#define	_ASM_CACHECTL

/*
 * Options for cacheflush system call
 */
#define	ICACHE	(1<<0)		/* flush instruction cache        */
#define	DCACHE	(1<<1)		/* writeback and flush data cache */
#define	BCACHE	(ICACHE|DCACHE)	/* flush both caches              */

/*
 * Caching modes for the cachectl(2) call
 *
 * cachectl(2) is currently not supported and returns ENOSYS.
 */
#define CACHEABLE	0	/* make pages cacheable */
#define UNCACHEABLE	1	/* make pages uncacheable */

#endif	/* _ASM_CACHECTL */

{'repo_name': 'nccgroup/TriforceAFL', 'stars': '493', 'repo_language': 'C', 'file_name': 'Makefile', 'mime_type': 'text/plain', 'hash': 5259669045826230737, 'source_dataset': 'data'}


## Directory Walker Generator
Originally published: 2002-11-07 16:54:48
Last updated: 2003-03-28 01:03:55
Author: Doug Fort

A generator that does what os.path.walk does, without the need for a callback function.

{'repo_name': 'ActiveState/code', 'stars': '1842', 'repo_language': 'Python', 'file_name': 'recipe-442420.tcl', 'mime_type': 'text/plain', 'hash': -5877575601141737751, 'source_dataset': 'data'}


<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>WizardCapture_UI</class>
 <widget class="QWidget" name="WizardCapture_UI">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>152</width>
    <height>154</height>
   </rect>
  </property>
  <layout class="QGridLayout" name="gridLayout">
   <item row="1" column="3">
    <widget class="QPushButton" name="button_reload">
     <property name="text">
      <string>Check</string>
     </property>
    </widget>
   </item>
   <item row="4" column="0" colspan="4">
    <widget class="Line" name="line">
     <property name="orientation">
      <enum>Qt::Horizontal</enum>
     </property>
    </widget>
   </item>
   <item row="7" column="1">
    <spacer name="verticalSpacer">
     <property name="orientation">
      <enum>Qt::Vertical</enum>
     </property>
     <property name="sizeHint" stdset="0">
      <size>
       <width>20</width>
       <height>1</height>
      </size>
     </property>
    </spacer>
   </item>
   <item row="3" column="0" colspan="4">
    <widget class="KComboBox" name="v4l_formats"/>
   </item>
   <item row="1" column="0" colspan="3">
    <widget class="KComboBox" name="v4l_devices"/>
   </item>
   <item row="0" column="0" colspan="4">
    <widget class="QLabel" name="v4l_status">
     <property name="text">
      <string/>
     </property>
    </widget>
   </item>
   <item row="2" column="0" colspan="4">
    <widget class="QLabel" name="label_9">
     <property name="text">
      <string>Capture format:</string>
     </property>
    </widget>
   </item>
   <item row="5" column="0" colspan="4">
    <widget class="QLabel" name="decklink_status">
     <property name="text">
      <string/>
     </property>
    </widget>
   </item>
   <item row="6" column="0" colspan="4">
    <widget class="KComboBox" name="decklink_devices"/>
   </item>
  </layout>
 </widget>
 <customwidgets>
  <customwidget>
   <class>KComboBox</class>
   <extends>QComboBox</extends>
   <header>kcombobox.h</header>
  </customwidget>
 </customwidgets>
 <resources/>
 <connections/>
</ui>

{'repo_name': 'KDE/kdenlive', 'stars': '753', 'repo_language': 'C++', 'file_name': 'sampleplugin.cpp', 'mime_type': 'text/x-c', 'hash': 3010820718964244885, 'source_dataset': 'data'}


/*
 * Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package net.runelite.client.ui;

import java.awt.Color;

/**
 * This class serves to hold colors used in Oldschool RuneScape that are also used in client code.
 */
public class JagexColors
{
	/*
	 * Colors of chat text when displayed on an opaque background.
	 */
	public static final Color CHAT_PUBLIC_TEXT_OPAQUE_BACKGROUND = Color.BLUE;
	public static final Color CHAT_PRIVATE_MESSAGE_TEXT_OPAQUE_BACKGROUND = Color.CYAN;
	public static final Color CHAT_FC_TEXT_OPAQUE_BACKGROUND = new Color(127, 0, 0);
	public static final Color CHAT_FC_NAME_OPAQUE_BACKGROUND = Color.BLUE;
	public static final Color CHAT_GAME_EXAMINE_TEXT_OPAQUE_BACKGROUND = Color.BLACK;
	public static final Color CHAT_TYPED_TEXT_OPAQUE_BACKGROUND = Color.BLUE;

	/*
	 * Colors of chat text when displayed on a transparent background.
	 */
	public static final Color CHAT_PUBLIC_TEXT_TRANSPARENT_BACKGROUND = new Color(144, 144, 255);
	public static final Color CHAT_PRIVATE_MESSAGE_TEXT_TRANSPARENT_BACKGROUND = Color.CYAN;
	public static final Color CHAT_FC_TEXT_TRANSPARENT_BACKGROUND = new Color(239, 80, 80);
	public static final Color CHAT_FC_NAME_TRANSPARENT_BACKGROUND = new Color(144, 112, 255);
	public static final Color CHAT_GAME_EXAMINE_TEXT_TRANSPARENT_BACKGROUND = Color.WHITE;
	public static final Color CHAT_TYPED_TEXT_TRANSPARENT_BACKGROUND = new Color(144, 144, 255);

	/*
	 * Colors relating to right-click menus.
	 */
	public static final Color MENU_TARGET = new Color(255, 144, 64);

	/*
	 * Colors relating to tooltips.
	 */
	public static final Color TOOLTIP_BACKGROUND = new Color(255, 255, 160);
	public static final Color TOOLTIP_BORDER = Color.BLACK;
	public static final Color TOOLTIP_TEXT = Color.BLACK;

	/*
	 * Colors used in interfaces
	 */
	public static final Color DARK_ORANGE_INTERFACE_TEXT = new Color(255, 152, 31);
	public static final Color YELLOW_INTERFACE_TEXT = Color.YELLOW;
}

{'repo_name': 'open-osrs/runelite', 'stars': '155', 'repo_language': 'Java', 'file_name': 'NpcStatsDumperTest.java', 'mime_type': 'text/x-c++', 'hash': -6399459834452273167, 'source_dataset': 'data'}


/*
   +----------------------------------------------------------------------+
   | Copyright (c) The PHP Group                                          |
   +----------------------------------------------------------------------+
   | This source file is subject to version 3.01 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.php.net/license/3_01.txt                                  |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | license@php.net so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Author: Niklas Keller <kelunik@php.net>                              |
   | Author: Anatol Belski <ab@php.net>                                   |
   +----------------------------------------------------------------------+
*/

#ifndef HRTIME_H
#define HRTIME_H

#define PHP_HRTIME_PLATFORM_POSIX   0
#define PHP_HRTIME_PLATFORM_WINDOWS 0
#define PHP_HRTIME_PLATFORM_APPLE   0
#define PHP_HRTIME_PLATFORM_HPUX    0
#define PHP_HRTIME_PLATFORM_AIX     0

#if defined(_POSIX_TIMERS) && ((_POSIX_TIMERS > 0) || defined(__OpenBSD__)) && defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC)
# undef  PHP_HRTIME_PLATFORM_POSIX
# define PHP_HRTIME_PLATFORM_POSIX 1
#elif defined(_WIN32) || defined(_WIN64)
# undef  PHP_HRTIME_PLATFORM_WINDOWS
# define PHP_HRTIME_PLATFORM_WINDOWS 1
#elif defined(__APPLE__)
# undef  PHP_HRTIME_PLATFORM_APPLE
# define PHP_HRTIME_PLATFORM_APPLE 1
#elif (defined(__hpux) || defined(hpux)) || ((defined(__sun__) || defined(__sun) || defined(sun)) && (defined(__SVR4) || defined(__svr4__)))
# undef  PHP_HRTIME_PLATFORM_HPUX
# define PHP_HRTIME_PLATFORM_HPUX 1
#elif defined(_AIX)
# undef  PHP_HRTIME_PLATFORM_AIX
# define PHP_HRTIME_PLATFORM_AIX 1
#endif

#define HRTIME_AVAILABLE (PHP_HRTIME_PLATFORM_POSIX || PHP_HRTIME_PLATFORM_WINDOWS || PHP_HRTIME_PLATFORM_APPLE || PHP_HRTIME_PLATFORM_HPUX || PHP_HRTIME_PLATFORM_AIX)

BEGIN_EXTERN_C()

typedef uint64_t php_hrtime_t;

PHPAPI php_hrtime_t php_hrtime_current(void);

PHP_MINIT_FUNCTION(hrtime);

END_EXTERN_C()

#endif /* HRTIME_H */

{'repo_name': 'php/php-src', 'stars': '27767', 'repo_language': 'C', 'file_name': 'echo.inc', 'mime_type': 'text/x-php', 'hash': -8639327227691937111, 'source_dataset': 'data'}


%% This module sends a different expires value
%% depending on the query string.

-module(expires_h).

-export([init/2]).
-export([content_types_provided/2]).
-export([get_text_plain/2]).
-export([expires/2]).

init(Req, Opts) ->
	{cowboy_rest, Req, Opts}.

content_types_provided(Req, State) ->
	{[{{<<"text">>, <<"plain">>, []}, get_text_plain}], Req, State}.

get_text_plain(Req, State) ->
	{<<"This is REST!">>, Req, State}.

expires(Req=#{qs := <<"tuple">>}, State) ->
	{{{2012, 9, 21}, {22, 36, 14}}, Req, State};
expires(Req=#{qs := <<"binary">>}, State) ->
	{<<"0">>, Req, State};
expires(Req=#{qs := <<"undefined">>}, State) ->
	{undefined, Req, State};
%% Simulate the callback being missing in other cases.
expires(#{qs := <<"missing">>}, _) ->
	no_call.

{'repo_name': 'ninenines/cowboy', 'stars': '5980', 'repo_language': 'Erlang', 'file_name': 'migrating_from_2.3.asciidoc', 'mime_type': 'text/plain', 'hash': -7305780782393465482, 'source_dataset': 'data'}


/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

// Various keypoint detecting functions.

#include <float.h>

#include "tensorflow/examples/android/jni/object_tracking/image-inl.h"
#include "tensorflow/examples/android/jni/object_tracking/image.h"
#include "tensorflow/examples/android/jni/object_tracking/time_log.h"
#include "tensorflow/examples/android/jni/object_tracking/utils.h"

#include "tensorflow/examples/android/jni/object_tracking/config.h"
#include "tensorflow/examples/android/jni/object_tracking/keypoint.h"
#include "tensorflow/examples/android/jni/object_tracking/keypoint_detector.h"

namespace tf_tracking {

static inline int GetDistSquaredBetween(const int* vec1, const int* vec2) {
  return Square(vec1[0] - vec2[0]) + Square(vec1[1] - vec2[1]);
}

void KeypointDetector::ScoreKeypoints(const ImageData& image_data,
                                      const int num_candidates,
                                      Keypoint* const candidate_keypoints) {
  const Image<int>& I_x = *image_data.GetSpatialX(0);
  const Image<int>& I_y = *image_data.GetSpatialY(0);

  if (config_->detect_skin) {
    const Image<uint8_t>& u_data = *image_data.GetU();
    const Image<uint8_t>& v_data = *image_data.GetV();

    static const int reference[] = {111, 155};

    // Score all the keypoints.
    for (int i = 0; i < num_candidates; ++i) {
      Keypoint* const keypoint = candidate_keypoints + i;

      const int x_pos = keypoint->pos_.x * 2;
      const int y_pos = keypoint->pos_.y * 2;

      const int curr_color[] = {u_data[y_pos][x_pos], v_data[y_pos][x_pos]};
      keypoint->score_ =
          HarrisFilter(I_x, I_y, keypoint->pos_.x, keypoint->pos_.y) /
          GetDistSquaredBetween(reference, curr_color);
    }
  } else {
    // Score all the keypoints.
    for (int i = 0; i < num_candidates; ++i) {
      Keypoint* const keypoint = candidate_keypoints + i;
      keypoint->score_ =
          HarrisFilter(I_x, I_y, keypoint->pos_.x, keypoint->pos_.y);
    }
  }
}

inline int KeypointCompare(const void* const a, const void* const b) {
  return (reinterpret_cast<const Keypoint*>(a)->score_ -
          reinterpret_cast<const Keypoint*>(b)->score_) <= 0 ? 1 : -1;
}

// Quicksorts detected keypoints by score.
void KeypointDetector::SortKeypoints(const int num_candidates,
                                   Keypoint* const candidate_keypoints) const {
  qsort(candidate_keypoints, num_candidates, sizeof(Keypoint), KeypointCompare);

#ifdef SANITY_CHECKS
  // Verify that the array got sorted.
  float last_score = FLT_MAX;
  for (int i = 0; i < num_candidates; ++i) {
    const float curr_score = candidate_keypoints[i].score_;

    // Scores should be monotonically increasing.
    SCHECK(last_score >= curr_score,
          "Quicksort failure! %d: %.5f > %d: %.5f (%d total)",
          i - 1, last_score, i, curr_score, num_candidates);

    last_score = curr_score;
  }
#endif
}

int KeypointDetector::SelectKeypointsInBox(
    const BoundingBox& box,
    const Keypoint* const candidate_keypoints,
    const int num_candidates,
    const int max_keypoints,
    const int num_existing_keypoints,
    const Keypoint* const existing_keypoints,
    Keypoint* const final_keypoints) const {
  if (max_keypoints <= 0) {
    return 0;
  }

  // This is the distance within which keypoints may be placed to each other
  // within this box, roughly based on the box dimensions.
  const int distance =
      MAX(1, MIN(box.GetWidth(), box.GetHeight()) * kClosestPercent / 2.0f);

  // First, mark keypoints that already happen to be inside this region. Ignore
  // keypoints that are outside it, however close they might be.
  interest_map_->Clear(false);
  for (int i = 0; i < num_existing_keypoints; ++i) {
    const Keypoint& candidate = existing_keypoints[i];

    const int x_pos = candidate.pos_.x;
    const int y_pos = candidate.pos_.y;
    if (box.Contains(candidate.pos_)) {
      MarkImage(x_pos, y_pos, distance, interest_map_.get());
    }
  }

  // Now, go through and check which keypoints will still fit in the box.
  int num_keypoints_selected = 0;
  for (int i = 0; i < num_candidates; ++i) {
    const Keypoint& candidate = candidate_keypoints[i];

    const int x_pos = candidate.pos_.x;
    const int y_pos = candidate.pos_.y;

    if (!box.Contains(candidate.pos_) ||
        !interest_map_->ValidPixel(x_pos, y_pos)) {
      continue;
    }

    if (!(*interest_map_)[y_pos][x_pos]) {
      final_keypoints[num_keypoints_selected++] = candidate;
      if (num_keypoints_selected >= max_keypoints) {
        break;
      }
      MarkImage(x_pos, y_pos, distance, interest_map_.get());
    }
  }
  return num_keypoints_selected;
}

void KeypointDetector::SelectKeypoints(
    const std::vector<BoundingBox>& boxes,
    const Keypoint* const candidate_keypoints,
    const int num_candidates,
    FramePair* const curr_change) const {
  // Now select all the interesting keypoints that fall insider our boxes.
  curr_change->number_of_keypoints_ = 0;
  for (std::vector<BoundingBox>::const_iterator iter = boxes.begin();
      iter != boxes.end(); ++iter) {
    const BoundingBox bounding_box = *iter;

    // Count up keypoints that have already been selected, and fall within our
    // box.
    int num_keypoints_already_in_box = 0;
    for (int i = 0; i < curr_change->number_of_keypoints_; ++i) {
      if (bounding_box.Contains(curr_change->frame1_keypoints_[i].pos_)) {
        ++num_keypoints_already_in_box;
      }
    }

    const int max_keypoints_to_find_in_box =
        MIN(kMaxKeypointsForObject - num_keypoints_already_in_box,
            kMaxKeypoints - curr_change->number_of_keypoints_);

    const int num_new_keypoints_in_box = SelectKeypointsInBox(
        bounding_box,
        candidate_keypoints,
        num_candidates,
        max_keypoints_to_find_in_box,
        curr_change->number_of_keypoints_,
        curr_change->frame1_keypoints_,
        curr_change->frame1_keypoints_ + curr_change->number_of_keypoints_);

    curr_change->number_of_keypoints_ += num_new_keypoints_in_box;

    LOGV("Selected %d keypoints!", curr_change->number_of_keypoints_);
  }
}

// Walks along the given circle checking for pixels above or below the center.
// Returns a score, or 0 if the keypoint did not pass the criteria.
//
// Parameters:
//  circle_perimeter: the circumference in pixels of the circle.
//  threshold: the minimum number of contiguous pixels that must be above or
//             below the center value.
//  center_ptr: the location of the center pixel in memory
//  offsets: the relative offsets from the center pixel of the edge pixels.
inline int TestCircle(const int circle_perimeter, const int threshold,
                      const uint8_t* const center_ptr, const int* offsets) {
  // Get the actual value of the center pixel for easier reference later on.
  const int center_value = static_cast<int>(*center_ptr);

  // Number of total pixels to check.  Have to wrap around some in case
  // the contiguous section is split by the array edges.
  const int num_total = circle_perimeter + threshold - 1;

  int num_above = 0;
  int above_diff = 0;

  int num_below = 0;
  int below_diff = 0;

  // Used to tell when this is definitely not going to meet the threshold so we
  // can early abort.
  int minimum_by_now = threshold - num_total + 1;

  // Go through every pixel along the perimeter of the circle, and then around
  // again a little bit.
  for (int i = 0; i < num_total; ++i) {
    // This should be faster than mod.
    const int perim_index = i < circle_perimeter ? i : i - circle_perimeter;

    // This gets the value of the current pixel along the perimeter by using
    // a precomputed offset.
    const int curr_value =
        static_cast<int>(center_ptr[offsets[perim_index]]);

    const int difference = curr_value - center_value;

    if (difference > kFastDiffAmount) {
      above_diff += difference;
      ++num_above;

      num_below = 0;
      below_diff = 0;

      if (num_above >= threshold) {
        return above_diff;
      }
    } else if (difference < -kFastDiffAmount) {
      below_diff += difference;
      ++num_below;

      num_above = 0;
      above_diff = 0;

      if (num_below >= threshold) {
        return below_diff;
      }
    } else {
      num_above = 0;
      num_below = 0;
      above_diff = 0;
      below_diff = 0;
    }

    // See if there's any chance of making the threshold.
    if (MAX(num_above, num_below) < minimum_by_now) {
      // Didn't pass.
      return 0;
    }
    ++minimum_by_now;
  }

  // Didn't pass.
  return 0;
}

// Returns a score in the range [0.0, positive infinity) which represents the
// relative likelihood of a point being a corner.
float KeypointDetector::HarrisFilter(const Image<int32_t>& I_x,
                                     const Image<int32_t>& I_y, const float x,
                                     const float y) const {
  if (I_x.ValidInterpPixel(x - kHarrisWindowSize, y - kHarrisWindowSize) &&
      I_x.ValidInterpPixel(x + kHarrisWindowSize, y + kHarrisWindowSize)) {
    // Image gradient matrix.
    float G[] = { 0, 0, 0, 0 };
    CalculateG(kHarrisWindowSize, x, y, I_x, I_y, G);

    const float dx = G[0];
    const float dy = G[3];
    const float dxy = G[1];

    // Harris-Nobel corner score.
    return (dx * dy - Square(dxy)) / (dx + dy + FLT_MIN);
  }

  return 0.0f;
}

int KeypointDetector::AddExtraCandidatesForBoxes(
    const std::vector<BoundingBox>& boxes,
    const int max_num_keypoints,
    Keypoint* const keypoints) const {
  int num_keypoints_added = 0;

  for (std::vector<BoundingBox>::const_iterator iter = boxes.begin();
      iter != boxes.end(); ++iter) {
    const BoundingBox box = *iter;

    for (int i = 0; i < kNumToAddAsCandidates; ++i) {
      for (int j = 0; j < kNumToAddAsCandidates; ++j) {
        if (num_keypoints_added >= max_num_keypoints) {
          LOGW("Hit cap of %d for temporary keypoints!", max_num_keypoints);
          return num_keypoints_added;
        }

        Keypoint curr_keypoint = keypoints[num_keypoints_added++];
        curr_keypoint.pos_ = Point2f(
            box.left_ + box.GetWidth() * (i + 0.5f) / kNumToAddAsCandidates,
            box.top_ + box.GetHeight() * (j + 0.5f) / kNumToAddAsCandidates);
        curr_keypoint.type_ = KEYPOINT_TYPE_INTEREST;
      }
    }
  }

  return num_keypoints_added;
}

void KeypointDetector::FindKeypoints(const ImageData& image_data,
                                   const std::vector<BoundingBox>& rois,
                                   const FramePair& prev_change,
                                   FramePair* const curr_change) {
  // Copy keypoints from second frame of last pass to temp keypoints of this
  // pass.
  int number_of_tmp_keypoints = CopyKeypoints(prev_change, tmp_keypoints_);

  const int max_num_fast = kMaxTempKeypoints - number_of_tmp_keypoints;
  number_of_tmp_keypoints +=
      FindFastKeypoints(image_data, max_num_fast,
                       tmp_keypoints_ + number_of_tmp_keypoints);

  TimeLog("Found FAST keypoints");

  if (number_of_tmp_keypoints >= kMaxTempKeypoints) {
    LOGW("Hit cap of %d for temporary keypoints (FAST)! %d keypoints",
         kMaxTempKeypoints, number_of_tmp_keypoints);
  }

  if (kAddArbitraryKeypoints) {
    // Add some for each object prior to scoring.
    const int max_num_box_keypoints =
        kMaxTempKeypoints - number_of_tmp_keypoints;
    number_of_tmp_keypoints +=
        AddExtraCandidatesForBoxes(rois, max_num_box_keypoints,
                                   tmp_keypoints_ + number_of_tmp_keypoints);
    TimeLog("Added box keypoints");

    if (number_of_tmp_keypoints >= kMaxTempKeypoints) {
      LOGW("Hit cap of %d for temporary keypoints (boxes)! %d keypoints",
           kMaxTempKeypoints, number_of_tmp_keypoints);
    }
  }

  // Score them...
  LOGV("Scoring %d keypoints!", number_of_tmp_keypoints);
  ScoreKeypoints(image_data, number_of_tmp_keypoints, tmp_keypoints_);
  TimeLog("Scored keypoints");

  // Now pare it down a bit.
  SortKeypoints(number_of_tmp_keypoints, tmp_keypoints_);
  TimeLog("Sorted keypoints");

  LOGV("%d keypoints to select from!", number_of_tmp_keypoints);

  SelectKeypoints(rois, tmp_keypoints_, number_of_tmp_keypoints, curr_change);
  TimeLog("Selected keypoints");

  LOGV("Picked %d (%d max) final keypoints out of %d potential.",
       curr_change->number_of_keypoints_,
       kMaxKeypoints, number_of_tmp_keypoints);
}

int KeypointDetector::CopyKeypoints(const FramePair& prev_change,
                                  Keypoint* const new_keypoints) {
  int number_of_keypoints = 0;

  // Caching values from last pass, just copy and compact.
  for (int i = 0; i < prev_change.number_of_keypoints_; ++i) {
    if (prev_change.optical_flow_found_keypoint_[i]) {
      new_keypoints[number_of_keypoints] =
          prev_change.frame2_keypoints_[i];

      new_keypoints[number_of_keypoints].score_ =
          prev_change.frame1_keypoints_[i].score_;

      ++number_of_keypoints;
    }
  }

  TimeLog("Copied keypoints");
  return number_of_keypoints;
}

// FAST keypoint detector.
int KeypointDetector::FindFastKeypoints(const Image<uint8_t>& frame,
                                        const int quadrant,
                                        const int downsample_factor,
                                        const int max_num_keypoints,
                                        Keypoint* const keypoints) {
  /*
   // Reference for a circle of diameter 7.
   const int circle[] = {0, 0, 1, 1, 1, 0, 0,
                         0, 1, 0, 0, 0, 1, 0,
                         1, 0, 0, 0, 0, 0, 1,
                         1, 0, 0, 0, 0, 0, 1,
                         1, 0, 0, 0, 0, 0, 1,
                         0, 1, 0, 0, 0, 1, 0,
                         0, 0, 1, 1, 1, 0, 0};
   const int circle_offset[] =
       {2, 3, 4, 8, 12, 14, 20, 21, 27, 28, 34, 36, 40, 44, 45, 46};
   */

  // Quick test of compass directions.  Any length 16 circle with a break of up
  // to 4 pixels will have at least 3 of these 4 pixels active.
  static const int short_circle_perimeter = 4;
  static const int short_threshold = 3;
  static const int short_circle_x[] = { -3,  0, +3,  0 };
  static const int short_circle_y[] = {  0, -3,  0, +3 };

  // Precompute image offsets.
  int short_offsets[short_circle_perimeter];
  for (int i = 0; i < short_circle_perimeter; ++i) {
    short_offsets[i] = short_circle_x[i] + short_circle_y[i] * frame.GetWidth();
  }

  // Large circle values.
  static const int full_circle_perimeter = 16;
  static const int full_threshold = 12;
  static const int full_circle_x[] =
      { -1,  0, +1, +2, +3, +3, +3, +2, +1, +0, -1, -2, -3, -3, -3, -2 };
  static const int full_circle_y[] =
      { -3, -3, -3, -2, -1,  0, +1, +2, +3, +3, +3, +2, +1, +0, -1, -2 };

  // Precompute image offsets.
  int full_offsets[full_circle_perimeter];
  for (int i = 0; i < full_circle_perimeter; ++i) {
    full_offsets[i] = full_circle_x[i] + full_circle_y[i] * frame.GetWidth();
  }

  const int scratch_stride = frame.stride();

  keypoint_scratch_->Clear(0);

  // Set up the bounds on the region to test based on the passed-in quadrant.
  const int quadrant_width = (frame.GetWidth() / 2) - kFastBorderBuffer;
  const int quadrant_height = (frame.GetHeight() / 2) - kFastBorderBuffer;
  const int start_x =
      kFastBorderBuffer + ((quadrant % 2 == 0) ? 0 : quadrant_width);
  const int start_y =
      kFastBorderBuffer + ((quadrant < 2) ? 0 : quadrant_height);
  const int end_x = start_x + quadrant_width;
  const int end_y = start_y + quadrant_height;

  // Loop through once to find FAST keypoint clumps.
  for (int img_y = start_y; img_y < end_y; ++img_y) {
    const uint8_t* curr_pixel_ptr = frame[img_y] + start_x;

    for (int img_x = start_x; img_x < end_x; ++img_x) {
      // Only insert it if it meets the quick minimum requirements test.
      if (TestCircle(short_circle_perimeter, short_threshold,
                     curr_pixel_ptr, short_offsets) != 0) {
        // Longer test for actual keypoint score..
        const int fast_score = TestCircle(full_circle_perimeter,
                                          full_threshold,
                                          curr_pixel_ptr,
                                          full_offsets);

        // Non-zero score means the keypoint was found.
        if (fast_score != 0) {
          uint8_t* const center_ptr = (*keypoint_scratch_)[img_y] + img_x;

          // Increase the keypoint count on this pixel and the pixels in all
          // 4 cardinal directions.
          *center_ptr += 5;
          *(center_ptr - 1) += 1;
          *(center_ptr + 1) += 1;
          *(center_ptr - scratch_stride) += 1;
          *(center_ptr + scratch_stride) += 1;
        }
      }

      ++curr_pixel_ptr;
    }  // x
  }  // y

  TimeLog("Found FAST keypoints.");

  int num_keypoints = 0;
  // Loop through again and Harris filter pixels in the center of clumps.
  // We can shrink the window by 1 pixel on every side.
  for (int img_y = start_y + 1; img_y < end_y - 1; ++img_y) {
    const uint8_t* curr_pixel_ptr = (*keypoint_scratch_)[img_y] + start_x;

    for (int img_x = start_x + 1; img_x < end_x - 1; ++img_x) {
      if (*curr_pixel_ptr >= kMinNumConnectedForFastKeypoint) {
       Keypoint* const keypoint = keypoints + num_keypoints;
        keypoint->pos_ = Point2f(
            img_x * downsample_factor, img_y * downsample_factor);
        keypoint->score_ = 0;
        keypoint->type_ = KEYPOINT_TYPE_FAST;

        ++num_keypoints;
        if (num_keypoints >= max_num_keypoints) {
          return num_keypoints;
        }
      }

      ++curr_pixel_ptr;
    }  // x
  }  // y

  TimeLog("Picked FAST keypoints.");

  return num_keypoints;
}

int KeypointDetector::FindFastKeypoints(const ImageData& image_data,
                                        const int max_num_keypoints,
                                        Keypoint* const keypoints) {
  int downsample_factor = 1;
  int num_found = 0;

  // TODO(andrewharp): Get this working for multiple image scales.
  for (int i = 0; i < 1; ++i) {
    const Image<uint8_t>& frame = *image_data.GetPyramidSqrt2Level(i);
    num_found += FindFastKeypoints(
        frame, fast_quadrant_,
        downsample_factor, max_num_keypoints, keypoints + num_found);
    downsample_factor *= 2;
  }

  // Increment the current quadrant.
  fast_quadrant_ = (fast_quadrant_ + 1) % 4;

  return num_found;
}

}  // namespace tf_tracking

{'repo_name': 'chiachunfu/speech', 'stars': '128', 'repo_language': 'Java', 'file_name': 'frame_pair.h', 'mime_type': 'text/x-c++', 'hash': 2424844922349715098, 'source_dataset': 'data'}


// CivOne
//
// To the extent possible under law, the person who associated CC0 with
// CivOne has waived all copyright and related or neighboring rights
// to CivOne.
//
// You should have received a copy of the CC0 legalcode along with this
// work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

using CivOne.Enums;
using CivOne.IO;
using CivOne.Units;

namespace CivOne.Graphics.Sprites
{
	public static class Unit
	{
		private static IBitmap BaseSprite(UnitType type) => CivOne.Units.BaseUnit.GetBaseSprite(type);
		private static Free Free => Free.Instance;
		private static Resources Resources => Resources.Instance;
		private static Settings Settings => Settings.Instance;

		private static bool GFX256 => (Settings.GraphicsMode == GraphicsMode.Graphics256);

		private static Bytemap GetUnit((UnitType Type, byte PlayerNumber) unit)
		{
			byte colourDark = Common.ColourDark[unit.PlayerNumber];
			byte colourLight = Common.ColourLight[unit.PlayerNumber];
			int unitId = (int)unit.Type;

			IBitmap baseSprite = BaseSprite(unit.Type);
			Bytemap output;
			if (baseSprite != null)
			{
				output = baseSprite.MatchColours(Common.DefaultPalette, 1, 15);
			}
			else
			{
				string resFile = GFX256 ? "SP257" : "SPRITES";
				int xx = (unitId % 20) * 16;
				int yy = unitId < 20 ? 160 : 176;

				if (Resources.Exists(resFile))
				{
					output = Resources[resFile].Bitmap[xx, yy, 16, 16]
						.FillRectangle(0, 0, 16, 1, 0)
						.FillRectangle(0, 1, 1, 15, 0);
				}
				else
				{
					output = Free.GetUnit(unit.Type);
				}
			}

			if (colourLight == 15) output.ColourReplace((15, 11), (10, colourLight), (2, colourDark));
			else if (colourDark == 8) output.ColourReplace((7, 3), (10, colourLight), (2, colourDark));
			else output.ColourReplace((10, colourLight), (2, colourDark));

			return output;
		}

		private static Bytemap GetUnitSentry((UnitType Type, byte PlayerNumber) unit)
		{
			return new Picture(16, 16)
				.AddLayer(BaseUnit[(unit.Type, unit.PlayerNumber)].Bitmap)
				.ColourReplace((5, 7), (8, 7))
				.Bitmap;
		}

		private static Bytemap GetUnitFortify((UnitType Type, byte PlayerNumber) unit)
		{
			return new Picture(16, 16)
				.AddLayer(BaseUnit[(unit.Type, unit.PlayerNumber)].Bitmap)
				.AddLayer(Generic.Fortify)
				.Bitmap;
		}

		private static Bytemap GetUnitLetter((UnitType Type, char Letter, byte PlayerNumber) unit)
		{
			return new Picture(16, 16)
				.AddLayer(BaseUnit[(unit.Type, unit.PlayerNumber)].Bitmap)
				.DrawText($"{unit.Letter}", 8, 8, TextSettings.UnitText(unit.PlayerNumber))
				.Bitmap;
		}

		private static ISpriteCollection<(UnitType, byte)> BaseUnit = new CachedSpriteCollection<(UnitType, byte)>(GetUnit);
		private static ISpriteCollection<(UnitType, byte)> SentryUnit = new CachedSpriteCollection<(UnitType, byte)>(GetUnitSentry);
		private static ISpriteCollection<(UnitType, byte)> FortifyUnit = new CachedSpriteCollection<(UnitType, byte)>(GetUnitFortify);
		private static ISpriteCollection<(UnitType, char, byte)> LetterUnit = new CachedSpriteCollection<(UnitType, char, byte)>(GetUnitLetter);
		public static ISprite Base<T>(byte playerNumber) where T : IUnit, new() => BaseUnit[(new T().Type, playerNumber)];
		public static ISprite Base(UnitType type, byte playerNumber) => BaseUnit[(type, playerNumber)];
		public static ISprite Sentry<T>(byte playerNumber) where T : IUnit, new() => SentryUnit[(new T().Type, playerNumber)];
		public static ISprite Sentry(UnitType type, byte playerNumber) => SentryUnit[(type, playerNumber)];
		public static ISprite Fortify<T>(byte playerNumber) where T : IUnit, new() => FortifyUnit[(new T().Type, playerNumber)];
		public static ISprite Fortify(UnitType type, byte playerNumber) => FortifyUnit[(type, playerNumber)];
		public static ISprite Letter<T>(char letter, byte playerNumber) where T : IUnit, new() => LetterUnit[(new T().Type, letter, playerNumber)];
		public static ISprite Letter(UnitType type, char letter, byte playerNumber) => LetterUnit[(type, letter, playerNumber)];

		public static ISprite Settlers(byte playerNumber) => BaseUnit[(UnitType.Settlers, playerNumber)];
		public static ISprite Militia(byte playerNumber) => BaseUnit[(UnitType.Militia, playerNumber)];
		public static ISprite Phalanx(byte playerNumber) => BaseUnit[(UnitType.Phalanx, playerNumber)];
		public static ISprite Legion(byte playerNumber) => BaseUnit[(UnitType.Legion, playerNumber)];
		public static ISprite Musketeers(byte playerNumber) => BaseUnit[(UnitType.Musketeers, playerNumber)];
		public static ISprite Riflemen(byte playerNumber) => BaseUnit[(UnitType.Riflemen, playerNumber)];
		public static ISprite Cavalry(byte playerNumber) => BaseUnit[(UnitType.Cavalry, playerNumber)];
		public static ISprite Knights(byte playerNumber) => BaseUnit[(UnitType.Knights, playerNumber)];
		public static ISprite Catapult(byte playerNumber) => BaseUnit[(UnitType.Catapult, playerNumber)];
		public static ISprite Cannon(byte playerNumber) => BaseUnit[(UnitType.Cannon, playerNumber)];
		public static ISprite Chariot(byte playerNumber) => BaseUnit[(UnitType.Chariot, playerNumber)];
		public static ISprite Armor(byte playerNumber) => BaseUnit[(UnitType.Armor, playerNumber)];
		public static ISprite MechInf(byte playerNumber) => BaseUnit[(UnitType.MechInf, playerNumber)];
		public static ISprite Artillery(byte playerNumber) => BaseUnit[(UnitType.Artillery, playerNumber)];
		public static ISprite Fighter(byte playerNumber) => BaseUnit[(UnitType.Fighter, playerNumber)];
		public static ISprite Bomber(byte playerNumber) => BaseUnit[(UnitType.Bomber, playerNumber)];
		public static ISprite Trireme(byte playerNumber) => BaseUnit[(UnitType.Trireme, playerNumber)];
		public static ISprite Sail(byte playerNumber) => BaseUnit[(UnitType.Sail, playerNumber)];
		public static ISprite Frigate(byte playerNumber) => BaseUnit[(UnitType.Frigate, playerNumber)];
		public static ISprite Ironclad(byte playerNumber) => BaseUnit[(UnitType.Ironclad, playerNumber)];
		public static ISprite Cruiser(byte playerNumber) => BaseUnit[(UnitType.Cruiser, playerNumber)];
		public static ISprite Battleship(byte playerNumber) => BaseUnit[(UnitType.Battleship, playerNumber)];
		public static ISprite Submarine(byte playerNumber) => BaseUnit[(UnitType.Submarine, playerNumber)];
		public static ISprite Carrier(byte playerNumber) => BaseUnit[(UnitType.Carrier, playerNumber)];
		public static ISprite Transport(byte playerNumber) => BaseUnit[(UnitType.Transport, playerNumber)];
		public static ISprite Nuclear(byte playerNumber) => BaseUnit[(UnitType.Nuclear, playerNumber)];
		public static ISprite Diplomat(byte playerNumber) => BaseUnit[(UnitType.Diplomat, playerNumber)];
		public static ISprite Caravan(byte playerNumber) => BaseUnit[(UnitType.Caravan, playerNumber)];
	}
}

{'repo_name': 'SWY1985/CivOne', 'stars': '166', 'repo_language': 'C#', 'file_name': 'AssemblyInfo.cs', 'mime_type': 'text/plain', 'hash': 557940974407772510, 'source_dataset': 'data'}


<?php
/**
 * DO NOT EDIT THIS FILE!
 *
 * This file was automatically generated from external sources.
 *
 * Any manual change here will be lost the next time the SDK
 * is updated. You've been warned!
 */

namespace DTS\eBaySDK\PostOrder\Types;

/**
 *
 * @property integer[] $ruleId
 */
class PriorityListType extends \DTS\eBaySDK\Types\BaseType
{
    /**
     * @var array Properties belonging to objects of this class.
     */
    private static $propertyTypes = [
        'ruleId' => [
            'type' => 'integer',
            'repeatable' => true,
            'attribute' => false,
            'elementName' => 'ruleId'
        ]
    ];

    /**
     * @param array $values Optional properties and values to assign to the object.
     */
    public function __construct(array $values = [])
    {
        list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values);

        parent::__construct($parentValues);

        if (!array_key_exists(__CLASS__, self::$properties)) {
            self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes);
        }

        $this->setValues(__CLASS__, $childValues);
    }
}

{'repo_name': 'davidtsadler/ebay-sdk-php', 'stars': '328', 'repo_language': 'PHP', 'file_name': 'apigen.neon', 'mime_type': 'text/plain', 'hash': -4904187290617842261, 'source_dataset': 'data'}


using System;
using System.Text;
using Wexflow.Core;
using System.Xml.Linq;
using System.IO;
using System.Threading;

namespace Wexflow.Tasks.FilesConcat
{
    public class FilesConcat : Task
    {
        public FilesConcat(XElement xe, Workflow wf)
            : base(xe, wf)
        {
        }

        public override TaskStatus Run()
        {
            Info("Concatenating files...");

            bool success = true;
            bool atLeastOneSucceed = false;

            var files = SelectFiles();

            if (files.Length > 0)
            {
                StringBuilder builder = new StringBuilder();
                for(int i = 0; i<files.Length; i++)
                {
                    var file = files[i];
                    builder.Append(Path.GetFileNameWithoutExtension(file.FileName));
                    if (i < files.Length - 1)
                    {
                        builder.Append("_");
                    }
                }

                var concatPath = Path.Combine(Workflow.WorkflowTempFolder, builder.ToString());

                if (File.Exists(concatPath))
                {
                    File.Delete(concatPath);
                }

                using (var output = File.Create(concatPath))
                {
                    foreach (FileInf file in files)
                    {
                        try
                        {
                            using (var input = File.OpenRead(file.Path))
                            {
                                input.CopyTo(output);
                            }

                            if (!atLeastOneSucceed) atLeastOneSucceed = true;
                        }
                        catch (ThreadAbortException)
                        {
                            throw;
                        }
                        catch (Exception e)
                        {
                            ErrorFormat("An error occured while concatenating the file {0}", e, file.Path);
                            success = false;
                        }
                    }
                }

                if (success)
                {
                    InfoFormat("Concatenation file generated: {0}", builder);
                }

                Files.Add(new FileInf(concatPath, Id));
            }

            var status = Status.Success;

            if (!success && atLeastOneSucceed)
            {
                status = Status.Warning;
            }
            else if (!success)
            {
                status = Status.Error;
            }

            Info("Task finished.");
            return new TaskStatus(status, false);
        }
    }
}

{'repo_name': 'aelassas/Wexflow', 'stars': '2231', 'repo_language': 'C#', 'file_name': 'appsettings.json', 'mime_type': 'text/plain', 'hash': 6063274166674677473, 'source_dataset': 'data'}