zoukankan      html  css  js  c++  java
  • 第51月第27天 AAPLEAGLLayer.m

    1.

    https://github.com/stevenyao/iOSHardwareDecoder

    https://github.com/LevyGG/iOS-H.264-hareware-encode-and-decode

    2.

    opengles

    https://www.jianshu.com/c/30e2e76bc140

    https://github.com/QinminiOS/OpenGLES

    gpuimage

    https://github.com/QinminiOS/GPUImage

    https://www.jianshu.com/c/4510dd854806

    3.

    toyuv

    CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sample);


    CVPixelBufferLockBaseAddress(pixelBuffer, 0); // 获取CVImageBufferRef中的y数据 UInt8 *pY = (UInt8 *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0); // 获取CMVImageBufferRef中的uv数据 UInt8 *pUV = (UInt8 *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1); size_t width = CVPixelBufferGetWidth(pixelBuffer); size_t height = CVPixelBufferGetHeight(pixelBuffer); size_t pYBytes = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0); size_t pUVBytes = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 1); UInt8 *pYUV420P = (UInt8 *)malloc(width * height * 3 / 2); UInt8 *pU = pYUV420P + (width * height); UInt8 *pV = pU + (width * height / 4); for(int i = 0; i < height; i++) { memcpy(pYUV420P + i * width, pY + i * pYBytes, width); } for(int j = 0; j < height / 2; j++) { for(int i = 0; i < width / 2; i++) { *(pU++) = pUV[i<<1]; *(pV++) = pUV[(i<<1) + 1]; } pUV += pUVBytes; } free(pYUV420P); CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);

    topixelBuffer

    - (CVPixelBufferRef) copyDataFromBuffer:(const unsigned char*)buffer toYUVPixelBufferWithWidth:(size_t)width Height:(size_t)height
    {
        
        uint8_t* nv12 = buffer;
        
        NSDictionary *pixelAttributes = @{(NSString*)kCVPixelBufferIOSurfacePropertiesKey:@{}};
        CVPixelBufferRef pixelBuffer = NULL;
        CVReturn result = CVPixelBufferCreate(kCFAllocatorDefault,
                                              width,
                                              height,
                                              kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange,
                                              (__bridge CFDictionaryRef)(pixelAttributes),
                                              &pixelBuffer);
        
        size_t pYBytes = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0);
        size_t pUVBytes = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 1);
        
        CVPixelBufferLockBaseAddress(pixelBuffer,0);
        unsigned char *yDestPlane = (unsigned char *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
        unsigned char *y_ch0 = nv12;
        unsigned char *y_ch1 = nv12 + width * height;
    //    memcpy(yDestPlane, y_ch0, width * height);
        for(int i = 0; i < height; i++) {
            memcpy(yDestPlane + i * pYBytes, y_ch0 + i * width, width);
        }
        unsigned char *uvDestPlane = (unsigned char *)CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1);
    //    memcpy(uvDestPlane, y_ch1, width * height/2);
        
        UInt8 *pU = nv12 + (width * height);
        UInt8 *pV = pU + (width * height / 4);
        
        for(int j = 0; j < height / 2; j++) {
            for(int i = 0; i < width / 2; i++) {
                uvDestPlane[i<<1] = *(pU++) ;
                uvDestPlane[(i<<1) + 1] = *(pV++);
            }
            
            uvDestPlane += pUVBytes;
        }
        
        //    if (nv12) {
        //        free(nv12);
        //    }
        
        CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
        
        if (result != kCVReturnSuccess) {
            NSLog(@"Unable to create cvpixelbuffer %d", result);
        }
    
        return pixelBuffer;
        
    }

     https://www.jianshu.com/p/7da76246ce82

    //nv12,uv分量交替存储;YUV420,uv分量分层存储

    https://blog.csdn.net/u013472201/article/details/105300770/

  • 相关阅读:
    【flutter学习】基础知识(一)
    【软件测试学习】 敏捷开发(二)
    【软件测试学习】 软件测试初步认识(一)
    【hugo】- hugo 监听浏览器切换title
    【hugo】- hugo 博客 添加鼠标单击特效
    春风十里
    一眼就能看懂的C#委托、多播委托和事件的区别与联系。
    js控制的DataGrid的URL参数不能动态刷新表格的问题
    [报错解决].net web api测试页面ajax 报错400 的问题
    [MVC]使用jquery.form.js 异步上传文件
  • 原文地址:https://www.cnblogs.com/javastart/p/14198087.html
Copyright © 2011-2022 走看看