简体   繁体   English

YUV转RGB和CreateBitmap……是什么格式?

[英]YUV to RGB and CreateBitmap…which is the format?

I'm not expert with image format.我不是图像格式的专家。 I'm testing frame rate performance of camera.我正在测试相机的帧率性能。 When I convert data from YUV to RGB, this data which RGB format is?当我将数据从 YUV 转换为 RGB 时,此数据是哪种 RGB 格式? rgb565 or argb8888? rgb565 还是 argb8888? And why createBitmap take a long time?为什么 createBitmap 需要很长时间? add info to raw data?向原始数据添加信息?

This is the rgb code这是rgb代码

public int[] YUV_NV21_TO_RGB( byte[] yuv, int width, int height) {
    final int frameSize = width * height;
    int[] argb = new int[width*height];

    final int ii = 0;
    final int ij = 0;
    final int di = +1;
    final int dj = +1;

    int a = 0;
    for (int i = 0, ci = ii; i < height; ++i, ci += di) {
        for (int j = 0, cj = ij; j < width; ++j, cj += dj) {
            int y = (0xff & ((int) yuv[ci * width + cj]));
            int v = (0xff & ((int) yuv[frameSize + (ci >> 1) * width + (cj & ~1) + 0]));
            int u = (0xff & ((int) yuv[frameSize + (ci >> 1) * width + (cj & ~1) + 1]));
            y = y < 16 ? 16 : y;

            int a0 = 1192 * (y - 16);
            int a1 = 1634 * (v - 128);
            int a2 = 832 * (v - 128);
            int a3 = 400 * (u - 128);
            int a4 = 2066 * (u - 128);

            int r = (a0 + a1) >> 10;
            int g = (a0 - a2 - a3) >> 10;
            int b = (a0 + a4) >> 10;

            r = r < 0 ? 0 : (r > 255 ? 255 : r);
            g = g < 0 ? 0 : (g > 255 ? 255 : g);
            b = b < 0 ? 0 : (b > 255 ? 255 : b);

            argb[a++] = 0xff000000 | (r << 16) | (g << 8) | b;
        }
    }


    return argb;
}

The problem is that if i use CreateBitmap with RGB_565 option, time is at least 10 ms faster than ARGB8888.问题是,如果我使用带有 RGB_565 选项的 CreateBitmap,时间至少比 ARGB8888 快 10 毫秒。 If RGB_565 is a sort of compression (loss of data), should not be the opposite ( createBitmap with ARGB888 faster than RGB_565)?如果RGB_565是一种压缩(数据丢失),不应该是相反的(createBitmap with ARGB888比RGB_565快)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM