ffmpeg解码,通过着色器将avFrame(yuv420p),yuv转换为rgb,但是它是如此绿色

时间:2019-05-06 03:04:04

标签: android ffmpeg android-ndk

shader is in the image

我使用ffmpeg解码xxx.mp4并得到YUV420p AVFrame。然后我通过着色器渲染了yuv数据,但是它是如此的绿色!

uTextureYLocation = glGetUniformLocation(program, uTextureY);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, yTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, avFrame->width, avFrame->height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, avFrame->data[0]);
glUniform1i(uTextureYLocation, 0);

uTextureULocation = glGetUniformLocation(program, uTextureU);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, uTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, avFrame->width / 2, avFrame->height / 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
             avFrame->data[1]);
glUniform1i(uTextureULocation, 1);

uTextureVLocation = glGetUniformLocation(program, uTextureV);
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, vTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, avFrame->width / 2, avFrame->height / 2, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
             avFrame->data[2]);
glUniform1i(uTextureVLocation, 2);

0 个答案:

没有答案