Skip to content

Commit

Permalink
ADD: Selective disabling of h/w acceleration in settings (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
koying committed Apr 11, 2016
1 parent 1e08883 commit 59e5e48
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 31 deletions.
15 changes: 15 additions & 0 deletions addons/resource.language.en_gb/resources/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -18191,3 +18191,18 @@ msgctxt "#38113"
msgid "This option uses frame-packing to output full resolution for 3D through HDMI"
msgstr ""

msgctxt "#39000"
msgid "HD and up"
msgstr ""

msgctxt "#39001"
msgid "Accelerate MPEG2"
msgstr ""

msgctxt "#39002"
msgid "Accelerate MPEG4"
msgstr ""

msgctxt "#39003"
msgid "Accelerate h264"
msgstr ""
41 changes: 41 additions & 0 deletions system/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,47 @@
<control type="toggle" />
</setting>
</group>
<group id="4">
<setting id="videoplayer.accelmpeg2" type="integer" label="39001">
<level>2</level>
<default>800</default>
<constraints>
<options>
<option label="20420">9999</option> <!-- Never -->
<option label="39000">800</option> <!-- HD -->
<option label="20422">0</option> <!-- Always -->
</options>
</constraints>
<control type="spinner" format="string" />
<control type="edit" format="integer" />
</setting>
<setting id="videoplayer.accelmpeg4" type="integer" label="39002">
<level>2</level>
<default>800</default>
<constraints>
<options>
<option label="20420">9999</option> <!-- Never -->
<option label="39000">800</option> <!-- HD -->
<option label="20422">0</option> <!-- Always -->
</options>
</constraints>
<control type="spinner" format="string" />
<control type="edit" format="integer" />
</setting>
<setting id="videoplayer.accelh264" type="integer" label="39003">
<level>2</level>
<default>0</default>
<constraints>
<options>
<option label="20420">9999</option> <!-- Never -->
<option label="39000">800</option> <!-- HD -->
<option label="20422">0</option> <!-- Always -->
</options>
</constraints>
<control type="spinner" format="string" />
<control type="edit" format="integer" />
</setting>
</group>
</category>
<category id="myvideos" label="14081" help="36601">
<group id="1">
Expand Down
89 changes: 58 additions & 31 deletions xbmc/cores/dvdplayer/DVDCodecs/DVDFactoryCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,18 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, const C
case AV_CODEC_ID_MPEG4:
case AV_CODEC_ID_MSMPEG4V2:
case AV_CODEC_ID_MSMPEG4V3:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELMPEG2))

This comment has been minimized.

Copy link
@wrxtasy

wrxtasy Apr 30, 2016

Typo here, should be:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELMPEG4))

This comment has been minimized.

Copy link
@koying

koying Apr 30, 2016

Author Owner

Grrr.. Thanks ;)

