diff -ur -X excl mythtv-vid-17/libs/libmythtv/frame.h mythtv-vid-18/libs/libmythtv/frame.h
--- mythtv-vid-17/libs/libmythtv/frame.h	2008-07-03 15:20:46.000000000 +0800
+++ mythtv-vid-18/libs/libmythtv/frame.h	2008-07-04 08:34:13.000000000 +0800
@@ -21,7 +21,7 @@
     FMT_ARGB32,
     FMT_RGBA32,
     FMT_YUV422P,
-    FMT_ALPHA,
+    FMT_BGRA,
 } VideoFrameType;
 
 typedef struct VideoFrame_
diff -ur -X excl mythtv-vid-17/libs/libmythtv/openglcontext.cpp mythtv-vid-18/libs/libmythtv/openglcontext.cpp
--- mythtv-vid-17/libs/libmythtv/openglcontext.cpp	2008-07-03 21:59:08.000000000 +0800
+++ mythtv-vid-18/libs/libmythtv/openglcontext.cpp	2008-07-04 08:34:13.000000000 +0800
@@ -4,6 +4,7 @@
 
 #include "util-opengl.h"
 
+
 #define LOC QString("GLCtx: ")
 #define LOC_ERR QString("GLCtx, Error: ")
 
@@ -19,13 +20,41 @@
         m_ctx->MakeCurrent(false);
 }
 
+class MythGLTexture
+{
+  public:
+    MythGLTexture() :
+        m_type(GL_TEXTURE_2D), m_data(NULL), m_data_size(0),
+        m_data_type(GL_UNSIGNED_BYTE), m_data_fmt(GL_BGRA),
+        m_internal_fmt(GL_RGBA8), m_pbo(0),
+        m_filter(GL_LINEAR), m_wrap(GL_CLAMP_TO_EDGE),
+        m_size(0,0), m_vid_size(0,0)
+    {
+    }
+
+    ~MythGLTexture()
+    {
+    }
+
+    GLuint  m_type;
+    unsigned char *m_data;
+    uint    m_data_size;
+    GLuint  m_data_type;
+    GLuint  m_data_fmt;
+    GLuint  m_internal_fmt;
+    GLuint  m_pbo;
+    GLuint  m_filter;
+    GLuint  m_wrap;
+    QSize   m_size;
+    QSize   m_vid_size;
+};
+
 class PrivateContext
 {
   public:
     PrivateContext() :
         m_glx_fbconfig(0), m_gl_window(0), m_glx_window(0),
-        m_glx_context(NULL),
-        m_texture_type(GL_TEXTURE_2D), m_textures_enabled(false),
+        m_glx_context(NULL), m_texture_type(0),
         m_vis_info(NULL), m_attr_list(NULL)
     {
     }
@@ -39,14 +68,12 @@
     GLXWindow    m_glx_window;
     GLXContext   m_glx_context;
     int          m_texture_type;
-    bool         m_textures_enabled;
     XVisualInfo *m_vis_info;
     int const   *m_attr_list;
 
-    vector<GLuint> m_textures;
+    map<GLuint, MythGLTexture> m_textures;
     vector<GLuint> m_programs;
     vector<GLuint> m_framebuffers;
-    vector<GLuint> m_pbos;
     GLuint         m_fence;
 };
 
@@ -75,7 +102,6 @@
         DeletePrograms();
         DeleteTextures();
         DeleteFrameBuffers();
-        DeletePBOs();
 
         Flush(true);
 
@@ -265,11 +291,8 @@
         MakeCurrent(false);
     }
 
-    int tex_type = get_gl_texture_rect_type(m_extensions);
-    m_priv->m_texture_type = (tex_type) ? tex_type : m_priv->m_texture_type;
-
     m_ext_supported =
-        ((tex_type) ? kGLExtRect : 0) |
+        ((get_gl_texture_rect_type(m_extensions)) ? kGLExtRect : 0) |
         ((has_gl_fragment_program_support(m_extensions)) ?
          kGLExtFragProg : 0) |
         ((has_gl_pixelbuffer_object_support(m_extensions)) ?
@@ -380,27 +403,160 @@
 }
 
 // locking ok
-void OpenGLContext::EnableTextures(void)
+void OpenGLContext::EnableTextures(uint tex, uint tex_type)
 {
-    if (!m_priv->m_textures_enabled)
+    MakeCurrent(true);
+
+    int type = tex ? m_priv->m_textures[tex].m_type : tex_type;
+
+    if (type != m_priv->m_texture_type)
     {
-        m_priv->m_textures_enabled = true;
+        if (m_priv->m_texture_type)
+        {
+            glDisable(m_priv->m_texture_type);
+        }
+        glEnable(type);
+        m_priv->m_texture_type = type;
+    }
 
-        MakeCurrent(true);
-        glEnable(GetTextureType());
-        MakeCurrent(false);
+    MakeCurrent(false);
+}
+
+void OpenGLContext::UpdateTexture(uint tex,
+                       const unsigned char *buf,
+                       const int *offsets,
+                       const int *pitches,
+                       VideoFrameType fmt,
+                       bool interlaced,
+                       const unsigned char* alpha)
+{
+    MakeCurrent(true);
+
+    MythGLTexture *tmp_tex = &m_priv->m_textures[tex];
+    QSize size = tmp_tex->m_vid_size;
+
+    EnableTextures(tex);
+    glBindTexture(tmp_tex->m_type, tex);
+
+    if (tmp_tex->m_pbo)
+    {
+        void *pboMemory;
+
+        gMythGLBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, tmp_tex->m_pbo);
+        gMythGLBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,
+                             tmp_tex->m_data_size, NULL, GL_STREAM_DRAW);
+
+        pboMemory = gMythGLMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,
+                                        GL_WRITE_ONLY);
+
+        if (FMT_BGRA == fmt)
+        {
+            memcpy(pboMemory, buf, tmp_tex->m_data_size);
+        }
+        else if (interlaced)
+        {
+            pack_yv12interlaced(buf, (unsigned char *)pboMemory,
+                                offsets, pitches, size);
+        }
+        else
+        {
+            pack_yv12alpha(buf, (unsigned char *)pboMemory,
+                           offsets, pitches, size, alpha);
+        }
+
+        gMythGLUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
+
+        glTexSubImage2D(tmp_tex->m_type, 0, 0, 0, size.width(), size.height(),
+                        tmp_tex->m_data_fmt, tmp_tex->m_data_type, 0);
+
+        gMythGLBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
     }
+    else
+    {
+        if (!tmp_tex->m_data)
+        {
+            unsigned char *scratch = new unsigned char[tmp_tex->m_data_size];
+            if (scratch)
+            {
+                bzero(scratch, tmp_tex->m_data_size);
+                tmp_tex->m_data = scratch;
+            }
+        }
+
+        if (tmp_tex->m_data)
+        {
+            const unsigned char *tmp = tmp_tex->m_data;
+
+            if (FMT_BGRA == fmt)
+            {
+                tmp = buf;
+            }
+            else if (interlaced)
+            {
+                pack_yv12interlaced(buf, tmp,
+                                    offsets, pitches, size);
+            }
+            else
+            {
+                pack_yv12alpha(buf, tmp, offsets,
+                               pitches, size, alpha);
+            }
+
+            glTexSubImage2D(tmp_tex->m_type, 0, 0, 0,
+                            size.width(), size.height(),
+                            tmp_tex->m_data_fmt, tmp_tex->m_data_type,
+                            tmp);
+        }
+    }
+
+    MakeCurrent(false);
 }
 
 // locking ok
