瀏覽代碼

跳跃卡点最后图片持续三秒问题

huzhiqiang 3 年之前
父節點
當前提交
ef07a72279

+ 8 - 8
BFFramework/Classes/PQGPUImage/akfilters/PQGPUImageDebugFilter.swift

@@ -31,7 +31,7 @@ open class PQGPUImageDebug: BasicOperation {
     var lastSubtitle: PQEditSubTitleModel?
 
     deinit {
-        FilterLog(message: "字幕析构 ")
+        BFLog(2, message: "字幕析构 ")
         clearData()
     }
 
@@ -75,7 +75,7 @@ open class PQGPUImageDebug: BasicOperation {
         subtitleLab.font = UIFont.boldSystemFont(ofSize: CGFloat(isBigSubtile ? 114 : font))
         subtitleLab.numberOfLines = 0
 
-        FilterLog(message: "字幕初始化时大小 \(subtitleLab.frame)")
+        BFLog(2, message: "字幕初始化时大小 \(subtitleLab.frame)")
 
         subtitleLab.textAlignment = .center
         subtitleLab.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.5)
@@ -114,7 +114,7 @@ open class PQGPUImageDebug: BasicOperation {
     
     func createTexture(text: String) {
         DispatchQueue.main.async {
-            FilterLog(message: "value istimescale is \(text)")
+            BFLog(2, message: "value istimescale is \(text)")
 
             self.update(text: text)
 
@@ -133,7 +133,7 @@ open class PQGPUImageDebug: BasicOperation {
 
     func createTexture(currtime: CMTime) {
         DispatchQueue.main.async {
-            FilterLog(message: "value istimescale is \(currtime)")
+            BFLog(2, message: "value istimescale is \(currtime)")
 
 //            self.update(withTimestamp: currtime)
 
@@ -168,7 +168,7 @@ open class PQGPUImageDebug: BasicOperation {
         let inputSize = inputFramebuffer.sizeForTargetOrientation(.portrait)
 
         let currTime = CMTimeGetSeconds(CMTime(value: inputFramebuffer.timingStyle.timestamp!.value, timescale: inputFramebuffer.timingStyle.timestamp!.timescale))
-        FilterLog(message: "subtitle 当前时间: \(currTime)")
+        BFLog(2, message: "subtitle 当前时间: \(currTime)")
 
         // 原有画布
         renderFramebuffer = sharedImageProcessingContext.framebufferCache.requestFramebufferWithProperties(orientation: .portrait, size: inputSize, stencil: false)
@@ -182,14 +182,14 @@ open class PQGPUImageDebug: BasicOperation {
         releaseIncomingFramebuffers()
 
         if subTitleTexture != 0 {
-            FilterLog(message: "UIElementFramebuffer 有值可以正常显示")
+            BFLog(2, message: "UIElementFramebuffer 有值可以正常显示")
             let texturePropertiesimagetwo = InputTextureProperties(textureCoordinates: inputFramebuffer.orientation.rotationNeededForOrientation(.portrait).textureCoordinates(), texture: subTitleTexture)
 
-            FilterLog(message: "subtitleSize subtitleSize is\(String(describing: subtitleSize)) \(inputCGSize)")
+            BFLog(2, message: "subtitleSize subtitleSize is\(String(describing: subtitleSize)) \(inputCGSize)")
 
             let size: CGSize = inputCGSize
             let bounds2: CGRect = CGRect(x: (inputCGSize.width - subtitleSize!.width) / 2, y: inputCGSize.height - subtitleSize!.height - 60, width: subtitleSize!.width, height: subtitleSize!.height)
-            FilterLog(message: "inputCGSize is \(size)  bounds2\(bounds2)")
+            BFLog(2, message: "inputCGSize is \(size)  bounds2\(bounds2)")
             renderQuadWithShader(shader,
                                  uniformSettings: uniformSettings,
                                  vertexBufferObject: PQGPUImageTools.NXGenerateVBO(for: PQGPUImageTools.computeVertices(viewSize: inputCGSize, _bounds: CGRect(x: (inputCGSize.width - subtitleSize!.width) / 2, y: isBigSubtile ? (inputCGSize.height - subtitleSize!.height - 60) / 2 : inputCGSize.height - subtitleSize!.height - 60, width: subtitleSize!.width, height: subtitleSize!.height))),

+ 20 - 20
BFFramework/Classes/PQGPUImage/akfilters/PQGPUImageTools.swift

@@ -49,7 +49,7 @@ open class PQGPUImageTools: NSObject {
 
     // 图片转纹理集数据 XXXXX 使用方法后 返回的 imageTexture 要清空纹理,注意不清空显存会暴增     glDeleteTextures(1,&imageTexture)
     class func setupTexture(image: CGImage) -> GLuint {
-        FilterLog(message: "图片转纹理集数据 =====width :\(image.width) height: \(image.height)")
+        BFLog(2, message: "图片转纹理集数据 =====width :\(image.width) height: \(image.height)")
 
         let widthOfImage = GLint(image.width)
         let heightOfImage = GLint(image.height)
@@ -118,7 +118,7 @@ open class PQGPUImageTools: NSObject {
                     }
                 }
             }
-            FilterLog(message: "图片转纹理集数据2222 =====")
+            BFLog(2, message: "图片转纹理集数据2222 =====")
 
             //        sharedImageProcessingContext.runOperationSynchronously{
             //    CFAbsoluteTime elapsedTime, startTime = CFAbsoluteTimeGetCurrent();
@@ -141,10 +141,10 @@ open class PQGPUImageTools: NSObject {
                 dataFromImageDataProvider = data
                 imageData = UnsafeMutablePointer<GLubyte>(mutating: CFDataGetBytePtr(dataFromImageDataProvider))
             }
-            FilterLog(message: "图片转纹理集数据333333 =====")
+            BFLog(2, message: "图片转纹理集数据333333 =====")
 
             glEnable(GLenum(GL_TEXTURE_2D))
-            FilterLog(message: "图片转纹理集数据44444 =====")
+            BFLog(2, message: "图片转纹理集数据44444 =====")
 
             /**
              *  GL_TEXTURE_2D表示操作2D纹理
@@ -153,10 +153,10 @@ open class PQGPUImageTools: NSObject {
              */
 
             glGenTextures(1, &textureID)
-            FilterLog(message: "图片转纹理集数据5555 =====\(textureID)")
+            BFLog(2, message: "图片转纹理集数据5555 =====\(textureID)")
 
             glBindTexture(GLenum(GL_TEXTURE_2D), textureID)
-            FilterLog(message: "图片转纹理集数据6666 =====\(textureID)")
+            BFLog(2, message: "图片转纹理集数据6666 =====\(textureID)")
 
             /**
              *  纹理过滤函数
@@ -186,29 +186,29 @@ open class PQGPUImageTools: NSObject {
              * 参数8:type
              * 参数9:纹理数据
              */
-            FilterLog(message: "载入纹理 =====")
-            FilterLog(message: "GL_TEXTURE_2D =====\(GL_TEXTURE_2D)")
-            FilterLog(message: "GL_RGBA =====\(GL_RGBA)")
-            FilterLog(message: "widthOfImage =====\(widthOfImage)")
-            FilterLog(message: "heightOfImage =====\(heightOfImage)")
-            FilterLog(message: "GL_UNSIGNED_BYTE =====\(GL_UNSIGNED_BYTE)")
-            FilterLog(message: "imageData =====\(String(describing: imageData))")
-            FilterLog(message: "GLenum(GL_TEXTURE_2D) =====\(GLenum(GL_TEXTURE_2D))")
-            FilterLog(message: "GLenum(format) =====\(GLenum(format))")
-            FilterLog(message: "GLenum(GL_UNSIGNED_BYTE) =====\(GLenum(GL_UNSIGNED_BYTE))")
+            BFLog(2, message: "载入纹理 =====")
+            BFLog(2, message: "GL_TEXTURE_2D =====\(GL_TEXTURE_2D)")
+            BFLog(2, message: "GL_RGBA =====\(GL_RGBA)")
+            BFLog(2, message: "widthOfImage =====\(widthOfImage)")
+            BFLog(2, message: "heightOfImage =====\(heightOfImage)")
+            BFLog(2, message: "GL_UNSIGNED_BYTE =====\(GL_UNSIGNED_BYTE)")
+            BFLog(2, message: "imageData =====\(String(describing: imageData))")
+            BFLog(2, message: "GLenum(GL_TEXTURE_2D) =====\(GLenum(GL_TEXTURE_2D))")
+            BFLog(2, message: "GLenum(format) =====\(GLenum(format))")
+            BFLog(2, message: "GLenum(GL_UNSIGNED_BYTE) =====\(GLenum(GL_UNSIGNED_BYTE))")
 
             glTexImage2D(GLenum(GL_TEXTURE_2D), 0, GL_RGBA, widthToUseForTexture, heightToUseForTexture, 0, GLenum(format), GLenum(GL_UNSIGNED_BYTE), imageData)
 
             // 结束后要做清理
-            FilterLog(message: "结束后要做清理 =====")
-            FilterLog(message: "GLenum(GL_TEXTURE_2D) =====\(GLenum(GL_TEXTURE_2D))")
+            BFLog(2, message: "结束后要做清理 =====")
+            BFLog(2, message: "GLenum(GL_TEXTURE_2D) =====\(GLenum(GL_TEXTURE_2D))")
 
             glBindTexture(GLenum(GL_TEXTURE_2D), 0) // 解绑
 
-            FilterLog(message: "结束后要做清理1111111 =====")
+            BFLog(2, message: "结束后要做清理1111111 =====")
             imageData.deallocate()
 
-            FilterLog(message: "textureID =====\(textureID)")
+            BFLog(2, message: "textureID =====\(textureID)")
         }
 
         return textureID

+ 9 - 9
BFFramework/Classes/PQGPUImage/akfilters/PQGifFilter.swift

@@ -32,7 +32,7 @@ open class PQGifFilter: PQBaseFilter {
         super.init(fragmentShader: PassthroughFragmentShader, numberOfInputs: 1)
         mSticker = sticker
 
-        FilterLog(message: "gif file path \(mSticker?.locationPath ?? "")")
+        BFLog(2, message: "gif file path \(mSticker?.locationPath ?? "")")
         var gifData: Data!
         autoreleasepool {
             do {
@@ -51,7 +51,7 @@ open class PQGifFilter: PQBaseFilter {
 
             self.mGifImages = images ?? []
             self.mDuration = duration ?? 0
-            FilterLog(message: "gif 原始时长 \(String(describing: duration)) 逻辑时长: \(String(describing: self.mSticker?.aptDuration)) 帧数:\(String(describing: images?.count))")
+            BFLog(2, message: "gif 原始时长 \(String(describing: duration)) 逻辑时长: \(String(describing: self.mSticker?.aptDuration)) 帧数:\(String(describing: images?.count))")
 
             if images!.count > 0 {
                 self.gifSize = images!.first!.size
@@ -79,23 +79,23 @@ open class PQGifFilter: PQBaseFilter {
     func updateImages(_ currTime: Float64) {
         autoreleasepool {
             if mGifImages.count == 0 {
-                FilterLog(message: "gif 文件有问题 一帧都没有")
+                BFLog(2, message: "gif 文件有问题 一帧都没有")
                 return
             }
             if delayTime <= 0 {
-                FilterLog(message: "gif 时间计算出错")
+                BFLog(2, message: "gif 时间计算出错")
                 return
             }
             // 判断显示哪一帧
             var gifIndex = delayTime <= 0 ? 0 : Int(((currTime >= beginTime) ? currTime - beginTime : currTime) / delayTime)
             if mSticker?.materialDurationFit?.fitType == adapterMode.staticFrame.rawValue && gifIndex >= mGifImages.count { // 定帧
-                FilterLog(message: "定帧效果 \(gifIndex)")
+                BFLog(2, message: "定帧效果 \(gifIndex)")
                 imageTexture = PQGPUImageTools.setupTexture(image: (mGifImages.last?.cgImage)!)
                 return
             }
 
             if gifIndex >= mGifImages.count && mSticker?.materialDurationFit?.fitType == adapterMode.loopAuto.rawValue { // 自动循环重新计算开始时间 达到循环效果
-                FilterLog(message: "自动循环效果")
+                BFLog(2, message: "自动循环效果")
                 gifIndex = gifIndex % mGifImages.count
             }
 
@@ -131,7 +131,7 @@ open class PQGifFilter: PQBaseFilter {
             let inputSize = inputFramebuffer.sizeForTargetOrientation(.portrait)
 
             let currTime = CMTimeGetSeconds(CMTime(value: inputFramebuffer.timingStyle.timestamp!.value, timescale: inputFramebuffer.timingStyle.timestamp!.timescale))
-            FilterLog(message: "gif filter 当前时间: \(currTime) ")
+            BFLog(2, message: "gif filter 当前时间: \(currTime) ")
 
             // 原有画布
             renderFramebuffer = sharedImageProcessingContext.framebufferCache.requestFramebufferWithProperties(orientation: .portrait, size: inputSize, stencil: false)
@@ -145,7 +145,7 @@ open class PQGifFilter: PQBaseFilter {
             releaseIncomingFramebuffers()
 
             if currTime >= mSticker!.timelineIn, currTime <= mSticker!.timelineOut {
-                FilterLog(message: " 显示gif当前时间: \(currTime) 开始时间:\(mSticker!.timelineIn) 结束时间:\(mSticker!.timelineOut)  ")
+                BFLog(2, message: " 显示gif当前时间: \(currTime) 开始时间:\(mSticker!.timelineIn) 结束时间:\(mSticker!.timelineOut)  ")
 
                 // 绘制 image
                 let textureCoordinates = PQGPUImageTools.getTextureCoordinates(sticker: mSticker!, textureSize: gifSize, cannvasSize: inputSize)
@@ -167,7 +167,7 @@ open class PQGifFilter: PQBaseFilter {
                 // XXXXXXX 清空纹理,注意不清空显存会暴增
                 glDeleteTextures(1, &imageTexture)
             } else {
-                FilterLog(message: " 不显示gif时: \(currTime) 开始时间:\(mSticker!.timelineIn) 结束时间:\(mSticker!.timelineOut)")
+                BFLog(2, message: " 不显示gif时: \(currTime) 开始时间:\(mSticker!.timelineIn) 结束时间:\(mSticker!.timelineOut)")
             }
         }
     }

+ 10 - 10
BFFramework/Classes/PQGPUImage/akfilters/PQImageFilter.swift

@@ -34,7 +34,7 @@ open class PQImageFilter: PQBaseFilter {
         stickerInfo = sticker
 
         if mSticker!.locationPath.count == 0 {
-            FilterLog(message: "图片数据为空,创建失败")
+            BFLog(2, message: "图片数据为空,创建失败")
             return
         }
 //        print("mSticker path : \(String(describing: mSticker!.locationPath))")
@@ -59,11 +59,11 @@ open class PQImageFilter: PQBaseFilter {
 //                if (!__CGSizeEqualToSize(aptImageSize, newImage!.size))
 //                {
 //
-//                    FilterLog(message: "原图大小宽度不是16的倍数 \(newImage!.size)")
+//                    BFLog(2, message: "原图大小宽度不是16的倍数 \(newImage!.size)")
 //
 //                    newImage = newImage?.nx_scaleToSize(size: aptImageSize)
 //
-//                    FilterLog(message: "归16后大小 \(newImage!.size)")
+//                    BFLog(2, message: "归16后大小 \(newImage!.size)")
 //
 //                }
 
@@ -77,7 +77,7 @@ open class PQImageFilter: PQBaseFilter {
                     if fileData.count != 0, fileData.isWebPFormat {
                         newImage = WebPProcessor.default.process(item: ImageProcessItem.data(fileData), options: KingfisherParsedOptionsInfo([.onlyLoadFirstFrame, .scaleFactor(1)]))
                     }
-                } else { FilterLog(message: "文件不存在") }
+                } else { BFLog(2, message: "文件不存在") }
             }
         }
 
@@ -86,7 +86,7 @@ open class PQImageFilter: PQBaseFilter {
 
 //            imageTexture = PQGPUImageTools.setupTexture(image: newImage!.cgImage!)
 
-        } else { FilterLog(message: "image filter init error image data is nil!") }
+        } else { BFLog(2, message: "image filter init error image data is nil!") }
     }
 
 //    override public func newFramebufferAvailable(_ framebuffer: Framebuffer, fromSourceIndex: UInt) {
@@ -121,22 +121,22 @@ open class PQImageFilter: PQBaseFilter {
         releaseIncomingFramebuffers()
 
         if newImage == nil {
-            FilterLog(message: "图片数据有错误!!!! 检查数据\(mSticker!.locationPath)")
+            BFLog(2, message: "图片数据有错误!!!! 检查数据\(mSticker!.locationPath)")
             return
         }
 
-        FilterLog(message: " image filter 当前时间: \(currTime) \(newImage!.size)")
+        BFLog(2, message: " image filter 当前时间: \(currTime) \(newImage!.size)")
 
 //        if currTime >= mSticker!.timelineIn && currTime <= mSticker!.timelineOut {
-        FilterLog(message: " 显示图片当前时间: \(currTime) 开始时间:\(mSticker!.timelineIn) 结束时间:\(mSticker!.timelineOut)  \(String(describing: newImage?.size))")
+        BFLog(2, message: " 显示图片当前时间: \(currTime) 开始时间:\(mSticker!.timelineIn) 结束时间:\(mSticker!.timelineOut)  \(String(describing: newImage?.size))")
         // 取纹理坐标
         let textureCoordinates = PQGPUImageTools.getTextureCoordinates(sticker: mSticker!, textureSize: newImage!.size, cannvasSize: inputSize)
 
-        FilterLog(message: "textureCoordinates is \(textureCoordinates)")
+        BFLog(2, message: "textureCoordinates is \(textureCoordinates)")
 
         // imageTexture 有可能被析构导致黑屏
         if imageTexture == 0 && newImage?.cgImage != nil {
-            FilterLog(message: "imageTexture is error !!!!!重新创建")
+            BFLog(2, message: "imageTexture is error !!!!!重新创建")
             imageTexture = PQGPUImageTools.setupTexture(image: newImage!.cgImage!)
         }
 

+ 24 - 24
BFFramework/Classes/PQGPUImage/akfilters/PQMovieFilter.swift

@@ -139,7 +139,7 @@ class PQMovieFilter: PQBaseFilter {
         super.init(fragmentShader: PassthroughFragmentShader, numberOfInputs: 1)
         moveSticker = movieSticker
         stickerInfo = movieSticker
-        FilterLog(message: "资源裁剪的 开始时间\(moveSticker!.model_in)  结束时间: \(moveSticker!.out)")
+        BFLog(2, message: "资源裁剪的 开始时间\(moveSticker!.model_in)  结束时间: \(moveSticker!.out)")
         if moveSticker!.videoIsCrop() {
             requestedStartTime = CMTimeMake(value: Int64(moveSticker!.model_in) * Int64(BASE_FILTER_TIMESCALE), timescale: BASE_FILTER_TIMESCALE)
         }
@@ -152,14 +152,14 @@ class PQMovieFilter: PQBaseFilter {
             if !videoFilePath.contains("var/mobile/Media") {
                 videoFilePath = documensDirectory + videoFilePath
             }
-            FilterLog(message: "视频地址 \(String(describing: videoFilePath))")
+            BFLog(2, message: "视频地址 \(String(describing: videoFilePath))")
             try loadAsset(url: URL(fileURLWithPath: videoFilePath), videoComposition: nil)
 
         } catch {
             NXLog(message: "load asset  with error: \(error)")
         }
 
-        FilterLog(message: " move FILTER 初始化 开始显示时间:\(movieSticker.timelineIn) 结束显示时间:\(movieSticker.timelineOut)  裁剪开始时间:\(movieSticker.model_in)  裁剪结束时间:\(movieSticker.out)  路径:\(String(describing: movieSticker.locationPath)) 时长 \(CMTimeGetSeconds(asset?.duration ?? .zero))")
+        BFLog(2, message: " move FILTER 初始化 开始显示时间:\(movieSticker.timelineIn) 结束显示时间:\(movieSticker.timelineOut)  裁剪开始时间:\(movieSticker.model_in)  裁剪结束时间:\(movieSticker.out)  路径:\(String(describing: movieSticker.locationPath)) 时长 \(CMTimeGetSeconds(asset?.duration ?? .zero))")
 
         startReading()
 //
@@ -184,7 +184,7 @@ class PQMovieFilter: PQBaseFilter {
         inputSize = inputFramebuffer.sizeForTargetOrientation(.portrait)
 
         currentTime = CMTime(value: inputFramebuffer.timingStyle.timestamp!.value, timescale: inputFramebuffer.timingStyle.timestamp!.timescale)
-        FilterLog(message: "wwwwwwwww duration is currentSampleTime is \(CMTimeGetSeconds(currentTime))")
+        BFLog(2, message: "wwwwwwwww duration is currentSampleTime is \(CMTimeGetSeconds(currentTime))")
 
         renderFramebuffer = sharedImageProcessingContext.framebufferCache.requestFramebufferWithProperties(orientation: mImageOrientation, size: inputSize, stencil: false)
 
@@ -196,10 +196,10 @@ class PQMovieFilter: PQBaseFilter {
                              vertexBufferObject: sharedImageProcessingContext.standardImageVBO, inputTextures: [textureProperties])
         releaseIncomingFramebuffers()
 
-        FilterLog(message: "开始显示 movefilter 了 开始\(String(describing: moveSticker?.timelineIn)) 结束 :\(String(describing: moveSticker?.timelineOut)) currentTime \(CMTimeGetSeconds(currentTime)) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) ")
+        BFLog(2, message: "开始显示 movefilter 了 开始\(String(describing: moveSticker?.timelineIn)) 结束 :\(String(describing: moveSticker?.timelineOut)) currentTime \(CMTimeGetSeconds(currentTime)) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) ")
 
         if enableSeek {
-            FilterLog(message: "seek 到 \(CMTimeGetSeconds(currentTime))  ")
+            BFLog(2, message: "seek 到 \(CMTimeGetSeconds(currentTime))  ")
             resetRangeTime(startTime: currentTime)
             enableSeek = false
         }
@@ -229,7 +229,7 @@ class PQMovieFilter: PQBaseFilter {
     // 原视频角度类型
     func moveAssetRotation() -> NXGPUImageRotationMode {
         let Angle: Int = PQPHAssetVideoParaseUtil.videoRotationAngle(assert: asset!)
-//        FilterLog(message: "原视频素材Angle is \(Angle)")
+//        BFLog(2, message: "原视频素材Angle is \(Angle)")
         // see https://my.oschina.net/NycoWang/blog/904105
         switch Angle {
         case -90, 270:
@@ -254,14 +254,14 @@ class PQMovieFilter: PQBaseFilter {
             stickerFPS = asset!.tracks(withMediaType: .video).first?.nominalFrameRate ?? 0.0
             let bitRate = asset!.tracks(withMediaType: .video).first?.estimatedDataRate
 
-            FilterLog(message: "move filter asset  fps is \(String(describing: stickerFPS))  bit rate is \(bitRate ?? 0)")
+            BFLog(2, message: "move filter asset  fps is \(String(describing: stickerFPS))  bit rate is \(bitRate ?? 0)")
 
             self.videoComposition = videoComposition
             self.playAtActualSpeed = playAtActualSpeed
 
             yuvConversionShader = crashOnShaderCompileFailure("MovieInput") { try sharedImageProcessingContext.programForVertexShader(defaultVertexShaderForInputs(2), fragmentShader: YUVConversionFullRangeFragmentShader) }
             self.audioSettings = audioSettings
-        } else { FilterLog(message: "asset is nil") }
+        } else { BFLog(2, message: "asset is nil") }
     }
 
     // MARK: -
@@ -278,7 +278,7 @@ class PQMovieFilter: PQBaseFilter {
             let videoTrack: AVAssetTrack = asset!.tracks(withMediaType: .video).first!
 
             videoSize = videoTrack.naturalSize
-            FilterLog(message: "视频大小为 : \(videoSize)")
+            BFLog(2, message: "视频大小为 : \(videoSize)")
 
             if videoComposition == nil {
                 let readerVideoTrackOutput = AVAssetReaderTrackOutput(track: asset!.tracks(withMediaType: .video).first!, outputSettings: outputSettings)
@@ -292,7 +292,7 @@ class PQMovieFilter: PQBaseFilter {
             }
             assetReader!.timeRange = CMTimeRange(start: CMTime(value: Int64((moveSticker?.model_in ?? 0) * Float64(BASE_FILTER_TIMESCALE)), timescale: BASE_FILTER_TIMESCALE), duration: CMTimeMake(value: Int64(((moveSticker?.out ?? 0) - (moveSticker?.model_in ?? 0)) * Float64(BASE_FILTER_TIMESCALE)), timescale: BASE_FILTER_TIMESCALE))
 
-            FilterLog(message: "set   assetReader!.timeRange is \(assetReader!.timeRange)")
+            BFLog(2, message: "set   assetReader!.timeRange is \(assetReader!.timeRange)")
 
             return assetReader
         } catch {
@@ -302,7 +302,7 @@ class PQMovieFilter: PQBaseFilter {
     }
 
     open func startReading() {
-        FilterLog(message: "开始初始化")
+        BFLog(2, message: "开始初始化")
         mach_timebase_info(&timebaseInfo)
 
         assetReader?.cancelReading()
@@ -329,7 +329,7 @@ class PQMovieFilter: PQBaseFilter {
 
     // 设置解码开始时间
     func resetRangeTime(startTime: CMTime = .zero) {
-        FilterLog(message: "\(String(describing: moveSticker?.locationPath)) 取帧的时间 \(CMTimeGetSeconds(requestedStartTime ?? .zero))")
+        BFLog(2, message: "\(String(describing: moveSticker?.locationPath)) 取帧的时间 \(CMTimeGetSeconds(requestedStartTime ?? .zero))")
         requestedStartTime = startTime
         startReading()
     }
@@ -345,12 +345,12 @@ class PQMovieFilter: PQBaseFilter {
 
         // 最后一帧的PTS > 要显示的目标时间 就不从解码器要数据,直接返回 view 不刷新 只有慢速时会调用
 //        if CMTimeGetSeconds(targetTimeStamp) >= CMTimeGetSeconds(showTimeStamp) + (stickerInfo?.model_in ?? 0) && CMTimeGetSeconds(targetTimeStamp) != 0 {
-            FilterLog(message: "28797speedRate  目标显示时间 \(String(format: "%.6f", (CMTimeGetSeconds(showTimeStamp)))) 最后显示的时间 \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp))) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) speedRate is \(stickerInfo!.speedRate)")
+            BFLog(2, message: "28797speedRate  目标显示时间 \(String(format: "%.6f", (CMTimeGetSeconds(showTimeStamp)))) 最后显示的时间 \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp))) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) speedRate is \(stickerInfo!.speedRate)")
             return
         }
 
         if assetReader == nil {
-            FilterLog(message: "assetReader is error 出现严重错误!!!!!!!!!!!!!!")
+            BFLog(2, message: "assetReader is error 出现严重错误!!!!!!!!!!!!!!")
             return
         }
 
@@ -371,7 +371,7 @@ class PQMovieFilter: PQBaseFilter {
             count = count + 1
             sampleBuffer = videoTrackOutput!.copyNextSampleBuffer()
             if sampleBuffer == nil {
-                FilterLog(message: " copyNextSampleBuffer is nil error!!!")
+                BFLog(2, message: " copyNextSampleBuffer is nil error!!!")
                 return
             }
             targetTimeStamp = CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer!)
@@ -380,12 +380,12 @@ class PQMovieFilter: PQBaseFilter {
             if sampleBuffer != nil && CMTimeGetSeconds(targetTimeStamp) >= CMTimeGetSeconds(showTimeStamp) {
                 let endDecoderTime: TimeInterval = Date().timeIntervalSince1970
                 
-                FilterLog(message: " 28797speedRate is \(stickerInfo!.speedRate) 当前主线时间为:\(String(format: "%.6f", CMTimeGetSeconds(currentTime))) 查找的帧时间为:\(String(format: "%.6f", CMTimeGetSeconds(showTimeStamp).truncatingRemainder(dividingBy: moveSticker!.out))) 要命中时间:\(CMTimeGetSeconds(showTimeStamp)) 命中时间为: \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp))) 差值\(CMTimeGetSeconds(targetTimeStamp) - (stickerInfo?.model_in ?? 0)) 查找耗时为:\(String(format: "%.6f", TimeInterval(endDecoderTime - beginDecoderTime))) 查找次数\(count)  进场时间: \(String(describing: moveSticker?.timelineIn))  裁剪开始时间:\(String(describing: moveSticker?.model_in)) 裁剪结束时间:\(String(describing: moveSticker?.out)) 原视频时长: \(CMTimeGetSeconds(asset?.duration ?? .zero))")
+                BFLog(2, message: " 28797speedRate is \(stickerInfo!.speedRate) 当前主线时间为:\(String(format: "%.6f", CMTimeGetSeconds(currentTime))) 查找的帧时间为:\(String(format: "%.6f", CMTimeGetSeconds(showTimeStamp).truncatingRemainder(dividingBy: moveSticker!.out))) 要命中时间:\(CMTimeGetSeconds(showTimeStamp)) 命中时间为: \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp))) 差值\(CMTimeGetSeconds(targetTimeStamp) - (stickerInfo?.model_in ?? 0)) 查找耗时为:\(String(format: "%.6f", TimeInterval(endDecoderTime - beginDecoderTime))) 查找次数\(count)  进场时间: \(String(describing: moveSticker?.timelineIn))  裁剪开始时间:\(String(describing: moveSticker?.model_in)) 裁剪结束时间:\(String(describing: moveSticker?.out)) 原视频时长: \(CMTimeGetSeconds(asset?.duration ?? .zero))")
                 break
 
             }
 //            else {
-//                FilterLog(message: "不丢帧显示  查找的帧时间为:\(String(format: "%.6f", CMTimeGetSeconds(showTimeStamp).truncatingRemainder(dividingBy: moveSticker!.out)))  命中时间为: \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp)))")
+//                BFLog(2, message: "不丢帧显示  查找的帧时间为:\(String(format: "%.6f", CMTimeGetSeconds(showTimeStamp).truncatingRemainder(dividingBy: moveSticker!.out)))  命中时间为: \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp)))")
 ////                usleep(2)
 ////                sharedImageProcessingContext.runOperationSynchronously {
 ////                    self.renderPixelBuffler(movieFrame: CMSampleBufferGetImageBuffer(sampleBuffer!)!, withSampleTime: currentTime)
@@ -404,23 +404,23 @@ class PQMovieFilter: PQBaseFilter {
             }
             return
         } else {
-            FilterLog(message: "sampleBuffer is  nil data is error self.assetReader?.status is \(String(describing: assetReader?.status))")
+            BFLog(2, message: "sampleBuffer is  nil data is error self.assetReader?.status is \(String(describing: assetReader?.status))")
         }
         // 二, 已经播放完一次
         if assetReader?.status == .completed {
             BFLog(message: "已经播放完一次")
             // 1 自动循环模式 重头开始循环
             if moveSticker?.materialDurationFit?.fitType == adapterMode.loopAuto.rawValue {
-                FilterLog(message: "自动循环模式 重头开始循环 \(CMTimeGetSeconds(currentTime))")
+                BFLog(2, message: "自动循环模式 重头开始循环 \(CMTimeGetSeconds(currentTime))")
 
                 startReading()
 
             } else if moveSticker?.materialDurationFit?.fitType == adapterMode.staticFrame.rawValue {
                 // 2),定帧处理
                 if lastImageBuffer != nil {
-                    FilterLog(message: "处理显示定帧")
+                    BFLog(2, message: "处理显示定帧")
                     let currTime = CMTimeGetSeconds(currentTime)
-                    FilterLog(message: "process time is \(currTime)")
+                    BFLog(2, message: "process time is \(currTime)")
                     sharedImageProcessingContext.runOperationSynchronously {
                         renderPixelBuffler(movieFrame: lastImageBuffer!, withSampleTime: currentTime)
                     }
@@ -435,7 +435,7 @@ class PQMovieFilter: PQBaseFilter {
     ///   - withSampleTime: 渲染时间戳,不是帧的 PTS 是渲染的时间
     func renderPixelBuffler(movieFrame: CVPixelBuffer, withSampleTime: CMTime) {
         // NV12 会返回 2,Y分量和UV 分量, 如果buffer 是BGRA 则返回0
-        FilterLog(message: "CVPixelBufferGetPlaneCount is \(CVPixelBufferGetPlaneCount(movieFrame))")
+        BFLog(2, message: "CVPixelBufferGetPlaneCount is \(CVPixelBufferGetPlaneCount(movieFrame))")
 
         let bufferHeight = CVPixelBufferGetHeight(movieFrame)
         let bufferWidth = CVPixelBufferGetWidth(movieFrame)
@@ -506,7 +506,7 @@ class PQMovieFilter: PQBaseFilter {
         convertYUVToRGBAK(shader: yuvConversionShader!, luminanceFramebuffer: luminanceFramebuffer, chrominanceFramebuffer: chrominanceFramebuffer, resultFramebuffer: movieFramebuffer, colorConversionMatrix: conversionMatrix)
         CVPixelBufferUnlockBaseAddress(movieFrame, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0)))
 
-        FilterLog(message: "mp4 render process time is \(CMTimeGetSeconds(withSampleTime))")
+        BFLog(2, message: "mp4 render process time is \(CMTimeGetSeconds(withSampleTime))")
         movieFramebuffer.timingStyle = .videoFrame(timestamp: Timestamp(withSampleTime))
 
         movieFramebuffer.userInfo = framebufferUserInfo

+ 37 - 37
BFFramework/Classes/PQGPUImage/akfilters/PQMovieInput.swift

@@ -137,7 +137,7 @@ public class PQMovieInput: ImageSource {
      // 画布的大小 注意要是偶数 要不在 IOS 13上会有绿边 自动放大到偶数
     public var mShowVidoSize: CGSize = cVideoCannvasSizeOneToOne {
         didSet {
-            FilterLog(message: "mShowVidoSize is move input  \(mShowVidoSize)")
+            BFLog(2, message: "mShowVidoSize is move input  \(mShowVidoSize)")
             do {
                 displayLink?.isPaused = true
                 imageFramebuffer = try Framebuffer(context: sharedImageProcessingContext, orientation: .portrait, size: GLSize(width: GLint(mShowVidoSize.width), height: GLint(mShowVidoSize.height)), textureOnly: true)
@@ -151,7 +151,7 @@ public class PQMovieInput: ImageSource {
     // 初始化方法
     public init(asset: AVAsset, videoComposition: AVVideoComposition?, audioMix: AVAudioMix?, playAtActualSpeed: Bool = false, loop: Bool = false, audioSettings: [String: Any]? = nil) throws {
         self.asset = asset
-        FilterLog(message: "asset 资源的总时长\(asset.duration.seconds) \(asset.duration)")
+        BFLog(2, message: "asset 资源的总时长\(asset.duration.seconds) \(asset.duration)")
         self.audioMix = audioMix
         self.audioSettings = audioSettings
         self.videoComposition = videoComposition
@@ -159,7 +159,7 @@ public class PQMovieInput: ImageSource {
         self.loop = loop
         yuvConversionShader = crashOnShaderCompileFailure("MovieInput") { try sharedImageProcessingContext.programForVertexShader(defaultVertexShaderForInputs(2), fragmentShader: YUVConversionFullRangeFragmentShader) }
         if asset.duration.seconds <= 0 {
-            FilterLog(message: "asset 资源的总时长为0,返回")
+            BFLog(2, message: "asset 资源的总时长为0,返回")
             return
         }
   
@@ -208,7 +208,7 @@ public class PQMovieInput: ImageSource {
         isPlay = false
         beginTime = 0
         currentTime = .zero
-        FilterLog(message: "初始化播放开始时间、\(CMTimeGetSeconds(timeRange.start)) 结束时间\(CMTimeGetSeconds(timeRange.end)) 播放总时长:\(CMTimeGetSeconds(timeRange.end) - CMTimeGetSeconds(timeRange.start))")
+        BFLog(2, message: "初始化播放开始时间、\(CMTimeGetSeconds(timeRange.start)) 结束时间\(CMTimeGetSeconds(timeRange.end)) 播放总时长:\(CMTimeGetSeconds(timeRange.end) - CMTimeGetSeconds(timeRange.start))")
   
         playeTimeRange = timeRange
         startTime = playeTimeRange.start
@@ -218,7 +218,7 @@ public class PQMovieInput: ImageSource {
 
     @objc func displayLinkClick(_ displayLink: CADisplayLink) {
         if assetReader == nil {
-            FilterLog(message: "self.assetReader is null !!!!!!!!!!")
+            BFLog(2, message: "self.assetReader is null !!!!!!!!!!")
             displayLink.isPaused = true
             return
         }
@@ -246,12 +246,12 @@ public class PQMovieInput: ImageSource {
   
             let prgressValue = currTime / Float64(duration)
             
-            FilterLog(message: "\(mIsExport) MovieOutput total frames appended:播放进行中 总用时: \(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0)) 播放器开始时间:\(CMTimeGetSeconds(playeTimeRange.start)) 播放器原始结束时间:\(CMTimeGetSeconds(playeTimeRange.end))    总时间:\(CMTimeGetSeconds(playeTimeRange.end) - CMTimeGetSeconds(playeTimeRange.start)) 播放进度当前时间:\(currTime) 进度:\(prgressValue) 帧id \(totalFramesSent)")
+            BFLog(2, message: "\(mIsExport) MovieOutput total frames appended:播放进行中 总用时: \(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0)) 播放器开始时间:\(CMTimeGetSeconds(playeTimeRange.start)) 播放器原始结束时间:\(CMTimeGetSeconds(playeTimeRange.end))    总时间:\(CMTimeGetSeconds(playeTimeRange.end) - CMTimeGetSeconds(playeTimeRange.start)) 播放进度当前时间:\(currTime) 进度:\(prgressValue) 帧id \(totalFramesSent)")
             totalFramesSent += 1
     
-            FilterLog(message: "播放进行中 总用时: \(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0)) 播放进度当前时间:\(currTime) 进度:\(prgressValue)")
+            BFLog(2, message: "播放进行中 总用时: \(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0)) 播放进度当前时间:\(currTime) 进度:\(prgressValue)")
             if currTime / duration > 1  {
-                FilterLog(message: "全部播放完成 总用时为:\(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0))")
+                BFLog(2, message: "全部播放完成 总用时为:\(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0))")
 
                 self.completion?()
  
@@ -270,9 +270,9 @@ public class PQMovieInput: ImageSource {
                 self.conditionLock.lock()
                 while self.readingShouldWait {
                     self.synchronizedEncodingDebugPrint("Disable reading")
-                    FilterLog(message: "Disable reading 开始等待 \(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0)) ")
+                    BFLog(2, message: "Disable reading 开始等待 \(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0)) ")
                     self.conditionLock.wait()
-                    FilterLog(message: "Enable reading  停止等待 \(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0))")
+                    BFLog(2, message: "Enable reading  停止等待 \(CFAbsoluteTimeGetCurrent() - (debugStartTime ?? 0.0))")
                 }
                 self.conditionLock.unlock()
 
@@ -305,11 +305,11 @@ public class PQMovieInput: ImageSource {
     @objc public func start(isFreeBuffer: Bool, isExport: Bool = false,timeRange:CMTimeRange = CMTimeRange.init()) {
         
         debugStartTime = CFAbsoluteTimeGetCurrent()
-        FilterLog(message: "开始播放的系统时钟时间 \(String(describing: debugStartTime))")
+        BFLog(2, message: "开始播放的系统时钟时间 \(String(describing: debugStartTime))")
         
         playeTimeRange = timeRange
         readerAudioTrackOutput = nil
-        FilterLog(message: "PQMoveInput开始")
+        BFLog(2, message: "PQMoveInput开始")
         mFreeBuffer = isFreeBuffer
         assetReader = createReader()
     
@@ -317,7 +317,7 @@ public class PQMovieInput: ImageSource {
 
         isPlay = true
         if assetReader == nil {
-            FilterLog(message: "assetReader is null!!!!!")
+            BFLog(2, message: "assetReader is null!!!!!")
             return
         }
 
@@ -326,7 +326,7 @@ public class PQMovieInput: ImageSource {
             try NSObject.catchException { [self] in
                 if(mIsExport){
                     guard self.assetReader.startReading() else {
-                        FilterLog(message: "ERROR: Unable to start reading: \(String(describing: self.assetReader.error))")
+                        BFLog(2, message: "ERROR: Unable to start reading: \(String(describing: self.assetReader.error))")
                         return
                     }
                 }else{
@@ -338,19 +338,19 @@ public class PQMovieInput: ImageSource {
               
             }
         } catch {
-            FilterLog(message: "ERROR: Unable to start reading: \(error)")
+            BFLog(2, message: "ERROR: Unable to start reading: \(error)")
             return
         }
 
-        FilterLog(message: "assetReader.outputs count is \(assetReader.outputs)")
+        BFLog(2, message: "assetReader.outputs count is \(assetReader.outputs)")
         for output in assetReader.outputs {
             if output.mediaType == AVMediaType.video {
                 readerVideoTrackOutput = output
-                FilterLog(message: " set  readerVideoTrackOutput")
+                BFLog(2, message: " set  readerVideoTrackOutput")
             }
             if output.mediaType == AVMediaType.audio {
                 readerAudioTrackOutput = output
-                FilterLog(message: " set  readerAudioTrackOutput")
+                BFLog(2, message: " set  readerAudioTrackOutput")
             }
         }
 
@@ -367,7 +367,7 @@ public class PQMovieInput: ImageSource {
     }
 
     public func cancel() {
-        FilterLog(message: "PQMoveInput取消")
+        BFLog(2, message: "PQMoveInput取消")
         isPlay = false
 
         // 将定时器移除主循环
@@ -382,7 +382,7 @@ public class PQMovieInput: ImageSource {
     }
 
     public func resume() {
-        FilterLog(message: "PQMoveInput恢复播放")
+        BFLog(2, message: "PQMoveInput恢复播放")
         mFreeBuffer = false
         isPlay = true
         if !mIsExport{
@@ -397,15 +397,15 @@ public class PQMovieInput: ImageSource {
 
     public func pause() {
         if !isPlay {
-            FilterLog(message: "还不是播放状态")
+            BFLog(2, message: "还不是播放状态")
             return
         }
 
         if displayLink == nil {
-            FilterLog(message: "displayLink is erorr displaye bug !!!!")
+            BFLog(2, message: "displayLink is erorr displaye bug !!!!")
             return
         }
-        FilterLog(message: "PQMoveInput暂停 displayLink.timestamp:  \(displayLink!.timestamp)")
+        BFLog(2, message: "PQMoveInput暂停 displayLink.timestamp:  \(displayLink!.timestamp)")
         isPlay = false
 
         // 暂停帧的刷新 true:停 ; false:开始
@@ -421,7 +421,7 @@ public class PQMovieInput: ImageSource {
             startTime = currentTime
         }
 
-        FilterLog(message: "暂停时间:\(currTime)")
+        BFLog(2, message: "暂停时间:\(currTime)")
 
         beginTime = 0
         
@@ -437,7 +437,7 @@ public class PQMovieInput: ImageSource {
     func createReader() -> AVAssetReader? {
         do {
             let assetReader = try AVAssetReader(asset: asset)
-            FilterLog(message: "assetReader init \(assetReader)  asset url is \(asset)")
+            BFLog(2, message: "assetReader init \(assetReader)  asset url is \(asset)")
             if audioMix == nil {
                 if let audioTrack = asset.tracks(withMediaType: .audio).first, let _ = audioEncodingTarget {
                     BFLog(1, message: "audioTrack start \(audioTrack.timeRange.start) \(audioTrack.timeRange.duration.value)")
@@ -451,7 +451,7 @@ public class PQMovieInput: ImageSource {
                 }
 
             } else {
-                FilterLog(message: "self.asset.tracks is \(asset.tracks.count)")
+                BFLog(2, message: "self.asset.tracks is \(asset.tracks.count)")
                 let readerAudioTrackOutput = AVAssetReaderAudioMixOutput(audioTracks: asset.tracks(withMediaType: .audio), audioSettings: audioSettings)
                 readerAudioTrackOutput.audioMix = audioMix
                 readerAudioTrackOutput.alwaysCopiesSampleData = false
@@ -459,21 +459,21 @@ public class PQMovieInput: ImageSource {
             }
 
             assetReader.timeRange = playeTimeRange
-            FilterLog(message: "初始化播放器开始时间\(CMTimeGetSeconds(assetReader.timeRange.start)) 结束时间\(CMTimeGetSeconds(assetReader.timeRange.end)) 音乐的总时长\(asset.duration.seconds)")
+            BFLog(2, message: "初始化播放器开始时间\(CMTimeGetSeconds(assetReader.timeRange.start)) 结束时间\(CMTimeGetSeconds(assetReader.timeRange.end)) 音乐的总时长\(asset.duration.seconds)")
        
 
             actualStartTime = nil
 
             return assetReader
         } catch {
-            FilterLog(message: "ERROR: Unable to create asset reader: \(error)")
+            BFLog(2, message: "ERROR: Unable to create asset reader: \(error)")
         }
         return nil
     }
 
     func readNextVideoFrame(with _: AVAssetReader) {
         
-        FilterLog(message: "视频解码状态\(assetReader.status.rawValue)")
+        BFLog(2, message: "视频解码状态\(assetReader.status.rawValue)")
      
         autoreleasepool {
             synchronizedEncodingDebugPrint("Process frame input")
@@ -497,12 +497,12 @@ public class PQMovieInput: ImageSource {
     func readNextAudioSample(with assetReader: AVAssetReader, from audioTrackOutput: AVAssetReaderOutput) {
         
         if(!mIsExport){
-            FilterLog(message: "不是导出模式")
+            BFLog(2, message: "不是导出模式")
             return
         }
        
         if !isPlay {
-            FilterLog(message: "自动停到首帧的不处理音频")
+            BFLog(2, message: "自动停到首帧的不处理音频")
             return
         }
         /*
@@ -511,30 +511,30 @@ public class PQMovieInput: ImageSource {
          case failed = 3
          case cancelled = 4
          */
-        FilterLog(message: "音频解码状态\(assetReader.status.rawValue)")
+        BFLog(2, message: "音频解码状态\(assetReader.status.rawValue)")
         BFLog(1, message:  "音频解码状态\(assetReader.status.rawValue)")
         
         autoreleasepool {
             guard let sampleBuffer = audioTrackOutput.copyNextSampleBuffer(),CMSampleBufferIsValid(sampleBuffer) else {
                 if(assetReader.status == .completed){
-                    FilterLog(message: "提前结束的了!!!!\(String(describing: assetReader.error))")
+                    BFLog(2, message: "提前结束的了!!!!\(String(describing: assetReader.error))")
                 }
                 if let movieOutput = synchronizedMovieOutput {
-                    FilterLog(message: "this is runing assetWriterAudioInput  markAsFinished \(String(describing: assetReader.error)) \(assetReader)")
+                    BFLog(2, message: "this is runing assetWriterAudioInput  markAsFinished \(String(describing: assetReader.error)) \(assetReader)")
 
                     movieOutput.movieProcessingContext.runOperationAsynchronously {
                         movieOutput.audioEncodingIsFinished = true
                         movieOutput.assetWriterAudioInput?.markAsFinished()
                     }
                 }
-                FilterLog(message: "sampleBuffer is null 速度太快copy is error")
+                BFLog(2, message: "sampleBuffer is null 速度太快copy is error")
                 return
             }
 
             synchronizedEncodingDebugPrint("Process audio sample input")
 
             let currentSampleTime = CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer)
-            FilterLog(message: "处理音频的时间戳 \(CMTimeGetSeconds(currentSampleTime)) 播放时间\(CMTimeGetSeconds(currentTime))")
+            BFLog(2, message: "处理音频的时间戳 \(CMTimeGetSeconds(currentSampleTime)) 播放时间\(CMTimeGetSeconds(currentTime))")
 
             // https://www.itdaan.com/blog/2013/11/28/deb10f90970a5ea33f185c9faf2a0ab3.html
             if !mFreeBuffer {
@@ -567,7 +567,7 @@ public class PQMovieInput: ImageSource {
                 totalFrameTimeDuringCapture += currentFrameTime
                 
                 
-                FilterLog(message: "currentTime is \(String(format: "%.6f", CMTimeGetSeconds(currentTime))) 当前帧渲染时间 : \(String(format: "%.6f",1000.0 * currentFrameTime)) ms Average frame time : \(String(format: "%.6f", 1000.0 * totalFrameTimeDuringCapture / Double(totalFramesSent))) ms  totalFrameTimeDuringCapture is \(String(format: "%.6f",totalFrameTimeDuringCapture))")
+                BFLog(2, message: "currentTime is \(String(format: "%.6f", CMTimeGetSeconds(currentTime))) 当前帧渲染时间 : \(String(format: "%.6f",1000.0 * currentFrameTime)) ms Average frame time : \(String(format: "%.6f", 1000.0 * totalFrameTimeDuringCapture / Double(totalFramesSent))) ms  totalFrameTimeDuringCapture is \(String(format: "%.6f",totalFrameTimeDuringCapture))")
              
             
 

+ 11 - 11
BFFramework/Classes/PQGPUImage/akfilters/PQSubTitleFilter.swift

@@ -37,7 +37,7 @@ open class PQSubTitleFilter: BasicOperation {
     var lastSubtitle: PQEditSubTitleModel?
 
     deinit {
-        FilterLog(message: "字幕析构 ")
+        BFLog(2, message: "字幕析构 ")
         clearData()
     }
 
@@ -94,7 +94,7 @@ open class PQSubTitleFilter: BasicOperation {
         subtitleLab.font = UIFont.boldSystemFont(ofSize: CGFloat(isBigSubtile ? 114 : font))
         subtitleLab.numberOfLines = 0
 
-        FilterLog(message: "字幕初始化时大小 \(subtitleLab.frame)")
+        BFLog(2, message: "字幕初始化时大小 \(subtitleLab.frame)")
 
         subtitleLab.textAlignment = .center
         subtitleLab.backgroundColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.5)
@@ -127,9 +127,9 @@ open class PQSubTitleFilter: BasicOperation {
 
     func update(withTimestamp frameTime: CMTime) {
         let currtime = CMTimeGetSeconds(frameTime)
-        FilterLog(message: "当前时间 \(currtime)")
+        BFLog(2, message: "当前时间 \(currtime)")
         if mSubtitles?.count == 0 {
-            FilterLog(message: "字幕数据错误")
+            BFLog(2, message: "字幕数据错误")
             return
         }
 
@@ -138,10 +138,10 @@ open class PQSubTitleFilter: BasicOperation {
                 if lastSubtitle != subtitle {
                     lastSubtitle = subtitle
 
-                    FilterLog(message: "创建文字图片显示当前时间 \(currtime) start: \(subtitle.timelineIn)  end: \(subtitle.timelineOut) 显示的文字:\(subtitle.text)")
+                    BFLog(2, message: "创建文字图片显示当前时间 \(currtime) start: \(subtitle.timelineIn)  end: \(subtitle.timelineOut) 显示的文字:\(subtitle.text)")
                     subtitle.text = subtitle.text.replacingOccurrences(of: "\r", with: "")
                     if subtitle.text.count == 0 {
-                        FilterLog(message: "字幕为空 不能正常显示")
+                        BFLog(2, message: "字幕为空 不能正常显示")
                         subtitle.text = "  "
                     }
 
@@ -166,7 +166,7 @@ open class PQSubTitleFilter: BasicOperation {
 
     func createTexture(currtime: CMTime) {
         DispatchQueue.main.async {
-            FilterLog(message: "value istimescale is \(currtime)")
+            BFLog(2, message: "value istimescale is \(currtime)")
 
             self.update(withTimestamp: currtime)
 
@@ -201,7 +201,7 @@ open class PQSubTitleFilter: BasicOperation {
         let inputSize = inputFramebuffer.sizeForTargetOrientation(.portrait)
 
         let currTime = CMTimeGetSeconds(CMTime(value: inputFramebuffer.timingStyle.timestamp!.value, timescale: inputFramebuffer.timingStyle.timestamp!.timescale))
-        FilterLog(message: "subtitle 当前时间: \(currTime)")
+        BFLog(2, message: "subtitle 当前时间: \(currTime)")
 
         // 原有画布
         renderFramebuffer = sharedImageProcessingContext.framebufferCache.requestFramebufferWithProperties(orientation: .portrait, size: inputSize, stencil: false)
@@ -215,14 +215,14 @@ open class PQSubTitleFilter: BasicOperation {
         releaseIncomingFramebuffers()
 
         if subTitleTexture != 0 {
-            FilterLog(message: "UIElementFramebuffer 有值可以正常显示")
+            BFLog(2, message: "UIElementFramebuffer 有值可以正常显示")
             let texturePropertiesimagetwo = InputTextureProperties(textureCoordinates: inputFramebuffer.orientation.rotationNeededForOrientation(.portrait).textureCoordinates(), texture: subTitleTexture)
 
-            FilterLog(message: "subtitleSize subtitleSize is\(String(describing: subtitleSize)) \(inputCGSize)")
+            BFLog(2, message: "subtitleSize subtitleSize is\(String(describing: subtitleSize)) \(inputCGSize)")
 
             let size: CGSize = inputCGSize
             let bounds2: CGRect = CGRect(x: (inputCGSize.width - subtitleSize!.width) / 2, y: inputCGSize.height - subtitleSize!.height - 60, width: subtitleSize!.width, height: subtitleSize!.height)
-            FilterLog(message: "inputCGSize is \(size)  bounds2\(bounds2)")
+            BFLog(2, message: "inputCGSize is \(size)  bounds2\(bounds2)")
             renderQuadWithShader(shader,
                                  uniformSettings: uniformSettings,
                                  vertexBufferObject: PQGPUImageTools.NXGenerateVBO(for: PQGPUImageTools.computeVertices(viewSize: inputCGSize, _bounds: CGRect(x: (inputCGSize.width - subtitleSize!.width) / 2, y: isBigSubtile ? (inputCGSize.height - subtitleSize!.height - 60) / 2 : inputCGSize.height - subtitleSize!.height - 60, width: subtitleSize!.width, height: subtitleSize!.height))),

+ 9 - 9
BFFramework/Classes/PQGPUImage/akfilters/Tools/PQCompositionExporter.swift

@@ -314,7 +314,7 @@ public class PQCompositionExporter {
     /// - Parameter beginTime: 开始缓存的开始时间,用在 seek操作时 老的缓存已经无效不能在使用了
     func configCache(beginTime: Float64 ) {
         cacheFilters.removeAll()
-        FilterLog(message: "原素材 总数:\(mStickers?.count ?? 0) ")
+        BFLog(2, message: "原素材 总数:\(mStickers?.count ?? 0) ")
        
         if mStickers?.count ?? 0 > 0 {
             
@@ -348,7 +348,7 @@ public class PQCompositionExporter {
             
             
             for (index, filter) in cacheFilters.enumerated() {
-                FilterLog(message: " 初始化 config create currentSticker timelinein \(String(describing: filter.stickerInfo?.timelineIn)) timelineout \(String(describing: filter.stickerInfo?.timelineOut))  in :\(String(describing: filter.stickerInfo?.model_in)) out \(String(describing: filter.stickerInfo?.out))  index\(index)")
+                BFLog(2, message: " 初始化 config create currentSticker timelinein \(String(describing: filter.stickerInfo?.timelineIn)) timelineout \(String(describing: filter.stickerInfo?.timelineOut))  in :\(String(describing: filter.stickerInfo?.model_in)) out \(String(describing: filter.stickerInfo?.out))  index\(index)")
             }
             
             if(cacheFilters.first != nil){
@@ -367,12 +367,12 @@ public class PQCompositionExporter {
 
     //创建下一个filter 数据
     func createNextFilter() {
-        FilterLog(message: "加入前 当前的缓存个数为: \(cacheFilters.count)  maxCount \(cacheFiltersMaxCount) 最后一个显示时间 \(String(describing: cacheFilters.last?.stickerInfo?.timelineIn))")
+        BFLog(2, message: "加入前 当前的缓存个数为: \(cacheFilters.count)  maxCount \(cacheFiltersMaxCount) 最后一个显示时间 \(String(describing: cacheFilters.last?.stickerInfo?.timelineIn))")
           if cacheFilters.count <=  cacheFiltersMaxCount {
               let showIndex = mStickers?.firstIndex(where: { (sticker) -> Bool in
                 (cacheFilters.last?.stickerInfo == sticker)
               })
-                FilterLog(message: "当前显示的showIndex: \(String(describing: showIndex))")
+                BFLog(2, message: "当前显示的showIndex: \(String(describing: showIndex))")
               if ((showIndex ?? 0) + 1) < (mStickers?.count ?? 0) {
                   let currentSticker = mStickers?[(showIndex ?? 0) + 1]
                   if currentSticker != nil {
@@ -388,11 +388,11 @@ public class PQCompositionExporter {
                           cacheFilters.append(showFitler!)
                       }
                   }else{
-                    FilterLog(message: "缓存数据加入不成功!!!!!")
+                    BFLog(2, message: "缓存数据加入不成功!!!!!")
                   }
               }
             
-            FilterLog(message: "加入后 当前的缓存个数为: \(cacheFilters.count)  maxCount \(cacheFiltersMaxCount) 最后一个显示时间 \(String(describing: cacheFilters.last?.stickerInfo?.timelineIn))")
+            BFLog(2, message: "加入后 当前的缓存个数为: \(cacheFilters.count)  maxCount \(cacheFiltersMaxCount) 最后一个显示时间 \(String(describing: cacheFilters.last?.stickerInfo?.timelineIn))")
              
           }
         
@@ -403,7 +403,7 @@ public class PQCompositionExporter {
     /// 按时间从缓存中取出要显示的filter
     /// - Parameter currTime: 当前播放时间
     func changeFilter(currTime: Float64) {
-        FilterLog(message: " 要查找的 currTime is \(currTime)")
+        BFLog(2, message: " 要查找的 currTime is \(currTime)")
         //1,删除已经显示过的 filter
         self.cacheFilters.removeAll(where: {(filter) -> Bool in
 
@@ -429,7 +429,7 @@ public class PQCompositionExporter {
         print("缓存操作   查找到命中的显示是为:\(currTime) 缓存数据timeline in :\(showFilter.stickerInfo?.timelineIn ?? 0.0)) timelineOut:\(showFilter.stickerInfo?.timelineOut ?? 0.0) 缓存数 \(cacheFilters.count) index: \(String(describing: showIndex))")
         
         if(!(showFilter.isShow)){
-            FilterLog(message: "showIndex当前时间为  \(currTime) showIndex is \(String(describing: showIndex)) 显示 filter timein is: \(String(describing: showFilter.stickerInfo?.timelineIn)) timeout is: \(String(describing: showFilter.stickerInfo?.timelineOut))")
+            BFLog(2, message: "showIndex当前时间为  \(currTime) showIndex is \(String(describing: showIndex)) 显示 filter timein is: \(String(describing: showFilter.stickerInfo?.timelineIn)) timeout is: \(String(describing: showFilter.stickerInfo?.timelineOut))")
  
             showFilter.isShow = true
             
@@ -441,7 +441,7 @@ public class PQCompositionExporter {
                     //高斯层
                     let json = showFilter.stickerInfo?.toJSONString(prettyPrint: false)
                     if json == nil {
-                        FilterLog(message: "数据转换有问题 跳转")
+                        BFLog(2, message: "数据转换有问题 跳转")
                         return
                     }
 

+ 2 - 2
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointEditerController.swift

@@ -1123,7 +1123,7 @@ extension PQStuckPointEditerController {
          3, 视频素材a1需要切分的个数clipNum = max (round (kongduan * a1 / L) , 1)
          */
         // 要补的空位数
-        let kongduan: Int = Int(stuckPoints.count) - Int(section.sectionTimeline!.visionTrack?.getEnableVisionTrackMaterials().count ?? 0)
+        let kongduan: Int = Int(stuckPoints.count - 1) - selectedImageDataCount
 
         // 所有视频总时长
         var videoTotalDuration: Float64 = 0.0
@@ -1554,7 +1554,7 @@ extension PQStuckPointEditerController {
                                     break
                                 }
                                 pointCount += 1
-                                FilterLog(message: "finallyStuckPoints last ;\((finallyStuckPoints.last ?? 0.0) - (finallyStuckPoints.first ?? 0.0)), tmp:\(useAssestDurationTemp)")
+                                BFLog(2, message: "finallyStuckPoints last ;\((finallyStuckPoints.last ?? 0.0) - (finallyStuckPoints.first ?? 0.0)), tmp:\(useAssestDurationTemp)")
     
                             }
                             // 2拼接要使用的卡点信息

+ 23 - 23
BFFramework/Classes/Stuckpoint/ViewModel/PQGPUImagePlayerView.swift

@@ -129,7 +129,7 @@ public class PQGPUImagePlayerView: UIView {
     var mStickers: [PQEditVisionTrackMaterialsModel]? {
         didSet {
             
-            FilterLog(message: "设置线程为: \(Thread.current) \(OperationQueue.current?.underlyingQueue?.label as Any)")
+            BFLog(2, message: "设置线程为: \(Thread.current) \(OperationQueue.current?.underlyingQueue?.label as Any)")
         
             configCache(beginTime: mStickers?.first?.timelineIn ?? 0)
         }
@@ -292,7 +292,7 @@ public class PQGPUImagePlayerView: UIView {
     // 设置画布比例
     public func resetCanvasFrame(frame: CGRect) {
         if self.frame.equalTo(frame) {
-            FilterLog(message: "新老值一样,不重置")
+            BFLog(2, message: "新老值一样,不重置")
             return
         }
 
@@ -304,7 +304,7 @@ public class PQGPUImagePlayerView: UIView {
             showBorderLayer()
         }
 
-        FilterLog(message: "new frame is \(frame)")
+        BFLog(2, message: "new frame is \(frame)")
         renderView.isHidden = true
         renderView.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height)
         renderView.resatSize()
@@ -365,7 +365,7 @@ public class PQGPUImagePlayerView: UIView {
 
         self.asset = asset
         if (audioMixModel != nil && audioMixModel?.localPath != nil) || (videoStickers != nil && (videoStickers?.count ?? 0) > 0 || originMusicDuration != 0) {
-            FilterLog(message: "有参加混音的数据。")
+            BFLog(2, message: "有参加混音的数据。")
             (audioMix, composition) = PQPlayerViewModel.setupAudioMix(originAsset: asset, bgmData: audioMixModel, videoStickers: videoStickers,originMusicDuration:originMusicDuration,clipAudioRange: clipAudioRange)
         } else {
             audioMix = nil
@@ -387,7 +387,7 @@ public class PQGPUImagePlayerView: UIView {
 //        }
         do {
             if composition != nil {
-                FilterLog(message: "composition 方式初始化")
+                BFLog(2, message: "composition 方式初始化")
                 movie = try PQMovieInput(asset: composition!, videoComposition: videoComposition, audioMix: audioMix, playAtActualSpeed: true, loop: isLoop, audioSettings: audioSettings)
 //                movie?.exportAudioUrl = url // clipAudioRange
                 movie?.configAVPlayer(assetUrl: url, ranges: [clipAudioRange])
@@ -467,7 +467,7 @@ public class PQGPUImagePlayerView: UIView {
     /// - Parameter beginTime: 开始缓存的开始时间,用在 seek操作时 老的缓存已经无效不能在使用了
     func configCache(beginTime: Float64 ) {
         cacheFilters.removeAll()
-        FilterLog(message: "原素材 总数:\(mStickers?.count ?? 0) ")
+        BFLog(2, message: "原素材 总数:\(mStickers?.count ?? 0) ")
        
         if mStickers?.count ?? 0 > 0 {
             for (index, currentSticker) in mStickers!.enumerated() {
@@ -497,7 +497,7 @@ public class PQGPUImagePlayerView: UIView {
             
             
             for (index, filter) in cacheFilters.enumerated() {
-                FilterLog(message: " 初始化 config create currentSticker timelinein \(String(describing: filter.stickerInfo?.timelineIn)) timelineout \(String(describing: filter.stickerInfo?.timelineOut))  in :\(String(describing: filter.stickerInfo?.model_in)) out \(String(describing: filter.stickerInfo?.out))  index\(index)")
+                BFLog(2, message: " 初始化 config create currentSticker timelinein \(String(describing: filter.stickerInfo?.timelineIn)) timelineout \(String(describing: filter.stickerInfo?.timelineOut))  in :\(String(describing: filter.stickerInfo?.model_in)) out \(String(describing: filter.stickerInfo?.out))  index\(index)")
             }
             
             if(cacheFilters.first != nil){
@@ -513,12 +513,12 @@ public class PQGPUImagePlayerView: UIView {
 
     //创建下一个filter 数据
     func createNextFilter() {
-        FilterLog(message: "加入前 当前的缓存个数为: \(cacheFilters.count)  maxCount \(cacheFiltersMaxCount) 最后一个显示时间 \(String(describing: cacheFilters.last?.stickerInfo?.timelineIn))")
+        BFLog(2, message: "加入前 当前的缓存个数为: \(cacheFilters.count)  maxCount \(cacheFiltersMaxCount) 最后一个显示时间 \(String(describing: cacheFilters.last?.stickerInfo?.timelineIn))")
           if cacheFilters.count <=  cacheFiltersMaxCount {
               let showIndex = mStickers?.firstIndex(where: { (sticker) -> Bool in
                 (cacheFilters.last?.stickerInfo == sticker)
               })
-                FilterLog(message: "当前显示的showIndex: \(String(describing: showIndex))")
+                BFLog(2, message: "当前显示的showIndex: \(String(describing: showIndex))")
               if ((showIndex ?? 0) + 1) < (mStickers?.count ?? 0) {
                   let currentSticker = mStickers?[(showIndex ?? 0) + 1]
                   if currentSticker != nil {
@@ -534,11 +534,11 @@ public class PQGPUImagePlayerView: UIView {
                           cacheFilters.append(showFitler!)
                       }
                   }else{
-                    FilterLog(message: "缓存数据加入不成功!!!!!")
+                    BFLog(2, message: "缓存数据加入不成功!!!!!")
                   }
               }
             
-            FilterLog(message: "加入后 当前的缓存个数为: \(cacheFilters.count)  maxCount \(cacheFiltersMaxCount) 最后一个显示时间 \(String(describing: cacheFilters.last?.stickerInfo?.timelineIn))")
+            BFLog(2, message: "加入后 当前的缓存个数为: \(cacheFilters.count)  maxCount \(cacheFiltersMaxCount) 最后一个显示时间 \(String(describing: cacheFilters.last?.stickerInfo?.timelineIn))")
              
           }
         
@@ -564,16 +564,16 @@ public class PQGPUImagePlayerView: UIView {
 
         })
         if(showIndex == nil){
-            FilterLog(message: "缓存没有查找到?出现数据错误!!!!")
+            BFLog(2, message: "缓存没有查找到?出现数据错误!!!!")
             return
         }
   
         let showFilter: PQBaseFilter = cacheFilters[showIndex ?? 0]
         
-        FilterLog(message: "缓存操作   查找到命中的显示是为:\(currTime) 缓存数据timeline in :\(showFilter.stickerInfo?.timelineIn ?? 0.0)) timelineOut:\(showFilter.stickerInfo?.timelineOut ?? 0.0) in:\(showFilter.stickerInfo?.model_in ?? 0.0) out:\(showFilter.stickerInfo?.out ?? 0.0) 缓存数 \(cacheFilters.count) index: \(String(describing: showIndex))")
+        BFLog(2, message: "缓存操作   查找到命中的显示是为:\(currTime) 缓存数据timeline in :\(showFilter.stickerInfo?.timelineIn ?? 0.0)) timelineOut:\(showFilter.stickerInfo?.timelineOut ?? 0.0) in:\(showFilter.stickerInfo?.model_in ?? 0.0) out:\(showFilter.stickerInfo?.out ?? 0.0) 缓存数 \(cacheFilters.count) index: \(String(describing: showIndex))")
         
         if(!(showFilter.isShow)){
-            FilterLog(message: "showIndex当前时间为  \(currTime) showIndex is \(String(describing: showIndex)) 显示 filter timelineIn is: \(String(describing: showFilter.stickerInfo?.timelineIn)) timelineOut is: \(String(describing: showFilter.stickerInfo?.timelineOut))")
+            BFLog(2, message: "showIndex当前时间为  \(currTime) showIndex is \(String(describing: showIndex)) 显示 filter timelineIn is: \(String(describing: showFilter.stickerInfo?.timelineIn)) timelineOut is: \(String(describing: showFilter.stickerInfo?.timelineOut))")
  
             showFilter.isShow = true
             
@@ -585,13 +585,13 @@ public class PQGPUImagePlayerView: UIView {
             //画面的比例
             let canverAspectRatio = String(format: "%.6f",(movie?.mShowVidoSize.width ?? 0.0) /  (movie?.mShowVidoSize.height ?? 0.0))
             if(showFilter.stickerInfo?.type == StickerType.IMAGE.rawValue && showGaussianBlur && Float(stickerAspectRatio) != Float(canverAspectRatio)){
-                      FilterLog(message: "显示图片filter")
+                      BFLog(2, message: "显示图片filter")
 //                    //高斯层
                         let  blurStickerModel:PQEditVisionTrackMaterialsModel? = showFilter.stickerInfo?.copy() as? PQEditVisionTrackMaterialsModel
                         blurStickerModel?.canvasFillType = stickerContentMode.aspectFillStr.rawValue
 
                         if blurStickerModel == nil {
-                            FilterLog(message: "显示图片filter blurStickerModel is nil")
+                            BFLog(2, message: "显示图片filter blurStickerModel is nil")
                             return
                         }
                         let showGaussianFitler:PQBaseFilter = PQImageFilter(sticker: blurStickerModel!, isExport: (movie?.mIsExport) ?? false, showUISize: mCanverSize)
@@ -604,7 +604,7 @@ public class PQGPUImagePlayerView: UIView {
                         iosb.addTarget(showFilter,atTargetIndex: 0)
                         showFilter.addTarget(self.renderView as ImageConsumer, atTargetIndex: 0)
                 
-                        FilterLog(message: "filter 添加成功 注意是否添加成功。")
+                        BFLog(2, message: "filter 添加成功 注意是否添加成功。")
                         
 //                    }
  
@@ -618,7 +618,7 @@ public class PQGPUImagePlayerView: UIView {
             }
 
         }else{
-            FilterLog(message: " 添加过了 currTime is \(currTime) timelineIn:\(showFilter.stickerInfo?.timelineIn ?? 0.0)")
+            BFLog(2, message: " 添加过了 currTime is \(currTime) timelineIn:\(showFilter.stickerInfo?.timelineIn ?? 0.0)")
         }
     }
 
@@ -656,7 +656,7 @@ public extension PQGPUImagePlayerView {
             self.progressLab.isHidden = false
         }
 //        guard status != .playing else {
-//            FilterLog(message: "已经是播放状态")
+//            BFLog(2, message: "已经是播放状态")
 //            return
 //        }
 
@@ -717,7 +717,7 @@ public extension PQGPUImagePlayerView {
 
     // 显示提示文字
     func showTip(show: Bool) {
-        FilterLog(message: "showTip \(show)")
+        BFLog(2, message: "showTip \(show)")
         tipLab.isHidden = !show
         if show {
             playerEmptyView.isHidden = true
@@ -757,15 +757,15 @@ public extension PQGPUImagePlayerView {
 // MARK: - RenderViewDelegate
 extension PQGPUImagePlayerView: RenderViewDelegate{
     public func willDisplayFramebuffer(renderView _: RenderView, framebuffer _: Framebuffer) {
-        FilterLog(message: "willDisplayFramebuffer")
+        BFLog(2, message: "willDisplayFramebuffer")
     }
 
     public func didDisplayFramebuffer(renderView _: RenderView, framebuffer: Framebuffer) {
-        FilterLog(message: "didDisplayFramebuffer")
+        BFLog(2, message: "didDisplayFramebuffer")
     }
 
     public func shouldDisplayNextFramebufferAfterMainThreadLoop() -> Bool {
-        FilterLog(message: "didDisplayFramebuffer")
+        BFLog(2, message: "didDisplayFramebuffer")
         
         return false
     }