博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IOS 硬件GPU解码
阅读量:2345 次
发布时间:2019-05-10

本文共 2169 字,大约阅读时间需要 7 分钟。

导入框架和头文件#import <VideoToolbox/VideoToolbox.h>

{//声明的全局变量 NSData *spsData ;    NSData *ppsData;    uint8_t pFrameData[BUFFER_SIZE];    CMVideoFormatDescriptionRef  videoFormatDescription ;    VTDecompressionSessionRef decompressionSession;    VTDecompressionOutputCallback  decompressionSessionDecodeFrameCallback;}-(void)createDecompSession{    VTDecompressionOutputCallbackRecord callBackRecord;    callBackRecord.decompressionOutputCallback = decompressionSessionDecodeFrameCallback;    callBackRecord.decompressionOutputRefCon = (__bridge void *)self;    //attr是传递给decode session的属性词典,两种方式//    NSDictionary *destinationImageBufferAttributes =[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO],(id)kCVPixelBufferOpenGLESCompatibilityKey,//                                                     [NSNumber numberWithInt:kCVPixelFormatType_24RGB],(id)kCVPixelBufferPixelFormatTypeKey,nil];    //kCVPixelFormatType_420YpCbCr8BiPlanarFullRange,kCVPixelFormatType_24RGB    //(__bridge CFDictionaryRef)(destinationImageBufferAttributes)    //attr是传递给decode session的属性词典    CFDictionaryRef attrs = NULL;    //kCVPixelBufferPixelFormatTypeKey,指定解码后的图像格式,必须指定成NV12,苹果的硬解码器只支持NV12。    const void *keys[] = { kCVPixelBufferPixelFormatTypeKey };    //      kCVPixelFormatType_420YpCbCr8Planar is YUV420    //      kCVPixelFormatType_420YpCbCr8BiPlanarFullRange is NV12    uint32_t v = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;    const void *values[] = { CFNumberCreate(NULL, kCFNumberSInt32Type, &v) };    attrs = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL);    //创建解码session    OSStatus status =  VTDecompressionSessionCreate(kCFAllocatorDefault,                                                    videoFormatDescription,                                                    NULL,                                                   attrs , // attrs, // NULL                                                    &callBackRecord,                                                    &decompressionSession);}-(void)decodeData:(char*)pFromeData Leng:(int)length{    //去掉开始码,提取sps和pps    int naluType = ((uint8_t)pFromeData[4]&0x1f);//    for (int i=0; i

转载地址:http://mqnvb.baihongyu.com/

你可能感兴趣的文章
搭建zookeeper集群
查看>>
1005. 数独
查看>>
1006. 求和游戏
查看>>
IDEA eclipse 控制台日志输出到文件
查看>>
1022. Fib数列
查看>>
一些开源项目
查看>>
将博客搬至CSDN
查看>>
MySQL 中事务的实现
查看>>
CheckStyle
查看>>
IDE配置jvm参数
查看>>
内存溢出
查看>>
Spring Cloud 声明式服务调用 Feign
查看>>
JVM实用参数(一)JVM类型以及编译器模式
查看>>
spring cloud config 属性加解密
查看>>
rabbitmq安装
查看>>
RabbitMQ 使用
查看>>
动态代理
查看>>
oracle中merge into用法解析
查看>>
MySQL Explain详解
查看>>
oracle性能监控
查看>>