-uint OpenGLContext::CreateTexture(void)
+uint OpenGLContext::CreateTexture(QSize tot_size, QSize vid_size,
+                                  bool use_pbo,
+                                  uint type, uint data_type,
+                                  uint data_fmt, uint internal_fmt,
+                                  uint filter, uint wrap)
 {
+    if ((uint)tot_size.width() > m_max_tex_size ||
+        (uint)tot_size.height() > m_max_tex_size)
+        return 0;
+
     MakeCurrent(true);
 
+    EnableTextures(0, type);
+
     GLuint tex;
     glGenTextures(1, &tex);
-    SetupTextureFilters(tex, GL_LINEAR);
-    m_priv->m_textures.push_back(tex);
+    glBindTexture(type, tex);
+
+    if (tex)
+    {
+        MythGLTexture *texture = new MythGLTexture();
+        texture->m_type = type;
+        texture->m_data_type = data_type;
+        texture->m_data_fmt = data_fmt;
+        texture->m_internal_fmt = internal_fmt;
+        texture->m_size = tot_size;
+        texture->m_vid_size = vid_size;
+        texture->m_data_size = GetBufferSize(vid_size, data_fmt, data_type);
+        m_priv->m_textures[tex] = *texture;
+
+        if (ClearTexture(tex) && m_priv->m_textures[tex].m_data_size)
+        {
+            SetTextureFilters(tex, filter, wrap);
+            if (use_pbo)
+                m_priv->m_textures[tex].m_pbo = CreatePBO(tex);
+        }
+        else
+        {
+            DeleteTexture(tex);
+            tex = 0;
+        }
+
+        delete texture;
+    }
 
     Flush(true);
 
@@ -409,25 +565,63 @@
     return tex;
 }
 
+uint OpenGLContext::GetBufferSize(QSize size, uint fmt, uint type)
+{
+    uint bytes;
+    uint bpp;
+
+    switch (fmt)
+    {
+        case GL_BGRA:
+        case GL_RGBA:
+            bpp = 4;
+            break;
+        default:
+            bpp =0;
+    }
+
+    switch (type)
+    {
+        case GL_UNSIGNED_BYTE:
+            bytes = sizeof(GLubyte);
+            break;
+        case GL_FLOAT:
+            bytes = sizeof(GLfloat);
+            break;
+        default:
+            bytes = 0;
+    }
+
+    if (!bpp || !bytes || size.width() < 1 || size.height() < 1)
+        return 0;
+
+    return size.width() * size.height() * bpp * bytes;
+}
+
 // locking ok
-bool OpenGLContext::SetupTexture(const QSize &size, uint tex, int filt)
+bool OpenGLContext::ClearTexture(uint tex)
 {
-    unsigned char *scratch =
-        new unsigned char[(size.width() * size.height() * 4) + 128];
+    MythGLTexture *tmp = &m_priv->m_textures[tex];
+    QSize size = tmp->m_size;
+
+    uint tmp_size = GetBufferSize(size, tmp->m_data_fmt, tmp->m_data_type);
+
+    if (!tmp_size)
+        return false;
+
+    unsigned char *scratch = new unsigned char[tmp_size];
 
     if (!scratch)
         return false;
 
-    bzero(scratch, size.width() * size.height() * 4);
+    bzero(scratch, tmp_size);
 
     GLint check;
 
-    MakeCurrent(true);
-    SetupTextureFilters(tex, filt);
-    glTexImage2D(GetTextureType(), 0, GL_RGBA8, size.width(), size.height(),
-                 0, GL_RGB , GL_UNSIGNED_BYTE, scratch);
-    glGetTexLevelParameteriv(GetTextureType(), 0, GL_TEXTURE_WIDTH, &check);
-    MakeCurrent(false);
+    glTexImage2D(tmp->m_type, 0, tmp->m_internal_fmt,
+                 size.width(), size.height(), 0,
+                 tmp->m_data_fmt , tmp->m_data_type, scratch);
+    glGetTexLevelParameteriv(tmp->m_type, 0, GL_TEXTURE_WIDTH, &check);
 
     delete [] scratch;
 
@@ -435,34 +629,53 @@
 }
 
 // locking ok
