C++ 海康 YV12转RGB32,YV420转RGB32
来源:互联网 发布:数据分析统计表 编辑:程序博客网 时间:2024/06/04 20:09
bool YV12_to_RGB32(unsigned char* pYV12, unsigned char* pRGB32, int iWidth, int iHeight){ if (!pYV12 || !pRGB32) return false; const long nYLen = long(iHeight * iWidth); const int nHfWidth = (iWidth >> 1); if (nYLen < 1 || nHfWidth < 1) return false; unsigned char* yData = pYV12; unsigned char* vData = pYV12 + iWidth*iHeight + (iHeight / 2)*(iWidth / 2);//&vData[nYLen >> 2]; unsigned char* uData = pYV12 + iWidth*iHeight;// &yData[nYLen]; if (!uData || !vData) return false; int rgb[4]; int jCol, iRow; for (iRow = 0; iRow < iHeight; iRow++) { for (jCol = 0; jCol < iWidth; jCol++) { rgb[3] = 1; int Y = yData[iRow*iWidth + jCol]; int U = uData[(iRow / 2)*(iWidth / 2) + (jCol / 2)]; int V = vData[(iRow / 2)*(iWidth / 2) + (jCol / 2)]; int R = Y + (U - 128) + (((U - 128) * 103) >> 8); int G = Y - (((V - 128) * 88) >> 8) - (((U - 128) * 183) >> 8); int B = Y + (V - 128) + (((V - 128) * 198) >> 8); // r分量值 R = R<0 ? 0 : R; rgb[2] = R > 255 ? 255 : R; // g分量值 G = G<0 ? 0 : G; rgb[1] = G>255 ? 255 : G; // b分量值 B = B<0 ? 0 : B; rgb[0] = B>255 ? 255 : B; pRGB32[4 * (iRow*iWidth + jCol) + 0] = rgb[0]; pRGB32[4 * (iRow*iWidth + jCol) + 1] = rgb[1]; pRGB32[4 * (iRow*iWidth + jCol) + 2] = rgb[2]; pRGB32[4 * (iRow*iWidth + jCol) + 3] = rgb[3]; } } return true;}
如果是YV420转RGB32,只要把
unsigned char* vData = pYV12 + iWidth*iHeight + (iHeight / 2)*(iWidth / 2);unsigned char* uData = pYV12 + iWidth*iHeight;// &yData[nYLen];改成
unsigned char* vData = pYV12 + iWidth*iHeight;unsigned char* uData = pYV12 + iWidth*iHeight + (iHeight / 2)*(iWidth / 2);
0 0
- C++ 海康 YV12转RGB32,YV420转RGB32
- YV12转换到RGB32[]
- RGB32转RGB565
- YUV420P转RGB32
- RGB32
- C实现RGB32 Gama校正
- ffmpeg 转jpg文件为rgb32格式的文件
- 从零开始学习音视频编程技术(十五) YUV420P转RGB32
- YUV420P转换为RGB32格式
- RGB565,RGB555, RGB888,RGB32转换
- YUV420P转换为RGB32格式
- [iOS]从UIImage得到RGB32的方法
- rgb32编程写为bmp文件
- YV12转RGB24
- 【转】YV12 and NV12
- YV12转opencv IplImage
- YV12转RGB24
- YV12转RGB24
- 7.You have issued a SHUTDOWN ABORT command to bring down your database instance. Considerthe steps t
- ehcacge.xml
- git使用本地
- JAVA学习笔记 NO.1 环境配置
- 如何使用MediaPlayer播发res/raw下的音频文件
- C++ 海康 YV12转RGB32,YV420转RGB32
- SSM整合配置文件(Springmvc+Spring+Mybatis)
- hdu4302(模拟+STL)
- HDFS 权限问题:Permission denied
- ios——推控制器的几种方法
- linux 常用命令
- mysql游标实例演示
- 在cocos2dx中实现水波滤镜
- Java中的重写与重载