diff options
author | Martijn Kaijser <martijn@xbmc.org> | 2016-03-27 16:23:46 +0200 |
---|---|---|
committer | Martijn Kaijser <martijn@xbmc.org> | 2016-03-27 16:23:46 +0200 |
commit | 3ee62f7c021a9888b7054df39fb86259710118a3 (patch) | |
tree | 34035ee89e26255624f87e0aa5ea43eebe97d5ad | |
parent | 38e0839549f1a1aaef24ab9333477cc7726ceb45 (diff) | |
parent | 6a9e2bf65a346a43caff06efbf6051318d11aa8e (diff) |
Merge pull request #9388 from bkuhls/jarvis_pr9231
[Jarvis] partly backport of PR 9231 to fix segfault
-rw-r--r-- | xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp | 18 | ||||
-rw-r--r-- | xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h | 9 | ||||
-rw-r--r-- | xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp | 19 | ||||
-rw-r--r-- | xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp | 19 |
4 files changed, 25 insertions, 40 deletions
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp index 2428696dbe..43e88445e2 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp @@ -60,19 +60,15 @@ bool CDVDVideoCodec::IsSettingVisible(const std::string &condition, const std::s return true; } -bool CDVDVideoCodec::IsCodecDisabled(DVDCodecAvailableType* map, unsigned int size, AVCodecID id) +bool CDVDVideoCodec::IsCodecDisabled(const std::map<AVCodecID, std::string> &map, AVCodecID id) { - int index = -1; - for (unsigned int i = 0; i < size; ++i) + auto codec = map.find(id); + if (codec != map.end()) { - if(map[i].codec == id) - { - index = (int) i; - break; - } + return (!CSettings::GetInstance().GetBool(codec->second) || + !CDVDVideoCodec::IsSettingVisible("unused", "unused", + CSettings::GetInstance().GetSetting(codec->second), + NULL)); } - if(index > -1) - return (!CSettings::GetInstance().GetBool(map[index].setting) || !CDVDVideoCodec::IsSettingVisible("unused", "unused", CSettings::GetInstance().GetSetting(map[index].setting), NULL)); - return false; //don't disable what we don't have } diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h index c84bb70a83..68ada7dc58 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h @@ -24,6 +24,7 @@ #include <vector> #include <string> +#include <map> #include "cores/VideoRenderers/RenderFormats.h" @@ -34,12 +35,6 @@ extern "C" { class CSetting; -struct DVDCodecAvailableType -{ - AVCodecID codec; - const char* setting; -}; - // when modifying these structures, make sure you update all codecs accordingly #define FRAME_TYPE_UNDEF 0 #define FRAME_TYPE_I 1 @@ -290,7 +285,7 @@ public: /** * Interact with user settings so that user disabled codecs are disabled */ - static bool IsCodecDisabled(DVDCodecAvailableType* map, unsigned int size, AVCodecID id); + static bool IsCodecDisabled(const std::map<AVCodecID, std::string> &map, AVCodecID id); /* For calculation of dropping requirements player asks for some information. * diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp index 540f91484e..ff53dd5e59 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp @@ -451,16 +451,6 @@ bool CVideoSurfaces::HasRefs() // VAAPI //----------------------------------------------------------------------------- -// settings codecs mapping -DVDCodecAvailableType g_vaapi_available[] = { - { AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4.c_str() }, - { AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4.c_str() }, - { AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1.c_str() }, - { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1.c_str() }, - { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG2.c_str() }, -}; -const size_t settings_count = sizeof(g_vaapi_available) / sizeof(DVDCodecAvailableType); - CDecoder::CDecoder() : m_vaapiOutput(&m_inMsgEvent) { m_vaapiConfig.videoSurfaces = &m_videoSurfaces; @@ -500,7 +490,14 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum P } // check if user wants to decode this format with VAAPI - if (CDVDVideoCodec::IsCodecDisabled(g_vaapi_available, settings_count, avctx->codec_id)) + std::map<AVCodecID, std::string> settings_map = { + { AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4 }, + { AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4 }, + { AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1 }, + { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1 }, + { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG2 }, + }; + if (CDVDVideoCodec::IsCodecDisabled(settings_map, avctx->codec_id)) return false; if (g_advancedSettings.CanLogComponent(LOGVIDEO)) diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp index 85d9295d2e..4e995b6f0a 100644 --- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp +++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp @@ -45,16 +45,6 @@ using namespace VDPAU; #define ARSIZE(x) (sizeof(x) / sizeof((x)[0])) -// settings codecs mapping -DVDCodecAvailableType g_vdpau_available[] = { - { AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4.c_str() }, - { AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4.c_str() }, - { AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1.c_str() }, - { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1.c_str() }, - { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2.c_str() }, -}; -const size_t settings_count = sizeof(g_vdpau_available) / sizeof(DVDCodecAvailableType); - CDecoder::Desc decoder_profiles[] = { {"MPEG1", VDP_DECODER_PROFILE_MPEG1}, {"MPEG2_SIMPLE", VDP_DECODER_PROFILE_MPEG2_SIMPLE}, @@ -494,7 +484,14 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum P // nvidia is whitelisted despite for mpeg-4 we need to query user settings if ((gpuvendor.compare(0, 6, "nvidia") != 0) || (avctx->codec_id == AV_CODEC_ID_MPEG4) || (avctx->codec_id == AV_CODEC_ID_H263)) { - if (CDVDVideoCodec::IsCodecDisabled(g_vdpau_available, settings_count, avctx->codec_id)) + std::map<AVCodecID, std::string> settings_map = { + { AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4 }, + { AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4 }, + { AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1 }, + { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1 }, + { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2 }, + }; + if (CDVDVideoCodec::IsCodecDisabled(settings_map, avctx->codec_id)) return false; } |