if ( (pCodec = OpenCodec(new CDVDVideoCodecAmlogic(), hint, options)) ) return pCodec;
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
// Avoid h/w decoder for SD; Those files might use features
// not supported and can easily be soft-decoded
if (hint.width <= 800)
break;
if (hint.width >CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELMPEG2))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAmlogic(), hint, options)) ) return pCodec;
break;
case AV_CODEC_ID_H264:
if (hint.width >CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELH264))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAmlogic(), hint, options)) ) return pCodec;
break;
default:
if ( (pCodec = OpenCodec(new CDVDVideoCodecAmlogic(), hint, options)) ) return pCodec;
}
Expand Down Expand Up @@ -272,48 +278,69 @@ CDVDVideoCodec* CDVDFactoryCodec::CreateVideoCodec(CDVDStreamInfo &hint, const C
{
switch(hint.codec)
{
case AV_CODEC_ID_MPEG4:
case AV_CODEC_ID_MSMPEG4V2:
case AV_CODEC_ID_MSMPEG4V3:
// Avoid h/w decoder for SD; Those files might use features
// not supported and can easily be soft-decoded
if (hint.width <= 800)
break;
default:
CLog::Log(LOGINFO, "MediaCodec (Surface) Video Decoder...");
case AV_CODEC_ID_MPEG4:
case AV_CODEC_ID_MSMPEG4V2:
case AV_CODEC_ID_MSMPEG4V3:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELMPEG4))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(true), hint, options)) ) return pCodec;
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELMPEG2))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(true), hint, options)) ) return pCodec;
break;
case AV_CODEC_ID_H264:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELH264))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(true), hint, options)) ) return pCodec;
break;
default:
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(true), hint, options)) ) return pCodec;
}
}
if (!hint.software && CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEMEDIACODEC))
{
switch(hint.codec)
{
case AV_CODEC_ID_MPEG4:
case AV_CODEC_ID_MSMPEG4V2:
case AV_CODEC_ID_MSMPEG4V3:
// Avoid h/w decoder for SD; Those files might use features
// not supported and can easily be soft-decoded
if (hint.width <= 800)
break;
default:
CLog::Log(LOGINFO, "MediaCodec Video Decoder...");
case AV_CODEC_ID_MPEG4:
case AV_CODEC_ID_MSMPEG4V2:
case AV_CODEC_ID_MSMPEG4V3:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELMPEG4))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(false), hint, options)) ) return pCodec;
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELMPEG2))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(false), hint, options)) ) return pCodec;
break;
case AV_CODEC_ID_H264:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELH264))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(false), hint, options)) ) return pCodec;
break;
default:
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(false), hint, options)) ) return pCodec;
}
}
if (!hint.software && hint.height <= 1080 && CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEMEDIACODECSURFACE))
{
switch(hint.codec)
{
case AV_CODEC_ID_MPEG4:
case AV_CODEC_ID_MSMPEG4V2:
case AV_CODEC_ID_MSMPEG4V3:
// Avoid h/w decoder for SD; Those files might use features
// not supported and can easily be soft-decoded
if (hint.width <= 800)
break;
default:
CLog::Log(LOGINFO, "MediaCodec (Surface) Video Decoder...");
case AV_CODEC_ID_MPEG4:
case AV_CODEC_ID_MSMPEG4V2:
case AV_CODEC_ID_MSMPEG4V3:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELMPEG4))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(true), hint, options)) ) return pCodec;
break;
case AV_CODEC_ID_MPEG1VIDEO:
case AV_CODEC_ID_MPEG2VIDEO:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELMPEG2))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(true), hint, options)) ) return pCodec;
break;
case AV_CODEC_ID_H264:
if (hint.width > CSettings::GetInstance().GetInt(CSettings::SETTING_VIDEOPLAYER_ACCELH264))
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(true), hint, options)) ) return pCodec;
break;
default:
if ( (pCodec = OpenCodec(new CDVDVideoCodecAndroidMediaCodec(true), hint, options)) ) return pCodec;
}
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions xbmc/settings/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ const std::string CSettings::SETTING_VIDEOPLAYER_USEVIDEOTOOLBOX = "videoplayer.
const std::string CSettings::SETTING_VIDEOPLAYER_USEVDA = "videoplayer.usevda";
const std::string CSettings::SETTING_VIDEOPLAYER_USEMMAL = "videoplayer.usemmal";
const std::string CSettings::SETTING_VIDEOPLAYER_USESTAGEFRIGHT = "videoplayer.usestagefright";
const std::string CSettings::SETTING_VIDEOPLAYER_ACCELMPEG2 = "videoplayer.accelmpeg2";
const std::string CSettings::SETTING_VIDEOPLAYER_ACCELMPEG4 = "videoplayer.accelmpeg4";
const std::string CSettings::SETTING_VIDEOPLAYER_ACCELH264 = "videoplayer.accelh264";
const std::string CSettings::SETTING_VIDEOPLAYER_LIMITGUIUPDATE = "videoplayer.limitguiupdate";
const std::string CSettings::SETTING_MYVIDEOS_SELECTACTION = "myvideos.selectaction";
const std::string CSettings::SETTING_MYVIDEOS_EXTRACTFLAGS = "myvideos.extractflags";
Expand Down
3 changes: 3 additions & 0 deletions xbmc/settings/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ class CSettings : public CSettingCreator, public CSettingControlCreator
static const std::string SETTING_VIDEOPLAYER_USEVDA;
static const std::string SETTING_VIDEOPLAYER_USEMMAL;
static const std::string SETTING_VIDEOPLAYER_USESTAGEFRIGHT;
static const std::string SETTING_VIDEOPLAYER_ACCELMPEG2;
static const std::string SETTING_VIDEOPLAYER_ACCELMPEG4;
static const std::string SETTING_VIDEOPLAYER_ACCELH264;
static const std::string SETTING_VIDEOPLAYER_LIMITGUIUPDATE;
static const std::string SETTING_MYVIDEOS_SELECTACTION;
static const std::string SETTING_MYVIDEOS_EXTRACTFLAGS;
Expand Down

0 comments on commit 59e5e48

Please sign in to comment.