Permalink
Browse files

vdpau: redesign

  • Loading branch information...
1 parent 560ef88 commit b0ace21fa18b816afece0952d0ca8fe4ce879125 @FernetMenta committed Apr 7, 2012
@@ -5114,7 +5114,15 @@ msgctxt "#13434"
msgid "Play only this"
msgstr ""
-#empty strings from id 13435 to 13499
+msgctxt "#13435"
+msgid "Allow Vdpau OpenGL interop"
+msgstr ""
+
+msgctxt "#13436"
+msgid "Allow Vdpau OpenGL interop YUV"
+msgstr ""
+
+#empty strings from id 13437 to 13499
msgctxt "#13500"
msgid "A/V sync method"
@@ -6333,7 +6341,7 @@ msgid "Software Blend"
msgstr ""
msgctxt "#16325"
-msgid "Auto - ION Optimized"
+msgid "VDPAU - Bob"
msgstr ""
#empty strings from id 16326 to 16399
@@ -70,6 +70,18 @@ void main()
rgb.a = gl_Color.a;
gl_FragColor = rgb;
+#elif defined(XBMC_VDPAU_NV12)
+
+ vec4 yuv, rgb;
+ yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r
+ , texture2D(m_sampU, stretch(m_cordU)).r
+ , texture2D(m_sampV, stretch(m_cordV)).g
+ , 1.0 );
+
+ rgb = m_yuvmat * yuv;
+ rgb.a = gl_Color.a;
+ gl_FragColor = rgb;
+
#elif defined(XBMC_YUY2) || defined(XBMC_UYVY)
#if(XBMC_texture_rectangle)
@@ -689,6 +689,18 @@ void CLinuxRendererGL::RenderUpdate(bool clear, DWORD flags, DWORD alpha)
glDisable(GL_POLYGON_STIPPLE);
}
+ else if(m_format == RENDER_FMT_VDPAU_420
+ && !(flags & RENDER_FLAG_BOTH))
+ {
+ glDisable(GL_BLEND);
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ Render(flags | RENDER_FLAG_TOP, index);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glColor4f(1.0f, 1.0f, 1.0f, 128 / 255.0f);
+ Render(flags | RENDER_FLAG_BOT , index);
+ }
else
Render(flags, index);
@@ -769,11 +781,6 @@ void CLinuxRendererGL::FlipPage(int source)
m_buffers[m_iYV12RenderBuffer].flipindex = ++m_flipindex;
-#ifdef HAVE_LIBVDPAU
- if((m_renderMethod & RENDER_VDPAU) && m_buffers[m_iYV12RenderBuffer].vdpau)
- m_buffers[m_iYV12RenderBuffer].vdpau->Present();
-#endif
-
return;
}
@@ -1100,6 +1107,12 @@ void CLinuxRendererGL::LoadShaders(int field)
m_textureCreate = &CLinuxRendererGL::CreateVDPAUTexture;
m_textureDelete = &CLinuxRendererGL::DeleteVDPAUTexture;
}
+ else if (m_format == RENDER_FMT_VDPAU_420)
+ {
+ m_textureUpload = &CLinuxRendererGL::UploadVDPAUTexture420;
+ m_textureCreate = &CLinuxRendererGL::CreateVDPAUTexture420;
+ m_textureDelete = &CLinuxRendererGL::DeleteVDPAUTexture420;
+ }
else if (m_format == RENDER_FMT_VAAPI)
{
m_textureUpload = &CLinuxRendererGL::UploadVAAPITexture;
@@ -1175,7 +1188,10 @@ void CLinuxRendererGL::Render(DWORD flags, int renderBuffer)
m_currentField = FIELD_FULL;
// call texture load function
+ m_skipRender = false;
(this->*m_textureUpload)(renderBuffer);
+ if (m_skipRender)
+ return;
if (m_renderMethod & RENDER_GLSL)
{
@@ -1541,17 +1557,12 @@ void CLinuxRendererGL::RenderFromFBO()
void CLinuxRendererGL::RenderVDPAU(int index, int field)
{
#ifdef HAVE_LIBVDPAU
- YUVPLANE &plane = m_buffers[index].fields[field][0];
- CVDPAU *vdpau = m_buffers[m_iYV12RenderBuffer].vdpau;
-
- if (!vdpau)
- return;
+ YUVPLANE &plane = m_buffers[index].fields[0][1];
glEnable(m_textureTarget);
glActiveTextureARB(GL_TEXTURE0);
- glBindTexture(m_textureTarget, plane.id);
- vdpau->BindPixmap();
+ glBindTexture(m_textureTarget, plane.id);
// Try some clamping or wrapping
glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@@ -1609,8 +1620,6 @@ void CLinuxRendererGL::RenderVDPAU(int index, int field)
if (m_pVideoFilterShader)
m_pVideoFilterShader->Disable();
- vdpau->ReleasePixmap();
-
glBindTexture (m_textureTarget, 0);
glDisable(m_textureTarget);
#endif
@@ -2295,12 +2304,14 @@ void CLinuxRendererGL::DeleteVDPAUTexture(int index)
{
#ifdef HAVE_LIBVDPAU
YUVPLANE &plane = m_buffers[index].fields[0][0];
+ YUVFIELDS &fields = m_buffers[index].fields;
SAFE_RELEASE(m_buffers[index].vdpau);
if(plane.id && glIsTexture(plane.id))
glDeleteTextures(1, &plane.id);
plane.id = 0;
+ fields[0][1].id = 0;
#endif
}
@@ -2334,11 +2345,152 @@ bool CLinuxRendererGL::CreateVDPAUTexture(int index)
void CLinuxRendererGL::UploadVDPAUTexture(int index)
{
#ifdef HAVE_LIBVDPAU
+ VDPAU::CVdpauRenderPicture *vdpau = m_buffers[index].vdpau;
+
+ unsigned int flipindex = m_buffers[index].flipindex;
+ YUVFIELDS &fields = m_buffers[index].fields;
+ YUVPLANE &plane = fields[0][0];
+
+ if (!vdpau || !vdpau->valid)
+ {
+ m_eventTexturesDone[index]->Set();
+ m_skipRender = true;
+ return;
+ }
+
+ fields[0][1].id = vdpau->texture[0];
+
+ m_eventTexturesDone[index]->Set();
+#endif
+}
+
+void CLinuxRendererGL::DeleteVDPAUTexture420(int index)
+{
+#ifdef HAVE_LIBVDPAU
+ YUVPLANE &plane = m_buffers[index].fields[0][0];
+ YUVFIELDS &fields = m_buffers[index].fields;
+
+ SAFE_RELEASE(m_buffers[index].vdpau);
+
+ if(plane.id && glIsTexture(plane.id))
+ glDeleteTextures(1, &plane.id);
+ plane.id = 0;
+ fields[1][0].id = 0;
+ fields[1][1].id = 0;
+ fields[2][0].id = 0;
+ fields[2][1].id = 0;
+
+#endif
+}
+
+bool CLinuxRendererGL::CreateVDPAUTexture420(int index)
+{
+#ifdef HAVE_LIBVDPAU
+ YV12Image &im = m_buffers[index].image;
+ YUVFIELDS &fields = m_buffers[index].fields;
+ YUVPLANE &plane = fields[0][0];
+ GLuint *pbo = m_buffers[index].pbo;
+
+ DeleteVDPAUTexture420(index);
+
+ memset(&im , 0, sizeof(im));
+ memset(&fields, 0, sizeof(fields));
+
+ im.cshift_x = 1;
+ im.cshift_y = 1;
+
+ im.plane[0] = NULL;
+ im.plane[1] = NULL;
+ im.plane[2] = NULL;
+
+ for(int p = 0;p<3;p++)
+ {
+ pbo[p] = None;
+ }
+
+ glEnable(m_textureTarget);
+ glGenTextures(1, &plane.id);
+ glDisable(m_textureTarget);
+
m_eventTexturesDone[index]->Set();
- glPixelStorei(GL_UNPACK_ALIGNMENT,1); //what's this for?
#endif
+ return true;
}
+void CLinuxRendererGL::UploadVDPAUTexture420(int index)
+{
+#ifdef HAVE_LIBVDPAU
+ VDPAU::CVdpauRenderPicture *vdpau = m_buffers[index].vdpau;
+ YV12Image &im = m_buffers[index].image;
+
+ unsigned int flipindex = m_buffers[index].flipindex;
+ YUVFIELDS &fields = m_buffers[index].fields;
+ YUVPLANE &plane = fields[0][0];
+
+ if (!vdpau || !vdpau->valid)
+ {
+ m_eventTexturesDone[index]->Set();
+ m_skipRender = true;
+ return;
+ }
+
+ im.height = vdpau->texHeight;
+ im.width = vdpau->texWidth;
+
+ // YUV
+ for (int f = FIELD_FULL; f<=FIELD_BOT ; f++)
+ {
+ int fieldshift = (f==FIELD_FULL) ? 0 : 1;
+ YUVPLANES &planes = fields[f];
+
+ planes[0].texwidth = im.width;
+ planes[0].texheight = im.height >> fieldshift;
+
+ planes[1].texwidth = planes[0].texwidth >> im.cshift_x;
+ planes[1].texheight = planes[0].texheight >> im.cshift_y;
+ planes[2].texwidth = planes[1].texwidth;
+ planes[2].texheight = planes[1].texheight;
+
+ for (int p = 0; p < 3; p++)
+ {
+ planes[p].pixpertex_x = 1;
+ planes[p].pixpertex_y = 1;
+ }
+ }
+ // crop
+// m_sourceRect.x1 += vdpau->crop.x1;
+// m_sourceRect.x2 -= vdpau->crop.x2;
+// m_sourceRect.y1 += vdpau->crop.y1;
+// m_sourceRect.y2 -= vdpau->crop.y2;
+
+ // set textures
+ fields[1][0].id = vdpau->texture[0];
+ fields[1][1].id = vdpau->texture[2];
+ fields[2][0].id = vdpau->texture[1];
+ fields[2][1].id = vdpau->texture[3];
+
+ glEnable(m_textureTarget);
+ for (int f = 1; f < 3; f++)
+ {
+ for (int p=0;p<2;p++)
+ {
+ glBindTexture(m_textureTarget,fields[f][p].id);
+ glTexParameteri(m_textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(m_textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(m_textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ glBindTexture(m_textureTarget,0);
+ VerifyGLState();
+ }
+ fields[f][2].id = fields[f][1].id;
+ }
+ CalculateTextureSourceRects(index, 3);
+ glDisable(m_textureTarget);
+
+ m_eventTexturesDone[index]->Set();
+#endif
+}
void CLinuxRendererGL::DeleteVAAPITexture(int index)
{
@@ -3276,12 +3428,13 @@ bool CLinuxRendererGL::Supports(EINTERLACEMETHOD method)
if(method == VS_INTERLACEMETHOD_AUTO)
return true;
- if(m_renderMethod & RENDER_VDPAU)
+ if(m_renderMethod & RENDER_VDPAU ||
+ m_format == RENDER_FMT_VDPAU_420)
{
#ifdef HAVE_LIBVDPAU
- CVDPAU *vdpau = m_buffers[m_iYV12RenderBuffer].vdpau;
- if(vdpau)
- return vdpau->Supports(method);
+ VDPAU::CVdpauRenderPicture *vdpauPic = m_buffers[m_iYV12RenderBuffer].vdpau;
+ if(vdpauPic && vdpauPic->vdpau)
+ return vdpauPic->vdpau->Supports(method);
#endif
return false;
}
@@ -3367,14 +3520,7 @@ EINTERLACEMETHOD CLinuxRendererGL::AutoInterlaceMethod()
return VS_INTERLACEMETHOD_NONE;
if(m_renderMethod & RENDER_VDPAU)
- {
-#ifdef HAVE_LIBVDPAU
- CVDPAU *vdpau = m_buffers[m_iYV12RenderBuffer].vdpau;
- if(vdpau)
- return vdpau->AutoInterlaceMethod();
-#endif
return VS_INTERLACEMETHOD_NONE;
- }
if(Supports(VS_INTERLACEMETHOD_RENDER_BOB))
return VS_INTERLACEMETHOD_RENDER_BOB;
@@ -3417,11 +3563,12 @@ void CLinuxRendererGL::UnBindPbo(YUVBUFFER& buff)
}
#ifdef HAVE_LIBVDPAU
-void CLinuxRendererGL::AddProcessor(CVDPAU* vdpau, int index)
+void CLinuxRendererGL::AddProcessor(VDPAU::CVdpauRenderPicture *vdpau, int index)
{
YUVBUFFER &buf = m_buffers[index];
+ VDPAU::CVdpauRenderPicture *pic = vdpau->Acquire();
SAFE_RELEASE(buf.vdpau);
- buf.vdpau = (CVDPAU*)vdpau->Acquire();
+ buf.vdpau = pic;
}
#endif
Oops, something went wrong.

0 comments on commit b0ace21

Please sign in to comment.