Skip to content

Commit 6a9e2bf

Browse files
committed
[Jarvis] partly backport of PR 9231 to fix segfault
This patch is a backport of xbmc@a81208e to fix a segfault during playback of vaapi-accelerated mpeg2 content: terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid [New LWP 3743] Program received signal SIGABRT, Aborted. [Switching to LWP 3743] 0xb5664a9b in raise () from /lib/libc.so.0 (gdb) bt full #0 0xb5664a9b in raise () from /lib/libc.so.0 No symbol table info available. #1 0xb5660520 in abort () from /lib/libc.so.0 No symbol table info available. #2 0xb56e6536 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6 No symbol table info available. #3 0xb56e4a1c in ?? () from /usr/lib/libstdc++.so.6 No symbol table info available. #4 0xb56e4a80 in std::terminate() () from /usr/lib/libstdc++.so.6 No symbol table info available. #5 0xb56e4cc9 in __cxa_throw () from /usr/lib/libstdc++.so.6 No symbol table info available. #6 0xb5719d79 in std::__throw_logic_error(char const*) () from /usr/lib/libstdc++.so.6 No symbol table info available. #7 0xb5722c41 in char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) () from /usr/lib/libstdc++.so.6 No symbol table info available. #8 0xb5722cc7 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () from /usr/lib/libstdc++.so.6 No symbol table info available. #9 0x0848fea3 in CDVDVideoCodec::IsCodecDisabled (map=0x9130420 <g_vaapi_available>, size=5, id=AV_CODEC_ID_MPEG4) at DVDVideoCodec.cpp:75 index = <optimized out> #10 0x08499d04 in VAAPI::CDecoder::Open (this=0xd09e5e8, avctx=0xd6a2ec0, mainctx=0xd6a2ec0, fmt=AV_PIX_FMT_VAAPI_VLD, surfaces=6) at VAAPI.cpp:503 gpuvendor = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0xceb267c "intel open source technology center"}} profile = <optimized out> #11 0x08491bda in CDVDVideoCodecFFmpeg::GetFormat (avctx=0xd6a2ec0, fmt=0x986d9c0) at DVDVideoCodecFFmpeg.cpp:143 dec = 0xd09e5e8 ctx = <optimized out> cur = 0x986d9c0 #12 0xb61c8ced in ?? () from /usr/lib/libavcodec.so.56
1 parent a7caa16 commit 6a9e2bf

File tree

4 files changed

+25
-40
lines changed

4 files changed

+25
-40
lines changed

xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,15 @@ bool CDVDVideoCodec::IsSettingVisible(const std::string &condition, const std::s
6060
return true;
6161
}
6262

63-
bool CDVDVideoCodec::IsCodecDisabled(DVDCodecAvailableType* map, unsigned int size, AVCodecID id)
63+
bool CDVDVideoCodec::IsCodecDisabled(const std::map<AVCodecID, std::string> &map, AVCodecID id)
6464
{
65-
int index = -1;
66-
for (unsigned int i = 0; i < size; ++i)
65+
auto codec = map.find(id);
66+
if (codec != map.end())
6767
{
68-
if(map[i].codec == id)
69-
{
70-
index = (int) i;
71-
break;
72-
}
68+
return (!CSettings::GetInstance().GetBool(codec->second) ||
69+
!CDVDVideoCodec::IsSettingVisible("unused", "unused",
70+
CSettings::GetInstance().GetSetting(codec->second),
71+
NULL));
7372
}
74-
if(index > -1)
75-
return (!CSettings::GetInstance().GetBool(map[index].setting) || !CDVDVideoCodec::IsSettingVisible("unused", "unused", CSettings::GetInstance().GetSetting(map[index].setting), NULL));
76-
7773
return false; //don't disable what we don't have
7874
}

xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <vector>
2626
#include <string>
27+
#include <map>
2728
#include "cores/VideoRenderers/RenderFormats.h"
2829

2930