-void OpenGLContext::SetupTextureFilters(uint tex, int filt)
+void OpenGLContext::SetTextureFilters(uint tex, uint filt, uint wrap)
 {
+    if (!m_priv->m_textures.count(tex))
+        return;
+
     MakeCurrent(true);
-    glBindTexture(GetTextureType(), tex);
-    glTexParameteri(GetTextureType(), GL_TEXTURE_MIN_FILTER, filt);
-    glTexParameteri(GetTextureType(), GL_TEXTURE_MAG_FILTER, filt);
-    glTexParameteri(GetTextureType(), GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-    glTexParameteri(GetTextureType(), GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+    EnableTextures(tex);
+
+    m_priv->m_textures[tex].m_filter = filt;
+    m_priv->m_textures[tex].m_wrap = wrap;
+
+    uint type = m_priv->m_textures[tex].m_type;
+
+    glBindTexture(type, tex);
+    glTexParameteri(type, GL_TEXTURE_MIN_FILTER, filt);
+    glTexParameteri(type, GL_TEXTURE_MAG_FILTER, filt);
+    glTexParameteri(type, GL_TEXTURE_WRAP_S, wrap);
+    if (type != GL_TEXTURE_1D)
+        glTexParameteri(type, GL_TEXTURE_WRAP_T, wrap);
+
     MakeCurrent(false);
 }
 
 // locking ok
 void OpenGLContext::DeleteTexture(uint tex)
 {
+    if (!m_priv->m_textures.count(tex))
+        return;
+
     MakeCurrent(true);
 
-    vector<GLuint>::iterator it;
-    for (it = m_priv->m_textures.begin(); it !=m_priv->m_textures.end(); it++)
+    GLuint gltex = tex;
+    glDeleteTextures(1, &gltex);
+
+    if (m_priv->m_textures[tex].m_data)
     {
-        if (*(it) == tex)
-        {
-            GLuint gltex = tex;
-            glDeleteTextures(1, &gltex);
-            m_priv->m_textures.erase(it);
-            break;
-        }
+        delete m_priv->m_textures[tex].m_data;
+    }
+
+    if (m_priv->m_textures[tex].m_pbo)
+    {
+        gMythGLDeleteBuffersARB(1, &(m_priv->m_textures[tex].m_pbo));
     }
 
+    m_priv->m_textures.erase(tex);
+
     Flush(true);
 
     MakeCurrent(false);
@@ -471,17 +684,40 @@
 // locking ok
 void OpenGLContext::DeleteTextures(void)
 {
-    vector<GLuint>::iterator it;
+    map<GLuint, MythGLTexture>::iterator it;
     for (it = m_priv->m_textures.begin(); it !=m_priv->m_textures.end(); it++)
-        glDeleteTextures(1, &(*(it)));
+    {
+        GLuint gltex = it->first;
+        glDeleteTextures(1, &gltex);
+
+        if (it->second.m_data)
+        {
+            delete it->second.m_data;
+        }
+
+        if (it->second.m_pbo)
+        {
+            gltex = it->second.m_pbo;
+            gMythGLDeleteBuffersARB(1, &gltex);
+        }
+    }
     m_priv->m_textures.clear();
 
     Flush(true);
 }
 
-int OpenGLContext::GetTextureType(void) const
+void OpenGLContext::GetTextureType(uint &current, bool &rect)
 {
-    return m_priv->m_texture_type;
+    uint type = get_gl_texture_rect_type(m_extensions);
+    if (type)
+    {
+        rect = true;
+        current = type;
+        return;
+    }
+
+    rect = false;
+    return;
 }
 
 // locking ok
@@ -585,26 +821,31 @@
 }
 
 // locking ok
-bool OpenGLContext::CreateFrameBuffer(uint &fb, uint tex, const QSize &size)
+bool OpenGLContext::CreateFrameBuffer(uint &fb, uint tex)
 {
+    if (!m_priv->m_textures.count(tex))
+        return false;
+
+    MythGLTexture *tmp = &m_priv->m_textures[tex];
+    QSize size = tmp->m_size;
     GLuint glfb;
 
     MakeCurrent(true);
     glCheck();
 
-    SetupTextureFilters(tex, GL_LINEAR);
+    EnableTextures(tex);
 
     glPushAttrib(GL_VIEWPORT_BIT);
     glViewport(0, 0, size.width(), size.height());
     gMythGLGenFramebuffersEXT(1, &glfb);
     gMythGLBindFramebufferEXT(GL_FRAMEBUFFER_EXT, glfb);
-    glBindTexture(GetTextureType(), tex);
-    glTexImage2D(GetTextureType(), 0, GL_RGBA8,
+    glBindTexture(tmp->m_type, tex);
+    glTexImage2D(tmp->m_type, 0, tmp->m_internal_fmt,
                  (GLint) size.width(), (GLint) size.height(), 0,
-                 GL_RGB, GL_UNSIGNED_BYTE, NULL);
+                 tmp->m_data_fmt, tmp->m_data_type, NULL);
     gMythGLFramebufferTexture2DEXT(
         GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
-        GetTextureType(), tex, 0);
+        tmp->m_type, tex, 0);
 
     GLenum status;
     status = gMythGLCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
@@ -735,9 +976,6 @@
     glDisable(GL_DEPTH_TEST);
     glDepthMask(GL_FALSE);
     glDisable(GL_CULL_FACE);
-
-    EnableTextures();;
-
     glShadeModel(GL_FLAT);
     glDisable(GL_POLYGON_SMOOTH);
     glDisable(GL_LINE_SMOOTH);
@@ -768,54 +1006,17 @@
     MakeCurrent(false);
 }
 
-void OpenGLContext::UpdatePBO(uint tex, uint pbo,
-                             const VideoFrame *frame,
-                             const unsigned char *alpha)
+uint OpenGLContext::CreatePBO(uint tex)
 {
-    MakeCurrent(true);
-
-    void *pboMemory;
-    uint tex_size = frame->width * frame->height * 4;
+    if (!m_priv->m_textures.count(tex))
+        return 0;
 
-    glBindTexture(GetTextureType(), tex);
-    gMythGLBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
-    gMythGLBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB,
-                         tex_size, NULL, GL_STREAM_DRAW);
-
-    pboMemory = gMythGLMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB,
-                                    GL_WRITE_ONLY);
-
-    if (frame->interlaced_frame)
-    {
-        pack_yv12interlaced(frame->buf, (unsigned char *)pboMemory,
-                            frame->offsets, frame->pitches,
-                            QSize(frame->width, frame->height));
-    }
-    else
-    {
-        pack_yv12alpha(frame->buf, (unsigned char *)pboMemory,
-                       frame->offsets, frame->pitches,
-                       QSize(frame->width, frame->height), alpha);
-    }
-
-    gMythGLUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB);
-
-    glTexSubImage2D(GetTextureType(), 0, 0, 0, frame->width, frame->height,
-                    GL_BGRA, GL_UNSIGNED_BYTE, 0);
-
-    gMythGLBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
-
-    MakeCurrent(false);
-}
-
-
-uint OpenGLContext::CreatePBO(QSize size)
-{
-    MakeCurrent(true);
+    MythGLTexture *tmp = &m_priv->m_textures[tex];
 
     gMythGLBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
-    glTexImage2D(GetTextureType(), 0, GL_RGBA8, size.width(), size.height(),
-                 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
+    glTexImage2D(tmp->m_type, 0, tmp->m_internal_fmt,
+                 tmp->m_size.width(), tmp->m_size.height(), 0,
+                 tmp->m_data_fmt, tmp->m_data_type, NULL);
 
     GLuint tmp_pbo;
     gMythGLGenBuffersARB(1, &tmp_pbo);
@@ -824,49 +1025,9 @@
 
     Flush(true);
 
-    MakeCurrent(false);
-
-    if (tmp_pbo)
-        m_priv->m_pbos.push_back(tmp_pbo);
-
     return tmp_pbo;
 }
 
-void OpenGLContext::DeletePBO(uint pbo)
-{
-    MakeCurrent(true);
-
-    vector<GLuint>::iterator it;
-    for (it = m_priv->m_pbos.begin();
-         it != m_priv->m_pbos.end(); it++)
-    {
-        if (*(it) == pbo)
-        {
-            GLuint glpbo = pbo;
-            gMythGLDeleteBuffersARB(1, &glpbo);
-            m_priv->m_pbos.erase(it);
-            break;
-        }
-    }
-
-    Flush(true);
-
-    MakeCurrent(false);
-}
-
-void OpenGLContext::DeletePBOs(void)
-{
-    vector<GLuint>::iterator it;
-    for (it = m_priv->m_pbos.begin();
-         it != m_priv->m_pbos.end(); it++)
-    {
-        gMythGLDeleteBuffersARB(1, &(*(it)));
-    }
-    m_priv->m_pbos.clear();
-
-    Flush(true);
-}
-
 int OpenGLContext::SetPictureAttribute(
     PictureAttribute attribute, int newValue)
 {
diff -ur -X excl mythtv-vid-17/libs/libmythtv/openglcontext.h mythtv-vid-18/libs/libmythtv/openglcontext.h
--- mythtv-vid-17/libs/libmythtv/openglcontext.h	2008-07-03 15:20:46.000000000 +0800
+++ mythtv-vid-18/libs/libmythtv/openglcontext.h	2008-07-04 08:34:13.000000000 +0800
@@ -14,6 +14,22 @@
 #include "frame.h"
 #include "videooutbase.h"
 
+#ifndef GL_BGRA
+#define GL_BGRA                           0x80E1
+#endif
+#ifndef GL_UNSIGNED_BYTE
+#define GL_UNSIGNED_BYTE                  0x1401
+#endif
+#ifndef GL_RGBA8
+#define GL_RGBA8                          0x8058
+#endif
+#ifndef GL_LINEAR
+#define GL_LINEAR                         0x2601
+#endif
+#ifndef GL_CLAMP_TO_EDGE
+#define GL_CLAMP_TO_EDGE                  0x812F
+#endif
+
 class OpenGLVideo;
 class PrivateContext;
 
@@ -57,22 +73,32 @@
     void SwapBuffers(void);
     void Flush(bool use_fence);
 
-    uint GetMaxTexSize(void) const { return m_max_tex_size; }
     uint GetScreenNum(void)  const { return m_screen_num;   }
 
-    uint CreateTexture(void);
-    bool SetupTexture(const QSize &size, uint tex, int filt);
-    void SetupTextureFilters(uint tex, int filt);
+    void UpdateTexture(uint tex, const unsigned char *buf,
+                       const int *offsets,
+                       const int *pitches,
+                       VideoFrameType fmt,
+                       bool interlaced = FALSE,
+                       const unsigned char* alpha = NULL);
+    uint CreateTexture(QSize tot_size, QSize vid_size,
+                       bool use_pbo, uint type,
+                       uint data_type = GL_UNSIGNED_BYTE,
+                       uint data_fmt = GL_BGRA,
+                       uint internal_fmt = GL_RGBA8,
+                       uint filter = GL_LINEAR,
+                       uint wrap = GL_CLAMP_TO_EDGE);
+    void SetTextureFilters(uint tex, uint filt, uint wrap);
     void DeleteTexture(uint tex);
-    int  GetTextureType(void) const;
-    void EnableTextures(void);
+    void GetTextureType(uint &current, bool &rect);
+    void EnableTextures(uint type, uint tex_type = 0);
 
     bool CreateFragmentProgram(const QString &program, uint &prog);
     void DeleteFragmentProgram(uint prog);
     void BindFragmentProgram(uint fp);
     void InitFragmentParams(uint fp, float a, float b, float c, float d);
 
-    bool CreateFrameBuffer(uint &fb, uint tex, const QSize &size);
+    bool CreateFrameBuffer(uint &fb, uint tex);
     void DeleteFrameBuffer(uint fb);
     void BindFramebuffer(uint fb);
 
@@ -81,11 +107,6 @@
 
     static bool IsGLXSupported(Display *display, uint major, uint minor);
 
-    uint CreatePBO(QSize size);
-    void DeletePBO(uint pbo);
-    void UpdatePBO(uint tex, uint pbo,
-                   const VideoFrame *frame,
-                   const unsigned char *alpha = NULL);
     int SetPictureAttribute(PictureAttribute attributeType, int newValue);
     PictureAttributeSupported GetSupportedPictureAttributes(void) const;
     void SetColourParams(void);
@@ -98,10 +119,13 @@
             ((m_major_ver == major) && (m_minor_ver >= minor));
     }
 
+    uint CreatePBO(uint tex);
+
     void DeleteTextures(void);
     void DeletePrograms(void);
     void DeleteFrameBuffers(void);
-    void DeletePBOs(void);
+    uint GetBufferSize(QSize size, uint fmt, uint type);
+    bool ClearTexture(uint tex);
 
     PrivateContext *m_priv;
 
@@ -138,31 +162,32 @@
     void SwapBuffers(void) { }
     void Flush(bool) { }
 
-    uint GetMaxTexSize(void) const { return 0; }
     uint GetScreenNum(void)  const { return 0; }
 
-    uint CreateTexture(void) { return 0; }
-    bool SetupTexture(const QSize&, uint, int) { return false; }
-    void SetupTextureFilters(uint, int) { }
+    void UpdateTexture(uint, const unsigned char*,
+                       const int *, const int *,
+                       VideoFrameType, bool = FALSE,
+                       const unsigned char* = NULL) { }
+    uint CreateTexture(QSize, QSize, bool, uint,
+                       uint = 0, uint = 0, uint = 0,
+                       uint = 0, uint = 0) { return 0; }
+    void SetTextureFilters(uint, uint, uint) { }
     void DeleteTexture(uint) { }
-    int  GetTextureType(void) const { return 0; }
-    void EnableTextures(void) { }
+    void GetTextureType(uint&, bool&) { }
+    void EnableTextures(uint, uint = 0) { }
 
     bool CreateFragmentProgram(const QString&, uint&) { return false; }
     void DeleteFragmentProgram(uint) { }
     void BindFragmentProgram(uint) { }
     void InitFragmentParams(uint, float, float, float, float) { }
 
-    bool CreateFrameBuffer(uint&, uint, const QSize&) { return false; }
+    bool CreateFrameBuffer(uint&, uint) { return false; }
     void DeleteFrameBuffer(uint);
     void BindFramebuffer(uint);
 
     bool IsFeatureSupported(GLFeatures) const { return false; }
     static bool IsGLXSupported(Display*, uint, uint) { return false; }
 
-    uint CreatePBO(QSize);
-    void DeletePBO(uint);
-    void UpdatePBO(uint, uint, const VideoFrame*, const unsigned char*);
     int SetPictureAttribute(PictureAttribute, int) { return -1; }
     PictureAttributeSupported GetSupportedPictureAttributes(void) const
         { return kPictureAttributeSupported_None; }
diff -ur -X excl mythtv-vid-17/libs/libmythtv/openglvideo.cpp mythtv-vid-18/libs/libmythtv/openglvideo.cpp
--- mythtv-vid-17/libs/libmythtv/openglvideo.cpp	2008-07-03 21:59:08.000000000 +0800
+++ mythtv-vid-18/libs/libmythtv/openglvideo.cpp	2008-07-04 08:38:54.000000000 +0800
@@ -43,8 +43,8 @@
     hardwareDeinterlacing(false),
     useColourControl(false),  viewportControl(false),
     inputTextureSize(0,0),    currentFrameNum(0),
-    inputUpdated(false),
-    fastTexStreaming(false),  pixelBufferObject(0),
+    inputUpdated(false),      
+    textureRects(false),      textureType(GL_TEXTURE_2D),
     convertSize(0,0),         convertBuf(NULL),
 
     videoResize(false),       videoResizeRect(0,0,0,0),
@@ -63,10 +63,6 @@
 {
     ShutDownYUV2RGB();
 
-    if (pixelBufferObject)
-        gl_context->DeletePBO(pixelBufferObject);
-    pixelBufferObject = 0;
-
     for (uint i = 0; i < inputTextures.size(); i++)
         gl_context->DeleteTexture(inputTextures[i]);
     inputTextures.clear();
@@ -103,10 +99,7 @@
     display_video_rect    = displayVideoRect;
     video_rect            = videoRect;
     masterViewportSize    = QSize(1920, 1080);
-
-    QSize rect            = GetTextureSize(video_dim);
-
-    frameBufferRect       = QRect(QPoint(0,0), rect);
+    frameBufferRect       = QRect(QPoint(0,0), video_dim);
     softwareDeinterlacer  = "";
     hardwareDeinterlacing = false;
     useColourControl      = colour_control;
@@ -119,90 +112,40 @@
     inputUpdated          = false;
     gl_letterbox_colour   = letterbox_colour;
 
+    gl_context->GetTextureType(textureType, textureRects);
+
     SetViewPort(display_visible_rect.size());
 
-    fastTexStreaming = gl_context->IsFeatureSupported(kGLExtPBufObj);
+    bool use_pbo = gl_context->IsFeatureSupported(kGLExtPBufObj);
 
     if (osd)
     {
         QSize osdsize = display_visible_rect.size();
-        if (fastTexStreaming)
-        {
-            GLuint tex = CreateVideoTexture(osdsize, inputTextureSize);
-            pixelBufferObject = gl_context->CreatePBO(osdsize);
+        GLuint tex = CreateVideoTexture(osdsize, inputTextureSize, use_pbo);
 
-            if (tex && pixelBufferObject &&
-                AddFilter(kGLFilterYUV2RGBA) &&
-                AddFilter(kGLFilterResize))
-            {
-                inputTextures.push_back(tex);
-            }
-            else
-            {
-                Teardown();
-                fastTexStreaming = false;
-            }
+        if (tex &&
+            AddFilter(kGLFilterYUV2RGBA) &&
+            AddFilter(kGLFilterResize))
+        {
+            inputTextures.push_back(tex);
         }
-        
-        if (!fastTexStreaming)
-        {   
-            QSize half_size(osdsize.width() >> 1, osdsize.height() >>1);
-            GLuint alphatex = CreateVideoTexture(osdsize, inputTextureSize);
-            GLuint utex = CreateVideoTexture(half_size, inputTextureSize);
-            GLuint vtex = CreateVideoTexture(half_size, inputTextureSize);
-            GLuint ytex = CreateVideoTexture(osdsize, inputTextureSize);
-
-            if ((alphatex && ytex && utex && vtex) &&
-                 AddFilter(kGLFilterYUV2RGBA) &&
-                 AddFilter(kGLFilterResize))
-            {
-                inputTextures.push_back(ytex);
-                inputTextures.push_back(utex);
-                inputTextures.push_back(vtex);
-                inputTextures.push_back(alphatex);
-            }
-            else
-            {
-                Teardown();
-            }
+        else
+        {
+            Teardown();
         }
     }
     else
     {
-        if (fastTexStreaming)
+        GLuint tex = CreateVideoTexture(actual_video_dim,
+                                        inputTextureSize, use_pbo);
+
+        if (tex && AddFilter(kGLFilterYUV2RGB))
         {
-            GLuint tex = CreateVideoTexture(actual_video_dim, inputTextureSize);
-            pixelBufferObject = gl_context->CreatePBO(actual_video_dim);
- 
-            if (tex && pixelBufferObject &&
-                AddFilter(kGLFilterYUV2RGB))
-            {
-                inputTextures.push_back(tex);
-            }
-            else
-            {
-                Teardown();
-                fastTexStreaming = false;
-            }
+            inputTextures.push_back(tex);
         }
-
-        if (!fastTexStreaming)
+        else
         {
-            QSize half_size(actual_video_dim.width() >> 1, actual_video_dim.height() >>1);
-            GLuint utex = CreateVideoTexture(half_size, inputTextureSize);
-            GLuint vtex = CreateVideoTexture(half_size, inputTextureSize);
-            GLuint ytex = CreateVideoTexture(actual_video_dim, inputTextureSize);
-
-            if ((ytex && utex && vtex) && AddFilter(kGLFilterYUV2RGB))
-            {
-                inputTextures.push_back(ytex);
-                inputTextures.push_back(utex);
-                inputTextures.push_back(vtex);
-            }
-            else
-            {
-                Teardown();
-            }
+            Teardown();
         }
     }
 
@@ -219,12 +162,12 @@
                 "Falling back to software conversion.\n\t\t\t"
                 "Any opengl filters will also be disabled.");
 
-        GLuint rgb24tex = CreateVideoTexture(actual_video_dim,
-                                             inputTextureSize);
+        GLuint bgra32tex = CreateVideoTexture(actual_video_dim,
+                                             inputTextureSize, use_pbo);
 
-        if (rgb24tex && AddFilter(kGLFilterResize))
+        if (bgra32tex && AddFilter(kGLFilterResize))
         {
-            inputTextures.push_back(rgb24tex);
+            inputTextures.push_back(bgra32tex);
         }
         else
         {
@@ -234,8 +177,15 @@
         }
     }
 
-    if (fastTexStreaming)
-        VERBOSE(VB_PLAYBACK, LOC + "Using PBO accelerated texture uploading.");
+#ifdef MMX
+    bool mmx = true;
+#else
+    bool mmx = false;
+#endif
+
+    VERBOSE(VB_PLAYBACK, LOC + 
+            QString("Using packed textures with%1 mmx and with%2 PBOs")
+            .arg(mmx ? "" : "out").arg(use_pbo ? "" : "out"));
 
     return true;
 }
@@ -298,7 +248,7 @@
                 QSize fb_size = GetTextureSize(video_dim);
                 for (int i = 0; i < buffers_diff; i++)
                 {
-                    if (!AddFrameBuffer(tmp_buf, tmp_tex, fb_size))
+                    if (!AddFrameBuffer(tmp_buf, fb_size, tmp_tex, video_dim))
                         return false;
                     else
                     {
@@ -359,15 +309,16 @@
 
     if (filters.size() == 1)
     {
-        SetTextureFilters(&inputTextures, GL_LINEAR);
+        SetTextureFilters(&inputTextures, GL_LINEAR, GL_CLAMP_TO_EDGE);
         return;
     }
 
-    SetTextureFilters(&inputTextures, GL_NEAREST);
+    SetTextureFilters(&inputTextures, GL_NEAREST, GL_CLAMP_TO_EDGE);
     vector<GLuint> textures;
     glfilt_map_t::iterator it;
     for (it = filters.begin(); it != filters.end(); it++)
-        SetTextureFilters(&(it->second->frameBufferTextures), GL_NEAREST);
+        SetTextureFilters(&(it->second->frameBufferTextures),
+                          GL_NEAREST, GL_CLAMP_TO_EDGE);
 
     // resize or last active (ie don't need resize) need GL_LINEAR
     glfilt_map_t::reverse_iterator rit;
@@ -377,7 +328,8 @@
     {
         if (next && (rit->second->outputBuffer != kNoBuffer))
         {
-            SetTextureFilters(&(rit->second->frameBufferTextures), GL_LINEAR);
+            SetTextureFilters(&(rit->second->frameBufferTextures),
+                              GL_LINEAR, GL_CLAMP_TO_EDGE);
             return;
         }
 
@@ -388,7 +340,7 @@
         }
     }
 
-    SetTextureFilters(&inputTextures, GL_LINEAR);
+    SetTextureFilters(&inputTextures, GL_LINEAR, GL_CLAMP_TO_EDGE);
 }
 
 // locking ok
@@ -410,17 +362,12 @@
     {
         temp->numInputs = 2;
     }
-    else if ((filter == kGLFilterYUV2RGB && !fastTexStreaming) ||
-             (filter == kGLFilterOneFieldDeintDFR) ||
+    else if ((filter == kGLFilterOneFieldDeintDFR) ||
              (filter == kGLFilterKernelDeintDFR) ||
              (filter == kGLFilterLinearBlendDeintDFR))
     {
         temp->numInputs = 3;
     }
-    else if ((filter == kGLFilterYUV2RGBA) && !fastTexStreaming)
-    {
-        temp->numInputs = 4;
-    }
 
     GLuint program = 0;
     if (filter != kGLFilterNone && filter != kGLFilterResize)
@@ -500,7 +447,7 @@
     }
 
     QString program = GetProgramString(name);
-    QString texType = (gl_context->IsFeatureSupported(kGLExtRect)) ? "RECT" : "2D";
+    QString texType = (textureRects) ? "RECT" : "2D";
     program.replace("%1", texType);
 
     uint ret;
@@ -516,8 +463,8 @@
 }
 
 // locking ok
