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

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnderground78 <underground78@users.sourceforge.net>2013-06-23 22:46:36 +0400
committerUnderground78 <underground78@users.sourceforge.net>2013-06-29 23:56:22 +0400
commitf46c1fd78e595b889bb27148a986cdbd0e4913c0 (patch)
treefbd90a5b738081dc615b1083382907cb228e6b3a /src/filters/transform/MPCVideoDec
parent51e719b03f2e1ace5bf49b1512b340f278cb586e (diff)
Remove now deprecated filters.
Diffstat (limited to 'src/filters/transform/MPCVideoDec')
-rw-r--r--src/filters/transform/MPCVideoDec/CpuId.cpp128
-rw-r--r--src/filters/transform/MPCVideoDec/CpuId.h56
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.cpp773
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.h161
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp390
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderH264.h67
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp282
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h62
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp330
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.h103
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.cpp939
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.h78
-rw-r--r--src/filters/transform/MPCVideoDec/H264RandomAccess.cpp96
-rw-r--r--src/filters/transform/MPCVideoDec/H264RandomAccess.h40
-rw-r--r--src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h90
-rw-r--r--src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp59
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDec.def5
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj313
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters137
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp2672
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h329
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.rc166
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp447
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h102
-rw-r--r--src/filters/transform/MPCVideoDec/PODtypes.h32
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp56
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.h47
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp208
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h87
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp131
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecOutputPin.h55
-rw-r--r--src/filters/transform/MPCVideoDec/array_allocator.h49
-rw-r--r--src/filters/transform/MPCVideoDec/char_t.h291
-rw-r--r--src/filters/transform/MPCVideoDec/ffImgfmt.cpp1562
-rw-r--r--src/filters/transform/MPCVideoDec/ffImgfmt.h489
-rw-r--r--src/filters/transform/MPCVideoDec/resource.h40
-rw-r--r--src/filters/transform/MPCVideoDec/stdafx.cpp46
-rw-r--r--src/filters/transform/MPCVideoDec/stdafx.h40
38 files changed, 0 insertions, 10958 deletions
diff --git a/src/filters/transform/MPCVideoDec/CpuId.cpp b/src/filters/transform/MPCVideoDec/CpuId.cpp
deleted file mode 100644
index 5c10d7ed4..000000000
--- a/src/filters/transform/MPCVideoDec/CpuId.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <intrin.h>
-#include "CpuId.h"
-
-#define CPUID_MMX (1 << 23)
-#define CPUID_SSE (1 << 25)
-#define CPUID_SSE2 (1 << 26)
-#define CPUID_SSE3 (1 << 0)
-#define CPUID_SSE41 (1 << 19)
-#define CPUID_SSE42 (1 << 20)
-#define CPUID_AVX ((1 << 27) | (1 << 28))
-
-// Intel specific
-#define CPUID_SSSE3 (1 << 9)
-
-// AMD specific
-#define CPUID_3DNOW (1 << 31)
-#define CPUID_MMXEXT (1 << 22)
-
-CCpuId::CCpuId()
-{
- unsigned nHighestFeature;
- unsigned nHighestFeatureEx;
- int nBuff[4];
- char szMan[13];
-
- // Get CPU manufacturer and highest CPUID
- __cpuid(nBuff, 0);
- nHighestFeature = (unsigned)nBuff[0];
- *(int*)&szMan[0] = nBuff[1];
- *(int*)&szMan[4] = nBuff[3];
- *(int*)&szMan[8] = nBuff[2];
- szMan[12] = 0;
-
- if (strcmp(szMan, "AuthenticAMD") == 0) {
- m_nType = PROCESSOR_AMD;
- } else if (strcmp(szMan, "GenuineIntel") == 0) {
- m_nType = PROCESSOR_INTEL;
- } else {
- m_nType = PROCESSOR_UNKNOWN;
- }
-
- // Get highest extended feature
- __cpuid(nBuff, 0x80000000);
- nHighestFeatureEx = (unsigned)nBuff[0];
-
- // Get CPU features
- m_nCPUFeatures = 0;
- if (nHighestFeature >= 1) {
- __cpuid(nBuff, 1);
- if (nBuff[3] & CPUID_MMX) {
- m_nCPUFeatures |= MPC_MM_MMX;
- }
- if (nBuff[3] & CPUID_SSE) {
- m_nCPUFeatures |= MPC_MM_SSE;
- }
- if (nBuff[3] & CPUID_SSE2) {
- m_nCPUFeatures |= MPC_MM_SSE2;
- }
- if (nBuff[2] & CPUID_SSE3) {
- m_nCPUFeatures |= MPC_MM_SSE3;
- }
- if (nBuff[2] & CPUID_SSE41) {
- m_nCPUFeatures |= MPC_MM_SSE4;
- }
- if (nBuff[2] & CPUID_SSE42) {
- m_nCPUFeatures |= MPC_MM_SSE42;
- }
-
- // Intel specific
- if (m_nType == PROCESSOR_INTEL) {
- if (nBuff[2] & CPUID_SSSE3) {
- m_nCPUFeatures |= MPC_MM_SSSE3;
- }
- if ((nBuff[2] & CPUID_AVX) == CPUID_AVX) {
- // Check for OS support
- unsigned long long xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
- if ((xcrFeatureMask & 0x6) == 0x6) {
- m_nCPUFeatures |= MPC_MM_AVX;
- }
- }
- }
- }
-
- // AMD specific
- if (m_nType == PROCESSOR_AMD) {
- // Get extended features
- __cpuid(nBuff, 0x80000000);
- if (nHighestFeatureEx >= 0x80000001) {
- __cpuid(nBuff, 0x80000001);
- if (nBuff[3] & CPUID_3DNOW) {
- m_nCPUFeatures |= MPC_MM_3DNOW;
- }
- if (nBuff[3] & CPUID_MMXEXT) {
- m_nCPUFeatures |= MPC_MM_MMXEXT;
- }
- }
- }
-
-}
-
-int CCpuId::GetProcessorNumber()
-{
- SYSTEM_INFO SystemInfo;
- GetSystemInfo(&SystemInfo);
-
- return SystemInfo.dwNumberOfProcessors;
-}
diff --git a/src/filters/transform/MPCVideoDec/CpuId.h b/src/filters/transform/MPCVideoDec/CpuId.h
deleted file mode 100644
index 54ed12cfe..000000000
--- a/src/filters/transform/MPCVideoDec/CpuId.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-class CCpuId
-{
-public:
-
- typedef enum {
- PROCESSOR_AMD,
- PROCESSOR_INTEL,
- PROCESSOR_UNKNOWN
- } PROCESSOR_TYPE;
-
- // Enum codes identical to FFmpeg cpu features define
- typedef enum {
- MPC_MM_MMX = 0x0001, /* standard MMX */
- MPC_MM_3DNOW = 0x0004, /* AMD 3DNOW */
- MPC_MM_MMXEXT = 0x0002, /* SSE integer functions or AMD MMX ext */
- MPC_MM_SSE = 0x0008, /* SSE functions */
- MPC_MM_SSE2 = 0x0010, /* PIV SSE2 functions */
- MPC_MM_SSE3 = 0x0040, /* AMD64 & PIV SSE3 functions */
- MPC_MM_SSSE3 = 0x0080, /* PIV Core 2 SSSE3 functions */
- MPC_MM_SSE4 = 0x0100,
- MPC_MM_SSE42 = 0x0200,
- MPC_MM_AVX = 0x4000
- } PROCESSOR_FEATURES;
-
- CCpuId();
-
- int GetFeatures() const { return m_nCPUFeatures; };
- PROCESSOR_TYPE GetType() const { return m_nType; };
- int GetProcessorNumber();
-
-private:
- int m_nCPUFeatures;
- PROCESSOR_TYPE m_nType;
-};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
deleted file mode 100644
index dda150c79..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
+++ /dev/null
@@ -1,773 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <d3dx9.h>
-#include <dxva2api.h>
-#include <evr.h>
-#include "moreuuids.h"
-#include "DXVADecoderH264.h"
-#include "DXVADecoderVC1.h"
-#include "DXVADecoderMpeg2.h"
-#include "MPCVideoDecFilter.h"
-#include "VideoDecDXVAAllocator.h"
-#include "FfmpegContext.h"
-
-#define MAX_RETRY_ON_PENDING 50
-#define DO_DXVA_PENDING_LOOP(x) \
- nTry = 0; \
- while (FAILED(hr = x) && nTry < MAX_RETRY_ON_PENDING) { \
- if (hr != E_PENDING) \
- break; \
- Sleep(3); \
- nTry++; \
- }
-
-CDXVADecoder::CDXVADecoder(CMPCVideoDecFilter* pFilter,
- IAMVideoAccelerator* pAMVideoAccelerator,
- DXVAMode nMode,
- int nPicEntryNumber)
-{
- m_nEngine = ENGINE_DXVA1;
- m_pAMVideoAccelerator = pAMVideoAccelerator;
- m_dwBufferIndex = 0;
- m_nMaxWaiting = 3;
-
- Init(pFilter, nMode, nPicEntryNumber);
-}
-
-CDXVADecoder::CDXVADecoder(CMPCVideoDecFilter* pFilter,
- IDirectXVideoDecoder* pDirectXVideoDec,
- DXVAMode nMode,
- int nPicEntryNumber,
- DXVA2_ConfigPictureDecode* pDXVA2Config)
-{
- m_nEngine = ENGINE_DXVA2;
- m_pDirectXVideoDec = pDirectXVideoDec;
- m_dwBufferIndex = 0;
- m_nMaxWaiting = 3;
- memcpy(&m_DXVA2Config, pDXVA2Config, sizeof(DXVA2_ConfigPictureDecode));
-
- Init(pFilter, nMode, nPicEntryNumber);
-};
-
-CDXVADecoder::~CDXVADecoder()
-{
- SAFE_DELETE_ARRAY(m_pPictureStore);
- SAFE_DELETE_ARRAY(m_ExecuteParams.pCompressedBuffers);
-}
-
-void CDXVADecoder::Init(CMPCVideoDecFilter* pFilter, DXVAMode nMode, int nPicEntryNumber)
-{
- m_pFilter = pFilter;
- m_nMode = nMode;
- m_nPicEntryNumber = nPicEntryNumber;
- m_pPictureStore = DEBUG_NEW PICTURE_STORE[nPicEntryNumber];
- m_dwNumBuffersInfo = 0;
- m_bNeedChangeAspect = true;
-
- ZeroMemory(&m_DXVA1Config, sizeof(m_DXVA1Config));
- ZeroMemory(&m_DXVA1BufferDesc, sizeof(m_DXVA1BufferDesc));
- m_DXVA1Config.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
- m_DXVA1Config.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
- m_DXVA1Config.guidConfigResidDiffEncryption = DXVA_NoEncrypt;
- m_DXVA1Config.bConfigBitstreamRaw = 2;
-
- ZeroMemory(&m_DXVA1BufferInfo, sizeof(m_DXVA1BufferInfo));
- ZeroMemory(&m_ExecuteParams, sizeof(m_ExecuteParams));
- Flush();
-}
-
-// === Public functions
-void CDXVADecoder::AllocExecuteParams(int nSize)
-{
- m_ExecuteParams.pCompressedBuffers = DEBUG_NEW DXVA2_DecodeBufferDesc[nSize];
-
- for (int i = 0; i < nSize; i++) {
- ZeroMemory(&m_ExecuteParams.pCompressedBuffers[i], sizeof(DXVA2_DecodeBufferDesc));
- }
-}
-
-void CDXVADecoder::SetExtraData(BYTE* pDataIn, UINT nSize)
-{
- // Extradata is codec dependant
- UNREFERENCED_PARAMETER(pDataIn);
- UNREFERENCED_PARAMETER(nSize);
-}
-
-void CDXVADecoder::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
-{
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
-}
-
-void CDXVADecoder::Flush()
-{
- TRACE(_T("CDXVADecoder::Flush\n"));
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- m_pPictureStore[i].bRefPicture = false;
- m_pPictureStore[i].bInUse = false;
- m_pPictureStore[i].bDisplayed = false;
- m_pPictureStore[i].pSample = nullptr;
- m_pPictureStore[i].nCodecSpecific = -1;
- m_pPictureStore[i].dwDisplayCount = 0;
- }
-
- m_nWaitingPics = 0;
- m_bFlushed = true;
- m_nFieldSurface = -1;
- m_dwDisplayCount = 1;
- m_pFieldSample = nullptr;
-}
-
-HRESULT CDXVADecoder::ConfigureDXVA1()
-{
- HRESULT hr = S_FALSE;
- DXVA_ConfigPictureDecode ConfigRequested;
-
- if (m_pAMVideoAccelerator) {
- ZeroMemory(&ConfigRequested, sizeof(ConfigRequested));
- ConfigRequested.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
- ConfigRequested.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
- ConfigRequested.guidConfigResidDiffEncryption = DXVA_NoEncrypt;
- ConfigRequested.bConfigBitstreamRaw = 2;
-
- writeDXVA_QueryOrReplyFunc(&ConfigRequested.dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_PROBE_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
- hr = m_pAMVideoAccelerator->Execute(ConfigRequested.dwFunction, &ConfigRequested, sizeof(DXVA_ConfigPictureDecode), &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), 0, nullptr);
-
- // Copy to DXVA2 structure (simplify code based on accelerator config)
- m_DXVA2Config.guidConfigBitstreamEncryption = m_DXVA1Config.guidConfigBitstreamEncryption;
- m_DXVA2Config.guidConfigMBcontrolEncryption = m_DXVA1Config.guidConfigMBcontrolEncryption;
- m_DXVA2Config.guidConfigResidDiffEncryption = m_DXVA1Config.guidConfigResidDiffEncryption;
- m_DXVA2Config.ConfigBitstreamRaw = m_DXVA1Config.bConfigBitstreamRaw;
- m_DXVA2Config.ConfigMBcontrolRasterOrder = m_DXVA1Config.bConfigMBcontrolRasterOrder;
- m_DXVA2Config.ConfigResidDiffHost = m_DXVA1Config.bConfigResidDiffHost;
- m_DXVA2Config.ConfigSpatialResid8 = m_DXVA1Config.bConfigSpatialResid8;
- m_DXVA2Config.ConfigResid8Subtraction = m_DXVA1Config.bConfigResid8Subtraction;
- m_DXVA2Config.ConfigSpatialHost8or9Clipping = m_DXVA1Config.bConfigSpatialHost8or9Clipping;
- m_DXVA2Config.ConfigSpatialResidInterleaved = m_DXVA1Config.bConfigSpatialResidInterleaved;
- m_DXVA2Config.ConfigIntraResidUnsigned = m_DXVA1Config.bConfigIntraResidUnsigned;
- m_DXVA2Config.ConfigResidDiffAccelerator = m_DXVA1Config.bConfigResidDiffAccelerator;
- m_DXVA2Config.ConfigHostInverseScan = m_DXVA1Config.bConfigHostInverseScan;
- m_DXVA2Config.ConfigSpecificIDCT = m_DXVA1Config.bConfigSpecificIDCT;
- m_DXVA2Config.Config4GroupedCoefs = m_DXVA1Config.bConfig4GroupedCoefs;
-
- if (SUCCEEDED(hr)) {
- writeDXVA_QueryOrReplyFunc(&m_DXVA1Config.dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
- hr = m_pAMVideoAccelerator->Execute(m_DXVA1Config.dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), &ConfigRequested, sizeof(DXVA_ConfigPictureDecode), 0, nullptr);
-
- // TODO : check config!
- //ASSERT (ConfigRequested.bConfigBitstreamRaw == 2);
-
- AMVAUncompDataInfo DataInfo;
- DWORD dwNum = COMP_BUFFER_COUNT;
- DataInfo.dwUncompWidth = m_pFilter->PictWidthRounded();
- DataInfo.dwUncompHeight = m_pFilter->PictHeightRounded();
- memcpy(&DataInfo.ddUncompPixelFormat, m_pFilter->GetPixelFormat(), sizeof(DDPIXELFORMAT));
- hr = m_pAMVideoAccelerator->GetCompBufferInfo(m_pFilter->GetDXVADecoderGuid(), &DataInfo, &dwNum, m_ComBufferInfo);
- }
- }
- return hr;
-}
-
-CDXVADecoder* CDXVADecoder::CreateDecoder(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, int nPicEntryNumber)
-{
- CDXVADecoder* pDecoder = nullptr;
-
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
- pDecoder = DEBUG_NEW CDXVADecoderH264(pFilter, pAMVideoAccelerator, H264_VLD, nPicEntryNumber);
- } else if (*guidDecoder == DXVA2_ModeVC1_D) {
- pDecoder = DEBUG_NEW CDXVADecoderVC1(pFilter, pAMVideoAccelerator, VC1_VLD, nPicEntryNumber);
- } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
- pDecoder = DEBUG_NEW CDXVADecoderMpeg2(pFilter, pAMVideoAccelerator, MPEG2_VLD, nPicEntryNumber);
- } else {
- ASSERT(FALSE); // Unknown decoder !!
- }
-
- return pDecoder;
-}
-
-CDXVADecoder* CDXVADecoder::CreateDecoder(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, const GUID* guidDecoder, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
-{
- CDXVADecoder* pDecoder = nullptr;
-
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo)) {
- pDecoder = DEBUG_NEW CDXVADecoderH264(pFilter, pDirectXVideoDec, H264_VLD, nPicEntryNumber, pDXVA2Config);
- } else if (*guidDecoder == DXVA2_ModeVC1_D) {
- pDecoder = DEBUG_NEW CDXVADecoderVC1(pFilter, pDirectXVideoDec, VC1_VLD, nPicEntryNumber, pDXVA2Config);
- } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
- pDecoder = DEBUG_NEW CDXVADecoderMpeg2(pFilter, pDirectXVideoDec, MPEG2_VLD, nPicEntryNumber, pDXVA2Config);
- } else {
- ASSERT(FALSE); // Unknown decoder !!
- }
-
- return pDecoder;
-}
-
-// === DXVA functions
-
-HRESULT CDXVADecoder::AddExecuteBuffer(DWORD CompressedBufferType, UINT nSize, void* pBuffer, UINT* pRealSize)
-{
- HRESULT hr = E_INVALIDARG;
- DWORD dwNumMBs = 0;
- BYTE* pDXVABuffer;
-
- //if (CompressedBufferType != DXVA2_PictureParametersBufferType && CompressedBufferType != DXVA2_InverseQuantizationMatrixBufferType)
- // dwNumMBs = FFGetMBNumber (m_pFilter->GetAVCtx());
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- DWORD dwTypeIndex;
- LONG lStride;
- dwTypeIndex = GetDXVA1CompressedType(CompressedBufferType);
-
- //TRACE(_T("Fill : %d - %d\n"), dwTypeIndex, m_dwBufferIndex);
- hr = m_pAMVideoAccelerator->GetBuffer(dwTypeIndex, m_dwBufferIndex, FALSE, (void**)&pDXVABuffer, &lStride);
- ASSERT(SUCCEEDED(hr));
-
- if (SUCCEEDED(hr)) {
- if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
- CopyBitstream(pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
- }
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
- m_DXVA1BufferInfo[m_dwNumBuffersInfo].dwDataSize = nSize;
-
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwTypeIndex = dwTypeIndex;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwBufferIndex = m_dwBufferIndex;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwDataSize = nSize;
- m_DXVA1BufferDesc[m_dwNumBuffersInfo].dwNumMBsInBuffer = dwNumMBs;
-
- m_dwNumBuffersInfo++;
- }
- break;
-
- case ENGINE_DXVA2:
- UINT nDXVASize;
- hr = m_pDirectXVideoDec->GetBuffer(CompressedBufferType, (void**)&pDXVABuffer, &nDXVASize);
- ASSERT(nSize <= nDXVASize);
-
- if (SUCCEEDED(hr) && (nSize <= nDXVASize)) {
- if (CompressedBufferType == DXVA2_BitStreamDateBufferType) {
- CopyBitstream(pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
- }
-
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].CompressedBufferType = CompressedBufferType;
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].DataSize = nSize;
- m_ExecuteParams.pCompressedBuffers[m_ExecuteParams.NumCompBuffers].NumMBsInBuffer = dwNumMBs;
- m_ExecuteParams.NumCompBuffers++;
-
- }
- break;
- default:
- ASSERT(FALSE);
- break;
- }
- if (pRealSize) {
- *pRealSize = nSize;
- }
-
- return hr;
-}
-
-HRESULT CDXVADecoder::GetDeliveryBuffer(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, IMediaSample** ppSampleToDeliver)
-{
- HRESULT hr;
- CComPtr<IMediaSample> pNewSample;
-
- // Change aspect ratio for DXVA2
- if (m_nEngine == ENGINE_DXVA2) {
- if (m_bNeedChangeAspect) {
- m_pFilter->UpdateAspectRatio();
- m_pFilter->ReconnectOutput(m_pFilter->PictWidthRounded(), m_pFilter->PictHeightRounded(), true, m_pFilter->PictWidth(), m_pFilter->PictHeight());
- }
- }
- hr = m_pFilter->GetOutputPin()->GetDeliveryBuffer(&pNewSample, 0, 0, 0);
-
- if (SUCCEEDED(hr)) {
- pNewSample->SetTime(&rtStart, &rtStop);
- pNewSample->SetMediaTime(nullptr, nullptr);
- *ppSampleToDeliver = pNewSample.Detach();
- }
- return hr;
-}
-
-HRESULT CDXVADecoder::Execute()
-{
- HRESULT hr = E_INVALIDARG;
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- DWORD dwFunction;
- HRESULT hr2;
-
- //writeDXVA_QueryOrReplyFunc(&dwFunction, DXVA_QUERYORREPLYFUNCFLAG_DECODER_LOCK_QUERY, DXVA_PICTURE_DECODING_FUNCTION);
- //hr = m_pAMVideoAccelerator->Execute (dwFunction, &m_DXVA1Config, sizeof(DXVA_ConfigPictureDecode), nullptr, 0, m_dwNumBuffersInfo, m_DXVA1BufferInfo);
-
- DWORD dwResult;
- dwFunction = 0x01000000;
- hr = m_pAMVideoAccelerator->Execute(dwFunction, m_DXVA1BufferDesc, sizeof(DXVA_BufferDescription) * m_dwNumBuffersInfo, &dwResult, sizeof(dwResult), m_dwNumBuffersInfo, m_DXVA1BufferInfo);
- ASSERT(SUCCEEDED(hr));
-
- for (DWORD i = 0; i < m_dwNumBuffersInfo; i++) {
- hr2 = m_pAMVideoAccelerator->ReleaseBuffer(m_DXVA1BufferInfo[i].dwTypeIndex, m_DXVA1BufferInfo[i].dwBufferIndex);
- ASSERT(SUCCEEDED(hr2));
- }
-
- m_dwNumBuffersInfo = 0;
- break;
- case ENGINE_DXVA2:
-
- for (DWORD i = 0; i < m_ExecuteParams.NumCompBuffers; i++) {
- hr2 = m_pDirectXVideoDec->ReleaseBuffer(m_ExecuteParams.pCompressedBuffers[i].CompressedBufferType);
- ASSERT(SUCCEEDED(hr2));
- }
-
- hr = m_pDirectXVideoDec->Execute(&m_ExecuteParams);
- m_ExecuteParams.NumCompBuffers = 0;
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- return hr;
-}
-
-HRESULT CDXVADecoder::QueryStatus(PVOID LPDXVAStatus, UINT nSize)
-{
- HRESULT hr = E_INVALIDARG;
- DXVA2_DecodeExecuteParams ExecuteParams;
- DXVA2_DecodeExtensionData ExtensionData;
- DWORD dwFunction = 0x07000000;
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- hr = m_pAMVideoAccelerator->Execute(dwFunction, nullptr, 0, LPDXVAStatus, nSize, 0, nullptr);
- break;
-
- case ENGINE_DXVA2:
- ZeroMemory(&ExecuteParams, sizeof(ExecuteParams));
- ZeroMemory(&ExtensionData, sizeof(ExtensionData));
- ExecuteParams.pExtensionData = &ExtensionData;
- ExtensionData.pPrivateOutputData = LPDXVAStatus;
- ExtensionData.PrivateOutputDataSize = nSize;
- ExtensionData.Function = 7;
- hr = m_pDirectXVideoDec->Execute(&ExecuteParams);
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- return hr;
-}
-
-DWORD CDXVADecoder::GetDXVA1CompressedType(DWORD dwDXVA2CompressedType)
-{
- if (dwDXVA2CompressedType <= DXVA2_BitStreamDateBufferType) {
- return dwDXVA2CompressedType + 1;
- } else {
- switch (dwDXVA2CompressedType) {
- case DXVA2_MotionVectorBuffer:
- return DXVA_MOTION_VECTOR_BUFFER;
- break;
- case DXVA2_FilmGrainBuffer:
- return DXVA_FILM_GRAIN_BUFFER;
- break;
- default:
- ASSERT(FALSE);
- return DXVA_COMPBUFFER_TYPE_THAT_IS_NOT_USED;
- }
- }
-}
-
-HRESULT CDXVADecoder::FindFreeDXVA1Buffer(DWORD dwTypeIndex, DWORD& dwBufferIndex)
-{
- HRESULT hr = E_INVALIDARG;
- int nTry = 0;
-
- dwBufferIndex = 0; //(dwBufferIndex + 1) % m_ComBufferInfo[DXVA_PICTURE_DECODE_BUFFER].dwNumCompBuffers;
- DO_DXVA_PENDING_LOOP(m_pAMVideoAccelerator->QueryRenderStatus((DWORD) - 1, dwBufferIndex, 0));
-
- return hr;
-}
-
-HRESULT CDXVADecoder::BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliver)
-{
- HRESULT hr = E_INVALIDARG;
- int nTry = 0;
-
- for (int i = 0; i < 20; i++) {
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- AMVABeginFrameInfo BeginFrameInfo;
-
- BeginFrameInfo.dwDestSurfaceIndex = nSurfaceIndex;
- BeginFrameInfo.dwSizeInputData = sizeof(nSurfaceIndex);
- BeginFrameInfo.pInputData = &nSurfaceIndex;
- BeginFrameInfo.dwSizeOutputData = 0;
- BeginFrameInfo.pOutputData = nullptr;
-
- DO_DXVA_PENDING_LOOP(m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo));
-
- ASSERT(SUCCEEDED(hr));
- if (SUCCEEDED(hr)) {
- hr = FindFreeDXVA1Buffer((DWORD) - 1, m_dwBufferIndex);
- }
- break;
-
- case ENGINE_DXVA2: {
- CComQIPtr<IMFGetService> pSampleService;
- CComPtr<IDirect3DSurface9> pDecoderRenderTarget;
- pSampleService = pSampleToDeliver;
- if (pSampleService) {
- hr = pSampleService->GetService(MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**) &pDecoderRenderTarget);
- if (SUCCEEDED(hr)) {
- DO_DXVA_PENDING_LOOP(m_pDirectXVideoDec->BeginFrame(pDecoderRenderTarget, nullptr));
- }
- }
- }
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- // For slow accelerator wait a little...
- if (SUCCEEDED(hr)) {
- break;
- }
- Sleep(1);
- }
-
- return hr;
-}
-
-HRESULT CDXVADecoder::EndFrame(int nSurfaceIndex)
-{
- HRESULT hr = E_INVALIDARG;
- DWORD dwDummy = nSurfaceIndex;
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- AMVAEndFrameInfo EndFrameInfo;
-
- EndFrameInfo.dwSizeMiscData = sizeof(dwDummy); // TODO : usefull ??
- EndFrameInfo.pMiscData = &dwDummy;
- hr = m_pAMVideoAccelerator->EndFrame(&EndFrameInfo);
- ASSERT(SUCCEEDED(hr));
- break;
-
- case ENGINE_DXVA2:
- hr = m_pDirectXVideoDec->EndFrame(nullptr);
- break;
- default:
- ASSERT(FALSE);
- break;
- }
-
- return hr;
-}
-
-// === Picture store functions
-bool CDXVADecoder::AddToStore(int nSurfaceIndex,
- IMediaSample* pSample,
- bool bRefPicture,
- REFERENCE_TIME rtStart,
- REFERENCE_TIME rtStop,
- bool bIsField,
- FF_FIELD_TYPE nFieldType,
- FF_SLICE_TYPE nSliceType,
- int nCodecSpecific)
-{
- if (bIsField && (m_nFieldSurface == -1)) {
- m_nFieldSurface = nSurfaceIndex;
- m_pFieldSample = pSample;
- m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
- m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
- m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
- m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
- return false;
- } else {
- //TRACE(_T("Add Stor: [%10I64d - %10I64d], Ind = %d, Codec=%d\n"), rtStart, rtStop, nSurfaceIndex, nCodecSpecific);
- /*
- ASSERT(m_pPictureStore[nSurfaceIndex].pSample == nullptr);
- ASSERT(!m_pPictureStore[nSurfaceIndex].bInUse);
- ASSERT((nSurfaceIndex < m_nPicEntryNumber) && (m_pPictureStore[nSurfaceIndex].pSample == nullptr));
- */
-
- m_pPictureStore[nSurfaceIndex].bRefPicture = bRefPicture;
- m_pPictureStore[nSurfaceIndex].bInUse = true;
- m_pPictureStore[nSurfaceIndex].bDisplayed = false;
- m_pPictureStore[nSurfaceIndex].pSample = pSample;
- m_pPictureStore[nSurfaceIndex].nSliceType = nSliceType;
-
- if (!bIsField) {
- m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
- m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
- m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
- m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
- }
-
- m_nFieldSurface = -1;
- m_nWaitingPics++;
- return true;
- }
-}
-
-void CDXVADecoder::UpdateStore(int nSurfaceIndex, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- ASSERT((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse && !m_pPictureStore[nSurfaceIndex].bDisplayed);
-
- m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
- m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
-}
-
-void CDXVADecoder::RemoveRefFrame(int nSurfaceIndex)
-{
- //ASSERT ((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse);
-
- m_pPictureStore[nSurfaceIndex].bRefPicture = false;
- if (m_pPictureStore[nSurfaceIndex].bDisplayed) {
- FreePictureSlot(nSurfaceIndex);
- }
-}
-
-int CDXVADecoder::FindOldestFrame()
-{
- REFERENCE_TIME rtMin = _I64_MAX;
- int nPos = -1;
-
- // TODO : find better solution...
- if (m_nWaitingPics > m_nMaxWaiting) {
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (!m_pPictureStore[i].bDisplayed && m_pPictureStore[i].bInUse && (m_pPictureStore[i].rtStart < rtMin)) {
- rtMin = m_pPictureStore[i].rtStart;
- nPos = i;
- }
- }
- }
- return nPos;
-}
-
-void CDXVADecoder::SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS)
-{
- if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
- AM_SAMPLE2_PROPERTIES props;
- if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
- props.dwTypeSpecificFlags &= ~0x7f;
-
- FF_FIELD_TYPE fieldType;
- switch (m_pFilter->GetInterlacedFlag()) {
- case MPCVC_INTERLACED_PROGRESSIVE:
- fieldType = PICT_FRAME;
- break;
- case MPCVC_INTERLACED_TOP_FIELD_FIRST:
- fieldType = PICT_TOP_FIELD;
- break;
- case MPCVC_INTERLACED_BOTTOM_FIELD_FIRST:
- fieldType = PICT_BOTTOM_FIELD;
- break;
- default:
- fieldType = pPicture->n1FieldType;
- break;
- }
-
- m_pFilter->SetFrameType(fieldType);
-
- if (fieldType == PICT_FRAME) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- } else if (fieldType == PICT_TOP_FIELD) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- }
-
- switch (pPicture->nSliceType) {
- case I_TYPE:
- case SI_TYPE:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- break;
- case P_TYPE:
- case SP_TYPE:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- break;
- default:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- break;
- }
-
- pMS2->SetProperties(sizeof(props), (BYTE*)&props);
- }
- }
- pMS->SetTime(&pPicture->rtStart, &pPicture->rtStop);
-}
-
-HRESULT CDXVADecoder::DisplayNextFrame()
-{
- HRESULT hr = S_FALSE;
- CComPtr<IMediaSample> pSampleToDeliver;
- int nPicIndex = FindOldestFrame();
-
- if (nPicIndex != -1) {
- if (m_pPictureStore[nPicIndex].rtStart >= 0) {
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- // For DXVA1, query a media sample at the last time (only one in the allocator)
- hr = GetDeliveryBuffer(m_pPictureStore[nPicIndex].rtStart, m_pPictureStore[nPicIndex].rtStop, &pSampleToDeliver);
- SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], pSampleToDeliver);
- if (SUCCEEDED(hr)) {
- hr = m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
- }
- break;
- case ENGINE_DXVA2:
- // For DXVA2 media sample is in the picture store
- m_pPictureStore[nPicIndex].pSample->SetTime(&m_pPictureStore[nPicIndex].rtStart, &m_pPictureStore[nPicIndex].rtStop);
- SetTypeSpecificFlags(&m_pPictureStore[nPicIndex], m_pPictureStore[nPicIndex].pSample);
- hr = m_pFilter->GetOutputPin()->Deliver(m_pPictureStore[nPicIndex].pSample);
- break;
- }
-
-#if defined(_DEBUG) && 0
- static REFERENCE_TIME rtLast = 0;
- TRACE(_T("Deliver : %10I64d - %10I64d (Dur = %10I64d) {Delta = %10I64d} Ind = %02d Codec=%d Ref=%d\n"),
- m_pPictureStore[nPicIndex].rtStart,
- m_pPictureStore[nPicIndex].rtStop,
- m_pPictureStore[nPicIndex].rtStop - m_pPictureStore[nPicIndex].rtStart,
- m_pPictureStore[nPicIndex].rtStart - rtLast, nPicIndex,
- m_pPictureStore[nPicIndex].nCodecSpecific,
- m_pPictureStore[nPicIndex].bRefPicture);
- rtLast = m_pPictureStore[nPicIndex].rtStart;
-#endif
- }
- m_bNeedChangeAspect = false;
-
- m_pPictureStore[nPicIndex].bDisplayed = true;
- if (!m_pPictureStore[nPicIndex].bRefPicture) {
- FreePictureSlot(nPicIndex);
- }
- }
-
- return hr;
-}
-
-HRESULT CDXVADecoder::GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppSampleToDeliver, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- HRESULT hr = E_UNEXPECTED;
- int nPos = -1;
- DWORD dwMinDisplay = MAXDWORD;
-
- if (m_nFieldSurface != -1) {
- nSurfaceIndex = m_nFieldSurface;
- *ppSampleToDeliver = m_pFieldSample.Detach();
- return S_FALSE;
- }
-
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (!m_pPictureStore[i].bInUse && m_pPictureStore[i].dwDisplayCount < dwMinDisplay) {
- dwMinDisplay = m_pPictureStore[i].dwDisplayCount;
- nPos = i;
- }
- }
-
- if (nPos != -1) {
- nSurfaceIndex = nPos;
- return S_OK;
- }
-
- // Ho ho...
- ASSERT(FALSE);
- Flush();
- break;
- case ENGINE_DXVA2:
- CComPtr<IMediaSample> pNewSample;
- CComQIPtr<IMPCDXVA2Sample> pMPCDXVA2Sample;
- // TODO : test IDirect3DDeviceManager9::TestDevice !!!
- if (SUCCEEDED(hr = GetDeliveryBuffer(rtStart, rtStop, &pNewSample))) {
- pMPCDXVA2Sample = pNewSample;
- nSurfaceIndex = pMPCDXVA2Sample ? pMPCDXVA2Sample->GetDXSurfaceId() : 0;
- *ppSampleToDeliver = pNewSample.Detach();
- }
- break;
- }
-
- return hr;
-}
-
-void CDXVADecoder::FreePictureSlot(int nSurfaceIndex)
-{
- m_pPictureStore[nSurfaceIndex].dwDisplayCount = m_dwDisplayCount++;
- m_pPictureStore[nSurfaceIndex].bInUse = false;
- m_pPictureStore[nSurfaceIndex].bDisplayed = false;
- m_pPictureStore[nSurfaceIndex].pSample = nullptr;
- m_pPictureStore[nSurfaceIndex].nCodecSpecific = -1;
- m_nWaitingPics--;
-}
-
-BYTE CDXVADecoder::GetConfigResidDiffAccelerator()
-{
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- return m_DXVA1Config.bConfigResidDiffAccelerator;
- case ENGINE_DXVA2:
- return m_DXVA2Config.ConfigResidDiffAccelerator;
- }
- return 0;
-}
-
-BYTE CDXVADecoder::GetConfigIntraResidUnsigned()
-{
- switch (m_nEngine) {
- case ENGINE_DXVA1:
- return m_DXVA1Config.bConfigIntraResidUnsigned;
- case ENGINE_DXVA2:
- return m_DXVA2Config.ConfigIntraResidUnsigned;
- }
- return 0;
-}
-
-void CDXVADecoder::EndOfStream()
-{
- CComPtr<IMediaSample> pSampleToDeliver;
-
- for (int nPicIndex = 0; nPicIndex < m_nPicEntryNumber; nPicIndex++) {
- PICTURE_STORE& pic = m_pPictureStore[nPicIndex];
- if (pic.bInUse && !pic.bDisplayed && pic.rtStart != _I64_MIN) {
- switch (m_nEngine) {
- // TODO - need check under WinXP on DXVA1
- /*
- case ENGINE_DXVA1:
- if (SUCCEEDED (GetDeliveryBuffer (pic.rtStart, pic.rtStop, &pSampleToDeliver)) && pSampleToDeliver) {
- m_pAMVideoAccelerator->DisplayFrame(nPicIndex, pSampleToDeliver);
- }
- break;
- */
- case ENGINE_DXVA2:
- SetTypeSpecificFlags(&pic, pic.pSample);
- m_pFilter->GetOutputPin()->Deliver(pic.pSample);
- break;
- }
- }
- }
-}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.h b/src/filters/transform/MPCVideoDec/DXVADecoder.h
deleted file mode 100644
index 638432a03..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva2api.h>
-#include <videoacc.h>
-#include "../../../DSUtil/DSUtil.h"
-
-typedef enum {
- ENGINE_DXVA1,
- ENGINE_DXVA2
-} DXVA_ENGINE;
-
-typedef enum {
- H264_VLD,
- VC1_VLD,
- MPEG2_VLD
-} DXVAMode;
-
-typedef enum {
- I_TYPE = 1, ///< Intra
- P_TYPE = 2, ///< Predicted
- B_TYPE = 3, ///< Bi-dir predicted
- S_TYPE = 4, ///< S(GMC)-VOP MPEG4
- SI_TYPE = 5, ///< Switching Intra
- SP_TYPE = 6, ///< Switching Predicted
- BI_TYPE = 7
-} FF_SLICE_TYPE;
-
-typedef struct {
- bool bRefPicture; // True if reference picture
- bool bInUse; // Slot in use
- bool bDisplayed; // True if picture have been presented
- CComPtr<IMediaSample> pSample; // Only for DXVA2 !
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
- FF_FIELD_TYPE n1FieldType; // Top or bottom for the 1st field
- FF_SLICE_TYPE nSliceType;
- int nCodecSpecific;
- DWORD dwDisplayCount;
-} PICTURE_STORE;
-
-#define MAX_COM_BUFFER 6 // Max uncompressed buffer for an Execute command (DXVA1)
-#define COMP_BUFFER_COUNT 18
-#define NO_REF_FRAME 0xFFFF
-
-class CMPCVideoDecFilter;
-
-class CDXVADecoder
-{
-public:
- // === Public functions
- virtual ~CDXVADecoder();
- DXVAMode GetMode() const { return m_nMode; };
- DXVA_ENGINE GetEngine() const { return m_nEngine; };
- void AllocExecuteParams(int nSize);
- void SetDirectXVideoDec(IDirectXVideoDecoder* pDirectXVideoDec) {
- m_pDirectXVideoDec = pDirectXVideoDec;
- };
-
- virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop) = 0;
- virtual void SetExtraData(BYTE* pDataIn, UINT nSize);
- virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
- HRESULT ConfigureDXVA1();
-
- static CDXVADecoder* CreateDecoder(CMPCVideoDecFilter* pFilter,
- IAMVideoAccelerator* pAMVideoAccelerator,
- const GUID* guidDecoder,
- int nPicEntryNumber);
- static CDXVADecoder* CreateDecoder(CMPCVideoDecFilter* pFilter,
- IDirectXVideoDecoder* pDirectXVideoDec,
- const GUID* guidDecoder,
- int nPicEntryNumber,
- DXVA2_ConfigPictureDecode* pDXVA2Config);
-
- void EndOfStream();
-
-protected:
- CDXVADecoder(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoder(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
-
- CMPCVideoDecFilter* m_pFilter;
- bool m_bFlushed;
- int m_nMaxWaiting;
-
- PICTURE_STORE* m_pPictureStore; // Store reference picture, and delayed B-frames
- int m_nPicEntryNumber; // Total number of picture in store
- int m_nWaitingPics; // Number of picture not yet displayed
-
- bool m_bNeedChangeAspect;
-
- // === DXVA functions
- HRESULT AddExecuteBuffer(DWORD CompressedBufferType, UINT nSize, void* pBuffer, UINT* pRealSize = nullptr);
- HRESULT GetDeliveryBuffer(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, IMediaSample** ppSampleToDeliver);
- HRESULT Execute();
- DWORD GetDXVA1CompressedType(DWORD dwDXVA2CompressedType);
- HRESULT FindFreeDXVA1Buffer(DWORD dwTypeIndex, DWORD& dwBufferIndex);
- HRESULT BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliver);
- HRESULT EndFrame(int nSurfaceIndex);
- HRESULT QueryStatus(PVOID LPDXVAStatus, UINT nSize);
- BYTE GetConfigIntraResidUnsigned();
- BYTE GetConfigResidDiffAccelerator();
- DXVA_ConfigPictureDecode* GetDXVA1Config() { return &m_DXVA1Config; };
- DXVA2_ConfigPictureDecode* GetDXVA2Config() { return &m_DXVA2Config; };
-
- // === Picture store functions
- bool AddToStore(int nSurfaceIndex, IMediaSample* pSample, bool bRefPicture,
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, bool bIsField,
- FF_FIELD_TYPE nFieldType, FF_SLICE_TYPE nSliceType, int nCodecSpecific);
- void UpdateStore(int nSurfaceIndex, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- void RemoveRefFrame(int nSurfaceIndex);
- HRESULT DisplayNextFrame();
- HRESULT GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppSampleToDeliver,
- REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual int FindOldestFrame();
-
-private:
- DXVAMode m_nMode;
- DXVA_ENGINE m_nEngine;
-
- CComPtr<IMediaSample> m_pFieldSample;
- int m_nFieldSurface;
-
- // === DXVA1 variables
- CComQIPtr<IAMVideoAccelerator> m_pAMVideoAccelerator;
- AMVABUFFERINFO m_DXVA1BufferInfo[MAX_COM_BUFFER];
- DXVA_BufferDescription m_DXVA1BufferDesc[MAX_COM_BUFFER];
- DWORD m_dwNumBuffersInfo;
- DXVA_ConfigPictureDecode m_DXVA1Config;
- AMVACompBufferInfo m_ComBufferInfo[COMP_BUFFER_COUNT];
- DWORD m_dwBufferIndex;
- DWORD m_dwDisplayCount;
-
- // === DXVA2 variables
- CComPtr<IDirectXVideoDecoder> m_pDirectXVideoDec;
- DXVA2_ConfigPictureDecode m_DXVA2Config;
- DXVA2_DecodeExecuteParams m_ExecuteParams;
-
- void Init(CMPCVideoDecFilter* pFilter, DXVAMode nMode, int nPicEntryNumber);
- void FreePictureSlot(int nSurfaceIndex);
- void SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS);
-};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
deleted file mode 100644
index 3c46e62e8..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "../../../DSUtil/DSUtil.h"
-#include "DXVADecoderH264.h"
-#include "MPCVideoDecFilter.h"
-#include "VideoDecDXVAAllocator.h"
-#include "ffmpeg/libavcodec/avcodec.h"
-
-#include "FfmpegContext.h"
-
-#if 0
-#define TRACE_H264 TRACE
-#else
-#define TRACE_H264 __noop
-#endif
-
-CDXVADecoderH264::CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
- : CDXVADecoder(pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
-{
- m_bUseLongSlice = (GetDXVA1Config()->bConfigBitstreamRaw != 2);
- Init();
-}
-
-CDXVADecoderH264::CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
- : CDXVADecoder(pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
-{
- m_bUseLongSlice = (m_pFilter->GetDXVA2Config()->ConfigBitstreamRaw != 2);
- Init();
-}
-
-CDXVADecoderH264::~CDXVADecoderH264()
-{
-}
-
-void CDXVADecoderH264::Init()
-{
- ZeroMemory(&m_DXVAPicParams, sizeof(m_DXVAPicParams));
- ZeroMemory(&m_DXVAPicParams, sizeof(DXVA_PicParams_H264));
- ZeroMemory(&m_pSliceLong, sizeof(DXVA_Slice_H264_Long) * MAX_SLICES);
- ZeroMemory(&m_pSliceShort, sizeof(DXVA_Slice_H264_Short) * MAX_SLICES);
-
- m_DXVAPicParams.MbsConsecutiveFlag = 1;
- if (m_pFilter->GetPCIVendor() == PCIV_Intel) {
- m_DXVAPicParams.Reserved16Bits = 0x534c;
- } else {
- m_DXVAPicParams.Reserved16Bits = 0;
- }
- m_DXVAPicParams.ContinuationFlag = 1;
- m_DXVAPicParams.Reserved8BitsA = 0;
- m_DXVAPicParams.Reserved8BitsB = 0;
- m_DXVAPicParams.MinLumaBipredSize8x8Flag = 1; // Improve accelerator performances
- m_DXVAPicParams.StatusReportFeedbackNumber = 0; // Use to report status
-
- for (int i = 0; i < 16; i++) {
- m_DXVAPicParams.RefFrameList[i].AssociatedFlag = 1;
- m_DXVAPicParams.RefFrameList[i].bPicEntry = 255;
- m_DXVAPicParams.RefFrameList[i].Index7Bits = 127;
- }
-
- m_nNALLength = 4;
- m_nMaxSlices = 0;
-
- switch (GetMode()) {
- case H264_VLD:
- AllocExecuteParams(3);
- break;
- default:
- ASSERT(FALSE);
- }
-}
-
-void CDXVADecoderH264::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
-{
- CH264Nalu Nalu;
- int nDummy;
- int nSlices = 0;
- UINT m_nSize = nSize;
- int slice_step = 1;
- int nDxvaNalLength;
-
- while (!nSlices && slice_step <= 2) {
- Nalu.SetBuffer(pBuffer, m_nSize, slice_step == 1 ? m_nNALLength : 0);
- nSize = 0;
- while (Nalu.ReadNext()) {
- switch (Nalu.GetType()) {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- // Skip the NALU if the data length is below 0
- if (Nalu.GetDataLength() < 0) {
- break;
- }
-
- // For AVC1, put startcode 0x000001
- pDXVABuffer[0] = pDXVABuffer[1] = 0;
- pDXVABuffer[2] = 1;
-
- // Copy NALU
- __try {
- memcpy(pDXVABuffer + 3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
- } __except (EXCEPTION_EXECUTE_HANDLER) {
- break;
- }
-
- // Update slice control buffer
- nDxvaNalLength = (int)Nalu.GetDataLength() + 3;
- m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
- m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
-
- nSize += nDxvaNalLength;
- pDXVABuffer += nDxvaNalLength;
- nSlices++;
- break;
- }
- }
- slice_step++;
- }
-
- // Complete with zero padding (buffer size should be a multiple of 128)
- nDummy = 128 - (nSize % 128);
-
- ZeroMemory(pDXVABuffer, nDummy);
- m_pSliceShort[nSlices - 1].SliceBytesInBuffer += nDummy;
- nSize += nDummy;
-}
-
-void CDXVADecoderH264::Flush()
-{
- ClearRefFramesList();
- m_DXVAPicParams.UsedForReferenceFlags = 0;
- m_nOutPOC = INT_MIN;
- m_nPrevOutPOC = INT_MIN;
-
- m_nfield_pic_flag = 1;
- m_nRefPicFlag = 1;
- m_nBrokenFramesFlag = 0;
- m_nBrokenFramesFlag_POC = 0;
-
- __super::Flush();
-}
-
-HRESULT CDXVADecoderH264::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- HRESULT hr = S_FALSE;
- UINT nSlices = 0;
- int nSurfaceIndex = -1;
- int nFieldType = -1;
- int nSliceType = -1;
- int nFramePOC = INT_MIN;
- int nOutPOC = INT_MIN;
- REFERENCE_TIME rtOutStart = _I64_MIN;
- CH264Nalu Nalu;
- UINT nNalOffset = 0;
- CComPtr<IMediaSample> pSampleToDeliver;
- CComQIPtr<IMPCDXVA2Sample> pDXVA2Sample;
- int slice_step = 1;
-
- if (FFH264DecodeBuffer(m_pFilter->GetAVCtx(), pDataIn, nSize, &nFramePOC, &nOutPOC, &rtOutStart) == -1) {
- return S_FALSE;
- }
-
- while (!nSlices && slice_step <= 2) {
- Nalu.SetBuffer(pDataIn, nSize, slice_step == 1 ? m_nNALLength : 0);
- while (Nalu.ReadNext()) {
- switch (Nalu.GetType()) {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- if (m_bUseLongSlice) {
- m_pSliceLong[nSlices].BSNALunitDataLocation = nNalOffset;
- m_pSliceLong[nSlices].SliceBytesInBuffer = (UINT)Nalu.GetDataLength() + 3; //.GetRoundedDataLength();
- m_pSliceLong[nSlices].slice_id = nSlices;
- FF264UpdateRefFrameSliceLong(&m_DXVAPicParams, &m_pSliceLong[nSlices], m_pFilter->GetAVCtx());
-
- if (nSlices > 0) {
- m_pSliceLong[nSlices - 1].NumMbsForSlice = m_pSliceLong[nSlices].NumMbsForSlice = m_pSliceLong[nSlices].first_mb_in_slice - m_pSliceLong[nSlices - 1].first_mb_in_slice;
- }
- }
- nSlices++;
- nNalOffset += (UINT)(Nalu.GetDataLength() + 3);
- if (nSlices > MAX_SLICES) {
- break;
- }
- break;
- }
- }
- slice_step++;
- }
-
- if (!nSlices) {
- return S_FALSE;
- }
-
- m_nMaxWaiting = min(max(m_DXVAPicParams.num_ref_frames, 3), 8);
-
- // If parsing fail (probably no PPS/SPS), continue anyway it may arrived later (happen on truncated streams)
- if (FAILED(FFH264BuildPicParams(&m_DXVAPicParams, &m_DXVAScalingMatrix, &nFieldType, &nSliceType, m_pFilter->GetAVCtx(), m_pFilter->GetPCIVendor()))) {
- return S_FALSE;
- }
-
- TRACE_H264("CDXVADecoderH264::DecodeFrame() : nFramePOC = %11d, nOutPOC = %11d[%11d], [%d - %d], rtOutStart = [%20I64d]\n", nFramePOC, nOutPOC, m_nOutPOC, m_DXVAPicParams.field_pic_flag, m_DXVAPicParams.RefPicFlag, rtOutStart);
-
- // Wait I frame after a flush
- if (m_bFlushed && !m_DXVAPicParams.IntraPicFlag) {
- TRACE_H264("CDXVADecoderH264::DecodeFrame() : Flush - wait I frame\n");
- m_nBrokenFramesFlag = 0;
- m_nBrokenFramesFlag_POC = 0;
- m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag;
- m_nRefPicFlag = m_DXVAPicParams.RefPicFlag;
- m_nPrevOutPOC = INT_MIN;
- return S_FALSE;
- }
-
- /* Disabled, because that causes serious problems.
- // Some magic code for detecting the incorrect decoding of interlaced frames ...
- // TODO : necessary to make it better, and preferably on the side of ffmpeg ...
- if (m_nfield_pic_flag && m_nfield_pic_flag == m_DXVAPicParams.field_pic_flag && m_nRefPicFlag == m_DXVAPicParams.RefPicFlag) {
- if (m_nPrevOutPOC == m_nOutPOC && m_nOutPOC == INT_MIN) {
- m_nBrokenFramesFlag_POC++;
- }
- m_nBrokenFramesFlag++;
- } else {
- m_nBrokenFramesFlag = 0;
- m_nBrokenFramesFlag_POC = 0;
- }
- m_nfield_pic_flag = m_DXVAPicParams.field_pic_flag;
- m_nRefPicFlag = m_DXVAPicParams.RefPicFlag;
- m_nPrevOutPOC = m_nOutPOC;
-
- if (m_nBrokenFramesFlag > 4) {
- m_nBrokenFramesFlag = 0;
- if (m_nBrokenFramesFlag_POC > 1) {
- TRACE_H264("CDXVADecoderH264::DecodeFrame() : Detected broken frames ... flush data\n");
- m_nBrokenFramesFlag_POC = 0;
- Flush();
- return S_FALSE;
- }
- }
- //
- */
-
- CHECK_HR_TRACE(GetFreeSurfaceIndex(nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop));
- FFH264SetCurrentPicture(nSurfaceIndex, &m_DXVAPicParams, m_pFilter->GetAVCtx());
-
- CHECK_HR_TRACE(BeginFrame(nSurfaceIndex, pSampleToDeliver));
-
- m_DXVAPicParams.StatusReportFeedbackNumber++;
-
- // Send picture parameters
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_DXVAPicParams), &m_DXVAPicParams));
- CHECK_HR_TRACE(Execute());
-
- // Add bitstream, slice control and quantization matrix
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
-
- if (m_bUseLongSlice) {
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Long)*nSlices, m_pSliceLong));
- } else {
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Short)*nSlices, m_pSliceShort));
- }
-
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_InverseQuantizationMatrixBufferType, sizeof(DXVA_Qmatrix_H264), (void*)&m_DXVAScalingMatrix));
-
- // Decode bitstream
- CHECK_HR_TRACE(Execute());
- CHECK_HR_TRACE(EndFrame(nSurfaceIndex));
-
-#if defined(_DEBUG) && 0
- DisplayStatus();
-#endif
-
- bool bAdded = AddToStore(nSurfaceIndex, pSampleToDeliver, m_DXVAPicParams.RefPicFlag, rtStart, rtStop,
- m_DXVAPicParams.field_pic_flag, (FF_FIELD_TYPE)nFieldType,
- (FF_SLICE_TYPE)nSliceType, nFramePOC);
-
- FFH264UpdateRefFramesList(&m_DXVAPicParams, m_pFilter->GetAVCtx());
- ClearUnusedRefFrames();
-
- if (bAdded) {
- hr = DisplayNextFrame();
- }
-
- if (nOutPOC != INT_MIN) {
- m_nOutPOC = nOutPOC;
- m_rtOutStart = rtOutStart;
- }
-
- m_bFlushed = false;
- return hr;
-}
-
-void CDXVADecoderH264::RemoveUndisplayedFrame(int nPOC)
-{
- // Find frame with given POC, and free the slot
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bInUse && m_pPictureStore[i].nCodecSpecific == nPOC) {
- m_pPictureStore[i].bDisplayed = true;
- RemoveRefFrame(i);
- return;
- }
- }
-}
-
-void CDXVADecoderH264::ClearUnusedRefFrames()
-{
- // Remove old reference frames (not anymore a short or long ref frame)
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bRefPicture && m_pPictureStore[i].bDisplayed) {
- if (!FFH264IsRefFrameInUse(i, m_pFilter->GetAVCtx())) {
- RemoveRefFrame(i);
- }
- }
- }
-}
-
-void CDXVADecoderH264::SetExtraData(BYTE* pDataIn, UINT nSize)
-{
- AVCodecContext* pAVCtx = m_pFilter->GetAVCtx();
- m_nNALLength = pAVCtx->nal_length_size;
-
- FFH264DecodeBuffer(pAVCtx, pDataIn, nSize, nullptr, nullptr, nullptr);
- FFH264SetDxvaSliceLong(pAVCtx, m_pSliceLong);
-}
-
-void CDXVADecoderH264::ClearRefFramesList()
-{
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bInUse) {
- m_pPictureStore[i].bDisplayed = true;
- RemoveRefFrame(i);
- }
- }
-}
-
-HRESULT CDXVADecoderH264::DisplayStatus()
-{
- HRESULT hr = E_INVALIDARG;
- DXVA_Status_H264 Status;
-
- ZeroMemory(&Status, sizeof(Status));
- CHECK_HR_TRACE(CDXVADecoder::QueryStatus(&Status, sizeof(Status)));
-
- TRACE_H264("CDXVADecoderH264::DisplayStatus() : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
- Status.StatusReportFeedbackNumber,
- Status.bBufType,
- Status.bStatus,
- Status.wNumMbsAffected);
-
- return hr;
-}
-
-int CDXVADecoderH264::FindOldestFrame()
-{
- int nPos = -1;
- REFERENCE_TIME rtPos = _I64_MAX;
-
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (m_pPictureStore[i].bInUse && !m_pPictureStore[i].bDisplayed) {
- if ((m_pPictureStore[i].nCodecSpecific == m_nOutPOC) && (m_pPictureStore[i].rtStart < rtPos) && (m_pPictureStore[i].rtStart >= m_rtOutStart)) {
- nPos = i;
- rtPos = m_pPictureStore[i].rtStart;
- }
- }
- }
-
- if (nPos != -1) {
- m_pPictureStore[nPos].rtStart = m_rtOutStart;
- m_pFilter->UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
- m_pFilter->ReorderBFrames(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
- }
-
- return nPos;
-}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.h b/src/filters/transform/MPCVideoDec/DXVADecoderH264.h
deleted file mode 100644
index 5cf3a4fb7..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-#include "DXVADecoder.h"
-
-#define MAX_SLICES 16 // Also defined in libavcodec/h264.h
-
-class CDXVADecoderH264 : public CDXVADecoder
-{
-public:
- CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoderH264(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
- virtual ~CDXVADecoderH264();
-
- virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual void SetExtraData(BYTE* pDataIn, UINT nSize);
- virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
-
-protected:
- virtual int FindOldestFrame();
-
-private:
-
- DXVA_PicParams_H264 m_DXVAPicParams;
- DXVA_Qmatrix_H264 m_DXVAScalingMatrix;
- DXVA_Slice_H264_Short m_pSliceShort[MAX_SLICES];
- DXVA_Slice_H264_Long m_pSliceLong[MAX_SLICES];
- UINT m_nMaxSlices;
- int m_nNALLength;
- bool m_bUseLongSlice;
- int m_nOutPOC, m_nPrevOutPOC;
- REFERENCE_TIME m_rtOutStart;
-
- unsigned short m_nfield_pic_flag;
- unsigned short m_nRefPicFlag;
- UINT m_nBrokenFramesFlag, m_nBrokenFramesFlag_POC;
-
- // Private functions
- void Init();
- HRESULT DisplayStatus();
-
- // DXVA functions
- void RemoveUndisplayedFrame(int nPOC);
- void ClearRefFramesList();
- void ClearUnusedRefFrames();
-};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
deleted file mode 100644
index a6e7d8dd5..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * (C) 2010-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "DXVADecoderMpeg2.h"
-#include "MPCVideoDecFilter.h"
-
-#include "FfmpegContext.h"
-
-#if 0
-#define TRACE_MPEG2 TRACE
-#else
-#define TRACE_MPEG2 __noop
-#endif
-
-CDXVADecoderMpeg2::CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
- : CDXVADecoder(pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
-{
- Init();
-}
-
-CDXVADecoderMpeg2::CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
- : CDXVADecoder(pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
-{
- Init();
-}
-
-CDXVADecoderMpeg2::~CDXVADecoderMpeg2()
-{
- Flush();
-}
-
-void CDXVADecoderMpeg2::Init()
-{
- ZeroMemory(&m_PictureParams, sizeof(m_PictureParams));
- ZeroMemory(&m_SliceInfo, sizeof(m_SliceInfo));
- ZeroMemory(&m_QMatrixData, sizeof(m_QMatrixData));
-
- m_nMaxWaiting = 5;
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
- m_nSliceCount = 0;
-
- switch (GetMode()) {
- case MPEG2_VLD:
- AllocExecuteParams(4);
- break;
- default:
- ASSERT(FALSE);
- }
-}
-
-// === Public functions
-HRESULT CDXVADecoderMpeg2::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- HRESULT hr;
- int nFieldType;
- int nSliceType;
-
- FFMpeg2DecodeFrame(&m_PictureParams, &m_QMatrixData, m_SliceInfo, &m_nSliceCount, m_pFilter->GetAVCtx(),
- m_pFilter->GetFrame(), &m_nNextCodecIndex, &nFieldType, &nSliceType, pDataIn, nSize);
-
- if (m_PictureParams.bSecondField && !m_bSecondField) {
- m_bSecondField = true;
- }
-
- // Wait I frame after a flush
- if (m_bFlushed && (!m_PictureParams.bPicIntra || (m_bSecondField && m_PictureParams.bSecondField))) {
- TRACE_MPEG2("CDXVADecoderMpeg2::DecodeFrame() : Flush - wait I frame\n");
- return S_FALSE;
- }
-
- if (m_bSecondField) {
- if (!m_PictureParams.bSecondField) {
- m_rtStart = rtStart;
- m_rtStop = rtStop;
- m_pSampleToDeliver = nullptr;
- hr = GetFreeSurfaceIndex(m_nSurfaceIndex, &m_pSampleToDeliver, rtStart, rtStop);
- if (FAILED(hr)) {
- ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
- return hr;
- }
- }
- } else {
- m_rtStart = rtStart;
- m_rtStop = rtStop;
- m_pSampleToDeliver = nullptr;
- hr = GetFreeSurfaceIndex(m_nSurfaceIndex, &m_pSampleToDeliver, rtStart, rtStop);
- if (FAILED(hr)) {
- ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
- return hr;
- }
- }
-
- // m_pSampleToDeliver is unused for DXVA1
- if (GetEngine() == ENGINE_DXVA2 && m_pSampleToDeliver == nullptr) {
- return S_FALSE;
- }
-
- CHECK_HR_TRACE(BeginFrame(m_nSurfaceIndex, m_pSampleToDeliver));
-
- if (m_bSecondField) {
- if (!m_PictureParams.bSecondField) {
- UpdatePictureParams(m_nSurfaceIndex);
- }
- } else {
- UpdatePictureParams(m_nSurfaceIndex);
- }
-
- TRACE_MPEG2("CDXVADecoderMpeg2::DecodeFrame() : Surf = %d, PictureType = %d, SecondField = %d, m_nNextCodecIndex = %d, rtStart = [%I64d]\n",
- m_nSurfaceIndex, nSliceType, m_PictureParams.bSecondField, m_nNextCodecIndex, rtStart);
-
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_InverseQuantizationMatrixBufferType, sizeof(m_QMatrixData), &m_QMatrixData));
-
- // Send bitstream to accelerator
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_SliceInfo)*m_nSliceCount, &m_SliceInfo));
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
-
- // Decode frame
- CHECK_HR_TRACE(Execute());
- CHECK_HR_TRACE(EndFrame(m_nSurfaceIndex));
-
- if (m_bSecondField) {
- if (m_PictureParams.bSecondField) {
- AddToStore(m_nSurfaceIndex, m_pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), m_rtStart, m_rtStop,
- false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, FFGetCodedPicture(m_pFilter->GetAVCtx()));
- hr = DisplayNextFrame();
- }
- } else {
- AddToStore(m_nSurfaceIndex, m_pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), m_rtStart, m_rtStop,
- false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, FFGetCodedPicture(m_pFilter->GetAVCtx()));
- hr = DisplayNextFrame();
- }
-
- m_bFlushed = false;
-
- return hr;
-}
-
-void CDXVADecoderMpeg2::UpdatePictureParams(int nSurfaceIndex)
-{
- DXVA2_ConfigPictureDecode* cpd = GetDXVA2Config(); // Ok for DXVA1 too (parameters have been copied)
-
- m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
-
- // Manage reference picture list
- if (!m_PictureParams.bPicBackwardPrediction) {
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[0]);
- }
- m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
- m_wRefPictureIndex[1] = nSurfaceIndex;
- }
- m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME;
- m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;
-
- // Shall be 0 if bConfigResidDiffHost is 0 or if BPP > 8
- if (cpd->ConfigResidDiffHost == 0 || m_PictureParams.bBPPminus1 > 7) {
- m_PictureParams.bPicSpatialResid8 = 0;
- } else {
- if (m_PictureParams.bBPPminus1 == 7 && m_PictureParams.bPicIntra && cpd->ConfigResidDiffHost)
- // Shall be 1 if BPP is 8 and bPicIntra is 1 and bConfigResidDiffHost is 1
- {
- m_PictureParams.bPicSpatialResid8 = 1;
- } else
- // Shall be 1 if bConfigSpatialResid8 is 1
- {
- m_PictureParams.bPicSpatialResid8 = cpd->ConfigSpatialResid8;
- }
- }
-
- // Shall be 0 if bConfigResidDiffHost is 0 or if bConfigSpatialResid8 is 0 or if BPP > 8
- if (cpd->ConfigResidDiffHost == 0 || cpd->ConfigSpatialResid8 == 0 || m_PictureParams.bBPPminus1 > 7) {
- m_PictureParams.bPicOverflowBlocks = 0;
- }
-
- // Shall be 1 if bConfigHostInverseScan is 1 or if bConfigResidDiffAccelerator is 0.
-
- if (cpd->ConfigHostInverseScan == 1 || cpd->ConfigResidDiffAccelerator == 0) {
- m_PictureParams.bPicScanFixed = 1;
-
- if (cpd->ConfigHostInverseScan != 0) {
- m_PictureParams.bPicScanMethod = 3; // 11 = Arbitrary scan with absolute coefficient address.
- } else if (FFGetAlternateScan(m_pFilter->GetAVCtx())) {
- m_PictureParams.bPicScanMethod = 1; // 00 = Zig-zag scan (MPEG-2 Figure 7-2)
- } else {
- m_PictureParams.bPicScanMethod = 0; // 01 = Alternate-vertical (MPEG-2 Figure 7-3),
- }
- }
-}
-
-void CDXVADecoderMpeg2::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
-{
- while (*((DWORD*)pBuffer) != 0x01010000) {
- pBuffer++;
- nSize--;
-
- if (nSize <= 0) {
- return;
- }
- }
-
- memcpy(pDXVABuffer, pBuffer, nSize);
-}
-
-void CDXVADecoderMpeg2::Flush()
-{
- m_nNextCodecIndex = INT_MIN;
-
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[0]);
- }
- if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[1]);
- }
-
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
-
- m_nSurfaceIndex = 0;
- m_pSampleToDeliver = nullptr;
- m_bSecondField = false;
-
- m_rtStart = _I64_MIN;
- m_rtStop = _I64_MIN;
-
- m_rtLastStart = 0;
-
- __super::Flush();
-}
-
-int CDXVADecoderMpeg2::FindOldestFrame()
-{
- int nPos = -1;
-
- for (int i = 0; i < m_nPicEntryNumber; i++) {
- if (!m_pPictureStore[i].bDisplayed &&
- m_pPictureStore[i].bInUse &&
- (m_pPictureStore[i].nCodecSpecific == m_nNextCodecIndex)) {
- m_nNextCodecIndex = INT_MIN;
- nPos = i;
- }
- }
-
- if (nPos != -1) {
- UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
- }
-
- return nPos;
-}
-
-void CDXVADecoderMpeg2::UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
-{
- TRACE(_T("\n\nrtStart = [%10I64d - %10I64d] // "), rtStart, rtStop);
-
- if (m_rtLastStart && (rtStart == _I64_MIN || (rtStart < m_rtLastStart))) {
- rtStart = m_rtLastStart;
- }
-
- rtStop = rtStart + (REFERENCE_TIME)(m_pFilter->GetAvrTimePerFrame() / m_pFilter->GetRate());
- m_rtLastStart = rtStop;
-
- TRACE(_T("rtStart = [%10I64d - %10I64d]\n"), rtStart, rtStop);
-}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h
deleted file mode 100644
index 3ab0db871..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * (C) 2010-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-#include "DXVADecoder.h"
-
-#define MAX_SLICE 1024 // Max slice number for Mpeg2 streams
-
-class CDXVADecoderMpeg2 : public CDXVADecoder
-{
-public:
- CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoderMpeg2(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
- virtual ~CDXVADecoderMpeg2();
-
- virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
-
-protected:
- virtual int FindOldestFrame();
-
-private:
- DXVA_PictureParameters m_PictureParams;
- DXVA_QmatrixData m_QMatrixData;
- WORD m_wRefPictureIndex[2];
- DXVA_SliceInfo m_SliceInfo[MAX_SLICE];
- int m_nSliceCount;
-
- int m_nNextCodecIndex;
-
- int m_nSurfaceIndex;
- CComPtr<IMediaSample> m_pSampleToDeliver;
- bool m_bSecondField;
- REFERENCE_TIME m_rtStart;
- REFERENCE_TIME m_rtStop;
- REFERENCE_TIME m_rtLastStart;
-
- // Private functions
- void Init();
- void UpdatePictureParams(int nSurfaceIndex);
- void UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
-};
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
deleted file mode 100644
index acdd62520..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "DXVADecoderVC1.h"
-#include "MPCVideoDecFilter.h"
-#include "ffmpeg/libavcodec/avcodec.h"
-
-#include "FfmpegContext.h"
-
-#if 0
-#define TRACE_VC1 TRACE
-#else
-#define TRACE_VC1 __noop
-#endif
-
-inline void SwapRT(REFERENCE_TIME& rtFirst, REFERENCE_TIME& rtSecond)
-{
- REFERENCE_TIME rtTemp = rtFirst;
- rtFirst = rtSecond;
- rtSecond = rtTemp;
-}
-
-CDXVADecoderVC1::CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber)
- : CDXVADecoder(pFilter, pAMVideoAccelerator, nMode, nPicEntryNumber)
-{
- Init();
-}
-
-CDXVADecoderVC1::CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config)
- : CDXVADecoder(pFilter, pDirectXVideoDec, nMode, nPicEntryNumber, pDXVA2Config)
-{
- Init();
-}
-
-CDXVADecoderVC1::~CDXVADecoderVC1()
-{
- Flush();
-}
-
-void CDXVADecoderVC1::Init()
-{
- ZeroMemory(&m_PictureParams, sizeof(m_PictureParams));
- ZeroMemory(&m_SliceInfo, sizeof(m_SliceInfo));
-
- m_nMaxWaiting = 5;
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
-
- switch (GetMode()) {
- case VC1_VLD:
- AllocExecuteParams(3);
- break;
- default:
- ASSERT(FALSE);
- }
-
- m_bFrame_repeat_pict = FALSE;
-}
-
-// === Public functions
-HRESULT CDXVADecoderVC1::DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- HRESULT hr;
- int nSurfaceIndex;
- CComPtr<IMediaSample> pSampleToDeliver;
- int nFieldType, nSliceType;
- UINT nFrameSize, nSize_Result;
-
- FFVC1UpdatePictureParam(&m_PictureParams, m_pFilter->GetAVCtx(), &nFieldType, &nSliceType, pDataIn, nSize, &nFrameSize, FALSE, &m_bFrame_repeat_pict);
-
- if (FFIsSkipped(m_pFilter->GetAVCtx())) {
- return S_OK;
- }
-
- // Wait I frame after a flush
- if (m_bFlushed && !m_PictureParams.bPicIntra) {
- return S_FALSE;
- }
-
- hr = GetFreeSurfaceIndex(nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop);
- if (FAILED(hr)) {
- ASSERT(hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
- return hr;
- }
-
- CHECK_HR_TRACE(BeginFrame(nSurfaceIndex, pSampleToDeliver));
-
- TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : PictureType = %d, rtStart = %I64d, Surf = %d\n", nSliceType, rtStart, nSurfaceIndex);
-
- m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
- m_PictureParams.wDeblockedPictureIndex = m_PictureParams.wDecodedPictureIndex;
-
- // Manage reference picture list
- if (!m_PictureParams.bPicBackwardPrediction) {
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[0]);
- }
- m_wRefPictureIndex[0] = m_wRefPictureIndex[1];
- m_wRefPictureIndex[1] = nSurfaceIndex;
- }
- m_PictureParams.wForwardRefPictureIndex = (m_PictureParams.bPicIntra == 0) ? m_wRefPictureIndex[0] : NO_REF_FRAME;
- m_PictureParams.wBackwardRefPictureIndex = (m_PictureParams.bPicBackwardPrediction == 1) ? m_wRefPictureIndex[1] : NO_REF_FRAME;
-
- m_PictureParams.bPic4MVallowed = (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME && m_PictureParams.bPicStructure == 3) ? 1 : 0;
- m_PictureParams.bPicDeblockConfined |= (m_PictureParams.wBackwardRefPictureIndex == NO_REF_FRAME) ? 0x04 : 0;
-
- m_PictureParams.bPicScanMethod++; // Use for status reporting sections 3.8.1 and 3.8.2
-
- TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : Decode frame %d\n", m_PictureParams.bPicScanMethod);
-
- // Send picture params to accelerator
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
-
- // Send bitstream to accelerator
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nFrameSize ? nFrameSize : nSize, pDataIn, &nSize_Result));
-
- m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ???
- m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo));
-
- // Decode frame
- CHECK_HR_TRACE(Execute());
- CHECK_HR_TRACE(EndFrame(nSurfaceIndex));
-
- // ***************
- if (nFrameSize) { // Decoding Second Field
- FFVC1UpdatePictureParam(&m_PictureParams, m_pFilter->GetAVCtx(), nullptr, nullptr, pDataIn, nSize, nullptr, TRUE, &m_bFrame_repeat_pict);
-
- CHECK_HR_TRACE(BeginFrame(nSurfaceIndex, pSampleToDeliver));
-
- TRACE_VC1("CDXVADecoderVC1::DecodeFrame() : PictureType = %d\n", nSliceType);
-
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
-
- // Send bitstream to accelerator
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_BitStreamDateBufferType, nSize - nFrameSize, pDataIn + nFrameSize, &nSize_Result));
-
- m_SliceInfo.wQuantizerScaleCode = 1; // TODO : 1->31 ???
- m_SliceInfo.dwSliceBitsInBuffer = nSize_Result * 8;
- CHECK_HR_TRACE(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(m_SliceInfo), &m_SliceInfo));
-
- // Decode frame
- CHECK_HR_TRACE(Execute());
- CHECK_HR_TRACE(EndFrame(nSurfaceIndex));
- }
- // ***************
-
-#ifdef _DEBUG
- DisplayStatus();
-#endif
-
- // Update timestamp & Re-order B frames
- if (m_bFrame_repeat_pict || m_pFilter->IsReorderBFrame()) {
- if (m_bFrame_repeat_pict || m_pFilter->GetCodec() == AV_CODEC_ID_WMV3) {
- m_pFilter->UpdateFrameTime(rtStart, rtStop, !!m_bFrame_repeat_pict);
- }
- if (m_pFilter->IsReorderBFrame() || m_pFilter->IsEvo()) {
- if (m_PictureParams.bPicBackwardPrediction == 1) {
- SwapRT(rtStart, m_rtStartDelayed);
- SwapRT(rtStop, m_rtStopDelayed);
- } else {
- // Save I or P reference time (swap later)
- if (!m_bFlushed) {
- if (m_nDelayedSurfaceIndex != -1) {
- UpdateStore(m_nDelayedSurfaceIndex, m_rtStartDelayed, m_rtStopDelayed);
- }
- m_rtStartDelayed = m_rtStopDelayed = _I64_MAX;
- SwapRT(rtStart, m_rtStartDelayed);
- SwapRT(rtStop, m_rtStopDelayed);
- m_nDelayedSurfaceIndex = nSurfaceIndex;
- }
- }
- }
- }
-
- AddToStore(nSurfaceIndex, pSampleToDeliver, (m_PictureParams.bPicBackwardPrediction != 1), rtStart, rtStop,
- false, (FF_FIELD_TYPE)nFieldType, (FF_SLICE_TYPE)nSliceType, 0);
- m_bFlushed = false;
-
- return DisplayNextFrame();
-}
-
-void CDXVADecoderVC1::SetExtraData(BYTE* pDataIn, UINT nSize)
-{
- m_PictureParams.bMacroblockWidthMinus1 = 15;
- m_PictureParams.bMacroblockHeightMinus1 = 15;
- m_PictureParams.bBlockWidthMinus1 = 7;
- m_PictureParams.bBlockHeightMinus1 = 7;
- m_PictureParams.bBPPminus1 = 7;
-
- m_PictureParams.bChromaFormat = VC1_CHROMA_420;
-
- m_PictureParams.bPicScanFixed = 0; // Use for status reporting sections 3.8.1 and 3.8.2
- m_PictureParams.bPicReadbackRequests = 0;
-
- m_PictureParams.bPicBinPB = 0; // TODO
- m_PictureParams.bMV_RPS = 0; // TODO
-
- m_PictureParams.bReservedBits = 0;
-
- // iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
- m_PictureParams.bBidirectionalAveragingMode = (1 << 7) |
- (GetConfigIntraResidUnsigned() << 6) | // i9IRU
- (GetConfigResidDiffAccelerator() << 5); // iOHIT
-}
-
-BYTE* CDXVADecoderVC1::FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacketSize)
-{
- BYTE* pStart = pBuffer;
- BYTE bCode = 0;
- for (UINT i = 0; i < nSize - 4; i++) {
- if (((*((DWORD*)(pBuffer + i)) & 0x00FFFFFF) == 0x00010000) || (i >= nSize - 5)) {
- if (bCode == 0) {
- bCode = pBuffer[i + 3];
- if ((nSize == 5) && (bCode == 0x0D)) {
- nPacketSize = nSize;
- return pBuffer;
- }
- } else {
- if (bCode == 0x0D) {
- // Start code found!
- nPacketSize = i - (pStart - pBuffer) + (i >= nSize - 5 ? 5 : 1);
- return pStart;
- } else {
- // Other stuff, ignore it
- pStart = pBuffer + i;
- bCode = pBuffer[i + 3];
- }
- }
- }
- }
-
- ASSERT(FALSE); // Should never happen!
-
- return nullptr;
-}
-
-void CDXVADecoderVC1::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
-{
- int nDummy;
-
- if (m_PictureParams.bSecondField) {
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- if ((*((DWORD*)pBuffer) & 0x00FFFFFF) != 0x00010000) {
- if (m_pFilter->GetCodec() == AV_CODEC_ID_WMV3) {
- memcpy(pDXVABuffer, (BYTE*)pBuffer, nSize);
- } else {
- pDXVABuffer[0] = pDXVABuffer[1] = 0;
- pDXVABuffer[2] = 1;
- pDXVABuffer[3] = 0x0D;
- memcpy(pDXVABuffer + 4, (BYTE*)pBuffer, nSize);
- nSize += 4;
- }
- } else {
- BYTE* pStart;
- UINT nPacketSize;
-
- pStart = FindNextStartCode(pBuffer, nSize, nPacketSize);
- if (pStart) {
- // Startcode already present
- memcpy(pDXVABuffer, (BYTE*)pStart, nPacketSize);
- nSize = nPacketSize;
- }
- }
- }
-
- // Copy bitstream buffer, with zero padding (buffer is rounded to multiple of 128)
- nDummy = 128 - (nSize % 128);
-
- ZeroMemory(pDXVABuffer + nSize, nDummy);
- nSize += nDummy;
-}
-
-void CDXVADecoderVC1::Flush()
-{
- m_nDelayedSurfaceIndex = -1;
- m_rtStartDelayed = _I64_MAX;
- m_rtStopDelayed = _I64_MAX;
-
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[0]);
- }
- if (m_wRefPictureIndex[1] != NO_REF_FRAME) {
- RemoveRefFrame(m_wRefPictureIndex[1]);
- }
-
- m_wRefPictureIndex[0] = NO_REF_FRAME;
- m_wRefPictureIndex[1] = NO_REF_FRAME;
-
- __super::Flush();
-}
-
-HRESULT CDXVADecoderVC1::DisplayStatus()
-{
- HRESULT hr = E_INVALIDARG;
- DXVA_Status_VC1 Status;
-
- ZeroMemory(&Status, sizeof(Status));
-
- if (SUCCEEDED(hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status)))) {
- Status.StatusReportFeedbackNumber = 0x00FF & Status.StatusReportFeedbackNumber;
-
- TRACE_VC1("CDXVADecoderVC1::DisplayStatus() : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
- Status.StatusReportFeedbackNumber,
- Status.bBufType,
- Status.bStatus,
- Status.wNumMbsAffected);
- }
-
- return hr;
-}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
deleted file mode 100644
index 75781e180..000000000
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-#include "DXVADecoder.h"
-
-class CDXVADecoderVC1 : public CDXVADecoder
-{
-public:
- CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IAMVideoAccelerator* pAMVideoAccelerator, DXVAMode nMode, int nPicEntryNumber);
- CDXVADecoderVC1(CMPCVideoDecFilter* pFilter, IDirectXVideoDecoder* pDirectXVideoDec, DXVAMode nMode, int nPicEntryNumber, DXVA2_ConfigPictureDecode* pDXVA2Config);
- virtual ~CDXVADecoderVC1();
-
- // === Public functions
- virtual HRESULT DecodeFrame(BYTE* pDataIn, UINT nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- virtual void SetExtraData(BYTE* pDataIn, UINT nSize);
- virtual void CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
- virtual void Flush();
-
- typedef enum {
- VC1_PS_TOP_FIELD = 1,
- VC1_PS_BOTTOM_FIELD = 2,
- VC1_PS_PROGRESSIVE = 3
- } VC1_INTERLACING;
-
- typedef enum {
- VC1_CHROMA_420 = 1,
- VC1_CHROMA_422 = 2,
- VC1_CHROMA_444 = 3
- } VC1_CHROMA_FORMAT;
-
- typedef enum {
- VC1_CR_BICUBIC_QUARTER_CHROMA = 4,
- VC1_CR_BICUBIC_HALF_CHROMA = 5,
- VC1_CR_BILINEAR_QUARTER_CHROMA = 12,
- VC1_CR_BILINEAR_HALF_CHROMA = 13
- } VC1_CHROMA_RESIZE;
-
- typedef enum {
- VC1_SCAN_ZIGZAG = 0,
- VC1_SCAN_ALTERNATE_VERTICAL = 1,
- VC1_SCAN_ALTERNATE_HORIZONTAL = 2,
- VC1_SCAN_ARBITRARY = 3 // Use when bConfigHostInverseScan = 1
- } VC1_PIC_SCAN_METHOD;
-
- typedef enum { // Values for bPicDeblockConfined when bConfigBitstreamRaw = 1
- VC1_EXTENDED_DMV = 0x0001,
- VC1_PSF = 0x0002,
- VC1_REFPICFLAG = 0x0004,
- VC1_FINTERPFLAG = 0x0008,
- VC1_TFCNTRFLAG = 0x0010,
- VC1_INTERLACE = 0x0020,
- VC1_PULLDOWN = 0x0040,
- VC1_POSTPROCFLAG = 0x0080
- } VC1_DEBLOCK_CONFINED;
-
- typedef enum { // Values for bPicSpatialResid8
- VC1_VSTRANSFORM = 0x0001,
- VC1_DQUANT = 0x0002,
- VC1_EXTENDED_MV = 0x0004,
- VC1_FASTUVMC = 0x0008,
- VC1_LOOPFILTER = 0x0010,
- VC1_REDIST_FLAG = 0x0020,
- VC1_PANSCAN_FLAG = 0x0040
- } VC1_PIC_SPATIAL_RESID8;
-
-protected:
-
-private:
- DXVA_PictureParameters m_PictureParams;
- DXVA_SliceInfo m_SliceInfo;
- WORD m_wRefPictureIndex[2];
-
- int m_nDelayedSurfaceIndex;
- REFERENCE_TIME m_rtStartDelayed;
- REFERENCE_TIME m_rtStopDelayed;
-
- BOOL m_bFrame_repeat_pict;
-
- void Init();
- HRESULT DisplayStatus();
- BYTE* FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacketSize);
-
-};
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.cpp b/src/filters/transform/MPCVideoDec/FfmpegContext.cpp
deleted file mode 100644
index 06a9ea3fe..000000000
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.cpp
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <Windows.h>
-#include <WinNT.h>
-#include <vfwmsgs.h>
-#include <sys/timeb.h>
-#if defined(STANDALONE_FILTER) && defined(_WIN64)
-#include <time.h> // for the _time64 workaround
-#endif
-
-#include "FfmpegContext.h"
-#include "../../../DSUtil/SysVersion.h"
-
-#define HAVE_AV_CONFIG_H
-
-extern "C" {
-#pragma warning(push)
-#pragma warning(disable: 4244)
-#include "ffmpeg/libavcodec/avcodec.h"
- // This is kind of a hack but it avoids using a C++ keyword as a struct member name
-#define class classFFMPEG
-#include "ffmpeg/libavcodec/mpegvideo.h"
-#undef class
-
-#define new newC // hack since "h264.h" is using new as a variable
-#include "ffmpeg/libavcodec/h264.h"
-#undef new
-#include "ffmpeg/libavcodec/vc1.h"
-#include "ffmpeg/libavcodec/mpeg12.h"
-#pragma warning(pop)
-
- int av_h264_decode_frame(struct AVCodecContext* avctx, int* nOutPOC, int64_t* rtStartTime, uint8_t* buf, int buf_size);
- int av_vc1_decode_frame(AVCodecContext* avctx, uint8_t* buf, int buf_size, int* nFrameSize);
- void av_init_packet(AVPacket* pkt);
-
- // Hack to use MinGW64 from 2.x branch
- void __mingw_raise_matherr(int typ, const char* name, double a1, double a2, double rslt) {}
-}
-
-#if defined(STANDALONE_FILTER)
-void* __imp_toupper = toupper;
-#if defined(_WIN64)
-void* __imp_time64 = _time64;
-#endif
-#endif
-
-#define CHECK_AVC_L52_SIZE(w, h) ((w) <= 4096 && (h) <= 4096 && (w) * (h) <= 36864 * 16 * 16)
-
-const byte ZZ_SCAN[16] = {
- 0, 1, 4, 8,
- 5, 2, 3, 6,
- 9, 12, 13, 10,
- 7, 11, 14, 15
-};
-
-const byte ZZ_SCAN8[64] = {
- 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63
-};
-
-static const WORD PCID_NVIDIA_VP5[] = {
- // http://us.download.nvidia.com/XFree86/Linux-x86_64/313.26/README/supportedchips.html
- // Nvidia VDPAU Feature Set D
- 0x0FC6, // GeForce GTX 650
- 0x0FD1, // GeForce GT 650M
- 0x0FD2, // GeForce GT 640M
- 0x0FD4, // GeForce GTX 660M
- 0x0FD5, // GeForce GT 650M
- 0x0FD8, // GeForce GT 640M
- 0x0FD9, // GeForce GT 645M
- 0x0FE0, // GeForce GTX 660M
- 0x0FE1, // GeForce GT 730M
- 0x0FF2, // GRID K1
- 0x0FF9, // Quadro K2000D
- 0x0FFA, // Quadro K600
- 0x0FFB, // Quadro K2000M
- 0x0FFC, // Quadro K1000M
- 0x0FFD, // NVS 510
- 0x0FFE, // Quadro K2000
- 0x0FFF, // Quadro 410
- 0x1005, // GeForce GTX TITAN
- 0x1021, // Tesla K20Xm
- 0x1022, // Tesla K20c
- 0x1026, // Tesla K20s
- 0x1028, // Tesla K20m
- 0x1040, // GeForce GT 520 (not officially supported or typo) (4k tested)
- 0x1042, // GeForce 510
- 0x1048, // GeForce 605
- 0x104A, // GeForce GT 610 (fully tested)
- 0x104B, // GeForce GT 625 (OEM)
- 0x1051, // GeForce GT 520MX
- 0x1054, // GeForce 410M
- 0x1055, // GeForce 410M
- 0x1056, // NVS 4200M
- 0x1057, // NVS 4200M
- 0x105B, // GeForce 705M
- 0x107D, // NVS 310
- 0x1180, // GeForce GTX 680
- 0x1183, // GeForce GTX 660 Ti (fully tested)
- 0x1185, // GeForce GTX 660
- 0x1188, // GeForce GTX 690
- 0x1189, // GeForce GTX 670
- 0x118F, // Tesla K10
- 0x11A0, // GeForce GTX 680M
- 0x11A1, // GeForce GTX 670MX
- 0x11A2, // GeForce GTX 675MX
- 0x11A3, // GeForce GTX 680MX
- 0x11A7, // GeForce GTX 675MX
- 0x11BA, // Quadro K5000
- 0x11BC, // Quadro K5000M
- 0x11BD, // Quadro K4000M
- 0x11BE, // Quadro K3000M
- 0x11BF, // VGX K2
- 0x11C0, // GeForce GTX 660
- 0x11C3, // GeForce GTX 650 Ti
- 0x11C6, // GeForce GTX 650 Ti
- 0x11FA, // Quadro K4000
-};
-
-bool CheckPCID(WORD pcid, const WORD* pPCIDs, size_t len)
-{
- for (size_t i = 0; i < len; i++) {
- if (pcid == pPCIDs[i]) {
- return true;
- }
- }
-
- return false;
-}
-
-inline MpegEncContext* GetMpegEncContext(struct AVCodecContext* pAVCtx)
-{
- Mpeg1Context* s1;
- MpegEncContext* s = nullptr;
-
- switch (pAVCtx->codec_id) {
- case AV_CODEC_ID_VC1:
- case AV_CODEC_ID_H264:
- s = (MpegEncContext*)pAVCtx->priv_data;
- break;
- case AV_CODEC_ID_MPEG2VIDEO:
- s1 = (Mpeg1Context*)pAVCtx->priv_data;
- s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- break;
- }
- return s;
-}
-
-int FFH264DecodeBuffer(struct AVCodecContext* pAVCtx,
- BYTE* pBuffer,
- UINT nSize,
- int* pFramePOC,
- int* pOutPOC,
- REFERENCE_TIME* pOutrtStart)
-{
- int result = -1;
- if (pBuffer != nullptr) {
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- result = av_h264_decode_frame(pAVCtx, pOutPOC, pOutrtStart, pBuffer, nSize);
-
- if (result != -1 && h->s.current_picture_ptr != nullptr && pFramePOC) {
- *pFramePOC = h->s.current_picture_ptr->poc;
- }
- }
- return result;
-}
-
-// returns TRUE if version is equal to or higher than A.B.C.D, returns FALSE otherwise
-BOOL DriverVersionCheck(LARGE_INTEGER VideoDriverVersion, int A, int B, int C, int D)
-{
- if (HIWORD(VideoDriverVersion.HighPart) > A) {
- return TRUE;
- } else if (HIWORD(VideoDriverVersion.HighPart) == A) {
- if (LOWORD(VideoDriverVersion.HighPart) > B) {
- return TRUE;
- } else if (LOWORD(VideoDriverVersion.HighPart) == B) {
- if (HIWORD(VideoDriverVersion.LowPart) > C) {
- return TRUE;
- } else if (HIWORD(VideoDriverVersion.LowPart) == C) {
- if (LOWORD(VideoDriverVersion.LowPart) >= D) {
- return TRUE;
- }
- }
- }
- }
- return FALSE;
-}
-
-int FFH264CheckCompatibility(int nWidth,
- int nHeight,
- struct AVCodecContext* pAVCtx,
- BYTE* pBuffer,
- UINT nSize,
- DWORD nPCIVendor,
- DWORD nPCIDevice,
- LARGE_INTEGER VideoDriverVersion)
-{
- H264Context* pContext = (H264Context*) pAVCtx->priv_data;
- SPS* cur_sps;
- PPS* cur_pps;
-
- int video_is_level51 = 0;
- int no_level51_support = 1;
- int too_many_ref_frames = 0;
- int profile_higher_than_high = 0;
- int max_ref_frames_dpb41 = min(11, 8388608 / (nWidth * nHeight));
-
- if (pBuffer != nullptr) {
- av_h264_decode_frame(pAVCtx, nullptr, nullptr, pBuffer, nSize);
- }
-
- cur_sps = pContext->sps_buffers[0];
- cur_pps = pContext->pps_buffers[0];
-
- if (cur_sps != nullptr) {
- int max_ref_frames = 0;
-
- if (cur_sps->bit_depth_luma > 8 || cur_sps->chroma_format_idc > 1) {
- return DXVA_HIGH_BIT;
- }
-
- video_is_level51 = cur_sps->level_idc >= 51 ? 1 : 0;
- profile_higher_than_high = (cur_sps->profile_idc > 100);
- max_ref_frames = max_ref_frames_dpb41; // default value is calculate
-
- if (nPCIVendor == PCIV_nVidia) {
- // nVidia cards support level 5.1 since drivers v6.14.11.7800 for XP and drivers v7.15.11.7800 for Vista/7
- if (SysVersion::IsVistaOrLater()) {
- if (DriverVersionCheck(VideoDriverVersion, 7, 15, 11, 7800)) {
- no_level51_support = 0;
-
- // max ref frames is 16 for HD and 11 otherwise
- if (nWidth >= 1280) {
- max_ref_frames = 16;
- } else {
- max_ref_frames = 11;
- }
- }
- } else {
- if (DriverVersionCheck(VideoDriverVersion, 6, 14, 11, 7800)) {
- no_level51_support = 0;
-
- // max ref frames is 14
- max_ref_frames = 14;
- }
- }
- } else if (nPCIVendor == PCIV_S3_Graphics) {
- no_level51_support = 0;
- } else if (nPCIVendor == PCIV_ATI) {
- // HD4xxx, HD5xxx, and HD6xxx AMD/ATI cards support level 5.1 since drivers v8.14.1.6105 (Catalyst 10.4)
- if (nPCIDevice > 0x6700) {
- if (DriverVersionCheck(VideoDriverVersion, 8, 14, 1, 6105)) {
- no_level51_support = 0;
- max_ref_frames = 16;
- }
- }
- }
-
- // Check maximum allowed number reference frames
- if (cur_sps->ref_frame_count > max_ref_frames) {
- too_many_ref_frames = 1;
- }
- }
-
- return (video_is_level51 * no_level51_support * DXVA_UNSUPPORTED_LEVEL) +
- (too_many_ref_frames * DXVA_TOO_MANY_REF_FRAMES) +
- (profile_higher_than_high * DXVA_PROFILE_HIGHER_THAN_HIGH);
-}
-
-void CopyScalingMatrix(DXVA_Qmatrix_H264* pDest, PPS* pps, DWORD nPCIVendor)
-{
- int i, j;
- ZeroMemory(pDest, sizeof(DXVA_Qmatrix_H264));
- if (nPCIVendor == PCIV_ATI) {
- for (i = 0; i < 6; i++) {
- for (j = 0; j < 16; j++) {
- pDest->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][j];
- }
- }
- for (i = 0; i < 64; i++) {
- pDest->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][i];
- pDest->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][i];
- }
- } else {
- for (i = 0; i < 6; i++) {
- for (j = 0; j < 16; j++) {
- pDest->bScalingLists4x4[i][j] = pps->scaling_matrix4[i][ZZ_SCAN[j]];
- }
- }
- for (i = 0; i < 64; i++) {
- pDest->bScalingLists8x8[0][i] = pps->scaling_matrix8[0][ZZ_SCAN8[i]];
- pDest->bScalingLists8x8[1][i] = pps->scaling_matrix8[3][ZZ_SCAN8[i]];
- }
- }
-}
-
-unsigned short FFH264FindRefFrameIndex(unsigned short num_frame, DXVA_PicParams_H264* pDXVAPicParams)
-{
- int i;
- for (i = 0; i < pDXVAPicParams->num_ref_frames; i++) {
- if (pDXVAPicParams->FrameNumList[i] == num_frame) {
- return pDXVAPicParams->RefFrameList[i].Index7Bits;
- }
- }
-
- return 127;
-}
-
-HRESULT FFH264BuildPicParams(DXVA_PicParams_H264* pDXVAPicParams,
- DXVA_Qmatrix_H264* pDXVAScalingMatrix,
- int* nFieldType,
- int* nSliceType,
- struct AVCodecContext* pAVCtx,
- DWORD nPCIVendor)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- SPS* cur_sps;
- PPS* cur_pps;
- MpegEncContext* const s = &h->s;
- int field_pic_flag;
- HRESULT hr = E_FAIL;
- const Picture* current_picture = s->current_picture_ptr;
-
- field_pic_flag = (h->s.picture_structure != PICT_FRAME);
-
- cur_sps = &h->sps;
- cur_pps = &h->pps;
-
- if (cur_sps && cur_pps) {
- *nFieldType = h->s.picture_structure;
- if (h->sps.pic_struct_present_flag) {
- switch (h->sei_pic_struct) {
- case SEI_PIC_STRUCT_TOP_FIELD:
- case SEI_PIC_STRUCT_TOP_BOTTOM:
- case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
- *nFieldType = PICT_TOP_FIELD;
- break;
- case SEI_PIC_STRUCT_BOTTOM_FIELD:
- case SEI_PIC_STRUCT_BOTTOM_TOP:
- case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
- *nFieldType = PICT_BOTTOM_FIELD;
- break;
- case SEI_PIC_STRUCT_FRAME_DOUBLING:
- case SEI_PIC_STRUCT_FRAME_TRIPLING:
- case SEI_PIC_STRUCT_FRAME:
- *nFieldType = PICT_FRAME;
- break;
- }
- }
-
- *nSliceType = h->slice_type;
-
- if (cur_sps->mb_width == 0 || cur_sps->mb_height == 0) {
- return VFW_E_INVALID_FILE_FORMAT;
- }
-
- pDXVAPicParams->wFrameWidthInMbsMinus1 = cur_sps->mb_width - 1; // pic_width_in_mbs_minus1;
- pDXVAPicParams->wFrameHeightInMbsMinus1 = cur_sps->mb_height * (2 - cur_sps->frame_mbs_only_flag) - 1; // pic_height_in_map_units_minus1;
- pDXVAPicParams->num_ref_frames = cur_sps->ref_frame_count; // num_ref_frames;
- pDXVAPicParams->field_pic_flag = field_pic_flag;
- pDXVAPicParams->MbaffFrameFlag = (h->sps.mb_aff && (field_pic_flag == 0));
- pDXVAPicParams->residual_colour_transform_flag = cur_sps->residual_color_transform_flag;
- pDXVAPicParams->sp_for_switch_flag = h->sp_for_switch_flag;
- pDXVAPicParams->chroma_format_idc = cur_sps->chroma_format_idc;
- pDXVAPicParams->RefPicFlag = h->ref_pic_flag;
- pDXVAPicParams->constrained_intra_pred_flag = cur_pps->constrained_intra_pred;
- pDXVAPicParams->weighted_pred_flag = cur_pps->weighted_pred;
- pDXVAPicParams->weighted_bipred_idc = cur_pps->weighted_bipred_idc;
- pDXVAPicParams->frame_mbs_only_flag = cur_sps->frame_mbs_only_flag;
- pDXVAPicParams->transform_8x8_mode_flag = cur_pps->transform_8x8_mode;
- pDXVAPicParams->MinLumaBipredSize8x8Flag = h->sps.level_idc >= 31;
- pDXVAPicParams->IntraPicFlag = (h->slice_type == AV_PICTURE_TYPE_I || h->slice_type == AV_PICTURE_TYPE_SI);
-
- pDXVAPicParams->bit_depth_luma_minus8 = cur_sps->bit_depth_luma - 8; // bit_depth_luma_minus8
- pDXVAPicParams->bit_depth_chroma_minus8 = cur_sps->bit_depth_chroma - 8; // bit_depth_chroma_minus8
-
- //pDXVAPicParams->StatusReportFeedbackNumber = SET IN DecodeFrame;
- //pDXVAPicParams->CurrFieldOrderCnt = SET IN UpdateRefFramesList;
- //pDXVAPicParams->FieldOrderCntList = SET IN UpdateRefFramesList;
- //pDXVAPicParams->FrameNumList = SET IN UpdateRefFramesList;
- //pDXVAPicParams->UsedForReferenceFlags = SET IN UpdateRefFramesList;
- //pDXVAPicParams->NonExistingFrameFlags
-
- pDXVAPicParams->frame_num = h->frame_num;
-
- pDXVAPicParams->log2_max_frame_num_minus4 = cur_sps->log2_max_frame_num - 4; // log2_max_frame_num_minus4;
- pDXVAPicParams->pic_order_cnt_type = cur_sps->poc_type; // pic_order_cnt_type;
- if (cur_sps->poc_type == 0) {
- pDXVAPicParams->log2_max_pic_order_cnt_lsb_minus4 = cur_sps->log2_max_poc_lsb - 4; // log2_max_pic_order_cnt_lsb_minus4;
- } else if (cur_sps->poc_type == 1) {
- pDXVAPicParams->delta_pic_order_always_zero_flag = cur_sps->delta_pic_order_always_zero_flag;
- }
- pDXVAPicParams->direct_8x8_inference_flag = cur_sps->direct_8x8_inference_flag;
- pDXVAPicParams->entropy_coding_mode_flag = cur_pps->cabac; // entropy_coding_mode_flag;
- pDXVAPicParams->pic_order_present_flag = cur_pps->pic_order_present; // pic_order_present_flag;
- pDXVAPicParams->num_slice_groups_minus1 = cur_pps->slice_group_count - 1; // num_slice_groups_minus1;
- pDXVAPicParams->slice_group_map_type = cur_pps->mb_slice_group_map_type; // slice_group_map_type;
- pDXVAPicParams->deblocking_filter_control_present_flag = cur_pps->deblocking_filter_parameters_present; // deblocking_filter_control_present_flag;
- pDXVAPicParams->redundant_pic_cnt_present_flag = cur_pps->redundant_pic_cnt_present; // redundant_pic_cnt_present_flag;
-
- pDXVAPicParams->chroma_qp_index_offset = cur_pps->chroma_qp_index_offset[0];
- pDXVAPicParams->second_chroma_qp_index_offset = cur_pps->chroma_qp_index_offset[1];
- pDXVAPicParams->num_ref_idx_l0_active_minus1 = cur_pps->ref_count[0] - 1; // num_ref_idx_l0_active_minus1;
- pDXVAPicParams->num_ref_idx_l1_active_minus1 = cur_pps->ref_count[1] - 1; // num_ref_idx_l1_active_minus1;
- pDXVAPicParams->pic_init_qp_minus26 = cur_pps->init_qp - 26;
- pDXVAPicParams->pic_init_qs_minus26 = cur_pps->init_qs - 26;
-
- pDXVAPicParams->CurrPic.AssociatedFlag = field_pic_flag && (h->s.picture_structure == PICT_BOTTOM_FIELD);
- pDXVAPicParams->CurrFieldOrderCnt[0] = 0;
- if ((h->s.picture_structure & PICT_TOP_FIELD) && current_picture->field_poc[0] != INT_MAX) {
- pDXVAPicParams->CurrFieldOrderCnt[0] = current_picture->field_poc[0];
- }
- pDXVAPicParams->CurrFieldOrderCnt[1] = 0;
- if ((h->s.picture_structure & PICT_BOTTOM_FIELD) && current_picture->field_poc[1] != INT_MAX) {
- pDXVAPicParams->CurrFieldOrderCnt[1] = current_picture->field_poc[1];
- }
-
- CopyScalingMatrix(pDXVAScalingMatrix, cur_pps, nPCIVendor);
- hr = S_OK;
- }
-
- return hr;
-}
-
-void FFH264SetCurrentPicture(int nIndex, DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- pDXVAPicParams->CurrPic.Index7Bits = nIndex;
-
- if (h->s.current_picture_ptr) {
- h->s.current_picture_ptr->f.opaque = (void*)nIndex;
- }
-}
-
-void FFH264UpdateRefFramesList(DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- UINT nUsedForReferenceFlags = 0;
- int i, j;
- Picture* pic;
- UCHAR AssociatedFlag;
-
- for (i = 0, j = 0; i < 16; i++) {
- if (i < h->short_ref_count) {
- // Short list reference frames
- pic = h->short_ref[h->short_ref_count - i - 1];
- AssociatedFlag = pic->long_ref != 0;
- } else {
- // Long list reference frames
- pic = nullptr;
- while (!pic && j < h->short_ref_count + 16) {
- pic = h->long_ref[j++ - h->short_ref_count];
- }
- AssociatedFlag = 1;
- }
-
- if (pic != nullptr) {
- pDXVAPicParams->FrameNumList[i] = pic->long_ref ? pic->pic_id : pic->frame_num;
- pDXVAPicParams->FieldOrderCntList[i][0] = 0;
- pDXVAPicParams->FieldOrderCntList[i][1] = 0;
-
- if (pic->field_poc[0] != INT_MAX) {
- pDXVAPicParams->FieldOrderCntList[i][0] = pic->field_poc [0];
- nUsedForReferenceFlags |= 1 << (i * 2);
- }
-
- if (pic->field_poc[1] != INT_MAX) {
- pDXVAPicParams->FieldOrderCntList[i][1] = pic->field_poc [1];
- nUsedForReferenceFlags |= 2 << (i * 2);
- }
-
- pDXVAPicParams->RefFrameList[i].AssociatedFlag = AssociatedFlag;
- pDXVAPicParams->RefFrameList[i].Index7Bits = (UCHAR)pic->f.opaque;
- } else {
- pDXVAPicParams->FrameNumList[i] = 0;
- pDXVAPicParams->FieldOrderCntList[i][0] = 0;
- pDXVAPicParams->FieldOrderCntList[i][1] = 0;
- pDXVAPicParams->RefFrameList[i].AssociatedFlag = 1;
- pDXVAPicParams->RefFrameList[i].Index7Bits = 127;
- }
- }
-
- pDXVAPicParams->UsedForReferenceFlags = nUsedForReferenceFlags;
-}
-
-BOOL FFH264IsRefFrameInUse(int nFrameNum, struct AVCodecContext* pAVCtx)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- int i;
-
- for (i = 0; i < h->short_ref_count; i++) {
- if ((int)h->short_ref[i]->f.opaque == nFrameNum) {
- return TRUE;
- }
- }
-
- for (i = 0; i < h->long_ref_count; i++) {
- if ((int)h->long_ref[i]->f.opaque == nFrameNum) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams,
- DXVA_Slice_H264_Long* pSlice,
- struct AVCodecContext* pAVCtx)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- MpegEncContext* const s = &h->s;
- unsigned i, list;
-
- for (list = 0; list < 2; list++) {
- for (i = 0; i < 32; i++) {
- pSlice->RefPicList[list][i].AssociatedFlag = 1;
- pSlice->RefPicList[list][i].Index7Bits = 127;
- pSlice->RefPicList[list][i].bPicEntry = 255;
- }
- }
-
- for (list = 0; list < 2; list++) {
- for (i = 0; i < 32; i++) {
- if (list < h->list_count && i < h->ref_count[list]) {
- const Picture* r = &h->ref_list[list][i];
- pSlice->RefPicList[list][i].Index7Bits = FFH264FindRefFrameIndex(h->ref_list[list][i].frame_num, pDXVAPicParams);
- pSlice->RefPicList[list][i].AssociatedFlag = r->f.reference == PICT_BOTTOM_FIELD;
- }
- }
- }
-}
-
-void FFH264SetDxvaSliceLong(struct AVCodecContext* pAVCtx, void* pSliceLong)
-{
- H264Context* h = (H264Context*) pAVCtx->priv_data;
- h->dxva_slice_long = pSliceLong;
-}
-
-HRESULT FFVC1UpdatePictureParam(DXVA_PictureParameters* pPicParams,
- struct AVCodecContext* pAVCtx,
- int* nFieldType,
- int* nSliceType,
- BYTE* pBuffer,
- UINT nSize,
- UINT* nFrameSize,
- BOOL b_SecondField,
- BOOL* b_repeat_pict)
-{
- VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- int out_nFrameSize = 0;
-
- if (pBuffer && !b_SecondField) {
- av_vc1_decode_frame(pAVCtx, pBuffer, nSize, &out_nFrameSize);
- }
-
- // WARNING : vc1->interlace is not reliable (always set for progressive video on HD-DVD material)
- if (vc1->fcm == 0) {
- if (nFieldType) {
- *nFieldType = PICT_FRAME;
- }
- } else { // fcm : 2 or 3 frame or field interlaced
- if (nFieldType) {
- *nFieldType = (vc1->tff ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD);
- }
- }
-
- if (b_SecondField) {
- vc1->second_field = 1;
- vc1->s.picture_structure = PICT_TOP_FIELD + vc1->tff;
- vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;
- if (vc1->fptype & 4) {
- vc1->s.pict_type = (vc1->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;
- }
- }
-
- if (nFrameSize) {
- *nFrameSize = out_nFrameSize;
- }
-
- if (vc1->profile == PROFILE_ADVANCED) {
- /* It is the cropped width/height -1 of the frame */
- pPicParams->wPicWidthInMBminus1 = pAVCtx->width - 1;
- pPicParams->wPicHeightInMBminus1 = pAVCtx->height - 1;
- } else {
- /* It is the coded width/height in macroblock -1 of the frame */
- pPicParams->wPicWidthInMBminus1 = vc1->s.mb_width - 1;
- pPicParams->wPicHeightInMBminus1 = vc1->s.mb_height - 1;
- }
-
- pPicParams->bSecondField = (vc1->interlace && vc1->fcm == ILACE_FIELD && vc1->second_field);
- pPicParams->bPicIntra = vc1->s.pict_type == AV_PICTURE_TYPE_I;
- pPicParams->bPicBackwardPrediction = vc1->s.pict_type == AV_PICTURE_TYPE_B;
-
-
- // Init Init Init Todo
- // iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
- pPicParams->bBidirectionalAveragingMode = (pPicParams->bBidirectionalAveragingMode & 0xE0) | // init in SetExtraData
- ((vc1->lumshift != 0 || vc1->lumscale != 32) ? 0x10 : 0) | // iINSO
- ((vc1->profile == PROFILE_ADVANCED) << 3); // iWMVA
-
- // Section 3.2.20.3
- pPicParams->bPicSpatialResid8 = (vc1->panscanflag << 7) | (vc1->refdist_flag << 6) |
- (vc1->s.loop_filter << 5) | (vc1->fastuvmc << 4) |
- (vc1->extended_mv << 3) | (vc1->dquant << 1) |
- (vc1->vstransform);
-
- // Section 3.2.20.4
- pPicParams->bPicOverflowBlocks = (vc1->quantizer_mode << 6) | (vc1->multires << 5) |
- (vc1->s.resync_marker << 4) | (vc1->rangered << 3) |
- (vc1->s.max_b_frames);
-
- // Section 3.2.20.2
- pPicParams->bPicDeblockConfined = (vc1->postprocflag << 7) | (vc1->broadcast << 6) |
- (vc1->interlace << 5) | (vc1->tfcntrflag << 4) |
- (vc1->finterpflag << 3) | // (refpic << 2) set in DecodeFrame !
- (vc1->psf << 1) | vc1->extended_dmv;
-
-
- pPicParams->bPicStructure = 0;
- if (vc1->s.picture_structure & PICT_TOP_FIELD) {
- pPicParams->bPicStructure |= 0x01;
- }
- if (vc1->s.picture_structure & PICT_BOTTOM_FIELD) {
- pPicParams->bPicStructure |= 0x02;
- }
-
- pPicParams->bMVprecisionAndChromaRelation = ((vc1->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) |
- (1 << 2) |
- (0 << 1) |
- (!vc1->s.quarter_sample);
-
- // Cf page 17 : 2 for interlaced, 0 for progressive
- pPicParams->bPicExtrapolation = (!vc1->interlace || vc1->fcm == PROGRESSIVE) ? 1 : 2;
-
- if (vc1->s.picture_structure == PICT_FRAME) {
- pPicParams->wBitstreamFcodes = vc1->lumscale;
- pPicParams->wBitstreamPCEelements = vc1->lumshift;
- } else {
- /* Syntax: (top_field_param << 8) | bottom_field_param */
- pPicParams->wBitstreamFcodes = (vc1->lumscale << 8) | vc1->lumscale;
- pPicParams->wBitstreamPCEelements = (vc1->lumshift << 8) | vc1->lumshift;
- }
-
- if (vc1->profile == PROFILE_ADVANCED) {
- pPicParams->bPicOBMC = (vc1->range_mapy_flag << 7) |
- (vc1->range_mapy << 4) |
- (vc1->range_mapuv_flag << 3) |
- (vc1->range_mapuv);
- }
-
- // Section 3.2.16
- if (nSliceType) {
- *nSliceType = vc1->s.pict_type;
- }
-
- // Cf section 7.1.1.25 in VC1 specification, section 3.2.14.3 in DXVA spec
- pPicParams->bRcontrol = vc1->rnd;
-
- pPicParams->bPicDeblocked = ((vc1->profile == PROFILE_ADVANCED && vc1->overlap == 1 &&
- pPicParams->bPicBackwardPrediction == 0) << 6) |
- ((vc1->profile != PROFILE_ADVANCED && vc1->rangeredfrm) << 5) |
- (vc1->s.loop_filter << 1);
-
- if (vc1->profile == PROFILE_ADVANCED && (vc1->rff || vc1->rptfrm)) {
- *b_repeat_pict = TRUE;
- }
-
- return S_OK;
-}
-
-int MPEG2CheckCompatibility(struct AVCodecContext* pAVCtx, struct AVFrame* pFrame)
-{
- int got_picture = 0;
- Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
- MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- AVPacket avpkt;
-
- av_init_packet(&avpkt);
- avpkt.data = (BYTE*)pAVCtx->extradata;
- avpkt.size = pAVCtx->extradata_size;
- avpkt.flags = AV_PKT_FLAG_KEY;
-
- avcodec_decode_video2(pAVCtx, pFrame, &got_picture, &avpkt);
-
- return (s->chroma_format < 2);
-}
-
-HRESULT FFMpeg2DecodeFrame(DXVA_PictureParameters* pPicParams,
- DXVA_QmatrixData* pQMatrixData,
- DXVA_SliceInfo* pSliceInfo,
- int* nSliceCount,
- struct AVCodecContext* pAVCtx,
- struct AVFrame* pFrame,
- int* nNextCodecIndex,
- int* nFieldType,
- int* nSliceType,
- BYTE* pBuffer,
- UINT nSize)
-{
- int i;
- int got_picture = 0;
- Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
- MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- int is_field = 0;
- unsigned mb_count = 0;
- AVPacket avpkt;
-
- if (pBuffer) {
- s1->pSliceInfo = pSliceInfo;
-
- av_init_packet(&avpkt);
- avpkt.data = pBuffer;
- avpkt.size = nSize;
- avpkt.flags = AV_PKT_FLAG_KEY;
- avcodec_decode_video2(pAVCtx, pFrame, &got_picture, &avpkt);
-
- *nSliceCount = s1->slice_count;
- *nFieldType = s->progressive_frame ? PICT_FRAME : s->current_picture.f.top_field_first ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD;
- *nSliceType = s->pict_type;
- }
-
- // pPicParams->wDecodedPictureIndex; set in DecodeFrame
- // pPicParams->wDeblockedPictureIndex; 0 for Mpeg2
- // pPicParams->wForwardRefPictureIndex; set in DecodeFrame
- // pPicParams->wBackwardRefPictureIndex; set in DecodeFrame
-
- is_field = s->picture_structure != PICT_FRAME;
-
- pPicParams->wPicWidthInMBminus1 = s->mb_width - 1;
- pPicParams->wPicHeightInMBminus1 = (s->mb_height >> is_field) - 1;
-
- pPicParams->bMacroblockWidthMinus1 = 15; // This is equal to "15" for MPEG-1, MPEG-2, H.263, and MPEG-4
- pPicParams->bMacroblockHeightMinus1 = 15; // This is equal to "15" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
-
- pPicParams->bBlockWidthMinus1 = 7; // This is equal to "7" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
- pPicParams->bBlockHeightMinus1 = 7; // This is equal to "7" for MPEG-1, MPEG-2, H.261, H.263, and MPEG-4
-
- pPicParams->bBPPminus1 = 7; // It is equal to "7" for MPEG-1, MPEG-2, H.261, and H.263
-
- pPicParams->bPicStructure = s->picture_structure;
- pPicParams->bSecondField = is_field && !s->first_field;
- pPicParams->bPicIntra = (s->current_picture.f.pict_type == AV_PICTURE_TYPE_I);
- pPicParams->bPicBackwardPrediction = (s->current_picture.f.pict_type == AV_PICTURE_TYPE_B);
-
- pPicParams->bBidirectionalAveragingMode = 0; // The value "0" indicates MPEG-1 and MPEG-2 rounded averaging (//2),
- //pPicParams->bMVprecisionAndChromaRelation = 0; // Indicates that luminance motion vectors have half-sample precision and that chrominance motion vectors are derived from luminance motion vectors according to the rules in MPEG-2
- pPicParams->bChromaFormat = 0x01; // For MPEG-1, MPEG-2 "Main Profile," H.261 and H.263 bitstreams, this value shall always be set to "01", indicating "4:2:0" format
-
- //pPicParams->bPicScanFixed = 1; // set in UpdatePicParams
- //pPicParams->bPicScanMethod = 1; // set in UpdatePicParams
- //pPicParams->bPicReadbackRequests; // ??
-
- //pPicParams->bRcontrol = 0; // It shall be set to "0" for all MPEG-1, and MPEG-2 bitstreams in order to conform with the rounding operator defined by those standards
- //pPicParams->bPicSpatialResid8; // set in UpdatePicParams
- //pPicParams->bPicOverflowBlocks; // set in UpdatePicParams
- //pPicParams->bPicExtrapolation; = 0; // by H.263 Annex D and MPEG-4
-
- //pPicParams->bPicDeblocked; = 0; // MPEG2_A Restricted Profile
- //pPicParams->bPicDeblockConfined; // ??
- //pPicParams->bPic4MVallowed; // See H.263 Annexes F and J
- //pPicParams->bPicOBMC; // H.263 Annex F
- //pPicParams->bPicBinPB; // Annexes G and M of H.263
- //pPicParams->bMV_RPS; // ???
- //pPicParams->bReservedBits; // ??
-
- pPicParams->wBitstreamFcodes = (s->mpeg_f_code[0][0] << 12) | (s->mpeg_f_code[0][1] << 8) |
- (s->mpeg_f_code[1][0] << 4) | (s->mpeg_f_code[1][1]);
-
- pPicParams->wBitstreamPCEelements = (s->intra_dc_precision << 14) | (s->picture_structure << 12) |
- (s->top_field_first << 11) | (s->frame_pred_frame_dct << 10) |
- (s->concealment_motion_vectors << 9) | (s->q_scale_type << 8) |
- (s->intra_vlc_format << 7) | (s->alternate_scan << 6) |
- (s->repeat_first_field << 5) | (s->chroma_420_type << 4) |
- (s->progressive_frame << 3);
-
- pPicParams->bBitstreamConcealmentNeed = 0;
- pPicParams->bBitstreamConcealmentMethod = 0;
-
- pQMatrixData->bNewQmatrix[0] = 1;
- pQMatrixData->bNewQmatrix[1] = 1;
- pQMatrixData->bNewQmatrix[2] = 1;
- pQMatrixData->bNewQmatrix[3] = 1;
- for (i = 0; i < 64; i++) {
- int n = s->dsp.idct_permutation[ZZ_SCAN8[i]];
- pQMatrixData->Qmatrix[0][i] = s->intra_matrix[n];
- pQMatrixData->Qmatrix[1][i] = s->inter_matrix[n];
- pQMatrixData->Qmatrix[2][i] = s->chroma_intra_matrix[n];
- pQMatrixData->Qmatrix[3][i] = s->chroma_inter_matrix[n];
- }
-
- mb_count = s->mb_width * (s->mb_height >> is_field);
- for (i = 0; i < s1->slice_count; i++) {
- DXVA_SliceInfo* slice = &s1->pSliceInfo[i];
-
- if (i < s1->slice_count - 1) {
- slice->wNumberMBsInSlice = slice[1].wNumberMBsInSlice - slice[0].wNumberMBsInSlice;
- } else {
- slice->wNumberMBsInSlice = mb_count - slice[0].wNumberMBsInSlice;
- }
- }
-
- if (got_picture) {
- *nNextCodecIndex = pFrame->coded_picture_number;
- }
-
- return S_OK;
-}
-
-unsigned long FFGetMBNumber(struct AVCodecContext* pAVCtx)
-{
- MpegEncContext* s = GetMpegEncContext(pAVCtx);
-
- return (s != nullptr) ? s->mb_num : 0;
-}
-
-int FFIsSkipped(struct AVCodecContext* pAVCtx)
-{
- VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- return vc1->p_frame_skipped;
-}
-
-int FFGetThreadType(enum AVCodecID nCodecId, int nThreadCount)
-{
- if (!nThreadCount) {
- return 0;
- }
- switch (nCodecId) {
- case AV_CODEC_ID_H264:
- return FF_THREAD_FRAME | FF_THREAD_SLICE;
- break;
- case AV_CODEC_ID_MPEG1VIDEO:
- case AV_CODEC_ID_DVVIDEO:
- case AV_CODEC_ID_FFV1:
- return FF_THREAD_SLICE;
- break;
- case AV_CODEC_ID_VP3:
- case AV_CODEC_ID_VP8:
- case AV_CODEC_ID_THEORA:
- case AV_CODEC_ID_RV30:
- case AV_CODEC_ID_RV40:
- return FF_THREAD_FRAME;
- break;
- default:
- return 0;
- }
-}
-
-void FFSetThreadNumber(struct AVCodecContext* pAVCtx, enum AVCodecID nCodecId, int nThreadCount)
-{
- pAVCtx->thread_count = nThreadCount;
- pAVCtx->thread_type = FFGetThreadType(nCodecId, nThreadCount);
-}
-
-BOOL FFSoftwareCheckCompatibility(struct AVCodecContext* pAVCtx)
-{
- if (pAVCtx->codec_id == AV_CODEC_ID_VC1) {
- VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- return !vc1->interlace;
- } else {
- return TRUE;
- }
-}
-
-int FFGetCodedPicture(struct AVCodecContext* pAVCtx)
-{
- MpegEncContext* s = GetMpegEncContext(pAVCtx);
-
- return (s != nullptr) ? s->current_picture.f.coded_picture_number : 0;
-}
-
-BOOL FFGetAlternateScan(struct AVCodecContext* pAVCtx)
-{
- MpegEncContext* s = GetMpegEncContext(pAVCtx);
-
- return (s != nullptr) ? s->alternate_scan : 0;
-}
-
-BOOL DXVACheckFramesize(int width, int height, DWORD nPCIVendor, DWORD nPCIDevice)
-{
- width = (width + 15) & ~15; // (width + 15) / 16 * 16;
- height = (height + 15) & ~15; // (height + 15) / 16 * 16;
-
- if (nPCIVendor == PCIV_nVidia) {
- if (CheckPCID((WORD)nPCIDevice, PCID_NVIDIA_VP5, _countof(PCID_NVIDIA_VP5)) && width <= 4096 && height <= 4096 && width * height <= 4080 * 4080) {
- // tested H.264 on VP5 (GT 610, GTX 660 Ti)
- // 4080x4080 = 65025 macroblocks
- return TRUE;
- } else if (width <= 2032 && height <= 2032 && width * height <= 8190 * 16 * 16) {
- // tested H.264, VC-1 and MPEG-2 on VP4 (feature set C) (G210M, GT220)
- return TRUE;
- }
- } else if (nPCIVendor == PCIV_ATI) {
- if (width <= 2048 && height <= 2304 && width * height <= 2048 * 2048) {
- // tested H.264 on UVD 2.2 (HD5670, HD5770, HD5850)
- // it may also work if width = 2064, but unstable
- return TRUE;
- }
- } else if (nPCIVendor == PCIV_Intel && nPCIDevice == PCID_Intel_HD4000) {
- //if (width <= 4096 && height <= 4096 && width * height <= 56672 * 16 * 16) {
- if (width <= 4096 && height <= 4096) { // driver v.9.17.10.2867
- // complete test was performed
- return TRUE;
- }
- } else if (nPCIVendor == PCIV_Intel && nPCIDevice == PCID_Intel_HD2500) {
- if (CHECK_AVC_L52_SIZE(width, height)) {
- // tested some media files with AVC Livel 5.1
- // complete test was NOT performed
- return TRUE;
- }
- } else if (width <= 1920 && height <= 1088) {
- return TRUE;
- }
-
- return FALSE;
-}
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.h b/src/filters/transform/MPCVideoDec/FfmpegContext.h
deleted file mode 100644
index d6f5b8ed8..000000000
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-
-struct AVCodecContext;
-struct AVFrame;
-
-enum PCI_Vendors {
- PCIV_ATI = 0x1002,
- PCIV_nVidia = 0x10DE,
- PCIV_Intel = 0x8086,
- PCIV_S3_Graphics = 0x5333
-};
-
-#define PCID_Intel_HD2500 0x0152
-#define PCID_Intel_HD4000 0x0162
-
-// Bitmasks for DXVA compatibility check
-#define DXVA_UNSUPPORTED_LEVEL 1
-#define DXVA_TOO_MANY_REF_FRAMES 2
-#define DXVA_INCOMPATIBLE_SAR 4
-#define DXVA_PROFILE_HIGHER_THAN_HIGH 8
-#define DXVA_HIGH_BIT 16
-
-// === H264 functions
-int FFH264DecodeBuffer(struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize,
- int* pFramePOC, int* pOutPOC, REFERENCE_TIME* pOutrtStart);
-HRESULT FFH264BuildPicParams(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_H264* pDXVAScalingMatrix,
- int* nFieldType, int* nSliceType, struct AVCodecContext* pAVCtx, DWORD nPCIVendor);
-int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAVCtx, BYTE* pBuffer,
- UINT nSize, DWORD nPCIVendor, DWORD nPCIDevice, LARGE_INTEGER VideoDriverVersion);
-void FFH264SetCurrentPicture(int nIndex, DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx);
-void FFH264UpdateRefFramesList(DXVA_PicParams_H264* pDXVAPicParams, struct AVCodecContext* pAVCtx);
-BOOL FFH264IsRefFrameInUse(int nFrameNum, struct AVCodecContext* pAVCtx);
-void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slice_H264_Long* pSlice,
- struct AVCodecContext* pAVCtx);
-void FFH264SetDxvaSliceLong(struct AVCodecContext* pAVCtx, void* pSliceLong);
-
-// === VC1 functions
-HRESULT FFVC1UpdatePictureParam(DXVA_PictureParameters* pPicParams, struct AVCodecContext* pAVCtx,
- int* nFieldType, int* nSliceType, BYTE* pBuffer, UINT nSize,
- UINT* nFrameSize, BOOL b_SecondField, BOOL* b_repeat_pict);
-int FFIsSkipped(struct AVCodecContext* pAVCtx);
-
-// === Mpeg2 functions
-int MPEG2CheckCompatibility(struct AVCodecContext* pAVCtx, struct AVFrame* pFrame);
-HRESULT FFMpeg2DecodeFrame(DXVA_PictureParameters* pPicParams, DXVA_QmatrixData* m_QMatrixData,
- DXVA_SliceInfo* pSliceInfo, int* nSliceCount, struct AVCodecContext* pAVCtx,
- struct AVFrame* pFrame, int* nNextCodecIndex, int* nFieldType, int* nSliceType,
- BYTE* pBuffer, UINT nSize);
-
-// === Common functions
-unsigned long FFGetMBNumber(struct AVCodecContext* pAVCtx);
-void FFSetThreadNumber(struct AVCodecContext* pAVCtx, enum AVCodecID nCodecId, int nThreadCount);
-BOOL FFSoftwareCheckCompatibility(struct AVCodecContext* pAVCtx);
-int FFGetCodedPicture(struct AVCodecContext* pAVCtx);
-BOOL FFGetAlternateScan(struct AVCodecContext* pAVCtx);
-BOOL DXVACheckFramesize(int width, int height, DWORD nPCIVendor, DWORD nPCIDevice);
diff --git a/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp b/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp
deleted file mode 100644
index 9922c9b41..000000000
--- a/src/filters/transform/MPCVideoDec/H264RandomAccess.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2010-2012 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.
- */
-
-#include "stdafx.h"
-#include "H264RandomAccess.h"
-
-#pragma warning(push)
-#pragma warning(disable: 4005)
-extern "C" {
-#include "ffmpeg/libavcodec/avcodec.h"
-}
-#pragma warning(pop)
-
-CH264RandomAccess::CH264RandomAccess()
-{
- flush(0);
-}
-
-CH264RandomAccess::~CH264RandomAccess()
-{
-}
-
-void CH264RandomAccess::flush(int threadCount)
-{
- m_RecoveryMode = 1;
- m_RecoveryFrameCount = 0;
- m_ThreadDelay = threadCount;
-}
-
-BOOL CH264RandomAccess::searchRecoveryPoint(AVCodecContext* pAVCtx, BYTE *buf, int buf_size)
-{
- if (m_RecoveryMode == 1) {
- int recoveryPoint = avcodec_h264_search_recovery_point(pAVCtx, buf, buf_size, &m_RecoveryFrameCount);
- switch (recoveryPoint) {
- case 3: // IDRS
- m_RecoveryMode = 0;
- return TRUE;
- case 2: // SEI recovery
- m_RecoveryMode = 2;
- return TRUE;
- case 1: // I Frame
- m_RecoveryMode = 2;
- m_RecoveryFrameCount = 0;
- return TRUE;
- default:
- return FALSE;
- }
- } else {
- return TRUE;
- }
-}
-
-void CH264RandomAccess::judgeFrameUsability(AVFrame *pFrame, int *got_picture_ptr)
-{
- if ((m_ThreadDelay > 1 && --m_ThreadDelay > 0) || m_RecoveryMode == 0 || pFrame->h264_max_frame_num == 0) {
- return;
- }
-
- if (m_RecoveryMode == 1 || m_RecoveryMode == 2) {
- m_RecoveryFrameCount = (m_RecoveryFrameCount + pFrame->h264_frame_num_decoded) % pFrame->h264_max_frame_num;
- m_RecoveryMode = 3;
- }
-
- if (m_RecoveryMode == 3) {
- if (m_RecoveryFrameCount <= pFrame->h264_frame_num_decoded) {
- m_RecoveryPOC = pFrame->h264_poc_decoded;
- m_RecoveryMode = 4;
- }
- }
-
- if (m_RecoveryMode == 4) {
- if (pFrame->h264_poc_outputed >= m_RecoveryPOC) {
- m_RecoveryMode = 0;
- }
- }
-
- if (m_RecoveryMode != 0) {
- *got_picture_ptr = 0;
- }
-}
diff --git a/src/filters/transform/MPCVideoDec/H264RandomAccess.h b/src/filters/transform/MPCVideoDec/H264RandomAccess.h
deleted file mode 100644
index 5f9eced93..000000000
--- a/src/filters/transform/MPCVideoDec/H264RandomAccess.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010-2012 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.
- */
-
-#pragma once
-
-struct AVCodecContext;
-struct AVFrame;
-
-class CH264RandomAccess
-{
-public:
- CH264RandomAccess();
- ~CH264RandomAccess();
-
- void flush(int threadCount);
- BOOL searchRecoveryPoint(AVCodecContext* pAVCtx, BYTE *buf, int buf_size);
- void judgeFrameUsability(AVFrame *pFrame, int *got_picture_ptr);
-
-private:
- int m_RecoveryMode; // 0: OK; 1: Searching; 2: Found; 3:
- int m_RecoveryFrameCount;
- int m_RecoveryPOC;
- int m_ThreadDelay;
-};
diff --git a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
deleted file mode 100644
index dbfe1316b..000000000
--- a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * (C) 2006-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-// Internal codec list (used to enable/disable codec in standalone mode)
-typedef enum {
- MPCVD_H264 = 1 << 0,
- MPCVD_VC1 = 1 << 1,
- MPCVD_XVID = 1 << 2,
- MPCVD_DIVX = 1 << 3,
- MPCVD_WMV = 1 << 4,
- MPCVD_MSMPEG4 = 1 << 5,
- MPCVD_H263 = 1 << 6,
- MPCVD_SVQ3 = 1 << 7,
- MPCVD_THEORA = 1 << 8,
- MPCVD_AMVV = 1 << 9,
- MPCVD_FLASH = 1 << 10,
- MPCVD_H264_DXVA = 1 << 11,
- MPCVD_VC1_DXVA = 1 << 12,
- MPCVD_VP356 = 1 << 13,
- MPCVD_VP8 = 1 << 14,
- MPCVD_MJPEG = 1 << 15,
- MPCVD_INDEO = 1 << 16,
- MPCVD_RV = 1 << 17,
- MPCVD_WMV3_DXVA = 1 << 19,
- MPCVD_MPEG2_DXVA = 1 << 20
-} MPC_VIDEO_CODEC;
-
-// Interlaced flag handling
-enum MPCVD_INTERLACED_FLAG {
- MPCVC_INTERLACED_AUTO,
- MPCVC_INTERLACED_PROGRESSIVE,
- MPCVC_INTERLACED_TOP_FIELD_FIRST,
- MPCVC_INTERLACED_BOTTOM_FIELD_FIRST
-};
-
-interface __declspec(uuid("CDC3B5B3-A8B0-4c70-A805-9FC80CDEF262"))
-IMPCVideoDecFilter :
-public IUnknown {
- STDMETHOD(Apply()) PURE;
-
- STDMETHOD(SetThreadNumber(int nValue)) PURE;
- STDMETHOD_(int, GetThreadNumber()) PURE;
-
- STDMETHOD(SetDiscardMode(int nValue)) PURE;
- STDMETHOD_(int, GetDiscardMode()) PURE;
-
- STDMETHOD_(GUID*, GetDXVADecoderGuid()) PURE;
-
- STDMETHOD(SetActiveCodecs(MPC_VIDEO_CODEC nValue)) PURE;
- STDMETHOD_(MPC_VIDEO_CODEC, GetActiveCodecs()) PURE;
-
- STDMETHOD_(LPCTSTR, GetVideoCardDescription()) PURE;
-
- STDMETHOD(SetARMode(int nValue)) PURE;
- STDMETHOD_(int, GetARMode()) PURE;
-
- STDMETHOD(SetDXVACheckCompatibility(int nValue)) PURE;
- STDMETHOD_(int, GetDXVACheckCompatibility()) PURE;
-
- STDMETHOD(SetDXVA_SD(int nValue)) PURE;
- STDMETHOD_(int, GetDXVA_SD()) PURE;
-};
-
-interface __declspec(uuid("F0ABC515-19ED-4D65-9D5F-59E36AE7F2AF"))
-IMPCVideoDecFilter2 :
-public IMPCVideoDecFilter {
- STDMETHOD_(int, GetFrameType()) PURE;
-
- STDMETHOD(SetInterlacedFlag(MPCVD_INTERLACED_FLAG interlacedFlag)) PURE;
- STDMETHOD_(MPCVD_INTERLACED_FLAG, GetInterlacedFlag()) PURE;
-};
diff --git a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp b/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
deleted file mode 100644
index 4528621d3..000000000
--- a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "MPCVideoDecFilter.h"
-#include "../../../DSUtil/DSUtil.h"
-
-#ifdef STANDALONE_FILTER
-
-// Workaround: graphedit crashes when a filter exposes more than 115 input MediaTypes!
-const AMOVIESETUP_PIN sudpPinsVideoDec[] = {
- {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr, CMPCVideoDecFilter::sudPinTypesInCount > 115 ? 115 : CMPCVideoDecFilter::sudPinTypesInCount, CMPCVideoDecFilter::sudPinTypesIn},
- {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr, CMPCVideoDecFilter::sudPinTypesOutCount, CMPCVideoDecFilter::sudPinTypesOut}
-};
-
-const AMOVIESETUP_FILTER sudFilters[] = {
- {&__uuidof(CMPCVideoDecFilter), MPCVideoDecName, /*MERIT_DO_NOT_USE*/0x40000001, _countof(sudpPinsVideoDec), sudpPinsVideoDec, CLSID_LegacyAmFilterCategory}
-};
-
-CFactoryTemplate g_Templates[] = {
- {sudFilters[0].strName, &__uuidof(CMPCVideoDecFilter), CreateInstance<CMPCVideoDecFilter>, nullptr, &sudFilters[0]},
- {L"CMPCVideoDecPropertyPage", &__uuidof(CMPCVideoDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd>>},
- {L"CMPCVideoDecPropertyPage2", &__uuidof(CMPCVideoDecCodecWnd), CreateInstance<CInternalPropertyPageTempl<CMPCVideoDecCodecWnd>>},
-};
-
-int g_cTemplates = _countof(g_Templates);
-
-STDAPI DllRegisterServer()
-{
- return AMovieDllRegisterServer2(TRUE);
-}
-
-STDAPI DllUnregisterServer()
-{
- return AMovieDllRegisterServer2(FALSE);
-}
-
-#include "../../FilterApp.h"
-
-CFilterApp theApp;
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDec.def b/src/filters/transform/MPCVideoDec/MPCVideoDec.def
deleted file mode 100644
index 6492e5cd6..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDec.def
+++ /dev/null
@@ -1,5 +0,0 @@
-EXPORTS
- DllCanUnloadNow PRIVATE
- DllGetClassObject PRIVATE
- DllRegisterServer PRIVATE
- DllUnregisterServer PRIVATE
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj b/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj
deleted file mode 100644
index 051e260eb..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj
+++ /dev/null
@@ -1,313 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug Filter|Win32">
- <Configuration>Debug Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug Filter|x64">
- <Configuration>Debug Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Debug|x64">
- <Configuration>Debug</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|Win32">
- <Configuration>Release Filter</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release Filter|x64">
- <Configuration>Release Filter</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|x64">
- <Configuration>Release</Configuration>
- <Platform>x64</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectGuid>{58E36BF5-4A06-47E4-BD40-4CCEF8C634DF}</ProjectGuid>
- <RootNamespace>MPCVideoDec</RootNamespace>
- <Keyword>MFCProj</Keyword>
- <ProjectName>MPCVideoDec</ProjectName>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <Import Project="..\..\..\platform.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>StaticLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- <UseOfMfc>Static</UseOfMfc>
- <CharacterSet>Unicode</CharacterSet>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- <Import Project="..\..\..\common.props" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">.ax</TargetExt>
- <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">.ax</TargetExt>
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;d3d9.lib;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib;$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MPCVideoDec.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;d3d9.lib;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib64;$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MPCVideoDec.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;d3d9.lib;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib;$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MPCVideoDec.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release Filter|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ClCompile>
- <Link>
- <AdditionalDependencies>libgcc.a;libmingwex.a;d3d9.lib;Vfw32.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(SolutionDir)lib64;$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <ModuleDefinitionFile>MPCVideoDec.def</ModuleDefinitionFile>
- <ImageHasSafeExceptionHandlers Condition="'$(PlatformToolsetVersion)'=='110'">false</ImageHasSafeExceptionHandlers>
- </Link>
- <ResourceCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- </ResourceCompile>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- </Lib>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- </Lib>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- </Lib>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <ClCompile>
- <AdditionalIncludeDirectories>..\..\..\..\include;..\..\..\thirdparty;..\..\..\thirdparty\ffmpeg;$(DXSDK_DIR)Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- </ClCompile>
- <Lib>
- <AdditionalDependencies>d3d9.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>$(DXSDK_DIR)Lib\x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- </Lib>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release' or '$(PlatformToolsetVersion)'=='110'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="CpuId.cpp" />
- <ClCompile Include="DXVADecoder.cpp" />
- <ClCompile Include="DXVADecoderH264.cpp" />
- <ClCompile Include="DXVADecoderMpeg2.cpp" />
- <ClCompile Include="DXVADecoderVC1.cpp" />
- <ClCompile Include="ffImgfmt.cpp" />
- <ClCompile Include="FfmpegContext.cpp">
- <PrecompiledHeader>NotUsing</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="H264RandomAccess.cpp" />
- <ClCompile Include="MPCFfmpegDec.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="MPCVideoDecFilter.cpp" />
- <ClCompile Include="MPCVideoDecSettingsWnd.cpp" />
- <ClCompile Include="stdafx.cpp">
- <PrecompiledHeader>Create</PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="TlibavcodecExt.cpp" />
- <ClCompile Include="VideoDecDXVAAllocator.cpp" />
- <ClCompile Include="VideoDecOutputPin.cpp" />
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="array_allocator.h" />
- <ClInclude Include="char_t.h" />
- <ClInclude Include="CpuId.h" />
- <ClInclude Include="DXVADecoder.h" />
- <ClInclude Include="DXVADecoderH264.h" />
- <ClInclude Include="DXVADecoderMpeg2.h" />
- <ClInclude Include="DXVADecoderVC1.h" />
- <ClInclude Include="ffImgfmt.h" />
- <ClInclude Include="FfmpegContext.h" />
- <ClInclude Include="H264RandomAccess.h" />
- <ClInclude Include="IMPCVideoDecFilter.h" />
- <ClInclude Include="MPCVideoDecFilter.h" />
- <ClInclude Include="MPCVideoDecSettingsWnd.h" />
- <ClInclude Include="PODtypes.h" />
- <ClInclude Include="resource.h">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ClInclude>
- <ClInclude Include="stdafx.h" />
- <ClInclude Include="TlibavcodecExt.h" />
- <ClInclude Include="VideoDecDXVAAllocator.h" />
- <ClInclude Include="VideoDecOutputPin.h" />
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MPCVideoDecFilter.rc">
- <ExcludedFromBuild Condition="'$(Configuration)'=='Debug' or '$(Configuration)'=='Release'">true</ExcludedFromBuild>
- </ResourceCompile>
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\..\DSUtil\DSUtil.vcxproj">
- <Project>{fc70988b-1ae5-4381-866d-4f405e28ac42}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\Kasumi\Kasumi.vcxproj">
- <Project>{0d252872-7542-4232-8d02-53f9182aee15}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\VirtualDub\system\system.vcxproj">
- <Project>{c2082189-3ecb-4079-91fa-89d3c8a305c0}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\zlib\zlib.vcxproj">
- <Project>{2fcd4b66-9cf9-4c8f-bc70-37cd20002d49}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\BaseClasses\BaseClasses.vcxproj">
- <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\Filters.vcxproj">
- <Project>{273b3149-3192-4b75-a791-470320b90812}</Project>
- </ProjectReference>
- <ProjectReference Include="..\BaseVideoFilter\BaseVideoFilter.vcxproj">
- <Project>{54dda60f-e528-4d07-a152-960a1e818680}</Project>
- </ProjectReference>
- <ProjectReference Include="..\..\..\thirdparty\ffmpeg\ffmpeg.vcxproj">
- <Project>{438286b7-a9f4-411d-bcc5-948c40e37d8f}</Project>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters b/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters
deleted file mode 100644
index 98f3bc6e4..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDec.vcxproj.filters
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup>
- <Filter Include="Source Files">
- <UniqueIdentifier>{e15c9785-536b-4371-9e8e-ddbcfdb5c17e}</UniqueIdentifier>
- <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
- </Filter>
- <Filter Include="Header Files">
- <UniqueIdentifier>{2f29e203-dfe5-49ab-8326-55ff62a38d80}</UniqueIdentifier>
- <Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
- </Filter>
- <Filter Include="Resource Files">
- <UniqueIdentifier>{29435264-dc59-4006-a197-91a4bd1e583f}</UniqueIdentifier>
- <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
- </Filter>
- </ItemGroup>
- <ItemGroup>
- <ClCompile Include="CpuId.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="DXVADecoder.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="DXVADecoderH264.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="DXVADecoderMpeg2.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="DXVADecoderVC1.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="ffImgfmt.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MPCFfmpegDec.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MPCVideoDecFilter.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="MPCVideoDecSettingsWnd.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="stdafx.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="TlibavcodecExt.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="VideoDecDXVAAllocator.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="VideoDecOutputPin.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\winmdi.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxctrlcontainer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="..\..\..\thirdparty\mfc\afxglobals.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="H264RandomAccess.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- <ClCompile Include="FfmpegContext.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="CpuId.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="DXVADecoder.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="DXVADecoderH264.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="DXVADecoderMpeg2.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="DXVADecoderVC1.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="FfmpegContext.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="IMPCVideoDecFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MPCVideoDecFilter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="MPCVideoDecSettingsWnd.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="resource.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="stdafx.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="TlibavcodecExt.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="VideoDecDXVAAllocator.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="VideoDecOutputPin.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="H264RandomAccess.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="char_t.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="ffImgfmt.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="array_allocator.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- <ClInclude Include="PODtypes.h">
- <Filter>Header Files</Filter>
- </ClInclude>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="MPCVideoDecFilter.rc">
- <Filter>Resource Files</Filter>
- </ResourceCompile>
- </ItemGroup>
-</Project> \ No newline at end of file
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
deleted file mode 100644
index 9ac369bfc..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
+++ /dev/null
@@ -1,2672 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include <math.h>
-#include <atlbase.h>
-#include <MMReg.h>
-#include <evr.h>
-#include <vector>
-
-#ifdef STANDALONE_FILTER
-#include <InitGuid.h>
-#endif
-
-#include "MPCVideoDecFilter.h"
-#include "VideoDecOutputPin.h"
-#include "CpuId.h"
-
-#include "FfmpegContext.h"
-extern "C"
-{
-#include "ffmpeg/libavcodec/avcodec.h"
-#include "ffmpeg/libswscale/swscale.h"
-}
-#include "ffImgfmt.h"
-
-#include "../../../DSUtil/DSUtil.h"
-#include "../../../DSUtil/MediaTypes.h"
-#include "../../../DSUtil/SysVersion.h"
-#include "../../../DSUtil/WinAPIUtils.h"
-#include "../../parser/MpegSplitter/MpegSplitter.h"
-#include "../../parser/OggSplitter/OggSplitter.h"
-#include "../../parser/RealMediaSplitter/RealMediaSplitter.h"
-#include "moreuuids.h"
-#include "DXVADecoderH264.h"
-#include "../../../mpc-hc/FilterEnum.h"
-
-// options names
-#define OPT_REGKEY_VideoDec _T("Software\\Gabest\\Filters\\MPC Video Decoder")
-#define OPT_SECTION_VideoDec _T("Filters\\MPC Video Decoder")
-#define OPT_ThreadNumber _T("ThreadNumber")
-#define OPT_DiscardMode _T("DiscardMode")
-#define OPT_ActiveCodecs _T("ActiveCodecs")
-#define OPT_ARMode _T("ARMode")
-#define OPT_DXVACheck _T("DXVACheckCompatibility")
-#define OPT_DisableDXVA_SD _T("DisableDXVA_SD")
-#define OPT_InterlacedFlag _T("InterlacedFlag")
-
-#define MAX_SUPPORTED_MODE 5
-#define AVRTIMEPERFRAME_VC1_EVO 417083
-
-typedef struct {
- const int PicEntryNumber;
- const UINT PreferedConfigBitstream;
- const GUID* Decoder[MAX_SUPPORTED_MODE];
- const WORD RestrictedMode[MAX_SUPPORTED_MODE];
-} DXVA_PARAMS;
-
-typedef struct {
- const CLSID* clsMinorType;
- const enum AVCodecID nFFCodec;
- const DXVA_PARAMS* DXVAModes;
-
- int DXVAModeCount() {
- if (!DXVAModes) {
- return 0;
- }
- for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
- if (DXVAModes->Decoder[i] == &GUID_NULL) {
- return i;
- }
- }
- return MAX_SUPPORTED_MODE;
- }
-} FFMPEG_CODECS;
-
-// DXVA modes supported for Mpeg2
-DXVA_PARAMS DXVA_Mpeg2 = {
- 9, // PicEntryNumber
- 1, // PreferedConfigBitstream
- { &DXVA2_ModeMPEG2_VLD, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_UNRESTRICTED, 0 } // Restricted mode for DXVA1?
-};
-
-// DXVA modes supported for H264
-DXVA_PARAMS DXVA_H264 = {
- 16, // PicEntryNumber
- 2, // PreferedConfigBitstream
- { &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_H264_E, 0}
-};
-
-DXVA_PARAMS DXVA_H264_VISTA = {
- 22, // PicEntryNumber
- 2, // PreferedConfigBitstream
- { &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_H264_E, 0}
-};
-
-// DXVA modes supported for VC1
-DXVA_PARAMS DXVA_VC1 = {
- 14, // PicEntryNumber
- 1, // PreferedConfigBitstream
- { &DXVA2_ModeVC1_D, &GUID_NULL },
- { DXVA_RESTRICTED_MODE_VC1_D, 0}
-};
-
-FFMPEG_CODECS ffCodecs[] = {
-#if HAS_FFMPEG_VIDEO_DECODERS
- // Flash video
- { &MEDIASUBTYPE_FLV1, AV_CODEC_ID_FLV1, nullptr },
- { &MEDIASUBTYPE_flv1, AV_CODEC_ID_FLV1, nullptr },
- { &MEDIASUBTYPE_FLV4, AV_CODEC_ID_VP6F, nullptr },
- { &MEDIASUBTYPE_flv4, AV_CODEC_ID_VP6F, nullptr },
- { &MEDIASUBTYPE_VP6F, AV_CODEC_ID_VP6F, nullptr },
- { &MEDIASUBTYPE_vp6f, AV_CODEC_ID_VP6F, nullptr },
-
- // VP3
- { &MEDIASUBTYPE_VP30, AV_CODEC_ID_VP3, nullptr },
- { &MEDIASUBTYPE_VP31, AV_CODEC_ID_VP3, nullptr },
-
- // VP5
- { &MEDIASUBTYPE_VP50, AV_CODEC_ID_VP5, nullptr },
- { &MEDIASUBTYPE_vp50, AV_CODEC_ID_VP5, nullptr },
-
- // VP6
- { &MEDIASUBTYPE_VP60, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_vp60, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_VP61, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_vp61, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_VP62, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_vp62, AV_CODEC_ID_VP6, nullptr },
- { &MEDIASUBTYPE_VP6A, AV_CODEC_ID_VP6A, nullptr },
- { &MEDIASUBTYPE_vp6a, AV_CODEC_ID_VP6A, nullptr },
-
- // VP8
- { &MEDIASUBTYPE_VP80, AV_CODEC_ID_VP8, nullptr },
-
- // Xvid
- { &MEDIASUBTYPE_XVID, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_xvid, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_XVIX, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_xvix, AV_CODEC_ID_MPEG4, nullptr },
-
- // DivX
- { &MEDIASUBTYPE_DX50, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_dx50, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_DIVX, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_divx, AV_CODEC_ID_MPEG4, nullptr },
-
- // WMV1/2/3
- { &MEDIASUBTYPE_WMV1, AV_CODEC_ID_WMV1, nullptr },
- { &MEDIASUBTYPE_wmv1, AV_CODEC_ID_WMV1, nullptr },
- { &MEDIASUBTYPE_WMV2, AV_CODEC_ID_WMV2, nullptr },
- { &MEDIASUBTYPE_wmv2, AV_CODEC_ID_WMV2, nullptr },
- { &MEDIASUBTYPE_WMV3, AV_CODEC_ID_WMV3, &DXVA_VC1 },
- { &MEDIASUBTYPE_wmv3, AV_CODEC_ID_WMV3, &DXVA_VC1 },
-
- // MPEG-2
- { &MEDIASUBTYPE_MPEG2_VIDEO, AV_CODEC_ID_MPEG2VIDEO, &DXVA_Mpeg2 },
- { &MEDIASUBTYPE_MPG2, AV_CODEC_ID_MPEG2VIDEO, &DXVA_Mpeg2 },
-
- // MSMPEG-4
- { &MEDIASUBTYPE_DIV3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_div3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DVX3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_dvx3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_MP43, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_mp43, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_COL1, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_col1, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DIV4, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_div4, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DIV5, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_div5, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DIV6, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_div6, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_AP41, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_ap41, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_MPG3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_mpg3, AV_CODEC_ID_MSMPEG4V3, nullptr },
- { &MEDIASUBTYPE_DIV2, AV_CODEC_ID_MSMPEG4V2, nullptr },
- { &MEDIASUBTYPE_div2, AV_CODEC_ID_MSMPEG4V2, nullptr },
- { &MEDIASUBTYPE_MP42, AV_CODEC_ID_MSMPEG4V2, nullptr },
- { &MEDIASUBTYPE_mp42, AV_CODEC_ID_MSMPEG4V2, nullptr },
- { &MEDIASUBTYPE_MPG4, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_mpg4, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_DIV1, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_div1, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_MP41, AV_CODEC_ID_MSMPEG4V1, nullptr },
- { &MEDIASUBTYPE_mp41, AV_CODEC_ID_MSMPEG4V1, nullptr },
-
- // AMV Video
- { &MEDIASUBTYPE_AMVV, AV_CODEC_ID_AMV, nullptr },
-
- // MJPEG
- { &MEDIASUBTYPE_MJPG, AV_CODEC_ID_MJPEG, nullptr },
- { &MEDIASUBTYPE_QTJpeg, AV_CODEC_ID_MJPEG, nullptr },
- { &MEDIASUBTYPE_MJPA, AV_CODEC_ID_MJPEG, nullptr },
- { &MEDIASUBTYPE_MJPB, AV_CODEC_ID_MJPEGB, nullptr },
-
- // Indeo 3/4/5
- { &MEDIASUBTYPE_IV31, AV_CODEC_ID_INDEO3, nullptr },
- { &MEDIASUBTYPE_IV32, AV_CODEC_ID_INDEO3, nullptr },
- { &MEDIASUBTYPE_IV41, AV_CODEC_ID_INDEO4, nullptr },
- { &MEDIASUBTYPE_IV50, AV_CODEC_ID_INDEO5, nullptr },
-
- // Screen Capture(TSCC, VMnc)
- { &MEDIASUBTYPE_TSCC, AV_CODEC_ID_TSCC, nullptr },
- { &MEDIASUBTYPE_VMnc, AV_CODEC_ID_VMNC, nullptr },
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // H264/AVC
- { &MEDIASUBTYPE_H264, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_h264, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_X264, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_x264, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_VSSH, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_vssh, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_DAVC, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_davc, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_PAVC, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_pavc, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_AVC1, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_avc1, AV_CODEC_ID_H264, &DXVA_H264 },
- { &MEDIASUBTYPE_H264_bis, AV_CODEC_ID_H264, &DXVA_H264 },
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- // SVQ3
- { &MEDIASUBTYPE_SVQ3, AV_CODEC_ID_SVQ3, nullptr },
-
- // SVQ1
- { &MEDIASUBTYPE_SVQ1, AV_CODEC_ID_SVQ1, nullptr },
-
- // H263
- { &MEDIASUBTYPE_H263, AV_CODEC_ID_H263, nullptr },
- { &MEDIASUBTYPE_h263, AV_CODEC_ID_H263, nullptr },
-
- { &MEDIASUBTYPE_S263, AV_CODEC_ID_H263, nullptr },
- { &MEDIASUBTYPE_s263, AV_CODEC_ID_H263, nullptr },
-
- // Real Video
- { &MEDIASUBTYPE_RV10, AV_CODEC_ID_RV10, nullptr },
- { &MEDIASUBTYPE_RV20, AV_CODEC_ID_RV20, nullptr },
- { &MEDIASUBTYPE_RV30, AV_CODEC_ID_RV30, nullptr },
- { &MEDIASUBTYPE_RV40, AV_CODEC_ID_RV40, nullptr },
-
- // Theora
- { &MEDIASUBTYPE_THEORA, AV_CODEC_ID_THEORA, nullptr },
- { &MEDIASUBTYPE_theora, AV_CODEC_ID_THEORA, nullptr },
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // WVC1
- { &MEDIASUBTYPE_WVC1, AV_CODEC_ID_VC1, &DXVA_VC1 },
- { &MEDIASUBTYPE_wvc1, AV_CODEC_ID_VC1, &DXVA_VC1 },
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- // Other MPEG-4
- { &MEDIASUBTYPE_MP4V, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_mp4v, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_M4S2, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_m4s2, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_MP4S, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_mp4s, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3IV1, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3iv1, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3IV2, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3iv2, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3IVX, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_3ivx, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_BLZ0, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_blz0, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_DM4V, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_dm4v, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_FFDS, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_ffds, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_FVFW, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_fvfw, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_DXGM, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_dxgm, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_FMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_fmp4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_HDX4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_hdx4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_LMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_lmp4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_NDIG, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_ndig, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_RMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_rmp4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_SMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_smp4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_SEDG, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_sedg, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_UMP4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_ump4, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_WV1F, AV_CODEC_ID_MPEG4, nullptr },
- { &MEDIASUBTYPE_wv1f, AV_CODEC_ID_MPEG4, nullptr }
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-};
-
-/* Important: the order should be exactly the same as in ffCodecs[] */
-const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesIn[] = {
-#if HAS_FFMPEG_VIDEO_DECODERS
- // Flash video
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_flv1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_flv4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6F },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6f },
-
- // VP3
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP30 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP31 },
-
- // VP5
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP50 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp50 },
-
- // VP6
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP60 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp60 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP61 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp61 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP62 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp62 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6A },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6a },
-
- // VP8
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VP80 },
-
- // Xvid
- { &MEDIATYPE_Video, &MEDIASUBTYPE_XVID },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_xvid },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_XVIX },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_xvix },
-
- // DivX
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DX50 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dx50 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIVX },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_divx },
-
- // WMV1/2/3
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv3 },
-
- // MPEG-2
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG2 },
-
- // MSMPEG-4
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DVX3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dvx3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP43 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp43 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_COL1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_col1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV5 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div5 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV6 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div6 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_AP41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ap41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg3 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP42 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp42 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_div1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp41 },
-
- // AMV Video
- { &MEDIATYPE_Video, &MEDIASUBTYPE_AMVV },
-
- // MJPEG
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPG },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_QTJpeg },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPA },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPB },
-
- // Indeo 3/4/5
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV31 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV32 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV41 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_IV50 },
-
- // Screen Capture(TSCC, VMnc)
- { &MEDIATYPE_Video, &MEDIASUBTYPE_TSCC },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VMnc },
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // H264/AVC
- { &MEDIATYPE_Video, &MEDIASUBTYPE_H264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_h264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_X264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_x264 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_VSSH },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_vssh },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DAVC },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_davc },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_PAVC },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_pavc },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_AVC1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_avc1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_H264_bis },
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- // SVQ3
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ3 },
-
- // SVQ1
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ1 },
-
- // H263
- { &MEDIATYPE_Video, &MEDIASUBTYPE_H263 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_h263 },
-
- { &MEDIATYPE_Video, &MEDIASUBTYPE_S263 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_s263 },
-
- // Real video
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV10 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV20 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV30 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RV40 },
-
- // Theora
- { &MEDIATYPE_Video, &MEDIASUBTYPE_THEORA },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_theora },
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // VC1
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WVC1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wvc1 },
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- // IMPORTANT : some of the last MediaTypes present in next group may be not available in
- // the standalone filter (workaround to prevent GraphEdit crash).
- // Other MPEG-4
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4V },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4v },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_M4S2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_m4s2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4S },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4s },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv1 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv2 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3IVX },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_3ivx },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_BLZ0 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_blz0 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DM4V },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dm4v },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FFDS },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ffds },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FVFW },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_fvfw },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_DXGM },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_dxgm },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_FMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_fmp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_HDX4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_hdx4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_LMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_lmp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_NDIG },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ndig },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_RMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_rmp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_smp4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_SEDG },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_sedg },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_UMP4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_ump4 },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_WV1F },
- { &MEDIATYPE_Video, &MEDIASUBTYPE_wv1f }
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-};
-
-const int CMPCVideoDecFilter::sudPinTypesInCount = _countof(CMPCVideoDecFilter::sudPinTypesIn);
-
-const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesOut[] = {
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NV12},
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NV24}
-};
-const int CMPCVideoDecFilter::sudPinTypesOutCount = _countof(CMPCVideoDecFilter::sudPinTypesOut);
-
-BOOL CALLBACK EnumFindProcessWnd(HWND hwnd, LPARAM lParam)
-{
- DWORD procid = 0;
- TCHAR WindowClass [40];
- GetWindowThreadProcessId(hwnd, &procid);
- GetClassName(hwnd, WindowClass, _countof(WindowClass));
-
- if (procid == GetCurrentProcessId() && _tcscmp(WindowClass, _T("MediaPlayerClassicW")) == 0) {
- HWND* pWnd = (HWND*)lParam;
- *pWnd = hwnd;
- return FALSE;
- }
- return TRUE;
-}
-
-CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CBaseVideoFilter(MPCVideoDecName, lpunk, phr, __uuidof(this))
-{
- HWND hWnd = nullptr;
-
- if (SysVersion::IsVistaOrLater()) {
- for (int i = 0; i < _countof(ffCodecs); i++) {
- if (ffCodecs[i].nFFCodec == AV_CODEC_ID_H264) {
- ffCodecs[i].DXVAModes = &DXVA_H264_VISTA;
- }
- }
- }
-
- if (phr) {
- *phr = S_OK;
- }
-
- if (m_pOutput) {
- delete m_pOutput;
- }
- m_pOutput = DEBUG_NEW CVideoDecOutputPin(NAME("CVideoDecOutputPin"), this, phr, L"Output");
- if (!m_pOutput) {
- *phr = E_OUTOFMEMORY;
- }
-
- m_pCpuId = DEBUG_NEW CCpuId();
- m_pAVCodec = nullptr;
- m_pAVCtx = nullptr;
- m_pFrame = nullptr;
- m_nCodecNb = -1;
- m_nCodecId = AV_CODEC_ID_NONE;
- m_bReorderBFrame = true;
- m_DXVADecoderGUID = GUID_NULL;
- m_nActiveCodecs = MPCVD_H264 | MPCVD_VC1 | MPCVD_XVID | MPCVD_DIVX | MPCVD_MSMPEG4 |
- MPCVD_FLASH | MPCVD_WMV | MPCVD_H263 | MPCVD_SVQ3 | MPCVD_AMVV |
- MPCVD_THEORA | MPCVD_H264_DXVA | MPCVD_VC1_DXVA | MPCVD_VP356 |
- MPCVD_VP8 | MPCVD_MJPEG | MPCVD_INDEO | MPCVD_RV | MPCVD_WMV3_DXVA |
- MPCVD_MPEG2_DXVA;
-
- m_rtAvrTimePerFrame = 0;
- m_rtLastStart = 0;
- m_nCountEstimated = 0;
- m_rtPrevStop = 0;
-
- m_nWorkaroundBug = FF_BUG_AUTODETECT;
- m_nErrorConcealment = FF_EC_DEBLOCK | FF_EC_GUESS_MVS;
-
- m_nThreadNumber = 0;
- m_nDiscardMode = AVDISCARD_DEFAULT;
- m_bDXVACompatible = true;
- m_pFFBuffer = nullptr;
- m_nFFBufferSize = 0;
- m_pAlignedFFBuffer = nullptr;
- m_nAlignedFFBufferSize = 0;
- ResetBuffer();
-
- m_nWidth = 0;
- m_nHeight = 0;
- m_pSwsContext = nullptr;
-
- m_bUseDXVA = true;
- m_bUseFFmpeg = true;
-
- m_nDXVAMode = MODE_SOFTWARE;
- m_pDXVADecoder = nullptr;
- m_pVideoOutputFormat = nullptr;
- m_nVideoOutputCount = 0;
- m_hDevice = INVALID_HANDLE_VALUE;
-
- m_nARMode = 1;
- m_nDXVACheckCompatibility = 1; // skip level check by default
- m_nDXVA_SD = 0;
- m_par.SetSize(1, 1);
-
- m_interlacedFlag = MPCVC_INTERLACED_AUTO;
-
- m_bTheoraMTSupport = true;
- m_bWaitingForKeyFrame = TRUE;
- m_nPosB = 1;
- m_bFrame_repeat_pict = false;
- m_bIsEVO = false;
-
-#ifdef STANDALONE_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, OPT_REGKEY_VideoDec, KEY_READ)) {
- DWORD dw;
-#if HAS_FFMPEG_VIDEO_DECODERS
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_ThreadNumber, dw)) {
- m_nThreadNumber = dw;
- }
-#if INTERNAL_DECODER_H264
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_DiscardMode, dw)) {
- m_nDiscardMode = dw;
- }
-#endif
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_ActiveCodecs, dw)) {
- m_nActiveCodecs = dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_ARMode, dw)) {
- m_nARMode = dw;
- }
-#endif
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_DXVACheck, dw)) {
- m_nDXVACheckCompatibility = dw;
- }
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_DisableDXVA_SD, dw)) {
- m_nDXVA_SD = dw;
- }
-
- if (ERROR_SUCCESS == key.QueryDWORDValue(OPT_InterlacedFlag, dw)) {
- m_interlacedFlag = (MPCVD_INTERLACED_FLAG)dw;
- }
- }
-#else
-#if HAS_FFMPEG_VIDEO_DECODERS
- m_nThreadNumber = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_ThreadNumber, m_nThreadNumber);
-#if INTERNAL_DECODER_H264
- m_nDiscardMode = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_DiscardMode, m_nDiscardMode);
-#endif
- m_nARMode = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_ARMode, m_nARMode);
-#endif
- m_nDXVACheckCompatibility = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_DXVACheck, m_nDXVACheckCompatibility);
- m_nDXVA_SD = AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_DisableDXVA_SD, m_nDXVA_SD);
-
- m_interlacedFlag = (MPCVD_INTERLACED_FLAG)AfxGetApp()->GetProfileInt(OPT_SECTION_VideoDec, OPT_InterlacedFlag, m_interlacedFlag);
-#endif
-
- if (m_nDXVACheckCompatibility > 3) {
- m_nDXVACheckCompatibility = 1; // skip level check by default
- }
-
- ff_avcodec_default_get_buffer = avcodec_default_get_buffer;
- ff_avcodec_default_release_buffer = avcodec_default_release_buffer;
- ff_avcodec_default_reget_buffer = avcodec_default_reget_buffer;
-
- avcodec_register_all();
- av_log_set_callback(LogLibavcodec);
-
- EnumWindows(EnumFindProcessWnd, (LPARAM)&hWnd);
- DetectVideoCard(hWnd);
-
-#ifdef _DEBUG
- // Check codec definition table
- int nCodecs = _countof(ffCodecs);
- int nPinTypes = _countof(sudPinTypesIn);
- ASSERT(nCodecs == nPinTypes);
- for (int i = 0; i < nPinTypes; i++) {
- ASSERT(ffCodecs[i].clsMinorType == sudPinTypesIn[i].clsMinorType);
- }
-#endif
-}
-
-void CMPCVideoDecFilter::DetectVideoCard(HWND hWnd)
-{
- IDirect3D9* pD3D9;
- m_nPCIVendor = 0;
- m_nPCIDevice = 0;
- m_VideoDriverVersion.HighPart = 0;
- m_VideoDriverVersion.LowPart = 0;
-
- pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
- if (pD3D9) {
- D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, hWnd), 0, &adapterIdentifier) == S_OK) {
- m_nPCIVendor = adapterIdentifier.VendorId;
- m_nPCIDevice = adapterIdentifier.DeviceId;
- m_VideoDriverVersion = adapterIdentifier.DriverVersion;
- m_strDeviceDescription = adapterIdentifier.Description;
- m_strDeviceDescription.AppendFormat(_T(" (%04X:%04X)"), m_nPCIVendor, m_nPCIDevice);
- }
- pD3D9->Release();
- }
-}
-
-CMPCVideoDecFilter::~CMPCVideoDecFilter()
-{
- Cleanup();
- SAFE_DELETE(m_pCpuId);
-}
-
-bool CMPCVideoDecFilter::IsVideoInterlaced()
-{
- // NOT A BUG : always tell DirectShow it's interlaced (progressive flags set in
- // SetTypeSpecificFlags function)
- return true;
-};
-
-void CMPCVideoDecFilter::UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop, bool b_repeat_pict)
-{
- bool m_PullDownFlag = (m_nCodecId == AV_CODEC_ID_VC1 && b_repeat_pict && m_rtAvrTimePerFrame == 333666);
- REFERENCE_TIME m_rtFrameDuration = m_PullDownFlag ? AVRTIMEPERFRAME_VC1_EVO : m_rtAvrTimePerFrame;
-
- if ((rtStart == _I64_MIN) || (m_PullDownFlag && m_rtPrevStop && (rtStart <= m_rtPrevStop))) {
- rtStart = m_rtLastStart + (REFERENCE_TIME)(m_rtFrameDuration / m_dRate) * m_nCountEstimated;
- m_nCountEstimated++;
- } else {
- m_rtLastStart = rtStart;
- m_nCountEstimated = 1;
- }
-
- rtStop = rtStart + (REFERENCE_TIME)(m_rtFrameDuration / m_dRate);
-}
-
-void CMPCVideoDecFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight)
-{
-#if 1
- RealWidth = m_nWidth;
- RealHeight = m_nHeight;
- w = PictWidthRounded();
- h = PictHeightRounded();
-#else
- if (m_nDXVAMode == MODE_SOFTWARE) {
- w = m_nWidth;
- h = m_nHeight;
- } else {
- // DXVA surfaces are multiple of 16 pixels!
- w = PictWidthRounded();
- h = PictHeightRounded();
- }
-#endif
-}
-
-int CMPCVideoDecFilter::PictWidth()
-{
- return m_nWidth;
-}
-
-int CMPCVideoDecFilter::PictHeight()
-{
- return m_nHeight;
-}
-
-int CMPCVideoDecFilter::PictWidthRounded()
-{
- // Picture height should be rounded to 16 for DXVA
- return ((m_nWidth + 15) / 16) * 16;
-}
-
-int CMPCVideoDecFilter::PictHeightRounded()
-{
- // Picture height should be rounded to 16 for DXVA
- return ((m_nHeight + 15) / 16) * 16;
-}
-
-int CMPCVideoDecFilter::FindCodec(const CMediaType* mtIn)
-{
- for (int i = 0; i < _countof(ffCodecs); i++) {
- if (mtIn->subtype == *ffCodecs[i].clsMinorType) {
-#ifndef STANDALONE_FILTER
-/*
- switch (ffCodecs[i].nFFCodec) {
- case AV_CODEC_ID_H264:
-#if INTERNAL_DECODER_H264_DXVA
- m_bUseDXVA = m_DXVAFilters && m_DXVAFilters[TRA_DXVA_H264];
-#else
- m_bUseDXVA = false;
-#endif
-#if INTERNAL_DECODER_H264
- m_bUseFFmpeg = m_FFmpegFilters && m_FFmpegFilters[FFM_H264];
-#else
- m_bUseFFmpeg = false;
-#endif
- break;
- case AV_CODEC_ID_VC1:
-#if INTERNAL_DECODER_VC1_DXVA
- m_bUseDXVA = m_DXVAFilters && m_DXVAFilters[TRA_DXVA_VC1];
-#else
- m_bUseDXVA = false;
-#endif
-#if INTERNAL_DECODER_VC1
- m_bUseFFmpeg = m_FFmpegFilters && m_FFmpegFilters[FFM_VC1];
-#else
- m_bUseFFmpeg = false;
-#endif
- break;
- case AV_CODEC_ID_WMV3:
-#if INTERNAL_DECODER_WMV3_DXVA
- m_bUseDXVA = m_DXVAFilters && m_DXVAFilters[TRA_DXVA_WMV3];
-#else
- m_bUseDXVA = false;
-#endif
-#if INTERNAL_DECODER_WMV
- m_bUseFFmpeg = m_FFmpegFilters && m_FFmpegFilters[FFM_WMV];
-#else
- m_bUseFFmpeg = false;
-#endif
- break;
- case AV_CODEC_ID_MPEG2VIDEO:
-#if INTERNAL_DECODER_MPEG2_DXVA
- m_bUseDXVA = true;
-#endif
- m_bUseFFmpeg = false; // No Mpeg2 software support with ffmpeg!
- break;
- default:
- m_bUseDXVA = false;
- }
-
- return ((m_bUseDXVA || m_bUseFFmpeg) ? i : -1);
-*/
-#else
- bool bCodecActivated = false;
- switch (ffCodecs[i].nFFCodec) {
- case AV_CODEC_ID_FLV1:
- case AV_CODEC_ID_VP6F:
- bCodecActivated = (m_nActiveCodecs & MPCVD_FLASH) != 0;
- break;
- case AV_CODEC_ID_MPEG4:
- if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DX50) || // DivX
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx)) {
- bCodecActivated = (m_nActiveCodecs & MPCVD_DIVX) != 0;
- } else {
- bCodecActivated = (m_nActiveCodecs & MPCVD_XVID) != 0; // Xvid/MPEG-4
- }
- break;
- case AV_CODEC_ID_WMV1:
- case AV_CODEC_ID_WMV2:
- bCodecActivated = (m_nActiveCodecs & MPCVD_WMV) != 0;
- break;
- case AV_CODEC_ID_WMV3:
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_WMV3_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_WMV) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case AV_CODEC_ID_MSMPEG4V3:
- case AV_CODEC_ID_MSMPEG4V2:
- case AV_CODEC_ID_MSMPEG4V1:
- bCodecActivated = (m_nActiveCodecs & MPCVD_MSMPEG4) != 0;
- break;
- case AV_CODEC_ID_H264:
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_H264_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_H264) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case AV_CODEC_ID_SVQ3:
- case AV_CODEC_ID_SVQ1:
- bCodecActivated = (m_nActiveCodecs & MPCVD_SVQ3) != 0;
- break;
- case AV_CODEC_ID_H263:
- bCodecActivated = (m_nActiveCodecs & MPCVD_H263) != 0;
- break;
- case AV_CODEC_ID_THEORA:
- bCodecActivated = (m_nActiveCodecs & MPCVD_THEORA) != 0;
- break;
- case AV_CODEC_ID_VC1:
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_VC1_DXVA) != 0;
- m_bUseFFmpeg = (m_nActiveCodecs & MPCVD_VC1) != 0;
- bCodecActivated = m_bUseDXVA || m_bUseFFmpeg;
- break;
- case AV_CODEC_ID_AMV:
- bCodecActivated = (m_nActiveCodecs & MPCVD_AMVV) != 0;
- break;
- case AV_CODEC_ID_VP3:
- case AV_CODEC_ID_VP5:
- case AV_CODEC_ID_VP6:
- case AV_CODEC_ID_VP6A:
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP356) != 0;
- break;
- case AV_CODEC_ID_VP8:
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP8) != 0;
- break;
- case AV_CODEC_ID_MJPEG:
- case AV_CODEC_ID_MJPEGB:
- bCodecActivated = (m_nActiveCodecs & MPCVD_MJPEG) != 0;
- break;
- case AV_CODEC_ID_INDEO3:
- case AV_CODEC_ID_INDEO4:
- case AV_CODEC_ID_INDEO5:
- bCodecActivated = (m_nActiveCodecs & MPCVD_INDEO) != 0;
- break;
- case AV_CODEC_ID_TSCC:
- case AV_CODEC_ID_VMNC:
- bCodecActivated = 1;
- break;
- case AV_CODEC_ID_RV10:
- case AV_CODEC_ID_RV20:
- case AV_CODEC_ID_RV30:
- case AV_CODEC_ID_RV40:
- bCodecActivated = (m_nActiveCodecs & MPCVD_RV) != 0;
- break;
- case AV_CODEC_ID_MPEG2VIDEO:
- m_bUseDXVA = (m_nActiveCodecs & MPCVD_MPEG2_DXVA) != 0;
- m_bUseFFmpeg = false;
- bCodecActivated = m_bUseDXVA;
- break;
- }
- return (bCodecActivated ? i : -1);
-#endif
- }
- }
-
- return -1;
-}
-
-void CMPCVideoDecFilter::Cleanup()
-{
- SAFE_DELETE(m_pDXVADecoder);
-
- // Release FFmpeg
- if (m_pAVCtx) {
- if (m_pAVCtx->extradata) {
- av_freep(&m_pAVCtx->extradata);
- }
- if (m_pFFBuffer) {
- av_freep(&m_pFFBuffer);
- }
- m_nFFBufferSize = 0;
- if (m_pAlignedFFBuffer) {
- av_freep(&m_pAlignedFFBuffer);
- }
- m_nAlignedFFBufferSize = 0;
-
- if (m_pAVCtx->codec) {
- avcodec_close(m_pAVCtx);
- }
-
- // Free thread resource if necessary
- FFSetThreadNumber(m_pAVCtx, m_pAVCtx->codec_id, 0);
-
- av_freep(&m_pAVCtx);
- }
-
- if (m_pFrame) {
- av_freep(&m_pFrame);
- }
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_pSwsContext) {
- sws_freeContext(m_pSwsContext);
- m_pSwsContext = nullptr;
- }
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- m_pAVCodec = nullptr;
- m_pAVCtx = nullptr;
- m_pFrame = nullptr;
- m_pFFBuffer = nullptr;
- m_nFFBufferSize = 0;
- m_nFFBufferPos = 0;
- m_nFFPicEnd = INT_MIN;
- m_nCodecNb = -1;
- m_nCodecId = AV_CODEC_ID_NONE;
- SAFE_DELETE_ARRAY(m_pVideoOutputFormat);
-
- // Release DXVA ressources
- if (m_hDevice != INVALID_HANDLE_VALUE) {
- m_pDeviceManager->CloseDeviceHandle(m_hDevice);
- m_hDevice = INVALID_HANDLE_VALUE;
- }
-
- m_pDeviceManager = nullptr;
- m_pDecoderService = nullptr;
- m_pDecoderRenderTarget = nullptr;
-}
-
-void CMPCVideoDecFilter::CalcAvgTimePerFrame()
-{
- CMediaType& mt = m_pInput->CurrentMediaType();
- if (mt.formattype == FORMAT_VideoInfo) {
- m_rtAvrTimePerFrame = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
- } else if (mt.formattype == FORMAT_VideoInfo2) {
- m_rtAvrTimePerFrame = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
- } else if (mt.formattype == FORMAT_MPEGVideo) {
- m_rtAvrTimePerFrame = ((MPEG1VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- } else if (mt.formattype == FORMAT_MPEG2Video) {
- m_rtAvrTimePerFrame = ((MPEG2VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- } else {
- ASSERT(FALSE);
- m_rtAvrTimePerFrame = 1;
- }
-
- m_rtAvrTimePerFrame = max(1, m_rtAvrTimePerFrame);
-}
-
-void CMPCVideoDecFilter::LogLibavcodec(void* par, int level, const char* fmt, va_list valist)
-{
-#if defined(_DEBUG) && 0
- if (level <= AV_LOG_VERBOSE) {
- char Msg [500];
- vsnprintf_s(Msg, sizeof(Msg), _TRUNCATE, fmt, valist);
- TRACE(_T("AVLIB : %s\n"), Msg);
- }
-#endif
-}
-
-void CMPCVideoDecFilter::OnGetBuffer(AVFrame* pic)
-{
- // Callback from FFmpeg to store Ref Time in frame (needed to have correct rtStart after avcodec_decode_video calls)
- //pic->rtStart = m_rtStart;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- return
- QI(IMPCVideoDecFilter)
- QI(IMPCVideoDecFilter2)
- QI(ISpecifyPropertyPages)
- QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-
-
-HRESULT CMPCVideoDecFilter::CheckInputType(const CMediaType* mtIn)
-{
- for (int i = 0; i < _countof(sudPinTypesIn); i++) {
- if ((mtIn->majortype == *sudPinTypesIn[i].clsMajorType) &&
- (mtIn->subtype == *sudPinTypesIn[i].clsMinorType)) {
- return S_OK;
- }
- }
-
- return VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-bool CMPCVideoDecFilter::IsMultiThreadSupported(enum AVCodecID nCodec)
-{
- return
- (
- nCodec == AV_CODEC_ID_H264 ||
- nCodec == AV_CODEC_ID_MPEG1VIDEO ||
- nCodec == AV_CODEC_ID_FFV1 ||
- nCodec == AV_CODEC_ID_DVVIDEO ||
- nCodec == AV_CODEC_ID_VP3 ||
- nCodec == AV_CODEC_ID_VP8 ||
- nCodec == AV_CODEC_ID_THEORA ||
- nCodec == AV_CODEC_ID_RV30 ||
- nCodec == AV_CODEC_ID_RV40
- );
-}
-
-CString CMPCVideoDecFilter::GetFileExtension()
-{
- CString ext;
-
- BeginEnumFilters(m_pGraph, pEF, pBF) {
- CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if (pFSF) {
- LPOLESTR pFN = nullptr;
- AM_MEDIA_TYPE mt;
- if (SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
- ext = CPath(CStringW(pFN)).GetExtension();
- ext.MakeLower();
- CoTaskMemFree(pFN);
- }
- break;
- }
- }
- EndEnumFilters;
-
- return ext;
-}
-
-HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction, const CMediaType* pmt)
-{
- if (direction == PINDIR_INPUT) {
-
- int nNewCodec = FindCodec(pmt);
-
- if (nNewCodec == -1) {
- return VFW_E_TYPE_NOT_ACCEPTED;
- }
-
- if (nNewCodec != m_nCodecNb) {
- m_nCodecNb = nNewCodec;
- m_nCodecId = ffCodecs[nNewCodec].nFFCodec;
-
- CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if ((ClsidSourceFilter == __uuidof(COggSourceFilter)) || (ClsidSourceFilter == __uuidof(COggSplitterFilter))) {
- m_bTheoraMTSupport = false;
- } else if ((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
- if (CComPtr<IBaseFilter> pFilter = GetFilterFromPin(m_pInput->GetConnected())) {
- if (CComQIPtr<IMpegSplitterFilter> MpegSplitterFilter = pFilter) {
- m_bIsEVO = (m_nCodecId == AV_CODEC_ID_VC1 && mpeg_ps == MpegSplitterFilter->GetMPEGType());
- }
- }
- }
-
- m_bReorderBFrame = true;
- m_pAVCodec = avcodec_find_decoder(m_nCodecId);
- CheckPointer(m_pAVCodec, VFW_E_UNSUPPORTED_VIDEO);
-
- m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);
- CheckPointer(m_pAVCtx, E_POINTER);
-
- int nThreadNumber = m_nThreadNumber ? m_nThreadNumber : m_pCpuId->GetProcessorNumber() * 3 / 2;
- if ((nThreadNumber > 1) && IsMultiThreadSupported(m_nCodecId)) {
- FFSetThreadNumber(m_pAVCtx, m_nCodecId, (IsDXVASupported() || (m_nCodecId == AV_CODEC_ID_THEORA && !m_bTheoraMTSupport)) ? 1 : nThreadNumber);
- }
-
- m_pFrame = avcodec_alloc_frame();
- CheckPointer(m_pFrame, E_POINTER);
-
- m_h264RandomAccess.flush(m_pAVCtx->thread_count);
-
- if (pmt->formattype == FORMAT_VideoInfo) {
- VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
- m_pAVCtx->width = vih->bmiHeader.biWidth;
- m_pAVCtx->height = abs(vih->bmiHeader.biHeight);
- m_pAVCtx->codec_tag = vih->bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = vih->bmiHeader.biBitCount;
- } else if (pmt->formattype == FORMAT_VideoInfo2) {
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->pbFormat;
- m_pAVCtx->width = vih2->bmiHeader.biWidth;
- m_pAVCtx->height = abs(vih2->bmiHeader.biHeight);
- m_pAVCtx->codec_tag = vih2->bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = vih2->bmiHeader.biBitCount;
- } else if (pmt->formattype == FORMAT_MPEGVideo) {
- MPEG1VIDEOINFO* mpgv = (MPEG1VIDEOINFO*)pmt->pbFormat;
- m_pAVCtx->width = mpgv->hdr.bmiHeader.biWidth;
- m_pAVCtx->height = abs(mpgv->hdr.bmiHeader.biHeight);
- m_pAVCtx->codec_tag = mpgv->hdr.bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = mpgv->hdr.bmiHeader.biBitCount;
- } else if (pmt->formattype == FORMAT_MPEG2Video) {
- MPEG2VIDEOINFO* mpg2v = (MPEG2VIDEOINFO*)pmt->pbFormat;
- m_pAVCtx->width = mpg2v->hdr.bmiHeader.biWidth;
- m_pAVCtx->height = abs(mpg2v->hdr.bmiHeader.biHeight);
- m_pAVCtx->codec_tag = mpg2v->hdr.bmiHeader.biCompression;
- m_pAVCtx->bits_per_coded_sample = mpg2v->hdr.bmiHeader.biBitCount;
-
- if (mpg2v->hdr.bmiHeader.biCompression == 0) {
- m_pAVCtx->codec_tag = pmt->subtype.Data1;
- } else if ((m_pAVCtx->codec_tag == MAKEFOURCC('a', 'v', 'c', '1')) || (m_pAVCtx->codec_tag == MAKEFOURCC('A', 'V', 'C', '1'))) {
- m_pAVCtx->nal_length_size = mpg2v->dwFlags;
- m_bReorderBFrame = (GetFileExtension() == _T(".avi")) ? true : false;
- } else if ((m_pAVCtx->codec_tag == MAKEFOURCC('m', 'p', '4', 'v')) || (m_pAVCtx->codec_tag == MAKEFOURCC('M', 'P', '4', 'V'))) {
- m_bReorderBFrame = false;
- }
- } else {
- return VFW_E_INVALIDMEDIATYPE;
- }
- m_nWidth = m_pAVCtx->width;
- m_nHeight = m_pAVCtx->height;
-
- if (m_pAVCtx->codec_tag == MAKEFOURCC('m', 'p', 'g', '2')) {
- m_pAVCtx->codec_tag = MAKEFOURCC('M', 'P', 'E', 'G');
- }
-
- if (m_nCodecId == AV_CODEC_ID_RV10 || m_nCodecId == AV_CODEC_ID_RV20 || m_nCodecId == AV_CODEC_ID_RV30 || m_nCodecId == AV_CODEC_ID_RV40) {
- m_bReorderBFrame = false;
- }
-
- m_pAVCtx->codec_id = m_nCodecId;
- m_pAVCtx->workaround_bugs = m_nWorkaroundBug;
- m_pAVCtx->error_concealment = m_nErrorConcealment;
- m_pAVCtx->err_recognition = AV_EF_CAREFUL;
- m_pAVCtx->idct_algo = FF_IDCT_AUTO;
- m_pAVCtx->skip_loop_filter = (AVDiscard)m_nDiscardMode;
- m_pAVCtx->dsp_mask = AV_CPU_FLAG_FORCE | m_pCpuId->GetFeatures();
-
- m_pAVCtx->debug_mv = 0;
-
- m_pAVCtx->opaque = this;
- m_pAVCtx->get_buffer = get_buffer;
-
- if (m_nCodecId == AV_CODEC_ID_H264) {
- m_pAVCtx->flags2 |= CODEC_FLAG2_SHOW_ALL;
- }
-
- AllocExtradata(m_pAVCtx, pmt);
- ConnectTo(m_pAVCtx);
- CalcAvgTimePerFrame();
-
- if (avcodec_open2(m_pAVCtx, m_pAVCodec, nullptr) < 0) {
- return VFW_E_INVALIDMEDIATYPE;
- }
-
- // if DXVA is supported in theory the file can still be incompatible
- bool bDXVAAvailableButUnused = IsDXVASupported();
- if (IsDXVASupported()) {
- do {
- m_bDXVACompatible = false;
-
- if (!DXVACheckFramesize(PictWidth(), PictHeight(), m_nPCIVendor, m_nPCIDevice)) { // check frame size
- break;
- }
-
- if (m_nCodecId == AV_CODEC_ID_H264) {
- if (m_nDXVA_SD && PictWidthRounded() < 1280) { // check "Disable DXVA for SD" option
- break;
- }
- int nCompat = FFH264CheckCompatibility(PictWidthRounded(), PictHeightRounded(), m_pAVCtx, (BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size, m_nPCIVendor, m_nPCIDevice, m_VideoDriverVersion);
- if (nCompat) {
- if (nCompat == DXVA_HIGH_BIT ||
- m_nDXVACheckCompatibility == 0 || // full check
- m_nDXVACheckCompatibility == 1 && nCompat != DXVA_UNSUPPORTED_LEVEL || // skip level check
- m_nDXVACheckCompatibility == 2 && nCompat != DXVA_TOO_MANY_REF_FRAMES) { // skip reference frame check
- break;
- }
- }
- } else if (m_nCodecId == AV_CODEC_ID_MPEG2VIDEO) {
- // DSP is disable for DXVA decoding (to keep default idct_permutation)
- m_pAVCtx->dsp_mask ^= AV_CPU_FLAG_FORCE;
- if (!MPEG2CheckCompatibility(m_pAVCtx, m_pFrame)) {
- break;
- }
- } else if (m_nCodecId == AV_CODEC_ID_WMV3) {
- if (PictWidth() <= 720) { // fixes color problem for some wmv files (profile <= MP@ML)
- break;
- }
- }
-
- m_bDXVACompatible = true;
- bDXVAAvailableButUnused = false;
- } while (false);
- }
-
- if (bDXVAAvailableButUnused) { // reset the threads count
- m_bUseDXVA = false;
- avcodec_close(m_pAVCtx);
- if ((nThreadNumber > 1) && IsMultiThreadSupported(m_nCodecId)) {
- FFSetThreadNumber(m_pAVCtx, m_nCodecId, nThreadNumber);
- }
- if (avcodec_open2(m_pAVCtx, m_pAVCodec, nullptr) < 0) {
- return VFW_E_INVALIDMEDIATYPE;
- }
- }
-
- BuildDXVAOutputFormat();
- }
- }
-
- HRESULT hr = __super::SetMediaType(direction, pmt);
-
- if (direction == PINDIR_INPUT) {
- // Compute the expected Pixel AR
- m_par.cx = m_arx * m_h;
- m_par.cy = m_ary * m_w;
- int gcd = GCD(m_par.cx, m_par.cy);
- if (gcd > 1) {
- m_par.cx /= gcd;
- m_par.cy /= gcd;
- }
- }
-
- return hr;
-}
-
-VIDEO_OUTPUT_FORMATS DXVAFormats[] = { // DXVA2
- {&MEDIASUBTYPE_NV12, 1, 12, 'avxd'},
- {&MEDIASUBTYPE_NV12, 1, 12, 'AVXD'},
- {&MEDIASUBTYPE_NV12, 1, 12, 'AVxD'},
- {&MEDIASUBTYPE_NV12, 1, 12, 'AvXD'}
-};
-
-VIDEO_OUTPUT_FORMATS SoftwareFormats1[] = { // Software
- {&MEDIASUBTYPE_NV12, 2, 12, '21VN'},
- {&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
- {&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'},
-};
-
-VIDEO_OUTPUT_FORMATS SoftwareFormats2[] = { // Software
- {&MEDIASUBTYPE_RGB32, 1, 32, BI_RGB},
-};
-
-bool CMPCVideoDecFilter::IsDXVASupported()
-{
- if (m_nCodecNb != -1) {
- // Does the codec suppport DXVA ?
- if (ffCodecs[m_nCodecNb].DXVAModes != nullptr) {
- // Enabled by user ?
- if (m_bUseDXVA) {
- // is the file compatible ?
- if (m_bDXVACompatible) {
- return true;
- }
- }
- }
- }
- return false;
-}
-
-void CMPCVideoDecFilter::BuildDXVAOutputFormat()
-{
- SAFE_DELETE_ARRAY(m_pVideoOutputFormat);
-
- m_nVideoOutputCount = IsDXVASupported() ? ffCodecs[m_nCodecNb].DXVAModeCount() + _countof(DXVAFormats) : 0;
- if (m_bUseFFmpeg) {
- if (!(m_pAVCtx->width & 1 || m_pAVCtx->height & 1)) { // Do not use NV12, YV12 and YUY2 if width or height is not even
- m_nVideoOutputCount += _countof(SoftwareFormats1);
- }
- m_nVideoOutputCount += _countof(SoftwareFormats2);
- }
- m_pVideoOutputFormat = DEBUG_NEW VIDEO_OUTPUT_FORMATS[m_nVideoOutputCount];
-
- int nPos = 0;
- if (IsDXVASupported()) {
- // Dynamic DXVA media types for DXVA1
- for (nPos = 0; nPos < ffCodecs[m_nCodecNb].DXVAModeCount(); nPos++) {
- m_pVideoOutputFormat[nPos].subtype = ffCodecs[m_nCodecNb].DXVAModes->Decoder[nPos];
- m_pVideoOutputFormat[nPos].biCompression = 'avxd';
- m_pVideoOutputFormat[nPos].biBitCount = 12;
- m_pVideoOutputFormat[nPos].biPlanes = 1;
- }
-
- // Static list for DXVA2
- memcpy(&m_pVideoOutputFormat[nPos], DXVAFormats, sizeof(DXVAFormats));
- nPos += _countof(DXVAFormats);
- }
- // Software rendering
- if (m_bUseFFmpeg) {
- if (!(m_pAVCtx->width & 1 || m_pAVCtx->height & 1)) { // Do not use NV12, YV12 and YUY2 if width or height is not even
- memcpy(&m_pVideoOutputFormat[nPos], SoftwareFormats1, sizeof(SoftwareFormats1));
- nPos += _countof(SoftwareFormats1);
- }
- memcpy(&m_pVideoOutputFormat[nPos], SoftwareFormats2, sizeof(SoftwareFormats2));
- }
-}
-
-int CMPCVideoDecFilter::GetPicEntryNumber()
-{
- if (IsDXVASupported()) {
- return ffCodecs[m_nCodecNb].DXVAModes->PicEntryNumber;
- } else {
- return 0;
- }
-}
-
-void CMPCVideoDecFilter::GetOutputFormats(int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats)
-{
- nNumber = m_nVideoOutputCount;
- *ppFormats = m_pVideoOutputFormat;
-}
-
-void CMPCVideoDecFilter::AllocExtradata(AVCodecContext* pAVCtx, const CMediaType* pmt)
-{
- // code from LAV ...
- // Process Extradata
- BYTE* extra = nullptr;
- unsigned int extralen = 0;
- getExtraData((const BYTE*)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), nullptr, &extralen);
-
- BOOL bH264avc = FALSE;
- if (extralen > 0) {
- TRACE(_T("CMPCVideoDecFilter::AllocExtradata() : processing extradata of %d bytes\n"), extralen);
- // Reconstruct AVC1 extradata format
- if (pmt->formattype == FORMAT_MPEG2Video && (m_pAVCtx->codec_tag == MAKEFOURCC('a', 'v', 'c', '1') || m_pAVCtx->codec_tag == MAKEFOURCC('A', 'V', 'C', '1') || m_pAVCtx->codec_tag == MAKEFOURCC('C', 'C', 'V', '1'))) {
- MPEG2VIDEOINFO* mp2vi = (MPEG2VIDEOINFO*)pmt->Format();
- extralen += 7;
- extra = (uint8_t*)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- extra[0] = 1;
- extra[1] = (BYTE)mp2vi->dwProfile;
- extra[2] = 0;
- extra[3] = (BYTE)mp2vi->dwLevel;
- extra[4] = (BYTE)(mp2vi->dwFlags ? mp2vi->dwFlags : 2) - 1;
-
- // Actually copy the metadata into our new buffer
- unsigned int actual_len;
- getExtraData((const BYTE*)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), extra + 6, &actual_len);
-
- // Count the number of SPS/PPS in them and set the length
- // We'll put them all into one block and add a second block with 0 elements afterwards
- // The parsing logic does not care what type they are, it just expects 2 blocks.
- BYTE* p = extra + 6, *end = extra + 6 + actual_len;
- BOOL bSPS = FALSE, bPPS = FALSE;
- int count = 0;
- while (p + 1 < end) {
- unsigned len = (((unsigned)p[0] << 8) | p[1]) + 2;
- if (p + len > end) {
- break;
- }
- if ((p[2] & 0x1F) == 7) {
- bSPS = TRUE;
- }
- if ((p[2] & 0x1F) == 8) {
- bPPS = TRUE;
- }
- count++;
- p += len;
- }
- extra[5] = count;
- extra[extralen - 1] = 0;
-
- bH264avc = TRUE;
- if (!bSPS) {
- TRACE(_T("CMPCVideoDecFilter::AllocExtradata() : AVC1 extradata doesn't contain a SPS, setting thread_count = 1\n"));
- m_pAVCtx->thread_count = 1;
- }
- } else {
- // Just copy extradata for other formats
- extra = (uint8_t*)av_mallocz(extralen + FF_INPUT_BUFFER_PADDING_SIZE);
- getExtraData((const BYTE*)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), extra, nullptr);
- }
- // Hack to discard invalid MP4 metadata with AnnexB style video
- if (m_nCodecId == AV_CODEC_ID_H264 && !bH264avc && extra[0] == 1) {
- av_freep(&extra);
- extralen = 0;
- }
- m_pAVCtx->extradata = extra;
- m_pAVCtx->extradata_size = (int)extralen;
- }
-}
-
-HRESULT CMPCVideoDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pReceivePin)
-{
- LOG(_T("CMPCVideoDecFilter::CompleteConnect"));
-
- if (direction == PINDIR_INPUT && m_pOutput->IsConnected()) {
- ReconnectOutput(m_nWidth, m_nHeight);
- } else if (direction == PINDIR_OUTPUT) {
- if (IsDXVASupported()) {
- if (m_nDXVAMode == MODE_DXVA1) {
- m_pDXVADecoder->ConfigureDXVA1();
- } else if (SUCCEEDED(ConfigureDXVA2(pReceivePin)) && SUCCEEDED(SetEVRForDXVA2(pReceivePin))) {
- m_nDXVAMode = MODE_DXVA2;
- }
- }
- if (m_nDXVAMode == MODE_SOFTWARE && (!m_bUseFFmpeg || !FFSoftwareCheckCompatibility(m_pAVCtx))) {
- return VFW_E_INVALIDMEDIATYPE;
- }
-
- CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if ((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
- m_bReorderBFrame = false;
- }
- }
-
- return __super::CompleteConnect(direction, pReceivePin);
-}
-
-HRESULT CMPCVideoDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
-{
- if (UseDXVA2()) {
- HRESULT hr;
- ALLOCATOR_PROPERTIES Actual;
-
- if (m_pInput->IsConnected() == FALSE) {
- return E_UNEXPECTED;
- }
-
- pProperties->cBuffers = GetPicEntryNumber();
-
- if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
- return hr;
- }
-
- return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR;
- } else {
- return __super::DecideBufferSize(pAllocator, pProperties);
- }
-}
-
-HRESULT CMPCVideoDecFilter::BeginFlush()
-{
- return __super::BeginFlush();
-}
-
-HRESULT CMPCVideoDecFilter::EndFlush()
-{
- CAutoLock cAutoLock(&m_csReceive);
- return __super::EndFlush();
-}
-
-HRESULT CMPCVideoDecFilter::NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double dRate)
-{
- CAutoLock cAutoLock(&m_csReceive);
-
- if (m_pAVCtx) {
- avcodec_flush_buffers(m_pAVCtx);
- }
-
- if (m_pDXVADecoder) {
- m_pDXVADecoder->Flush();
- }
-
- m_nPosB = 1;
- ZeroMemory(&m_BFrames, sizeof(m_BFrames));
- m_rtLastStart = 0;
- m_nCountEstimated = 0;
- m_dRate = dRate;
-
- ResetBuffer();
-
- m_h264RandomAccess.flush(m_pAVCtx->thread_count);
-
- m_bWaitingForKeyFrame = TRUE;
-
- m_rtPrevStop = 0;
-
- rm.video_after_seek = true;
- m_rtStart = rtStart;
-
- return __super::NewSegment(rtStart, rtStop, dRate);
-}
-
-HRESULT CMPCVideoDecFilter::EndOfStream()
-{
- CAutoLock cAutoLock(&m_csReceive);
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_nDXVAMode == MODE_SOFTWARE) {
- REFERENCE_TIME rtStart = 0, rtStop = 0;
- SoftwareDecode(nullptr, nullptr, 0, rtStart, rtStop);
- } else
-#endif
- if (m_nDXVAMode == MODE_DXVA2) { // TODO - need to check DXVA1 on WinXP
- m_pDXVADecoder->EndOfStream();
- }
-
- return __super::EndOfStream();
-}
-
-HRESULT CMPCVideoDecFilter::BreakConnect(PIN_DIRECTION dir)
-{
- if (dir == PINDIR_INPUT) {
- Cleanup();
- }
-
- return __super::BreakConnect(dir);
-}
-
-void CMPCVideoDecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
-{
- if (CComQIPtr<IMediaSample2> pMS2 = pMS) {
- AM_SAMPLE2_PROPERTIES props;
- if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
- props.dwTypeSpecificFlags &= ~0x7f;
-
- m_nFrameType = PICT_BOTTOM_FIELD;
- if ((m_interlacedFlag == MPCVC_INTERLACED_AUTO && !m_pFrame->interlaced_frame)
- || m_interlacedFlag == MPCVC_INTERLACED_PROGRESSIVE) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- m_nFrameType = PICT_FRAME;
- } else {
- if ((m_interlacedFlag == MPCVC_INTERLACED_AUTO && m_pFrame->top_field_first)
- || m_interlacedFlag == MPCVC_INTERLACED_TOP_FIELD_FIRST) {
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- m_nFrameType = PICT_TOP_FIELD;
- }
- }
-
- switch (m_pFrame->pict_type) {
- case AV_PICTURE_TYPE_I:
- case AV_PICTURE_TYPE_SI:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- break;
- case AV_PICTURE_TYPE_P:
- case AV_PICTURE_TYPE_SP:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- break;
- default:
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- break;
- }
-
- pMS2->SetProperties(sizeof(props), (BYTE*)&props);
- }
- }
-}
-
-#if HAS_FFMPEG_VIDEO_DECODERS
-unsigned __int64 CMPCVideoDecFilter::GetCspFromMediaType(GUID& subtype)
-{
- if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
- return (FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ);
- } else if (subtype == MEDIASUBTYPE_NV12) {
- return FF_CSP_NV12;
- } else if (subtype == MEDIASUBTYPE_RGB32) {
- return FF_CSP_RGB32;
- } else if (subtype == MEDIASUBTYPE_YUY2) {
- return FF_CSP_YUY2;
- }
-
- ASSERT(FALSE);
- return FF_CSP_NULL;
-}
-
-void CMPCVideoDecFilter::InitSwscale()
-{
- if (m_pSwsContext == nullptr) {
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
-
- int sws_Flags = SWS_BILINEAR | SWS_FULL_CHR_H_INT | SWS_FULL_CHR_H_INP | SWS_ACCURATE_RND;
-
- m_nOutCsp = GetCspFromMediaType(m_pOutput->CurrentMediaType().subtype);
-
- PixelFormat pix_fmt = csp_ffdshow2lavc(csp_lavc2ffdshow(m_pAVCtx->pix_fmt));
- if (pix_fmt == PIX_FMT_NB) {
- pix_fmt = m_pAVCtx->pix_fmt;
- }
-
- m_pSwsContext = sws_getCachedContext(
- nullptr,
- m_pAVCtx->width,
- m_pAVCtx->height,
- pix_fmt,
- m_pAVCtx->width,
- m_pAVCtx->height,
- csp_ffdshow2lavc(m_nOutCsp),
- sws_Flags | SWS_PRINT_INFO,
- nullptr,
- nullptr,
- nullptr);
-
- m_nSwOutBpp = bihOut.biBitCount;
- m_pOutSize.cx = bihOut.biWidth;
- m_pOutSize.cy = abs(bihOut.biHeight);
-
- int* inv_tbl = nullptr, *tbl = nullptr;
- int srcRange, dstRange, brightness, contrast, saturation;
- int ret = sws_getColorspaceDetails(m_pSwsContext, &inv_tbl, &srcRange, &tbl, &dstRange, &brightness, &contrast, &saturation);
- if (ret >= 0) {
- sws_setColorspaceDetails(m_pSwsContext, sws_getCoefficients((PictWidthRounded() > 768) ? SWS_CS_ITU709 : SWS_CS_ITU601), srcRange, tbl, dstRange, brightness, contrast, saturation);
- }
- }
-}
-
-#define RM_SKIP_BITS(n) (buffer <<= n)
-#define RM_SHOW_BITS(n) ((buffer) >> (32 - (n)))
-
-static int rm_fix_timestamp(uint8_t* buf, int64_t timestamp, enum AVCodecID nCodecId, int64_t* kf_base, int* kf_pts)
-{
- uint8_t* s = buf + 1 + (*buf + 1) * 8;
- uint32_t buffer = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3];
- uint32_t kf = timestamp;
- int pict_type;
- uint32_t orig_kf;
-
- if (nCodecId == AV_CODEC_ID_RV30) {
- RM_SKIP_BITS(3);
- pict_type = RM_SHOW_BITS(2);
- RM_SKIP_BITS(2 + 7);
- } else {
- RM_SKIP_BITS(1);
- pict_type = RM_SHOW_BITS(2);
- RM_SKIP_BITS(2 + 7 + 3);
- }
- orig_kf = kf = RM_SHOW_BITS(13); // kf= 2*RM_SHOW_BITS(12);
- if (pict_type <= 1) {
- // I frame, sync timestamps:
- *kf_base = (int64_t)timestamp - kf;
- kf = timestamp;
- } else {
- // P/B frame, merge timestamps:
- int64_t tmp = (int64_t)timestamp - *kf_base;
- kf |= tmp & (~0x1fff); // combine with packet timestamp
- if (kf < tmp - 4096) {
- kf += 8192;
- } else if (kf > tmp + 4096) { // workaround wrap-around problems
- kf -= 8192;
- }
- kf += *kf_base;
- }
- if (pict_type != 3) { // P || I frame -> swap timestamps
- uint32_t tmp = kf;
- kf = *kf_pts;
- *kf_pts = tmp;
- }
-
- return kf;
-}
-
-static int64_t process_rv_timestamp(RMDemuxContext* rm, enum AVCodecID nCodecId, uint8_t* buf, int64_t timestamp)
-{
- if (rm->video_after_seek) {
- rm->kf_base = 0;
- rm->kf_pts = timestamp;
- rm->video_after_seek = false;
- }
- return rm_fix_timestamp(buf, timestamp, nCodecId, &rm->kf_base, &rm->kf_pts);
-}
-
-void copyPlane(BYTE* dstp, stride_t dst_pitch, const BYTE* srcp, stride_t src_pitch, int row_size, int height, bool flip = false)
-{
- if (!flip) {
- for (int y = height; y > 0; --y) {
- memcpy(dstp, srcp, row_size);
- dstp += dst_pitch;
- srcp += src_pitch;
- }
- } else {
- dstp += dst_pitch * (height - 1);
- for (int y = height; y > 0; --y) {
- memcpy(dstp, srcp, row_size);
- dstp -= dst_pitch;
- srcp += src_pitch;
- }
- }
-}
-
-HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int nSize, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
-{
- HRESULT hr = S_OK;
- int got_picture;
- int used_bytes;
- BOOL bFlush = (pDataIn == nullptr);
-
- AVPacket avpkt;
- av_init_packet(&avpkt);
-
- if (!bFlush && m_nCodecId == AV_CODEC_ID_H264) {
- if (!m_h264RandomAccess.searchRecoveryPoint(m_pAVCtx, pDataIn, nSize)) {
- return S_OK;
- }
- }
-
- while (nSize > 0 || bFlush) {
- if (!bFlush) {
- if (nSize + FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
- m_nFFBufferSize = nSize + FF_INPUT_BUFFER_PADDING_SIZE;
- m_pFFBuffer = (BYTE*)av_realloc(m_pFFBuffer, m_nFFBufferSize);
- if (!m_pFFBuffer) {
- m_nFFBufferSize = 0;
- return E_FAIL;
- }
- }
-
- // Required number of additionally allocated bytes at the end of the input bitstream for decoding.
- // This is mainly needed because some optimized bitstream readers read
- // 32 or 64 bit at once and could read over the end.
- // Note: If the first 23 bits of the additional bytes are not 0, then damaged
- // MPEG bitstreams could cause overread and segfault.
- memcpy(m_pFFBuffer, pDataIn, nSize);
- ZeroMemory(m_pFFBuffer + nSize, FF_INPUT_BUFFER_PADDING_SIZE);
-
- avpkt.data = m_pFFBuffer;
- avpkt.size = nSize;
- avpkt.pts = rtStart;
- avpkt.dts = rtStop;
- avpkt.flags = AV_PKT_FLAG_KEY;
- } else {
- avpkt.data = nullptr;
- avpkt.size = 0;
- }
- used_bytes = avcodec_decode_video2(m_pAVCtx, m_pFrame, &got_picture, &avpkt);
-
- if (used_bytes < 0) {
- return S_OK;
- }
-
- // Comment from LAV Video code:
- // When Frame Threading, we won't know how much data has been consumed, so it by default eats everything.
- // In addition, if no data got consumed, and no picture was extracted, the frame probably isn't all that useufl.
- // The MJPEB decoder is somewhat buggy and doesn't let us know how much data was consumed really...
- if ((m_pAVCtx->active_thread_type & FF_THREAD_FRAME || (!got_picture && used_bytes == 0)) || m_nCodecId == AV_CODEC_ID_MJPEGB || bFlush) {
- nSize = 0;
- } else {
- nSize -= used_bytes;
- pDataIn += used_bytes;
- }
-
- if (m_nCodecId == AV_CODEC_ID_H264) {
- m_h264RandomAccess.judgeFrameUsability(m_pFrame, &got_picture);
- } else if (m_nCodecId == AV_CODEC_ID_VC1 || m_nCodecId == AV_CODEC_ID_RV30 || m_nCodecId == AV_CODEC_ID_RV40) {
- if (m_bWaitingForKeyFrame && got_picture) {
- if (m_pFrame->key_frame) {
- m_bWaitingForKeyFrame = FALSE;
- } else {
- got_picture = 0;
- }
- }
- }
-
- if (!got_picture || !m_pFrame->data[0]) {
- bFlush = FALSE;
- continue;
- }
-
- if ((pIn && pIn->IsPreroll() == S_OK) || rtStart < 0) {
- return S_OK;
- }
-
- if (!m_bFrame_repeat_pict && m_pFrame->repeat_pict) {
- m_bFrame_repeat_pict = true;
- }
-
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = nullptr;
-
- UpdateAspectRatio();
- if (FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut))) {
- return hr;
- }
-
- if (m_nCodecId == AV_CODEC_ID_THEORA || (m_nCodecId == AV_CODEC_ID_VP8 && m_rtAvrTimePerFrame == 10000)) { // need more tests
- rtStart = m_pFrame->pkt_pts;
- rtStop = m_pFrame->pkt_dts;
- } else if ((m_nCodecId == AV_CODEC_ID_RV10 || m_nCodecId == AV_CODEC_ID_RV20) && m_pFrame->pict_type == AV_PICTURE_TYPE_B) {
- rtStart = m_rtPrevStop;
- rtStop = rtStart + m_rtAvrTimePerFrame;
- } else if ((m_nCodecId == AV_CODEC_ID_RV30 || m_nCodecId == AV_CODEC_ID_RV40) && avpkt.data) {
- rtStart = (rtStart == _I64_MIN) ? m_rtPrevStop : (10000i64 * process_rv_timestamp(&rm, m_nCodecId, avpkt.data, (rtStart + m_rtStart) / 10000) - m_rtStart);
- rtStop = rtStart + m_rtAvrTimePerFrame;
- } else if (!(m_nCodecId == AV_CODEC_ID_VC1 && m_bFrame_repeat_pict && m_rtAvrTimePerFrame == 333666)) {
- rtStart = m_pFrame->reordered_opaque;
- rtStop = m_pFrame->reordered_opaque2;
- }
-
- m_rtPrevStop = rtStop;
-
- ReorderBFrames(rtStart, rtStop);
-
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(nullptr, nullptr);
-
- if (m_pSwsContext == nullptr) {
- InitSwscale();
- }
- if (m_pSwsContext != nullptr) {
-
- int outStride = m_pOutSize.cx;
- BYTE* outData = pDataOut;
-
- // From LAVVideo ...
- // Check if we have proper pixel alignment and the dst memory is actually aligned
- if (FFALIGN(outStride, 16) != outStride || ((uintptr_t)pDataOut % 16u)) {
- outStride = FFALIGN(outStride, 16);
- int requiredSize = (outStride * m_pAVCtx->height * m_nSwOutBpp) << 3;
- if (requiredSize > m_nAlignedFFBufferSize) {
- av_freep(&m_pAlignedFFBuffer);
- m_nAlignedFFBufferSize = requiredSize;
- m_pAlignedFFBuffer = (BYTE*)av_malloc(m_nAlignedFFBufferSize + FF_INPUT_BUFFER_PADDING_SIZE);
- }
- outData = m_pAlignedFFBuffer;
- }
-
- uint8_t* dst[4] = {nullptr, nullptr, nullptr, nullptr};
- stride_t dstStride[4] = {0, 0, 0, 0};
- const TcspInfo* outcspInfo = csp_getInfo(m_nOutCsp);
-
- if (m_nOutCsp == FF_CSP_YUY2 || m_nOutCsp == FF_CSP_RGB32) {
- dst[0] = outData;
- dstStride[0] = (m_nSwOutBpp >> 3) * (outStride);
- } else {
- for (unsigned int i = 0; i < outcspInfo->numPlanes; i++) {
- dstStride[i] = outStride >> outcspInfo->shiftX[i];
- dst[i] = !i ? outData : dst[i - 1] + dstStride[i - 1] * (m_pOutSize.cy >> outcspInfo->shiftY[i - 1]);
- }
-
- if (m_nOutCsp & FF_CSP_420P) {
- std::swap(dst[1], dst[2]);
- }
- }
-
- sws_scale(m_pSwsContext, m_pFrame->data, m_pFrame->linesize, 0, m_pAVCtx->height, dst, dstStride);
-
- if (outData != pDataOut) {
- if (m_nOutCsp & FF_CSP_420P) {
- std::swap(dst[1], dst[2]);
- }
- int rowsize = 0, height = 0;
- for (unsigned int i = 0; i < outcspInfo->numPlanes; i++) {
- rowsize = (m_pOutSize.cx * outcspInfo->Bpp) >> outcspInfo->shiftX[i];
- height = m_pAVCtx->height >> outcspInfo->shiftY[i];
- copyPlane(pDataOut, rowsize, dst[i], (outStride * outcspInfo->Bpp) >> outcspInfo->shiftX[i], rowsize, height, (m_nOutCsp == FF_CSP_RGB32));
- pDataOut += rowsize * height;
- }
- }
- }
-
-#if defined(_DEBUG) && 0
- static REFERENCE_TIME rtLast = 0;
- TRACE(_T("Deliver : %10I64d - %10I64d (%10I64d) {%10I64d}\n"), rtStart, rtStop,
- rtStop - rtStart, rtStart - rtLast);
- rtLast = rtStart;
-#endif
-
- SetTypeSpecificFlags(pOut);
- hr = m_pOutput->Deliver(pOut);
- }
-
- return hr;
-}
-
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
-bool CMPCVideoDecFilter::FindPicture(int nIndex, int nStartCode)
-{
- DWORD dw = 0;
-
- for (int i = 0; i < m_nFFBufferPos - nIndex; i++) {
- dw = (dw << 8) + m_pFFBuffer[i + nIndex];
- if (i >= 4) {
- if (m_nFFPicEnd == INT_MIN) {
- if ((dw & 0xffffff00) == 0x00000100 &&
- (dw & 0x000000FF) == (DWORD)nStartCode) {
- m_nFFPicEnd = i + nIndex - 3;
- }
- } else {
- if ((dw & 0xffffff00) == 0x00000100 &&
- ((dw & 0x000000FF) == (DWORD)nStartCode || (dw & 0x000000FF) == 0xB3)) {
- m_nFFPicEnd = i + nIndex - 3;
- return true;
- }
- }
- }
-
- }
-
- return false;
-}
-
-void CMPCVideoDecFilter::ResetBuffer()
-{
- m_nFFBufferPos = 0;
- m_nFFPicEnd = INT_MIN;
-
- for (int i = 0; i < MAX_BUFF_TIME; i++) {
- m_FFBufferTime[i].nBuffPos = INT_MIN;
- m_FFBufferTime[i].rtStart = _I64_MIN;
- m_FFBufferTime[i].rtStop = _I64_MIN;
- }
-}
-
-void CMPCVideoDecFilter::PushBufferTime(int nPos, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
-{
- for (int i = 0; i < MAX_BUFF_TIME; i++) {
- if (m_FFBufferTime[i].nBuffPos == INT_MIN) {
- m_FFBufferTime[i].nBuffPos = nPos;
- m_FFBufferTime[i].rtStart = rtStart;
- m_FFBufferTime[i].rtStop = rtStop;
- break;
- }
- }
-}
-
-void CMPCVideoDecFilter::PopBufferTime(int nPos)
-{
- int nDestPos = 0;
- int i = 0;
-
- // Shift buffer time list
- while (i < MAX_BUFF_TIME && m_FFBufferTime[i].nBuffPos != INT_MIN) {
- if (m_FFBufferTime[i].nBuffPos >= nPos) {
- m_FFBufferTime[nDestPos].nBuffPos = m_FFBufferTime[i].nBuffPos - nPos;
- m_FFBufferTime[nDestPos].rtStart = m_FFBufferTime[i].rtStart;
- m_FFBufferTime[nDestPos].rtStop = m_FFBufferTime[i].rtStop;
- nDestPos++;
- }
- i++;
- }
-
- // Free unused slots
- for (i = nDestPos; i < MAX_BUFF_TIME; i++) {
- m_FFBufferTime[i].nBuffPos = INT_MIN;
- m_FFBufferTime[i].rtStart = _I64_MIN;
- m_FFBufferTime[i].rtStop = _I64_MIN;
- }
-}
-
-bool CMPCVideoDecFilter::AppendBuffer(BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
-{
- if (rtStart != _I64_MIN) {
- PushBufferTime(m_nFFBufferPos, rtStart, rtStop);
- }
-
- if (m_nFFBufferPos + nSize + FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
- m_nFFBufferSize = m_nFFBufferPos + nSize + FF_INPUT_BUFFER_PADDING_SIZE;
- m_pFFBuffer = (BYTE*)av_realloc(m_pFFBuffer, m_nFFBufferSize);
- }
-
- memcpy(m_pFFBuffer + m_nFFBufferPos, pDataIn, nSize);
-
- m_nFFBufferPos += nSize;
-
- return true;
-}
-
-void CMPCVideoDecFilter::ShrinkBuffer()
-{
- int nRemaining = m_nFFBufferPos - m_nFFPicEnd;
-
- ASSERT(m_nFFPicEnd != INT_MIN);
-
- PopBufferTime(m_nFFPicEnd);
- memcpy(m_pFFBuffer, m_pFFBuffer + m_nFFPicEnd, nRemaining);
- m_nFFBufferPos = nRemaining;
-
- m_nFFPicEnd = (m_pFFBuffer[3] == 0x00) ? 0 : INT_MIN;
-}
-
-HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
-{
- CAutoLock cAutoLock(&m_csReceive);
- HRESULT hr;
- BYTE* pDataIn;
- int nSize;
- REFERENCE_TIME rtStart = _I64_MIN;
- REFERENCE_TIME rtStop = _I64_MIN;
-
- if (FAILED(hr = pIn->GetPointer(&pDataIn))) {
- return hr;
- }
-
- nSize = pIn->GetActualDataLength();
- hr = pIn->GetTime(&rtStart, &rtStop);
-
- if (FAILED(hr)) {
- rtStart = rtStop = _I64_MIN;
- }
-
- if (m_nDXVAMode == MODE_SOFTWARE || (m_nCodecId == AV_CODEC_ID_VC1 && !m_bIsEVO)) {
- UpdateFrameTime(rtStart, rtStop, m_bFrame_repeat_pict);
- }
-
- m_pAVCtx->reordered_opaque = rtStart;
- m_pAVCtx->reordered_opaque2 = rtStop;
-
- if (m_pAVCtx->has_b_frames) {
- m_BFrames[m_nPosB].rtStart = rtStart;
- m_BFrames[m_nPosB].rtStop = rtStop;
- m_nPosB = 1 - m_nPosB;
- }
-
- switch (m_nDXVAMode) {
-#if HAS_FFMPEG_VIDEO_DECODERS
- case MODE_SOFTWARE:
- hr = SoftwareDecode(pIn, pDataIn, nSize, rtStart, rtStop);
- break;
-#endif
- case MODE_DXVA1:
- case MODE_DXVA2:
- CheckPointer(m_pDXVADecoder, E_UNEXPECTED);
- UpdateAspectRatio();
-
- // Change aspect ratio for DXVA1
- if ((m_nDXVAMode == MODE_DXVA1) &&
- ReconnectOutput(PictWidthRounded(), PictHeightRounded(), true, PictWidth(), PictHeight()) == S_OK) {
- m_pDXVADecoder->ConfigureDXVA1();
- }
-
- if (m_pAVCtx->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
- AppendBuffer(pDataIn, nSize, rtStart, rtStop);
- hr = S_OK;
-
- while (FindPicture(max(m_nFFBufferPos - nSize - 4, 0), 0x00)) {
- if (m_FFBufferTime[0].nBuffPos != INT_MIN && m_FFBufferTime[0].nBuffPos < m_nFFPicEnd) {
- rtStart = m_FFBufferTime[0].rtStart;
- rtStop = m_FFBufferTime[0].rtStop;
- } else {
- rtStart = rtStop = _I64_MIN;
- }
- hr = m_pDXVADecoder->DecodeFrame(m_pFFBuffer, m_nFFPicEnd, rtStart, rtStop);
- ShrinkBuffer();
- }
- } else {
- hr = m_pDXVADecoder->DecodeFrame(pDataIn, nSize, rtStart, rtStop);
- }
- break;
- default:
- ASSERT(FALSE);
- hr = E_UNEXPECTED;
- }
-
- return hr;
-}
-
-void CMPCVideoDecFilter::UpdateAspectRatio()
-{
- if (m_nARMode && m_pAVCtx && (m_pAVCtx->sample_aspect_ratio.num > 0) && (m_pAVCtx->sample_aspect_ratio.den > 0)) {
- CSize PAR(m_pAVCtx->sample_aspect_ratio.num, m_pAVCtx->sample_aspect_ratio.den);
- if (m_par != PAR) {
- m_par = PAR;
- CSize aspect(m_nWidth * PAR.cx, m_nHeight * PAR.cy);
- int gcd = GCD(aspect.cx, aspect.cy);
- if (gcd > 1) {
- aspect.cx /= gcd;
- aspect.cy /= gcd;
- }
- SetAspect(aspect);
- }
- }
-}
-
-void CMPCVideoDecFilter::ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
-{
- // Re-order B-frames if needed
- if (m_pAVCtx->has_b_frames && m_bReorderBFrame) {
- rtStart = m_BFrames [m_nPosB].rtStart;
- rtStop = m_BFrames [m_nPosB].rtStop;
- }
-}
-
-void CMPCVideoDecFilter::FillInVideoDescription(DXVA2_VideoDesc* pDesc)
-{
- ZeroMemory(pDesc, sizeof(DXVA2_VideoDesc));
- pDesc->SampleWidth = PictWidthRounded();
- pDesc->SampleHeight = PictHeightRounded();
- pDesc->Format = D3DFMT_A8R8G8B8;
- pDesc->UABProtectionLevel = 1;
-}
-
-BOOL CMPCVideoDecFilter::IsSupportedDecoderMode(const GUID& mode)
-{
- if (IsDXVASupported()) {
- for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == GUID_NULL) {
- break;
- } else if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == mode) {
- return true;
- }
- }
- }
-
- return false;
-}
-
-BOOL CMPCVideoDecFilter::IsSupportedDecoderConfig(const D3DFORMAT nD3DFormat, const DXVA2_ConfigPictureDecode& config, bool& bIsPrefered)
-{
- bool bRet = false;
-
- bRet = (nD3DFormat == MAKEFOURCC('N', 'V', '1', '2') || nD3DFormat == MAKEFOURCC('I', 'M', 'C', '3'));
-
- bIsPrefered = (config.ConfigBitstreamRaw == ffCodecs[m_nCodecNb].DXVAModes->PreferedConfigBitstream);
- LOG(_T("IsSupportedDecoderConfig 0x%08x %d"), nD3DFormat, bRet);
- return bRet;
-}
-
-HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService* pDecoderService,
- const GUID& guidDecoder,
- DXVA2_ConfigPictureDecode* pSelectedConfig,
- BOOL* pbFoundDXVA2Configuration)
-{
- HRESULT hr = S_OK;
- UINT cFormats = 0;
- UINT cConfigurations = 0;
- bool bIsPrefered = false;
-
- D3DFORMAT* pFormats = nullptr; // size = cFormats
- DXVA2_ConfigPictureDecode* pConfig = nullptr; // size = cConfigurations
-
- // Find the valid render target formats for this decoder GUID.
- hr = pDecoderService->GetDecoderRenderTargets(guidDecoder, &cFormats, &pFormats);
- LOG(_T("GetDecoderRenderTargets => %d"), cFormats);
-
- if (SUCCEEDED(hr)) {
- // Look for a format that matches our output format.
- for (UINT iFormat = 0; iFormat < cFormats; iFormat++) {
- LOG(_T("Try to negociate => 0x%08x"), pFormats[iFormat]);
-
- // Fill in the video description. Set the width, height, format, and frame rate.
- FillInVideoDescription(&m_VideoDesc); // Private helper function.
- m_VideoDesc.Format = pFormats[iFormat];
-
- // Get the available configurations.
- hr = pDecoderService->GetDecoderConfigurations(guidDecoder, &m_VideoDesc, nullptr, &cConfigurations, &pConfig);
-
- if (FAILED(hr)) {
- continue;
- }
-
- // Find a supported configuration.
- for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++) {
- if (IsSupportedDecoderConfig(pFormats[iFormat], pConfig[iConfig], bIsPrefered)) {
- // This configuration is good.
- if (bIsPrefered || !*pbFoundDXVA2Configuration) {
- *pbFoundDXVA2Configuration = TRUE;
- *pSelectedConfig = pConfig[iConfig];
- }
-
- if (bIsPrefered) {
- break;
- }
- }
- }
-
- CoTaskMemFree(pConfig);
- } // End of formats loop.
- }
-
- CoTaskMemFree(pFormats);
-
- // Note: It is possible to return S_OK without finding a configuration.
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::ConfigureDXVA2(IPin* pPin)
-{
- HRESULT hr = S_OK;
- UINT cDecoderGuids = 0;
- BOOL bFoundDXVA2Configuration = FALSE;
- BOOL bHasIntelGuid = FALSE;
- GUID guidDecoder = GUID_NULL;
-
- DXVA2_ConfigPictureDecode config;
- ZeroMemory(&config, sizeof(config));
-
- CComPtr<IMFGetService> pGetService;
- CComPtr<IDirect3DDeviceManager9> pDeviceManager;
- CComPtr<IDirectXVideoDecoderService> pDecoderService;
- GUID* pDecoderGuids = nullptr;
- HANDLE hDevice = INVALID_HANDLE_VALUE;
-
- // Query the pin for IMFGetService.
- hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
-
- // Get the Direct3D device manager.
- if (SUCCEEDED(hr)) {
- hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirect3DDeviceManager9),
- (void**)&pDeviceManager);
- }
-
- // Open a new device handle.
- if (SUCCEEDED(hr)) {
- hr = pDeviceManager->OpenDeviceHandle(&hDevice);
- }
-
- // Get the video decoder service.
- if (SUCCEEDED(hr)) {
- hr = pDeviceManager->GetVideoService(
- hDevice,
- __uuidof(IDirectXVideoDecoderService),
- (void**)&pDecoderService);
- }
-
- // Get the decoder GUIDs.
- if (SUCCEEDED(hr)) {
- hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
- }
-
- if (SUCCEEDED(hr)) {
-
- // Intel patch for Ivy Bridge and Sandy Bridge
- if (m_nPCIVendor == PCIV_Intel) {
- for (UINT iCnt = 0; iCnt < cDecoderGuids; iCnt++) {
- if (pDecoderGuids[iCnt] == DXVA_Intel_H264_ClearVideo) {
- bHasIntelGuid = TRUE;
- }
- }
- }
- // Look for the decoder GUIDs we want.
- for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++) {
- // Do we support this mode?
- if (!IsSupportedDecoderMode(pDecoderGuids[iGuid])) {
- continue;
- }
-
- // Find a configuration that we support.
- hr = FindDXVA2DecoderConfiguration(pDecoderService, pDecoderGuids[iGuid], &config, &bFoundDXVA2Configuration);
-
- if (FAILED(hr)) {
- break;
- }
-
- // Patch for the Sandy Bridge (prevent crash on Mode_E, fixme later)
- if (m_nPCIVendor == PCIV_Intel && pDecoderGuids[iGuid] == DXVA2_ModeH264_E && bHasIntelGuid) {
- continue;
- }
-
- if (bFoundDXVA2Configuration) {
- // Found a good configuration. Save the GUID.
- guidDecoder = pDecoderGuids[iGuid];
- if (!bHasIntelGuid) {
- break;
- }
- }
- }
- }
-
- if (pDecoderGuids) {
- CoTaskMemFree(pDecoderGuids);
- }
- if (!bFoundDXVA2Configuration) {
- hr = E_FAIL; // Unable to find a configuration.
- }
-
- if (SUCCEEDED(hr)) {
- // Store the things we will need later.
- m_pDeviceManager = pDeviceManager;
- m_pDecoderService = pDecoderService;
-
- m_DXVA2Config = config;
- m_DXVADecoderGUID = guidDecoder;
- m_hDevice = hDevice;
- }
-
- if (FAILED(hr)) {
- if (hDevice != INVALID_HANDLE_VALUE) {
- pDeviceManager->CloseDeviceHandle(hDevice);
- }
- }
-
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::SetEVRForDXVA2(IPin* pPin)
-{
- HRESULT hr = S_OK;
-
- CComPtr<IMFGetService> pGetService;
- CComPtr<IDirectXVideoMemoryConfiguration> pVideoConfig;
- CComPtr<IMFVideoDisplayControl> pVdc;
-
- // Query the pin for IMFGetService.
- hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
-
- // Get the IDirectXVideoMemoryConfiguration interface.
- if (SUCCEEDED(hr)) {
- hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirectXVideoMemoryConfiguration),
- (void**)&pVideoConfig);
-
- if (SUCCEEDED(pGetService->GetService(MR_VIDEO_RENDER_SERVICE, __uuidof(IMFVideoDisplayControl), (void**)&pVdc))) {
- HWND hWnd;
- if (SUCCEEDED(pVdc->GetVideoWindow(&hWnd))) {
- DetectVideoCard(hWnd);
- }
- }
- }
-
- // Notify the EVR.
- if (SUCCEEDED(hr)) {
- DXVA2_SurfaceType surfaceType;
-
- for (DWORD iTypeIndex = 0; ; iTypeIndex++) {
- hr = pVideoConfig->GetAvailableSurfaceTypeByIndex(iTypeIndex, &surfaceType);
-
- if (FAILED(hr)) {
- break;
- }
-
- if (surfaceType == DXVA2_SurfaceType_DecoderRenderTarget) {
- hr = pVideoConfig->SetSurfaceType(DXVA2_SurfaceType_DecoderRenderTarget);
- break;
- }
- }
- }
-
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3DSurface9** pDecoderRenderTargets)
-{
- HRESULT hr;
- CComPtr<IDirectXVideoDecoder> pDirectXVideoDec;
-
- m_pDecoderRenderTarget = nullptr;
-
- if (m_pDXVADecoder) {
- m_pDXVADecoder->SetDirectXVideoDec(nullptr);
- }
-
- hr = m_pDecoderService->CreateVideoDecoder(m_DXVADecoderGUID, &m_VideoDesc, &m_DXVA2Config,
- pDecoderRenderTargets, nNumRenderTargets, &pDirectXVideoDec);
-
- if (SUCCEEDED(hr)) {
- if (m_nPCIVendor == PCIV_Intel) {
- // We need to recreate the dxva decoder after "stop" on Intel HD Graphics
- SAFE_DELETE(m_pDXVADecoder);
- }
- if (!m_pDXVADecoder) {
- m_pDXVADecoder = CDXVADecoder::CreateDecoder(this, pDirectXVideoDec, &m_DXVADecoderGUID, GetPicEntryNumber(), &m_DXVA2Config);
- if (m_pDXVADecoder) {
- m_pDXVADecoder->SetExtraData((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
- }
- }
-
- m_pDXVADecoder->SetDirectXVideoDec(pDirectXVideoDec);
- }
-
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::FindDXVA1DecoderConfiguration(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, DDPIXELFORMAT* pPixelFormat)
-{
- HRESULT hr = E_FAIL;
- DWORD dwFormats = 0;
- DDPIXELFORMAT* pPixelFormats = nullptr;
-
-
- pAMVideoAccelerator->GetUncompFormatsSupported(guidDecoder, &dwFormats, nullptr);
- if (dwFormats > 0) {
- // Find the valid render target formats for this decoder GUID.
- pPixelFormats = DEBUG_NEW DDPIXELFORMAT[dwFormats];
- hr = pAMVideoAccelerator->GetUncompFormatsSupported(guidDecoder, &dwFormats, pPixelFormats);
- if (SUCCEEDED(hr)) {
- // Look for a format that matches our output format.
- for (DWORD iFormat = 0; iFormat < dwFormats; iFormat++) {
- if (pPixelFormats[iFormat].dwFourCC == MAKEFOURCC('N', 'V', '1', '2')) {
- memcpy(pPixelFormat, &pPixelFormats[iFormat], sizeof(DDPIXELFORMAT));
- SAFE_DELETE_ARRAY(pPixelFormats);
- return S_OK;
- }
- }
-
- SAFE_DELETE_ARRAY(pPixelFormats);
- hr = E_FAIL;
- }
- }
-
- return hr;
-}
-
-HRESULT CMPCVideoDecFilter::CheckDXVA1Decoder(const GUID* pGuid)
-{
- if (m_nCodecNb != -1) {
- for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == *pGuid) {
- return S_OK;
- }
- }
- }
-
- return E_INVALIDARG;
-}
-
-void CMPCVideoDecFilter::SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixelFormat)
-{
- m_DXVADecoderGUID = *pGuid;
- memcpy(&m_PixelFormat, pPixelFormat, sizeof(DDPIXELFORMAT));
-}
-
-WORD CMPCVideoDecFilter::GetDXVA1RestrictedMode()
-{
- if (m_nCodecNb != -1) {
- for (int i = 0; i < MAX_SUPPORTED_MODE; i++) {
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == m_DXVADecoderGUID) {
- return ffCodecs[m_nCodecNb].DXVAModes->RestrictedMode [i];
- }
- }
- }
-
- return DXVA_RESTRICTED_MODE_UNRESTRICTED;
-}
-
-HRESULT CMPCVideoDecFilter::CreateDXVA1Decoder(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* pDecoderGuid, DWORD dwSurfaceCount)
-{
- if (m_pDXVADecoder && m_DXVADecoderGUID == *pDecoderGuid) {
- return S_OK;
- }
- SAFE_DELETE(m_pDXVADecoder);
-
- if (!m_bUseDXVA) {
- return E_FAIL;
- }
-
- m_nDXVAMode = MODE_DXVA1;
- m_DXVADecoderGUID = *pDecoderGuid;
- m_pDXVADecoder = CDXVADecoder::CreateDecoder(this, pAMVideoAccelerator, &m_DXVADecoderGUID, dwSurfaceCount);
- if (m_pDXVADecoder) {
- m_pDXVADecoder->SetExtraData((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
- }
-
- return S_OK;
-}
-
-// ISpecifyPropertyPages2
-
-STDMETHODIMP CMPCVideoDecFilter::GetPages(CAUUID* pPages)
-{
- CheckPointer(pPages, E_POINTER);
-
- HRESULT hr = S_OK;
-
-#ifdef STANDALONE_FILTER
- pPages->cElems = 2;
-#else
- pPages->cElems = 1;
-#endif
-
- pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
- if (pPages->pElems != nullptr) {
- pPages->pElems[0] = __uuidof(CMPCVideoDecSettingsWnd);
- if (pPages->cElems > 1) {
- pPages->pElems[1] = __uuidof(CMPCVideoDecCodecWnd);
- }
- } else {
- hr = E_OUTOFMEMORY;
- }
-
- return hr;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
-{
- CheckPointer(ppPage, E_POINTER);
-
- if (*ppPage != nullptr) {
- return E_INVALIDARG;
- }
-
- HRESULT hr;
-
- if (guid == __uuidof(CMPCVideoDecSettingsWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd>(nullptr, &hr))->AddRef();
- } else if (guid == __uuidof(CMPCVideoDecCodecWnd)) {
- (*ppPage = DEBUG_NEW CInternalPropertyPageTempl<CMPCVideoDecCodecWnd>(nullptr, &hr))->AddRef();
- }
-
- return *ppPage ? S_OK : E_FAIL;
-}
-
-void CMPCVideoDecFilter::SetFrameType(FF_FIELD_TYPE nFrameType)
-{
- m_nFrameType = nFrameType;
-}
-
-// IFFmpegDecFilter
-STDMETHODIMP CMPCVideoDecFilter::Apply()
-{
-#ifdef STANDALONE_FILTER
- CRegKey key;
- if (ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, OPT_REGKEY_VideoDec)) {
- key.SetDWORDValue(OPT_ThreadNumber, m_nThreadNumber);
- key.SetDWORDValue(OPT_DiscardMode, m_nDiscardMode);
- key.SetDWORDValue(OPT_ActiveCodecs, m_nActiveCodecs);
- key.SetDWORDValue(OPT_ARMode, m_nARMode);
- key.SetDWORDValue(OPT_DXVACheck, m_nDXVACheckCompatibility);
- key.SetDWORDValue(OPT_DisableDXVA_SD, m_nDXVA_SD);
- key.SetDWORDValue(OPT_InterlacedFlag, m_interlacedFlag);
- }
-#else
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_ThreadNumber, m_nThreadNumber);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_DiscardMode, m_nDiscardMode);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_ARMode, m_nARMode);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_DXVACheck, m_nDXVACheckCompatibility);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_DisableDXVA_SD, m_nDXVA_SD);
- AfxGetApp()->WriteProfileInt(OPT_SECTION_VideoDec, OPT_InterlacedFlag, m_interlacedFlag);
-#endif
-
- return S_OK;
-}
-
-// === IMPCVideoDecFilter
-
-STDMETHODIMP CMPCVideoDecFilter::SetThreadNumber(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nThreadNumber = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetThreadNumber()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nThreadNumber;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetDiscardMode(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nDiscardMode = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetDiscardMode()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nDiscardMode;
-}
-
-STDMETHODIMP_(GUID*) CMPCVideoDecFilter::GetDXVADecoderGuid()
-{
- if (m_pGraph == nullptr) {
- return nullptr;
- } else {
- return &m_DXVADecoderGUID;
- }
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetActiveCodecs(MPC_VIDEO_CODEC nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nActiveCodecs = (int)nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(MPC_VIDEO_CODEC) CMPCVideoDecFilter::GetActiveCodecs()
-{
- CAutoLock cAutoLock(&m_csProps);
- return (MPC_VIDEO_CODEC)m_nActiveCodecs;
-}
-
-STDMETHODIMP_(LPCTSTR) CMPCVideoDecFilter::GetVideoCardDescription()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_strDeviceDescription;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetARMode(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nARMode = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetARMode()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nARMode;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetDXVACheckCompatibility(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nDXVACheckCompatibility = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetDXVACheckCompatibility()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nDXVACheckCompatibility;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetDXVA_SD(int nValue)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_nDXVA_SD = nValue;
- return S_OK;
-}
-
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetDXVA_SD()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nDXVA_SD;
-}
-
-// === IMPCVideoDecFilter2
-STDMETHODIMP_(int) CMPCVideoDecFilter::GetFrameType()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_nFrameType;
-}
-
-STDMETHODIMP CMPCVideoDecFilter::SetInterlacedFlag(MPCVD_INTERLACED_FLAG interlacedFlag)
-{
- CAutoLock cAutoLock(&m_csProps);
- m_interlacedFlag = interlacedFlag;
- return S_OK;
-}
-
-STDMETHODIMP_(MPCVD_INTERLACED_FLAG) CMPCVideoDecFilter::GetInterlacedFlag()
-{
- CAutoLock cAutoLock(&m_csProps);
- return m_interlacedFlag;
-}
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
deleted file mode 100644
index 9784bd999..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <d3dx9.h>
-#include <videoacc.h> // DXVA1
-#include <dxva.h>
-#include <dxva2api.h> // DXVA2
-#include "../BaseVideoFilter/BaseVideoFilter.h"
-
-#include "IMPCVideoDecFilter.h"
-#include "MPCVideoDecSettingsWnd.h"
-#include "../../../DeCSS/DeCSSInputPin.h"
-#include "DXVADecoder.h"
-#include "TlibavcodecExt.h"
-
-#include "H264RandomAccess.h"
-#include <atlpath.h>
-
-// TODO: remove this when it's fixed in MSVC
-// Work around warning C4005: 'XXXX' : macro redefinition
-#pragma warning(push)
-#pragma warning(disable: 4005)
-#include <stdint.h>
-#pragma warning(pop)
-
-
-#define MPCVideoDecName L"MPC Video Decoder"
-
-#define MAX_BUFF_TIME 20
-
-#define CHECK_HR_TRACE(x) \
- hr = ##x; \
- if (FAILED(hr)) { \
- TRACE(_T("Error : 0x%08x\n"), hr); \
- ASSERT(hr == VFW_E_NOT_COMMITTED); \
- return hr; \
- }
-
-struct AVCodec;
-struct AVCodecContext;
-struct AVFrame;
-struct SwsContext;
-
-class CCpuId;
-
-typedef enum {
- MODE_SOFTWARE,
- MODE_DXVA1,
- MODE_DXVA2
-} DXVA_MODE;
-
-typedef struct {
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
-} B_FRAME;
-
-typedef struct {
- REFERENCE_TIME rtStart;
- REFERENCE_TIME rtStop;
- int nBuffPos;
-} BUFFER_TIME;
-
-typedef struct {
- bool video_after_seek;
- int kf_pts; ///< timestamp of next video keyframe
- int64_t kf_base; ///< timestamp of the previous video keyframe
-} RMDemuxContext;
-
-class __declspec(uuid("008BAC12-FBAF-497b-9670-BC6F6FBAE2C4"))
- CMPCVideoDecFilter
- : public CBaseVideoFilter
- , public TlibavcodecExt
- , public ISpecifyPropertyPages2
- , public IMPCVideoDecFilter2
-{
-protected:
-
- // === FFmpeg callbacks
- static void LogLibavcodec(void* par, int level, const char* fmt, va_list valist);
- virtual void OnGetBuffer(AVFrame* pic);
-
- friend class CVideoDecDXVAAllocator;
-
- CCpuId* m_pCpuId;
- CCritSec m_csProps;
-
- CAutoPtr<bool> m_DXVAFilters;
- CAutoPtr<bool> m_FFmpegFilters;
-
- // === Persistants parameters (registry)
- int m_nThreadNumber;
- int m_nDiscardMode;
- bool m_bDXVACompatible;
- int m_nActiveCodecs;
- int m_nARMode;
- int m_nDXVACheckCompatibility;
- int m_nDXVA_SD;
- MPCVD_INTERLACED_FLAG m_interlacedFlag;
-
- FF_FIELD_TYPE m_nFrameType;
-
- // === FFmpeg variables
- AVCodec* m_pAVCodec;
- AVCodecContext* m_pAVCtx;
- AVFrame* m_pFrame;
- int m_nCodecNb;
- enum AVCodecID m_nCodecId;
- int m_nWorkaroundBug;
- int m_nErrorConcealment;
- REFERENCE_TIME m_rtAvrTimePerFrame;
- bool m_bReorderBFrame;
- B_FRAME m_BFrames[2];
- int m_nPosB;
- int m_nWidth; // Frame width given to input pin
- int m_nHeight; // Frame height given to input pin
-
- bool m_bTheoraMTSupport;
- bool m_bIsEVO;
-
- // Buffer management for truncated stream (store stream chunks & reference time sent by splitter)
- BYTE* m_pFFBuffer;
- int m_nFFBufferSize;
- BYTE* m_pAlignedFFBuffer;
- int m_nAlignedFFBufferSize;
-
- int m_nFFBufferPos;
- int m_nFFPicEnd;
- BUFFER_TIME m_FFBufferTime[MAX_BUFF_TIME];
-
- REFERENCE_TIME m_rtLastStart; // rtStart for last delivered frame
- int m_nCountEstimated; // Number of rtStart estimated since last rtStart received
- double m_dRate;
- REFERENCE_TIME m_rtPrevStop;
- bool m_bFrame_repeat_pict;
-
- bool m_bUseDXVA;
- bool m_bUseFFmpeg;
- CSize m_par;
- SwsContext* m_pSwsContext;
- unsigned __int64 m_nOutCsp;
- CSize m_pOutSize; // Picture size on output pin
- int m_nSwOutBpp;
-
- // === DXVA common variables
- VIDEO_OUTPUT_FORMATS* m_pVideoOutputFormat;
- int m_nVideoOutputCount;
- DXVA_MODE m_nDXVAMode;
- CDXVADecoder* m_pDXVADecoder;
- GUID m_DXVADecoderGUID;
-
- DWORD m_nPCIVendor;
- DWORD m_nPCIDevice;
- LARGE_INTEGER m_VideoDriverVersion;
- CString m_strDeviceDescription;
-
- // === DXVA1 variables
- DDPIXELFORMAT m_PixelFormat;
-
- // === DXVA2 variables
- CComPtr<IDirect3DDeviceManager9> m_pDeviceManager;
- CComPtr<IDirectXVideoDecoderService> m_pDecoderService;
- CComPtr<IDirect3DSurface9> m_pDecoderRenderTarget;
- DXVA2_ConfigPictureDecode m_DXVA2Config;
- HANDLE m_hDevice;
- DXVA2_VideoDesc m_VideoDesc;
-
- CH264RandomAccess m_h264RandomAccess;
-
- BOOL m_bWaitingForKeyFrame;
-
- RMDemuxContext rm;
- REFERENCE_TIME m_rtStart;
-
- // === Private functions
- void Cleanup();
- int FindCodec(const CMediaType* mtIn);
- void AllocExtradata(AVCodecContext* pAVCtx, const CMediaType* mt);
- bool IsMultiThreadSupported(enum AVCodecID nCodec);
- void GetOutputFormats(int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats);
- void CalcAvgTimePerFrame();
- void DetectVideoCard(HWND hWnd);
- unsigned __int64 GetCspFromMediaType(GUID& subtype);
- void InitSwscale();
-
- void SetTypeSpecificFlags(IMediaSample* pMS);
- HRESULT SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int nSize, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- bool AppendBuffer(BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
- bool FindPicture(int nIndex, int nStartCode);
- void ShrinkBuffer();
- void ResetBuffer();
- void PushBufferTime(int nPos, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- void PopBufferTime(int nPos);
-
-public:
-
- const static AMOVIESETUP_MEDIATYPE sudPinTypesIn[];
- const static int sudPinTypesInCount;
- const static AMOVIESETUP_MEDIATYPE sudPinTypesOut[];
- const static int sudPinTypesOutCount;
-
- CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMPCVideoDecFilter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- virtual bool IsVideoInterlaced();
- virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int& RealWidth, int& RealHeight);
- CTransformOutputPin* GetOutputPin() { return m_pOutput; }
-
- void UpdateFrameTime(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop, bool b_repeat_pict = false);
- CString GetFileExtension();
-
- void SetDXVAFilters(CAutoPtr<bool> DXVAFilters) { m_DXVAFilters = DXVAFilters; };
- void SetFFmpegFilters(CAutoPtr<bool> FFmpegFilters) { m_FFmpegFilters = FFmpegFilters; };
-
- // === Overriden DirectShow functions
- HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType* pmt);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT Transform(IMediaSample* pIn);
- HRESULT CompleteConnect(PIN_DIRECTION direction, IPin* pReceivePin);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT BeginFlush();
- HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, double dRate);
- HRESULT EndOfStream();
-
- HRESULT BreakConnect(PIN_DIRECTION dir);
-
-
- // === ISpecifyPropertyPages2
-
- STDMETHODIMP GetPages(CAUUID* pPages);
- STDMETHODIMP CreatePage(const GUID& guid, IPropertyPage** ppPage);
-
- // === IMPCVideoDecFilter
- STDMETHODIMP Apply();
- STDMETHODIMP SetThreadNumber(int nValue);
- STDMETHODIMP_(int) GetThreadNumber();
- STDMETHOD(SetDiscardMode(int nValue));
- STDMETHOD_(int, GetDiscardMode());
- STDMETHOD_(GUID*, GetDXVADecoderGuid());
- STDMETHOD(SetActiveCodecs(MPC_VIDEO_CODEC nValue));
- STDMETHOD_(MPC_VIDEO_CODEC, GetActiveCodecs());
- STDMETHODIMP_(LPCTSTR) GetVideoCardDescription();
-
- STDMETHOD(SetARMode(int nValue));
- STDMETHOD_(int, GetARMode());
-
- STDMETHOD(SetDXVACheckCompatibility(int nValue));
- STDMETHOD_(int, GetDXVACheckCompatibility());
-
- STDMETHOD(SetDXVA_SD(int nValue));
- STDMETHOD_(int, GetDXVA_SD());
-
- // === IMPCVideoDecFilter2
- STDMETHOD_(int, GetFrameType());
-
- STDMETHOD(SetInterlacedFlag(MPCVD_INTERLACED_FLAG interlacedFlag));
- STDMETHOD_(MPCVD_INTERLACED_FLAG, GetInterlacedFlag());
-
- // === DXVA common functions
- BOOL IsSupportedDecoderConfig(const D3DFORMAT nD3DFormat, const DXVA2_ConfigPictureDecode& config, bool& bIsPrefered);
- BOOL IsSupportedDecoderMode(const GUID& mode);
- void BuildDXVAOutputFormat();
- int GetPicEntryNumber();
- int PictWidth();
- int PictHeight();
- int PictWidthRounded();
- int PictHeightRounded();
-
- inline bool UseDXVA2() { return (m_nDXVAMode == MODE_DXVA2); };
- inline AVCodecContext* GetAVCtx() { return m_pAVCtx; };
- inline AVFrame* GetFrame() { return m_pFrame; };
- inline enum AVCodecID GetCodec() { return m_nCodecId; };
- inline bool IsReorderBFrame() { return m_bReorderBFrame; };
- inline bool IsEvo() { return m_bIsEVO; };
- inline DWORD GetPCIVendor() { return m_nPCIVendor; };
- inline REFERENCE_TIME GetAvrTimePerFrame() { return m_rtAvrTimePerFrame; };
- inline double GetRate() { return m_dRate; };
- bool IsDXVASupported();
- void UpdateAspectRatio();
- void ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
- void FlushDXVADecoder() {
- if (m_pDXVADecoder) {
- m_pDXVADecoder->Flush();
- }
- }
-
- void SetFrameType(FF_FIELD_TYPE nFrameType);
-
- // === DXVA1 functions
- DDPIXELFORMAT* GetPixelFormat() { return &m_PixelFormat; }
- HRESULT FindDXVA1DecoderConfiguration(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* guidDecoder, DDPIXELFORMAT* pPixelFormat);
- HRESULT CheckDXVA1Decoder(const GUID* pGuid);
- void SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixelFormat);
- WORD GetDXVA1RestrictedMode();
- HRESULT CreateDXVA1Decoder(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* pDecoderGuid, DWORD dwSurfaceCount);
-
-
- // === DXVA2 functions
- void FillInVideoDescription(DXVA2_VideoDesc* pDesc);
- DXVA2_ConfigPictureDecode* GetDXVA2Config() { return &m_DXVA2Config; };
- HRESULT ConfigureDXVA2(IPin* pPin);
- HRESULT SetEVRForDXVA2(IPin* pPin);
- HRESULT FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService* pDecoderService,
- const GUID& guidDecoder,
- DXVA2_ConfigPictureDecode* pSelectedConfig,
- BOOL* pbFoundDXVA2Configuration);
- HRESULT CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3DSurface9** pDecoderRenderTargets);
-};
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.rc b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.rc
deleted file mode 100644
index a59ca7eb9..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.rc
+++ /dev/null
@@ -1,166 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-#include "version.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (United States) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
- "#define _AFX_NO_OLE_RESOURCES\r\n"
- "#define _AFX_NO_TRACKER_RESOURCES\r\n"
- "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
- "\r\n"
- "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
- "LANGUAGE 9, 1\r\n"
- "#pragma code_page(1252)\r\n"
- "#include ""afxres.rc"" // Standard components\r\n"
- "#endif\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION MPC_VERSION_NUM
- PRODUCTVERSION MPC_VERSION_NUM
- FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
-#ifdef _DEBUG
- FILEFLAGS VS_FF_DEBUG
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS VOS_NT_WINDOWS32
- FILETYPE VFT_DLL
- FILESUBTYPE VFT2_UNKNOWN
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "Comments", MPC_VERSION_COMMENTS
- VALUE "CompanyName", MPC_COMP_NAME_STR
- VALUE "FileDescription", "H.264/VC-1 DXVA video decoder"
- VALUE "FileVersion", MPC_VERSION_STR_FULL
- VALUE "InternalName", "MPCVideoDec Filter"
- VALUE "LegalCopyright", MPC_COPYRIGHT_STR
- VALUE "OriginalFilename", "MPCVideoDecFilter.ax"
- VALUE "ProductName", "MPCVideoDec Filter"
- VALUE "ProductVersion", MPC_VERSION_STR_FULL
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// String Table
-//
-
-STRINGTABLE
-BEGIN
-
- IDS_FILTER_SETTINGS_CAPTION "Settings"
- IDS_VDF_FFSETTINGS "FFmpeg settings"
- IDS_VDF_THREADNUMBER "Decoding thread number"
- IDS_VDF_SKIPDEBLOCK "H264 skip deblocking mode"
- IDS_VDF_DBLK_NONE "None"
- IDS_VDF_DBLK_DEFAULT "Default"
- IDS_VDF_DBLK_NONREF "Non Reference"
- IDS_VDF_DBLK_BIDIR "Bidirectional"
- IDS_VDF_DBLK_NONKFRM "Non keyframes"
- IDS_VDF_DBLK_ALL "All frames"
- IDS_VDF_AUTO "Auto"
- IDS_VDF_AR_MODE "Read AR from stream"
-END
-
-STRINGTABLE
-BEGIN
- IDS_VDF_DXVA_SETTING "DXVA settings"
- IDS_VDF_DXVA_MODE "DXVA Mode"
- IDS_VDF_DXVA_SD "Disable DXVA for SD"
- IDS_VDF_VIDEOCARD "Videocard"
-END
-
-STRINGTABLE
-BEGIN
- IDS_VDF_DXVACOMPATIBILITY "DXVA (H.264) Compatibility check"
- IDS_VDF_DXVA_FULLCHECK "Full check"
- IDS_VDF_DXVA_SKIP_LEVELCHECK "Skip level check"
- IDS_VDF_DXVA_SKIP_REFCHECK "Skip ref frame check"
- IDS_VDF_DXVA_SKIP_ALLCHECK "Skip all checks"
-END
-
-STRINGTABLE
-BEGIN
- IDS_VDF_INTERLACED_FLAG "Force the interlaced flag"
- IDS_VDF_IF_PROGRESSIVE "Progressive"
- IDS_VDF_IF_TOP_FIELD_FIRST "Top field first"
- IDS_VDF_IF_BOTTOM_FIELD_FIRST "Bottom field first"
-END
-
-#endif // English (United States) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-#define _AFX_NO_SPLITTER_RESOURCES
-#define _AFX_NO_OLE_RESOURCES
-#define _AFX_NO_TRACKER_RESOURCES
-#define _AFX_NO_PROPERTY_RESOURCES
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE 9, 1
-#pragma code_page(1252)
-#include "afxres.rc" // Standard components
-#endif
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
deleted file mode 100644
index dfe2fb24b..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "resource.h"
-#include "MPCVideoDecSettingsWnd.h"
-#include "../../../DSUtil/DSUtil.h"
-
-#include "ffmpeg/libavcodec/avcodec.h"
-
-#include "../../../mpc-hc/InternalFiltersConfig.h"
-
-
-//
-// CMPCVideoDecSettingsWnd
-//
-
-int g_AVDiscard[] = {
- AVDISCARD_NONE,
- AVDISCARD_DEFAULT,
- AVDISCARD_NONREF,
- AVDISCARD_BIDIR,
- AVDISCARD_NONKEY,
- AVDISCARD_ALL,
-};
-
-int FindDiscardIndex(int nValue)
-{
- for (int i = 0; i < _countof(g_AVDiscard); i++) {
- if (g_AVDiscard[i] == nValue) {
- return i;
- }
- }
- return 1;
-}
-
-int g_AVErrRecognition[] = {
- AV_EF_CAREFUL,
- AV_EF_COMPLIANT,
- AV_EF_AGGRESSIVE,
-};
-
-int FindErrRecognitionIndex(int nValue)
-{
- for (int i = 0; i < _countof(g_AVErrRecognition); i++) {
- if (g_AVErrRecognition[i] == nValue) {
- return i;
- }
- }
- return 1;
-}
-
-CMPCVideoDecSettingsWnd::CMPCVideoDecSettingsWnd()
-{
-}
-
-bool CMPCVideoDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pMDF);
-
- m_pMDF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pMDF) {
- return false;
- }
-
- return true;
-}
-
-void CMPCVideoDecSettingsWnd::OnDisconnect()
-{
- m_pMDF.Release();
-}
-
-bool CMPCVideoDecSettingsWnd::OnActivate()
-{
- ASSERT(IPP_FONTSIZE == 13);
- const int h20 = IPP_SCALE(20);
- const int h25 = IPP_SCALE(25);
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
- CPoint p(10, 10);
- GUID* DxvaGui = nullptr;
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- m_grpFFMpeg.Create(ResStr(IDS_VDF_FFSETTINGS), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(p + CPoint(-5, 0), CSize(IPP_SCALE(350), h20 + h25 * 3 + h20)), this, (UINT)IDC_STATIC);
- p.y += h20;
-
- // Decoding threads
- m_txtThreadNumber.Create(ResStr(IDS_VDF_THREADNUMBER), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(220), m_fontheight)), this, (UINT)IDC_STATIC);
- m_cbThreadNumber.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p + CPoint(IPP_SCALE(230), -4), CSize(IPP_SCALE(110), 200)), this, IDC_PP_THREAD_COUNT);
- m_cbThreadNumber.AddString(ResStr(IDS_VDF_AUTO));
- CString ThreadNumberStr;
- for (int i = 0; i < 16; i++) {
- ThreadNumberStr.Format(_T("%d"), i + 1);
- m_cbThreadNumber.AddString(ThreadNumberStr);
- }
- p.y += h25;
-
-#if INTERNAL_DECODER_H264
- // H264 deblocking mode
- m_txtSkipDeblock.Create(ResStr(IDS_VDF_SKIPDEBLOCK), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(220), m_fontheight)), this, (UINT)IDC_STATIC);
- m_cbSkipDeblock.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p + CPoint(IPP_SCALE(230), -4), CSize(IPP_SCALE(110), 200)), this, IDC_PP_SKIP_DEBLOCK);
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_NONE));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_DEFAULT));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_NONREF));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_BIDIR));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_NONKFRM));
- m_cbSkipDeblock.AddString(ResStr(IDS_VDF_DBLK_ALL));
-#endif /* INTERNAL_DECODER_H264 */
- p.y += h25;
-
- // Read AR from stream
- m_cbARMode.Create(ResStr(IDS_VDF_AR_MODE), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(340), m_fontheight)), this, IDC_PP_AR);
- m_cbARMode.SetCheck(FALSE);
- p.y += h25;
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- // Interlaced flag
- m_txtInterlacedFlag.Create(ResStr(IDS_VDF_INTERLACED_FLAG), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(220), m_fontheight)), this, (UINT)IDC_STATIC);
- m_cbInterlacedFlag.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p + CPoint(IPP_SCALE(230), -6), CSize(IPP_SCALE(110), 200)), this, IDC_PP_INTERLACED_FLAG);
- m_cbInterlacedFlag.AddString(ResStr(IDS_VDF_AUTO));
- m_cbInterlacedFlag.AddString(ResStr(IDS_VDF_IF_PROGRESSIVE));
- m_cbInterlacedFlag.AddString(ResStr(IDS_VDF_IF_TOP_FIELD_FIRST));
- m_cbInterlacedFlag.AddString(ResStr(IDS_VDF_IF_BOTTOM_FIELD_FIRST));
- p.y += h25;
-
- m_grpDXVA.Create(ResStr(IDS_VDF_DXVA_SETTING), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(p + CPoint(-5, 0), CSize(IPP_SCALE(350), h20 + h25 + h20 * 3 + m_fontheight)), this, (UINT)IDC_STATIC);
- p.y += h20;
-
- // DXVA Compatibility check
- m_txtDXVACompatibilityCheck.Create(ResStr(IDS_VDF_DXVACOMPATIBILITY), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(225), m_fontheight)), this, (UINT)IDC_STATIC);
- m_cbDXVACompatibilityCheck.Create(dwStyle | CBS_DROPDOWNLIST | WS_VSCROLL, CRect(p + CPoint(IPP_SCALE(230), -4), CSize(IPP_SCALE(110), 200)), this, IDC_PP_DXVA_CHECK);
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_FULLCHECK));
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_LEVELCHECK));
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_REFCHECK));
- m_cbDXVACompatibilityCheck.AddString(ResStr(IDS_VDF_DXVA_SKIP_ALLCHECK));
- p.y += h25;
-
- // Set DXVA for SD (H.264)
- m_cbDXVA_SD.Create(ResStr(IDS_VDF_DXVA_SD), dwStyle | BS_AUTOCHECKBOX | BS_LEFTTEXT, CRect(p, CSize(IPP_SCALE(340), m_fontheight)), this, IDC_PP_DXVA_SD);
- m_cbDXVA_SD.SetCheck(FALSE);
- p.y += h20;
-
- // DXVA mode
- m_txtDXVAMode.Create(ResStr(IDS_VDF_DXVA_MODE), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(120), m_fontheight)), this, (UINT)IDC_STATIC);
- m_edtDXVAMode.Create(WS_CHILD | WS_VISIBLE | WS_DISABLED, CRect(p + CPoint(IPP_SCALE(120), 0), CSize(IPP_SCALE(220), m_fontheight)), this, 0);
- p.y += h20;
-
- // Video card description
- m_txtVideoCardDescription.Create(ResStr(IDS_VDF_VIDEOCARD), WS_VISIBLE | WS_CHILD, CRect(p, CSize(IPP_SCALE(120), m_fontheight)), this, (UINT)IDC_STATIC);
- m_edtVideoCardDescription.Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_DISABLED, CRect(p + CPoint(IPP_SCALE(120), 0), CSize(IPP_SCALE(220), m_fontheight * 2)), this, 0);
- m_edtVideoCardDescription.SetWindowText(m_pMDF->GetVideoCardDescription());
-
- DxvaGui = m_pMDF->GetDXVADecoderGuid();
- if (DxvaGui != nullptr) {
- CString DXVAMode = GetDXVAMode(DxvaGui);
- m_edtDXVAMode.SetWindowText(DXVAMode);
- } else {
- m_txtDXVAMode.ShowWindow(SW_HIDE);
- m_edtDXVAMode.ShowWindow(SW_HIDE);
- }
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- CorrectComboListWidth(m_cbDXVACompatibilityCheck);
-#if INTERNAL_DECODER_H264
- CorrectComboListWidth(m_cbSkipDeblock);
-#endif
-
- if (m_pMDF) {
-#if HAS_FFMPEG_VIDEO_DECODERS
-#if INTERNAL_DECODER_H264
- m_cbThreadNumber.SetCurSel(m_pMDF->GetThreadNumber());
- m_cbSkipDeblock.SetCurSel(FindDiscardIndex(m_pMDF->GetDiscardMode()));
-#endif
-
- m_cbARMode.SetCheck(m_pMDF->GetARMode());
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- m_cbDXVACompatibilityCheck.SetCurSel(m_pMDF->GetDXVACheckCompatibility());
- m_cbDXVA_SD.SetCheck(m_pMDF->GetDXVA_SD());
-
- m_cbInterlacedFlag.SetCurSel(m_pMDF->GetInterlacedFlag());
- }
-
- return true;
-}
-
-void CMPCVideoDecSettingsWnd::OnDeactivate()
-{
-}
-
-bool CMPCVideoDecSettingsWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd) {
-#if HAS_FFMPEG_VIDEO_DECODERS
-#if INTERNAL_DECODER_H264
- m_pMDF->SetThreadNumber(m_cbThreadNumber.GetCurSel());
- m_pMDF->SetDiscardMode(g_AVDiscard[m_cbSkipDeblock.GetCurSel()]);
-#endif /* INTERNAL_DECODER_H264 */
-
- m_pMDF->SetARMode(m_cbARMode.GetCheck());
-#endif /* HAS_FFMPEG_VIDEO_DECODERS */
-
- m_pMDF->SetDXVACheckCompatibility(m_cbDXVACompatibilityCheck.GetCurSel());
-
- m_pMDF->SetDXVA_SD(m_cbDXVA_SD.GetCheck());
-
- m_pMDF->SetInterlacedFlag((MPCVD_INTERLACED_FLAG)m_cbInterlacedFlag.GetCurSel());
-
- m_pMDF->Apply();
- }
-
- return true;
-}
-
-
-BEGIN_MESSAGE_MAP(CMPCVideoDecSettingsWnd, CInternalPropertyPageWnd)
-END_MESSAGE_MAP()
-
-
-// ====== Codec filter property page (for standalone filter only)
-
-CMPCVideoDecCodecWnd::CMPCVideoDecCodecWnd()
-{
-}
-
-bool CMPCVideoDecCodecWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
-{
- ASSERT(!m_pMDF);
-
- m_pMDF.Release();
-
- POSITION pos = pUnks.GetHeadPosition();
- while (pos && !(m_pMDF = pUnks.GetNext(pos))) {
- ;
- }
-
- if (!m_pMDF) {
- return false;
- }
-
- return true;
-}
-
-void CMPCVideoDecCodecWnd::OnDisconnect()
-{
- m_pMDF.Release();
-}
-
-bool CMPCVideoDecCodecWnd::OnActivate()
-{
- DWORD dwStyle = WS_VISIBLE | WS_CHILD | WS_BORDER;
- int nPos = 0;
- MPC_VIDEO_CODEC nActiveCodecs = (MPC_VIDEO_CODEC)(m_pMDF ? m_pMDF->GetActiveCodecs() : 0);
-
- m_grpSelectedCodec.Create(_T("Selected codecs"), WS_VISIBLE | WS_CHILD | BS_GROUPBOX, CRect(10, 10, 330, 280), this, (UINT)IDC_STATIC);
-
- m_lstCodecs.Create(dwStyle | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP, CRect(20, 30, 320, 270), this, 0);
-
-#if INTERNAL_DECODER_H264_DXVA
- m_lstCodecs.AddString(_T("H.264/AVC (DXVA)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_H264_DXVA) != 0);
-#endif
-#if INTERNAL_DECODER_VC1_DXVA
- m_lstCodecs.AddString(_T("VC1 (DXVA)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VC1_DXVA) != 0);
-#endif
-#if INTERNAL_DECODER_WMV3_DXVA
- m_lstCodecs.AddString(_T("WMV3 (DXVA)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_WMV3_DXVA) != 0);
-#endif
-#if INTERNAL_DECODER_MPEG2_DXVA
- m_lstCodecs.AddString(_T("MPEG2 (DXVA)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_MPEG2_DXVA) != 0);
-#endif
-
-#if INTERNAL_DECODER_H264
- m_lstCodecs.AddString(_T("H.264/AVC (FFmpeg)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_H264) != 0);
-#endif
-#if INTERNAL_DECODER_VC1
- m_lstCodecs.AddString(_T("VC1 (FFmpeg)"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VC1) != 0);
-#endif
-
-#if HAS_FFMPEG_VIDEO_DECODERS
- m_lstCodecs.AddString(_T("Xvid/MPEG-4"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_XVID) != 0);
- m_lstCodecs.AddString(_T("DivX"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_DIVX) != 0);
- m_lstCodecs.AddString(_T("MS-MPEG4"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_MSMPEG4) != 0);
- m_lstCodecs.AddString(_T("FLV1/4"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_FLASH) != 0);
- m_lstCodecs.AddString(_T("VP3/5/6"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VP356) != 0);
- m_lstCodecs.AddString(_T("VP8"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_VP8) != 0);
- m_lstCodecs.AddString(_T("WMV1/2/3"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_WMV) != 0);
- m_lstCodecs.AddString(_T("H.263"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_H263) != 0);
- m_lstCodecs.AddString(_T("SVQ1/3"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_SVQ3) != 0);
- m_lstCodecs.AddString(_T("AMV video"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_AMVV) != 0);
- m_lstCodecs.AddString(_T("Theora"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_THEORA) != 0);
- m_lstCodecs.AddString(_T("MJPEG"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_MJPEG) != 0);
- m_lstCodecs.AddString(_T("Indeo 3/4/5"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_INDEO) != 0);
- m_lstCodecs.AddString(_T("Real Video"));
- m_lstCodecs.SetCheck(nPos++, (nActiveCodecs & MPCVD_RV) != 0);
-#endif
-
- for (CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
- pWnd->SetFont(&m_font, FALSE);
- }
-
- return true;
-}
-
-void CMPCVideoDecCodecWnd::OnDeactivate()
-{
-}
-
-bool CMPCVideoDecCodecWnd::OnApply()
-{
- OnDeactivate();
-
- if (m_pMDF) {
- int nActiveCodecs = 0;
- int nPos = 0;
-
-#if INTERNAL_DECODER_H264_DXVA
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_H264_DXVA;
- }
-#endif
-#if INTERNAL_DECODER_VC1_DXVA
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_VC1_DXVA;
- }
-#endif
-#if INTERNAL_DECODER_WMV3_DXVA
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_WMV3_DXVA;
- }
-#endif
-#if INTERNAL_DECODER_MPEG2_DXVA
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_MPEG2_DXVA;
- }
-#endif
-#if INTERNAL_DECODER_H264
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_H264;
- }
-#endif
-#if INTERNAL_DECODER_VC1
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_VC1;
- }
-#endif
-#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_XVID;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_DIVX;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_MSMPEG4;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_FLASH;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_VP356;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_VP8;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_WMV;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_H263;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_SVQ3;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_AMVV;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_THEORA;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_MJPEG;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_INDEO;
- }
- if (m_lstCodecs.GetCheck(nPos++)) {
- nActiveCodecs |= MPCVD_RV;
- }
-#endif
- m_pMDF->SetActiveCodecs((MPC_VIDEO_CODEC)nActiveCodecs);
-
- m_pMDF->Apply();
- }
-
- return true;
-}
-
-
-BEGIN_MESSAGE_MAP(CMPCVideoDecCodecWnd, CInternalPropertyPageWnd)
-END_MESSAGE_MAP()
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
deleted file mode 100644
index 248c984bc..000000000
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../InternalPropertyPage.h"
-#include "IMPCVideoDecFilter.h"
-#include "resource.h"
-#include <afxcmn.h>
-
-class __declspec(uuid("D5AA0389-D274-48e1-BF50-ACB05A56DDE0"))
- CMPCVideoDecSettingsWnd : public CInternalPropertyPageWnd
-{
- CComQIPtr<IMPCVideoDecFilter2> m_pMDF;
-
- CButton m_grpFFMpeg;
- CStatic m_txtThreadNumber;
- CComboBox m_cbThreadNumber;
- CStatic m_txtSkipDeblock;
- CComboBox m_cbSkipDeblock;
-
- CButton m_grpDXVA;
- CStatic m_txtDXVAMode;
- CEdit m_edtDXVAMode;
-
- CStatic m_txtInterlacedFlag;
- CComboBox m_cbInterlacedFlag;
-
- CStatic m_txtVideoCardDescription;
- CEdit m_edtVideoCardDescription;
-
- CButton m_cbARMode;
-
- CStatic m_txtDXVACompatibilityCheck;
- CComboBox m_cbDXVACompatibilityCheck;
-
- CButton m_cbDXVA_SD;
-
- enum {
- IDC_PP_THREAD_COUNT = 10000,
- IDC_PP_SKIP_DEBLOCK,
- IDC_PP_AR,
- IDC_PP_INTERLACED_FLAG,
- IDC_PP_DXVA_CHECK,
- IDC_PP_DXVA_SD
- };
-
-public:
- CMPCVideoDecSettingsWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return MAKEINTRESOURCE(IDS_FILTER_SETTINGS_CAPTION); }
- static CSize GetWindowSize() { return CSize(360, 258); }
-
- DECLARE_MESSAGE_MAP()
-};
-
-class __declspec(uuid("3C395D46-8B0F-440d-B962-2F4A97355453"))
- CMPCVideoDecCodecWnd : public CInternalPropertyPageWnd
-{
- CComQIPtr<IMPCVideoDecFilter> m_pMDF;
-
- CButton m_grpSelectedCodec;
- CCheckListBox m_lstCodecs;
- CImageList m_onoff;
-
-public:
- CMPCVideoDecCodecWnd();
-
- bool OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks);
- void OnDisconnect();
- bool OnActivate();
- void OnDeactivate();
- bool OnApply();
-
- static LPCTSTR GetWindowTitle() { return _T("Codecs"); }
- static CSize GetWindowSize() { return CSize(360, 283); }
-
- DECLARE_MESSAGE_MAP()
-};
diff --git a/src/filters/transform/MPCVideoDec/PODtypes.h b/src/filters/transform/MPCVideoDec/PODtypes.h
deleted file mode 100644
index 33a200159..000000000
--- a/src/filters/transform/MPCVideoDec/PODtypes.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef _PODTYPES_H_
-#define _PODTYPES_H_
-
-template<class T> struct isPOD {enum {is = false};};
-template<> struct isPOD<bool> {enum {is = true};};
-
-template<> struct isPOD<char> {enum {is = true};};
-
-template<> struct isPOD<signed char> {enum {is = true};};
-template<> struct isPOD<short int> {enum {is = true};};
-template<> struct isPOD<int> {enum {is = true};};
-template<> struct isPOD<long int> {enum {is = true};};
-template<> struct isPOD<__int64> {enum {is = true};};
-
-template<> struct isPOD<unsigned char> {enum {is = true};};
-template<> struct isPOD<unsigned short int> {enum {is = true};};
-template<> struct isPOD<unsigned int> {enum {is = true};};
-template<> struct isPOD<unsigned long int> {enum {is = true};};
-template<> struct isPOD<unsigned __int64> {enum {is = true};};
-
-template<> struct isPOD<float> {enum {is = true};};
-template<> struct isPOD<double> {enum {is = true};};
-template<> struct isPOD<long double> {enum {is = true};};
-
-#if defined(__INTEL_COMPILER) || defined(__GNUC__) || (_MSC_VER >= 1300)
-template<> struct isPOD<wchar_t> {enum {is = true};};
-template<class Tp> struct isPOD<Tp*> {enum {is = true};};
-#endif
-
-template<class A> struct allocator_traits {enum {is_static = false};};
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp b/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
deleted file mode 100644
index b99d83c56..000000000
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#include "stdafx.h"
-#include "ffmpeg/libavcodec/avcodec.h"
-#include "TlibavcodecExt.h"
-
-void TlibavcodecExt::ConnectTo(AVCodecContext* pAVCtx)
-{
- pAVCtx->opaque = this;
- pAVCtx->get_buffer = get_buffer;
- pAVCtx->reget_buffer = reget_buffer;
- pAVCtx->release_buffer = release_buffer;
-}
-
-int TlibavcodecExt::get_buffer(AVCodecContext* c, AVFrame* pic)
-{
- int ret = c->opaque->ff_avcodec_default_get_buffer(c, pic);
- if (ret == 0) {
- c->opaque->OnGetBuffer(pic);
- }
- return ret;
-}
-
-int TlibavcodecExt::reget_buffer(AVCodecContext* c, AVFrame* pic)
-{
- int ret = c->opaque->ff_avcodec_default_reget_buffer(c, pic);
- if (ret == 0) {
- c->opaque->OnRegetBuffer(pic);
- }
- return ret;
-}
-
-void TlibavcodecExt::release_buffer(AVCodecContext* c, AVFrame* pic)
-{
- c->opaque->ff_avcodec_default_release_buffer(c, pic);
- c->opaque->OnReleaseBuffer(pic);
-}
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h b/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
deleted file mode 100644
index e77680f8f..000000000
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-struct AVCodecContext;
-struct AVFrame;
-
-typedef int (*FUNC_AV_DEFAULT_GET_BUFFER)(AVCodecContext* s, AVFrame* pic);
-typedef void (*FUNC_AV_DEFAULT_RELEASE_BUFFER)(AVCodecContext* s, AVFrame* pic);
-typedef int (*FUNC_AV_DEFAULT_REGET_BUFFER)(AVCodecContext* s, AVFrame* pic);
-
-
-struct TlibavcodecExt {
-protected:
- static int get_buffer(AVCodecContext* s, AVFrame* pic);
- static void release_buffer(AVCodecContext* s, AVFrame* pic);
- static int reget_buffer(AVCodecContext* s, AVFrame* pic);
-
- FUNC_AV_DEFAULT_GET_BUFFER ff_avcodec_default_get_buffer;
- FUNC_AV_DEFAULT_RELEASE_BUFFER ff_avcodec_default_release_buffer;
- FUNC_AV_DEFAULT_REGET_BUFFER ff_avcodec_default_reget_buffer;
-
-public:
- virtual ~TlibavcodecExt() {}
- void ConnectTo(AVCodecContext* pAVCtx);
- virtual void OnGetBuffer(AVFrame* pic) {}
- virtual void OnRegetBuffer(AVFrame* pic) {}
- virtual void OnReleaseBuffer(AVFrame* pic) {}
-};
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
deleted file mode 100644
index 61d5fcc91..000000000
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#include "stdafx.h"
-#include "VideoDecDXVAAllocator.h"
-#include "MPCVideoDecFilter.h"
-#include <Mferror.h>
-#include <d3dx9.h>
-#include <evr.h>
-
-
-CDXVA2Sample::CDXVA2Sample(CVideoDecDXVAAllocator* pAlloc, HRESULT* phr)
- : CMediaSample(NAME("CDXVA2Sample"), (CBaseAllocator*)pAlloc, phr, nullptr, 0)
- , m_dwSurfaceId(0)
-{
-}
-
-//Note: CMediaSample does not derive from CUnknown, so we cannot use the
-// DECLARE_IUNKNOWN macro that is used by most of the filter classes.
-
-STDMETHODIMP CDXVA2Sample::QueryInterface(REFIID riid, __deref_out void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
- ValidateReadWritePtr(ppv, sizeof(PVOID));
-
- if (riid == __uuidof(IMFGetService)) {
- return GetInterface((IMFGetService*) this, ppv);
- }
- if (riid == __uuidof(IMPCDXVA2Sample)) {
- return GetInterface((IMPCDXVA2Sample*) this, ppv);
- } else {
- return CMediaSample::QueryInterface(riid, ppv);
- }
-}
-
-STDMETHODIMP_(ULONG) CDXVA2Sample::AddRef()
-{
- return __super::AddRef();
-}
-
-STDMETHODIMP_(ULONG) CDXVA2Sample::Release()
-{
- // Return a temporary variable for thread safety.
- ULONG cRef = __super::Release();
- return cRef;
-}
-
-// IMFGetService::GetService
-STDMETHODIMP CDXVA2Sample::GetService(REFGUID guidService, REFIID riid, LPVOID* ppv)
-{
- if (guidService != MR_BUFFER_SERVICE) {
- return MF_E_UNSUPPORTED_SERVICE;
- } else if (m_pSurface == nullptr) {
- return E_NOINTERFACE;
- } else {
- return m_pSurface->QueryInterface(riid, ppv);
- }
-}
-
-// Override GetPointer because this class does not manage a system memory buffer.
-// The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.
-STDMETHODIMP CDXVA2Sample::GetPointer(BYTE** ppBuffer)
-{
- return E_NOTIMPL;
-}
-
-// Sets the pointer to the Direct3D surface.
-void CDXVA2Sample::SetSurface(DWORD surfaceId, IDirect3DSurface9* pSurf)
-{
- m_pSurface = pSurf;
- m_dwSurfaceId = surfaceId;
-}
-
-STDMETHODIMP_(int) CDXVA2Sample::GetDXSurfaceId()
-{
- return m_dwSurfaceId;
-}
-
-CVideoDecDXVAAllocator::CVideoDecDXVAAllocator(CMPCVideoDecFilter* pVideoDecFilter, HRESULT* phr)
- : CBaseAllocator(NAME("CVideoDecDXVAAllocator"), nullptr, phr)
- , m_pVideoDecFilter(pVideoDecFilter)
- , m_ppRTSurfaceArray(nullptr)
- , m_nSurfaceArrayCount(0)
-{
-}
-
-CVideoDecDXVAAllocator::~CVideoDecDXVAAllocator()
-{
- Free();
-}
-
-HRESULT CVideoDecDXVAAllocator::Alloc()
-{
- HRESULT hr;
- CComPtr<IDirectXVideoDecoderService> pDXVA2Service;
-
- CheckPointer(m_pVideoDecFilter->m_pDeviceManager, E_UNEXPECTED);
- hr = m_pVideoDecFilter->m_pDeviceManager->GetVideoService(m_pVideoDecFilter->m_hDevice, IID_IDirectXVideoDecoderService, (void**)&pDXVA2Service);
- CheckPointer(pDXVA2Service, E_UNEXPECTED);
- CAutoLock lock(this);
-
- hr = __super::Alloc();
-
- if (SUCCEEDED(hr)) {
- // Free the old resources.
- Free();
-
- m_nSurfaceArrayCount = m_lCount;
-
- // Allocate a new array of pointers.
- m_ppRTSurfaceArray = DEBUG_NEW IDirect3DSurface9 * [m_lCount];
- if (m_ppRTSurfaceArray == nullptr) {
- hr = E_OUTOFMEMORY;
- } else {
- ZeroMemory(m_ppRTSurfaceArray, sizeof(IDirect3DSurface9*) * m_lCount);
- }
- }
-
- // Allocate the surfaces.
- D3DFORMAT m_dwFormat = m_pVideoDecFilter->m_VideoDesc.Format;
- if (SUCCEEDED(hr)) {
- hr = pDXVA2Service->CreateSurface(
- m_pVideoDecFilter->PictWidthRounded(),
- m_pVideoDecFilter->PictHeightRounded(),
- m_lCount - 1,
- (D3DFORMAT)m_dwFormat,
- D3DPOOL_DEFAULT,
- 0,
- DXVA2_VideoDecoderRenderTarget,
- m_ppRTSurfaceArray,
- nullptr
- );
- }
-
- if (SUCCEEDED(hr)) {
- // Important : create samples in reverse order !
- for (m_lAllocated = m_lCount - 1; m_lAllocated >= 0; m_lAllocated--) {
- CDXVA2Sample* pSample = DEBUG_NEW CDXVA2Sample(this, &hr);
- if (pSample == nullptr) {
- hr = E_OUTOFMEMORY;
- break;
- }
- if (FAILED(hr)) {
- break;
- }
- // Assign the Direct3D surface pointer and the index.
- pSample->SetSurface(m_lAllocated, m_ppRTSurfaceArray[m_lAllocated]);
-
- // Add to the sample list.
- m_lFree.Add(pSample);
- }
-
- hr = m_pVideoDecFilter->CreateDXVA2Decoder(m_lCount, m_ppRTSurfaceArray);
- if (FAILED(hr)) {
- Free();
- }
- }
-
- if (SUCCEEDED(hr)) {
- m_bChanged = FALSE;
- }
- return hr;
-}
-
-void CVideoDecDXVAAllocator::Free()
-{
- CMediaSample* pSample = nullptr;
-
- m_pVideoDecFilter->FlushDXVADecoder();
- // m_FreeSurface.RemoveAll();
- do {
- pSample = m_lFree.RemoveHead();
- if (pSample) {
- delete pSample;
- }
- } while (pSample);
-
- if (m_ppRTSurfaceArray) {
- for (UINT i = 0; i < m_nSurfaceArrayCount; i++) {
- if (m_ppRTSurfaceArray[i] != nullptr) {
- m_ppRTSurfaceArray[i]->Release();
- }
- }
-
- delete [] m_ppRTSurfaceArray;
- m_ppRTSurfaceArray = nullptr;
- }
- m_lAllocated = 0;
- m_nSurfaceArrayCount = 0;
-}
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
deleted file mode 100644
index 71e362b94..000000000
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <dxva.h>
-#include <dxva2api.h>
-#include <evr.h>
-
-
-class CMPCVideoDecFilter;
-class CVideoDecDXVAAllocator;
-
-interface __declspec(uuid("AE7EC2A2-1913-4a80-8DD6-DF1497ABA494"))
-IMPCDXVA2Sample :
-public IUnknown {
- STDMETHOD_(int, GetDXSurfaceId()) PURE;
-};
-
-class CDXVA2Sample : public CMediaSample, public IMFGetService, public IMPCDXVA2Sample
-{
- friend class CVideoDecDXVAAllocator;
-
-public:
-
- CDXVA2Sample(CVideoDecDXVAAllocator* pAlloc, HRESULT* phr);
-
- //Note: CMediaSample does not derive from CUnknown, so we cannot use the
- // DECLARE_IUNKNOWN macro that is used by most of the filter classes.
-
- STDMETHODIMP QueryInterface(REFIID riid, __deref_out void** ppv);
- STDMETHODIMP_(ULONG) AddRef();
- STDMETHODIMP_(ULONG) Release();
-
- // IMFGetService::GetService
- STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID* ppv);
-
- // IMPCDXVA2Sample
- STDMETHODIMP_(int) GetDXSurfaceId();
-
- // Override GetPointer because this class does not manage a system memory buffer.
- // The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.
- STDMETHODIMP GetPointer(BYTE** ppBuffer);
-
-private:
-
- // Sets the pointer to the Direct3D surface.
- void SetSurface(DWORD surfaceId, IDirect3DSurface9* pSurf);
-
- CComPtr<IDirect3DSurface9> m_pSurface;
- DWORD m_dwSurfaceId;
-};
-
-
-class CVideoDecDXVAAllocator : public CBaseAllocator
-{
-public:
- CVideoDecDXVAAllocator(CMPCVideoDecFilter* pVideoDecFilter, HRESULT* phr);
- virtual ~CVideoDecDXVAAllocator();
-
-protected:
- HRESULT Alloc();
- void Free();
-
-private:
- CMPCVideoDecFilter* m_pVideoDecFilter;
- IDirect3DSurface9** m_ppRTSurfaceArray;
- UINT m_nSurfaceArrayCount;
-
-};
diff --git a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
deleted file mode 100644
index a0b9e1c8e..000000000
--- a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * (C) 2007-2013 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "stdafx.h"
-#include "VideoDecOutputPin.h"
-#include "VideoDecDXVAAllocator.h"
-#include "MPCVideoDecFilter.h"
-#include "../../../DSUtil/DSUtil.h"
-
-CVideoDecOutputPin::CVideoDecOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName)
- : CBaseVideoOutputPin(pObjectName, pFilter, phr, pName)
-{
- m_pVideoDecFilter = static_cast<CMPCVideoDecFilter*>(pFilter);
- m_pDXVA2Allocator = nullptr;
- m_dwDXVA1SurfaceCount = 0;
- m_GuidDecoderDXVA1 = GUID_NULL;
- ZeroMemory(&m_ddUncompPixelFormat, sizeof(m_ddUncompPixelFormat));
-}
-
-CVideoDecOutputPin::~CVideoDecOutputPin()
-{
-}
-
-HRESULT CVideoDecOutputPin::InitAllocator(IMemAllocator** ppAlloc)
-{
- TRACE(_T("CVideoDecOutputPin::InitAllocator\n"));
- if (m_pVideoDecFilter->UseDXVA2()) {
- HRESULT hr = S_FALSE;
- m_pDXVA2Allocator = DEBUG_NEW CVideoDecDXVAAllocator(m_pVideoDecFilter, &hr);
- if (!m_pDXVA2Allocator) {
- return E_OUTOFMEMORY;
- }
- if (FAILED(hr)) {
- delete m_pDXVA2Allocator;
- return hr;
- }
- // Return the IMemAllocator interface.
- return m_pDXVA2Allocator->QueryInterface(__uuidof(IMemAllocator), (void**)ppAlloc);
- } else {
- return __super::InitAllocator(ppAlloc);
- }
-}
-
-STDMETHODIMP CVideoDecOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- return
- QI(IAMVideoAcceleratorNotify)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-// === IAMVideoAcceleratorNotify
-STDMETHODIMP CVideoDecOutputPin::GetUncompSurfacesInfo(const GUID* pGuid, LPAMVAUncompBufferInfo pUncompBufferInfo)
-{
- HRESULT hr = E_INVALIDARG;
-
- if (SUCCEEDED(m_pVideoDecFilter->CheckDXVA1Decoder(pGuid))) {
- CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
-
- if (pAMVideoAccelerator) {
- pUncompBufferInfo->dwMaxNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
- pUncompBufferInfo->dwMinNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
-
- hr = m_pVideoDecFilter->FindDXVA1DecoderConfiguration(pAMVideoAccelerator, pGuid, &pUncompBufferInfo->ddUncompPixelFormat);
- if (SUCCEEDED(hr)) {
- memcpy(&m_ddUncompPixelFormat, &pUncompBufferInfo->ddUncompPixelFormat, sizeof(DDPIXELFORMAT));
- m_GuidDecoderDXVA1 = *pGuid;
- }
- }
- }
- return hr;
-}
-
-STDMETHODIMP CVideoDecOutputPin::SetUncompSurfacesInfo(DWORD dwActualUncompSurfacesAllocated)
-{
- m_dwDXVA1SurfaceCount = dwActualUncompSurfacesAllocated;
- return S_OK;
-}
-
-STDMETHODIMP CVideoDecOutputPin::GetCreateVideoAcceleratorData(const GUID* pGuid, LPDWORD pdwSizeMiscData, LPVOID* ppMiscData)
-{
- HRESULT hr = E_UNEXPECTED;
- AMVAUncompDataInfo UncompInfo;
- AMVACompBufferInfo CompInfo[30];
- DWORD dwNumTypesCompBuffers = _countof(CompInfo);
- CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
- DXVA_ConnectMode* pConnectMode;
-
- if (pAMVideoAccelerator) {
- memcpy(&UncompInfo.ddUncompPixelFormat, &m_ddUncompPixelFormat, sizeof(DDPIXELFORMAT));
- UncompInfo.dwUncompWidth = m_pVideoDecFilter->PictWidthRounded();
- UncompInfo.dwUncompHeight = m_pVideoDecFilter->PictHeightRounded();
- hr = pAMVideoAccelerator->GetCompBufferInfo(&m_GuidDecoderDXVA1, &UncompInfo, &dwNumTypesCompBuffers, CompInfo);
-
- if (SUCCEEDED(hr)) {
- hr = m_pVideoDecFilter->CreateDXVA1Decoder(pAMVideoAccelerator, pGuid, m_dwDXVA1SurfaceCount);
-
- if (SUCCEEDED(hr)) {
- m_pVideoDecFilter->SetDXVA1Params(&m_GuidDecoderDXVA1, &m_ddUncompPixelFormat);
-
- pConnectMode = (DXVA_ConnectMode*)CoTaskMemAlloc(sizeof(DXVA_ConnectMode));
- if (pConnectMode != nullptr) {
- pConnectMode->guidMode = m_GuidDecoderDXVA1;
- pConnectMode->wRestrictedMode = m_pVideoDecFilter->GetDXVA1RestrictedMode();
- *pdwSizeMiscData = sizeof(DXVA_ConnectMode);
- *ppMiscData = pConnectMode;
- } else {
- hr = E_OUTOFMEMORY;
- }
- }
- }
- }
-
- return hr;
-}
diff --git a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h
deleted file mode 100644
index d0254bd4c..000000000
--- a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include <videoacc.h>
-#include "../BaseVideoFilter/BaseVideoFilter.h"
-
-
-class CMPCVideoDecFilter;
-class CVideoDecDXVAAllocator;
-
-
-class CVideoDecOutputPin : public CBaseVideoOutputPin
- , public IAMVideoAcceleratorNotify
-{
-public:
- CVideoDecOutputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName);
-
- ~CVideoDecOutputPin();
-
- HRESULT InitAllocator(IMemAllocator** ppAlloc);
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- // IAMVideoAcceleratorNotify
- STDMETHODIMP GetUncompSurfacesInfo(const GUID* pGuid, LPAMVAUncompBufferInfo pUncompBufferInfo);
- STDMETHODIMP SetUncompSurfacesInfo(DWORD dwActualUncompSurfacesAllocated);
- STDMETHODIMP GetCreateVideoAcceleratorData(const GUID* pGuid, LPDWORD pdwSizeMiscData, LPVOID* ppMiscData);
-
-private:
- CMPCVideoDecFilter* m_pVideoDecFilter;
- CVideoDecDXVAAllocator* m_pDXVA2Allocator;
- DWORD m_dwDXVA1SurfaceCount;
- GUID m_GuidDecoderDXVA1;
- DDPIXELFORMAT m_ddUncompPixelFormat;
-};
diff --git a/src/filters/transform/MPCVideoDec/array_allocator.h b/src/filters/transform/MPCVideoDec/array_allocator.h
deleted file mode 100644
index ea4241376..000000000
--- a/src/filters/transform/MPCVideoDec/array_allocator.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef _ARRAY_ALLOCATOR_H_
-#define _ARRAY_ALLOCATOR_H_
-
-#include "PODtypes.h"
-
-template <class T, size_t size> class array_allocator
-{
-private:
- T* p;
-public:
- typedef T value_type;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
-
- typedef T* pointer;
- typedef const T* const_pointer;
-
- typedef T& reference;
- typedef const T& const_reference;
-
- pointer address(reference r) const {return &r;}
- const_pointer address(const_reference r) const {return &r;}
-
- array_allocator() throw() {}
- template <class U, size_t sz> array_allocator(const array_allocator<U, sz>&) throw() {}
- ~array_allocator() throw() {}
-
- pointer allocate(size_type n, const void* = 0) {
- p = ((T *)::operator new(size * sizeof(T)));
- return p;
- }
- void deallocate(pointer p, size_type) {delete p;}
-
- //Use placement new to engage the constructor
- void construct(pointer p, const T& val) {new((void*)p) T(val);}
- void destroy(pointer p) {((T*)p)->~T();}
-
- size_type max_size() const throw() {return size;}
- template<class U> struct rebind {typedef array_allocator<U, size> other;};
-};
-
-template<class T, size_t size> struct array_vector : std::vector<T, array_allocator<T, size> > {
-};
-
-#if defined(__INTEL_COMPILER) || defined(__GNUC__) || (_MSC_VER >= 1300)
-template<class T, size_t a> struct allocator_traits<array_allocator<T, a> > {enum {is_static = true};};
-#endif
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/char_t.h b/src/filters/transform/MPCVideoDec/char_t.h
deleted file mode 100644
index ad422fd10..000000000
--- a/src/filters/transform/MPCVideoDec/char_t.h
+++ /dev/null
@@ -1,291 +0,0 @@
-#ifndef _CHAR_T_H_
-#define _CHAR_T_H_
-
-#include <stdio.h>
-#include <time.h>
-#include <wchar.h>
-
-#pragma warning(push)
-#pragma warning(disable:4995 4996)
-
-#undef _l
-#ifdef UNICODE
-typedef wchar_t char_t;
-#define tsprintf swprintf
-#define tsnprintf_s _snwprintf_s
-#define tfprintf fwprintf
-#define tsscanf swscanf
-#define __l(x) L ## x
-#define _l(x) __l(x)
-#else
-typedef char char_t;
-#define tsprintf sprintf
-#define tsnprintf_s _snprintf_s
-#define tfprintf fprintf
-#define tsscanf sscanf
-#define _l(x) x
-#endif
-
-#ifdef __cplusplus
-
-#ifdef __GNUC__
-#ifndef __forceinline
-#define __forceinline __attribute__((__always_inline__)) inline
-#endif
-#endif
-
-static __forceinline errno_t strncat_s(wchar_t *a, size_t b, const wchar_t *c, size_t d)
-{
- return wcsncat_s(a, b, c, d);
-}
-static __forceinline int vsnprintf_s(wchar_t *a, size_t b, size_t c, const wchar_t *d, va_list e)
-{
- return _vsnwprintf_s(a, b, c, d, e);
-}
-static __forceinline errno_t _splitpath_s(const wchar_t * a,
- wchar_t * b, size_t c, wchar_t * d, size_t e,
- wchar_t * f, size_t g, wchar_t * h, size_t i)
-{
- return _wsplitpath_s(a, b, c, d, e, f, g, h, i);
-};
-static __forceinline errno_t _makepath_s(wchar_t *a, size_t b,
- const wchar_t *c, const wchar_t *d,
- const wchar_t *e, const wchar_t *f)
-{
- return _wmakepath_s(a, b, c, d, e, f);
-};
-static __forceinline wchar_t* ff_strncpy(wchar_t *dst, const wchar_t *src, size_t count)
-{
- wcsncpy_s(dst, count, src, _TRUNCATE);
- return dst;
-}
-static __forceinline char* ff_strncpy(char *dst, const char *src, size_t count)
-{
- strncpy_s(dst, count, src, _TRUNCATE);
- return dst;
-}
-
-static __forceinline wchar_t* strcat(wchar_t *a, const wchar_t *b)
-{
- return wcscat(a, b);
-}
-static __forceinline int strcmp(const wchar_t *a, const wchar_t *b)
-{
- return wcscmp(a, b);
-}
-static __forceinline int strncmp(const wchar_t *a, const wchar_t *b, size_t c)
-{
- return wcsncmp(a, b, c);
-}
-static __forceinline int strnicmp(const wchar_t *a, const wchar_t *b, size_t c)
-{
- return _wcsnicmp(a, b, c);
-}
-
-static __forceinline long strtol(const wchar_t *a, wchar_t **b, int c)
-{
- return wcstol(a, b, c);
-}
-static __forceinline wchar_t* strchr(const wchar_t *a, wchar_t b)
-{
- return (wchar_t*)wcschr(a, b);
-}
-static __forceinline int _strnicmp(const wchar_t *a, const wchar_t *b, size_t c)
-{
- return _wcsnicmp(a, b, c);
-}
-static __forceinline wchar_t* strstr(const wchar_t *a, const wchar_t *b)
-{
- return (wchar_t*)wcsstr(a, b);
-}
-static __forceinline size_t strlen(const wchar_t *a)
-{
- return wcslen(a);
-}
-static __forceinline wchar_t* strcpy(wchar_t *a, const wchar_t *b)
-{
- return wcscpy(a, b);
-}
-static __forceinline int atoi(const wchar_t *a)
-{
- return _wtoi(a);
-}
-static __forceinline wchar_t* _itoa(int a, wchar_t *b, int c)
-{
- return _itow(a, b, c);
-}
-static __forceinline int stricmp(const wchar_t *a, const wchar_t *b)
-{
- return _wcsicmp(a, b);
-}
-static __forceinline unsigned long strtoul(const wchar_t *a, wchar_t **b, int c)
-{
- return wcstoul(a, b, c);
-}
-static __forceinline double strtod(const wchar_t *a, wchar_t **b)
-{
- return wcstod(a, b);
-}
-static __forceinline int vsprintf(wchar_t *a, const wchar_t *b, va_list c)
-{
- return vswprintf(a, b, c);
-}
-static __forceinline int _vsnprintf(wchar_t *a, size_t b, const wchar_t *c, va_list d)
-{
- return _vsnwprintf(a, b, c, d);
-}
-
-static __forceinline FILE* fopen(const wchar_t *a, const wchar_t *b)
-{
- return _wfopen(a, b);
-}
-static __forceinline int fputs(const wchar_t *a, FILE *b)
-{
- return fputws(a, b);
-}
-static __forceinline int _stricoll(const wchar_t *a, const wchar_t *b)
-{
- return _wcsicoll(a, b);
-}
-static __forceinline wchar_t* strrchr(const wchar_t *a, wchar_t b)
-{
- return (wchar_t*)wcsrchr(a, b);
-}
-static __forceinline wchar_t* strupr(wchar_t *a)
-{
- return _wcsupr(a);
-}
-static __forceinline wchar_t* strlwr(wchar_t *a)
-{
- return _wcslwr(a);
-}
-static __forceinline wchar_t* _strtime(wchar_t *a)
-{
- return _wstrtime(a);
-}
-static __forceinline wchar_t* memchr(wchar_t *a, wchar_t b, size_t c)
-{
- return wmemchr(a, b, c);
-}
-static __forceinline const wchar_t* memchr(const wchar_t *a, wchar_t b, size_t c)
-{
- return wmemchr(a, b, c);
-}
-static __forceinline wchar_t* strpbrk(const wchar_t *a, const wchar_t *b)
-{
- return (wchar_t*)wcspbrk(a, b);
-}
-static __forceinline int64_t _strtoi64(const wchar_t *nptr, wchar_t **endptr, int base)
-{
- return _wcstoi64(nptr, endptr, base);
-};
-
-template<class Tout> struct text
- // ANSI <--> UNICODE conversion.
- // in : input string in char* or wchar_t*.
- // inlen : count of characters, not byte size!! -1 for null terminated string.
- // out : output string in char* or wchar_t*.
- // outlen : count of characters, not byte size!!
-{
-private:
- Tout *buf;
- bool own;
-public:
- template<class Tin> inline text(const Tin *in, int code_page = CP_ACP);
- template<class Tin> inline text(const Tin *in, Tout *Ibuf, int code_page = CP_ACP);
- template<class Tin> inline text(const Tin *in, int inlen, Tout *Ibuf, size_t outlen, int code_page = CP_ACP);
- ~text() {
- if (own) {
- delete []buf;
- }
- }
- operator const Tout*() const {
- return buf;
- }
-};
-
-
-template<> template<> inline text<char>::text(const char *in, int code_page): buf(const_cast<char*>(in)), own(false) {}
-template<> template<> inline text<char>::text(const char *in, char *Ibuf, int code_page): buf(strcpy(Ibuf, in)), own(false) {}
-template<> template<> inline text<char>::text(const char *in, int inlen, char *Ibuf, size_t outlen, int code_page): own(false)
-{
- if (inlen != -1) {
- buf = Ibuf;
- if ((size_t)inlen < outlen) {
- ff_strncpy(Ibuf, in, inlen + 1);
- } else {
- ff_strncpy(Ibuf, in, outlen);
- }
- } else {
- buf = Ibuf;
- ff_strncpy(Ibuf, in, outlen);
- }
-}
-
-
-template<> template<> inline text<wchar_t>::text(const wchar_t *in, int code_page): buf(const_cast<wchar_t*>(in)), own(false) {}
-template<> template<> inline text<wchar_t>::text(const wchar_t *in, wchar_t *Ibuf, int code_page): buf(strcpy(Ibuf, in)), own(false) {}
-template<> template<> inline text<wchar_t>::text(const wchar_t *in, int inlen, wchar_t *Ibuf, size_t outlen, int code_page): own(false)
-{
- if (inlen != -1) {
- buf = Ibuf;
- if ((size_t)inlen < outlen) {
- ff_strncpy(Ibuf, in, inlen + 1);
- } else {
- ff_strncpy(Ibuf, in, outlen);
- }
- } else {
- buf = Ibuf;
- ff_strncpy(Ibuf, in, outlen);
- }
-}
-
-
-template<> template<> inline text<wchar_t>::text(const char *in, int code_page): own(in ? true : false)
-{
- if (in) {
- size_t l = strlen(in);
- buf = new wchar_t[l + 1];
- MultiByteToWideChar(code_page, 0, in, int(l + 1), buf, int(l + 1));
- } else {
- buf = NULL;
- }
-}
-template<> template<> inline text<wchar_t>::text(const char *in, wchar_t *Ibuf, int code_page): own(false), buf(Ibuf)
-{
- size_t l = strlen(in);
- MultiByteToWideChar(code_page, 0, in, int(l + 1), buf, int(l + 1));
-}
-template<> template<> inline text<wchar_t>::text(const char *in, int inlen, wchar_t *Ibuf, size_t outlen, int code_page): own(false), buf(Ibuf)
-{
- MultiByteToWideChar(code_page, 0, in, int(inlen), buf, int(outlen));
-}
-
-
-template<> template<> inline text<char>::text(const wchar_t *in, int code_page): own(in ? true : false)
-{
- if (in) {
- size_t l = strlen(in);
- int length = WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, 0, NULL, NULL);
- buf = new char[length + 1];
- WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, int(length + 1), NULL, NULL);
- } else {
- buf = NULL;
- }
-}
-template<> template<> inline text<char>::text(const wchar_t *in, char *Ibuf, int code_page): own(false), buf(Ibuf)
-{
- size_t l = strlen(in);
- int length = WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, 0, NULL, NULL);
- WideCharToMultiByte(code_page, 0, in, int(l + 1), buf, length, NULL, NULL);
-}
-template<> template<> inline text<char>::text(const wchar_t *in, int inlen, char *Ibuf, size_t outlen, int code_page): own(false), buf(Ibuf)
-{
- WideCharToMultiByte(code_page, 0, in, int(inlen), buf, int(outlen), NULL, NULL);
-}
-
-#endif
-
-#pragma warning(pop)
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/ffImgfmt.cpp b/src/filters/transform/MPCVideoDec/ffImgfmt.cpp
deleted file mode 100644
index 5bb8cbdd8..000000000
--- a/src/filters/transform/MPCVideoDec/ffImgfmt.cpp
+++ /dev/null
@@ -1,1562 +0,0 @@
-/*
- * Copyright (c) 2003-2006 Milan Cutka
- *
- * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "stdafx.h"
-#include <vector>
-#include "ffmpeg/libavcodec/avcodec.h"
-#include <uuids.h>
-#include "moreuuids.h"
-#include "char_t.h"
-#include "ffImgfmt.h"
-
-const TcspInfo cspInfos[] = {
- {
- FF_CSP_420P, _l("YV12"),
- 1, 12, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 128, 128, 0}, //black,
- FOURCC_YV12, FOURCC_YV12, &MEDIASUBTYPE_YV12
- },
- {
- FF_CSP_422P, _l("422P"),
- 1, 16, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_422P, FOURCC_422P, &MEDIASUBTYPE_422P
- },
- {
- FF_CSP_444P, _l("444P"),
- 1, 24, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_444P, FOURCC_444P, &MEDIASUBTYPE_444P
- },
- {
- FF_CSP_411P, _l("411P"),
- 1, 17, //Bpp
- 3, //numplanes
- {0, 2, 2, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_411P, FOURCC_411P, &MEDIASUBTYPE_411P
- },
- {
- FF_CSP_410P, _l("410P"),
- 1, 10, //Bpp
- 3, //numplanes
- {0, 2, 2, 0}, //shiftX
- {0, 2, 2, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_410P, FOURCC_410P, &MEDIASUBTYPE_410P
- },
-
- {
- FF_CSP_YUY2, _l("YUY2"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0x8000, 0, 0, 0}, //black
- FOURCC_YUY2, FOURCC_YUY2, &MEDIASUBTYPE_YUY2,
- 0, 1 //packedLumaOffset,packedChromaOffset
- },
- {
- FF_CSP_UYVY, _l("UYVY"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0x0080, 0, 0, 0}, //black
- FOURCC_UYVY, FOURCC_UYVY, &MEDIASUBTYPE_UYVY,
- 1, 0 //packedLumaOffset,packedChromaOffset
- },
- {
- FF_CSP_YVYU, _l("YVYU"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0x8000, 0, 0, 0}, //black
- FOURCC_YVYU, FOURCC_YVYU, &MEDIASUBTYPE_YVYU,
- 0, 1 //packedLumaOffset,packedChromaOffset
- },
- {
- FF_CSP_VYUY, _l("VYUY"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0x0080, 0, 0, 0}, //black
- FOURCC_VYUY, FOURCC_VYUY, &MEDIASUBTYPE_VYUY,
- 1, 0 //packedLumaOffset,packedChromaOffset
- },
-
- {
- FF_CSP_ABGR, _l("ABGR"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_RGBA, _l("RGBA"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_BGR32, _l("BGR32"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_BGR24, _l("BGR24"),
- 3, 24, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB24
- },
- {
- FF_CSP_BGR15, _l("BGR15"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB555
- },
- {
- FF_CSP_BGR16, _l("BGR16"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB565
- },
- {
- FF_CSP_RGB32, _l("RGB32"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, FOURCC_RGB3, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_RGB24, _l("RGB24"),
- 3, 24, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, FOURCC_RGB2, &MEDIASUBTYPE_RGB24
- },
- {
- FF_CSP_RGB15, _l("RGB15"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, FOURCC_RGB5, &MEDIASUBTYPE_RGB555
- },
- {
- FF_CSP_RGB16, _l("RGB16"),
- 2, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, FOURCC_RGB6, &MEDIASUBTYPE_RGB565
- },
- {
- FF_CSP_CLJR, _l("cljr"),
- 1, 16, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- FOURCC_CLJR, FOURCC_CLJR, &MEDIASUBTYPE_CLJR
- },
- {
- FF_CSP_Y800, _l("gray"),
- 1, 8, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- FOURCC_Y800, FOURCC_Y800, &MEDIASUBTYPE_Y800
- },
- {
- FF_CSP_NV12, _l("NV12"),
- 1, 12, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_NV12, FOURCC_NV12, &MEDIASUBTYPE_NV12
- },
- {
- FF_CSP_420P10, _l("420P10"),
- 2, 24, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 512, 512, 0}, //black
- FOURCC_420R, FOURCC_420R, &MEDIASUBTYPE_420R
- },
- {
- FF_CSP_444P10, _l("444P10"),
- 2, 48, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 512, 512, 0}, //black
- FOURCC_444R, FOURCC_444R, &MEDIASUBTYPE_444R
- },
- {
- FF_CSP_P016, _l("P016"),
- 2, 24, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 32768, 32768, 0}, //black,
- FOURCC_P016, FOURCC_P016, &MEDIASUBTYPE_P016
- },
- {
- FF_CSP_P010, _l("P010"),
- 2, 24, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 32768, 32768, 0}, //black,
- FOURCC_P010, FOURCC_P010, &MEDIASUBTYPE_P010
- },
- {
- FF_CSP_422P10, _l("422P10"),
- 2, 32, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 512, 512, 0}, //black
- FOURCC_422R, FOURCC_422R, &MEDIASUBTYPE_422R
- },
- {
- FF_CSP_P210, _l("P210"),
- 2, 32, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 32768, 32768, 0}, //black,
- FOURCC_P210, FOURCC_P210, &MEDIASUBTYPE_P210
- },
- {
- FF_CSP_P216, _l("P216"),
- 2, 32, //Bpp
- 2, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 32768, 32768, 0}, //black,
- FOURCC_P216, FOURCC_P216, &MEDIASUBTYPE_P216
- },
- {
- FF_CSP_AYUV, _l("AYUV"),
- 4, 32, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 128, 128, 0}, //black
- FOURCC_AYUV, FOURCC_AYUV, &MEDIASUBTYPE_AYUV
- },
- {
- FF_CSP_Y416, _l("Y416"),
- 8, 64, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 32768, 32768, 0}, //black
- FOURCC_Y416, FOURCC_Y416, &MEDIASUBTYPE_Y416
- },
- {
- FF_CSP_PAL8, _l("pal8"),
- 1, 8, //Bpp
- 1, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB8
- },
- {
- FF_CSP_GBRP, _l("GBRP"),
- 1, 24, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- 0, 0, NULL
- },
- {
- FF_CSP_GBRP9, _l("GBRP9"),
- 2, 48, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- 0, 0, NULL
- },
- {
- FF_CSP_GBRP10, _l("GBRP10"),
- 2, 48, //Bpp
- 3, //numplanes
- {0, 0, 0, 0}, //shiftX
- {0, 0, 0, 0}, //shiftY
- {0, 0, 0, 0}, //black
- 0, 0, NULL
- },
- 0
-};
-
-TcspInfo cspInfoIYUV = {
- FF_CSP_420P, _l("YV12"),
- 1, 12, //Bpp
- 3, //numplanes
- {0, 1, 1, 0}, //shiftX
- {0, 1, 1, 0}, //shiftY
- {0, 128, 128, 0}, //black,
- FOURCC_IYUV, FOURCC_IYUV, &MEDIASUBTYPE_IYUV
-};
-
-const TcspFcc cspFccs[] = {
- _l("YV12") , FOURCC_YV12, FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ, false, true,
- _l("I420/IYUV"), FOURCC_I420, FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ | FF_CSP_FLAGS_YUV_ORDER, false, true,
- _l("YUY2") , FOURCC_YUY2, FF_CSP_YUY2, false, true,
- _l("YVYU") , FOURCC_YVYU, FF_CSP_YVYU, false, true,
- _l("UYVY") , FOURCC_UYVY, FF_CSP_UYVY, false, true,
- _l("VYUY") , FOURCC_VYUY, FF_CSP_VYUY, false, true,
- _l("RGB32") , FOURCC_RGB3, FF_CSP_RGB32, true, true,
- _l("RGB24") , FOURCC_RGB2, FF_CSP_RGB24, true, true,
- _l("RGB555") , FOURCC_RGB5, FF_CSP_RGB15, true, true,
- _l("RGB565") , FOURCC_RGB6, FF_CSP_RGB16, true, true,
- _l("CLJR") , FOURCC_CLJR, FF_CSP_CLJR, false, false,
- _l("Y800") , FOURCC_Y800, FF_CSP_Y800, false, true,
- _l("NV12") , FOURCC_NV12, FF_CSP_NV12, false, false,
- _l("P016") , FOURCC_P016, FF_CSP_P016, false, false,
- _l("P010") , FOURCC_P010, FF_CSP_P010, false, false,
- _l("P210") , FOURCC_P210, FF_CSP_P210, false, false,
- _l("P216") , FOURCC_P216, FF_CSP_P216, false, false,
- _l("AYUV") , FOURCC_AYUV, FF_CSP_AYUV, false, false,
- _l("Y416") , FOURCC_Y416, FF_CSP_Y416, false, false,
- NULL, 0
-};
-
-char_t* csp_getName(uint64_t csp, char_t *buf, size_t len)
-{
- return csp_getName2(csp_getInfo(csp), csp, buf, len);
-}
-char_t* csp_getName2(const TcspInfo *cspInfo, uint64_t csp, char_t *buf, size_t len)
-{
- const char_t *colorspaceName = cspInfo ? cspInfo->name : _l("unknown");
- tsnprintf_s(buf,
- len,
- _TRUNCATE,
- _l("%s%s%s"),
- colorspaceName,
- csp & FF_CSP_FLAGS_VFLIP ? _l(", flipped vertically") : _l(""),
- csp & FF_CSP_FLAGS_INTERLACED ? _l(", interlaced") : _l(""));
- return buf;
-}
-
-const TcspInfo* csp_getInfoFcc(FOURCC fcccsp)
-{
- if (fcccsp == FOURCC_IYUV || fcccsp == FOURCC_I420) {
- return &cspInfoIYUV;
- } else {
- for (int i = 0; i < FF_CSPS_NUM; i++) {
- if (cspInfos[i].fcccsp == fcccsp) {
- return cspInfos + i;
- }
- }
- return NULL;
- }
-}
-
-uint64_t csp_bestMatch(uint64_t inCSP, uint64_t wantedCSPS, int *rank, uint64_t outPrimaryCSP)
-{
- if (outPrimaryCSP & wantedCSPS & FF_CSPS_MASK) {
- if (rank) {
- *rank = 200;
- }
- return outPrimaryCSP | (inCSP&~FF_CSPS_MASK);
- }
- uint64_t outCSP = inCSP & wantedCSPS & FF_CSPS_MASK;
- if (outCSP) {
- if (rank) {
- *rank = 100;
- }
- return outCSP | (inCSP&~FF_CSPS_MASK);
- }
-
- const uint64_t *bestcsps = NULL;
- switch (inCSP & FF_CSPS_MASK) {
- case FF_CSP_420P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_NV12 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_422P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_444P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_AYUV ,
- FF_CSP_444P10,
- FF_CSP_Y416 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_411P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_410P: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_411P ,
- FF_CSP_NV12 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
-
- case FF_CSP_YUY2: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_UYVY: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_YUY2 ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_YVYU: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_VYUY: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
-
- case FF_CSP_ABGR: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGBA: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_BGR32: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_BGR24: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB24,
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_RGB32,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_BGR15: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR24,
- FF_CSP_BGR16,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_BGR16: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_BGR15,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGB32: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_420P10,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGB24: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_BGR24,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGB15: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_BGR15,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_RGB16,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_BGR16,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_RGB16: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB15,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_CLJR: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_Y800: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_NV12: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_420P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_420P10: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_444P10,
- FF_CSP_Y416 ,
- FF_CSP_NV12 ,
- FF_CSP_420P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_AYUV ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_422P10: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_Y416 ,
- FF_CSP_422P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_444P10,
- FF_CSP_444P ,
- FF_CSP_AYUV ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_420P ,
- FF_CSP_NV12 ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_444P10: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_Y416 ,
- FF_CSP_444P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_AYUV ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_PAL8: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB32,
- FF_CSP_BGR32,
- FF_CSP_RGB24,
- FF_CSP_BGR24,
- FF_CSP_RGB15,
- FF_CSP_BGR15,
- FF_CSP_RGB16,
- FF_CSP_BGR16,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_444P ,
- FF_CSP_422P ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_GBRP: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB32,
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P ,
- FF_CSP_444P10,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P ,
- FF_CSP_422P10,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P ,
- FF_CSP_420P10,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_GBRP9: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB32,
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P10,
- FF_CSP_444P ,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P10,
- FF_CSP_422P ,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P10,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- case FF_CSP_GBRP10: {
- static const uint64_t best[FF_CSPS_NUM] = {
- FF_CSP_RGB32,
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_444P10,
- FF_CSP_444P ,
- FF_CSP_AYUV ,
- FF_CSP_Y416 ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_422P10,
- FF_CSP_422P ,
- FF_CSP_P210 ,
- FF_CSP_P216 ,
- FF_CSP_420P10,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_NV12 ,
- FF_CSP_P010 ,
- FF_CSP_P016 ,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_NULL
- };
- bestcsps = best;
- break;
- }
- default:
- return FF_CSP_NULL;
- }
- if (rank) {
- *rank = 99;
- }
- while (*bestcsps) {
- if (*bestcsps & wantedCSPS) {
- return *bestcsps | (inCSP&~FF_CSPS_MASK);
- }
- bestcsps++;
- if (rank) {
- (*rank)--;
- }
- }
- return FF_CSP_NULL;
-}
-
-/*
-bool csp_inFOURCCmask(uint64_t x, FOURCC fcc)
-{
- switch (fcc) {
- case FOURCC_MASK_YUV:
- return !!csp_isYUV(x);
- case FOURCC_MASK_RGB:
- return !!csp_isRGB(x);
- default:
- return false;
- }
-}
-*/
-
-bool TcspInfos::TsortFc::operator()(const TcspInfo* &csp1, const TcspInfo* &csp2)
-{
- int rank1;
- csp_bestMatch(csp, csp1->id, &rank1, outPrimaryCSP);
- int rank2;
- csp_bestMatch(csp, csp2->id, &rank2, outPrimaryCSP);
- return rank1 > rank2;
-}
-
-/*
-void TcspInfos::sort(uint64_t csp, uint64_t outPrimaryCSP)
-{
- std::sort(begin(), end(), TsortFc(csp & FF_CSPS_MASK, outPrimaryCSP));
-}
-
-uint64_t getBMPcolorspace(const BITMAPINFOHEADER *hdr, const TcspInfos &forcedCsps)
-{
- uint64_t csp;
- switch (hdr->biCompression) {
- case BI_RGB:
- switch (hdr->biBitCount) {
- case 15:
- csp = FF_CSP_RGB15 | FF_CSP_FLAGS_VFLIP;
- break;
- case 16:
- csp = FF_CSP_RGB16 | FF_CSP_FLAGS_VFLIP;
- break;
- case 24:
- csp = FF_CSP_RGB24 | FF_CSP_FLAGS_VFLIP;
- break;
- case 32:
- csp = FF_CSP_RGB32 | FF_CSP_FLAGS_VFLIP;
- break;
- default:
- return FF_CSP_NULL;
- }
- break;
- case FOURCC_I420:
- case FOURCC_IYUV:
- csp = FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ | FF_CSP_FLAGS_YUV_ORDER;
- break;
- case FOURCC_YV12:
- csp = FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ;
- break;
- case FOURCC_YUYV:
- case FOURCC_YUY2:
- case FOURCC_V422:
- csp = FF_CSP_YUY2;
- break;
- case FOURCC_YVYU:
- csp = FF_CSP_YVYU;
- break;
- case FOURCC_UYVY:
- csp = FF_CSP_UYVY;
- break;
- case FOURCC_VYUY:
- csp = FF_CSP_VYUY;
- break;
- case FOURCC_Y800:
- csp = FF_CSP_Y800;
- break;
- case FOURCC_444P:
- case FOURCC_YV24:
- csp = FF_CSP_444P;
- break;
- case FOURCC_422P:
- csp = FF_CSP_422P;
- break;
- case FOURCC_YV16:
- csp = FF_CSP_422P | FF_CSP_FLAGS_YUV_ADJ;
- break;
- case FOURCC_411P:
- case FOURCC_Y41B:
- csp = FF_CSP_411P;
- break;
- case FOURCC_410P:
- csp = FF_CSP_410P;
- break;
- case FOURCC_420R:
- csp = FF_CSP_420P10;
- break;
- case FOURCC_422R:
- csp = FF_CSP_422P10;
- break;
- case FOURCC_444R:
- csp = FF_CSP_444P10;
- break;
- case FOURCC_P016:
- csp = FF_CSP_P016;
- break;
- case FOURCC_P010:
- csp = FF_CSP_P010;
- break;
- case FOURCC_P210:
- csp = FF_CSP_P210;
- break;
- case FOURCC_P216:
- csp = FF_CSP_P216;
- break;
- case FOURCC_AYUV:
- csp = FF_CSP_AYUV;
- break;
- case FOURCC_Y416:
- csp = FF_CSP_Y416;
- break;
- default:
- return FF_CSP_NULL;
- }
- bool ok;
- if (!forcedCsps.empty()) {
- ok = std::find(forcedCsps.begin(), forcedCsps.end(), csp_getInfo(csp)) != forcedCsps.end();
- } else {
- ok = true;
- }
- return ok ? csp : FF_CSP_NULL;
-}
-*/
diff --git a/src/filters/transform/MPCVideoDec/ffImgfmt.h b/src/filters/transform/MPCVideoDec/ffImgfmt.h
deleted file mode 100644
index 30f3c77cc..000000000
--- a/src/filters/transform/MPCVideoDec/ffImgfmt.h
+++ /dev/null
@@ -1,489 +0,0 @@
-#ifndef _FFIMGFMT_H_
-#define _FFIMGFMT_H_
-
-#include "ffmpeg/libavutil/pixfmt.h"
-
-//================================ ffdshow ==================================
-// the RGB related values in this enum refers to the "memory byte order" (byte order as stored in memory).
-// under x86 architecture (little endians), the byte order is stored reversed (comparing to the write order),
-// this means RGB will be stored in the memory as BGR.
-// When working with DirectShow in the Red-Green-Blue colorspace, DirectShow always
-// expects RGB at the "memory byte order", so RGB should be selected.
-// When working with files, we are interested in the "write order", which is the opposite
-// of the "memory byte order" (under x86), so you should select the opposite from the
-// destination byte order for the file.
-// (e.g. PNG images uses RGB order, so select BGR order
-// BMP image uses BGR order, so select RGB order)
-
-/* ffdshow colorspace ids, values should be unique including flag values, and must fit inside a uint64_t
- * (an enum should be used instead of defines, but GCC does not support an enum with type uint64_t ?)
- */
-
-// Do not reorder or renumber! Values are stored in user's registry.
-#define FF_CSP_NULL (0ULL)
-
-#define FF_CSP_420P (1ULL << 0) // 0x0000001
-#define FF_CSP_422P (1ULL << 1) // 0x0000002
-#define FF_CSP_444P (1ULL << 2) // 0x0000004
-#define FF_CSP_411P (1ULL << 3) // 0x0000008
-#define FF_CSP_410P (1ULL << 4) // 0x0000010
-
-#define FF_CSP_YUY2 (1ULL << 5) // 0x0000020
-#define FF_CSP_UYVY (1ULL << 6) // 0x0000040
-#define FF_CSP_YVYU (1ULL << 7) // 0x0000080
-#define FF_CSP_VYUY (1ULL << 8) // 0x0000100
-
-#define FF_CSP_ABGR (1ULL << 9) // 0x0000200 [a|b|g|r]
-#define FF_CSP_RGBA (1ULL << 10) // 0x0000400 [r|g|b|a]
-#define FF_CSP_BGR32 (1ULL << 11) // 0x0000800
-#define FF_CSP_BGR24 (1ULL << 12) // 0x0001000
-#define FF_CSP_BGR15 (1ULL << 13) // 0x0002000
-#define FF_CSP_BGR16 (1ULL << 14) // 0x0004000
-#define FF_CSP_RGB32 (1ULL << 15) // 0x0008000
-#define FF_CSP_RGB24 (1ULL << 16) // 0x0010000
-#define FF_CSP_RGB15 (1ULL << 17) // 0x0020000
-#define FF_CSP_RGB16 (1ULL << 18) // 0x0040000
-
-#define FF_CSP_CLJR (1ULL << 19) // 0x0080000
-#define FF_CSP_Y800 (1ULL << 20) // 0x0100000
-#define FF_CSP_NV12 (1ULL << 21) // 0x0200000
-
-#define FF_CSP_420P10 (1ULL << 22) // 0x0400000
-#define FF_CSP_444P10 (1ULL << 23) // 0x0800000
-#define FF_CSP_P016 (1ULL << 24) // 0x1000000 P016 in Media Fundation (MFVideoFormat_P016). 16bit version of NV12.
-#define FF_CSP_P010 (1ULL << 25) // 0x2000000 P010 in Media Fundation (MFVideoFormat_P010). same as FF_CSP_P016
-#define FF_CSP_422P10 (1ULL << 26) // 0x4000000
-#define FF_CSP_P210 (1ULL << 27) // 0x8000000
-#define FF_CSP_P216 (1ULL << 28) // 0x10000000
-
-#define FF_CSP_AYUV (1ULL << 29) // 0x20000000
-#define FF_CSP_Y416 (1ULL << 30) // 0x40000000
-
-#define FF_CSP_PAL8 (1ULL << 31) // 0x80000000
-
-#define FF_CSP_GBRP (1ULL << 32) // 0x100000000
-#define FF_CSP_GBRP9 (1ULL << 33) // 0x200000000
-#define FF_CSP_GBRP10 (1ULL << 34) // 0x400000000
-
-#define FF_CSP_420P9 (1ULL << 35) // 0x800000000
-#define FF_CSP_422P9 (1ULL << 36) // 0x1000000000
-#define FF_CSP_444P9 (1ULL << 37) // 0x2000000000
-
-// Flags
-#define FF_CSP_FLAGS_YUV_JPEG (1ULL << 59)
-#define FF_CSP_FLAGS_YUV_ORDER (1ULL << 60) // UV ordered chroma planes (not VU as default)
-#define FF_CSP_FLAGS_YUV_ADJ (1ULL << 61) // YUV planes are stored consecutively in one memory block
-#define FF_CSP_FLAGS_INTERLACED (1ULL << 62)
-#define FF_CSP_FLAGS_VFLIP (1ULL << 63) // flip mask
-
-#define FF_CSPS_NUM 38
-
-#define FF_CSP_UNSUPPORTED (1ULL<<FF_CSPS_NUM)
-
-#define FF_CSPS_MASK (FF_CSP_UNSUPPORTED-1)
-#define FF_CSPS_MASK_HIGH_BIT (FF_CSP_420P10|FF_CSP_422P10|FF_CSP_444P10)
-#define FF_CSPS_MASK_YUV_PLANAR (FF_CSP_420P|FF_CSP_422P|FF_CSP_444P|FF_CSP_411P|FF_CSP_410P)
-#define FF_CSPS_MASK_RGB_PLANAR (FF_CSP_GBRP|FF_CSP_GBRP9|FF_CSP_GBRP10)
-#define FF_CSPS_MASK_YUV_PACKED (FF_CSP_YUY2|FF_CSP_UYVY|FF_CSP_YVYU|FF_CSP_VYUY)
-#define FF_CSPS_MASK_RGB (FF_CSP_RGBA|FF_CSP_RGB32|FF_CSP_RGB24|FF_CSP_RGB15|FF_CSP_RGB16)
-#define FF_CSPS_MASK_BGR (FF_CSP_ABGR|FF_CSP_BGR32|FF_CSP_BGR24|FF_CSP_BGR15|FF_CSP_BGR16)
-#define FF_CSPS_MASK_FFRGB (FF_CSP_RGB32|FF_CSP_RGB24|FF_CSP_BGR32|FF_CSP_BGR24) // ffdshow converters output color spaces. Require dst stride to be multiple of 4.
-
-#include <stddef.h>
-typedef int stride_t;
-
-//==================================== xvid4 =====================================
-
-#define XVID4_CSP_PLANAR (1<< 0) /* 4:2:0 planar */
-#define XVID4_CSP_I420 (1<< 1) /* 4:2:0 packed(planar win32) */
-#define XVID4_CSP_YV12 (1<< 2) /* 4:2:0 packed(planar win32) */
-#define XVID4_CSP_YUY2 (1<< 3) /* 4:2:2 packed */
-#define XVID4_CSP_UYVY (1<< 4) /* 4:2:2 packed */
-#define XVID4_CSP_YVYU (1<< 5) /* 4:2:2 packed */
-#define XVID4_CSP_BGRA (1<< 6) /* 32-bit bgra packed */
-#define XVID4_CSP_ABGR (1<< 7) /* 32-bit abgr packed */
-#define XVID4_CSP_RGBA (1<< 8) /* 32-bit rgba packed */
-#define XVID4_CSP_BGR (1<< 9) /* 24-bit bgr packed */
-#define XVID4_CSP_RGB555 (1<<10) /* 16-bit rgb555 packed */
-#define XVID4_CSP_RGB565 (1<<11) /* 16-bit rgb565 packed */
-#define XVID4_CSP_SLICE (1<<12) /* decoder only: 4:2:0 planar, per slice rendering */
-#define XVID4_CSP_INTERNAL (1<<13) /* decoder only: 4:2:0 planar, returns ptrs to internal buffers */
-#define XVID4_CSP_NULL (1<<14) /* decoder only: dont output anything */
-#define XVID4_CSP_VFLIP (1<<31) /* vertical flip mask */
-
-static __inline uint64_t csp_xvid4_2ffdshow(int csp)
-{
- switch (csp) {
- case XVID4_CSP_BGR :
- return FF_CSP_RGB24;
- case XVID4_CSP_YV12 :
- return FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ;
- case XVID4_CSP_YUY2 :
- return FF_CSP_YUY2;
- case XVID4_CSP_UYVY :
- return FF_CSP_UYVY;
- case XVID4_CSP_I420 :
- return FF_CSP_420P | FF_CSP_FLAGS_YUV_ADJ | FF_CSP_FLAGS_YUV_ORDER;
- case XVID4_CSP_RGB555:
- return FF_CSP_RGB15;
- case XVID4_CSP_RGB565:
- return FF_CSP_RGB16;
- case XVID4_CSP_PLANAR:
- return FF_CSP_420P;
- case XVID4_CSP_YVYU :
- return FF_CSP_YVYU;
- case XVID4_CSP_BGRA :
- return FF_CSP_RGB32;
- case XVID4_CSP_ABGR :
- return FF_CSP_ABGR;
- case XVID4_CSP_RGBA :
- return FF_CSP_RGBA;
- default :
- return FF_CSP_NULL;
- }
-}
-
-//================================= ffmpeg ===================================
-static __inline uint64_t csp_lavc2ffdshow(enum PixelFormat pix_fmt)
-{
- switch (pix_fmt) {
- case PIX_FMT_YUV420P :
- case PIX_FMT_YUVJ420P:
- return FF_CSP_420P;
- case PIX_FMT_YUV422P :
- case PIX_FMT_YUVJ422P:
- return FF_CSP_422P;
- case PIX_FMT_YUV444P :
- case PIX_FMT_YUVJ444P:
- return FF_CSP_444P;
- case PIX_FMT_YUV411P :
- return FF_CSP_411P;
- case PIX_FMT_YUV410P :
- return FF_CSP_410P;
- case PIX_FMT_YUYV422 :
- return FF_CSP_YUY2;
- case PIX_FMT_UYVY422 :
- return FF_CSP_UYVY;
- case PIX_FMT_YUV420P10:
- return FF_CSP_420P10;
- case PIX_FMT_YUV422P10:
- return FF_CSP_422P10;
- case PIX_FMT_YUV444P10:
- return FF_CSP_444P10;
- case PIX_FMT_BGR24 :
- return FF_CSP_RGB24;
- case PIX_FMT_RGB24 :
- return FF_CSP_BGR24;
- case PIX_FMT_RGB32 :
- case PIX_FMT_ARGB:
- return FF_CSP_RGB32;
- case PIX_FMT_RGB555 :
- return FF_CSP_RGB15;
- case PIX_FMT_RGB565 :
- return FF_CSP_RGB16;
- case PIX_FMT_GRAY8 :
- return FF_CSP_Y800;
- case PIX_FMT_PAL8 :
- return FF_CSP_PAL8;
- case PIX_FMT_NV12 :
- return FF_CSP_NV12;
- case PIX_FMT_GBRP :
- return FF_CSP_GBRP;
- case PIX_FMT_GBRP9 :
- return FF_CSP_GBRP9;
- case PIX_FMT_GBRP10 :
- return FF_CSP_GBRP10;
- case PIX_FMT_YUV420P9:
- return FF_CSP_420P9;
- case PIX_FMT_YUV422P9:
- return FF_CSP_422P9;
- case PIX_FMT_YUV444P9:
- return FF_CSP_444P9;
- default :
- return FF_CSP_NULL;
- }
-}
-static __inline enum PixelFormat csp_ffdshow2lavc(uint64_t pix_fmt)
-{
- switch (pix_fmt & FF_CSPS_MASK) {
- case FF_CSP_420P:
- return pix_fmt & FF_CSP_FLAGS_YUV_JPEG ? PIX_FMT_YUVJ420P : PIX_FMT_YUV420P;
- case FF_CSP_422P:
- return pix_fmt & FF_CSP_FLAGS_YUV_JPEG ? PIX_FMT_YUVJ422P : PIX_FMT_YUV422P;
- case FF_CSP_444P:
- return pix_fmt & FF_CSP_FLAGS_YUV_JPEG ? PIX_FMT_YUVJ444P : PIX_FMT_YUV444P;
- case FF_CSP_411P:
- return PIX_FMT_YUV411P;
- case FF_CSP_410P:
- return PIX_FMT_YUV410P;
- case FF_CSP_YUY2:
- return PIX_FMT_YUYV422;
- case FF_CSP_UYVY:
- return PIX_FMT_UYVY422;
- case FF_CSP_420P10:
- return PIX_FMT_YUV420P10;
- case FF_CSP_422P10:
- return PIX_FMT_YUV422P10;
- case FF_CSP_444P10:
- return PIX_FMT_YUV444P10;
- case FF_CSP_RGB24:
- return PIX_FMT_BGR24;
- case FF_CSP_BGR24:
- return PIX_FMT_RGB24;
- case FF_CSP_RGB32:
- return PIX_FMT_RGB32;
- case FF_CSP_BGR32:
- return PIX_FMT_BGR32;
- case FF_CSP_RGB15:
- return PIX_FMT_RGB555;
- case FF_CSP_RGB16:
- return PIX_FMT_RGB565;
- case FF_CSP_Y800:
- return PIX_FMT_GRAY8;
- case FF_CSP_PAL8:
- return PIX_FMT_PAL8;
- case FF_CSP_NV12:
- return PIX_FMT_NV12;
- case FF_CSP_ABGR:
- return PIX_FMT_ABGR;
- case FF_CSP_RGBA:
- return PIX_FMT_RGBA;
- case FF_CSP_GBRP:
- return PIX_FMT_GBRP;
- case FF_CSP_GBRP9:
- return PIX_FMT_GBRP9;
- case FF_CSP_GBRP10:
- return PIX_FMT_GBRP10;
- case FF_CSP_420P9:
- return PIX_FMT_YUV420P9;
- case FF_CSP_422P9:
- return PIX_FMT_YUV422P9;
- case FF_CSP_444P9:
- return PIX_FMT_YUV444P9;
- default :
- return PIX_FMT_NB;
- }
-}
-
-#define SWS_IN_CSPS \
- ( \
- FF_CSP_420P| \
- FF_CSP_444P| \
- FF_CSP_422P| \
- FF_CSP_411P| \
- FF_CSP_410P| \
- FF_CSP_YUY2| \
- FF_CSP_UYVY| \
- FF_CSP_YVYU| \
- FF_CSP_VYUY| \
- FF_CSP_BGR32| \
- FF_CSP_BGR24| \
- FF_CSP_BGR16| \
- FF_CSP_BGR15| \
- FF_CSP_RGB32| \
- FF_CSP_RGB24| \
- FF_CSP_RGB16| \
- FF_CSP_RGB15| \
- FF_CSP_NV12| \
- FF_CSP_420P10| \
- FF_CSP_422P10| \
- FF_CSP_444P10| \
- FF_CSP_420P9| \
- FF_CSP_422P9| \
- FF_CSP_444P9| \
- FF_CSP_Y800 \
- )
-#define SWS_OUT_CSPS \
- ( \
- FF_CSP_420P| \
- FF_CSP_444P| \
- FF_CSP_422P| \
- FF_CSP_411P| \
- FF_CSP_410P| \
- FF_CSP_YUY2| \
- FF_CSP_UYVY| \
- FF_CSP_YVYU| \
- FF_CSP_VYUY| \
- FF_CSP_RGB32| \
- FF_CSP_RGB24| \
- FF_CSP_RGB16| \
- FF_CSP_RGB15| \
- FF_CSP_BGR32| \
- FF_CSP_BGR24| \
- FF_CSP_BGR16| \
- FF_CSP_BGR15| \
- FF_CSP_NV12| \
- FF_CSP_420P10| \
- FF_CSP_422P10| \
- FF_CSP_444P10| \
- FF_CSP_420P9| \
- FF_CSP_422P9| \
- FF_CSP_444P9| \
- FF_CSP_Y800 \
- )
-
-static __inline uint64_t csp_supSWSin(uint64_t x)
-{
- return (x & FF_CSPS_MASK) & (SWS_IN_CSPS | FF_CSPS_MASK_HIGH_BIT);
-}
-static __inline uint64_t csp_supSWSout(uint64_t x)
-{
- return (x & FF_CSPS_MASK) & (SWS_OUT_CSPS | FF_CSPS_MASK_HIGH_BIT);
-}
-
-#endif
-
-#if defined(__cplusplus) && !defined(FF_CSP_ONLY)
-
-#ifndef _FFIMGFMTCPP_H_
-#define _FFIMGFMTCPP_H_
-
-#include "array_allocator.h"
-#include "char_t.h"
-
-struct TcspInfo {
- uint64_t id;
- const char_t *name;
- int Bpp; // Bytes per pixel for each plane.
- int bpp; // bits per pixel for all plane. (Memory usage, not the effective bit depth)
- unsigned int numPlanes;
- unsigned int shiftX[4], shiftY[4];
- unsigned int black[4];
- FOURCC fcc, fcccsp;
- const GUID *subtype;
- int packedLumaOffset, packedChromaOffset;
-};
-extern const TcspInfo cspInfos[];
-struct TcspInfos : std::vector<const TcspInfo*, array_allocator<const TcspInfo*, FF_CSPS_NUM*2> > {
-private:
- struct TsortFc {
- private:
- uint64_t csp, outPrimaryCSP;
- public:
- TsortFc(uint64_t Icsp, uint64_t IoutPrimaryCSP): csp(Icsp), outPrimaryCSP(IoutPrimaryCSP) {}
- bool operator()(const TcspInfo* &csp1, const TcspInfo* &csp2);
- };
-public:
- void sort(uint64_t csp, uint64_t outPrimaryCSP);
-};
-
-static __inline const TcspInfo* csp_getInfo(uint64_t csp)
-{
- switch (csp & (FF_CSPS_MASK | FF_CSP_FLAGS_YUV_ORDER)) {
- case FF_CSP_420P|FF_CSP_FLAGS_YUV_ORDER: {
- extern TcspInfo cspInfoIYUV;
- return &cspInfoIYUV;
- }
- default:
- csp &= FF_CSPS_MASK;
- if (csp == 0) {
- return NULL;
- }
- int i = 0;
- while (csp >>= 1) {
- i++;
- }
- if (i <= FF_CSPS_NUM) {
- return &cspInfos[i];
- } else {
- return NULL;
- }
- }
-}
-const TcspInfo* csp_getInfoFcc(FOURCC fcc);
-
-static __inline uint64_t csp_isYUVplanar(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_YUV_PLANAR;
-}
-static __inline uint64_t csp_isRGBplanar(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_RGB_PLANAR;
-}
-static __inline uint64_t csp_isYUVplanarHighBit(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_HIGH_BIT;
-}
-static __inline uint64_t csp_isYUVpacked(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_YUV_PACKED;
-}
-static __inline uint64_t csp_isYUV(uint64_t x)
-{
- return csp_isYUVpacked(x) | csp_isYUVplanar(x);
-}
-static __inline uint64_t csp_isYUV_NV(uint64_t x)
-{
- return csp_isYUVpacked(x) | csp_isYUVplanar(x) | (x & (FF_CSP_NV12 | FF_CSP_P016 | FF_CSP_P010 | FF_CSP_P210 | FF_CSP_P216));
-}
-static __inline uint64_t csp_isRGB_RGB(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_RGB;
-}
-static __inline uint64_t csp_isRGB_BGR(uint64_t x)
-{
- return x & FF_CSPS_MASK & FF_CSPS_MASK_BGR;
-}
-static __inline uint64_t csp_isRGB(uint64_t x)
-{
- return csp_isRGB_RGB(x) | csp_isRGB_BGR(x);
-}
-static __inline uint64_t csp_supXvid(uint64_t x)
-{
- return (x & FF_CSPS_MASK) & (FF_CSP_RGB24 | FF_CSP_420P | FF_CSP_YUY2 | FF_CSP_UYVY | FF_CSP_YVYU | FF_CSP_VYUY | FF_CSP_RGB15 | FF_CSP_RGB16 | FF_CSP_RGB32 | FF_CSP_ABGR | FF_CSP_RGBA | FF_CSP_BGR24);
-}
-
-bool csp_inFOURCCmask(uint64_t x, FOURCC fcc);
-
-extern char_t* csp_getName2(const TcspInfo *cspInfo, uint64_t csp, char_t *buf, size_t len);
-extern char_t* csp_getName(uint64_t csp, char_t *buf, size_t len);
-extern uint64_t csp_bestMatch(uint64_t inCSP, uint64_t wantedCSPS, int *rank = NULL, uint64_t outPrimaryCSP = 0);
-
-static __inline void csp_yuv_adj_to_plane(uint64_t &csp, const TcspInfo *cspInfo, unsigned int dy, unsigned char *data[4], stride_t stride[4])
-{
- if (csp_isYUVplanar(csp) && (csp & FF_CSP_FLAGS_YUV_ADJ)) {
- csp &= ~FF_CSP_FLAGS_YUV_ADJ;
- data[2] = data[0] + stride[0] * (dy >> cspInfo->shiftY[0]);
- stride[1] = stride[0] >> cspInfo->shiftX[1];
- data[1] = data[2] + stride[1] * (dy >> cspInfo->shiftY[1]);
- stride[2] = stride[0] >> cspInfo->shiftX[2];
- } else if ((csp & (FF_CSP_NV12 | FF_CSP_P016 | FF_CSP_P010 | FF_CSP_P210 | FF_CSP_P216)) && (csp & FF_CSP_FLAGS_YUV_ADJ)) {
- csp &= ~FF_CSP_FLAGS_YUV_ADJ;
- data[1] = data[0] + stride[0] * dy;
- stride[1] = stride[0];
- }
-
-}
-static __inline void csp_yuv_order(uint64_t &csp, unsigned char *data[4], stride_t stride[4])
-{
- if (csp_isYUVplanar(csp) && (csp & FF_CSP_FLAGS_YUV_ORDER)) {
- csp &= ~FF_CSP_FLAGS_YUV_ORDER;
- std::swap(data[1], data[2]);
- std::swap(stride[1], stride[2]);
- }
-}
-static __inline void csp_vflip(uint64_t &csp, const TcspInfo *cspInfo, unsigned char *data[], stride_t stride[], unsigned int dy)
-{
- if (csp & FF_CSP_FLAGS_VFLIP) {
- csp &= ~FF_CSP_FLAGS_VFLIP;
- for (unsigned int i = 0; i < cspInfo->numPlanes; i++) {
- data[i] += stride[i] * ((dy >> cspInfo->shiftY[i]) - 1);
- stride[i] *= -1;
- }
- }
-}
-
-uint64_t getBMPcolorspace(const BITMAPINFOHEADER *hdr, const TcspInfos &forcedCsps);
-
-struct TcspFcc {
- const char_t *name;
- FOURCC fcc;
- uint64_t csp;
- bool flip;
- bool supEnc;
-};
-extern const TcspFcc cspFccs[];
-
-#endif
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/resource.h b/src/filters/transform/MPCVideoDec/resource.h
deleted file mode 100644
index 5367e2a85..000000000
--- a/src/filters/transform/MPCVideoDec/resource.h
+++ /dev/null
@@ -1,40 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Visual C++ generated include file.
-// Used by MPCVideoDecFilter.rc
-//
-#define IDS_FILTER_SETTINGS_CAPTION 7000
-#define IDS_VDF_FFSETTINGS 7400
-#define IDS_VDF_AUTO 7401
-#define IDS_VDF_THREADNUMBER 7402
-#define IDS_VDF_SKIPDEBLOCK 7403
-#define IDS_VDF_DBLK_NONE 7404
-#define IDS_VDF_DBLK_DEFAULT 7405
-#define IDS_VDF_DBLK_NONREF 7406
-#define IDS_VDF_DBLK_BIDIR 7407
-#define IDS_VDF_DBLK_NONKFRM 7408
-#define IDS_VDF_DBLK_ALL 7409
-#define IDS_VDF_AR_MODE 7410
-#define IDS_VDF_INTERLACED_FLAG 7411
-#define IDS_VDF_IF_PROGRESSIVE 7412
-#define IDS_VDF_IF_TOP_FIELD_FIRST 7413
-#define IDS_VDF_IF_BOTTOM_FIELD_FIRST 7414
-#define IDS_VDF_DXVA_SETTING 7415
-#define IDS_VDF_DXVACOMPATIBILITY 7416
-#define IDS_VDF_DXVA_FULLCHECK 7417
-#define IDS_VDF_DXVA_SKIP_LEVELCHECK 7418
-#define IDS_VDF_DXVA_SKIP_REFCHECK 7419
-#define IDS_VDF_DXVA_SKIP_ALLCHECK 7420
-#define IDS_VDF_DXVA_SD 7421
-#define IDS_VDF_VIDEOCARD 7422
-#define IDS_VDF_DXVA_MODE 7423
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 103
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/src/filters/transform/MPCVideoDec/stdafx.cpp b/src/filters/transform/MPCVideoDec/stdafx.cpp
deleted file mode 100644
index 85320ac36..000000000
--- a/src/filters/transform/MPCVideoDec/stdafx.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * (C) 2006-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#include "stdafx.h"
-
-//#define DXVA_LOGFILE_B
-
-#if defined(_DEBUG) && defined(DXVA_LOGFILE_B)
-
-#define LOG_FILE _T("dxva.log")
-
-void LOG(LPCTSTR fmt, ...)
-{
- va_list args;
- va_start(args, fmt);
- if (TCHAR* buff = DEBUG_NEW TCHAR[_vsctprintf(fmt, args) + 1]) {
- _vstprintf(buff, fmt, args);
- if (FILE* f = _tfopen(LOG_FILE, _T("at"))) {
- fseek(f, 0, 2);
- _ftprintf_s(f, _T("%s\n"), buff);
- fclose(f);
- }
- delete [] buff;
- }
- va_end(args);
-}
-
-#endif
diff --git a/src/filters/transform/MPCVideoDec/stdafx.h b/src/filters/transform/MPCVideoDec/stdafx.h
deleted file mode 100644
index 6b62890ae..000000000
--- a/src/filters/transform/MPCVideoDec/stdafx.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * (C) 2007-2012 see Authors.txt
- *
- * This file is part of MPC-HC.
- *
- * MPC-HC 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 3 of the License, or
- * (at your option) any later version.
- *
- * MPC-HC 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-#include "../../../DSUtil/SharedInclude.h"
-#include "../../../../include/stdafx_common.h"
-#include "../../../../include/stdafx_common_afx.h"
-#include "../../../../include/stdafx_common_dshow.h"
-
-#include <d3dx9.h>
-#include <evr.h>
-#include <atlcoll.h>
-
-#pragma warning(disable: 4005)
-/* this shouldn't be here but due to stdint.h/inttypes.h
-being included from various ffmpeg headers we get redefitions */
-
-#if defined(_DEBUG) && defined(DXVA_LOGFILE_B)
-void LOG(LPCTSTR fmt, ...);
-#else
-inline void LOG(LPCTSTR fmt, ...) {}
-#endif