相关疑难解决方法(0)

通过GLSL将YV12转换为RGB的问题

我试图完成YV12到RGB转换提到在这个岗位与GLSL着色器.

我的应用程序从磁盘加载原始YV12帧并尝试使用GLSL着色器执行转换.但是,生成的图像会垂直翻转并出现一些颜色问题.我认为问题可能是图像被读取为char(1字节)的数组,然后转换为GLushort(2字节)的数组.你怎么看?

这是原始YUV框架的样子:

在此输入图像描述

并且可以从此处下载应用程序加载的原始帧.

这是我得到的输出:

在此输入图像描述

我正在分享以下应用程序的源代码:

#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/glu.h>

#include <iostream>

#include <fstream>

#ifndef SEEK_SET
#  define SEEK_SET 0
#endif

static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
static GLint ImgWidth, ImgHeight;
static GLushort *ImageYUV = NULL;


static void DrawObject(void)
{
   glBegin(GL_QUADS);

   glTexCoord2f(0, 0);
   glVertex2f(-1.0, -1.0);

   glTexCoord2f(ImgWidth, 0);
   glVertex2f(1.0, -1.0);

   glTexCoord2f(ImgWidth, ImgHeight);
   glVertex2f(1.0, 1.0);

   glTexCoord2f(0, …
Run Code Online (Sandbox Code Playgroud)

c c++ opengl glsl yuv

6
推荐指数
1
解决办法
3855
查看次数

标签 统计

c ×1

c++ ×1

glsl ×1

opengl ×1

yuv ×1