-bool OpenGLVideo::AddFrameBuffer(uint &framebuffer,
-                                 uint &texture, QSize size)
+bool OpenGLVideo::AddFrameBuffer(uint &framebuffer, QSize fb_size,
+                                 uint &texture, QSize vid_size)
 {
     if (!gl_context->IsFeatureSupported(kGLExtFBufObj))
     {
@@ -525,9 +472,9 @@
         return false;
     }
 
-    texture = gl_context->CreateTexture();
+    texture = gl_context->CreateTexture(fb_size, vid_size, false, textureType);
 
-    bool ok = gl_context->CreateFrameBuffer(framebuffer, texture, size);
+    bool ok = gl_context->CreateFrameBuffer(framebuffer, texture);
 
     if (!ok)
         gl_context->DeleteTexture(texture);
@@ -552,24 +499,22 @@
 }
 
 // locking ok
-uint OpenGLVideo::CreateVideoTexture(QSize size, QSize &tex_size)
+uint OpenGLVideo::CreateVideoTexture(QSize size, QSize &tex_size,
+                                     bool use_pbo)
 {
-    uint tmp_tex = gl_context->CreateTexture();
-
     QSize temp = GetTextureSize(size);
+    uint tmp_tex = gl_context->CreateTexture(temp, size, use_pbo,
+                                             textureType);
 
-    if ((temp.width()  > (int)gl_context->GetMaxTexSize()) ||
-        (temp.height() > (int)gl_context->GetMaxTexSize()) ||
-        !gl_context->SetupTexture(temp, tmp_tex, GL_LINEAR))
+    if (!tmp_tex)
     {
         VERBOSE(VB_PLAYBACK, LOC_ERR + "Could not create texture.");
-        gl_context->DeleteTexture(tmp_tex);
         return 0;
     }
 
     tex_size = temp;
 
-    VERBOSE(VB_PLAYBACK, LOC + QString("Created main input texture %1x%2")
+    VERBOSE(VB_PLAYBACK, LOC + QString("Created texture (%1x%2)")
             .arg(temp.width()).arg(temp.height()));
 
     return tmp_tex;
@@ -578,7 +523,7 @@
 // locking ok
 QSize OpenGLVideo::GetTextureSize(const QSize &size)
 {
-    if (gl_context->IsFeatureSupported(kGLExtRect))
+    if (textureRects)
         return size;
 
     int w = 64;
@@ -613,15 +558,10 @@
 
     if (filters.count(kGLFilterYUV2RGB) && (frame->codec == FMT_YV12))
     {
-        if (fastTexStreaming && pixelBufferObject)
-        {
-            gl_context->UpdatePBO(inputTextures[0], pixelBufferObject,
-                                  frame);
-            inputUpdated = true;
-            return;
-        }
-
-        UpdateInput(frame->buf, frame->offsets, FMT_YV12, actual_video_dim);
+        gl_context->UpdateTexture(inputTextures[0], frame->buf,
+                                  frame->offsets, frame->pitches, FMT_YV12,
+                                  frame->interlaced_frame);
+        inputUpdated = true;
         return;
     }
 
@@ -634,24 +574,27 @@
 
         convertSize = actual_video_dim;
         convertBuf = new unsigned char[
-            (actual_video_dim.width() * actual_video_dim.height() * 3) + 128];
+            (actual_video_dim.width() * actual_video_dim.height() * 4) + 128];
     }
 
     if (convertBuf)
     {
         AVPicture img_in, img_out;
 
-        avpicture_fill(&img_out, (uint8_t *)convertBuf, PIX_FMT_RGB24,
+        avpicture_fill(&img_out, (uint8_t *)convertBuf, PIX_FMT_BGRA,
                        convertSize.width(), convertSize.height());
         avpicture_fill(&img_in, (uint8_t *)frame->buf, PIX_FMT_YUV420P,
                        convertSize.width(), convertSize.height());
-        img_convert(&img_out, PIX_FMT_RGB24,
+        img_convert(&img_out, PIX_FMT_BGRA,
                     &img_in,  PIX_FMT_YUV420P,
                     convertSize.width(), convertSize.height());
 
         int offset = 0;
-        UpdateInput(convertBuf, &offset, FMT_RGB24, convertSize);
+        gl_context->UpdateTexture(inputTextures[0], convertBuf,
+                                  &offset, &offset, FMT_BGRA);
     }
+
+    inputUpdated = true;
 }
 
 // locking ok
@@ -661,53 +604,16 @@
 {
     OpenGLContextLocker ctx_lock(gl_context);
 
-    inputUpdated = false;
-
-    if (fastTexStreaming && pixelBufferObject &&
-        FMT_YV12 == format && alpha)
-    {
-        VideoFrame frame;
-        frame.interlaced_frame = false;
-        frame.codec = FMT_YV12;
-        frame.buf = (unsigned char *)buf;
-        frame.width = size.width();
-        frame.height = size.height();
-        frame.offsets[0] = offsets[0];
-        frame.offsets[1] = offsets[1];
-        frame.offsets[2] = offsets[2];
-        frame.pitches[0] = size.width();
-        frame.pitches[1] = size.width() >> 1;
-        frame.pitches[2] = size.width() >> 1;
-        gl_context->UpdatePBO(inputTextures[0], pixelBufferObject,
-                              &frame, alpha);
-
-        inputUpdated = true;
+    if (size.width()  != actual_video_dim.width()  ||
+        size.height() != actual_video_dim.height() ||
+        format != FMT_YV12 || !alpha)
         return;
-    }
 
-    copy_pixels_to_texture(
-        buf + offsets[0], format, size,
-        inputTextures[0], gl_context->GetTextureType());
-
-    if (FMT_YV12 == format)
-    {
-        QSize chroma_size(size.width() >> 1, size.height() >> 1);
-        copy_pixels_to_texture(
-            buf + offsets[1], format, chroma_size,
-            inputTextures[1],
-            gl_context->GetTextureType());
-        copy_pixels_to_texture(
-            buf + offsets[2], format, chroma_size,
-            inputTextures[2],
-            gl_context->GetTextureType());
-        if (alpha)
-        {
-            copy_pixels_to_texture(
-                alpha, FMT_ALPHA, size,
-                inputTextures[3],
-                gl_context->GetTextureType());
-        }
-    }
+    int pitches[3] = {size.width(), size.width() >> 1, size.width() >> 1};
+
+    gl_context->UpdateTexture(inputTextures[0], buf,
+                              offsets, pitches, FMT_YV12,
+                              false, alpha);
 
     inputUpdated = true;
 }
@@ -828,8 +734,12 @@
 
     OpenGLContextLocker ctx_lock(gl_context);
 
+    // enable correct texture type
+    gl_context->EnableTextures(inputTextures[0]);
+
     vector<GLuint> inputs = inputTextures;
     QSize inputsize = inputTextureSize;
+    QSize realsize  = GetTextureSize(video_dim);
 
     glfilt_map_t::iterator it;
     for (it = filters.begin(); it != filters.end(); it++)
@@ -852,7 +762,7 @@
         if (!inputUpdated && type == kGLFilterYUV2RGBA)
         {
             inputs = filter->frameBufferTextures;
-            inputsize = video_dim;
+            inputsize = realsize;
             continue;
         }
 
@@ -862,7 +772,7 @@
             (!(softwareDeinterlacing && softwareDeinterlacer == "bobdeint")))
         {
             inputs = filter->frameBufferTextures;
-            inputsize = video_dim;
+            inputsize = realsize;
             continue;
         }
 
@@ -882,7 +792,7 @@
             t_bottom = (float)video_rect.height() + t_top;
         }
 
