YUV图片旋转

1、从H264视频流中解析出来的图片格式是YUV

  YUV旋转可以选择手工旋转,也可以利用libYUV,libYUV开启NEON指令之后可以加快处理速度

  在iOS系统上,利用Accelcerate库进行加速,其中旋转的方法是libYUV旋转的20倍

  

    //测试YUV to RGBA 旋转然后 再到YUV 性能
    
    int width  = inFrame->width;
    int height = inFrame->height;
    int size   = width*height*4;
    uint8 *pRGBA = (uint8 *)calloc(size*3, sizeof(uint8));
    uint8 *pDstRGBA = (uint8 *)calloc(size*3, sizeof(uint8));
    
    start = [NSDate date];
    
    libyuv::I420ToARGB(inFrame->data[0],
                       inFrame->linesize[0],
                       inFrame->data[1],
                       inFrame->linesize[1],
                       inFrame->data[2],
                       inFrame->linesize[2],
                       pRGBA,
                       width*4,
                       width,
                       height);
    
    Pixel_8888 bgColor = {0,0,0,0};
    vImageRotate_ARGB8888((const vImage_Buffer *)pRGBA,
                          (const vImage_Buffer *)pDstRGBA,
                          NULL,
                          angle,
                          bgColor,
                          kvImageBackgroundColorFill);
    
    libyuv::ARGBToI420(pDstRGBA,
                       height*4,
                       _rotFrame->data[0],
                       _rotFrame->linesize[0],
                       _rotFrame->data[1],
                       _rotFrame->linesize[1],
                       _rotFrame->data[2],
                       _rotFrame->linesize[2],
                       width,
                       height);
    
    LOGE("YUV Rotate -[vImageRotate_ARGB8888] cost : %f", [[NSDate date] timeIntervalSinceDate:start]);

    free(pRGBA);
    free(pDstRGBA);

  

posted @ 2017-03-23 16:48  兜兜有糖的博客  阅读(2766)  评论(0编辑  收藏  举报