Ticket #1842: cn400-mythtv-vid-video.patch

File cn400-mythtv-vid-video.patch, 4.5 KB (added by teague@…, 13 years ago)

Updated patch to get VLD decoding working for the mythtv-vid branch

  • libs/libmythtv/videoout_xv.h

     
    170170
    171171    bool CreateXvMCBuffers(void);
    172172    bool CreateBuffers(VOSType subtype);
    173     vector<void*> CreateXvMCSurfaces(uint num, bool create_xvmc_blocks);
     173    vector<void*> CreateXvMCSurfaces(uint num, bool surface_has_vld);
    174174    vector<unsigned char*> CreateShmImages(uint num, bool use_xv);
    175175    void CreatePauseFrame(VOSType subtype);
    176176    void CopyFrame(VideoFrame *to, const VideoFrame *from);
  • libs/libmythtv/util-opengl.cpp

     
    6767{
    6868    int ret, errbase, eventbase, gl_major, gl_minor;
    6969
     70    // this crashes my Unichrome-based system if it is run more than once.
     71    static bool has_run = false;
     72    static int static_major = 0;
     73    static int static_minor = 0;
     74    static int static_ret = false;
     75
     76    if( has_run )
     77    {
     78        major = static_major;
     79        minor = static_minor;
     80        return static_ret;
     81    }
     82
    7083    major = minor = 0;
     84    has_run = true;
    7185
    7286    X11S(ret = glXQueryExtension(XJ_disp, &errbase, &eventbase));
    7387    if (!ret)
     
    86100    if (!ret)
    87101        return false;
    88102
    89     major = gl_major;
    90     minor = gl_minor;
     103    static_major = major = gl_major;
     104    static_minor = minor = gl_minor;
     105    static_ret = true;
    91106
    92107    return true;
    93108}
  • libs/libmythtv/videoout_xv.cpp

     
    17851785    if (!xvmc_ctx)
    17861786        return false;
    17871787
    1788     bool createBlocks = !(XVMC_VLD == (xvmc_surf_info.mc_type & XVMC_VLD));
    1789     xvmc_surfs = CreateXvMCSurfaces(xvmc_buf_attr->GetMaxSurf(), createBlocks);
     1788    bool surface_has_vld = (XVMC_VLD == (xvmc_surf_info.mc_type & XVMC_VLD));
     1789    xvmc_surfs = CreateXvMCSurfaces(xvmc_buf_attr->GetMaxSurf(),
     1790                                    surface_has_vld);
     1791
    17901792    if (xvmc_surfs.size() < xvmc_buf_attr->GetMinSurf())
    17911793    {
    17921794        VERBOSE(VB_IMPORTANT, LOC_ERR + "Unable to create XvMC Surfaces");
     
    18251827#endif // USING_XVMC
    18261828}
    18271829
    1828 vector<void*> VideoOutputXv::CreateXvMCSurfaces(uint num, bool create_xvmc_blocks)
     1830vector<void*> VideoOutputXv::CreateXvMCSurfaces(uint num, bool surface_has_vld)
    18291831{
    18301832    (void)num;
    1831     (void)create_xvmc_blocks;
     1833    (void)surface_has_vld;
    18321834
    18331835    vector<void*> surfaces;
    18341836#ifdef USING_XVMC
     
    18371839                            ((video_dim.height() + 15) / 16));
    18381840    uint num_data_blocks = num_mv_blocks * blocks_per_macroblock;
    18391841
     1842    // need the equivalent of 5 extra surfaces for VLD decoding
     1843    if( surface_has_vld )
     1844        num += 5;
     1845
    18401846    // create needed XvMC stuff
    18411847    bool ok = true;
    18421848    for (uint i = 0; i < num; i++)
     
    18491855        int ret = XvMCCreateSurface(XJ_disp, xvmc_ctx, &(surf->surface));
    18501856        ok &= (Success == ret);
    18511857
    1852         if (create_xvmc_blocks && ok)
     1858        if (ok && !surface_has_vld)
    18531859        {
    18541860            ret = XvMCCreateBlocks(XJ_disp, xvmc_ctx, num_data_blocks,
    18551861                                   &(surf->blocks));
     
    18601866            }
    18611867        }
    18621868
    1863         if (create_xvmc_blocks && ok)
     1869        if (ok && !surface_has_vld)
    18641870        {
    18651871            ret = XvMCCreateMacroBlocks(XJ_disp, xvmc_ctx, num_mv_blocks,
    18661872                                        &(surf->macro_blocks));
     
    18811887        }
    18821888        surfaces.push_back(surf);
    18831889    }
     1890
     1891    // for VLD decoding: the last 5 surface were allocated just to make
     1892    // sure we had enough space.  now, deallocate/destroy them.
     1893   
     1894    if( surface_has_vld )
     1895    {
     1896        VERBOSE(VB_PLAYBACK, LOC + QString("VLD - Allocated %1 surfaces, now destroying 5 of them.").arg(surfaces.size()));
     1897
     1898        for( uint i = 0; i < 5; i++ )
     1899        {
     1900            xvmc_vo_surf_t *surf = (xvmc_vo_surf_t*)surfaces.back();
     1901            surfaces.pop_back();
     1902            XvMCDestroySurface(XJ_disp, &(surf->surface));
     1903            delete surf;
     1904        }
     1905    }
    18841906#endif // USING_XVMC
    18851907    return surfaces;
    18861908}
     
    41444166    SetFromEnv(vld, idct, mc, xv, shm, opengl);
    41454167    SetFromHW(XJ_disp, mc, xv, shm, xvmc_opengl, opengl);
    41464168
    4147     vld  &= mc;
    41484169    idct &= mc;
    41494170
    41504171    QStringList list;