-        if (!gl_context->IsFeatureSupported(kGLExtRect) &&
+        if (!textureRects &&
             (inputsize.width() > 0) && (inputsize.height() > 0))
         {
             t_right  /= inputsize.width();
@@ -930,19 +840,6 @@
             }
         }
 
-        float t_right_uv = t_right;
-        float t_top_uv   = t_top;
-        float t_bottom_uv = t_bottom;
-        float t_left_uv  = t_left;
-
-        if (gl_context->IsFeatureSupported(kGLExtRect))
-        {
-            t_right_uv  /= 2;
-            t_top_uv    /= 2;
-            t_bottom_uv /= 2;
-            t_left_uv   /= 2;
-        }
-
         // vertex coordinates
         QRect display = (filter->frameBuffers.empty() ||  
                          filter->outputBuffer == kDefaultBuffer) ? 
@@ -1013,7 +910,7 @@
         for (uint i = 0; i < inputs.size(); i++)
         {
             glActiveTexture(GL_TEXTURE0 + i);
-            glBindTexture(gl_context->GetTextureType(), inputs[i]);
+            glBindTexture(textureType, inputs[i]);
         }
 
         // enable fragment program and set any environment variables
@@ -1057,51 +954,17 @@
             glEnable(GL_BLEND);
 
         // draw quad