@@ -34,12 +35,6 @@ extern "C" {
3435

3536
class CSetting;
3637

37-
struct DVDCodecAvailableType
38-
{
39-
AVCodecID codec;
40-
const char* setting;
41-
};
42-
4338
// when modifying these structures, make sure you update all codecs accordingly
4439
#define FRAME_TYPE_UNDEF 0
4540
#define FRAME_TYPE_I 1
@@ -290,7 +285,7 @@ class CDVDVideoCodec
290285
/**
291286
* Interact with user settings so that user disabled codecs are disabled
292287
*/
293-
static bool IsCodecDisabled(DVDCodecAvailableType* map, unsigned int size, AVCodecID id);
288+
static bool IsCodecDisabled(const std::map<AVCodecID, std::string> &map, AVCodecID id);
294289

295290
/* For calculation of dropping requirements player asks for some information.
296291
*

xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -451,16 +451,6 @@ bool CVideoSurfaces::HasRefs()
451451
// VAAPI
452452
//-----------------------------------------------------------------------------
453453

454-
// settings codecs mapping
455-
DVDCodecAvailableType g_vaapi_available[] = {
456-
{ AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4.c_str() },
457-
{ AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4.c_str() },
458-
{ AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1.c_str() },
459-
{ AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1.c_str() },
460-
{ AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG2.c_str() },
461-
};
462-
const size_t settings_count = sizeof(g_vaapi_available) / sizeof(DVDCodecAvailableType);
463-
464454
CDecoder::CDecoder() : m_vaapiOutput(&m_inMsgEvent)
465455
{
466456
m_vaapiConfig.videoSurfaces = &m_videoSurfaces;
@@ -500,7 +490,14 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum P
500490
}
501491

502492
// check if user wants to decode this format with VAAPI
503-
if (CDVDVideoCodec::IsCodecDisabled(g_vaapi_available, settings_count, avctx->codec_id))
493+
std::map<AVCodecID, std::string> settings_map = {
494+
{ AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4 },
495+
{ AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4 },
496+
{ AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1 },
497+
{ AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1 },
498+
{ AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG2 },
499+
};
500+
if (CDVDVideoCodec::IsCodecDisabled(settings_map, avctx->codec_id))
504501
return false;
505502

506503
if (g_advancedSettings.CanLogComponent(LOGVIDEO))

xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ using namespace VDPAU;
4545

4646
#define ARSIZE(x) (sizeof(x) / sizeof((x)[0]))
4747

48-
// settings codecs mapping
49-
DVDCodecAvailableType g_vdpau_available[] = {
50-
{ AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4.c_str() },
51-
{ AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4.c_str() },
52-
{ AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1.c_str() },
53-
{ AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1.c_str() },
54-
{ AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2.c_str() },
55-
};
56-
const size_t settings_count = sizeof(g_vdpau_available) / sizeof(DVDCodecAvailableType);
57-
5848
CDecoder::Desc decoder_profiles[] = {
5949
{"MPEG1", VDP_DECODER_PROFILE_MPEG1},
6050
{"MPEG2_SIMPLE", VDP_DECODER_PROFILE_MPEG2_SIMPLE},
@@ -494,7 +484,14 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum P
494484
// nvidia is whitelisted despite for mpeg-4 we need to query user settings
495485
if ((gpuvendor.compare(0, 6, "nvidia") != 0) || (avctx->codec_id == AV_CODEC_ID_MPEG4) || (avctx->codec_id == AV_CODEC_ID_H263))
496486
{
497-
if (CDVDVideoCodec::IsCodecDisabled(g_vdpau_available, settings_count, avctx->codec_id))
487+
std::map<AVCodecID, std::string> settings_map = {
488+
{ AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4 },
489+
{ AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4 },
490+
{ AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1 },
491+
{ AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1 },
492+
{ AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2 },
493+
};
494+
if (CDVDVideoCodec::IsCodecDisabled(settings_map, avctx->codec_id))
498495
return false;
499496
}
500497

0 commit comments

Comments
 (0)