Skip to content

Commit

Permalink
stereoscopicmanager: fixups for rbp
Browse files Browse the repository at this point in the history
  • Loading branch information
popcornmix committed Apr 3, 2020
1 parent 940b0af commit de4b541
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 3 deletions.
60 changes: 60 additions & 0 deletions xbmc/cores/VideoPlayer/DVDCodecs/DVDCodecUtils.cpp
Expand Up @@ -10,9 +10,11 @@
#include "cores/VideoPlayer/Interface/Addon/TimingConstants.h"
#include "cores/FFmpeg.h"
#include "Util.h"
#include <assert.h>

extern "C" {
#include <libswscale/swscale.h>
#include <libavutil/intreadwrite.h>
}

bool CDVDCodecUtils::IsVP3CompatibleWidth(int width)
Expand Down Expand Up @@ -64,3 +66,61 @@ double CDVDCodecUtils::NormalizeFrameduration(double frameduration, bool *match)
}
}

bool CDVDCodecUtils::IsH264AnnexB(std::string format, AVStream *avstream)
{
assert(avstream->codecpar->codec_id == AV_CODEC_ID_H264 || avstream->codecpar->codec_id == AV_CODEC_ID_H264_MVC);
if (avstream->codecpar->extradata_size < 4)
return true;
if (avstream->codecpar->extradata[0] == 1)
return false;
if (format == "avi")
{
uint8_t *src = avstream->codecpar->extradata;
unsigned startcode = AV_RB32(src);
if (startcode == 0x00000001 || (startcode & 0xffffff00) == 0x00000100)
return true;
if (avstream->codecpar->codec_tag == MKTAG('A', 'V', 'C', '1') || avstream->codecpar->codec_tag == MKTAG('a', 'v', 'c', '1'))
return false;
}
return true;
}

bool CDVDCodecUtils::ProcessH264MVCExtradata(uint8_t *data, int data_size, uint8_t **mvc_data, int *mvc_data_size)
{
uint8_t* extradata = data;
int extradata_size = data_size;

if (extradata_size > 4 && *(char *)extradata == 1)
{
// Find "mvcC" atom
uint32_t state = -1;
int i = 0;
for (; i < extradata_size; i++)
{
state = (state << 8) | extradata[i];
if (state == MKBETAG('m', 'v', 'c', 'C'))
break;
}
if (i >= 8 && i < extradata_size)
{
// Update pointers to the start of the mvcC atom
extradata = extradata + i - 7;
extradata_size = extradata_size - i + 7;
// verify size atom and actual size
if (extradata_size >= 14 && (AV_RB32(extradata) + 4) <= extradata_size)
{
extradata += 8;
extradata_size -= 8;
if (*(char *)extradata == 1)
{
if (mvc_data)
*mvc_data = extradata;
if (mvc_data_size)
*mvc_data_size = extradata_size;
return true;
}
}
}
}
return false;
}
5 changes: 5 additions & 0 deletions xbmc/cores/VideoPlayer/DVDCodecs/DVDCodecUtils.h
Expand Up @@ -8,11 +8,16 @@

#pragma once

#include "Video/DVDVideoCodec.h"

class AVStream;

class CDVDCodecUtils
{
public:
static bool IsVP3CompatibleWidth(int width);
static double NormalizeFrameduration(double frameduration, bool *match = nullptr);
static bool IsH264AnnexB(std::string format, AVStream *avstream);
static bool ProcessH264MVCExtradata(uint8_t *extradata, int extradata_size, uint8_t **mvc_extradata = nullptr, int *mvc_extradata_size = nullptr);
};

9 changes: 7 additions & 2 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALCodec.cpp
Expand Up @@ -333,6 +333,11 @@ bool CMMALVideo::SendCodecConfigData()
return true;
}

bool CMMALVideo::SupportsExtention()
{
return CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_VIDEOPLAYER_SUPPORTMVC);
}

bool CMMALVideo::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
{
CSingleLock lock(m_sharedSection);
Expand Down Expand Up @@ -384,12 +389,12 @@ bool CMMALVideo::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
m_codingType = MMAL_ENCODING_H264;
m_pFormatName = "mmal-h264";
if ((hints.codec_tag == MKTAG('M', 'V', 'C', '1') || hints.codec_tag == MKTAG('A', 'M', 'V', 'C')) &&
CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_VIDEOPLAYER_SUPPORTMVC))
SupportsExtention())
{
m_codingType = MMAL_ENCODING_MVC;
m_pFormatName= "mmal-mvc";
if (hints.stereo_mode == "mono")
hints.stereo_mode = "mvc_lr";
hints.stereo_mode = "block_lr";
}
break;
case AV_CODEC_ID_H263:
Expand Down
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/DVDCodecs/Video/MMALCodec.h
Expand Up @@ -53,6 +53,7 @@ class CMMALVideo : public CDVDVideoCodec
virtual const char* GetName(void) override { return m_pFormatName ? m_pFormatName:"mmal-xxx"; }
virtual void SetCodecControl(int flags) override;
virtual void SetSpeed(int iSpeed) override;
virtual bool SupportsExtention() override;

// MMAL decoder callback routines.
void dec_output_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
Expand Down
Expand Up @@ -1199,7 +1199,7 @@ bool CDVDInputStreamBluray::ProcessItem(int playitem)

m_titleInfo = bd_get_playlist_info(m_bd, playitem, m_angle);

if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_VIDEOPLAYER_SUPPORTMVC) && !m_bMVCDisabled)
if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_VIDEOPLAYER_SUPPORTMVC) && !m_bMVCDisabled)
{
MPLS_PL * mpls = bd_get_title_mpls(m_bd);
if (mpls)
Expand Down
3 changes: 3 additions & 0 deletions xbmc/guilib/StereoscopicsManager.cpp
Expand Up @@ -62,10 +62,13 @@ static const struct StereoModeMap VideoModeToGuiModeMap[] =
{ "anaglyph_cyan_red", RENDER_STEREO_MODE_ANAGLYPH_RED_CYAN },
{ "anaglyph_green_magenta", RENDER_STEREO_MODE_ANAGLYPH_GREEN_MAGENTA },
{ "anaglyph_yellow_blue", RENDER_STEREO_MODE_ANAGLYPH_YELLOW_BLUE },
#ifndef TARGET_RASPBERRY_PI
{ "block_lr", RENDER_STEREO_MODE_HARDWAREBASED },
{ "block_rl", RENDER_STEREO_MODE_HARDWAREBASED },
#else
{ "block_lr", RENDER_STEREO_MODE_SPLIT_HORIZONTAL }, // fallback
{ "block_rl", RENDER_STEREO_MODE_SPLIT_HORIZONTAL }, // fallback
#endif
{}
};

Expand Down

0 comments on commit de4b541

Please sign in to comment.