-
-        bool multi = ((type == kGLFilterYUV2RGB ||
-                        type == kGLFilterYUV2RGBA) &&
-                        !fastTexStreaming);
-        bool multi_alpha = multi && (type == kGLFilterYUV2RGBA);
-
         glBegin(GL_QUADS);
         glTexCoord2f(t_left, t_top);
-        if (multi)
-        {
-            glMultiTexCoord2f(GL_TEXTURE1, t_left_uv, t_top_uv);
-            glMultiTexCoord2f(GL_TEXTURE2, t_left_uv, t_top_uv);
-            if (multi_alpha)
-                glMultiTexCoord2f(GL_TEXTURE3, t_left_uv, t_top_uv);
-        }
         glVertex2f(vleft,  vtop);
 
         glTexCoord2f(t_right, t_top);
-        if (multi)
-        {
-            glMultiTexCoord2f(GL_TEXTURE1, t_right_uv, t_top_uv);
-            glMultiTexCoord2f(GL_TEXTURE2, t_right_uv, t_top_uv);
-            if (multi_alpha)
-                glMultiTexCoord2f(GL_TEXTURE3, t_right, t_top);
-        }
         glVertex2f(vright, vtop);
 
         glTexCoord2f(t_right, t_bottom);
-        if (multi)
-        {
-            glMultiTexCoord2f(GL_TEXTURE1, t_right_uv, t_bottom_uv);
-            glMultiTexCoord2f(GL_TEXTURE2, t_right_uv, t_bottom_uv);
-            if (multi_alpha)
-                glMultiTexCoord2f(GL_TEXTURE3, t_right, t_bottom);
-        }
         glVertex2f(vright, vbot);
 
         glTexCoord2f(t_left, t_bottom);
