Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/LAVFilters.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/includes/IMediaSideDataFFmpeg.h39
-rw-r--r--demuxer/Demuxers/LAVFDemuxer.cpp7
-rw-r--r--demuxer/LAVSplitter/PacketAllocator.cpp27
-rw-r--r--demuxer/LAVSplitter/PacketAllocator.h13
-rw-r--r--demuxer/LAVSplitter/dllmain.cpp1
5 files changed, 80 insertions, 7 deletions
diff --git a/common/includes/IMediaSideDataFFmpeg.h b/common/includes/IMediaSideDataFFmpeg.h
new file mode 100644
index 00000000..598b7404
--- /dev/null
+++ b/common/includes/IMediaSideDataFFmpeg.h
@@ -0,0 +1,39 @@
+/*
+* Copyright (C) 2010-2016 Hendrik Leppkes
+* http://www.1f0.de
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*
+* Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2
+* Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2
+*/
+
+#pragma once
+
+// {08FA97DB-392C-4132-9C41-0B6507C3A164}
+DEFINE_GUID(IID_MediaSideDataFFMpeg,
+ 0x8fa97db, 0x392c, 0x4132, 0x9c, 0x41, 0xb, 0x65, 0x7, 0xc3, 0xa1, 0x64);
+
+extern "C" {
+#include "libavcodec/avcodec.h"
+}
+
+#pragma pack(push, 1)
+struct MediaSideDataFFMpeg
+{
+ AVPacketSideData *side_data;
+ int side_data_elems;
+};
+#pragma pack(pop)
diff --git a/demuxer/Demuxers/LAVFDemuxer.cpp b/demuxer/Demuxers/LAVFDemuxer.cpp
index deb032cf..1c28c839 100644
--- a/demuxer/Demuxers/LAVFDemuxer.cpp
+++ b/demuxer/Demuxers/LAVFDemuxer.cpp
@@ -596,11 +596,8 @@ STDMETHODIMP CLAVFDemuxer::InitAVFormat(LPCOLESTR pszFileName, BOOL bForce)
av_opt_set_int(m_avFormat, "correct_ts_overflow", !m_pBluRay, 0);
- // TODO: AVFMT_FLAG_KEEP_SIDE_DATA should be ON for all formats
- if (m_bMatroska || m_bMPEGTS)
- m_avFormat->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
- else
- m_avFormat->flags &= ~AVFMT_FLAG_KEEP_SIDE_DATA;
+ // preserve side-data in the packets properly
+ m_avFormat->flags |= AVFMT_FLAG_KEEP_SIDE_DATA;
m_timeOpening = time(nullptr);
int ret = avformat_find_stream_info(m_avFormat, nullptr);
diff --git a/demuxer/LAVSplitter/PacketAllocator.cpp b/demuxer/LAVSplitter/PacketAllocator.cpp
index a70f08c6..d04f584c 100644
--- a/demuxer/LAVSplitter/PacketAllocator.cpp
+++ b/demuxer/LAVSplitter/PacketAllocator.cpp
@@ -70,6 +70,8 @@ STDMETHODIMP_(ULONG) CMediaPacketSample::Release()
SAFE_DELETE(m_pPacket);
SetPointer(nullptr, 0);
+ SAFE_DELETE(m_pSideData);
+
/* This may cause us to be deleted */
// Our refcount is reliably 0 thus no-one will mess with us
m_pAllocator->ReleaseBuffer(this);
@@ -83,9 +85,34 @@ STDMETHODIMP CMediaPacketSample::SetPacket(Packet *pPacket)
m_pPacket = pPacket;
SetPointer(pPacket->GetData(), (LONG)pPacket->GetDataSize());
+ SAFE_DELETE(m_pSideData);
+
+ if (pPacket->GetNumSideData() > 0) {
+ m_pSideData = new MediaSideDataFFMpeg();
+ m_pSideData->side_data = pPacket->GetSideData();
+ m_pSideData->side_data_elems = pPacket->GetNumSideData();
+ }
+
return S_OK;
}
+STDMETHODIMP CMediaPacketSample::SetSideData(GUID guidType, const BYTE *pData, size_t size)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CMediaPacketSample::GetSideData(GUID guidType, const BYTE **pData, size_t *pSize)
+{
+ if (guidType == IID_MediaSideDataFFMpeg && m_pSideData) {
+ *pData = (const BYTE *)m_pSideData;
+ *pSize = sizeof(MediaSideDataFFMpeg);
+
+ return S_OK;
+ }
+
+ return E_INVALIDARG;
+}
+
CPacketAllocator::CPacketAllocator(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT *phr)
: CBaseAllocator(pName, pUnk, phr, TRUE, TRUE)
{
diff --git a/demuxer/LAVSplitter/PacketAllocator.h b/demuxer/LAVSplitter/PacketAllocator.h
index 08cddab1..ba5d82b3 100644
--- a/demuxer/LAVSplitter/PacketAllocator.h
+++ b/demuxer/LAVSplitter/PacketAllocator.h
@@ -22,13 +22,16 @@
#pragma once
+#include "IMediaSideData.h"
+#include "IMediaSideDataFFmpeg.h"
+
interface __declspec(uuid("0B2EE323-0ED8-452D-B31E-B9B4DE2C0C39"))
-ILAVMediaSample : public IUnknown {
+ILAVMediaSample : public IUnknown {
STDMETHOD(SetPacket)(Packet *pPacket) PURE;
};
-class CMediaPacketSample : public CMediaSample, public ILAVMediaSample
+class CMediaPacketSample : public CMediaSample, public ILAVMediaSample, public IMediaSideData
{
public:
CMediaPacketSample(LPCTSTR pName, CBaseAllocator *pAllocator, HRESULT *phr);
@@ -38,10 +41,16 @@ public:
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();
+ // ILAVMediaSamples
STDMETHODIMP SetPacket(Packet *pPacket);
+ // IMediaSideData
+ STDMETHODIMP SetSideData(GUID guidType, const BYTE *pData, size_t size);
+ STDMETHODIMP GetSideData(GUID guidType, const BYTE **pData, size_t *pSize);
+
protected:
Packet *m_pPacket = nullptr;
+ MediaSideDataFFMpeg *m_pSideData = nullptr;
};
class CPacketAllocator : public CBaseAllocator
diff --git a/demuxer/LAVSplitter/dllmain.cpp b/demuxer/LAVSplitter/dllmain.cpp
index 5f42bf5e..a68ff5b4 100644
--- a/demuxer/LAVSplitter/dllmain.cpp
+++ b/demuxer/LAVSplitter/dllmain.cpp
@@ -36,6 +36,7 @@
#include "registry.h"
#include "IGraphRebuildDelegate.h"
+#include "IMediaSideDataFFmpeg.h"
// The GUID we use to register the splitter media types
DEFINE_GUID(MEDIATYPE_LAVSplitter,