Skip to content

Commit

Permalink
Minor updates to centralize some deprecation warnings, replace M_PI w…
Browse files Browse the repository at this point in the history
…ith .pi.
  • Loading branch information
BradLarson committed Jul 6, 2016
1 parent 38feb70 commit a478629
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions framework/GPUImage-Mac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
BC4EE1681CB34B8900AD8A65 /* HistogramDisplay.vsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = HistogramDisplay.vsh; path = Source/Operations/Shaders/HistogramDisplay.vsh; sourceTree = "<group>"; };
BC4EE16B1CB34D7B00AD8A65 /* RawDataInput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RawDataInput.swift; path = Source/RawDataInput.swift; sourceTree = "<group>"; };
BC4EE16E1CB3554200AD8A65 /* RawDataOutput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RawDataOutput.swift; path = Source/RawDataOutput.swift; sourceTree = "<group>"; };
BC4EE1731CB3711600AD8A65 /* GaussianBlur.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GaussianBlur.swift; path = Source/Operations/GaussianBlur.swift; sourceTree = "<group>"; };
BC4EE1731CB3711600AD8A65 /* GaussianBlur.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = GaussianBlur.swift; path = Source/Operations/GaussianBlur.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
BC5B866E1CC07145006CDE75 /* PictureOutput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PictureOutput.swift; path = Source/Mac/PictureOutput.swift; sourceTree = "<group>"; };
BC6E7CAB1C39A9D8006DF678 /* GPUImage.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GPUImage.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BC6E7CB01C39A9D8006DF678 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; name = Info.plist; path = Source/Mac/Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -460,7 +460,7 @@
BCFF46BD1CB8ACDA00A0C521 /* TiltShift_GL.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = TiltShift_GL.fsh; path = Source/Operations/Shaders/TiltShift_GL.fsh; sourceTree = "<group>"; };
BCFF46BF1CB9556B00A0C521 /* WhiteBalance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WhiteBalance.swift; path = Source/Operations/WhiteBalance.swift; sourceTree = "<group>"; };
BCFF46C11CB9560700A0C521 /* WhiteBalance_GL.fsh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.glsl; name = WhiteBalance_GL.fsh; path = Source/Operations/Shaders/WhiteBalance_GL.fsh; sourceTree = "<group>"; };
BCFF46C31CB9565F00A0C521 /* MotionBlur.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MotionBlur.swift; path = Source/Operations/MotionBlur.swift; sourceTree = "<group>"; };
BCFF46C31CB9565F00A0C521 /* MotionBlur.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = MotionBlur.swift; path = Source/Operations/MotionBlur.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
BCFF46C51CB968DE00A0C521 /* ImageBuffer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ImageBuffer.swift; path = Source/Operations/ImageBuffer.swift; sourceTree = "<group>"; };
BCFF46C71CB96AB100A0C521 /* LowPassFilter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LowPassFilter.swift; path = Source/Operations/LowPassFilter.swift; sourceTree = "<group>"; };
BCFF46C91CB96BD700A0C521 /* HighPassFilter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = HighPassFilter.swift; path = Source/Operations/HighPassFilter.swift; sourceTree = "<group>"; };
Expand Down
4 changes: 2 additions & 2 deletions framework/Source/Mac/Camera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class Camera: NSObject, ImageSource, AVCaptureVideoDataOutputSampleBuffer
let captureAsYUV:Bool
let yuvConversionShader:ShaderProgram?
let frameRenderingSemaphore = DispatchSemaphore(value:1)
let cameraProcessingQueue = DispatchQueue.global(attributes:DispatchQueue.GlobalAttributes.priorityDefault)
let audioProcessingQueue = DispatchQueue.global(attributes:DispatchQueue.GlobalAttributes.priorityBackground)
let cameraProcessingQueue = DispatchQueue.global(attributes:standardProcessingQueuePriority)
let audioProcessingQueue = DispatchQueue.global(attributes:lowProcessingQueuePriority)

var numberOfFramesCaptured = 0
var totalFrameTimeDuringCapture:Double = 0.0
Expand Down
2 changes: 1 addition & 1 deletion framework/Source/Mac/MovieInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MovieInput: ImageSource {

public func start() {
asset.loadValuesAsynchronously(forKeys: ["tracks"], completionHandler: {
DispatchQueue.global(attributes: DispatchQueue.GlobalAttributes.priorityDefault).async {
DispatchQueue.global(attributes:standardProcessingQueuePriority).async {
guard (self.asset.statusOfValue(forKey:"tracks", error:nil) == .loaded) else { return }

guard self.assetReader.startReading() else {
Expand Down
4 changes: 2 additions & 2 deletions framework/Source/Operations/GaussianBlur.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func pixelRadiusForBlurSigma(_ sigma:Double) -> UInt {
var calculatedSampleRadius:UInt = 0
if (sigma >= 1.0) { // Avoid a divide-by-zero error here
// Calculate the number of pixels to sample from by setting a bottom limit for the contribution of the outermost pixel
calculatedSampleRadius = UInt(floor(sqrt(-2.0 * pow(sigma, 2.0) * log(minimumWeightToFindEdgeOfSamplingArea * sqrt(2.0 * M_PI * pow(sigma, 2.0))) )))
calculatedSampleRadius = UInt(floor(sqrt(-2.0 * pow(sigma, 2.0) * log(minimumWeightToFindEdgeOfSamplingArea * sqrt(2.0 * .pi * pow(sigma, 2.0))) )))
calculatedSampleRadius += calculatedSampleRadius % 2 // There's nothing to gain from handling odd radius sizes, due to the optimizations I use
}

Expand All @@ -60,7 +60,7 @@ func standardGaussianWeightsForRadius(_ blurRadius:UInt, sigma:Double) -> [Doubl
var gaussianWeights = [Double]()
var sumOfWeights = 0.0
for gaussianWeightIndex in 0...blurRadius {
let weight = (1.0 / sqrt(2.0 * M_PI * pow(sigma, 2.0))) * exp(-pow(Double(gaussianWeightIndex), 2.0) / (2.0 * pow(sigma, 2.0)))
let weight = (1.0 / sqrt(2.0 * .pi * pow(sigma, 2.0))) * exp(-pow(Double(gaussianWeightIndex), 2.0) / (2.0 * pow(sigma, 2.0)))
gaussianWeights.append(weight)
if (gaussianWeightIndex == 0) {
sumOfWeights += weight
Expand Down
8 changes: 4 additions & 4 deletions framework/Source/Operations/MotionBlur.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class MotionBlur: BasicOperation {
let aspectRatio = inputFramebuffer.aspectRatioForRotation(outputRotation)
let directionalTexelStep:Position
if outputRotation.flipsDimensions() {
let xOffset = blurSize * Float(sin(Double(blurAngle) * M_PI / 180.0)) * aspectRatio * texelSize.width
let yOffset = blurSize * Float(cos(Double(blurAngle) * M_PI / 180.0)) * texelSize.width
let xOffset = blurSize * Float(sin(Double(blurAngle) * .pi / 180.0)) * aspectRatio * texelSize.width
let yOffset = blurSize * Float(cos(Double(blurAngle) * .pi / 180.0)) * texelSize.width
directionalTexelStep = Position(xOffset, yOffset)
} else {
let xOffset = blurSize * Float(cos(Double(blurAngle) * M_PI / 180.0)) * aspectRatio * texelSize.width
let yOffset = blurSize * Float(sin(Double(blurAngle) * M_PI / 180.0)) * texelSize.width
let xOffset = blurSize * Float(cos(Double(blurAngle) * .pi / 180.0)) * aspectRatio * texelSize.width
let yOffset = blurSize * Float(sin(Double(blurAngle) * .pi / 180.0)) * texelSize.width
directionalTexelStep = Position(xOffset, yOffset)
}

Expand Down
16 changes: 16 additions & 0 deletions framework/Source/SerialDispatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ extension SerialDispatch {

#else

public let standardProcessingQueuePriority:DispatchQueue.GlobalAttributes = {
if #available(iOS 10, OSX 10.10, *) {
return DispatchQueue.GlobalAttributes.qosDefault
} else {
return DispatchQueue.GlobalAttributes.priorityDefault
}
}()

public let lowProcessingQueuePriority:DispatchQueue.GlobalAttributes = {
if #available(iOS 10, OSX 10.10, *) {
return DispatchQueue.GlobalAttributes.qosBackground
} else {
return DispatchQueue.GlobalAttributes.priorityLow
}
}()

func runAsynchronouslyOnMainQueue(_ mainThreadOperation:() -> ()) {
if (Thread.isMainThread()) {
mainThreadOperation()
Expand Down

0 comments on commit a478629

Please sign in to comment.