NV12 to RGB

NV12 to RGBtypedefunsignedcharUINT8;typedefunsignedintUINT32;staticUINT8RTable[256][256];staticUINT8GTable[256][256][256];staticUINT8BTable[256][256];staticvoidNV12_T_RGB_Table(){inty,u,v,res;for(y=0;y<=255;y++).

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

typedef unsigned char UINT8;
typedef unsigned int UINT32;

static UINT8 RTable[256][256];
static UINT8 GTable[256][256][256];
static UINT8 BTable[256][256];

static void NV12_T_RGB_Table()
{
    int y, u, v, res;
    for (y = 0; y <= 255; y++)
        for (v = 0; v <= 255; v++)
        {
            res = y + 1.402 * (v - 128);  //r
            if (res > 255)	res = 255;
            if (res < 0)	res = 0;
            RTable[y][v] = res;
        }

    for(y = 0; y <= 255; y++)
        for(u = 0; u <= 255; u++)
            for (v = 0; v <= 255; v++)
            {
                res = y - 0.34414 *(u - 128) - 0.71414 * (v - 128); //g
                if (res > 255)	res = 255;
                if (res < 0)	res = 0;
                GTable[y][u][v] = res;
            }

    for(y = 0; y <= 255; y++)
        for (u = 0; u <= 255; u++)
        {
            res = y + 1.772 * (u - 128); //b
            if (res > 255)	res = 255;
            if (res < 0)	res = 0;
            BTable[y][u] = res;
        }
}

static void NV12_T_BGR(unsigned int width, unsigned int height, unsigned char *yuyv, unsigned char *rgb)
{
    const int nv_start = width * height;
    UINT32  i, j, index = 0, rgb_index = 0;
    UINT8 y, u, v;
    int r, g, b, nv_index = 0;


    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++) {
            //nv_index = (rgb_index / 2 - width / 2 * ((i + 1) / 2)) * 2;
            nv_index = (i >> 1) * width + j - j % 2;

            y = yuyv[rgb_index];
            u = yuyv[nv_start + nv_index];
            v = yuyv[nv_start + nv_index + 1];

            r = RTable[y][v];
            g = GTable[y][u][v];
            b = BTable[y][u];

            //index = rgb_index % width + (height - i - 1) * width;
            index = rgb_index % width + i * width;
            rgb[index * 3 + 0] = b;
            rgb[index * 3 + 1] = g;
            rgb[index * 3 + 2] = r;
            rgb_index++;
        }
    }
}

static void NV12_T_RGB(unsigned int width, unsigned int height, unsigned char *yuyv, unsigned char *rgb)
{
    const int nv_start = width * height;
    UINT32  i, j, index = 0, rgb_index = 0;
    UINT8 y, u, v;
    int r, g, b, nv_index = 0;


    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++) {
            //nv_index = (rgb_index / 2 - width / 2 * ((i + 1) / 2)) * 2;
            nv_index = (i >> 1) * width + j - j % 2;

            y = yuyv[rgb_index];
            u = yuyv[nv_start + nv_index];
            v = yuyv[nv_start + nv_index + 1];

            r = RTable[y][v];
            g = GTable[y][u][v];
            b = BTable[y][u];

            //index = rgb_index % width + (height - i - 1) * width;
            index = rgb_index % width + i * width;
            rgb[index * 3 + 0] = r;
            rgb[index * 3 + 1] = g;
            rgb[index * 3 + 2] = b;
            rgb_index++;
        }
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/194090.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • vmware15最新激活码2021_在线激活

    (vmware15最新激活码2021)本文适用于JetBrains家族所有ide,包括IntelliJidea,phpstorm,webstorm,pycharm,datagrip等。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月22日
    81
  • pool2_commons pool

    pool2_commons pool一次服务上线没多久,页面处于刷新状态,系统发生假死,查看后台日志,并未发现任何的异常信息,在请求接口处增加debug日志后发现,程序在执行到数据库查询相关的地方卡死了。怀疑是数据库连接的问题,但是使用Navicat连接数据库正常。通过jstack导出线程快照发现,jstack<pid>>>jstack.log大量处于WAITTING状态的线程,而这些线程都是在调用borrowObject方法,这个是apachecommon…

    2026年1月23日
    4
  • Python任务调度模块 – APScheduler

    Python任务调度模块 – APScheduler

    2021年9月14日
    74
  • jquery仿搜狐投票动画代码

    体验效果:http://hovertree.com/texiao/jquery/21/这是一款基于jquery实现的仿搜狐投票动画特效源码,运行该源码可见VS图标首先出现在中间位置,紧接着随着投票比例

    2021年12月21日
    41
  • mysql和sqlyog安装教程_mysql 全连接

    mysql和sqlyog安装教程_mysql 全连接最近在学java,然后有涉及数据库,老师说是用MySQL,之前学数据库的时候用的是OracleDatabaseExpress11g,不一样,又得搞一次安装。看了很多教程,也踩了很多坑,记录一下。1.下载MySQLInstaller我下载的是MSIInstaller,感觉这个比较快。也可以下载ZIP,看了教程说要添加my.ini文件,改环境变量什么的。好麻烦。看了用MSIInstaller安装的,不用,所以。。MSIInstaller下载链接选择第二个下载选择Nothanks,j

    2025年6月12日
    5
  • Django(57)Generic类视图[通俗易懂]

    Django(57)Generic类视图[通俗易懂]前言上篇我们通过mixin可以非常方便的实现一些CURD操作。实际上针对这些mixin,DRF还进一步的进行了封装,放到generics下。有以下generic类视图:generics.ListA

    2022年7月29日
    11

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号