extension CVPixelBuffer {
func copy() -> CVPixelBuffer {
precondition(CFGetTypeID(self) == CVPixelBufferGetTypeID(), "copy() cannot be called on a non-CVPixelBuffer") var _copy : CVPixelBuffer? // var BytesAlignment:Int = 4
// let CFBytesAlignment = CFNumberCreate(kCFAllocatorDefault, .intType, &BytesAlignment)!
let attribute:[String:Any] = [kCVPixelBufferMetalCompatibilityKey as String:kCFBooleanTrue]
// kCVPixelBufferBytesPerRowAlignmentKey as String:CFBytesAlignment CVPixelBufferCreate(
kCFAllocatorDefault,
CVPixelBufferGetWidth(self),
CVPixelBufferGetHeight(self),
CVPixelBufferGetPixelFormatType(self),
attribute as CFDictionary,
&_copy) guard let copy = _copy else { fatalError() } CVPixelBufferLockBaseAddress(self, CVPixelBufferLockFlags.readOnly)
CVPixelBufferLockBaseAddress(copy, CVPixelBufferLockFlags(rawValue: )) for plane in ..<CVPixelBufferGetPlaneCount(self) {
let dest = CVPixelBufferGetBaseAddressOfPlane(copy, plane)
let source = CVPixelBufferGetBaseAddressOfPlane(self, plane)
let height = CVPixelBufferGetHeightOfPlane(self, plane)
let bytesPerRow = CVPixelBufferGetBytesPerRowOfPlane(self, plane) let bytesPerRowDst = CVPixelBufferGetBytesPerRowOfPlane(copy, plane) for h in ..<height {
memcpy(dest?.advanced(by:h*bytesPerRowDst), source?.advanced(by:h*bytesPerRow), bytesPerRow)
}
} CVPixelBufferUnlockBaseAddress(copy, CVPixelBufferLockFlags(rawValue: ))
CVPixelBufferUnlockBaseAddress(self, CVPixelBufferLockFlags.readOnly) return copy
}
}

https://stackoverflow.com/questions/38335365/pulling-data-from-a-cmsamplebuffer-in-order-to-create-a-deep-copy

http://blog.csdn.net/fernandowei/article/details/52180840

iOS CMSampleBuffer deep copy的更多相关文章

  1. C# Bitmap deep copy

    今天在研究一个关于 Bitmap deep copy 的问题, 经过一系列的查询,在StackOverFlow上面找到了答案,遂记录下来: public static Bitmap DeepCopyB ...

  2. shallow copy 和 deep copy 的示例

    本文属原创,转载请注明出处:http://www.cnblogs.com/robinjava77/p/5481874.html   (Robin) Student package base; impo ...

  3. python deep copy and shallow copy

    Python中对于对象的赋值都是引用,而不是拷贝对象(Assignment statements in Python do not copy objects, they create bindings ...

  4. Deep Copy cv::StereoBM 深度拷贝

    在使用OpenCV的三维立体重建的库时,一个重要的步骤就是生成左右视图的差异图Disparity,而控制生成disparity的参数的类是cv::StereoBM,我们有时候需要拷贝一份cv::Ste ...

  5. shallow copy & deep copy

    1.深复制与浅复制的概念 ->浅复制(shallow copy)概念   在SDK Guides中(搜索copy),官方给出的浅复制概念为: Copying compound objects, ...

  6. 【C#】Deep copy of objects

    If you learned C++ carefully, you must have known something about the copy of object. For example, I ...

  7. NumPy学习(索引和切片,合并,分割,copy与deep copy)

    NumPy学习(索引和切片,合并,分割,copy与deep copy) 目录 索引和切片 合并 分割 copy与deep copy 索引和切片 通过索引和切片可以访问以及修改数组元素的值 一维数组 程 ...

  8. Numpy copy & deep copy

    1. '='的赋值方式会带有关联性 >>> import numpy as np >>> a = np.arange(4) >>> b = a & ...

  9. angular.extend深拷贝(deep copy)

    在用到angular.extend的时候,正好碰到一个对象,是层层嵌套的Array, 结果发现只能extend第一层,查阅官文档,确实不支持deep copy: Note: Keep in mind ...

随机推荐

  1. Mysql--查询相关语句总结

    一.查询各个部门的最高工资及姓名,其中薪资字段是字符串类型: 优化前: SELECT *FROM (SELECT a.`deptno`, a.`sal`, a.`ename` FROM emp a O ...

  2. 为什么 [\000-\177]匹配任意7bit ascii码 ?

    如题 41     print \000;     42     print "\n";     43     print \177; 输出: SCALAR(0x3fce0)SCA ...

  3. 导入.sql文件入数据库

    1.创建数据库,例如abc create database abc; 2.进入数据库 use abc 3.导入e盘下的ssh.sql文件即可 source e:\ssh.sql; 截图如下:

  4. python msg_box

    转自:http://www.cnblogs.com/otfsenter/ # _*_ coding: utf-8 _*_ # @Time : 2017/3/27 17:39 # @Author : o ...

  5. pycharm 破解

    亲测有效! http://blog.lanyus.com/archives/174.html 备注: 注册码破解链接:http://idea.lanyus.com/ 将下载的jar包放入PyCharm ...

  6. admin——django自带数据库管理工具

    admin是Django自带的数据库管理工具,是一个app 在admin.py中可以自己定制类来使admin数据库管理页面展现自己想要查看的信息 models.py from django.db im ...

  7. 创建私有 Gems 源

    1.安装依赖 yum install gem -y gem install builder   2.安装.配置nginx的文件列表 添加/etc/nginx/default.d/mirrors.con ...

  8. [BZOJ3751][NOIP2014]解方程(数学相关+乱搞)

    题目描述 已知多项式方程: a0+a1x+a2x^2+..+anx^n=0 求这个方程在[1, m ] 内的整数解(n 和m 均为正整数) 输入输出格式 输入格式: 输入文件名为equation .i ...

  9. Linux下汇编语言学习笔记46 ---

    这是17年暑假学习Linux汇编语言的笔记记录,参考书目为清华大学出版社 Jeff Duntemann著 梁晓辉译<汇编语言基于Linux环境>的书,喜欢看原版书的同学可以看<Ass ...

  10. int *ptr=(int *)(&a+1)问题的探讨

    从网络上看到这样一道有意思的题目,是关于数组与指针的问题,描述如下: main() { ]={,,,,}; ); printf(),*(ptr-)); } 输出为:2,5 请解释以上代码的输出结果. ...