Skip to content

Commit

Permalink
[3DBD] Added support of 3D-BluRay playback.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Fedchin authored and popcornmix committed Oct 12, 2017
1 parent 8de51cd commit 4bc8ef6
Show file tree
Hide file tree
Showing 9 changed files with 556 additions and 23 deletions.
8 changes: 8 additions & 0 deletions lib/DllLibbluray.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ extern "C"
#include <libbluray/keys.h>
#include <libbluray/overlay.h>
#include <libbluray/bluray-version.h>
#include <libbluray/clpi_parse.h>
#include <libbluray/mpls_parse.h>
}

typedef int(*read_blocks_f)(void *handle, void *buf, int lba, int num_blocks);
Expand Down Expand Up @@ -88,6 +90,8 @@ class DllLibblurayInterface
virtual int bd_menu_call (BLURAY *bd, int64_t pts)=0;
virtual int bd_mouse_select (BLURAY *bd, int64_t pts, uint16_t x, uint16_t y)=0;
virtual int bd_get_sound_effect (BLURAY *bd, unsigned sound_id, struct bd_sound_effect *effect)=0;
virtual MPLS_PL* bd_get_title_mpls (BLURAY *bd) = 0;
virtual int bd_get_clip_infos (BLURAY *bd, unsigned clip, uint64_t *clip_start_time, uint64_t *stream_start_time, uint64_t *pos, uint64_t *duration) = 0;
};

class DllLibbluray : public DllDynamic, DllLibblurayInterface
Expand Down Expand Up @@ -141,6 +145,8 @@ class DllLibbluray : public DllDynamic, DllLibblurayInterface
DEFINE_METHOD2(int, bd_menu_call, (BLURAY *p1, int64_t p2))
DEFINE_METHOD4(int, bd_mouse_select, (BLURAY *p1, int64_t p2, uint16_t p3, uint16_t p4))
DEFINE_METHOD3(int, bd_get_sound_effect, (BLURAY *p1, unsigned p2, struct bd_sound_effect* p3))
DEFINE_METHOD1(MPLS_PL*, bd_get_title_mpls, (BLURAY *p1))
DEFINE_METHOD6(int, bd_get_clip_infos, (BLURAY *p1, unsigned p2, uint64_t *p3, uint64_t *p4, uint64_t *p5, uint64_t *p6))

BEGIN_METHOD_RESOLVE()
RESOLVE_METHOD(bd_get_titles)
Expand Down Expand Up @@ -190,6 +196,8 @@ class DllLibbluray : public DllDynamic, DllLibblurayInterface
RESOLVE_METHOD(bd_menu_call)
RESOLVE_METHOD(bd_mouse_select)
RESOLVE_METHOD(bd_get_sound_effect)
RESOLVE_METHOD(bd_get_title_mpls)
RESOLVE_METHOD(bd_get_clip_infos)
END_METHOD_RESOLVE()