-        if (type == kGLFilterYUV2RGB || type == kGLFilterYUV2RGBA)
-        {
-            glMultiTexCoord2f(GL_TEXTURE1, t_left_uv, t_bottom_uv);
-            glMultiTexCoord2f(GL_TEXTURE2, t_left_uv, t_bottom_uv);
-            if (type == kGLFilterYUV2RGBA)
-                glMultiTexCoord2f(GL_TEXTURE3, t_left_uv, t_bottom);
-        }
         glVertex2f(vleft,  vbot);
         glEnd();
 
@@ -1140,7 +1003,7 @@
             gl_context->BindFramebuffer(0);
 
         inputs = filter->frameBufferTextures;
-        inputsize = video_dim;
+        inputsize = realsize;
     }
 
     currentFrameNum = frame;
@@ -1160,13 +1023,14 @@
 }
 
 // locking ok
-void OpenGLVideo::SetTextureFilters(vector<GLuint> *textures, int filt)
+void OpenGLVideo::SetTextureFilters(vector<GLuint> *textures,
+                                    int filt, int wrap)
 {
     if (textures->empty())
         return;
 
     for (uint i = 0; i < textures->size(); i++)
-        gl_context->SetupTextureFilters((*textures)[i], filt);
+        gl_context->SetTextureFilters((*textures)[i], filt, wrap);
 }
 
 // locking ok
@@ -1234,41 +1098,11 @@
     return "";
 }
 
-static const QString init_norm =
-"ATTRIB ytex  = fragment.texcoord[0];"
-"ATTRIB uvtex = fragment.texcoord[1];"
-"TEMP res, tmp;";
-
-static const QString init_alpha =
-"TEMP alpha;"
-"TEX alpha, ytex, texture[3], %1;";
-
-static const QString tex_sample =
-"TEX res,   ytex,  texture[0], %1;"
-"TEX tmp.x, uvtex, texture[1], %1;"
-"TEX tmp.y, uvtex, texture[2], %1;";
-
-static const QString colour_control =
-"PARAM  adj  = program.env[0];"
-"SUB res, res, 0.5;"
-"MAD res, res, adj.yyyy, adj.xxxx;"
-"SUB tmp, tmp, { 0.5, 0.5 };"
-"MAD tmp, adj.zzzz, tmp, 0.5;";
-
 static const QString colour_control_fast =
 "PARAM  adj  = program.env[0];"
 "SUB res, res, 0.5;"
 "MAD res, res, adj.zzzy, adj.wwwx;";
 
