Merge pull request #4314 from MartijnKaijser/beta1
[vuplus_xbmc] / xbmc / cores / dvdplayer / DVDCodecs / Video / DVDVideoCodec.cpp
1 /*
2  *      Copyright (C) 2010-2013 Team XBMC
3  *      http://xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "DVDVideoCodec.h"
22 #include "windowing/WindowingFactory.h"
23 #include "settings/Settings.h"
24
25 bool CDVDVideoCodec::IsSettingVisible(const std::string &condition, const std::string &value, const std::string &settingId)
26 {
27   if (settingId.empty() || value.empty())
28     return false;
29
30   // check if we are running on nvidia hardware
31   std::string gpuvendor = g_Windowing.GetRenderVendor();
32   std::transform(gpuvendor.begin(), gpuvendor.end(), gpuvendor.begin(), ::tolower);
33   bool isNvidia = (gpuvendor.compare(0, 6, "nvidia") == 0);
34   bool isIntel = (gpuvendor.compare(0, 5, "intel") == 0);
35
36   // nvidia does only need mpeg-4 setting
37   if (isNvidia) 
38   {
39     if (settingId == "videoplayer.usevdpaumpeg4")
40       return true;
41
42     return false; //will also hide intel settings on nvidia hardware
43   }
44   else if (isIntel) // intel needs vc1, mpeg-2 and mpeg4 setting
45   {
46     if (settingId == "videoplayer.usevaapimpeg4")
47       return true;
48     if (settingId == "videoplayer.usevaapivc1")
49       return true;
50     if (settingId == "videoplayer.usevaapimpeg2")
51       return true;
52
53     return false; //this will also hide nvidia settings on intel hardware
54   }
55   // if we don't know the hardware we are running on e.g. amd oss vdpau 
56   // or fglrx with xvba-driver we show everything
57   return true;
58 }
59
60 bool CDVDVideoCodec::IsCodecDisabled(DVDCodecAvailableType* map, unsigned int size, AVCodecID id)
61 {
62   int index = -1;
63   for (unsigned int i = 0; i < size; ++i)
64   {
65     if(map[i].codec == id)
66     {
67       index = (int) i;
68       break;
69     }
70   }
71   if(index > -1)
72     return (!CSettings::Get().GetBool(map[index].setting) || !CDVDVideoCodec::IsSettingVisible("unused", "unused", map[index].setting));
73
74   return false; //don't disable what we don't have
75 }