Giter VIP home page Giter VIP logo

libyuv-ios's Introduction

libyuv-ios

libyuv是Google开源库,可用作图像数据格式的转换,比如视频流编解码时格式的转换,YUV数据转化RGB等 为了方便使用,已经将源代码打包成了iOS静态库,其中Code中的中的内容为静态库和头文件(静态库仅支持arm64)

下面以nv12(yuv420sp)转化为I420(yuv420p)为例:

void nv12_to_yuv420p(unsigned char* nv12, unsigned char* yuv420p, int width, int height) {
    
    int y_size = width * height;
    int u_size = y_size / 4;
    int v_size = u_size;
    int uv_size = u_size + v_size;

    unsigned char *src_y = malloc(y_size);
    unsigned char *src_uv = malloc(uv_size);
    memcpy(src_y, nv12, y_size);
    memcpy(src_uv, nv12 + y_size, uv_size);
    
    unsigned char *dst_y = malloc(y_size);
    unsigned char *dst_u = malloc(u_size);
    unsigned char *dst_v = malloc(v_size);
    
    int src_stride_y = width;
    int src_stride_uv = width;
    int dst_stride_y = width;
    int dst_stride_u = width >> 1;
    int dst_stride_v = dst_stride_u;
    
    NV12ToI420(src_y, src_stride_y, src_uv, src_stride_uv, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, width, height);
    memcpy(yuv420p, dst_y, y_size);
    memcpy(yuv420p + y_size, dst_u, u_size);
    memcpy(yuv420p + y_size + u_size, dst_v, v_size);
    
    free(src_y);
    free(src_uv);
    free(dst_y);
    free(dst_u);
    free(dst_v);
}

libyuv-ios's People

Contributors

wccw avatar

Stargazers

 avatar

Watchers

James Cloos avatar ShenYuanLuo avatar

Forkers

hero2000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.