mirror of
https://github.com/wang-bin/QtAV.git
synced 2026-10-29 11:36:51 +08:00
gl: try 10bit yuv planar. wrong color now
This commit is contained in:
@@ -342,6 +342,9 @@ bool GLWidgetRendererPrivate::prepareShaderProgram(const VideoFormat &fmt)
|
||||
}
|
||||
if (frag.isEmpty())
|
||||
return false;
|
||||
if (!fmt.isRGB() && fmt.isPlanar() && fmt.bitsPerPixel(0) == 10) {
|
||||
frag.prepend("#define P010 1\n");
|
||||
}
|
||||
#if NO_QGL_SHADER
|
||||
program = createProgram(kVertexShader, frag.toUtf8().constData());
|
||||
if (!program) {
|
||||
@@ -449,12 +452,19 @@ bool GLWidgetRendererPrivate::initTextures(const VideoFormat &fmt)
|
||||
if (fmt.planeCount() == 2) {
|
||||
internal_format[1] = data_format[1] = GL_LUMINANCE_ALPHA;
|
||||
} else {
|
||||
internal_format[1] = data_format[1] = GL_LUMINANCE; //vec4(L,L,L,0)
|
||||
internal_format[2] = data_format[2] = GL_ALPHA;//GL_ALPHA;
|
||||
if (fmt.bytesPerPixel(1) == 2) {
|
||||
// read 16 bits and compute in shader
|
||||
internal_format[0] = data_format[0] = GL_LUMINANCE_ALPHA; //or GL_RED for GL
|
||||
internal_format[1] = data_format[1] = GL_LUMINANCE_ALPHA; //vec4(L,L,L,A)
|
||||
internal_format[2] = data_format[2] = GL_LUMINANCE_ALPHA;
|
||||
} else {
|
||||
internal_format[1] = data_format[1] = GL_LUMINANCE; //vec4(L,L,L,1)
|
||||
internal_format[2] = data_format[2] = GL_ALPHA;//GL_ALPHA;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < internal_format.size(); ++i) {
|
||||
// xbmc use bpp not bpp(plane)
|
||||
internal_format[i] = GetGLInternalFormat(data_format[i], fmt.bytesPerPixel(i));
|
||||
//internal_format[i] = GetGLInternalFormat(data_format[i], fmt.bytesPerPixel(i));
|
||||
//data_format[i] = internal_format[i];
|
||||
}
|
||||
} else {
|
||||
@@ -462,8 +472,9 @@ bool GLWidgetRendererPrivate::initTextures(const VideoFormat &fmt)
|
||||
// TODO: if no alpha, data_fmt is not GL_BGRA. align at every upload?
|
||||
}
|
||||
for (int i = 0; i < fmt.planeCount(); ++i) {
|
||||
//qDebug("format: %#x GL_LUMINANCE_ALPHA=%#x", data_format[i], GL_LUMINANCE_ALPHA);
|
||||
if (fmt.bytesPerPixel(i) == 2 && fmt.planeCount() == 3) {
|
||||
data_type[i] = GL_UNSIGNED_SHORT;
|
||||
//data_type[i] = GL_UNSIGNED_SHORT;
|
||||
}
|
||||
int bpp_gl = bytesOfGLFormat(data_format[i], data_type[i]);
|
||||
int pad = qCeil((qreal)(texture_size[i].width() - effective_tex_width[i])/(qreal)bpp_gl);
|
||||
|
||||
@@ -27,12 +27,24 @@ const mat4 yuv2rgbMatrix = mat4(1, 1, 1, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, -0.5, -0.5, 1);
|
||||
|
||||
// 10, 16bit: http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578%28v=vs.85%29.aspx
|
||||
void main()
|
||||
{
|
||||
#if P010
|
||||
// yyyyyyyy yy000000 => (L, L, L, A)
|
||||
gl_FragColor = clamp(u_colorMatrix*yuv2rgbMatrix* vec4(
|
||||
(texture2D(u_Texture0, v_TexCoords).r*4.0 + texture2D(u_Texture0, v_TexCoords).a/64.0)*255.0/1023.0,
|
||||
(texture2D(u_Texture1, v_TexCoords).r*4.0 + texture2D(u_Texture1, v_TexCoords).a/64.0)*255.0/1023.0,
|
||||
(texture2D(u_Texture2, v_TexCoords).r*4.0 + texture2D(u_Texture2, v_TexCoords).a/64.0)*255.0/1023.0,
|
||||
1)
|
||||
, 0.0, 1.0);
|
||||
#else
|
||||
// use r, g, a to work for both yv12 and nv12
|
||||
gl_FragColor = clamp(u_colorMatrix*yuv2rgbMatrix* vec4(texture2D(u_Texture0, v_TexCoords).r,
|
||||
texture2D(u_Texture1, v_TexCoords).g,
|
||||
texture2D(u_Texture2, v_TexCoords).a,
|
||||
1)
|
||||
, 0.0, 1.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user