public:
Expand Down
2 changes: 2 additions & 0 deletions xbmc/cores/VideoPlayer/DVDDemuxers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(SOURCES DemuxMultiSource.cpp
DVDDemuxClient.cpp
DVDDemuxFFmpeg.cpp
DemuxStreamSSIF.cpp
DemuxMVC.cpp
DVDDemuxUtils.cpp
DVDDemuxVobsub.cpp
DVDFactoryDemuxer.cpp)
Expand All @@ -18,6 +19,7 @@ set(HEADERS DemuxMultiSource.h
DVDDemuxClient.h
DVDDemuxFFmpeg.h
DemuxStreamSSIF.h
DemuxMVC.h
DVDDemuxPacket.h
DVDDemuxUtils.h
DVDDemuxVobsub.h
Expand Down
51 changes: 42 additions & 9 deletions xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "cores/FFmpeg.h"
#include "TimingConstants.h" // for DVD_TIME_BASE
#include "DVDCodecs/DVDCodecUtils.h"
#include "DemuxMVC.h"
#include "DVDDemuxUtils.h"
#include "DVDInputStreams/DVDInputStream.h"
#include "DVDInputStreams/DVDInputStreamFFmpeg.h"
Expand Down Expand Up @@ -511,6 +512,16 @@ bool CDVDDemuxFFmpeg::Open(CDVDInputStream* pInput, bool streaminfo, bool filein

UpdateCurrentPTS();

if (!fileinfo && m_pInput->IsStreamType(DVDSTREAM_TYPE_BLURAY))
{
CDVDInputStreamBluray *bluRay = static_cast<CDVDInputStreamBluray*>(m_pInput);
if (bluRay->HasMVC())
{
SAFE_DELETE(m_pSSIF);
m_pSSIF = new CDemuxStreamSSIF();
m_pSSIF->SetBluRay(bluRay);
}
}
// in case of mpegts and we have not seen pat/pmt, defer creation of streams
if (!skipCreateStreams || m_pFormatContext->nb_programs > 0)
{
Expand Down Expand Up @@ -915,9 +926,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
{
Flush();
}
// libavformat is confused by the interleaved SSIF.
// Disable program management for those
else if (!m_pSSIF && IsProgramChange())
else if (IsProgramChange())
{
// update streams
CreateStreams(m_program);
Expand Down Expand Up @@ -970,8 +979,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
if (IsVideoReady())
{
// libavformat is confused by the interleaved SSIF.
// Disable program management for those
if (!m_pSSIF && m_program != UINT_MAX )
if ((!m_pSSIF || m_pSSIF->IsBluRay()) && m_program != UINT_MAX)
{
/* check so packet belongs to selected program */
for (unsigned int i = 0; i < m_pFormatContext->programs[m_program]->nb_stream_indexes; i++)
Expand Down Expand Up @@ -1104,10 +1112,7 @@ DemuxPacket* CDVDDemuxFFmpeg::Read()
}
if (stream && m_pSSIF)
{
if (stream->type == STREAM_VIDEO ||
stream->type == STREAM_DATA)
pPacket = m_pSSIF->AddPacket(pPacket);

pPacket = m_pSSIF->AddPacket(pPacket);
if (stream->type == STREAM_DATA && stream->codec == AV_CODEC_ID_H264_MVC && pPacket->iSize)
stream = GetStream(pPacket->iStreamId);
}
Expand Down Expand Up @@ -1509,6 +1514,29 @@ CDemuxStream* CDVDDemuxFFmpeg::AddStream(int streamIdx)
{
m_pSSIF->SetH264StreamId(streamIdx);
pStream->codecpar->codec_tag = MKTAG('A', 'M', 'V', 'C');

AVStream* mvcStream = nullptr;
if (m_pInput->IsStreamType(DVDSTREAM_TYPE_BLURAY))
{
CDVDInputStreamBluray *bluRay = static_cast<CDVDInputStreamBluray*>(m_pInput);
if (bluRay->HasMVC())
{
st->stereo_mode = bluRay->AreEyesFlipped() ? "block_rl" : "block_lr";
mvcStream = static_cast<CDemuxMVC*>(bluRay->GetDemuxMVC())->GetAVStream();
}
}
else
mvcStream = m_pFormatContext->streams[m_pSSIF->GetMVCStreamId()];

if (mvcStream && pStream->codec->extradata_size > 0 && mvcStream->codec->extradata_size > 0)
{
uint8_t* extr = pStream->codec->extradata;
pStream->codec->extradata = (uint8_t*)av_mallocz(pStream->codec->extradata_size + mvcStream->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy(pStream->codec->extradata, extr, pStream->codec->extradata_size);
memcpy(pStream->codec->extradata + pStream->codec->extradata_size, mvcStream->codec->extradata, mvcStream->codec->extradata_size);
pStream->codec->extradata_size += mvcStream->codec->extradata_size;
av_free(extr);
}
}
}
else if (CDVDCodecUtils::ProcessH264MVCExtradata(pStream->codec->extradata, pStream->codec->extradata_size))
Expand Down Expand Up @@ -1832,6 +1860,11 @@ std::string CDVDDemuxFFmpeg::GetStreamCodecName(int iStreamId)

bool CDVDDemuxFFmpeg::IsProgramChange()
{
// libavformat is confused by the interleaved SSIF.
// disable program management for those
if (m_pSSIF && !m_pSSIF->IsBluRay())
return false;

if (m_program == UINT_MAX)
return false;

Expand Down
Loading

0 comments on commit 4bc8ef6

Please sign in to comment.