-static const QString end_norm =
-"MAD res, res, 1.164, -0.063;"
-"SUB tmp, tmp, { 0.5, 0.5 };"
-"MAD res, { 0, -.392, 2.017 }, tmp.xxxw, res;"
-"MAD result.color, { 1.596, -.813, 0, 0 }, tmp.yyyw, res;";
-
-static const QString end_alpha =
-"MOV result.color.a, alpha.a;";
-
 static const QString init_fast = 
 "ATTRIB tex  = fragment.texcoord[0];"
 "TEMP tmp, res;"
@@ -1299,37 +1133,17 @@
     switch (name)
     {
         case kGLFilterYUV2RGB:
-            if (fastTexStreaming)
-            {
-                ret += init_fast;
-                if (useColourControl)
-                    ret += colour_control_fast;
-                ret += end_fast;
-            }
-            else
-            {
-                ret = ret + init_norm + tex_sample;
-                if (useColourControl)
-                    ret += colour_control;
-                ret += end_norm;
-            }
+            ret += init_fast;
+            if (useColourControl)
+                ret += colour_control_fast;
+            ret += end_fast;
             break;
 
         case kGLFilterYUV2RGBA:
-            if (fastTexStreaming)
-            {
-                ret += init_fast + init_fast_alpha;
-                if (useColourControl)
-                    ret += colour_control_fast;
-                ret += end_fast_alpha;
-            }
-            else
-            {
-                ret = ret + init_norm + init_alpha + tex_sample;
-                if (useColourControl)
-                    ret += colour_control;
-                ret = ret + end_norm + end_alpha;
-            }
+            ret += init_fast + init_fast_alpha;
+            if (useColourControl)
+                ret += colour_control_fast;
+            ret += end_fast_alpha;
             break;
 
         case kGLFilterKernelDeint:
diff -ur -X excl mythtv-vid-17/libs/libmythtv/openglvideo.h mythtv-vid-18/libs/libmythtv/openglvideo.h
--- mythtv-vid-17/libs/libmythtv/openglvideo.h	2008-07-03 15:20:46.000000000 +0800
+++ mythtv-vid-18/libs/libmythtv/openglvideo.h	2008-07-04 08:34:13.000000000 +0800
@@ -64,7 +64,7 @@
     void UpdateInputFrame(const VideoFrame *frame);
     void UpdateInput(const unsigned char *buf, const int *offsets,
                      int format, QSize size,
-                     const unsigned char *alpha = NULL);
+                     const unsigned char *alpha);
 
     bool AddFilter(const QString &filter)
          { return AddFilter(StringToFilter(filter)); }
@@ -96,9 +96,11 @@
     bool RemoveFilter(OpenGLFilterType filter);
     bool OptimiseFilters(void);
     OpenGLFilterType GetDeintFilter(void) const;
-    bool AddFrameBuffer(uint &framebuffer, uint &texture, QSize size);
+    bool AddFrameBuffer(uint &framebuffer, QSize fb_size,
+                        uint &texture, QSize vid_size);
     uint AddFragmentProgram(OpenGLFilterType name);
-    uint CreateVideoTexture(QSize size, QSize &tex_size);
+    uint CreateVideoTexture(QSize size, QSize &tex_size,
+                            bool use_pbo = false);
     QString GetProgramString(OpenGLFilterType filter);
     void CalculateResize(float &left,  float &top,
                          float &right, float &bottom);
@@ -109,7 +111,7 @@
     void SetFiltering(void);
 
     void Rotate(vector<uint> *target);
-    void SetTextureFilters(vector<uint> *textures, int filt);
+    void SetTextureFilters(vector<uint> *textures, int filt, int wrap);
 
     OpenGLContext *gl_context;
     QSize          video_dim;
@@ -129,8 +131,8 @@
     glfilt_map_t   filters;
     long long      currentFrameNum;
     bool           inputUpdated;
-    bool           fastTexStreaming;
-    uint           pixelBufferObject;
+    bool           textureRects;
+    uint           textureType;
 
     QSize            convertSize;
     unsigned char   *convertBuf;
@@ -155,7 +157,8 @@
                 { (void) osd; return false; }
 
     void UpdateInputFrame(const VideoFrame*) { }
-    void UpdateInput(const unsigned char*, const int*, int, QSize, unsigned char* = NULL) { }
+    void UpdateInput(const unsigned char*, const int*,
+                     int, QSize, unsigned char* = NULL) { }
 
     bool AddFilter(const QString&) { return false; }
     bool RemoveFilter(const QString&) { return false; }
diff -ur -X excl mythtv-vid-17/libs/libmythtv/util-opengl.cpp mythtv-vid-18/libs/libmythtv/util-opengl.cpp
--- mythtv-vid-17/libs/libmythtv/util-opengl.cpp	2008-07-03 21:59:08.000000000 +0800
+++ mythtv-vid-18/libs/libmythtv/util-opengl.cpp	2008-07-04 08:34:13.000000000 +0800
@@ -306,41 +306,6 @@
     return glx_window;
 }                       
 
-void copy_pixels_to_texture(const unsigned char *buf,
-                            int                  buffer_format,
-                            const QSize         &buffer_size,
-                            int                  texture,
-                            int                  texture_type)
-{
-    glBindTexture(texture_type, texture);
-
-    uint format;
-    switch (buffer_format)
-    {
-        case FMT_YV12:
-            format = GL_LUMINANCE;
-            break;
-        case FMT_RGB24:
-            format = GL_RGB;
-            break;
-        case FMT_RGBA32:
-            format = GL_RGBA;
-            break;
-        case FMT_ALPHA:
-            format = GL_ALPHA;
-            break;
-        default:
-            return;
-    }
-
-    glTexSubImage2D(
-        texture_type,
-        0, 0, 0,
-        buffer_size.width(), buffer_size.height(),
-        format, GL_UNSIGNED_BYTE,
-        buf);
-}
-
 __GLXextFuncPtr get_gl_proc_address(const QString &procName)
 {
     __GLXextFuncPtr ret = NULL;
diff -ur -X excl mythtv-vid-17/libs/libmythtv/util-opengl.h mythtv-vid-18/libs/libmythtv/util-opengl.h
--- mythtv-vid-17/libs/libmythtv/util-opengl.h	2008-07-03 21:59:08.000000000 +0800
+++ mythtv-vid-18/libs/libmythtv/util-opengl.h	2008-07-04 08:34:13.000000000 +0800
@@ -115,12 +115,6 @@
                          GLXPbuffer   glx_pbuffer,
                          const QSize &window_size);
 
-void copy_pixels_to_texture(const unsigned char *buf,
-                            int          buffer_format,
-                            const QSize &buffer_size,
-                            int          texture,
-                            int          texture_type);
-
 void pack_yv12alpha(const unsigned char *source,
                  const unsigned char *dest,
                  const int *offsets,
Binary files mythtv-vid-17/programs/mythbackend/mythbackend and mythtv-vid-18/programs/mythbackend/mythbackend differ
Binary files mythtv-vid-17/programs/mythcommflag/mythcommflag and mythtv-vid-18/programs/mythcommflag/mythcommflag differ
Binary files mythtv-vid-17/programs/mythfrontend/mythfrontend and mythtv-vid-18/programs/mythfrontend/mythfrontend differ
Binary files mythtv-vid-17/programs/mythtv/mythtv and mythtv-vid-18/programs/mythtv/mythtv differ

