mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-31 18:11:54 +08:00
init
This commit is contained in:
72
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/abstract_splitter.h
vendored
Normal file
72
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/abstract_splitter.h
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef _ABSTRACT_SPL_H__
|
||||
#define _ABSTRACT_SPL_H__
|
||||
|
||||
#include "mfxstructures.h"
|
||||
#include "vm/strings_defs.h"
|
||||
|
||||
enum SliceTypeCode {
|
||||
TYPE_I = 0,
|
||||
TYPE_P = 1,
|
||||
TYPE_B = 2,
|
||||
TYPE_SKIP=3,
|
||||
TYPE_UNKNOWN=4
|
||||
};
|
||||
|
||||
struct SliceSplitterInfo
|
||||
{
|
||||
mfxU32 DataOffset;
|
||||
mfxU32 DataLength;
|
||||
mfxU32 HeaderLength;
|
||||
SliceTypeCode SliceType;
|
||||
};
|
||||
|
||||
struct FrameSplitterInfo
|
||||
{
|
||||
SliceSplitterInfo * Slice; // array
|
||||
mfxU32 SliceNum;
|
||||
mfxU32 FirstFieldSliceNum;
|
||||
|
||||
mfxU8 * Data; // including data of slices
|
||||
mfxU32 DataLength;
|
||||
mfxU64 TimeStamp;
|
||||
};
|
||||
|
||||
class AbstractSplitter
|
||||
{
|
||||
public:
|
||||
|
||||
AbstractSplitter()
|
||||
{}
|
||||
|
||||
virtual ~AbstractSplitter()
|
||||
{}
|
||||
|
||||
virtual mfxStatus Reset() = 0;
|
||||
|
||||
virtual mfxStatus GetFrame(mfxBitstream * bs_in, FrameSplitterInfo ** frame) = 0;
|
||||
|
||||
virtual mfxStatus PostProcessing(FrameSplitterInfo *frame, mfxU32 sliceNum) = 0;
|
||||
|
||||
virtual void ResetCurrentState() = 0;
|
||||
};
|
||||
|
||||
#endif // _ABSTRACT_SPL_H__
|
||||
232
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_bitstream.h
vendored
Normal file
232
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_bitstream.h
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
#ifndef __AVC_BITSTREAM_H_
|
||||
#define __AVC_BITSTREAM_H_
|
||||
|
||||
#include "mfxstructures.h"
|
||||
#include "avc_structures.h"
|
||||
#include "avc_headers.h"
|
||||
|
||||
namespace ProtectedLibrary
|
||||
{
|
||||
|
||||
#define AVCPeek1Bit(current_data, offset) \
|
||||
((current_data[0] >> (offset)) & 1)
|
||||
|
||||
#define AVCDrop1Bit(current_data, offset) \
|
||||
{ \
|
||||
offset -= 1; \
|
||||
if (offset < 0) \
|
||||
{ \
|
||||
offset = 31; \
|
||||
current_data += 1; \
|
||||
} \
|
||||
}
|
||||
|
||||
// NAL unit definitions
|
||||
enum
|
||||
{
|
||||
NAL_STORAGE_IDC_BITS = 0x60,
|
||||
NAL_UNITTYPE_BITS = 0x1f
|
||||
};
|
||||
|
||||
class AVCBaseBitstream
|
||||
{
|
||||
public:
|
||||
|
||||
AVCBaseBitstream();
|
||||
AVCBaseBitstream(mfxU8 * const pb, const mfxU32 maxsize);
|
||||
virtual ~AVCBaseBitstream();
|
||||
|
||||
// Reset the bitstream with new data pointer
|
||||
void Reset(mfxU8 * const pb, mfxU32 maxsize);
|
||||
void Reset(mfxU8 * const pb, mfxI32 offset, mfxU32 maxsize);
|
||||
|
||||
inline mfxU32 GetBits(mfxU32 nbits);
|
||||
|
||||
// Read one VLC mfxI32 or mfxU32 value from bitstream
|
||||
mfxI32 GetVLCElement(bool bIsSigned);
|
||||
|
||||
// Reads one bit from the buffer.
|
||||
inline mfxU32 Get1Bit();
|
||||
|
||||
// Check amount of data
|
||||
bool More_RBSP_Data();
|
||||
|
||||
inline mfxU32 BytesDecoded();
|
||||
|
||||
inline mfxU32 BitsDecoded();
|
||||
|
||||
inline mfxU32 BytesLeft();
|
||||
|
||||
mfxStatus GetNALUnitType(NAL_Unit_Type &uNALUnitType, mfxU8 &uNALStorageIDC);
|
||||
void AlignPointerRight(void);
|
||||
|
||||
protected:
|
||||
mfxU32 *m_pbs; // pointer to the current position of the buffer.
|
||||
mfxI32 m_bitOffset; // the bit position (0 to 31) in the dword pointed by m_pbs.
|
||||
mfxU32 *m_pbsBase; // pointer to the first byte of the buffer.
|
||||
mfxU32 m_maxBsSize; // maximum buffer size in bytes.
|
||||
};
|
||||
|
||||
class AVCHeadersBitstream : public AVCBaseBitstream
|
||||
{
|
||||
public:
|
||||
|
||||
AVCHeadersBitstream();
|
||||
AVCHeadersBitstream(mfxU8 * const pb, const mfxU32 maxsize);
|
||||
|
||||
|
||||
// Decode sequence parameter set
|
||||
mfxStatus GetSequenceParamSet(AVCSeqParamSet *sps);
|
||||
// Decode sequence parameter set extension
|
||||
mfxStatus GetSequenceParamSetExtension(AVCSeqParamSetExtension *sps_ex);
|
||||
|
||||
// Decoding picture's parameter set functions
|
||||
mfxStatus GetPictureParamSetPart1(AVCPicParamSet *pps);
|
||||
mfxStatus GetPictureParamSetPart2(AVCPicParamSet *pps, const AVCSeqParamSet *sps);
|
||||
|
||||
mfxStatus GetSliceHeaderPart1(AVCSliceHeader *pSliceHeader);
|
||||
// Decoding slice header functions
|
||||
mfxStatus GetSliceHeaderPart2(AVCSliceHeader *hdr, // slice header read goes here
|
||||
const AVCPicParamSet *pps,
|
||||
const AVCSeqParamSet *sps); // from slice header NAL unit
|
||||
|
||||
mfxStatus GetSliceHeaderPart3(AVCSliceHeader *hdr, // slice header read goes here
|
||||
PredWeightTable *pPredWeight_L0, // L0 weight table goes here
|
||||
PredWeightTable *pPredWeight_L1, // L1 weight table goes here
|
||||
RefPicListReorderInfo *pReorderInfo_L0,
|
||||
RefPicListReorderInfo *pReorderInfo_L1,
|
||||
AdaptiveMarkingInfo *pAdaptiveMarkingInfo,
|
||||
const AVCPicParamSet *pps,
|
||||
const AVCSeqParamSet *sps,
|
||||
mfxU8 NALRef_idc); // from slice header NAL unit
|
||||
|
||||
|
||||
mfxStatus GetNalUnitPrefix(AVCNalExtension *pExt, mfxU32 NALRef_idc);
|
||||
|
||||
mfxI32 GetSEI(const HeaderSet<AVCSeqParamSet> & sps, mfxI32 current_sps, AVCSEIPayLoad *spl);
|
||||
|
||||
private:
|
||||
|
||||
mfxStatus GetNalUnitExtension(AVCNalExtension *pExt);
|
||||
|
||||
void GetScalingList4x4(AVCScalingList4x4 *scl, mfxU8 *def, mfxU8 *scl_type);
|
||||
void GetScalingList8x8(AVCScalingList8x8 *scl, mfxU8 *def, mfxU8 *scl_type);
|
||||
|
||||
mfxI32 GetSEIPayload(const HeaderSet<AVCSeqParamSet> & sps, mfxI32 current_sps, AVCSEIPayLoad *spl);
|
||||
mfxI32 recovery_point(const HeaderSet<AVCSeqParamSet> & sps, mfxI32 current_sps, AVCSEIPayLoad *spl);
|
||||
mfxI32 reserved_sei_message(const HeaderSet<AVCSeqParamSet> & sps, mfxI32 current_sps, AVCSEIPayLoad *spl);
|
||||
|
||||
mfxStatus GetVUIParam(AVCSeqParamSet *sps);
|
||||
mfxStatus GetHRDParam(AVCSeqParamSet *sps);
|
||||
};
|
||||
|
||||
|
||||
void SetDefaultScalingLists(AVCSeqParamSet * sps);
|
||||
|
||||
extern const mfxU32 bits_data[];
|
||||
|
||||
|
||||
#define _avcGetBits(current_data, offset, nbits, data) \
|
||||
{ \
|
||||
mfxU32 x; \
|
||||
\
|
||||
SAMPLE_ASSERT((nbits) > 0 && (nbits) <= 32); \
|
||||
SAMPLE_ASSERT(offset >= 0 && offset <= 31); \
|
||||
\
|
||||
offset -= (nbits); \
|
||||
\
|
||||
if (offset >= 0) \
|
||||
{ \
|
||||
x = current_data[0] >> (offset + 1); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
offset += 32; \
|
||||
\
|
||||
x = current_data[1] >> (offset); \
|
||||
x >>= 1; \
|
||||
x += current_data[0] << (31 - offset); \
|
||||
current_data++; \
|
||||
} \
|
||||
\
|
||||
SAMPLE_ASSERT(offset >= 0 && offset <= 31); \
|
||||
\
|
||||
(data) = x & bits_data[nbits]; \
|
||||
}
|
||||
|
||||
#define avcGetBits1(current_data, offset, data) \
|
||||
{ \
|
||||
data = ((current_data[0] >> (offset)) & 1); \
|
||||
offset -= 1; \
|
||||
if (offset < 0) \
|
||||
{ \
|
||||
offset = 31; \
|
||||
current_data += 1; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define avcUngetNBits(current_data, offset, nbits) \
|
||||
{ \
|
||||
SAMPLE_ASSERT(offset >= 0 && offset <= 31); \
|
||||
\
|
||||
offset += (nbits); \
|
||||
if (offset > 31) \
|
||||
{ \
|
||||
offset -= 32; \
|
||||
current_data--; \
|
||||
} \
|
||||
\
|
||||
SAMPLE_ASSERT(offset >= 0 && offset <= 31); \
|
||||
}
|
||||
|
||||
#define avcGetNBits( current_data, offset, nbits, data) \
|
||||
_avcGetBits(current_data, offset, nbits, data);
|
||||
|
||||
inline mfxU32 AVCBaseBitstream::GetBits(mfxU32 nbits)
|
||||
{
|
||||
mfxU32 w, n = nbits;
|
||||
|
||||
avcGetNBits(m_pbs, m_bitOffset, n, w);
|
||||
return w;
|
||||
}
|
||||
|
||||
inline mfxU32 AVCBaseBitstream::Get1Bit()
|
||||
{
|
||||
mfxU32 w;
|
||||
avcGetBits1(m_pbs, m_bitOffset, w);
|
||||
return w;
|
||||
|
||||
} // AVCBitstream::Get1Bit()
|
||||
|
||||
inline mfxU32 AVCBaseBitstream::BytesDecoded()
|
||||
{
|
||||
return static_cast<mfxU32>((mfxU8*)m_pbs - (mfxU8*)m_pbsBase) +
|
||||
((31 - m_bitOffset) >> 3);
|
||||
}
|
||||
|
||||
inline mfxU32 AVCBaseBitstream::BytesLeft()
|
||||
{
|
||||
return ((mfxI32)m_maxBsSize - (mfxI32) BytesDecoded());
|
||||
}
|
||||
|
||||
} // namespace ProtectedLibrary
|
||||
|
||||
#endif // __AVC_BITSTREAM_H_
|
||||
157
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_headers.h
vendored
Normal file
157
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_headers.h
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __AVC_HEADERS_H
|
||||
#define __AVC_HEADERS_H
|
||||
|
||||
#include "avc_structures.h"
|
||||
#include <vector>
|
||||
|
||||
namespace ProtectedLibrary
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
class HeaderSet
|
||||
{
|
||||
public:
|
||||
|
||||
HeaderSet()
|
||||
: m_currentID(-1)
|
||||
{
|
||||
}
|
||||
|
||||
~HeaderSet()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
void AddHeader(T* hdr)
|
||||
{
|
||||
mfxU32 id = hdr->GetID();
|
||||
if (id >= m_header.size())
|
||||
{
|
||||
m_header.resize(id + 1);
|
||||
}
|
||||
|
||||
delete m_header[id];
|
||||
|
||||
m_header[id] = new T();
|
||||
*(m_header[id]) = *hdr;
|
||||
}
|
||||
|
||||
T * GetHeader(mfxU32 id)
|
||||
{
|
||||
if (id >= m_header.size())
|
||||
return 0;
|
||||
|
||||
return m_header[id];
|
||||
}
|
||||
|
||||
void RemoveHeader(mfxU32 id)
|
||||
{
|
||||
if (id >= m_header.size())
|
||||
return;
|
||||
|
||||
delete m_header[id];
|
||||
m_header[id] = 0;
|
||||
}
|
||||
|
||||
void RemoveHeader(T * hdr)
|
||||
{
|
||||
if (!hdr)
|
||||
return;
|
||||
|
||||
RemoveHeader(hdr->GetID());
|
||||
}
|
||||
|
||||
const T * GetHeader(mfxU32 id) const
|
||||
{
|
||||
if (id >= m_header.size())
|
||||
return 0;
|
||||
|
||||
return m_header[id];
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
for (mfxU32 i = 0; i < m_header.size(); i++)
|
||||
{
|
||||
delete m_header[i];
|
||||
m_header[i]=0;
|
||||
}
|
||||
}
|
||||
|
||||
void SetCurrentID(mfxU32 id)
|
||||
{
|
||||
m_currentID = id;
|
||||
}
|
||||
|
||||
mfxI32 GetCurrrentID() const
|
||||
{
|
||||
return m_currentID;
|
||||
}
|
||||
|
||||
T * GetCurrentHeader()
|
||||
{
|
||||
if (m_currentID == -1)
|
||||
return 0;
|
||||
|
||||
return GetHeader(m_currentID);
|
||||
}
|
||||
|
||||
const T * GetCurrentHeader() const
|
||||
{
|
||||
if (m_currentID == -1)
|
||||
return 0;
|
||||
|
||||
return GetHeader(m_currentID);
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<T*> m_header;
|
||||
mfxI32 m_currentID;
|
||||
};
|
||||
|
||||
/****************************************************************************************************/
|
||||
// Headers stuff
|
||||
/****************************************************************************************************/
|
||||
class AVCHeaders
|
||||
{
|
||||
public:
|
||||
|
||||
void Reset()
|
||||
{
|
||||
m_SeqParams.Reset();
|
||||
m_SeqExParams.Reset();
|
||||
m_SeqParamsMvcExt.Reset();
|
||||
m_PicParams.Reset();
|
||||
m_SEIParams.Reset();
|
||||
}
|
||||
|
||||
HeaderSet<AVCSeqParamSet> m_SeqParams;
|
||||
HeaderSet<AVCSeqParamSetExtension> m_SeqExParams;
|
||||
HeaderSet<AVCSeqParamSet> m_SeqParamsMvcExt;
|
||||
HeaderSet<AVCPicParamSet> m_PicParams;
|
||||
HeaderSet<AVCSEIPayLoad> m_SEIParams;
|
||||
AVCNalExtension m_nalExtension;
|
||||
};
|
||||
|
||||
} //namespace ProtectedLibrary
|
||||
|
||||
#endif // __AVC_HEADERS_H
|
||||
101
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_nal_spl.h
vendored
Normal file
101
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_nal_spl.h
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
#ifndef __AVC_NAL_SPL_H
|
||||
#define __AVC_NAL_SPL_H
|
||||
|
||||
#include <vector>
|
||||
#include "mfxstructures.h"
|
||||
|
||||
namespace ProtectedLibrary
|
||||
{
|
||||
|
||||
class BytesSwapper
|
||||
{
|
||||
public:
|
||||
static void SwapMemory(mfxU8 *pDestination, mfxU32 &nDstSize, mfxU8 *pSource, mfxU32 nSrcSize);
|
||||
};
|
||||
|
||||
|
||||
class StartCodeIterator
|
||||
{
|
||||
public:
|
||||
|
||||
StartCodeIterator();
|
||||
|
||||
void Reset();
|
||||
|
||||
mfxI32 Init(mfxBitstream * source);
|
||||
|
||||
void SetSuggestedSize(mfxU32 size);
|
||||
|
||||
mfxI32 CheckNalUnitType(mfxBitstream * source);
|
||||
|
||||
mfxI32 GetNALUnit(mfxBitstream * source, mfxBitstream * destination);
|
||||
|
||||
mfxI32 EndOfStream(mfxBitstream * destination);
|
||||
|
||||
private:
|
||||
std::vector<mfxU8> m_prev;
|
||||
mfxU32 m_code;
|
||||
mfxU64 m_pts;
|
||||
|
||||
mfxU8 * m_pSource;
|
||||
mfxU32 m_nSourceSize;
|
||||
|
||||
mfxU8 * m_pSourceBase;
|
||||
mfxU32 m_nSourceBaseSize;
|
||||
|
||||
mfxU32 m_suggestedSize;
|
||||
|
||||
mfxI32 FindStartCode(mfxU8 * (&pb), mfxU32 & size, mfxI32 & startCodeSize);
|
||||
};
|
||||
|
||||
class NALUnitSplitter
|
||||
{
|
||||
public:
|
||||
|
||||
NALUnitSplitter();
|
||||
|
||||
virtual ~NALUnitSplitter();
|
||||
|
||||
virtual void Init();
|
||||
virtual void Release();
|
||||
|
||||
virtual mfxI32 CheckNalUnitType(mfxBitstream * source);
|
||||
virtual mfxI32 GetNalUnits(mfxBitstream * source, mfxBitstream * &destination);
|
||||
|
||||
virtual void Reset();
|
||||
|
||||
virtual void SetSuggestedSize(mfxU32 size)
|
||||
{
|
||||
m_pStartCodeIter.SetSuggestedSize(size);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
StartCodeIterator m_pStartCodeIter;
|
||||
|
||||
mfxBitstream m_bitstream;
|
||||
};
|
||||
|
||||
void SwapMemoryAndRemovePreventingBytes(mfxU8 *pDestination, mfxU32 &nDstSize, mfxU8 *pSource, mfxU32 nSrcSize);
|
||||
|
||||
} //namespace ProtectedLibrary
|
||||
|
||||
#endif // __AVC_NAL_SPL_H
|
||||
140
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_spl.h
vendored
Normal file
140
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_spl.h
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef _AVC_SPL_H__
|
||||
#define _AVC_SPL_H__
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
#include "abstract_splitter.h"
|
||||
|
||||
#include "avc_bitstream.h"
|
||||
#include "avc_headers.h"
|
||||
#include "avc_nal_spl.h"
|
||||
|
||||
namespace ProtectedLibrary
|
||||
{
|
||||
|
||||
class AVCSlice : public SliceSplitterInfo
|
||||
{
|
||||
public:
|
||||
|
||||
AVCSlice();
|
||||
|
||||
AVCSliceHeader * GetSliceHeader();
|
||||
|
||||
bool IsField() const {return m_sliceHeader.field_pic_flag != 0;}
|
||||
|
||||
mfxI32 RetrievePicParamSetNumber(mfxU8 *pSource, mfxU32 nSourceSize);
|
||||
|
||||
bool DecodeHeader(mfxU8 *pSource, mfxU32 nSourceSize);
|
||||
|
||||
AVCHeadersBitstream *GetBitStream(void){return &m_bitStream;}
|
||||
|
||||
AVCPicParamSet* m_picParamSet;
|
||||
AVCSeqParamSet* m_seqParamSet;
|
||||
AVCSeqParamSet* m_seqParamSetMvcEx;
|
||||
AVCSeqParamSetExtension* m_seqParamSetEx;
|
||||
|
||||
mfxU64 m_dTime;
|
||||
|
||||
protected:
|
||||
AVCSliceHeader m_sliceHeader;
|
||||
AVCHeadersBitstream m_bitStream;
|
||||
|
||||
void Reset();
|
||||
};
|
||||
|
||||
class AVCFrameInfo
|
||||
{
|
||||
public:
|
||||
|
||||
AVCFrameInfo();
|
||||
|
||||
void Reset();
|
||||
|
||||
AVCSlice * m_slice;
|
||||
mfxU32 m_index;
|
||||
};
|
||||
|
||||
class AVC_Spl : public AbstractSplitter
|
||||
{
|
||||
public:
|
||||
|
||||
AVC_Spl();
|
||||
|
||||
virtual ~AVC_Spl();
|
||||
|
||||
virtual mfxStatus Reset();
|
||||
|
||||
virtual mfxStatus GetFrame(mfxBitstream * bs_in, FrameSplitterInfo ** frame);
|
||||
|
||||
virtual mfxStatus PostProcessing(FrameSplitterInfo *frame, mfxU32 sliceNum);
|
||||
|
||||
void ResetCurrentState();
|
||||
|
||||
protected:
|
||||
std::unique_ptr<NALUnitSplitter> m_pNALSplitter;
|
||||
|
||||
mfxStatus Init();
|
||||
|
||||
void Close();
|
||||
|
||||
mfxStatus ProcessNalUnit(mfxI32 nalType, mfxBitstream * destination);
|
||||
|
||||
mfxStatus DecodeHeader(mfxBitstream * nalUnit);
|
||||
mfxStatus DecodeSEI(mfxBitstream * nalUnit);
|
||||
AVCSlice * DecodeSliceHeader(mfxBitstream * nalUnit);
|
||||
mfxStatus AddSlice(AVCSlice * pSlice);
|
||||
|
||||
AVCFrameInfo * GetFreeFrame();
|
||||
|
||||
mfxU8 * GetMemoryForSwapping(mfxU32 size);
|
||||
|
||||
mfxStatus AddNalUnit(mfxBitstream * nalUnit);
|
||||
mfxStatus AddSliceNalUnit(mfxBitstream * nalUnit, AVCSlice * pSlice);
|
||||
bool IsFieldOfOneFrame(AVCFrameInfo * frame, const AVCSliceHeader * slice1, const AVCSliceHeader *slice2);
|
||||
|
||||
bool m_WaitForIDR;
|
||||
|
||||
AVCHeaders m_headers;
|
||||
std::unique_ptr<AVCFrameInfo> m_AUInfo;
|
||||
AVCFrameInfo * m_currentInfo;
|
||||
AVCSlice * m_pLastSlice;
|
||||
|
||||
mfxBitstream * m_lastNalUnit;
|
||||
|
||||
enum
|
||||
{
|
||||
BUFFER_SIZE = 1024 * 1024
|
||||
};
|
||||
|
||||
std::vector<mfxU8> m_currentFrame;
|
||||
std::vector<mfxU8> m_swappingMemory;
|
||||
std::list<AVCSlice> m_slicesStorage;
|
||||
|
||||
std::vector<SliceSplitterInfo> m_slices;
|
||||
FrameSplitterInfo m_frame;
|
||||
};
|
||||
|
||||
} // namespace ProtectedLibrary
|
||||
|
||||
#endif // _AVC_SPL_H__
|
||||
1107
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_structures.h
vendored
Normal file
1107
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/avc_structures.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
201
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/base_allocator.h
vendored
Normal file
201
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/base_allocator.h
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __BASE_ALLOCATOR_H__
|
||||
#define __BASE_ALLOCATOR_H__
|
||||
|
||||
#include <list>
|
||||
#include <string.h>
|
||||
#include <functional>
|
||||
#include "mfxvideo.h"
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
struct mfxAllocatorParams
|
||||
{
|
||||
virtual ~mfxAllocatorParams(){};
|
||||
};
|
||||
|
||||
// this class implements methods declared in mfxFrameAllocator structure
|
||||
// simply redirecting them to virtual methods which should be overridden in derived classes
|
||||
class MFXFrameAllocator : public mfxFrameAllocator
|
||||
{
|
||||
public:
|
||||
MFXFrameAllocator();
|
||||
virtual ~MFXFrameAllocator();
|
||||
|
||||
// optional method, override if need to pass some parameters to allocator from application
|
||||
virtual mfxStatus Init(mfxAllocatorParams *pParams) = 0;
|
||||
virtual mfxStatus Close() = 0;
|
||||
|
||||
virtual mfxStatus AllocFrames(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response) = 0;
|
||||
virtual mfxStatus ReallocFrame(mfxMemId midIn, const mfxFrameInfo *info, mfxU16 memType, mfxMemId *midOut) = 0;
|
||||
virtual mfxStatus LockFrame(mfxMemId mid, mfxFrameData *ptr) = 0;
|
||||
virtual mfxStatus UnlockFrame(mfxMemId mid, mfxFrameData *ptr) = 0;
|
||||
virtual mfxStatus GetFrameHDL(mfxMemId mid, mfxHDL *handle) = 0;
|
||||
virtual mfxStatus FreeFrames(mfxFrameAllocResponse *response) = 0;
|
||||
|
||||
private:
|
||||
static mfxStatus MFX_CDECL Alloc_(mfxHDL pthis, mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);
|
||||
static mfxStatus MFX_CDECL Lock_(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr);
|
||||
static mfxStatus MFX_CDECL Unlock_(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr);
|
||||
static mfxStatus MFX_CDECL GetHDL_(mfxHDL pthis, mfxMemId mid, mfxHDL *handle);
|
||||
static mfxStatus MFX_CDECL Free_(mfxHDL pthis, mfxFrameAllocResponse *response);
|
||||
};
|
||||
|
||||
// This class implements basic logic of memory allocator
|
||||
// Manages responses for different components according to allocation request type
|
||||
// External frames of a particular component-related type are allocated in one call
|
||||
// Further calls return previously allocated response.
|
||||
// Ex. Preallocated frame chain with type=FROM_ENCODE | FROM_VPPIN will be returned when
|
||||
// request type contains either FROM_ENCODE or FROM_VPPIN
|
||||
|
||||
// This class does not allocate any actual memory
|
||||
|
||||
class BaseFrameAllocator: public MFXFrameAllocator
|
||||
{
|
||||
public:
|
||||
BaseFrameAllocator();
|
||||
virtual ~BaseFrameAllocator();
|
||||
|
||||
virtual mfxStatus Init(mfxAllocatorParams *pParams) = 0;
|
||||
virtual mfxStatus Close();
|
||||
virtual mfxStatus AllocFrames(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus ReallocFrame(mfxMemId midIn, const mfxFrameInfo *info, mfxU16 memType, mfxMemId *midOut);
|
||||
virtual mfxStatus FreeFrames(mfxFrameAllocResponse *response);
|
||||
|
||||
protected:
|
||||
std::mutex mtx;
|
||||
typedef std::list<mfxFrameAllocResponse>::iterator Iter;
|
||||
static const mfxU32 MEMTYPE_FROM_MASK = MFX_MEMTYPE_FROM_ENCODE | MFX_MEMTYPE_FROM_DECODE | \
|
||||
MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_FROM_VPPOUT | \
|
||||
MFX_MEMTYPE_FROM_ENC | MFX_MEMTYPE_FROM_PAK;
|
||||
|
||||
static const mfxU32 MEMTYPE_FROM_MASK_INT_EXT = MEMTYPE_FROM_MASK | MFX_MEMTYPE_INTERNAL_FRAME | MFX_MEMTYPE_EXTERNAL_FRAME;
|
||||
|
||||
struct UniqueResponse
|
||||
: mfxFrameAllocResponse
|
||||
{
|
||||
mfxU16 m_width;
|
||||
mfxU16 m_height;
|
||||
mfxU32 m_refCount;
|
||||
mfxU16 m_type;
|
||||
|
||||
UniqueResponse()
|
||||
: m_width(0)
|
||||
, m_height(0)
|
||||
, m_refCount(0)
|
||||
, m_type(0)
|
||||
{
|
||||
memset(static_cast<mfxFrameAllocResponse*>(this), 0, sizeof(mfxFrameAllocResponse));
|
||||
}
|
||||
|
||||
// compare responses by actual frame size, alignment (w and h) is up to application
|
||||
UniqueResponse(const mfxFrameAllocResponse & response, mfxU16 width, mfxU16 height, mfxU16 type)
|
||||
: mfxFrameAllocResponse(response)
|
||||
, m_width(width)
|
||||
, m_height(height)
|
||||
, m_refCount(1)
|
||||
, m_type(type)
|
||||
{
|
||||
}
|
||||
|
||||
//compare by resolution (and memory type for FEI ENC / PAK)
|
||||
bool operator () (const UniqueResponse &response)const
|
||||
{
|
||||
if (m_width <= response.m_width && m_height <= response.m_height)
|
||||
{
|
||||
// For FEI ENC and PAK we need to distinguish between INTERNAL and EXTERNAL frames
|
||||
|
||||
if (m_type & response.m_type & (MFX_MEMTYPE_FROM_ENC | MFX_MEMTYPE_FROM_PAK))
|
||||
{
|
||||
return !!((m_type & response.m_type) & 0x000f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return !!(m_type & response.m_type & MFX_MEMTYPE_FROM_DECODE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static mfxU16 CropMemoryTypeToStore(mfxU16 type)
|
||||
{
|
||||
// Remain INTERNAL / EXTERNAL flag for FEI ENC / PAK
|
||||
switch (type & 0xf000)
|
||||
{
|
||||
case MFX_MEMTYPE_FROM_ENC:
|
||||
case MFX_MEMTYPE_FROM_PAK:
|
||||
case (MFX_MEMTYPE_FROM_ENC | MFX_MEMTYPE_FROM_PAK):
|
||||
return type & MEMTYPE_FROM_MASK_INT_EXT;
|
||||
break;
|
||||
default:
|
||||
return type & MEMTYPE_FROM_MASK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::list<mfxFrameAllocResponse> m_responses;
|
||||
std::list<UniqueResponse> m_ExtResponses;
|
||||
|
||||
struct IsSame
|
||||
: public std::binary_function<mfxFrameAllocResponse, mfxFrameAllocResponse, bool>
|
||||
{
|
||||
bool operator () (const mfxFrameAllocResponse & l, const mfxFrameAllocResponse &r)const
|
||||
{
|
||||
return r.mids != 0 && l.mids != 0 &&
|
||||
r.mids[0] == l.mids[0] &&
|
||||
r.NumFrameActual == l.NumFrameActual;
|
||||
}
|
||||
};
|
||||
|
||||
// checks if request is supported
|
||||
virtual mfxStatus CheckRequestType(mfxFrameAllocRequest *request);
|
||||
|
||||
// frees memory attached to response
|
||||
virtual mfxStatus ReleaseResponse(mfxFrameAllocResponse *response) = 0;
|
||||
// allocates memory
|
||||
virtual mfxStatus AllocImpl(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response) = 0;
|
||||
virtual mfxStatus ReallocImpl(mfxMemId midIn, const mfxFrameInfo *info, mfxU16 memType, mfxMemId *midOut) = 0;
|
||||
};
|
||||
|
||||
class MFXBufferAllocator : public mfxBufferAllocator
|
||||
{
|
||||
public:
|
||||
MFXBufferAllocator();
|
||||
virtual ~MFXBufferAllocator();
|
||||
|
||||
virtual mfxStatus AllocBuffer(mfxU32 nbytes, mfxU16 type, mfxMemId *mid) = 0;
|
||||
virtual mfxStatus LockBuffer(mfxMemId mid, mfxU8 **ptr) = 0;
|
||||
virtual mfxStatus UnlockBuffer(mfxMemId mid) = 0;
|
||||
virtual mfxStatus FreeBuffer(mfxMemId mid) = 0;
|
||||
|
||||
private:
|
||||
static mfxStatus MFX_CDECL Alloc_(mfxHDL pthis, mfxU32 nbytes, mfxU16 type, mfxMemId *mid);
|
||||
static mfxStatus MFX_CDECL Lock_(mfxHDL pthis, mfxMemId mid, mfxU8 **ptr);
|
||||
static mfxStatus MFX_CDECL Unlock_(mfxHDL pthis, mfxMemId mid);
|
||||
static mfxStatus MFX_CDECL Free_(mfxHDL pthis, mfxMemId mid);
|
||||
};
|
||||
|
||||
|
||||
#endif // __BASE_ALLOCATOR_H__
|
||||
425
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/brc_routines.h
vendored
Normal file
425
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/brc_routines.h
vendored
Normal file
@@ -0,0 +1,425 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
#include "sample_defs.h"
|
||||
#include "algorithm"
|
||||
|
||||
#ifndef MFX_VERSION
|
||||
#error MFX_VERSION not defined
|
||||
#endif
|
||||
|
||||
#if (MFX_VERSION >= 1024)
|
||||
#include "mfxbrc.h"
|
||||
|
||||
#ifndef __PIPELINE_ENCODE_BRC_H__
|
||||
#define __PIPELINE_ENCODE_BRC_H__
|
||||
|
||||
#define MFX_CHECK_NULL_PTR1(pointer) MSDK_CHECK_POINTER(pointer, MFX_ERR_NULL_PTR);
|
||||
|
||||
#define MFX_CHECK_NULL_PTR2(pointer1,pointer2 )\
|
||||
MFX_CHECK_NULL_PTR1(pointer1);\
|
||||
MFX_CHECK_NULL_PTR1(pointer2);
|
||||
|
||||
#define MFX_CHECK_NULL_PTR3(pointer1,pointer2, pointer3 )\
|
||||
MFX_CHECK_NULL_PTR2(pointer1,pointer2);\
|
||||
MFX_CHECK_NULL_PTR1(pointer3);
|
||||
|
||||
#define MFX_CHECK(cond, error) MSDK_CHECK_NOT_EQUAL(cond, true, error)
|
||||
#define MFX_CHECK_STS(sts) MFX_CHECK(sts == MFX_ERR_NONE, sts)
|
||||
|
||||
|
||||
/*
|
||||
NalHrdConformance | VuiNalHrdParameters | Result
|
||||
--------------------------------------------------------------
|
||||
off any => MFX_BRC_NO_HRD
|
||||
default off => MFX_BRC_NO_HRD
|
||||
on off => MFX_BRC_HRD_WEAK
|
||||
on (or default) on (or default) => MFX_BRC_HRD_STRONG
|
||||
--------------------------------------------------------------
|
||||
*/
|
||||
enum : mfxU16
|
||||
{
|
||||
MFX_BRC_NO_HRD = 0,
|
||||
MFX_BRC_HRD_WEAK, // IF HRD CALCULATION IS REQUIRED, BUT NOT WRITTEN TO THE STREAM
|
||||
MFX_BRC_HRD_STRONG
|
||||
};
|
||||
|
||||
class cBRCParams
|
||||
{
|
||||
public:
|
||||
mfxU16 rateControlMethod; // CBR or VBR
|
||||
|
||||
mfxU16 HRDConformance; // is HRD compliance needed
|
||||
mfxU16 bRec; // is Recoding possible
|
||||
mfxU16 bPanic; // is Panic mode possible
|
||||
|
||||
// HRD params
|
||||
mfxU32 bufferSizeInBytes;
|
||||
mfxU32 initialDelayInBytes;
|
||||
|
||||
// Sliding window parameters
|
||||
mfxU16 WinBRCMaxAvgKbps;
|
||||
mfxU16 WinBRCSize;
|
||||
|
||||
// RC params
|
||||
mfxU32 targetbps;
|
||||
mfxU32 maxbps;
|
||||
mfxF64 frameRate;
|
||||
mfxF64 inputBitsPerFrame;
|
||||
mfxF64 maxInputBitsPerFrame;
|
||||
mfxU32 maxFrameSizeInBits;
|
||||
|
||||
// Frame size params
|
||||
mfxU16 width;
|
||||
mfxU16 height;
|
||||
mfxU16 chromaFormat;
|
||||
mfxU16 bitDepthLuma;
|
||||
|
||||
// GOP params
|
||||
mfxU16 gopPicSize;
|
||||
mfxU16 gopRefDist;
|
||||
bool bPyr;
|
||||
|
||||
//BRC accurancy params
|
||||
mfxF64 fAbPeriodLong; // number on frames to calculate abberation from target frame
|
||||
mfxF64 fAbPeriodShort; // number on frames to calculate abberation from target frame
|
||||
mfxF64 dqAbPeriod; // number on frames to calculate abberation from dequant
|
||||
mfxF64 bAbPeriod; // number of frames to calculate abberation from target bitrate
|
||||
|
||||
//QP parameters
|
||||
mfxI32 quantOffset;
|
||||
mfxI32 quantMaxI;
|
||||
mfxI32 quantMinI;
|
||||
mfxI32 quantMaxP;
|
||||
mfxI32 quantMinP;
|
||||
mfxI32 quantMaxB;
|
||||
mfxI32 quantMinB;
|
||||
|
||||
public:
|
||||
cBRCParams():
|
||||
rateControlMethod(0),
|
||||
HRDConformance(MFX_BRC_NO_HRD),
|
||||
bRec(0),
|
||||
bPanic(0),
|
||||
bufferSizeInBytes(0),
|
||||
initialDelayInBytes(0),
|
||||
WinBRCMaxAvgKbps(0),
|
||||
WinBRCSize(0),
|
||||
targetbps(0),
|
||||
maxbps(0),
|
||||
frameRate(0),
|
||||
inputBitsPerFrame(0),
|
||||
maxInputBitsPerFrame(0),
|
||||
maxFrameSizeInBits(0),
|
||||
width(0),
|
||||
height(0),
|
||||
chromaFormat(0),
|
||||
bitDepthLuma(0),
|
||||
gopPicSize(0),
|
||||
gopRefDist(0),
|
||||
bPyr(0),
|
||||
fAbPeriodLong(0),
|
||||
fAbPeriodShort(0),
|
||||
dqAbPeriod(0),
|
||||
bAbPeriod(0),
|
||||
quantOffset(0),
|
||||
quantMaxI(0),
|
||||
quantMinI(0),
|
||||
quantMaxP(0),
|
||||
quantMinP(0),
|
||||
quantMaxB(0),
|
||||
quantMinB(0)
|
||||
{}
|
||||
|
||||
mfxStatus Init(mfxVideoParam* par, bool bFieldMode = false);
|
||||
mfxStatus GetBRCResetType(mfxVideoParam* par, bool bNewSequence, bool &bReset, bool &bSlidingWindowReset );
|
||||
};
|
||||
class cHRD
|
||||
{
|
||||
public:
|
||||
cHRD():
|
||||
m_bufFullness(0),
|
||||
m_prevBufFullness(0),
|
||||
m_frameNum(0),
|
||||
m_minFrameSize(0),
|
||||
m_maxFrameSize(0),
|
||||
m_underflowQuant(0),
|
||||
m_overflowQuant(0),
|
||||
m_buffSizeInBits(0),
|
||||
m_delayInBits(0),
|
||||
m_inputBitsPerFrame(0),
|
||||
m_bCBR (false)
|
||||
{}
|
||||
|
||||
void Init(mfxU32 buffSizeInBytes, mfxU32 delayInBytes, mfxF64 inputBitsPerFrame, bool cbr);
|
||||
mfxU16 UpdateAndCheckHRD(mfxI32 frameBits, mfxI32 recode, mfxI32 minQuant, mfxI32 maxQuant);
|
||||
mfxStatus UpdateMinMaxQPForRec(mfxU32 brcSts, mfxI32 qp);
|
||||
mfxI32 GetTargetSize(mfxU32 brcSts);
|
||||
mfxI32 GetMaxFrameSize() { return m_maxFrameSize;}
|
||||
mfxI32 GetMinFrameSize() { return m_minFrameSize;}
|
||||
mfxI32 GetMaxQuant() { return m_overflowQuant - 1;}
|
||||
mfxI32 GetMinQuant() { return m_underflowQuant + 1;}
|
||||
mfxF64 GetBufferDiviation(mfxU32 targetBitrate);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
mfxF64 m_bufFullness;
|
||||
mfxF64 m_prevBufFullness;
|
||||
mfxI32 m_frameNum;
|
||||
mfxI32 m_minFrameSize;
|
||||
mfxI32 m_maxFrameSize;
|
||||
mfxI32 m_underflowQuant;
|
||||
mfxI32 m_overflowQuant;
|
||||
|
||||
private:
|
||||
mfxI32 m_buffSizeInBits;
|
||||
mfxI32 m_delayInBits;
|
||||
mfxF64 m_inputBitsPerFrame;
|
||||
bool m_bCBR;
|
||||
|
||||
};
|
||||
|
||||
struct BRC_Ctx
|
||||
{
|
||||
mfxI32 QuantI; //currect qp for intra frames
|
||||
mfxI32 QuantP; //currect qp for P frames
|
||||
mfxI32 QuantB; //currect qp for B frames
|
||||
|
||||
mfxI32 Quant; // qp for last encoded frame
|
||||
mfxI32 QuantMin; // qp Min for last encoded frame (is used for recoding)
|
||||
mfxI32 QuantMax; // qp Max for last encoded frame (is used for recoding)
|
||||
|
||||
bool bToRecode; // last frame is needed in recoding
|
||||
bool bPanic; // last frame is needed in panic
|
||||
mfxU32 encOrder; // encoding order of last encoded frame
|
||||
mfxU32 poc; // poc of last encoded frame
|
||||
mfxI32 SceneChange; // scene change parameter of last encoded frame
|
||||
mfxU32 SChPoc; // poc of frame with scene change
|
||||
mfxU32 LastIEncOrder; // encoded order if last intra frame
|
||||
mfxU32 LastNonBFrameSize; // encoded frame size of last non B frame (is used for sceneChange)
|
||||
|
||||
mfxF64 fAbLong; // avarage frame size (long period)
|
||||
mfxF64 fAbShort; // avarage frame size (short period)
|
||||
mfxF64 dQuantAb; // avarage dequant
|
||||
mfxF64 totalDiviation; // divation from target bitrate (total)
|
||||
|
||||
mfxF64 eRate; // eRate of last encoded frame, this parameter is used for scene change calculation
|
||||
mfxF64 eRateSH; // eRate of last encoded scene change frame, this parameter is used for scene change calculation
|
||||
};
|
||||
class AVGBitrate
|
||||
{
|
||||
public:
|
||||
AVGBitrate(mfxU32 windowSize, mfxU32 maxBitPerFrame, mfxU32 avgBitPerFrame) :
|
||||
m_maxWinBits(maxBitPerFrame*windowSize),
|
||||
m_maxWinBitsLim(0),
|
||||
m_avgBitPerFrame(std::min(avgBitPerFrame, maxBitPerFrame)),
|
||||
m_currPosInWindow(windowSize-1),
|
||||
m_lastFrameOrder(mfxU32(-1))
|
||||
|
||||
{
|
||||
windowSize = windowSize > 0 ? windowSize : 1; // kw
|
||||
m_slidingWindow.resize(windowSize);
|
||||
for (mfxU32 i = 0; i < windowSize; i++)
|
||||
{
|
||||
m_slidingWindow[i] = maxBitPerFrame / 3; //initial value to prevent big first frames
|
||||
}
|
||||
m_maxWinBitsLim = GetMaxWinBitsLim();
|
||||
}
|
||||
virtual ~AVGBitrate()
|
||||
{
|
||||
|
||||
}
|
||||
void UpdateSlidingWindow(mfxU32 sizeInBits, mfxU32 FrameOrder, bool bPanic, bool bSH, mfxU32 recode)
|
||||
{
|
||||
mfxU32 windowSize = (mfxU32)m_slidingWindow.size();
|
||||
bool bNextFrame = FrameOrder != m_lastFrameOrder;
|
||||
|
||||
if (bNextFrame)
|
||||
{
|
||||
m_lastFrameOrder = FrameOrder;
|
||||
m_currPosInWindow = (m_currPosInWindow + 1) % windowSize;
|
||||
}
|
||||
m_slidingWindow[m_currPosInWindow] = sizeInBits;
|
||||
|
||||
if (bNextFrame)
|
||||
{
|
||||
if (bPanic || bSH)
|
||||
{
|
||||
m_maxWinBitsLim = mfx::clamp((GetLastFrameBits(windowSize, false) + m_maxWinBits)/2, GetMaxWinBitsLim(), m_maxWinBits);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (recode)
|
||||
{
|
||||
m_maxWinBitsLim = mfx::clamp(GetLastFrameBits(windowSize, false) + GetStep()/2, m_maxWinBitsLim, m_maxWinBits);
|
||||
}
|
||||
else if ((m_maxWinBitsLim > GetMaxWinBitsLim() + GetStep()) &&
|
||||
(m_maxWinBitsLim - GetStep() > (GetLastFrameBits(windowSize - 1, false) + sizeInBits)))
|
||||
m_maxWinBitsLim -= GetStep();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
mfxU32 GetMaxFrameSize(bool bPanic, bool bSH, mfxU32 recode)
|
||||
{
|
||||
mfxU32 winBits = GetLastFrameBits(GetWindowSize() - 1, !bPanic);
|
||||
|
||||
mfxU32 maxWinBitsLim = m_maxWinBitsLim;
|
||||
if (bSH)
|
||||
maxWinBitsLim = (m_maxWinBits + m_maxWinBitsLim)/2;
|
||||
if (bPanic)
|
||||
maxWinBitsLim = m_maxWinBits;
|
||||
maxWinBitsLim = std::min(maxWinBitsLim + recode*GetStep()/2, m_maxWinBits);
|
||||
|
||||
mfxU32 maxFrameSize = winBits >= m_maxWinBitsLim ?
|
||||
mfxU32(std::max<mfxI32>((mfxI32)m_maxWinBits - (mfxI32)winBits, 1)):
|
||||
maxWinBitsLim - winBits;
|
||||
|
||||
|
||||
|
||||
return maxFrameSize;
|
||||
}
|
||||
mfxU32 GetWindowSize()
|
||||
{
|
||||
return (mfxU32)m_slidingWindow.size();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
mfxU32 m_maxWinBits;
|
||||
mfxU32 m_maxWinBitsLim;
|
||||
mfxU32 m_avgBitPerFrame;
|
||||
|
||||
mfxU32 m_currPosInWindow;
|
||||
mfxU32 m_lastFrameOrder;
|
||||
std::vector<mfxU32> m_slidingWindow;
|
||||
|
||||
|
||||
|
||||
mfxU32 GetLastFrameBits(mfxU32 numFrames, bool bCheckSkip)
|
||||
{
|
||||
mfxU32 size = 0;
|
||||
numFrames = numFrames < m_slidingWindow.size() ? numFrames : (mfxU32)m_slidingWindow.size();
|
||||
for (mfxU32 i = 0; i < numFrames; i++)
|
||||
{
|
||||
mfxU32 frame_size = m_slidingWindow[(m_currPosInWindow + m_slidingWindow.size() - i) % m_slidingWindow.size()];
|
||||
if (bCheckSkip && (frame_size < m_avgBitPerFrame / 3))
|
||||
frame_size = m_avgBitPerFrame / 3;
|
||||
size += frame_size;
|
||||
//printf("GetLastFrames: %d) %d sum %d\n",i,m_slidingWindow[(m_currPosInWindow + m_slidingWindow.size() - i) % m_slidingWindow.size() ], size);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
mfxU32 GetStep()
|
||||
{
|
||||
return (m_maxWinBits / GetWindowSize() - m_avgBitPerFrame) / 2;
|
||||
}
|
||||
|
||||
mfxU32 GetMaxWinBitsLim()
|
||||
{
|
||||
return m_maxWinBits - GetStep() * GetWindowSize();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
class ExtBRC
|
||||
{
|
||||
private:
|
||||
cBRCParams m_par;
|
||||
cHRD m_hrd;
|
||||
bool m_bInit;
|
||||
BRC_Ctx m_ctx;
|
||||
std::unique_ptr<AVGBitrate> m_avg;
|
||||
|
||||
public:
|
||||
ExtBRC():
|
||||
m_par(),
|
||||
m_hrd(),
|
||||
m_bInit(false)
|
||||
{
|
||||
memset(&m_ctx, 0, sizeof(m_ctx));
|
||||
|
||||
}
|
||||
mfxStatus Init (mfxVideoParam* par);
|
||||
mfxStatus Reset(mfxVideoParam* par);
|
||||
mfxStatus Close () {m_bInit = false; return MFX_ERR_NONE;}
|
||||
mfxStatus GetFrameCtrl (mfxBRCFrameParam* par, mfxBRCFrameCtrl* ctrl);
|
||||
mfxStatus Update (mfxBRCFrameParam* par, mfxBRCFrameCtrl* ctrl, mfxBRCFrameStatus* status);
|
||||
protected:
|
||||
mfxI32 GetCurQP (mfxU32 type, mfxI32 layer);
|
||||
};
|
||||
|
||||
namespace HEVCExtBRC
|
||||
{
|
||||
inline mfxStatus Init (mfxHDL pthis, mfxVideoParam* par)
|
||||
{
|
||||
MFX_CHECK_NULL_PTR1(pthis);
|
||||
return ((ExtBRC*)pthis)->Init(par) ;
|
||||
}
|
||||
inline mfxStatus Reset (mfxHDL pthis, mfxVideoParam* par)
|
||||
{
|
||||
MFX_CHECK_NULL_PTR1(pthis);
|
||||
return ((ExtBRC*)pthis)->Reset(par) ;
|
||||
}
|
||||
inline mfxStatus Close (mfxHDL pthis)
|
||||
{
|
||||
MFX_CHECK_NULL_PTR1(pthis);
|
||||
return ((ExtBRC*)pthis)->Close() ;
|
||||
}
|
||||
inline mfxStatus GetFrameCtrl (mfxHDL pthis, mfxBRCFrameParam* par, mfxBRCFrameCtrl* ctrl)
|
||||
{
|
||||
MFX_CHECK_NULL_PTR1(pthis);
|
||||
return ((ExtBRC*)pthis)->GetFrameCtrl(par,ctrl) ;
|
||||
}
|
||||
inline mfxStatus Update (mfxHDL pthis, mfxBRCFrameParam* par, mfxBRCFrameCtrl* ctrl, mfxBRCFrameStatus* status)
|
||||
{
|
||||
MFX_CHECK_NULL_PTR1(pthis);
|
||||
return ((ExtBRC*)pthis)->Update(par,ctrl, status) ;
|
||||
}
|
||||
inline mfxStatus Create(mfxExtBRC & m_BRC)
|
||||
{
|
||||
MFX_CHECK(m_BRC.pthis == NULL, MFX_ERR_UNDEFINED_BEHAVIOR);
|
||||
m_BRC.pthis = new ExtBRC;
|
||||
m_BRC.Init = Init;
|
||||
m_BRC.Reset = Reset;
|
||||
m_BRC.Close = Close;
|
||||
m_BRC.GetFrameCtrl = GetFrameCtrl;
|
||||
m_BRC.Update = Update;
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
inline mfxStatus Destroy(mfxExtBRC & m_BRC)
|
||||
{
|
||||
if(m_BRC.pthis != NULL)
|
||||
{
|
||||
delete (ExtBRC*)m_BRC.pthis;
|
||||
m_BRC.pthis = 0;
|
||||
m_BRC.Init = 0;
|
||||
m_BRC.Reset = 0;
|
||||
m_BRC.Close = 0;
|
||||
m_BRC.GetFrameCtrl = 0;
|
||||
m_BRC.Update = 0;
|
||||
}
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
27
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/current_date.h
vendored
Normal file
27
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/current_date.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#define PRODUCT_NAME "Intel\xae Media SDK"
|
||||
#define FILE_VERSION 1,0,0,0
|
||||
#define FILE_VERSION_STRING "1,0,0,0"
|
||||
#define FILTER_NAME_PREFIX ""
|
||||
#define FILTER_NAME_SUFFIX ""
|
||||
#define PRODUCT_COPYRIGHT "Copyright\xa9 2003-2019 Intel Corporation"
|
||||
#define PRODUCT_VERSION 1,0,0,0
|
||||
#define PRODUCT_VERSION_STRING "1,0,0,0"
|
||||
263
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/d3d11_allocator.h
vendored
Normal file
263
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/d3d11_allocator.h
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __D3D11_ALLOCATOR_H__
|
||||
#define __D3D11_ALLOCATOR_H__
|
||||
|
||||
#include "base_allocator.h"
|
||||
#include <limits>
|
||||
|
||||
#ifdef __gnu_linux__
|
||||
#include <stdint.h> // for uintptr_t on Linux
|
||||
#endif
|
||||
|
||||
//application can provide either generic mid from surface or this wrapper
|
||||
//wrapper distinguishes from generic mid by highest 1 bit
|
||||
//if it set then remained pointer points to extended structure of memid
|
||||
//64 bits system layout
|
||||
/*----+-----------------------------------------------------------+
|
||||
|b63=1|63 bits remained for pointer to extended structure of memid|
|
||||
|b63=0|63 bits from original mfxMemId |
|
||||
+-----+----------------------------------------------------------*/
|
||||
//32 bits system layout
|
||||
/*--+---+--------------------------------------------+
|
||||
|b31=1|31 bits remained for pointer to extended memid|
|
||||
|b31=0|31 bits remained for surface pointer |
|
||||
+---+---+-------------------------------------------*/
|
||||
//#pragma warning (disable:4293)
|
||||
class MFXReadWriteMid
|
||||
{
|
||||
static const uintptr_t bits_offset = std::numeric_limits<uintptr_t>::digits - 1;
|
||||
static const uintptr_t clear_mask = ~((uintptr_t)1 << bits_offset);
|
||||
public:
|
||||
enum
|
||||
{
|
||||
//if flag not set it means that read and write
|
||||
not_set = 0,
|
||||
reuse = 1,
|
||||
read = 2,
|
||||
write = 4,
|
||||
};
|
||||
//here mfxmemid might be as MFXReadWriteMid or mfxMemId memid
|
||||
MFXReadWriteMid(mfxMemId mid, mfxU8 flag = not_set)
|
||||
{
|
||||
//setup mid
|
||||
m_mid_to_report = (mfxMemId)((uintptr_t)&m_mid | ((uintptr_t)1 << bits_offset));
|
||||
if (0 != ((uintptr_t)mid >> bits_offset))
|
||||
{
|
||||
//it points to extended structure
|
||||
mfxMedIdEx * pMemIdExt = reinterpret_cast<mfxMedIdEx *>((uintptr_t)mid & clear_mask);
|
||||
m_mid.pId = pMemIdExt->pId;
|
||||
if (reuse == flag)
|
||||
{
|
||||
m_mid.read_write = pMemIdExt->read_write;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mid.read_write = flag;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mid.pId = mid;
|
||||
if (reuse == flag)
|
||||
m_mid.read_write = not_set;
|
||||
else
|
||||
m_mid.read_write = flag;
|
||||
}
|
||||
|
||||
}
|
||||
bool isRead() const
|
||||
{
|
||||
return 0 != (m_mid.read_write & read) || !m_mid.read_write;
|
||||
}
|
||||
bool isWrite() const
|
||||
{
|
||||
return 0 != (m_mid.read_write & write) || !m_mid.read_write;
|
||||
}
|
||||
/// returns original memid without read write flags
|
||||
mfxMemId raw() const
|
||||
{
|
||||
return m_mid.pId;
|
||||
}
|
||||
operator mfxMemId() const
|
||||
{
|
||||
return m_mid_to_report;
|
||||
}
|
||||
|
||||
private:
|
||||
struct mfxMedIdEx
|
||||
{
|
||||
mfxMemId pId;
|
||||
mfxU8 read_write;
|
||||
};
|
||||
|
||||
mfxMedIdEx m_mid;
|
||||
mfxMemId m_mid_to_report;
|
||||
};
|
||||
|
||||
#if (defined(_WIN32) || defined(_WIN64))
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
struct ID3D11VideoDevice;
|
||||
struct ID3D11VideoContext;
|
||||
|
||||
struct D3D11AllocatorParams : mfxAllocatorParams
|
||||
{
|
||||
ID3D11Device *pDevice;
|
||||
bool bUseSingleTexture;
|
||||
DWORD uncompressedResourceMiscFlags;
|
||||
|
||||
D3D11AllocatorParams()
|
||||
: pDevice()
|
||||
, bUseSingleTexture()
|
||||
, uncompressedResourceMiscFlags()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class D3D11FrameAllocator: public BaseFrameAllocator
|
||||
{
|
||||
public:
|
||||
|
||||
D3D11FrameAllocator();
|
||||
virtual ~D3D11FrameAllocator();
|
||||
|
||||
virtual mfxStatus Init(mfxAllocatorParams *pParams);
|
||||
virtual mfxStatus Close();
|
||||
virtual ID3D11Device * GetD3D11Device()
|
||||
{
|
||||
return m_initParams.pDevice;
|
||||
};
|
||||
virtual mfxStatus LockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus UnlockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus GetFrameHDL(mfxMemId mid, mfxHDL *handle);
|
||||
|
||||
protected:
|
||||
static DXGI_FORMAT ConverColortFormat(mfxU32 fourcc);
|
||||
virtual mfxStatus CheckRequestType(mfxFrameAllocRequest *request);
|
||||
virtual mfxStatus ReleaseResponse(mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus AllocImpl(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus ReallocImpl(mfxMemId midIn, const mfxFrameInfo *info, mfxU16 memType, mfxMemId *midOut);
|
||||
|
||||
D3D11AllocatorParams m_initParams;
|
||||
ID3D11DeviceContext *m_pDeviceContext;
|
||||
|
||||
struct TextureResource
|
||||
{
|
||||
std::vector<mfxMemId> outerMids;
|
||||
std::vector<ID3D11Texture2D*> textures;
|
||||
std::vector<ID3D11Texture2D*> stagingTexture;
|
||||
bool bAlloc;
|
||||
|
||||
TextureResource()
|
||||
: bAlloc(true)
|
||||
{
|
||||
}
|
||||
|
||||
static bool isAllocated (TextureResource & that)
|
||||
{
|
||||
return that.bAlloc;
|
||||
}
|
||||
ID3D11Texture2D* GetTexture(mfxMemId id)
|
||||
{
|
||||
if (outerMids.empty())
|
||||
return NULL;
|
||||
|
||||
return textures[((uintptr_t)id - (uintptr_t)outerMids.front()) % textures.size()];
|
||||
}
|
||||
UINT GetSubResource(mfxMemId id)
|
||||
{
|
||||
if (outerMids.empty())
|
||||
return NULL;
|
||||
|
||||
return (UINT)(((uintptr_t)id - (uintptr_t)outerMids.front()) / textures.size());
|
||||
}
|
||||
void Release()
|
||||
{
|
||||
size_t i = 0;
|
||||
for(i = 0; i < textures.size(); i++)
|
||||
{
|
||||
textures[i]->Release();
|
||||
}
|
||||
textures.clear();
|
||||
|
||||
for(i = 0; i < stagingTexture.size(); i++)
|
||||
{
|
||||
stagingTexture[i]->Release();
|
||||
}
|
||||
stagingTexture.clear();
|
||||
|
||||
//marking texture as deallocated
|
||||
bAlloc = false;
|
||||
}
|
||||
};
|
||||
class TextureSubResource
|
||||
{
|
||||
TextureResource * m_pTarget;
|
||||
ID3D11Texture2D * m_pTexture;
|
||||
ID3D11Texture2D * m_pStaging;
|
||||
UINT m_subResource;
|
||||
public:
|
||||
TextureSubResource(TextureResource * pTarget = NULL, mfxMemId id = 0)
|
||||
: m_pTarget(pTarget)
|
||||
, m_pTexture()
|
||||
, m_subResource()
|
||||
, m_pStaging(NULL)
|
||||
{
|
||||
if (NULL != m_pTarget && !m_pTarget->outerMids.empty())
|
||||
{
|
||||
ptrdiff_t idx = (uintptr_t)MFXReadWriteMid(id).raw() - (uintptr_t)m_pTarget->outerMids.front();
|
||||
m_pTexture = m_pTarget->textures[idx % m_pTarget->textures.size()];
|
||||
m_subResource = (UINT)(idx / m_pTarget->textures.size());
|
||||
m_pStaging = m_pTarget->stagingTexture.empty() ? NULL : m_pTarget->stagingTexture[idx];
|
||||
}
|
||||
}
|
||||
ID3D11Texture2D* GetStaging()const
|
||||
{
|
||||
return m_pStaging;
|
||||
}
|
||||
ID3D11Texture2D* GetTexture()const
|
||||
{
|
||||
return m_pTexture;
|
||||
}
|
||||
UINT GetSubResource()const
|
||||
{
|
||||
return m_subResource;
|
||||
}
|
||||
void Release()
|
||||
{
|
||||
if (NULL != m_pTarget)
|
||||
m_pTarget->Release();
|
||||
}
|
||||
};
|
||||
|
||||
TextureSubResource GetResourceFromMid(mfxMemId);
|
||||
|
||||
std::list <TextureResource> m_resourcesByRequest;//each alloc request generates new item in list
|
||||
|
||||
typedef std::list <TextureResource>::iterator referenceType;
|
||||
std::vector<referenceType> m_memIdMap;
|
||||
};
|
||||
|
||||
#endif // #if defined(_WIN32) || defined(_WIN64)
|
||||
#endif // __D3D11_ALLOCATOR_H__
|
||||
86
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/d3d11_device.h
vendored
Normal file
86
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/d3d11_device.h
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined( _WIN32 ) || defined ( _WIN64 )
|
||||
|
||||
#include "sample_defs.h" // defines MFX_D3D11_SUPPORT
|
||||
|
||||
#if MFX_D3D11_SUPPORT
|
||||
#include "hw_device.h"
|
||||
#include <windows.h>
|
||||
#include <d3d11.h>
|
||||
#include <atlbase.h>
|
||||
|
||||
#include <dxgi1_2.h>
|
||||
|
||||
class CD3D11Device: public CHWDevice
|
||||
{
|
||||
public:
|
||||
CD3D11Device();
|
||||
virtual ~CD3D11Device();
|
||||
virtual mfxStatus Init(
|
||||
mfxHDL hWindow,
|
||||
mfxU16 nViews,
|
||||
mfxU32 nAdapterNum);
|
||||
virtual mfxStatus Reset();
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *pHdl);
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl);
|
||||
virtual mfxStatus RenderFrame(mfxFrameSurface1 * pSurface, mfxFrameAllocator * pmfxAlloc);
|
||||
virtual void UpdateTitle(double /*fps*/) { }
|
||||
virtual void Close();
|
||||
void DefineFormat(bool isA2rgb10) { m_bIsA2rgb10 = (isA2rgb10) ? TRUE : FALSE; }
|
||||
virtual void SetMondelloInput(bool /*isMondelloInputEnabled*/ ) { }
|
||||
protected:
|
||||
virtual mfxStatus FillSCD(mfxHDL hWindow, DXGI_SWAP_CHAIN_DESC& scd);
|
||||
virtual mfxStatus FillSCD1(DXGI_SWAP_CHAIN_DESC1& scd);
|
||||
mfxStatus CreateVideoProcessor(mfxFrameSurface1 * pSrf);
|
||||
|
||||
CComPtr<ID3D11Device> m_pD3D11Device;
|
||||
CComPtr<ID3D11DeviceContext> m_pD3D11Ctx;
|
||||
CComQIPtr<ID3D11VideoDevice> m_pDX11VideoDevice;
|
||||
CComQIPtr<ID3D11VideoContext> m_pVideoContext;
|
||||
CComPtr<ID3D11VideoProcessorEnumerator> m_VideoProcessorEnum;
|
||||
|
||||
CComQIPtr<IDXGIDevice1> m_pDXGIDev;
|
||||
CComQIPtr<IDXGIAdapter> m_pAdapter;
|
||||
|
||||
CComPtr<IDXGIFactory2> m_pDXGIFactory;
|
||||
|
||||
CComPtr<IDXGISwapChain1> m_pSwapChain;
|
||||
CComPtr<ID3D11VideoProcessor> m_pVideoProcessor;
|
||||
|
||||
private:
|
||||
CComPtr<ID3D11VideoProcessorInputView> m_pInputViewLeft;
|
||||
CComPtr<ID3D11VideoProcessorInputView> m_pInputViewRight;
|
||||
CComPtr<ID3D11VideoProcessorOutputView> m_pOutputView;
|
||||
|
||||
CComPtr<ID3D11Texture2D> m_pDXGIBackBuffer;
|
||||
CComPtr<ID3D11Texture2D> m_pTempTexture;
|
||||
CComPtr<IDXGIDisplayControl> m_pDisplayControl;
|
||||
CComPtr<IDXGIOutput> m_pDXGIOutput;
|
||||
mfxU16 m_nViews;
|
||||
BOOL m_bDefaultStereoEnabled;
|
||||
BOOL m_bIsA2rgb10;
|
||||
HWND m_HandleWindow;
|
||||
};
|
||||
|
||||
#endif //#if defined( _WIN32 ) || defined ( _WIN64 )
|
||||
#endif //#if MFX_D3D11_SUPPORT
|
||||
86
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/d3d_allocator.h
vendored
Normal file
86
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/d3d_allocator.h
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __D3D_ALLOCATOR_H__
|
||||
#define __D3D_ALLOCATOR_H__
|
||||
|
||||
#if defined( _WIN32 ) || defined ( _WIN64 )
|
||||
|
||||
#include <atlbase.h>
|
||||
#include <d3d9.h>
|
||||
#include <dxva2api.h>
|
||||
#include "base_allocator.h"
|
||||
#include <vector>
|
||||
|
||||
enum eTypeHandle
|
||||
{
|
||||
DXVA2_PROCESSOR = 0x00,
|
||||
DXVA2_DECODER = 0x01
|
||||
};
|
||||
|
||||
struct D3DAllocatorParams : mfxAllocatorParams
|
||||
{
|
||||
IDirect3DDeviceManager9 *pManager;
|
||||
DWORD surfaceUsage;
|
||||
|
||||
D3DAllocatorParams()
|
||||
: pManager()
|
||||
, surfaceUsage()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class D3DFrameAllocator: public BaseFrameAllocator
|
||||
{
|
||||
public:
|
||||
D3DFrameAllocator();
|
||||
virtual ~D3DFrameAllocator();
|
||||
|
||||
virtual mfxStatus Init(mfxAllocatorParams *pParams);
|
||||
virtual mfxStatus Close();
|
||||
|
||||
virtual IDirect3DDeviceManager9* GetDeviceManager()
|
||||
{
|
||||
return m_manager;
|
||||
};
|
||||
|
||||
virtual mfxStatus LockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus UnlockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus GetFrameHDL(mfxMemId mid, mfxHDL *handle);
|
||||
|
||||
protected:
|
||||
virtual mfxStatus CheckRequestType(mfxFrameAllocRequest *request);
|
||||
virtual mfxStatus ReleaseResponse(mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus AllocImpl(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus ReallocImpl(mfxMemId midIn, const mfxFrameInfo *info, mfxU16 memType, mfxMemId *midOut);
|
||||
|
||||
void DeallocateMids(mfxHDLPair** pairs, int n);
|
||||
|
||||
std::vector<mfxHDLPair**> m_midsAllocated;
|
||||
|
||||
CComPtr<IDirect3DDeviceManager9> m_manager;
|
||||
CComPtr<IDirectXVideoDecoderService> m_decoderService;
|
||||
CComPtr<IDirectXVideoProcessorService> m_processorService;
|
||||
HANDLE m_hDecoder;
|
||||
HANDLE m_hProcessor;
|
||||
DWORD m_surfaceUsage;
|
||||
};
|
||||
|
||||
#endif // #if defined( _WIN32 ) || defined ( _WIN64 )
|
||||
#endif // __D3D_ALLOCATOR_H__
|
||||
88
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/d3d_device.h
vendored
Normal file
88
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/d3d_device.h
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined( _WIN32 ) || defined ( _WIN64 )
|
||||
|
||||
#include "hw_device.h"
|
||||
|
||||
#pragma warning(disable : 4201)
|
||||
#include <d3d9.h>
|
||||
#include <dxva2api.h>
|
||||
#include <dxva.h>
|
||||
#include <windows.h>
|
||||
|
||||
#define VIDEO_MAIN_FORMAT D3DFMT_YUY2
|
||||
|
||||
/** Direct3D 9 device implementation.
|
||||
@note Device always set D3DPRESENT_PARAMETERS::Windowed to TRUE.
|
||||
*/
|
||||
class CD3D9Device : public CHWDevice
|
||||
{
|
||||
public:
|
||||
CD3D9Device();
|
||||
virtual ~CD3D9Device();
|
||||
|
||||
virtual mfxStatus Init(
|
||||
mfxHDL hWindow,
|
||||
mfxU16 nViews,
|
||||
mfxU32 nAdapterNum);
|
||||
virtual mfxStatus Reset();
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *pHdl);
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl);
|
||||
virtual mfxStatus RenderFrame(mfxFrameSurface1 * pSurface, mfxFrameAllocator * pmfxAlloc);
|
||||
virtual void UpdateTitle(double /*fps*/) { }
|
||||
virtual void Close() ;
|
||||
void DefineFormat(bool isA2rgb10) { m_bIsA2rgb10 = (isA2rgb10) ? TRUE : FALSE; }
|
||||
virtual void SetMondelloInput(bool /*isMondelloInputEnabled*/) { }
|
||||
protected:
|
||||
mfxStatus CreateVideoProcessors();
|
||||
bool CheckOverlaySupport();
|
||||
virtual mfxStatus FillD3DPP(mfxHDL hWindow, mfxU16 nViews, D3DPRESENT_PARAMETERS &D3DPP);
|
||||
private:
|
||||
IDirect3D9Ex* m_pD3D9;
|
||||
IDirect3DDevice9Ex* m_pD3DD9;
|
||||
IDirect3DDeviceManager9* m_pDeviceManager9;
|
||||
D3DPRESENT_PARAMETERS m_D3DPP;
|
||||
UINT m_resetToken;
|
||||
|
||||
mfxU16 m_nViews;
|
||||
|
||||
D3DSURFACE_DESC m_backBufferDesc;
|
||||
|
||||
// service required to create video processors
|
||||
IDirectXVideoProcessorService* m_pDXVAVPS;
|
||||
//left channel processor
|
||||
IDirectXVideoProcessor* m_pDXVAVP_Left;
|
||||
// right channel processor
|
||||
IDirectXVideoProcessor* m_pDXVAVP_Right;
|
||||
|
||||
// target rectangle
|
||||
RECT m_targetRect;
|
||||
|
||||
// various structures for DXVA2 calls
|
||||
DXVA2_VideoDesc m_VideoDesc;
|
||||
DXVA2_VideoProcessBltParams m_BltParams;
|
||||
DXVA2_VideoSample m_Sample;
|
||||
|
||||
BOOL m_bIsA2rgb10;
|
||||
};
|
||||
|
||||
#endif // #if defined( _WIN32 ) || defined ( _WIN64 )
|
||||
109
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/decode_render.h
vendored
Normal file
109
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/decode_render.h
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
|
||||
#ifndef __DECODE_D3D_RENDER_H__
|
||||
#define __DECODE_D3D_RENDER_H__
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#pragma warning(disable : 4201)
|
||||
#include <d3d9.h>
|
||||
#include <dxva2api.h>
|
||||
#include <dxva.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "mfxstructures.h"
|
||||
#include "mfxvideo.h"
|
||||
|
||||
#include "hw_device.h"
|
||||
|
||||
typedef void* WindowHandle;
|
||||
typedef void* Handle;
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
struct sWindowParams
|
||||
{
|
||||
LPCTSTR lpClassName;
|
||||
LPCTSTR lpWindowName;
|
||||
DWORD dwStyle;
|
||||
int nx;
|
||||
int ny;
|
||||
int ncell;
|
||||
int nAdapter;
|
||||
int nWidth;
|
||||
int nHeight;
|
||||
HWND hWndParent;
|
||||
HMENU hMenu;
|
||||
HINSTANCE hInstance;
|
||||
LPVOID lpParam;
|
||||
bool bFullScreen; // Stretch window to full screen
|
||||
};
|
||||
|
||||
class CDecodeD3DRender
|
||||
{
|
||||
public:
|
||||
|
||||
CDecodeD3DRender();
|
||||
virtual ~CDecodeD3DRender();
|
||||
|
||||
virtual mfxStatus Init(sWindowParams pWParams);
|
||||
virtual mfxStatus RenderFrame(mfxFrameSurface1 *pSurface, mfxFrameAllocator *pmfxAlloc);
|
||||
virtual VOID UpdateTitle(double fps);
|
||||
void Close();
|
||||
|
||||
HWND GetWindowHandle();
|
||||
|
||||
VOID OnDestroy(HWND hwnd);
|
||||
VOID OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags);
|
||||
VOID ChangeWindowSize(bool bFullScreen);
|
||||
|
||||
void SetHWDevice(CHWDevice *dev)
|
||||
{
|
||||
m_hwdev = dev;
|
||||
}
|
||||
protected:
|
||||
void AdjustWindowRect(RECT *rect);
|
||||
|
||||
mfxStatus AllocateShiftedSurfaceIfNeeded(const mfxFrameSurface1* refSurface,mfxFrameAllocator* allocator);
|
||||
mfxFrameAllocResponse shiftSurfaceResponse;
|
||||
mfxFrameSurface1 shiftedSurface;
|
||||
mfxFrameAllocator* pAllocator;
|
||||
|
||||
CHWDevice *m_hwdev;
|
||||
|
||||
|
||||
sWindowParams m_sWindowParams;
|
||||
HWND m_Hwnd;
|
||||
RECT m_rect;
|
||||
DWORD m_style;
|
||||
|
||||
bool EnableDwmQueuing();
|
||||
static BOOL CALLBACK MonitorEnumProc(HMONITOR ,HDC ,LPRECT lprcMonitor,LPARAM dwData);
|
||||
static bool m_bIsMonitorFound;
|
||||
|
||||
bool m_bDwmEnabled;
|
||||
int m_nMonitorCurrent;
|
||||
::RECT m_RectWindow;
|
||||
};
|
||||
#endif // #if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#endif // __DECODE_D3D_RENDER_H__
|
||||
62
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/general_allocator.h
vendored
Normal file
62
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/general_allocator.h
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __GENERAL_ALLOCATOR_H__
|
||||
#define __GENERAL_ALLOCATOR_H__
|
||||
|
||||
#include "sample_utils.h"
|
||||
#include "base_allocator.h"
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
class SysMemFrameAllocator;
|
||||
|
||||
// Wrapper on standard allocator for concurrent allocation of
|
||||
// D3D and system surfaces
|
||||
class GeneralAllocator : public BaseFrameAllocator
|
||||
{
|
||||
public:
|
||||
GeneralAllocator();
|
||||
virtual ~GeneralAllocator();
|
||||
|
||||
virtual mfxStatus Init(mfxAllocatorParams *pParams);
|
||||
virtual mfxStatus Close();
|
||||
|
||||
protected:
|
||||
virtual mfxStatus LockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus UnlockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus GetFrameHDL(mfxMemId mid, mfxHDL *handle);
|
||||
|
||||
virtual mfxStatus ReleaseResponse(mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus AllocImpl(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus ReallocImpl(mfxMemId midIn, const mfxFrameInfo *info, mfxU16 memType, mfxMemId *midOut);
|
||||
|
||||
void StoreFrameMids(bool isD3DFrames, mfxFrameAllocResponse *response);
|
||||
bool isD3DMid(mfxHDL mid);
|
||||
|
||||
std::map<mfxHDL, bool> m_Mids;
|
||||
std::unique_ptr<BaseFrameAllocator> m_D3DAllocator;
|
||||
std::unique_ptr<SysMemFrameAllocator> m_SYSAllocator;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(GeneralAllocator);
|
||||
|
||||
};
|
||||
|
||||
#endif //__GENERAL_ALLOCATOR_H__
|
||||
50
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/hw_device.h
vendored
Normal file
50
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/hw_device.h
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mfxvideo++.h"
|
||||
|
||||
/// Base class for hw device
|
||||
class CHWDevice
|
||||
{
|
||||
public:
|
||||
virtual ~CHWDevice(){}
|
||||
/** Initializes device for requested processing.
|
||||
@param[in] hWindow Window handle to bundle device to.
|
||||
@param[in] nViews Number of views to process.
|
||||
@param[in] nAdapterNum Number of adapter to use
|
||||
*/
|
||||
virtual mfxStatus Init(
|
||||
mfxHDL hWindow,
|
||||
mfxU16 nViews,
|
||||
mfxU32 nAdapterNum) = 0;
|
||||
/// Reset device.
|
||||
virtual mfxStatus Reset() = 0;
|
||||
/// Get handle can be used for MFX session SetHandle calls
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *pHdl) = 0;
|
||||
/** Set handle.
|
||||
Particular device implementation may require other objects to operate.
|
||||
*/
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) = 0;
|
||||
virtual mfxStatus RenderFrame(mfxFrameSurface1 * pSurface, mfxFrameAllocator * pmfxAlloc) = 0;
|
||||
virtual void UpdateTitle(double fps) = 0;
|
||||
virtual void SetMondelloInput(bool isMondelloInputEnabled) = 0;
|
||||
virtual void Close() = 0;
|
||||
};
|
||||
62
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/intrusive_ptr.h
vendored
Normal file
62
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/intrusive_ptr.h
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
//intrusive ptr concept
|
||||
//usage examples same as smart pointers except user has to define addref and release routine for that class
|
||||
|
||||
//inline void intrusive_ptr_addref(UserClassA * pResource);
|
||||
//inline void intrusive_ptr_release(UserClassA * pResource);
|
||||
|
||||
template <class T>
|
||||
class intrusive_ptr
|
||||
{
|
||||
T * m_pResource;
|
||||
public:
|
||||
intrusive_ptr(T* pResource = NULL)
|
||||
: m_pResource(pResource) {
|
||||
intrusive_ptr_addref(m_pResource);
|
||||
}
|
||||
intrusive_ptr(const intrusive_ptr<T> & rhs)
|
||||
: m_pResource(rhs.m_pResource) {
|
||||
intrusive_ptr_addref(m_pResource);
|
||||
}
|
||||
void reset(T* pResource) {
|
||||
if (m_pResource){
|
||||
intrusive_ptr_release(m_pResource);
|
||||
}
|
||||
m_pResource = pResource;
|
||||
intrusive_ptr_addref(m_pResource);
|
||||
}
|
||||
T* operator *() {
|
||||
return m_pResource;
|
||||
}
|
||||
T* operator ->() {
|
||||
return m_pResource;
|
||||
}
|
||||
T* get(){
|
||||
return m_pResource;
|
||||
}
|
||||
~intrusive_ptr(){
|
||||
if (m_pResource) {
|
||||
intrusive_ptr_release(m_pResource);
|
||||
}
|
||||
}
|
||||
};
|
||||
399
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_buffering.h
vendored
Normal file
399
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_buffering.h
vendored
Normal file
@@ -0,0 +1,399 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __MFX_BUFFERING_H__
|
||||
#define __MFX_BUFFERING_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <mutex>
|
||||
|
||||
#include "mfxstructures.h"
|
||||
|
||||
#include "vm/strings_defs.h"
|
||||
#include "vm/thread_defs.h"
|
||||
#include "vm/time_defs.h"
|
||||
#include "vm/atomic_defs.h"
|
||||
|
||||
struct msdkFrameSurface
|
||||
{
|
||||
mfxFrameSurface1 frame; // NOTE: this _should_ be the first item (see CBuffering::FindUsedSurface())
|
||||
msdk_tick submit; // tick when frame was submitted for processing
|
||||
mfxU16 render_lock; // signifies that frame is locked for rendering
|
||||
msdkFrameSurface* prev;
|
||||
msdkFrameSurface* next;
|
||||
};
|
||||
|
||||
struct msdkOutputSurface
|
||||
{
|
||||
msdkFrameSurface* surface;
|
||||
mfxSyncPoint syncp;
|
||||
msdkOutputSurface* next;
|
||||
};
|
||||
|
||||
/** \brief Debug purpose macro to terminate execution if buggy situation happenned.
|
||||
*
|
||||
* Use this macro to check impossible, buggy condition which should not occur under
|
||||
* normal circumstances. Macro should be used where check in release mode is not
|
||||
* desirable and atually needed.
|
||||
*/
|
||||
#define MSDK_SELF_CHECK(C)
|
||||
|
||||
class CBuffering;
|
||||
|
||||
// LIFO list of frame surfaces
|
||||
class msdkFreeSurfacesPool
|
||||
{
|
||||
friend class CBuffering;
|
||||
public:
|
||||
msdkFreeSurfacesPool(std::mutex & mutex):
|
||||
m_pSurfaces(NULL),
|
||||
m_rMutex(mutex) {}
|
||||
|
||||
~msdkFreeSurfacesPool() {
|
||||
m_pSurfaces = NULL;
|
||||
}
|
||||
/** \brief The function adds free surface to the free surfaces array.
|
||||
*
|
||||
* @note That's caller responsibility to pass valid surface.
|
||||
* @note We always add and get free surface from the array head. In case not all surfaces
|
||||
* will be actually used we have good chance to avoid actual allocation of the surface memory.
|
||||
*/
|
||||
inline void AddSurface(msdkFrameSurface* surface) {
|
||||
std::lock_guard<std::mutex> lock(m_rMutex);
|
||||
AddSurfaceUnsafe(surface);
|
||||
}
|
||||
/** \brief The function gets the next free surface from the free surfaces array.
|
||||
*
|
||||
* @note Surface is detached from the free surfaces array.
|
||||
*/
|
||||
inline msdkFrameSurface* GetSurface() {
|
||||
std::lock_guard<std::mutex> lock(m_rMutex);
|
||||
return GetSurfaceUnsafe();
|
||||
}
|
||||
|
||||
private:
|
||||
inline void AddSurfaceUnsafe(msdkFrameSurface* surface) {
|
||||
msdkFrameSurface* head;
|
||||
|
||||
MSDK_SELF_CHECK(surface);
|
||||
MSDK_SELF_CHECK(!surface->prev);
|
||||
MSDK_SELF_CHECK(!surface->next);
|
||||
|
||||
head = m_pSurfaces;
|
||||
m_pSurfaces = surface;
|
||||
m_pSurfaces->next = head;
|
||||
}
|
||||
inline msdkFrameSurface* GetSurfaceUnsafe() {
|
||||
|
||||
msdkFrameSurface* surface = NULL;
|
||||
|
||||
if (m_pSurfaces) {
|
||||
surface = m_pSurfaces;
|
||||
m_pSurfaces = m_pSurfaces->next;
|
||||
surface->prev = surface->next = NULL;
|
||||
MSDK_SELF_CHECK(!surface->prev);
|
||||
MSDK_SELF_CHECK(!surface->next);
|
||||
}
|
||||
return surface;
|
||||
}
|
||||
|
||||
protected:
|
||||
msdkFrameSurface* m_pSurfaces;
|
||||
std::mutex & m_rMutex;
|
||||
|
||||
private:
|
||||
msdkFreeSurfacesPool(const msdkFreeSurfacesPool&);
|
||||
void operator=(const msdkFreeSurfacesPool&);
|
||||
};
|
||||
|
||||
// random access, predicted as FIFO
|
||||
class msdkUsedSurfacesPool
|
||||
{
|
||||
friend class CBuffering;
|
||||
public:
|
||||
msdkUsedSurfacesPool(std::mutex & mutex):
|
||||
m_pSurfacesHead(NULL),
|
||||
m_pSurfacesTail(NULL),
|
||||
m_rMutex(mutex) {}
|
||||
|
||||
~msdkUsedSurfacesPool() {
|
||||
m_pSurfacesHead = NULL;
|
||||
m_pSurfacesTail = NULL;
|
||||
}
|
||||
|
||||
/** \brief The function adds surface to the used surfaces array (m_pUsedSurfaces).
|
||||
*
|
||||
* @note That's caller responsibility to pass valid surface.
|
||||
* @note We can't actually know which surface will be returned by the decoder or unlocked. However,
|
||||
* we can make prediction that it will be the oldest surface. Thus, here the function adds new
|
||||
* surface (youngest) to the tail of the least. Check operations for the list will run starting from
|
||||
* head.
|
||||
*/
|
||||
inline void AddSurface(msdkFrameSurface* surface) {
|
||||
std::lock_guard<std::mutex> lock(m_rMutex);
|
||||
AddSurfaceUnsafe(surface);
|
||||
}
|
||||
|
||||
/** \brief The function detaches surface from the used surfaces array.
|
||||
*
|
||||
* @note That's caller responsibility to pass valid surface.
|
||||
*/
|
||||
|
||||
inline void DetachSurface(msdkFrameSurface* surface) {
|
||||
std::lock_guard<std::mutex> lock(m_rMutex);
|
||||
DetachSurfaceUnsafe(surface);
|
||||
}
|
||||
|
||||
private:
|
||||
inline void DetachSurfaceUnsafe(msdkFrameSurface* surface)
|
||||
{
|
||||
MSDK_SELF_CHECK(surface);
|
||||
|
||||
msdkFrameSurface *prev = surface->prev;
|
||||
msdkFrameSurface *next = surface->next;
|
||||
|
||||
if (prev) {
|
||||
prev->next = next;
|
||||
}
|
||||
else {
|
||||
MSDK_SELF_CHECK(surface == m_pSurfacesHead);
|
||||
m_pSurfacesHead = next;
|
||||
}
|
||||
if (next) {
|
||||
next->prev = prev;
|
||||
} else {
|
||||
MSDK_SELF_CHECK(surface == m_pSurfacesTail);
|
||||
m_pSurfacesTail = prev;
|
||||
}
|
||||
|
||||
surface->prev = surface->next = NULL;
|
||||
MSDK_SELF_CHECK(!surface->prev);
|
||||
MSDK_SELF_CHECK(!surface->next);
|
||||
}
|
||||
inline void AddSurfaceUnsafe(msdkFrameSurface* surface)
|
||||
{
|
||||
MSDK_SELF_CHECK(surface);
|
||||
MSDK_SELF_CHECK(!surface->prev);
|
||||
MSDK_SELF_CHECK(!surface->next);
|
||||
|
||||
surface->prev = m_pSurfacesTail;
|
||||
surface->next = NULL;
|
||||
if (m_pSurfacesTail) {
|
||||
m_pSurfacesTail->next = surface;
|
||||
m_pSurfacesTail = m_pSurfacesTail->next;
|
||||
} else {
|
||||
m_pSurfacesHead = m_pSurfacesTail = surface;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
msdkFrameSurface* m_pSurfacesHead; // oldest surface
|
||||
msdkFrameSurface* m_pSurfacesTail; // youngest surface
|
||||
std::mutex & m_rMutex;
|
||||
|
||||
private:
|
||||
msdkUsedSurfacesPool(const msdkUsedSurfacesPool&);
|
||||
void operator=(const msdkUsedSurfacesPool&);
|
||||
};
|
||||
|
||||
// FIFO list of surfaces
|
||||
class msdkOutputSurfacesPool
|
||||
{
|
||||
friend class CBuffering;
|
||||
public:
|
||||
msdkOutputSurfacesPool(std::mutex & mutex):
|
||||
m_pSurfacesHead(NULL),
|
||||
m_pSurfacesTail(NULL),
|
||||
m_SurfacesCount(0),
|
||||
m_rMutex(mutex) {}
|
||||
|
||||
~msdkOutputSurfacesPool() {
|
||||
m_pSurfacesHead = NULL;
|
||||
m_pSurfacesTail = NULL;
|
||||
}
|
||||
|
||||
inline void AddSurface(msdkOutputSurface* surface) {
|
||||
std::lock_guard<std::mutex> lock(m_rMutex);
|
||||
AddSurfaceUnsafe(surface);
|
||||
}
|
||||
inline msdkOutputSurface* GetSurface() {
|
||||
std::lock_guard<std::mutex> lock(m_rMutex);
|
||||
return GetSurfaceUnsafe();
|
||||
}
|
||||
|
||||
inline mfxU32 GetSurfaceCount() {
|
||||
return m_SurfacesCount;
|
||||
}
|
||||
private:
|
||||
inline void AddSurfaceUnsafe(msdkOutputSurface* surface)
|
||||
{
|
||||
MSDK_SELF_CHECK(surface);
|
||||
MSDK_SELF_CHECK(!surface->next);
|
||||
surface->next = NULL;
|
||||
|
||||
if (m_pSurfacesTail) {
|
||||
m_pSurfacesTail->next = surface;
|
||||
m_pSurfacesTail = m_pSurfacesTail->next;
|
||||
} else {
|
||||
m_pSurfacesHead = m_pSurfacesTail = surface;
|
||||
}
|
||||
++m_SurfacesCount;
|
||||
}
|
||||
inline msdkOutputSurface* GetSurfaceUnsafe()
|
||||
{
|
||||
msdkOutputSurface* surface = NULL;
|
||||
|
||||
if (m_pSurfacesHead) {
|
||||
surface = m_pSurfacesHead;
|
||||
m_pSurfacesHead = m_pSurfacesHead->next;
|
||||
if (!m_pSurfacesHead) {
|
||||
// there was only one surface in the array...
|
||||
m_pSurfacesTail = NULL;
|
||||
}
|
||||
--m_SurfacesCount;
|
||||
surface->next = NULL;
|
||||
MSDK_SELF_CHECK(!surface->next);
|
||||
}
|
||||
return surface;
|
||||
}
|
||||
|
||||
protected:
|
||||
msdkOutputSurface* m_pSurfacesHead; // oldest surface
|
||||
msdkOutputSurface* m_pSurfacesTail; // youngest surface
|
||||
mfxU32 m_SurfacesCount;
|
||||
std::mutex & m_rMutex;
|
||||
|
||||
private:
|
||||
msdkOutputSurfacesPool(const msdkOutputSurfacesPool&);
|
||||
void operator=(const msdkOutputSurfacesPool&);
|
||||
};
|
||||
|
||||
/** \brief Helper class defining optimal buffering operations for the Media SDK decoder.
|
||||
*/
|
||||
class CBuffering
|
||||
{
|
||||
public:
|
||||
CBuffering();
|
||||
virtual ~CBuffering();
|
||||
|
||||
protected: // functions
|
||||
mfxStatus AllocBuffers(mfxU32 SurfaceNumber);
|
||||
mfxStatus AllocVppBuffers(mfxU32 VppSurfaceNumber);
|
||||
void AllocOutputBuffer();
|
||||
void FreeBuffers();
|
||||
void ResetBuffers();
|
||||
void ResetVppBuffers();
|
||||
|
||||
/** \brief The function syncs arrays of free and used surfaces.
|
||||
*
|
||||
* If Media SDK used surface for internal needs and unlocked it, the function moves such a surface
|
||||
* back to the free surfaces array.
|
||||
*/
|
||||
void SyncFrameSurfaces();
|
||||
void SyncVppFrameSurfaces();
|
||||
|
||||
/** \brief Returns surface which corresponds to the given one in Media SDK format (mfxFrameSurface1).
|
||||
*
|
||||
* @note This function will not detach the surface from the array, perform this explicitly.
|
||||
*/
|
||||
inline msdkFrameSurface* FindUsedSurface(mfxFrameSurface1* frame)
|
||||
{
|
||||
return (msdkFrameSurface*)(frame);
|
||||
}
|
||||
|
||||
inline void AddFreeOutputSurfaceUnsafe(msdkOutputSurface* surface)
|
||||
{
|
||||
msdkOutputSurface* head = m_pFreeOutputSurfaces;
|
||||
|
||||
MSDK_SELF_CHECK(surface);
|
||||
MSDK_SELF_CHECK(!surface->next);
|
||||
m_pFreeOutputSurfaces = surface;
|
||||
m_pFreeOutputSurfaces->next = head;
|
||||
}
|
||||
inline void AddFreeOutputSurface(msdkOutputSurface* surface) {
|
||||
std::lock_guard<std::mutex> lock(m_Mutex);
|
||||
AddFreeOutputSurfaceUnsafe(surface);
|
||||
}
|
||||
|
||||
inline msdkOutputSurface* GetFreeOutputSurfaceUnsafe(std::unique_lock<std::mutex> & lock)
|
||||
{
|
||||
msdkOutputSurface* surface = NULL;
|
||||
|
||||
if (!m_pFreeOutputSurfaces) {
|
||||
lock.unlock();
|
||||
AllocOutputBuffer();
|
||||
lock.lock();
|
||||
}
|
||||
if (m_pFreeOutputSurfaces) {
|
||||
surface = m_pFreeOutputSurfaces;
|
||||
m_pFreeOutputSurfaces = m_pFreeOutputSurfaces->next;
|
||||
surface->next = NULL;
|
||||
MSDK_SELF_CHECK(!surface->next);
|
||||
}
|
||||
return surface;
|
||||
}
|
||||
inline msdkOutputSurface* GetFreeOutputSurface() {
|
||||
std::unique_lock<std::mutex> lock(m_Mutex);
|
||||
return GetFreeOutputSurfaceUnsafe(lock);
|
||||
}
|
||||
|
||||
/** \brief Function returns surface data to the corresponding buffers.
|
||||
*/
|
||||
inline void ReturnSurfaceToBuffers(msdkOutputSurface* output_surface)
|
||||
{
|
||||
MSDK_SELF_CHECK(output_surface);
|
||||
MSDK_SELF_CHECK(output_surface->surface);
|
||||
MSDK_SELF_CHECK(output_surface->syncp);
|
||||
|
||||
msdk_atomic_dec16(&(output_surface->surface->render_lock));
|
||||
|
||||
output_surface->surface = NULL;
|
||||
output_surface->syncp = NULL;
|
||||
|
||||
AddFreeOutputSurface(output_surface);
|
||||
}
|
||||
|
||||
protected: // variables
|
||||
mfxU32 m_SurfacesNumber;
|
||||
mfxU32 m_OutputSurfacesNumber;
|
||||
msdkFrameSurface* m_pSurfaces;
|
||||
msdkFrameSurface* m_pVppSurfaces;
|
||||
std::mutex m_Mutex;
|
||||
|
||||
// LIFO list of frame surfaces
|
||||
msdkFreeSurfacesPool m_FreeSurfacesPool;
|
||||
msdkFreeSurfacesPool m_FreeVppSurfacesPool;
|
||||
|
||||
// random access, predicted as FIFO
|
||||
msdkUsedSurfacesPool m_UsedSurfacesPool;
|
||||
msdkUsedSurfacesPool m_UsedVppSurfacesPool;
|
||||
|
||||
// LIFO list of output surfaces
|
||||
msdkOutputSurface* m_pFreeOutputSurfaces;
|
||||
|
||||
// FIFO list of surfaces
|
||||
msdkOutputSurfacesPool m_OutputSurfacesPool;
|
||||
msdkOutputSurfacesPool m_DeliveredSurfacesPool;
|
||||
|
||||
private:
|
||||
CBuffering(const CBuffering&);
|
||||
void operator=(const CBuffering&);
|
||||
};
|
||||
|
||||
#endif // __MFX_BUFFERING_H__
|
||||
59
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_itt_trace.h
vendored
Normal file
59
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_itt_trace.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __MFX_ITT_TRACE_H__
|
||||
#define __MFX_ITT_TRACE_H__
|
||||
|
||||
#ifdef ITT_SUPPORT
|
||||
#include <ittnotify.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ITT_SUPPORT
|
||||
|
||||
static inline __itt_domain* mfx_itt_get_domain() {
|
||||
static __itt_domain *domain = NULL;
|
||||
|
||||
if (!domain) domain = __itt_domain_create("MFX_SAMPLES");
|
||||
return domain;
|
||||
}
|
||||
|
||||
class MFX_ITT_Tracer
|
||||
{
|
||||
public:
|
||||
MFX_ITT_Tracer(const char* trace_name)
|
||||
{
|
||||
m_domain = mfx_itt_get_domain();
|
||||
if (m_domain)
|
||||
__itt_task_begin(m_domain, __itt_null, __itt_null, __itt_string_handle_create(trace_name));
|
||||
}
|
||||
~MFX_ITT_Tracer()
|
||||
{
|
||||
if (m_domain) __itt_task_end(m_domain);
|
||||
}
|
||||
private:
|
||||
__itt_domain* m_domain;
|
||||
};
|
||||
#define MFX_ITT_TASK(x) MFX_ITT_Tracer __mfx_itt_tracer(x);
|
||||
|
||||
#else
|
||||
#define MFX_ITT_TASK(x)
|
||||
#endif
|
||||
|
||||
#endif //__MFX_ITT_TRACE_H__
|
||||
27
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_plugin_base.h
vendored
Normal file
27
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_plugin_base.h
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <mfxplugin++.h>
|
||||
|
||||
typedef MFXDecoderPlugin* (*mfxCreateDecoderPlugin)();
|
||||
typedef MFXEncoderPlugin* (*mfxCreateEncoderPlugin)();
|
||||
typedef MFXGenericPlugin* (*mfxCreateGenericPlugin)();
|
||||
40
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_plugin_module.h
vendored
Normal file
40
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_plugin_module.h
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mfxplugin++.h"
|
||||
|
||||
struct PluginModuleTemplate {
|
||||
typedef MFXDecoderPlugin* (*fncCreateDecoderPlugin)();
|
||||
typedef MFXEncoderPlugin* (*fncCreateEncoderPlugin)();
|
||||
typedef MFXAudioDecoderPlugin* (*fncCreateAudioDecoderPlugin)();
|
||||
typedef MFXAudioEncoderPlugin* (*fncCreateAudioEncoderPlugin)();
|
||||
typedef MFXGenericPlugin* (*fncCreateGenericPlugin)();
|
||||
typedef mfxStatus (MFX_CDECL *CreatePluginPtr_t)(mfxPluginUID uid, mfxPlugin* plugin);
|
||||
|
||||
fncCreateDecoderPlugin CreateDecoderPlugin;
|
||||
fncCreateEncoderPlugin CreateEncoderPlugin;
|
||||
fncCreateGenericPlugin CreateGenericPlugin;
|
||||
CreatePluginPtr_t CreatePlugin;
|
||||
fncCreateAudioDecoderPlugin CreateAudioDecoderPlugin;
|
||||
fncCreateAudioEncoderPlugin CreateAudioEncoderPlugin;
|
||||
};
|
||||
|
||||
extern PluginModuleTemplate g_PluginModule;
|
||||
23
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_samples_config.h
vendored
Normal file
23
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/mfx_samples_config.h
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __MFX_SAMPLES_CONFIG__
|
||||
#define __MFX_SAMPLES_CONFIG__
|
||||
|
||||
#endif //__MFX_SAMPLES_CONFIG__
|
||||
73
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/parameters_dumper.h
vendored
Normal file
73
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/parameters_dumper.h
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __PARAMETERS_DUMPER_H__
|
||||
#define __PARAMETERS_DUMPER_H__
|
||||
#include "sample_defs.h"
|
||||
|
||||
class CParametersDumper
|
||||
{
|
||||
protected:
|
||||
static void SerializeFrameInfoStruct(msdk_ostream& sstr,msdk_string prefix,mfxFrameInfo& info);
|
||||
static void SerializeMfxInfoMFXStruct(msdk_ostream& sstr,msdk_string prefix,mfxInfoMFX& info);
|
||||
static void SerializeExtensionBuffer(msdk_ostream& sstr,msdk_string prefix,mfxExtBuffer* pExtBuffer);
|
||||
static void SerializeVPPCompInputStream(msdk_ostream& sstr, msdk_string prefix, mfxVPPCompInputStream& info);
|
||||
|
||||
template <class T>
|
||||
static mfxStatus GetUnitParams(T* pMfxUnit, const mfxVideoParam* pPresetParams, mfxVideoParam* pOutParams)
|
||||
{
|
||||
memset(pOutParams,0, sizeof(mfxVideoParam));
|
||||
mfxExtBuffer** paramsArray = new mfxExtBuffer*[pPresetParams->NumExtParam];
|
||||
for (int paramNum = 0; paramNum < pPresetParams->NumExtParam; paramNum++)
|
||||
{
|
||||
mfxExtBuffer* buf = pPresetParams->ExtParam[paramNum];
|
||||
mfxExtBuffer* newBuf = (mfxExtBuffer*)new mfxU8[buf->BufferSz];
|
||||
memset(newBuf, 0, buf->BufferSz);
|
||||
newBuf->BufferId = buf->BufferId;
|
||||
newBuf->BufferSz = buf->BufferSz;
|
||||
paramsArray[paramNum]=newBuf;
|
||||
}
|
||||
pOutParams->NumExtParam = pPresetParams->NumExtParam;
|
||||
pOutParams->ExtParam = paramsArray;
|
||||
|
||||
mfxStatus sts = pMfxUnit->GetVideoParam(pOutParams);
|
||||
MSDK_CHECK_STATUS_SAFE(sts, "Cannot read configuration from encoder: GetVideoParam failed", ClearExtBuffs(pOutParams));
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
static void ClearExtBuffs(mfxVideoParam* params)
|
||||
{
|
||||
// Cleaning params array
|
||||
for (int paramNum = 0; paramNum < params->NumExtParam; paramNum++)
|
||||
{
|
||||
delete[] params->ExtParam[paramNum];
|
||||
}
|
||||
delete[] params->ExtParam;
|
||||
params->ExtParam = NULL;
|
||||
params->NumExtParam = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
static void SerializeVideoParamStruct(msdk_ostream& sstr,msdk_string sectionName,mfxVideoParam& info,bool shouldUseVPPSection=false);
|
||||
static mfxStatus DumpLibraryConfiguration(msdk_string fileName, MFXVideoDECODE* pMfxDec, MFXVideoVPP* pMfxVPP, MFXVideoENCODE* pMfxEnc,
|
||||
const mfxVideoParam* pDecoderPresetParams, const mfxVideoParam* pVPPPresetParams, const mfxVideoParam* pEncoderPresetParams);
|
||||
static void ShowConfigurationDiff(msdk_ostream& sstr1, msdk_ostream& sstr2);
|
||||
};
|
||||
#endif
|
||||
261
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/plugin_loader.h
vendored
Normal file
261
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/plugin_loader.h
vendored
Normal file
@@ -0,0 +1,261 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __PLUGIN_LOADER_H__
|
||||
#define __PLUGIN_LOADER_H__
|
||||
|
||||
#include "vm/so_defs.h"
|
||||
#include "sample_utils.h"
|
||||
#include "plugin_utils.h"
|
||||
//#include "mfx_plugin_module.h"
|
||||
#include <iostream>
|
||||
#include <iomanip> // for std::setfill, std::setw
|
||||
#include <memory> // for std::unique_ptr
|
||||
|
||||
class MsdkSoModule
|
||||
{
|
||||
protected:
|
||||
msdk_so_handle m_module;
|
||||
public:
|
||||
MsdkSoModule()
|
||||
: m_module(NULL)
|
||||
{
|
||||
}
|
||||
MsdkSoModule(const msdk_string & pluginName)
|
||||
: m_module(NULL)
|
||||
{
|
||||
m_module = msdk_so_load(pluginName.c_str());
|
||||
if (NULL == m_module)
|
||||
{
|
||||
MSDK_TRACE_ERROR(msdk_tstring(MSDK_CHAR("Failed to load shared module: ")) + pluginName);
|
||||
}
|
||||
}
|
||||
template <class T>
|
||||
T GetAddr(const std::string & fncName)
|
||||
{
|
||||
T pCreateFunc = reinterpret_cast<T>(msdk_so_get_addr(m_module, fncName.c_str()));
|
||||
if (NULL == pCreateFunc) {
|
||||
MSDK_TRACE_ERROR(msdk_tstring("Failed to get function addres: ") + fncName.c_str());
|
||||
}
|
||||
return pCreateFunc;
|
||||
}
|
||||
|
||||
virtual ~MsdkSoModule()
|
||||
{
|
||||
if (m_module)
|
||||
{
|
||||
msdk_so_free(m_module);
|
||||
m_module = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Rationale: class to load+register any mediasdk plugin decoder/encoder/generic by given name
|
||||
*/
|
||||
class PluginLoader : public MFXPlugin
|
||||
{
|
||||
protected:
|
||||
mfxPluginType ePluginType;
|
||||
|
||||
mfxSession m_session;
|
||||
mfxPluginUID m_uid;
|
||||
|
||||
private:
|
||||
const msdk_char* msdkGetPluginName(const mfxPluginUID& guid)
|
||||
{
|
||||
if (AreGuidsEqual(guid, MFX_PLUGINID_HEVCD_SW))
|
||||
return MSDK_STRING("Intel (R) Media SDK plugin for HEVC DECODE");
|
||||
else if(AreGuidsEqual(guid, MFX_PLUGINID_HEVCD_HW))
|
||||
return MSDK_STRING("Intel (R) Media SDK HW plugin for HEVC DECODE");
|
||||
else if(AreGuidsEqual(guid, MFX_PLUGINID_HEVCE_SW))
|
||||
return MSDK_STRING("Intel (R) Media SDK plugin for HEVC ENCODE");
|
||||
else if(AreGuidsEqual(guid, MFX_PLUGINID_HEVCE_HW))
|
||||
return MSDK_STRING("Intel (R) Media SDK HW plugin for HEVC ENCODE");
|
||||
else if(AreGuidsEqual(guid, MFX_PLUGINID_VP8E_HW))
|
||||
return MSDK_STRING("Intel (R) Media SDK HW plugin for VP8 ENCODE");
|
||||
else if(AreGuidsEqual(guid, MFX_PLUGINID_VP8D_HW))
|
||||
return MSDK_STRING("Intel (R) Media SDK HW plugin for VP8 DECODE");
|
||||
else if(AreGuidsEqual(guid, MFX_PLUGINID_VP9E_HW))
|
||||
return MSDK_STRING("Intel (R) Media SDK HW plugin for VP9 ENCODE");
|
||||
else if(AreGuidsEqual(guid, MFX_PLUGINID_VP9D_HW))
|
||||
return MSDK_STRING("Intel (R) Media SDK HW plugin for VP9 DECODE");
|
||||
else if(AreGuidsEqual(guid, MFX_PLUGINID_H264LA_HW))
|
||||
return MSDK_STRING("Intel (R) Media SDK plugin for LA ENC");
|
||||
else if(AreGuidsEqual(guid, MFX_PLUGINID_ITELECINE_HW))
|
||||
return MSDK_STRING("Intel (R) Media SDK PTIR plugin (HW)");
|
||||
else if (AreGuidsEqual(guid, MFX_PLUGINID_HEVCE_GACC))
|
||||
return MSDK_STRING("Intel (R) Media SDK GPU-Accelerated plugin for HEVC ENCODE");
|
||||
else
|
||||
#if (MFX_VERSION >= 1027) && !defined(_WIN32) && !defined(_WIN64)
|
||||
if (AreGuidsEqual(guid, MFX_PLUGINID_HEVC_FEI_ENCODE))
|
||||
return MSDK_STRING("Intel (R) Media SDK HW plugin for HEVC FEI ENCODE");
|
||||
else
|
||||
#endif
|
||||
return MSDK_STRING("Unknown plugin");
|
||||
}
|
||||
|
||||
public:
|
||||
PluginLoader(mfxPluginType type, mfxSession session, const mfxPluginUID & uid, mfxU32 version, const mfxChar *pluginName, mfxU32 len)
|
||||
: ePluginType(type)
|
||||
, m_session()
|
||||
, m_uid()
|
||||
{
|
||||
mfxStatus sts = MFX_ERR_NONE;
|
||||
msdk_stringstream strStream;
|
||||
|
||||
MSDK_MEMCPY(&m_uid, &uid, sizeof(mfxPluginUID));
|
||||
for (size_t i = 0; i != sizeof(mfxPluginUID); i++)
|
||||
{
|
||||
strStream << MSDK_STRING("0x") << std::setfill(MSDK_CHAR('0')) << std::setw(2) << std::hex << (int)m_uid.Data[i];
|
||||
if (i != (sizeof(mfxPluginUID)-1)) strStream << MSDK_STRING(", ");
|
||||
}
|
||||
|
||||
if ((ePluginType == MFX_PLUGINTYPE_AUDIO_DECODE) ||
|
||||
(ePluginType == MFX_PLUGINTYPE_AUDIO_ENCODE))
|
||||
{
|
||||
// Audio plugins are not loaded by path
|
||||
sts = MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
sts = MFXVideoUSER_LoadByPath(session, &m_uid, version, pluginName, len);
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != sts)
|
||||
{
|
||||
MSDK_TRACE_ERROR(MSDK_STRING("Failed to load plugin from GUID, sts=") << sts << MSDK_STRING(": { ") << strStream.str().c_str() << MSDK_STRING(" } (") << msdkGetPluginName(m_uid) << MSDK_STRING(")"));
|
||||
}
|
||||
else
|
||||
{
|
||||
MSDK_TRACE_INFO(MSDK_STRING("Plugin was loaded from GUID"));
|
||||
m_session = session;
|
||||
}
|
||||
}
|
||||
|
||||
PluginLoader(mfxPluginType type, mfxSession session, const mfxPluginUID & uid, mfxU32 version)
|
||||
: ePluginType(type)
|
||||
, m_session()
|
||||
, m_uid()
|
||||
{
|
||||
mfxStatus sts = MFX_ERR_NONE;
|
||||
msdk_stringstream strStream;
|
||||
|
||||
MSDK_MEMCPY(&m_uid, &uid, sizeof(mfxPluginUID));
|
||||
for (size_t i = 0; i != sizeof(mfxPluginUID); i++)
|
||||
{
|
||||
strStream << MSDK_STRING("0x") << std::setfill(MSDK_CHAR('0')) << std::setw(2) << std::hex << (int)m_uid.Data[i];
|
||||
if (i != (sizeof(mfxPluginUID)-1)) strStream << MSDK_STRING(", ");
|
||||
}
|
||||
|
||||
if ((ePluginType == MFX_PLUGINTYPE_AUDIO_DECODE) ||
|
||||
(ePluginType == MFX_PLUGINTYPE_AUDIO_ENCODE))
|
||||
{
|
||||
sts = MFXAudioUSER_Load(session, &m_uid, version);
|
||||
}
|
||||
else
|
||||
{
|
||||
sts = MFXVideoUSER_Load(session, &m_uid, version);
|
||||
}
|
||||
|
||||
if (MFX_ERR_NONE != sts)
|
||||
{
|
||||
MSDK_TRACE_ERROR(MSDK_STRING("Failed to load plugin from GUID, sts=") << sts << MSDK_STRING(": { ") << strStream.str().c_str() << MSDK_STRING(" } (") << msdkGetPluginName(m_uid) << MSDK_STRING(")"));
|
||||
}
|
||||
else
|
||||
{
|
||||
MSDK_TRACE_INFO(MSDK_STRING("Plugin was loaded from GUID")<< MSDK_STRING(": { ") << strStream.str().c_str() << MSDK_STRING(" } (") << msdkGetPluginName(m_uid) << MSDK_STRING(")"));
|
||||
m_session = session;
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~PluginLoader()
|
||||
{
|
||||
mfxStatus sts = MFX_ERR_NONE;
|
||||
if (m_session)
|
||||
{
|
||||
if ((ePluginType == MFX_PLUGINTYPE_AUDIO_DECODE) ||
|
||||
(ePluginType == MFX_PLUGINTYPE_AUDIO_ENCODE))
|
||||
{
|
||||
sts = MFXAudioUSER_UnLoad(m_session, &m_uid);
|
||||
}
|
||||
else
|
||||
{
|
||||
sts = MFXVideoUSER_UnLoad(m_session, &m_uid);
|
||||
}
|
||||
|
||||
if (sts != MFX_ERR_NONE)
|
||||
{
|
||||
MSDK_TRACE_ERROR(MSDK_STRING("Failed to unload plugin from GUID, sts=") << sts);
|
||||
}
|
||||
else
|
||||
{
|
||||
MSDK_TRACE_INFO(MSDK_STRING("MFXBaseUSER_UnLoad(session=0x") << m_session << MSDK_STRING("), sts=") << sts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IsOk() {
|
||||
return m_session != 0;
|
||||
}
|
||||
virtual mfxStatus PluginInit( mfxCoreInterface * /*core*/ ) {
|
||||
return MFX_ERR_NULL_PTR;
|
||||
}
|
||||
virtual mfxStatus PluginClose() {
|
||||
return MFX_ERR_NULL_PTR;
|
||||
}
|
||||
virtual mfxStatus GetPluginParam( mfxPluginParam * /*par*/ ) {
|
||||
return MFX_ERR_NULL_PTR;
|
||||
}
|
||||
virtual mfxStatus Execute( mfxThreadTask /*task*/, mfxU32 /*uid_p*/, mfxU32 /*uid_a*/ ) {
|
||||
return MFX_ERR_NULL_PTR;
|
||||
}
|
||||
virtual mfxStatus FreeResources( mfxThreadTask /*task*/, mfxStatus /*sts*/ ) {
|
||||
return MFX_ERR_NULL_PTR;
|
||||
}
|
||||
virtual void Release() {
|
||||
}
|
||||
virtual mfxStatus Close() {
|
||||
return MFX_ERR_NULL_PTR;
|
||||
}
|
||||
virtual mfxStatus SetAuxParams( void* /*auxParam*/, int /*auxParamSize*/ ) {
|
||||
return MFX_ERR_NULL_PTR;
|
||||
}
|
||||
};
|
||||
|
||||
inline MFXPlugin * LoadPluginByType(mfxPluginType type, mfxSession session, const mfxPluginUID & uid, mfxU32 version, const mfxChar *pluginName, mfxU32 len) {
|
||||
std::unique_ptr<PluginLoader> plg(new PluginLoader (type, session, uid, version, pluginName, len));
|
||||
return plg->IsOk() ? plg.release() : NULL;
|
||||
}
|
||||
|
||||
inline MFXPlugin * LoadPluginByGUID(mfxPluginType type, mfxSession session, const mfxPluginUID & uid, mfxU32 version) {
|
||||
std::unique_ptr<PluginLoader> plg(new PluginLoader (type, session, uid, version));
|
||||
return plg->IsOk() ? plg.release() : NULL;
|
||||
}
|
||||
|
||||
inline MFXPlugin * LoadPlugin(mfxPluginType type, mfxSession session, const mfxPluginUID & uid, mfxU32 version, const mfxChar *pluginName, mfxU32 len) {
|
||||
return LoadPluginByType(type, session, uid, version, pluginName, len);
|
||||
}
|
||||
|
||||
inline MFXPlugin * LoadPlugin(mfxPluginType type, mfxSession session, const mfxPluginUID & uid, mfxU32 version) {
|
||||
return LoadPluginByGUID(type, session, uid, version);
|
||||
}
|
||||
#endif // PLUGIN_LOADER
|
||||
72
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/plugin_utils.h
vendored
Normal file
72
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/plugin_utils.h
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __PLUGIN_UTILS_H__
|
||||
#define __PLUGIN_UTILS_H__
|
||||
|
||||
#include "sample_defs.h"
|
||||
#include "sample_types.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define MSDK_CPU_ROTATE_PLUGIN MSDK_STRING("sample_rotate_plugin.dll")
|
||||
#define MSDK_OCL_ROTATE_PLUGIN MSDK_STRING("sample_plugin_opencl.dll")
|
||||
#else
|
||||
#define MSDK_CPU_ROTATE_PLUGIN MSDK_STRING("libsample_rotate_plugin.so")
|
||||
#define MSDK_OCL_ROTATE_PLUGIN MSDK_STRING("libsample_plugin_opencl.so")
|
||||
#endif
|
||||
|
||||
typedef mfxI32 msdkComponentType;
|
||||
enum
|
||||
{
|
||||
MSDK_VDECODE = 0x0001,
|
||||
MSDK_VENCODE = 0x0002,
|
||||
MSDK_VPP = 0x0004,
|
||||
MSDK_VENC = 0x0008,
|
||||
#if (MFX_VERSION >= 1027)
|
||||
MSDK_FEI = 0x1000,
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
MFX_PLUGINLOAD_TYPE_GUID = 1,
|
||||
MFX_PLUGINLOAD_TYPE_FILE = 2
|
||||
} MfxPluginLoadType;
|
||||
|
||||
struct sPluginParams
|
||||
{
|
||||
mfxPluginUID pluginGuid;
|
||||
mfxChar strPluginPath[MSDK_MAX_FILENAME_LEN];
|
||||
MfxPluginLoadType type;
|
||||
sPluginParams()
|
||||
{
|
||||
MSDK_ZERO_MEMORY(*this);
|
||||
}
|
||||
};
|
||||
|
||||
static const mfxPluginUID MSDK_PLUGINGUID_NULL = {{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
||||
|
||||
bool AreGuidsEqual(const mfxPluginUID& guid1, const mfxPluginUID& guid2);
|
||||
|
||||
const mfxPluginUID & msdkGetPluginUID(mfxIMPL impl, msdkComponentType type, mfxU32 uCodecid);
|
||||
|
||||
sPluginParams ParsePluginGuid(msdk_char* );
|
||||
sPluginParams ParsePluginPath(msdk_char* );
|
||||
mfxStatus ConvertStringToGuid(const msdk_string & strGuid, mfxPluginUID & mfxGuid);
|
||||
|
||||
#endif //__PLUGIN_UTILS_H__
|
||||
127
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/preset_manager.h
vendored
Normal file
127
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/preset_manager.h
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#include "sample_defs.h"
|
||||
|
||||
#pragma once
|
||||
enum EPresetModes
|
||||
{
|
||||
PRESET_DEFAULT,
|
||||
PRESET_DSS,
|
||||
PRESET_CONF,
|
||||
PRESET_GAMING,
|
||||
PRESET_MAX_MODES
|
||||
};
|
||||
|
||||
enum EPresetCodecs
|
||||
{
|
||||
PRESET_AVC,
|
||||
PRESET_HEVC,
|
||||
PRESET_MAX_CODECS
|
||||
};
|
||||
|
||||
struct CPresetParameters
|
||||
{
|
||||
mfxU16 GopRefDist;
|
||||
|
||||
mfxU16 TargetUsage;
|
||||
|
||||
mfxU16 RateControlMethod;
|
||||
mfxU16 ExtBRCUsage;
|
||||
mfxU16 AsyncDepth;
|
||||
mfxU16 BRefType;
|
||||
mfxU16 AdaptiveMaxFrameSize;
|
||||
mfxU16 LowDelayBRC;
|
||||
|
||||
mfxU16 IntRefType;
|
||||
mfxU16 IntRefCycleSize;
|
||||
mfxU16 IntRefQPDelta;
|
||||
mfxU16 IntRefCycleDist;
|
||||
|
||||
mfxU16 WeightedPred;
|
||||
mfxU16 WeightedBiPred;
|
||||
|
||||
bool EnableBPyramid;
|
||||
bool EnablePPyramid;
|
||||
// bool EnableLTR;
|
||||
};
|
||||
|
||||
struct CDependentPresetParameters
|
||||
{
|
||||
mfxU16 TargetKbps;
|
||||
mfxU16 MaxKbps;
|
||||
mfxU16 GopPicSize;
|
||||
mfxU16 BufferSizeInKB;
|
||||
mfxU16 LookAheadDepth;
|
||||
mfxU32 MaxFrameSize;
|
||||
};
|
||||
|
||||
struct COutputPresetParameters : public CPresetParameters,CDependentPresetParameters
|
||||
{
|
||||
|
||||
msdk_string PresetName;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
memset(dynamic_cast<CPresetParameters*>(this), 0, sizeof(CPresetParameters));
|
||||
memset(dynamic_cast<CDependentPresetParameters*>(this), 0, sizeof(CDependentPresetParameters));
|
||||
}
|
||||
|
||||
COutputPresetParameters()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
COutputPresetParameters(CPresetParameters src)
|
||||
{
|
||||
Clear();
|
||||
*(CPresetParameters*)this = src;
|
||||
}
|
||||
};
|
||||
|
||||
class CPresetManager
|
||||
{
|
||||
public:
|
||||
~CPresetManager();
|
||||
COutputPresetParameters GetPreset(EPresetModes mode, mfxU32 codecFourCC, mfxF64 fps, mfxU32 width, mfxU32 height, bool isHWLib);
|
||||
COutputPresetParameters GetBasicPreset(EPresetModes mode, mfxU32 codecFourCC);
|
||||
CDependentPresetParameters GetDependentPresetParameters(EPresetModes mode, mfxU32 codecFourCC, mfxF64 fps, mfxU32 width, mfxU32 height, mfxU16 targetUsage);
|
||||
|
||||
static CPresetManager Inst;
|
||||
static EPresetModes PresetNameToMode(const msdk_char* name);
|
||||
protected:
|
||||
CPresetManager();
|
||||
static CPresetParameters presets[PRESET_MAX_MODES][PRESET_MAX_CODECS];
|
||||
static msdk_string modesName[PRESET_MAX_MODES];
|
||||
};
|
||||
|
||||
#define MODIFY_AND_PRINT_PARAM(paramName,presetName,shouldPrintPresetInfo) \
|
||||
if (!paramName){ \
|
||||
paramName = presetParams.presetName; \
|
||||
if(shouldPrintPresetInfo){msdk_printf(MSDK_STRING(#presetName) MSDK_STRING(": %d\n"), (int)paramName);} \
|
||||
}else{ \
|
||||
if(shouldPrintPresetInfo){msdk_printf(MSDK_STRING(#presetName) MSDK_STRING(": %d (original preset value: %d)\n"), (int)paramName, (int)presetParams.presetName);}}
|
||||
|
||||
#define MODIFY_AND_PRINT_PARAM_EXT(paramName,presetName,value,shouldPrintPresetInfo) \
|
||||
if (!paramName){ \
|
||||
paramName = (value); \
|
||||
if(shouldPrintPresetInfo){msdk_printf(MSDK_STRING(#presetName) MSDK_STRING(": %d\n"), (int)paramName);} \
|
||||
}else{ \
|
||||
if(shouldPrintPresetInfo){msdk_printf(MSDK_STRING(#presetName) MSDK_STRING(": %d (original preset value: %d)\n"), (int)paramName, (int)(value));}}
|
||||
|
||||
204
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/sample_defs.h
vendored
Normal file
204
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/sample_defs.h
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2020, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __SAMPLE_DEFS_H__
|
||||
#define __SAMPLE_DEFS_H__
|
||||
|
||||
#include <memory.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#include "vm/strings_defs.h"
|
||||
#include "vm/file_defs.h"
|
||||
#include "vm/time_defs.h"
|
||||
|
||||
// Run-time HSBC
|
||||
// the condition below must be changed to MFX_VERSION >= 1027 after API is promoted to 1.27
|
||||
#if (MFX_VERSION >= MFX_VERSION_NEXT)
|
||||
#define ENABLE_VPP_RUNTIME_HSBC
|
||||
#endif
|
||||
|
||||
#if (MFX_VERSION >= 1026)
|
||||
#define ENABLE_MCTF
|
||||
#if defined(MFX_VERSION_NEXT) && (MFX_VERSION >= MFX_VERSION_NEXT)
|
||||
//---MCTF, extended interface
|
||||
#undef ENABLE_MCTF_EXT
|
||||
#endif
|
||||
enum {MCTF_BITRATE_MULTIPLIER = 100000};
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(WIN32) || defined(WIN64)
|
||||
|
||||
enum {
|
||||
MFX_HANDLE_DEVICEWINDOW = 0x101 /* A handle to the render window */
|
||||
}; //mfxHandleType
|
||||
|
||||
#ifndef D3D_SURFACES_SUPPORT
|
||||
#define D3D_SURFACES_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(MFX_D3D11_SUPPORT)
|
||||
#include <sdkddkver.h>
|
||||
#if (NTDDI_VERSION >= NTDDI_VERSION_FROM_WIN32_WINNT2(0x0602)) // >= _WIN32_WINNT_WIN8
|
||||
#define MFX_D3D11_SUPPORT 1 // Enable D3D11 support if SDK allows
|
||||
#else
|
||||
#define MFX_D3D11_SUPPORT 0
|
||||
#endif
|
||||
#endif // #if defined(WIN32) && !defined(MFX_D3D11_SUPPORT)
|
||||
#endif // #if defined(WIN32) || defined(WIN64)
|
||||
|
||||
enum
|
||||
{
|
||||
#define __DECLARE(type) MFX_MONITOR_ ## type
|
||||
__DECLARE(Unknown) = 0,
|
||||
__DECLARE(AUTO) = __DECLARE(Unknown),
|
||||
__DECLARE(VGA),
|
||||
__DECLARE(DVII),
|
||||
__DECLARE(DVID),
|
||||
__DECLARE(DVIA),
|
||||
__DECLARE(Composite),
|
||||
__DECLARE(SVIDEO),
|
||||
__DECLARE(LVDS),
|
||||
__DECLARE(Component),
|
||||
__DECLARE(9PinDIN),
|
||||
__DECLARE(HDMIA),
|
||||
__DECLARE(HDMIB),
|
||||
__DECLARE(eDP),
|
||||
__DECLARE(TV),
|
||||
__DECLARE(DisplayPort),
|
||||
#if defined(DRM_MODE_CONNECTOR_VIRTUAL) // from libdrm 2.4.59
|
||||
__DECLARE(VIRTUAL),
|
||||
#endif
|
||||
#if defined(DRM_MODE_CONNECTOR_DSI) // from libdrm 2.4.59
|
||||
__DECLARE(DSI),
|
||||
#endif
|
||||
__DECLARE(MAXNUMBER)
|
||||
#undef __DECLARE
|
||||
};
|
||||
|
||||
#if defined(LIBVA_SUPPORT)
|
||||
|
||||
enum LibVABackend
|
||||
{
|
||||
MFX_LIBVA_AUTO,
|
||||
MFX_LIBVA_DRM,
|
||||
MFX_LIBVA_DRM_RENDERNODE = MFX_LIBVA_DRM,
|
||||
MFX_LIBVA_DRM_MODESET,
|
||||
MFX_LIBVA_X11,
|
||||
MFX_LIBVA_WAYLAND
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//affects win32 winnt version macro
|
||||
#include "vm/time_defs.h"
|
||||
#include "sample_utils.h"
|
||||
|
||||
|
||||
#define MSDK_DEC_WAIT_INTERVAL 300000
|
||||
#define MSDK_ENC_WAIT_INTERVAL 300000
|
||||
#define MSDK_VPP_WAIT_INTERVAL 300000
|
||||
#define MSDK_SURFACE_WAIT_INTERVAL 300000
|
||||
#define MSDK_WAIT_INTERVAL (MSDK_DEC_WAIT_INTERVAL+3*MSDK_VPP_WAIT_INTERVAL+MSDK_ENC_WAIT_INTERVAL) // an estimate for the longest pipeline we have in samples
|
||||
|
||||
#define MSDK_INVALID_SURF_IDX 0xFFFF
|
||||
|
||||
#define MSDK_MAX_FILENAME_LEN 1024
|
||||
#define MSDK_MAX_USER_DATA_UNREG_SEI_LEN 80
|
||||
|
||||
#define MSDK_PRINT_RET_MSG(ERR,MSG) {msdk_stringstream tmpStr1;tmpStr1<<std::endl<<"[ERROR], sts=" \
|
||||
<<StatusToString(ERR)<<"("<<ERR<<")"<<", "<<__FUNCTION__<<", "<<MSG<<" at "<<__FILE__<<":"<<__LINE__<<std::endl;msdk_err<<tmpStr1.str();}
|
||||
|
||||
#define MSDK_PRINT_WRN_MSG(WRN,MSG) {msdk_stringstream tmpStr1;tmpStr1<<std::endl<<"[WARNING], sts=" \
|
||||
<<StatusToString(WRN)<<"("<<WRN<<")"<<", "<<__FUNCTION__<<", "<<MSG<<" at "<<__FILE__<<":"<<__LINE__<<std::endl;msdk_err<<tmpStr1.str();}
|
||||
|
||||
#define MSDK_TRACE_LEVEL(level, ERR) if (level <= msdk_trace_get_level()) {msdk_err<<NoFullPath(MSDK_STRING(__FILE__)) << MSDK_STRING(" :")<< __LINE__ <<MSDK_STRING(" [") \
|
||||
<<level<<MSDK_STRING("] ") << ERR << std::endl;}
|
||||
|
||||
#define MSDK_TRACE_CRITICAL(ERR) MSDK_TRACE_LEVEL(MSDK_TRACE_LEVEL_CRITICAL, ERR)
|
||||
#define MSDK_TRACE_ERROR(ERR) MSDK_TRACE_LEVEL(MSDK_TRACE_LEVEL_ERROR, ERR)
|
||||
#define MSDK_TRACE_WARNING(ERR) MSDK_TRACE_LEVEL(MSDK_TRACE_LEVEL_WARNING, ERR)
|
||||
#define MSDK_TRACE_INFO(ERR) MSDK_TRACE_LEVEL(MSDK_TRACE_LEVEL_INFO, ERR)
|
||||
#define MSDK_TRACE_DEBUG(ERR) MSDK_TRACE_LEVEL(MSDK_TRACE_LEVEL_DEBUG, ERR)
|
||||
|
||||
#define MSDK_CHECK_ERROR(P, X, ERR) {if ((X) == (P)) {msdk_stringstream tmpStr2;tmpStr2<<MSDK_STRING(#X)<<MSDK_STRING("==")<<MSDK_STRING(#P)<<MSDK_STRING(" error"); \
|
||||
MSDK_PRINT_RET_MSG(ERR, tmpStr2.str().c_str()); return ERR;}}
|
||||
|
||||
#define MSDK_CHECK_NOT_EQUAL(P, X, ERR) {if ((X) != (P)) {msdk_stringstream tmpStr3;tmpStr3<<MSDK_STRING(#X)<<MSDK_STRING("!=")<<MSDK_STRING(#P)<<MSDK_STRING(" error"); \
|
||||
MSDK_PRINT_RET_MSG(ERR, tmpStr3.str().c_str()); return ERR;}}
|
||||
|
||||
#define MSDK_CHECK_STATUS(X, MSG) {if ((X) < MFX_ERR_NONE) {MSDK_PRINT_RET_MSG(X, MSG); return X;}}
|
||||
#define MSDK_CHECK_STATUS_NO_RET(X, MSG) {if ((X) < MFX_ERR_NONE) {MSDK_PRINT_RET_MSG(X, MSG);}}
|
||||
#define MSDK_CHECK_WRN(X, MSG) {if ((X) > MFX_ERR_NONE) {MSDK_PRINT_WRN_MSG(X, MSG); }}
|
||||
#define MSDK_CHECK_ERR_NONE_STATUS(X, ERR, MSG) {if ((X) != MFX_ERR_NONE) {MSDK_PRINT_RET_MSG(X, MSG); return ERR;}}
|
||||
#define MSDK_CHECK_PARSE_RESULT(P, X, ERR) {if ((X) > (P)) {return ERR;}}
|
||||
|
||||
#define MSDK_CHECK_STATUS_SAFE(X, FUNC, ADD) {if ((X) < MFX_ERR_NONE) {ADD; MSDK_PRINT_RET_MSG(X, FUNC); return X;}}
|
||||
#define MSDK_IGNORE_MFX_STS(P, X) {if ((X) == (P)) {P = MFX_ERR_NONE;}}
|
||||
#define MSDK_CHECK_POINTER(P, ...) {if (!(P)) {msdk_stringstream tmpStr4;tmpStr4<<MSDK_STRING(#P)<<MSDK_STRING(" pointer is NULL");MSDK_PRINT_RET_MSG(MFX_ERR_NULL_PTR, tmpStr4.str().c_str());return __VA_ARGS__;}}
|
||||
#define MSDK_CHECK_POINTER_NO_RET(P) {if (!(P)) {msdk_stringstream tmpStr4;tmpStr4<<MSDK_STRING(#P)<<MSDK_STRING(" pointer is NULL");MSDK_PRINT_RET_MSG(MFX_ERR_NULL_PTR, tmpStr4.str().c_str());return;}}
|
||||
#define MSDK_CHECK_POINTER_SAFE(P, ERR, ADD) {if (!(P)) {ADD; return ERR;}}
|
||||
#define MSDK_BREAK_ON_ERROR(P) {if (MFX_ERR_NONE != (P)) break;}
|
||||
#define MSDK_SAFE_DELETE_ARRAY(P) {if (P) {delete[] P; P = NULL;}}
|
||||
#define MSDK_SAFE_RELEASE(X) {if (X) { X->Release(); X = NULL; }}
|
||||
#define MSDK_SAFE_FREE(X) {if (X) { free(X); X = NULL; }}
|
||||
|
||||
#ifndef MSDK_SAFE_DELETE
|
||||
#define MSDK_SAFE_DELETE(P) {if (P) {delete P; P = NULL;}}
|
||||
#endif // MSDK_SAFE_DELETE
|
||||
|
||||
#define MSDK_ZERO_MEMORY(VAR) {memset(&VAR, 0, sizeof(VAR));}
|
||||
#define MSDK_ALIGN16(value) (((value + 15) >> 4) << 4) // round up to a multiple of 16
|
||||
#define MSDK_ALIGN32(value) (((value + 31) >> 5) << 5) // round up to a multiple of 32
|
||||
#define MSDK_ALIGN(value, alignment) (alignment) * ( (value) / (alignment) + (((value) % (alignment)) ? 1 : 0))
|
||||
#define MSDK_ARRAY_LEN(value) (sizeof(value) / sizeof(value[0]))
|
||||
|
||||
#ifndef UNREFERENCED_PARAMETER
|
||||
#define UNREFERENCED_PARAMETER(par) (par)
|
||||
#endif
|
||||
|
||||
#define MFX_IMPL_VIA_MASK(x) (0x0f00 & (x))
|
||||
|
||||
// Deprecated
|
||||
#define MSDK_PRINT_RET_MSG_(ERR) {msdk_printf(MSDK_STRING("\nReturn on error: error code %d,\t%s\t%d\n\n"), (int)ERR, MSDK_STRING(__FILE__), __LINE__);}
|
||||
#define MSDK_CHECK_RESULT(P, X, ERR) {if ((X) > (P)) {MSDK_PRINT_RET_MSG_(ERR); return ERR;}}
|
||||
#define MSDK_CHECK_RESULT_SAFE(P, X, ERR, ADD) {if ((X) > (P)) {ADD; MSDK_PRINT_RET_MSG_(ERR); return ERR;}}
|
||||
|
||||
namespace mfx
|
||||
{
|
||||
// TODO: switch to std::clamp when C++17 support will be enabled
|
||||
|
||||
// Clip value v to range [lo, hi]
|
||||
template<class T>
|
||||
constexpr const T& clamp( const T& v, const T& lo, const T& hi )
|
||||
{
|
||||
return std::min(hi, std::max(v, lo));
|
||||
}
|
||||
|
||||
// Comp is comparison function object with meaning of 'less' operator (i.e. std::less<> or operator<)
|
||||
template<class T, class Compare>
|
||||
constexpr const T& clamp( const T& v, const T& lo, const T& hi, Compare comp )
|
||||
{
|
||||
return comp(v, lo) ? lo : comp(hi, v) ? hi : v;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //__SAMPLE_DEFS_H__
|
||||
|
||||
52
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/sample_types.h
vendored
Normal file
52
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/sample_types.h
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __SAMPLE_TYPES_H__
|
||||
#define __SAMPLE_TYPES_H__
|
||||
|
||||
#ifdef UNICODE
|
||||
#define msdk_cout std::wcout
|
||||
#define msdk_err std::wcerr
|
||||
#else
|
||||
#define msdk_cout std::cout
|
||||
#define msdk_err std::cerr
|
||||
#endif
|
||||
|
||||
typedef std::basic_string<msdk_char> msdk_string;
|
||||
typedef std::basic_stringstream<msdk_char> msdk_stringstream;
|
||||
typedef std::basic_ostream<msdk_char, std::char_traits<msdk_char> > msdk_ostream;
|
||||
typedef std::basic_istream<msdk_char, std::char_traits<msdk_char> > msdk_istream;
|
||||
typedef std::basic_fstream<msdk_char, std::char_traits<msdk_char> > msdk_fstream;
|
||||
|
||||
#if defined(_UNICODE)
|
||||
#define MSDK_MAKE_BYTE_STRING(src,dest) \
|
||||
{\
|
||||
std::wstring wstr(src);\
|
||||
std::string str(wstr.length(), 0);\
|
||||
std::transform(wstr.begin(), wstr.end(), str.begin(), [](wchar_t c) {\
|
||||
return (char)c;\
|
||||
});\
|
||||
strcpy_s(dest, str.c_str());\
|
||||
}
|
||||
#else
|
||||
#define MSDK_MAKE_BYTE_STRING(src,dest) msdk_strcopy(dest, src);
|
||||
#endif
|
||||
|
||||
|
||||
#endif //__SAMPLE_TYPES_H__
|
||||
1495
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/sample_utils.h
vendored
Normal file
1495
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/sample_utils.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
69
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/surface_auto_lock.h
vendored
Normal file
69
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/surface_auto_lock.h
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mfxstructures.h"
|
||||
#include "sample_utils.h"
|
||||
|
||||
/*
|
||||
Rationale: locks allocator if necessary to get RAW pointers, unlock it at the end
|
||||
*/
|
||||
class SurfaceAutoLock : private no_copy
|
||||
{
|
||||
public:
|
||||
SurfaceAutoLock(mfxFrameAllocator & alloc, mfxFrameSurface1 &srf)
|
||||
: m_alloc(alloc) , m_srf(srf), m_lockRes(MFX_ERR_NONE), m_bLocked() {
|
||||
LockFrame();
|
||||
}
|
||||
operator mfxStatus () {
|
||||
return m_lockRes;
|
||||
}
|
||||
~SurfaceAutoLock() {
|
||||
UnlockFrame();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
mfxFrameAllocator & m_alloc;
|
||||
mfxFrameSurface1 & m_srf;
|
||||
mfxStatus m_lockRes;
|
||||
bool m_bLocked;
|
||||
|
||||
void LockFrame()
|
||||
{
|
||||
//no allocator used, no need to do lock
|
||||
if (m_srf.Data.Y != 0)
|
||||
return ;
|
||||
//lock required
|
||||
m_lockRes = m_alloc.Lock(m_alloc.pthis, m_srf.Data.MemId, &m_srf.Data);
|
||||
if (m_lockRes == MFX_ERR_NONE) {
|
||||
m_bLocked = true;
|
||||
}
|
||||
}
|
||||
|
||||
void UnlockFrame()
|
||||
{
|
||||
if (m_lockRes != MFX_ERR_NONE || !m_bLocked) {
|
||||
return;
|
||||
}
|
||||
//unlock required
|
||||
m_alloc.Unlock(m_alloc.pthis, m_srf.Data.MemId, &m_srf.Data);
|
||||
}
|
||||
};
|
||||
84
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/sysmem_allocator.h
vendored
Normal file
84
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/sysmem_allocator.h
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __SYSMEM_ALLOCATOR_H__
|
||||
#define __SYSMEM_ALLOCATOR_H__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "base_allocator.h"
|
||||
#include <vector>
|
||||
|
||||
struct sBuffer
|
||||
{
|
||||
mfxU32 id;
|
||||
mfxU32 nbytes;
|
||||
mfxU16 type;
|
||||
};
|
||||
|
||||
struct sFrame
|
||||
{
|
||||
mfxU32 id;
|
||||
mfxFrameInfo info;
|
||||
};
|
||||
|
||||
struct SysMemAllocatorParams : mfxAllocatorParams
|
||||
{
|
||||
SysMemAllocatorParams()
|
||||
: mfxAllocatorParams(), pBufferAllocator(NULL) { }
|
||||
MFXBufferAllocator *pBufferAllocator;
|
||||
};
|
||||
|
||||
class SysMemFrameAllocator: public BaseFrameAllocator
|
||||
{
|
||||
public:
|
||||
SysMemFrameAllocator();
|
||||
virtual ~SysMemFrameAllocator();
|
||||
|
||||
virtual mfxStatus Init(mfxAllocatorParams *pParams);
|
||||
virtual mfxStatus Close();
|
||||
virtual mfxStatus LockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus UnlockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus GetFrameHDL(mfxMemId mid, mfxHDL *handle);
|
||||
|
||||
protected:
|
||||
virtual mfxStatus CheckRequestType(mfxFrameAllocRequest *request);
|
||||
virtual mfxStatus ReleaseResponse(mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus AllocImpl(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus ReallocImpl(mfxMemId midIn, const mfxFrameInfo *info, mfxU16 memType, mfxMemId *midOut);
|
||||
|
||||
MFXBufferAllocator *m_pBufferAllocator;
|
||||
bool m_bOwnBufferAllocator;
|
||||
|
||||
std::vector<mfxFrameAllocResponse *> m_vResp;
|
||||
|
||||
mfxMemId *GetMidHolder(mfxMemId mid);
|
||||
};
|
||||
|
||||
class SysMemBufferAllocator : public MFXBufferAllocator
|
||||
{
|
||||
public:
|
||||
SysMemBufferAllocator();
|
||||
virtual ~SysMemBufferAllocator();
|
||||
virtual mfxStatus AllocBuffer(mfxU32 nbytes, mfxU16 type, mfxMemId *mid);
|
||||
virtual mfxStatus LockBuffer(mfxMemId mid, mfxU8 **ptr);
|
||||
virtual mfxStatus UnlockBuffer(mfxMemId mid);
|
||||
virtual mfxStatus FreeBuffer(mfxMemId mid);
|
||||
};
|
||||
|
||||
#endif // __SYSMEM_ALLOCATOR_H__
|
||||
263
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/time_statistics.h
vendored
Normal file
263
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/time_statistics.h
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mfxstructures.h"
|
||||
#include "vm/time_defs.h"
|
||||
#include "vm/strings_defs.h"
|
||||
#include "math.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
class CTimeStatisticsReal
|
||||
{
|
||||
public:
|
||||
CTimeStatisticsReal()
|
||||
{
|
||||
ResetStatistics();
|
||||
start=0;
|
||||
m_bNeedDumping = false;
|
||||
}
|
||||
|
||||
static msdk_tick GetFrequency()
|
||||
{
|
||||
if (!frequency)
|
||||
{
|
||||
frequency = msdk_time_get_frequency();
|
||||
}
|
||||
return frequency;
|
||||
}
|
||||
|
||||
static mfxF64 ConvertToSeconds(msdk_tick elapsed)
|
||||
{
|
||||
return MSDK_GET_TIME(elapsed, 0, GetFrequency());
|
||||
}
|
||||
|
||||
inline void StartTimeMeasurement()
|
||||
{
|
||||
start = msdk_time_get_tick();
|
||||
}
|
||||
|
||||
inline void StopTimeMeasurement()
|
||||
{
|
||||
mfxF64 delta=GetDeltaTime();
|
||||
totalTime+=delta;
|
||||
totalTimeSquares+=delta*delta;
|
||||
// dump in ms:
|
||||
if(m_bNeedDumping)
|
||||
m_time_deltas.push_back(delta * 1000);
|
||||
|
||||
if(delta<minTime)
|
||||
{
|
||||
minTime=delta;
|
||||
}
|
||||
|
||||
if(delta>maxTime)
|
||||
{
|
||||
maxTime=delta;
|
||||
}
|
||||
numMeasurements++;
|
||||
}
|
||||
|
||||
inline void StopTimeMeasurementWithCheck()
|
||||
{
|
||||
if(start)
|
||||
{
|
||||
StopTimeMeasurement();
|
||||
}
|
||||
}
|
||||
|
||||
inline mfxF64 GetDeltaTime()
|
||||
{
|
||||
return MSDK_GET_TIME(msdk_time_get_tick(), start, GetFrequency());
|
||||
}
|
||||
|
||||
inline mfxF64 GetDeltaTimeInMiliSeconds()
|
||||
{
|
||||
return GetDeltaTime() * 1000;
|
||||
}
|
||||
|
||||
inline void TurnOnDumping(){m_bNeedDumping = true; }
|
||||
|
||||
inline void TurnOffDumping(){m_bNeedDumping = false; }
|
||||
|
||||
inline void PrintStatistics(const msdk_char* prefix)
|
||||
{
|
||||
msdk_printf(MSDK_STRING("%s Total:%.3lfms(%lld smpls),Avg %.3lfms,StdDev:%.3lfms,Min:%.3lfms,Max:%.3lfms\n"),
|
||||
prefix,totalTime,numMeasurements,
|
||||
GetAvgTime(false),GetTimeStdDev(false),
|
||||
GetMinTime(false),GetMaxTime(false));
|
||||
}
|
||||
|
||||
inline mfxU64 GetNumMeasurements()
|
||||
{
|
||||
return numMeasurements;
|
||||
}
|
||||
|
||||
inline mfxF64 GetAvgTime(bool inSeconds=true)
|
||||
{
|
||||
if (inSeconds)
|
||||
{
|
||||
return (numMeasurements ? totalTime / numMeasurements : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (numMeasurements ? totalTime / numMeasurements : 0) * 1000;
|
||||
}
|
||||
}
|
||||
|
||||
inline mfxF64 GetTimeStdDev(bool inSeconds=true)
|
||||
{
|
||||
mfxF64 avg = GetAvgTime();
|
||||
mfxF64 ftmp = (numMeasurements ? sqrt(totalTimeSquares/numMeasurements-avg*avg) : 0.0);
|
||||
return inSeconds ? ftmp : ftmp * 1000;
|
||||
}
|
||||
|
||||
inline mfxF64 GetMinTime(bool inSeconds=true)
|
||||
{
|
||||
return inSeconds ? minTime : minTime * 1000;
|
||||
}
|
||||
|
||||
inline mfxF64 GetMaxTime(bool inSeconds=true)
|
||||
{
|
||||
return inSeconds ? maxTime : maxTime * 1000;
|
||||
}
|
||||
|
||||
inline mfxF64 GetTotalTime(bool inSeconds=true)
|
||||
{
|
||||
return inSeconds ? totalTime : totalTime * 1000;
|
||||
}
|
||||
|
||||
inline void ResetStatistics()
|
||||
{
|
||||
totalTime=0;
|
||||
totalTimeSquares=0;
|
||||
minTime=1E100;
|
||||
maxTime=-1;
|
||||
numMeasurements=0;
|
||||
m_time_deltas.clear();
|
||||
TurnOffDumping();
|
||||
}
|
||||
|
||||
protected:
|
||||
static msdk_tick frequency;
|
||||
|
||||
msdk_tick start;
|
||||
mfxF64 totalTime;
|
||||
mfxF64 totalTimeSquares;
|
||||
mfxF64 minTime;
|
||||
mfxF64 maxTime;
|
||||
mfxU64 numMeasurements;
|
||||
std::vector<mfxF64> m_time_deltas;
|
||||
bool m_bNeedDumping;
|
||||
|
||||
};
|
||||
|
||||
class CTimeStatisticsDummy
|
||||
{
|
||||
public:
|
||||
static msdk_tick GetFrequency()
|
||||
{
|
||||
if (!frequency)
|
||||
{
|
||||
frequency = msdk_time_get_frequency();
|
||||
}
|
||||
return frequency;
|
||||
}
|
||||
|
||||
static mfxF64 ConvertToSeconds(msdk_tick /*elapsed*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void StartTimeMeasurement()
|
||||
{
|
||||
}
|
||||
|
||||
inline void StopTimeMeasurement()
|
||||
{
|
||||
}
|
||||
|
||||
inline void StopTimeMeasurementWithCheck()
|
||||
{
|
||||
}
|
||||
|
||||
inline mfxF64 GetDeltaTime()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline mfxF64 GetDeltaTimeInMiliSeconds()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void TurnOnDumping() {}
|
||||
|
||||
inline void TurnOffDumping() {}
|
||||
|
||||
inline void PrintStatistics(const msdk_char* /*prefix*/)
|
||||
{
|
||||
}
|
||||
|
||||
inline mfxU64 GetNumMeasurements()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline mfxF64 GetAvgTime(bool)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline mfxF64 GetTimeStdDev(bool)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline mfxF64 GetMinTime(bool)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline mfxF64 GetMaxTime(bool)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline mfxF64 GetTotalTime(bool)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void ResetStatistics()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
static msdk_tick frequency;
|
||||
};
|
||||
|
||||
#ifdef TIME_STATS
|
||||
typedef CTimeStatisticsReal CTimeStatistics;
|
||||
#else
|
||||
typedef CTimeStatisticsDummy CTimeStatistics;
|
||||
#endif
|
||||
120
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/v4l2_util.h
vendored
Normal file
120
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/v4l2_util.h
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __V4L2_UTIL_H__
|
||||
#define __V4L2_UTIL_H__
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <va/va.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include "sample_defs.h"
|
||||
|
||||
/* MIPI DRIVER Configurations*/
|
||||
#define _ISP_MODE_NONE 0x0000
|
||||
#define _ISP_MODE_CONTINUOUS 0x1000
|
||||
#define _ISP_MODE_STILL 0x2000
|
||||
#define _ISP_MODE_VIDEO 0x4000
|
||||
#define _ISP_MODE_PREVIEW 0x8000
|
||||
|
||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||
#define ERRSTR strerror(errno)
|
||||
|
||||
#define BYE_ON(cond, ...) \
|
||||
do { \
|
||||
if (cond) { \
|
||||
int errsv = errno; \
|
||||
fprintf(stderr, "ERROR(%s:%d) : ", \
|
||||
__FILE__, __LINE__); \
|
||||
errno = errsv; \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
abort(); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
enum AtomISPMode
|
||||
{
|
||||
NONE = 0, PREVIEW, STILL, VIDEO, CONTINUOUS
|
||||
};
|
||||
|
||||
enum V4L2PixelFormat
|
||||
{
|
||||
NO_FORMAT = 0, UYVY, YUY2
|
||||
};
|
||||
|
||||
typedef struct _Buffer
|
||||
{
|
||||
int fd, index;
|
||||
} Buffer;
|
||||
|
||||
extern Buffer *buffers;
|
||||
void *PollingThread(void *data);
|
||||
|
||||
class v4l2Device
|
||||
{
|
||||
public:
|
||||
v4l2Device(const char *devname = "/dev/video0",
|
||||
uint32_t width = 1920,
|
||||
uint32_t height = 1080,
|
||||
uint32_t num_buffer = 4,
|
||||
enum AtomISPMode MipiMode = NONE,
|
||||
enum V4L2PixelFormat m_v4l2Format = NO_FORMAT);
|
||||
|
||||
~v4l2Device();
|
||||
|
||||
void Init(const char *devname,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t num_buffer,
|
||||
enum V4L2PixelFormat v4l2Format,
|
||||
enum AtomISPMode MipiMode,
|
||||
int m_MipiPort);
|
||||
|
||||
void V4L2Init();
|
||||
void V4L2Alloc();
|
||||
int blockIOCTL(int handle, int request, void *args);
|
||||
int GetAtomISPModes(enum AtomISPMode mode);
|
||||
void V4L2QueueBuffer(Buffer *buffer);
|
||||
Buffer *V4L2DeQueueBuffer(Buffer *buffer);
|
||||
void V4L2StartCapture();
|
||||
void V4L2StopCapture();
|
||||
int GetV4L2TerminationSignal();
|
||||
void PutOnQ(int x);
|
||||
int GetOffQ();
|
||||
int ConvertToMFXFourCC(enum V4L2PixelFormat v4l2Format);
|
||||
int ConvertToV4L2FourCC();
|
||||
int GetV4L2DisplayID() { return m_fd; }
|
||||
bool ISV4L2Enabled() { return (m_fd > 0)? true : false; }
|
||||
|
||||
protected:
|
||||
const char *m_devname;
|
||||
uint32_t m_height;
|
||||
uint32_t m_width;
|
||||
uint32_t m_num_buffers;
|
||||
struct v4l2_pix_format m_format;
|
||||
int m_MipiPort;
|
||||
enum AtomISPMode m_MipiMode;
|
||||
enum V4L2PixelFormat m_v4l2Format;
|
||||
int m_fd;
|
||||
};
|
||||
|
||||
#endif // ifdef __V4L2_UTIL_H__
|
||||
111
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_allocator.h
vendored
Normal file
111
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_allocator.h
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __VAAPI_ALLOCATOR_H__
|
||||
#define __VAAPI_ALLOCATOR_H__
|
||||
|
||||
#if defined(LIBVA_SUPPORT)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <va/va.h>
|
||||
#include <va/va_drmcommon.h>
|
||||
|
||||
#include "base_allocator.h"
|
||||
#include "vaapi_utils.h"
|
||||
|
||||
// VAAPI Allocator internal Mem ID
|
||||
struct vaapiMemId
|
||||
{
|
||||
VASurfaceID* m_surface;
|
||||
VAImage m_image;
|
||||
// variables for VAAPI Allocator internal color conversion
|
||||
unsigned int m_fourcc;
|
||||
mfxU8* m_sys_buffer;
|
||||
mfxU8* m_va_buffer;
|
||||
// buffer info to support surface export
|
||||
VABufferInfo m_buffer_info;
|
||||
// pointer to private export data
|
||||
void* m_custom;
|
||||
};
|
||||
|
||||
namespace MfxLoader
|
||||
{
|
||||
class VA_Proxy;
|
||||
}
|
||||
|
||||
struct vaapiAllocatorParams : mfxAllocatorParams
|
||||
{
|
||||
enum {
|
||||
DONOT_EXPORT = 0,
|
||||
FLINK = 0x01,
|
||||
PRIME = 0x02,
|
||||
NATIVE_EXPORT_MASK = FLINK | PRIME,
|
||||
CUSTOM = 0x100,
|
||||
CUSTOM_FLINK = CUSTOM | FLINK,
|
||||
CUSTOM_PRIME = CUSTOM | PRIME
|
||||
};
|
||||
class Exporter
|
||||
{
|
||||
public:
|
||||
virtual ~Exporter(){}
|
||||
virtual void* acquire(mfxMemId mid) = 0;
|
||||
virtual void release(mfxMemId mid, void * hdl) = 0;
|
||||
};
|
||||
|
||||
vaapiAllocatorParams()
|
||||
: m_dpy(NULL)
|
||||
, m_export_mode(DONOT_EXPORT)
|
||||
, m_exporter(NULL)
|
||||
{}
|
||||
|
||||
VADisplay m_dpy;
|
||||
mfxU32 m_export_mode;
|
||||
Exporter* m_exporter;
|
||||
};
|
||||
|
||||
class vaapiFrameAllocator: public BaseFrameAllocator
|
||||
{
|
||||
public:
|
||||
vaapiFrameAllocator();
|
||||
virtual ~vaapiFrameAllocator();
|
||||
|
||||
virtual mfxStatus Init(mfxAllocatorParams *pParams);
|
||||
virtual mfxStatus Close();
|
||||
|
||||
protected:
|
||||
DISALLOW_COPY_AND_ASSIGN(vaapiFrameAllocator);
|
||||
|
||||
virtual mfxStatus LockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus UnlockFrame(mfxMemId mid, mfxFrameData *ptr);
|
||||
virtual mfxStatus GetFrameHDL(mfxMemId mid, mfxHDL *handle);
|
||||
|
||||
virtual mfxStatus CheckRequestType(mfxFrameAllocRequest *request);
|
||||
virtual mfxStatus ReleaseResponse(mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus AllocImpl(mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);
|
||||
virtual mfxStatus ReallocImpl(mfxMemId midIn, const mfxFrameInfo *info, mfxU16 memType, mfxMemId *midOut);
|
||||
|
||||
VADisplay m_dpy;
|
||||
MfxLoader::VA_Proxy * m_libva;
|
||||
mfxU32 m_export_mode;
|
||||
vaapiAllocatorParams::Exporter* m_exporter;
|
||||
};
|
||||
|
||||
#endif //#if defined(LIBVA_SUPPORT)
|
||||
|
||||
#endif // __VAAPI_ALLOCATOR_H__
|
||||
231
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_device.h
vendored
Normal file
231
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_device.h
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#if defined(LIBVA_DRM_SUPPORT) || defined(LIBVA_X11_SUPPORT) || defined(LIBVA_ANDROID_SUPPORT) || defined(LIBVA_WAYLAND_SUPPORT)
|
||||
|
||||
#include "hw_device.h"
|
||||
#include "vaapi_utils_drm.h"
|
||||
#include "vaapi_utils_x11.h"
|
||||
#if defined(LIBVA_ANDROID_SUPPORT)
|
||||
#include "vaapi_utils_android.h"
|
||||
#endif
|
||||
|
||||
CHWDevice* CreateVAAPIDevice(const std::string& devicePath = "", int type = MFX_LIBVA_DRM);
|
||||
|
||||
#if defined(LIBVA_DRM_SUPPORT)
|
||||
/** VAAPI DRM implementation. */
|
||||
class CVAAPIDeviceDRM : public CHWDevice
|
||||
{
|
||||
public:
|
||||
CVAAPIDeviceDRM(const std::string& devicePath, int type);
|
||||
virtual ~CVAAPIDeviceDRM(void);
|
||||
|
||||
virtual mfxStatus Init(mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNum);
|
||||
virtual mfxStatus Reset(void) { return MFX_ERR_NONE; }
|
||||
virtual void Close(void) { }
|
||||
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) { return MFX_ERR_UNSUPPORTED; }
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *pHdl)
|
||||
{
|
||||
if ((MFX_HANDLE_VA_DISPLAY == type) && (NULL != pHdl))
|
||||
{
|
||||
*pHdl = m_DRMLibVA.GetVADisplay();
|
||||
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
virtual mfxStatus RenderFrame(mfxFrameSurface1 * pSurface, mfxFrameAllocator * pmfxAlloc);
|
||||
virtual void UpdateTitle(double fps) { }
|
||||
virtual void SetMondelloInput(bool isMondelloInputEnabled) { }
|
||||
|
||||
inline drmRenderer* getRenderer() { return m_rndr; }
|
||||
protected:
|
||||
DRMLibVA m_DRMLibVA;
|
||||
drmRenderer * m_rndr;
|
||||
private:
|
||||
// no copies allowed
|
||||
CVAAPIDeviceDRM(const CVAAPIDeviceDRM &);
|
||||
void operator=(const CVAAPIDeviceDRM &);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(LIBVA_X11_SUPPORT)
|
||||
|
||||
/** VAAPI X11 implementation. */
|
||||
class CVAAPIDeviceX11 : public CHWDevice
|
||||
{
|
||||
public:
|
||||
CVAAPIDeviceX11()
|
||||
{
|
||||
m_window = NULL;
|
||||
m_nRenderWinX=0;
|
||||
m_nRenderWinY=0;
|
||||
m_nRenderWinW=0;
|
||||
m_nRenderWinH=0;
|
||||
m_bRenderWin=false;
|
||||
#if defined(X11_DRI3_SUPPORT)
|
||||
m_dri_fd = 0;
|
||||
m_bufmgr = NULL;
|
||||
m_xcbconn = NULL;
|
||||
#endif
|
||||
}
|
||||
virtual ~CVAAPIDeviceX11(void);
|
||||
|
||||
virtual mfxStatus Init(
|
||||
mfxHDL hWindow,
|
||||
mfxU16 nViews,
|
||||
mfxU32 nAdapterNum);
|
||||
virtual mfxStatus Reset(void);
|
||||
virtual void Close(void);
|
||||
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl);
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *pHdl);
|
||||
|
||||
virtual mfxStatus RenderFrame(mfxFrameSurface1 * pSurface, mfxFrameAllocator * pmfxAlloc);
|
||||
virtual void UpdateTitle(double fps) { }
|
||||
virtual void SetMondelloInput(bool isMondelloInputEnabled) { }
|
||||
|
||||
protected:
|
||||
mfxHDL m_window;
|
||||
X11LibVA m_X11LibVA;
|
||||
private:
|
||||
|
||||
bool m_bRenderWin;
|
||||
mfxU32 m_nRenderWinX;
|
||||
mfxU32 m_nRenderWinY;
|
||||
mfxU32 m_nRenderWinW;
|
||||
mfxU32 m_nRenderWinH;
|
||||
#if defined(X11_DRI3_SUPPORT)
|
||||
int m_dri_fd;
|
||||
drm_intel_bufmgr* m_bufmgr;
|
||||
xcb_connection_t *m_xcbconn;
|
||||
#endif
|
||||
// no copies allowed
|
||||
CVAAPIDeviceX11(const CVAAPIDeviceX11 &);
|
||||
void operator=(const CVAAPIDeviceX11 &);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(LIBVA_WAYLAND_SUPPORT)
|
||||
|
||||
class Wayland;
|
||||
|
||||
class CVAAPIDeviceWayland : public CHWDevice
|
||||
{
|
||||
public:
|
||||
CVAAPIDeviceWayland(){
|
||||
m_nRenderWinX = 0;
|
||||
m_nRenderWinY = 0;
|
||||
m_nRenderWinW = 0;
|
||||
m_nRenderWinH = 0;
|
||||
m_isMondelloInputEnabled = false;
|
||||
m_Wayland = NULL;
|
||||
}
|
||||
virtual ~CVAAPIDeviceWayland(void);
|
||||
|
||||
virtual mfxStatus Init(mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNum);
|
||||
virtual mfxStatus Reset(void) { return MFX_ERR_NONE; }
|
||||
virtual void Close(void);
|
||||
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) { return MFX_ERR_UNSUPPORTED; }
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *pHdl)
|
||||
{
|
||||
if((MFX_HANDLE_VA_DISPLAY == type) && (NULL != pHdl)) {
|
||||
*pHdl = m_DRMLibVA.GetVADisplay();
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
virtual mfxStatus RenderFrame(mfxFrameSurface1 * pSurface, mfxFrameAllocator * pmfxAlloc);
|
||||
virtual void UpdateTitle(double fps) { }
|
||||
|
||||
virtual void SetMondelloInput(bool isMondelloInputEnabled)
|
||||
{
|
||||
m_isMondelloInputEnabled = isMondelloInputEnabled;
|
||||
}
|
||||
|
||||
Wayland * GetWaylandHandle()
|
||||
{
|
||||
return m_Wayland;
|
||||
}
|
||||
protected:
|
||||
DRMLibVA m_DRMLibVA;
|
||||
MfxLoader::VA_WaylandClientProxy m_WaylandClient;
|
||||
Wayland *m_Wayland;
|
||||
private:
|
||||
mfxU32 m_nRenderWinX;
|
||||
mfxU32 m_nRenderWinY;
|
||||
mfxU32 m_nRenderWinW;
|
||||
mfxU32 m_nRenderWinH;
|
||||
|
||||
bool m_isMondelloInputEnabled;
|
||||
|
||||
// no copies allowed
|
||||
CVAAPIDeviceWayland(const CVAAPIDeviceWayland &);
|
||||
void operator=(const CVAAPIDeviceWayland &);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(LIBVA_ANDROID_SUPPORT)
|
||||
|
||||
/** VAAPI Android implementation. */
|
||||
class CVAAPIDeviceAndroid : public CHWDevice
|
||||
{
|
||||
public:
|
||||
CVAAPIDeviceAndroid(AndroidLibVA *pAndroidLibVA):
|
||||
m_pAndroidLibVA(pAndroidLibVA)
|
||||
{
|
||||
if (!m_pAndroidLibVA)
|
||||
{
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
};
|
||||
virtual ~CVAAPIDeviceAndroid(void) { Close();}
|
||||
|
||||
virtual mfxStatus Init(mfxHDL hWindow, mfxU16 nViews, mfxU32 nAdapterNum) { return MFX_ERR_NONE;}
|
||||
virtual mfxStatus Reset(void) { return MFX_ERR_NONE; }
|
||||
virtual void Close(void) { }
|
||||
|
||||
virtual mfxStatus SetHandle(mfxHandleType type, mfxHDL hdl) { return MFX_ERR_UNSUPPORTED; }
|
||||
virtual mfxStatus GetHandle(mfxHandleType type, mfxHDL *pHdl)
|
||||
{
|
||||
if ((MFX_HANDLE_VA_DISPLAY == type) && (NULL != pHdl))
|
||||
{
|
||||
if(m_pAndroidLibVA)*pHdl = m_pAndroidLibVA->GetVADisplay();
|
||||
return MFX_ERR_NONE;
|
||||
}
|
||||
|
||||
return MFX_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
virtual mfxStatus RenderFrame(mfxFrameSurface1 * pSurface, mfxFrameAllocator * pmfxAlloc) { return MFX_ERR_NONE; }
|
||||
virtual void UpdateTitle(double fps) { }
|
||||
virtual void SetMondelloInput(bool isMondelloInputEnabled) { }
|
||||
|
||||
protected:
|
||||
AndroidLibVA* m_pAndroidLibVA;
|
||||
};
|
||||
#endif
|
||||
#endif //#if defined(LIBVA_DRM_SUPPORT) || defined(LIBVA_X11_SUPPORT) || defined(LIBVA_ANDROID_SUPPORT)
|
||||
481
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_utils.h
vendored
Normal file
481
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_utils.h
vendored
Normal file
@@ -0,0 +1,481 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __VAAPI_UTILS_H__
|
||||
#define __VAAPI_UTILS_H__
|
||||
|
||||
#ifdef LIBVA_SUPPORT
|
||||
|
||||
#include <va/va.h>
|
||||
#include <va/va_drmcommon.h>
|
||||
|
||||
#if defined(LIBVA_DRM_SUPPORT)
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
#include <libdrm/intel_bufmgr.h>
|
||||
#include <va/va_drm.h>
|
||||
#endif
|
||||
#if defined(LIBVA_X11_SUPPORT)
|
||||
#include <va/va_x11.h>
|
||||
#if defined(X11_DRI3_SUPPORT)
|
||||
#include <xcb/dri3.h>
|
||||
#include <xcb/present.h>
|
||||
#endif // X11_DRI3_SUPPORT
|
||||
#endif
|
||||
#include "sample_defs.h"
|
||||
#include "sample_utils.h"
|
||||
#include "vm/thread_defs.h"
|
||||
|
||||
namespace MfxLoader
|
||||
{
|
||||
|
||||
class SimpleLoader
|
||||
{
|
||||
public:
|
||||
SimpleLoader(const char * name);
|
||||
|
||||
void * GetFunction(const char * name);
|
||||
|
||||
~SimpleLoader();
|
||||
|
||||
private:
|
||||
SimpleLoader(SimpleLoader&);
|
||||
void operator=(SimpleLoader&);
|
||||
|
||||
void * so_handle;
|
||||
};
|
||||
|
||||
#ifdef LIBVA_SUPPORT
|
||||
class VA_Proxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef VAStatus (*vaInitialize_type)(VADisplay, int *, int *);
|
||||
typedef VAStatus (*vaTerminate_type)(VADisplay);
|
||||
typedef VAStatus (*vaCreateSurfaces_type)(VADisplay, unsigned int,
|
||||
unsigned int, unsigned int, VASurfaceID *, unsigned int,
|
||||
VASurfaceAttrib *, unsigned int);
|
||||
typedef VAStatus (*vaDestroySurfaces_type)(VADisplay, VASurfaceID *, int);
|
||||
typedef VAStatus (*vaCreateBuffer_type)(VADisplay, VAContextID,
|
||||
VABufferType, unsigned int, unsigned int, void *, VABufferID *);
|
||||
typedef VAStatus (*vaDestroyBuffer_type)(VADisplay, VABufferID);
|
||||
typedef VAStatus (*vaMapBuffer_type)(VADisplay, VABufferID, void **pbuf);
|
||||
typedef VAStatus (*vaUnmapBuffer_type)(VADisplay, VABufferID);
|
||||
typedef VAStatus (*vaSyncSurface_type)(VADisplay, VASurfaceID);
|
||||
typedef VAStatus (*vaDeriveImage_type)(VADisplay, VASurfaceID, VAImage *);
|
||||
typedef VAStatus (*vaDestroyImage_type)(VADisplay, VAImageID);
|
||||
typedef VAStatus (*vaGetLibFunc_type)(VADisplay, const char *func);
|
||||
typedef VAStatus (*vaAcquireBufferHandle_type)(VADisplay, VABufferID, VABufferInfo *);
|
||||
typedef VAStatus (*vaReleaseBufferHandle_type)(VADisplay, VABufferID);
|
||||
typedef VAStatus (*vaMaxNumEntrypoints_type)(VADisplay dpy);
|
||||
typedef VAStatus (*vaQueryConfigEntrypoints_type)(VADisplay dpy,
|
||||
VAProfile profile,
|
||||
VAEntrypoint *entrypoint_list,
|
||||
int *num_entrypoints);
|
||||
typedef VAStatus (*vaGetConfigAttributes_type)(VADisplay dpy,
|
||||
VAProfile profile,
|
||||
VAEntrypoint entrypoint,
|
||||
VAConfigAttrib *attrib_list,
|
||||
int num_attribs);
|
||||
typedef VAStatus (*vaCreateConfig_type)(VADisplay dpy,
|
||||
VAProfile profile,
|
||||
VAEntrypoint entrypoint,
|
||||
VAConfigAttrib *attrib_list,
|
||||
int num_attribs,
|
||||
VAConfigID *config_id);
|
||||
|
||||
typedef VAStatus (*vaCreateContext_type)(VADisplay dpy,
|
||||
VAConfigID config_id,
|
||||
int picture_width,
|
||||
int picture_height,
|
||||
int flag,
|
||||
VASurfaceID *render_targets,
|
||||
int num_render_targets,
|
||||
VAContextID *context);
|
||||
typedef VAStatus (*vaDestroyConfig_type) (VADisplay dpy,
|
||||
VAConfigID config_id);
|
||||
typedef VAStatus (*vaDestroyContext_type) (VADisplay dpy,
|
||||
VAContextID context);
|
||||
|
||||
VA_Proxy();
|
||||
~VA_Proxy();
|
||||
|
||||
const vaInitialize_type vaInitialize;
|
||||
const vaTerminate_type vaTerminate;
|
||||
const vaCreateSurfaces_type vaCreateSurfaces;
|
||||
const vaDestroySurfaces_type vaDestroySurfaces;
|
||||
const vaCreateBuffer_type vaCreateBuffer;
|
||||
const vaDestroyBuffer_type vaDestroyBuffer;
|
||||
const vaMapBuffer_type vaMapBuffer;
|
||||
const vaUnmapBuffer_type vaUnmapBuffer;
|
||||
const vaSyncSurface_type vaSyncSurface;
|
||||
const vaDeriveImage_type vaDeriveImage;
|
||||
const vaDestroyImage_type vaDestroyImage;
|
||||
const vaGetLibFunc_type vaGetLibFunc;
|
||||
const vaAcquireBufferHandle_type vaAcquireBufferHandle;
|
||||
const vaReleaseBufferHandle_type vaReleaseBufferHandle;
|
||||
const vaMaxNumEntrypoints_type vaMaxNumEntrypoints;
|
||||
const vaQueryConfigEntrypoints_type vaQueryConfigEntrypoints;
|
||||
const vaGetConfigAttributes_type vaGetConfigAttributes;
|
||||
const vaCreateConfig_type vaCreateConfig;
|
||||
const vaCreateContext_type vaCreateContext;
|
||||
const vaDestroyConfig_type vaDestroyConfig;
|
||||
const vaDestroyContext_type vaDestroyContext;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(LIBVA_DRM_SUPPORT)
|
||||
class DRM_Proxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef int (*drmIoctl_type)(int fd, unsigned long request, void *arg);
|
||||
typedef int (*drmModeAddFB_type)(
|
||||
int fd, uint32_t width, uint32_t height, uint8_t depth,
|
||||
uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
|
||||
uint32_t *buf_id);
|
||||
typedef int (*drmModeAddFB2WithModifiers_type)(int fd, uint32_t width, uint32_t height, uint32_t pixel_format,
|
||||
uint32_t bo_handles[4], uint32_t pitches[4], uint32_t offsets[4], uint64_t modifier[4],
|
||||
uint32_t *buf_id, uint32_t flags);
|
||||
typedef void (*drmModeFreeConnector_type)( drmModeConnectorPtr ptr );
|
||||
typedef void (*drmModeFreeCrtc_type)( drmModeCrtcPtr ptr );
|
||||
typedef void (*drmModeFreeEncoder_type)( drmModeEncoderPtr ptr );
|
||||
typedef void (*drmModeFreePlane_type)( drmModePlanePtr ptr );
|
||||
typedef void (*drmModeFreePlaneResources_type)(drmModePlaneResPtr ptr);
|
||||
typedef void (*drmModeFreeResources_type)( drmModeResPtr ptr );
|
||||
typedef drmModeConnectorPtr (*drmModeGetConnector_type)(
|
||||
int fd, uint32_t connectorId);
|
||||
typedef drmModeCrtcPtr (*drmModeGetCrtc_type)(int fd, uint32_t crtcId);
|
||||
typedef drmModeEncoderPtr (*drmModeGetEncoder_type)(int fd, uint32_t encoder_id);
|
||||
typedef drmModePlanePtr (*drmModeGetPlane_type)(int fd, uint32_t plane_id);
|
||||
typedef drmModePlaneResPtr (*drmModeGetPlaneResources_type)(int fd);
|
||||
typedef drmModeResPtr (*drmModeGetResources_type)(int fd);
|
||||
typedef int (*drmModeRmFB_type)(int fd, uint32_t bufferId);
|
||||
typedef int (*drmModeSetCrtc_type)(
|
||||
int fd, uint32_t crtcId, uint32_t bufferId,
|
||||
uint32_t x, uint32_t y, uint32_t *connectors, int count,
|
||||
drmModeModeInfoPtr mode);
|
||||
typedef int (*drmSetMaster_type)(int fd);
|
||||
typedef int (*drmDropMaster_type)(int fd);
|
||||
typedef int (*drmModeSetPlane_type)(
|
||||
int fd, uint32_t plane_id, uint32_t crtc_id,
|
||||
uint32_t fb_id, uint32_t flags,
|
||||
int32_t crtc_x, int32_t crtc_y,
|
||||
uint32_t crtc_w, uint32_t crtc_h,
|
||||
uint32_t src_x, uint32_t src_y,
|
||||
uint32_t src_w, uint32_t src_h);
|
||||
|
||||
DRM_Proxy();
|
||||
~DRM_Proxy();
|
||||
|
||||
#define __DECLARE(name) const name ## _type name
|
||||
__DECLARE(drmIoctl);
|
||||
__DECLARE(drmModeAddFB);
|
||||
__DECLARE(drmModeAddFB2WithModifiers);
|
||||
__DECLARE(drmModeFreeConnector);
|
||||
__DECLARE(drmModeFreeCrtc);
|
||||
__DECLARE(drmModeFreeEncoder);
|
||||
__DECLARE(drmModeFreePlane);
|
||||
__DECLARE(drmModeFreePlaneResources);
|
||||
__DECLARE(drmModeFreeResources);
|
||||
__DECLARE(drmModeGetConnector);
|
||||
__DECLARE(drmModeGetCrtc);
|
||||
__DECLARE(drmModeGetEncoder);
|
||||
__DECLARE(drmModeGetPlane);
|
||||
__DECLARE(drmModeGetPlaneResources);
|
||||
__DECLARE(drmModeGetResources);
|
||||
__DECLARE(drmModeRmFB);
|
||||
__DECLARE(drmModeSetCrtc);
|
||||
__DECLARE(drmSetMaster);
|
||||
__DECLARE(drmDropMaster);
|
||||
__DECLARE(drmModeSetPlane);
|
||||
#undef __DECLARE
|
||||
};
|
||||
|
||||
class DrmIntel_Proxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef drm_intel_bo* (*drm_intel_bo_gem_create_from_prime_type)(
|
||||
drm_intel_bufmgr *bufmgr, int prime_fd, int size);
|
||||
typedef void (*drm_intel_bo_unreference_type)(drm_intel_bo *bo);
|
||||
typedef drm_intel_bufmgr* (*drm_intel_bufmgr_gem_init_type)(int fd, int batch_size);
|
||||
typedef int (*drm_intel_bo_gem_export_to_prime_type) (drm_intel_bo *, int *);
|
||||
typedef void (*drm_intel_bufmgr_destroy_type)(drm_intel_bufmgr*);
|
||||
|
||||
DrmIntel_Proxy();
|
||||
~DrmIntel_Proxy();
|
||||
|
||||
#define __DECLARE(name) const name ## _type name
|
||||
__DECLARE(drm_intel_bo_gem_create_from_prime);
|
||||
__DECLARE(drm_intel_bo_unreference);
|
||||
__DECLARE(drm_intel_bufmgr_gem_init);
|
||||
__DECLARE(drm_intel_bufmgr_destroy);
|
||||
#if defined(X11_DRI3_SUPPORT)
|
||||
__DECLARE(drm_intel_bo_gem_export_to_prime);
|
||||
#endif
|
||||
|
||||
#undef __DECLARE
|
||||
};
|
||||
|
||||
class VA_DRMProxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef VADisplay (*vaGetDisplayDRM_type)(int);
|
||||
|
||||
|
||||
VA_DRMProxy();
|
||||
~VA_DRMProxy();
|
||||
|
||||
const vaGetDisplayDRM_type vaGetDisplayDRM;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined (LIBVA_WAYLAND_SUPPORT)
|
||||
|
||||
class Wayland;
|
||||
|
||||
class VA_WaylandClientProxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef Wayland* (*WaylandCreate_type)(void);
|
||||
|
||||
VA_WaylandClientProxy();
|
||||
~VA_WaylandClientProxy();
|
||||
|
||||
const WaylandCreate_type WaylandCreate;
|
||||
};
|
||||
|
||||
#endif // LIBVA_WAYLAND_SUPPORT
|
||||
|
||||
#if defined(LIBVA_X11_SUPPORT)
|
||||
class VA_X11Proxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef VADisplay (*vaGetDisplay_type)(Display*);
|
||||
typedef VAStatus (*vaPutSurface_type)(
|
||||
VADisplay, VASurfaceID,
|
||||
Drawable,
|
||||
short, short,
|
||||
unsigned short, unsigned short,
|
||||
short, short,
|
||||
unsigned short, unsigned short,
|
||||
VARectangle *,
|
||||
unsigned int, unsigned int);
|
||||
|
||||
VA_X11Proxy();
|
||||
~VA_X11Proxy();
|
||||
|
||||
const vaGetDisplay_type vaGetDisplay;
|
||||
const vaPutSurface_type vaPutSurface;
|
||||
};
|
||||
|
||||
class XLib_Proxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef Display* (*XOpenDisplay_type) (const char*);
|
||||
typedef int (*XCloseDisplay_type)(Display*);
|
||||
typedef Window (*XCreateSimpleWindow_type)(Display *,
|
||||
Window, int, int,
|
||||
unsigned int, unsigned int,
|
||||
unsigned int, unsigned long,
|
||||
unsigned long);
|
||||
typedef int (*XMapWindow_type)(Display*, Window);
|
||||
typedef int (*XSync_type)(Display*, Bool);
|
||||
typedef int (*XDestroyWindow_type)(Display*, Window);
|
||||
typedef int (*XResizeWindow_type)(Display *, Window, unsigned int, unsigned int);
|
||||
#if defined(X11_DRI3_SUPPORT)
|
||||
typedef Status (*XGetGeometry_type)(Display *, Drawable, Window *,
|
||||
int *, int *, unsigned int *, unsigned int *,
|
||||
unsigned int *, unsigned int *);
|
||||
#endif // X11_DRI3_SUPPORT
|
||||
XLib_Proxy();
|
||||
~XLib_Proxy();
|
||||
|
||||
const XOpenDisplay_type XOpenDisplay;
|
||||
const XCloseDisplay_type XCloseDisplay;
|
||||
const XCreateSimpleWindow_type XCreateSimpleWindow;
|
||||
const XMapWindow_type XMapWindow;
|
||||
const XSync_type XSync;
|
||||
const XDestroyWindow_type XDestroyWindow;
|
||||
const XResizeWindow_type XResizeWindow;
|
||||
#if defined(X11_DRI3_SUPPORT)
|
||||
const XGetGeometry_type XGetGeometry;
|
||||
#endif // X11_DRI3_SUPPORT
|
||||
};
|
||||
|
||||
#if defined(X11_DRI3_SUPPORT)
|
||||
|
||||
class XCB_Dri3_Proxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef xcb_void_cookie_t (*xcb_dri3_pixmap_from_buffer_type) (xcb_connection_t *,
|
||||
xcb_pixmap_t,
|
||||
xcb_drawable_t,
|
||||
uint32_t,
|
||||
uint16_t,
|
||||
uint16_t,
|
||||
uint16_t,
|
||||
uint8_t,
|
||||
uint8_t,
|
||||
int32_t);
|
||||
typedef xcb_dri3_pixmap_from_buffer_type xcb_dri3_pixmap_from_buffer_checked_type;
|
||||
|
||||
XCB_Dri3_Proxy();
|
||||
~XCB_Dri3_Proxy();
|
||||
|
||||
const xcb_dri3_pixmap_from_buffer_checked_type xcb_dri3_pixmap_from_buffer_checked;
|
||||
};
|
||||
|
||||
class Xcb_Proxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef uint32_t (*xcb_generate_id_type) (xcb_connection_t *);
|
||||
typedef xcb_void_cookie_t (*xcb_free_pixmap_type) (xcb_connection_t *, xcb_pixmap_t);
|
||||
typedef int (*xcb_flush_type)(xcb_connection_t *);
|
||||
typedef xcb_generic_error_t* (*xcb_request_check_type)(xcb_connection_t *c, xcb_void_cookie_t cookie);
|
||||
|
||||
Xcb_Proxy();
|
||||
~Xcb_Proxy();
|
||||
|
||||
const xcb_generate_id_type xcb_generate_id;
|
||||
const xcb_free_pixmap_type xcb_free_pixmap;
|
||||
const xcb_flush_type xcb_flush;
|
||||
const xcb_request_check_type xcb_request_check;
|
||||
};
|
||||
|
||||
class X11_Xcb_Proxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib; // should appear first in member list
|
||||
|
||||
public:
|
||||
typedef xcb_connection_t * (*XGetXCBConnection_type) (Display *dpy);
|
||||
|
||||
X11_Xcb_Proxy();
|
||||
~X11_Xcb_Proxy();
|
||||
|
||||
const XGetXCBConnection_type XGetXCBConnection;
|
||||
};
|
||||
|
||||
class Xcbpresent_Proxy
|
||||
{
|
||||
private:
|
||||
SimpleLoader lib;
|
||||
|
||||
public:
|
||||
typedef xcb_void_cookie_t (*xcb_present_pixmap_type) (xcb_connection_t *,
|
||||
xcb_window_t,
|
||||
xcb_pixmap_t,
|
||||
uint32_t,
|
||||
xcb_xfixes_region_t,
|
||||
xcb_xfixes_region_t,
|
||||
int16_t,
|
||||
int16_t,
|
||||
xcb_randr_crtc_t,
|
||||
xcb_sync_fence_t,
|
||||
xcb_sync_fence_t,
|
||||
uint32_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
uint32_t,
|
||||
const xcb_present_notify_t *);
|
||||
typedef xcb_present_pixmap_type xcb_present_pixmap_checked_type;
|
||||
|
||||
Xcbpresent_Proxy();
|
||||
~Xcbpresent_Proxy();
|
||||
|
||||
const xcb_present_pixmap_checked_type xcb_present_pixmap_checked;
|
||||
};
|
||||
|
||||
#endif // X11_DRI3_SUPPORT
|
||||
#endif
|
||||
|
||||
} // namespace MfxLoader
|
||||
|
||||
|
||||
class CLibVA
|
||||
{
|
||||
public:
|
||||
virtual ~CLibVA(void) {};
|
||||
|
||||
VAStatus AcquireVASurface(
|
||||
void** pctx,
|
||||
VADisplay dpy1,
|
||||
VASurfaceID srf1,
|
||||
VADisplay dpy2,
|
||||
VASurfaceID* srf2);
|
||||
void ReleaseVASurface(
|
||||
void* actx,
|
||||
VADisplay dpy1,
|
||||
VASurfaceID /*srf1*/,
|
||||
VADisplay dpy2,
|
||||
VASurfaceID srf2);
|
||||
|
||||
inline int getBackendType() { return m_type; }
|
||||
VADisplay GetVADisplay() { return m_va_dpy; }
|
||||
const MfxLoader::VA_Proxy m_libva;
|
||||
|
||||
protected:
|
||||
CLibVA(int type)
|
||||
: m_type(type)
|
||||
, m_va_dpy(NULL)
|
||||
{}
|
||||
int m_type;
|
||||
VADisplay m_va_dpy;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(CLibVA);
|
||||
};
|
||||
|
||||
CLibVA* CreateLibVA(const std::string& devicePath = "", int type = MFX_LIBVA_DRM);
|
||||
|
||||
VAStatus AcquireVASurface(void** ctx, VADisplay dpy1, VASurfaceID srf1, VADisplay dpy2, VASurfaceID* srf2);
|
||||
void ReleaseVASurface(void* actx, VADisplay dpy1, VASurfaceID srf1, VADisplay dpy2, VASurfaceID srf2);
|
||||
|
||||
mfxStatus va_to_mfx_status(VAStatus va_res);
|
||||
|
||||
#endif // #ifdef LIBVA_SUPPORT
|
||||
|
||||
#endif // #ifndef __VAAPI_UTILS_H__
|
||||
43
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_utils_android.h
vendored
Normal file
43
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_utils_android.h
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __VAAPI_UTILS_ANDROID_H__
|
||||
#define __VAAPI_UTILS_ANDROID_H__
|
||||
|
||||
#if defined(LIBVA_ANDROID_SUPPORT)
|
||||
|
||||
#include <va/va_android.h>
|
||||
#include "vaapi_utils.h"
|
||||
|
||||
class AndroidLibVA : public CLibVA
|
||||
{
|
||||
public:
|
||||
AndroidLibVA(void);
|
||||
virtual ~AndroidLibVA(void);
|
||||
|
||||
protected:
|
||||
void *m_display;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AndroidLibVA);
|
||||
};
|
||||
|
||||
#endif // #if defined(LIBVA_ANDROID_SUPPORT)
|
||||
|
||||
#endif // #ifndef __VAAPI_UTILS_ANDROID_H__
|
||||
94
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_utils_drm.h
vendored
Normal file
94
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_utils_drm.h
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __VAAPI_UTILS_DRM_H__
|
||||
#define __VAAPI_UTILS_DRM_H__
|
||||
|
||||
#if defined(LIBVA_DRM_SUPPORT)
|
||||
|
||||
#include <va/va_drm.h>
|
||||
#include <va/va_drmcommon.h>
|
||||
#include "vaapi_utils.h"
|
||||
#include "vaapi_allocator.h"
|
||||
|
||||
class drmRenderer;
|
||||
|
||||
class DRMLibVA : public CLibVA
|
||||
{
|
||||
public:
|
||||
DRMLibVA(const std::string& devicePath = "", int type = MFX_LIBVA_DRM);
|
||||
virtual ~DRMLibVA(void);
|
||||
|
||||
inline int getFD() { return m_fd; }
|
||||
|
||||
protected:
|
||||
int m_fd;
|
||||
MfxLoader::VA_DRMProxy m_vadrmlib;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(DRMLibVA);
|
||||
};
|
||||
|
||||
class drmRenderer : public vaapiAllocatorParams::Exporter
|
||||
{
|
||||
public:
|
||||
drmRenderer(int fd, mfxI32 monitorType);
|
||||
virtual ~drmRenderer();
|
||||
|
||||
virtual mfxStatus render(mfxFrameSurface1 * pSurface);
|
||||
|
||||
// vaapiAllocatorParams::Exporter methods
|
||||
virtual void* acquire(mfxMemId mid);
|
||||
virtual void release(mfxMemId mid, void * mem);
|
||||
|
||||
static uint32_t getConnectorType(mfxI32 monitor_type);
|
||||
static const msdk_char* getConnectorName(uint32_t connector_type);
|
||||
|
||||
private:
|
||||
bool getConnector(drmModeRes *resource, uint32_t connector_type);
|
||||
bool setupConnection(drmModeRes *resource, drmModeConnector* connector);
|
||||
bool getPlane();
|
||||
|
||||
bool setMaster();
|
||||
void dropMaster();
|
||||
bool restore();
|
||||
|
||||
const MfxLoader::DRM_Proxy m_drmlib;
|
||||
const MfxLoader::DrmIntel_Proxy m_drmintellib;
|
||||
|
||||
int m_fd;
|
||||
uint32_t m_connector_type;
|
||||
uint32_t m_connectorID;
|
||||
uint32_t m_encoderID;
|
||||
uint32_t m_crtcID;
|
||||
uint32_t m_crtcIndex;
|
||||
uint32_t m_planeID;
|
||||
drmModeModeInfo m_mode;
|
||||
drmModeCrtcPtr m_crtc;
|
||||
drm_intel_bufmgr* m_bufmgr;
|
||||
bool m_overlay_wrn;
|
||||
mfxFrameSurface1 * m_pCurrentRenderTargetSurface;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(drmRenderer);
|
||||
};
|
||||
|
||||
#endif // #if defined(LIBVA_DRM_SUPPORT)
|
||||
|
||||
#endif // #ifndef __VAAPI_UTILS_DRM_H__
|
||||
70
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_utils_x11.h
vendored
Normal file
70
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vaapi_utils_x11.h
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __VAAPI_UTILS_X11_H__
|
||||
#define __VAAPI_UTILS_X11_H__
|
||||
|
||||
#if defined(LIBVA_X11_SUPPORT)
|
||||
|
||||
#include <va/va_x11.h>
|
||||
#include "vaapi_utils.h"
|
||||
|
||||
class X11LibVA : public CLibVA
|
||||
{
|
||||
public:
|
||||
X11LibVA(void);
|
||||
virtual ~X11LibVA(void);
|
||||
|
||||
void *GetXDisplay(void) { return m_display;}
|
||||
|
||||
|
||||
MfxLoader::XLib_Proxy & GetX11() { return m_x11lib; }
|
||||
MfxLoader::VA_X11Proxy & GetVAX11() { return m_vax11lib; }
|
||||
#if defined(X11_DRI3_SUPPORT)
|
||||
MfxLoader::Xcb_Proxy & GetXcbX11() { return m_xcblib; }
|
||||
MfxLoader::X11_Xcb_Proxy & GetX11XcbX11() { return m_x11xcblib; }
|
||||
MfxLoader::XCB_Dri3_Proxy & GetXCBDri3X11() { return m_xcbdri3lib; }
|
||||
MfxLoader::Xcbpresent_Proxy & GetXcbpresentX11() { return m_xcbpresentlib; }
|
||||
MfxLoader::DrmIntel_Proxy & GetDrmIntelX11() { return m_drmintellib; }
|
||||
#endif // X11_DRI3_SUPPORT
|
||||
|
||||
protected:
|
||||
Display* m_display;
|
||||
VAConfigID m_configID;
|
||||
VAContextID m_contextID;
|
||||
MfxLoader::XLib_Proxy m_x11lib;
|
||||
MfxLoader::VA_X11Proxy m_vax11lib;
|
||||
#if defined(X11_DRI3_SUPPORT)
|
||||
MfxLoader::VA_DRMProxy m_vadrmlib;
|
||||
MfxLoader::Xcb_Proxy m_xcblib;
|
||||
MfxLoader::X11_Xcb_Proxy m_x11xcblib;
|
||||
MfxLoader::XCB_Dri3_Proxy m_xcbdri3lib;
|
||||
MfxLoader::Xcbpresent_Proxy m_xcbpresentlib;
|
||||
MfxLoader::DrmIntel_Proxy m_drmintellib;
|
||||
#endif // X11_DRI3_SUPPORT
|
||||
|
||||
private:
|
||||
void Close();
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(X11LibVA);
|
||||
};
|
||||
|
||||
#endif // #if defined(LIBVA_X11_SUPPORT)
|
||||
|
||||
#endif // #ifndef __VAAPI_UTILS_X11_H__
|
||||
45
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/version.h
vendored
Normal file
45
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/version.h
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sample_defs.h"
|
||||
|
||||
#ifndef MSDK_MAJOR
|
||||
#define MSDK_MAJOR 8
|
||||
#endif
|
||||
|
||||
#ifndef MSDK_MINOR
|
||||
#define MSDK_MINOR 4
|
||||
#endif
|
||||
|
||||
#ifndef MSDK_RELEASE
|
||||
#define MSDK_TARGETAPIMINOR 27
|
||||
#endif
|
||||
|
||||
#ifndef MSDK_BUILD
|
||||
#define MSDK_BUILD 0
|
||||
#endif
|
||||
|
||||
static msdk_string GetMSDKSampleVersion()
|
||||
{
|
||||
msdk_stringstream ss;
|
||||
ss << MSDK_MAJOR << "." << MSDK_MINOR << "." << MSDK_TARGETAPIMINOR << "." << MSDK_BUILD;
|
||||
return ss.str();
|
||||
}
|
||||
37
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/atomic_defs.h
vendored
Normal file
37
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/atomic_defs.h
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __ATOMIC_DEFS_H__
|
||||
#define __ATOMIC_DEFS_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
|
||||
/* Thread-safe 16-bit variable incrementing */
|
||||
mfxU16 msdk_atomic_inc16(volatile mfxU16 *pVariable);
|
||||
|
||||
/* Thread-safe 16-bit variable decrementing */
|
||||
mfxU16 msdk_atomic_dec16(volatile mfxU16 *pVariable);
|
||||
|
||||
/* Thread-safe 32-bit variable incrementing */
|
||||
mfxU32 msdk_atomic_inc32(volatile mfxU32 *pVariable);
|
||||
|
||||
/* Thread-safe 32-bit variable decrementing */
|
||||
mfxU32 msdk_atomic_dec32(volatile mfxU32 *pVariable);
|
||||
|
||||
#endif // #ifndef __ATOMIC_DEFS_H__
|
||||
40
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/file_defs.h
vendored
Normal file
40
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/file_defs.h
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __FILE_DEFS_H__
|
||||
#define __FILE_DEFS_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#define MSDK_FOPEN(file, name, mode) _tfopen_s(&file, name, mode)
|
||||
|
||||
#define msdk_fgets _fgetts
|
||||
#else // #if defined(_WIN32) || defined(_WIN64)
|
||||
#include <unistd.h>
|
||||
|
||||
#define MSDK_FOPEN(file, name, mode) !(file = fopen(name, mode))
|
||||
|
||||
#define msdk_fgets fgets
|
||||
#endif // #if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#endif // #ifndef __FILE_DEFS_H__
|
||||
34
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/so_defs.h
vendored
Normal file
34
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/so_defs.h
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __SO_DEFS_H__
|
||||
#define __SO_DEFS_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#include "strings_defs.h"
|
||||
|
||||
/* Declare shared object handle */
|
||||
typedef void * msdk_so_handle;
|
||||
typedef void (*msdk_func_pointer)(void);
|
||||
|
||||
msdk_so_handle msdk_so_load(const msdk_char *file_name);
|
||||
msdk_func_pointer msdk_so_get_addr(msdk_so_handle handle, const char *func_name);
|
||||
void msdk_so_free(msdk_so_handle handle);
|
||||
|
||||
#endif // #ifndef __SO_DEFS_H__
|
||||
117
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/strings_defs.h
vendored
Normal file
117
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/strings_defs.h
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __STRING_DEFS_H__
|
||||
#define __STRING_DEFS_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#include <tchar.h>
|
||||
|
||||
#define MSDK_STRING(x) _T(x)
|
||||
#define MSDK_CHAR(x) _T(x)
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef std::basic_string<TCHAR> msdk_tstring;
|
||||
#endif
|
||||
typedef TCHAR msdk_char;
|
||||
|
||||
#define msdk_printf _tprintf
|
||||
#define msdk_fprintf _ftprintf
|
||||
#define msdk_sprintf _stprintf_s // to be removed
|
||||
#define msdk_vprintf _vtprintf
|
||||
#define msdk_strlen _tcslen
|
||||
#define msdk_strcmp _tcscmp
|
||||
#define msdk_stricmp _tcsicmp
|
||||
#define msdk_strncmp _tcsnicmp
|
||||
#define msdk_strstr _tcsstr
|
||||
#define msdk_atoi _ttoi
|
||||
#define msdk_strtol _tcstol
|
||||
#define msdk_strtod _tcstod
|
||||
#define msdk_strchr _tcschr
|
||||
#define msdk_strnlen(str,lenmax) strnlen_s(str,lenmax)
|
||||
#define msdk_sscanf _stscanf_s
|
||||
#define msdk_itoa_decimal(value, str) _itot_s(value,str,10)
|
||||
|
||||
// msdk_strcopy is intended to be used with 2 parmeters, i.e. msdk_strcopy(dst, src)
|
||||
// for _tcscpy_s that's possible if DST is declared as: TCHAR DST[n];
|
||||
#define msdk_strcopy _tcscpy_s
|
||||
#define msdk_strncopy_s _tcsncpy_s
|
||||
|
||||
#define MSDK_MEMCPY_BITSTREAM(bitstream, offset, src, count) memcpy_s((bitstream).Data + (offset), (bitstream).MaxLength - (offset), (src), (count))
|
||||
|
||||
#define MSDK_MEMCPY_BUF(bufptr, offset, maxsize, src, count) memcpy_s((bufptr)+ (offset), (maxsize) - (offset), (src), (count))
|
||||
|
||||
#define MSDK_MEMCPY_VAR(dstVarName, src, count) memcpy_s(&(dstVarName), sizeof(dstVarName), (src), (count))
|
||||
|
||||
#define MSDK_MEMCPY(dst, src, count) memcpy_s(dst, (count), (src), (count))
|
||||
|
||||
|
||||
|
||||
#else // #if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#define MSDK_STRING(x) x
|
||||
#define MSDK_CHAR(x) x
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef std::string msdk_tstring;
|
||||
#endif
|
||||
typedef char msdk_char;
|
||||
|
||||
#define msdk_printf printf
|
||||
#define msdk_sprintf sprintf
|
||||
#define msdk_vprintf vprintf
|
||||
#define msdk_fprintf fprintf
|
||||
#define msdk_strlen strlen
|
||||
#define msdk_strcmp strcmp
|
||||
#define msdk_stricmp strcasecmp
|
||||
#define msdk_strncmp strncmp
|
||||
#define msdk_strstr strstr
|
||||
#define msdk_atoi atoi
|
||||
#define msdk_atoll atoll
|
||||
#define msdk_strtol strtol
|
||||
#define msdk_strtod strtod
|
||||
#define msdk_itoa_decimal(value, str) \
|
||||
snprintf(str, sizeof(str)/sizeof(str[0])-1, "%d", value)
|
||||
#define msdk_strnlen(str,maxlen) strlen(str)
|
||||
#define msdk_sscanf sscanf
|
||||
|
||||
#define msdk_strcopy strcpy
|
||||
|
||||
#define msdk_strncopy_s(dst, num_dst, src, count) strncpy(dst, src, count)
|
||||
|
||||
#define MSDK_MEMCPY_BITSTREAM(bitstream, offset, src, count) memcpy((bitstream).Data + (offset), (src), (count))
|
||||
|
||||
#define MSDK_MEMCPY_BUF(bufptr, offset, maxsize, src, count) memcpy((bufptr)+ (offset), (src), (count))
|
||||
|
||||
#define MSDK_MEMCPY_VAR(dstVarName, src, count) memcpy(&(dstVarName), (src), (count))
|
||||
|
||||
#define MSDK_MEMCPY(dst, src, count) memcpy(dst, (src), (count))
|
||||
|
||||
#endif // #if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#endif //__STRING_DEFS_H__
|
||||
154
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/thread_defs.h
vendored
Normal file
154
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/thread_defs.h
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __THREAD_DEFS_H__
|
||||
#define __THREAD_DEFS_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#include "vm/strings_defs.h"
|
||||
|
||||
typedef unsigned int (MFX_STDCALL * msdk_thread_callback)(void*);
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
|
||||
struct msdkSemaphoreHandle
|
||||
{
|
||||
void* m_semaphore;
|
||||
};
|
||||
|
||||
struct msdkEventHandle
|
||||
{
|
||||
void* m_event;
|
||||
};
|
||||
|
||||
struct msdkThreadHandle
|
||||
{
|
||||
void* m_thread;
|
||||
};
|
||||
|
||||
#else // #if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#include <pthread.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
struct msdkSemaphoreHandle
|
||||
{
|
||||
msdkSemaphoreHandle(mfxU32 count):
|
||||
m_count(count)
|
||||
{}
|
||||
|
||||
mfxU32 m_count;
|
||||
pthread_cond_t m_semaphore;
|
||||
pthread_mutex_t m_mutex;
|
||||
};
|
||||
|
||||
struct msdkEventHandle
|
||||
{
|
||||
msdkEventHandle(bool manual, bool state):
|
||||
m_manual(manual),
|
||||
m_state(state)
|
||||
{}
|
||||
|
||||
bool m_manual;
|
||||
bool m_state;
|
||||
pthread_cond_t m_event;
|
||||
pthread_mutex_t m_mutex;
|
||||
};
|
||||
|
||||
class MSDKEvent;
|
||||
|
||||
struct msdkThreadHandle
|
||||
{
|
||||
msdkThreadHandle(
|
||||
msdk_thread_callback func,
|
||||
void* arg):
|
||||
m_func(func),
|
||||
m_arg(arg),
|
||||
m_event(0),
|
||||
m_thread(0)
|
||||
{}
|
||||
|
||||
msdk_thread_callback m_func;
|
||||
void* m_arg;
|
||||
MSDKEvent* m_event;
|
||||
pthread_t m_thread;
|
||||
};
|
||||
|
||||
#endif // #if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
class MSDKSemaphore: public msdkSemaphoreHandle
|
||||
{
|
||||
public:
|
||||
MSDKSemaphore(mfxStatus &sts, mfxU32 count = 0);
|
||||
~MSDKSemaphore(void);
|
||||
|
||||
mfxStatus Post(void);
|
||||
mfxStatus Wait(void);
|
||||
|
||||
private:
|
||||
MSDKSemaphore(const MSDKSemaphore&);
|
||||
void operator=(const MSDKSemaphore&);
|
||||
};
|
||||
|
||||
class MSDKEvent: public msdkEventHandle
|
||||
{
|
||||
public:
|
||||
MSDKEvent(mfxStatus &sts, bool manual, bool state);
|
||||
~MSDKEvent(void);
|
||||
|
||||
mfxStatus Signal(void);
|
||||
mfxStatus Reset(void);
|
||||
mfxStatus Wait(void);
|
||||
mfxStatus TimedWait(mfxU32 msec);
|
||||
|
||||
private:
|
||||
MSDKEvent(const MSDKEvent&);
|
||||
void operator=(const MSDKEvent&);
|
||||
};
|
||||
|
||||
class MSDKThread: public msdkThreadHandle
|
||||
{
|
||||
public:
|
||||
MSDKThread(mfxStatus &sts, msdk_thread_callback func, void* arg);
|
||||
~MSDKThread(void);
|
||||
|
||||
mfxStatus Wait(void);
|
||||
mfxStatus TimedWait(mfxU32 msec);
|
||||
mfxStatus GetExitCode();
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
friend void* msdk_thread_start(void* arg);
|
||||
#endif
|
||||
|
||||
private:
|
||||
MSDKThread(const MSDKThread&);
|
||||
void operator=(const MSDKThread&);
|
||||
};
|
||||
|
||||
mfxU32 msdk_get_current_pid();
|
||||
mfxStatus msdk_setrlimit_vmem(mfxU64 size);
|
||||
mfxStatus msdk_thread_get_schedtype(const msdk_char*, mfxI32 &type);
|
||||
void msdk_thread_printf_scheduling_help();
|
||||
|
||||
#endif //__THREAD_DEFS_H__
|
||||
68
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/time_defs.h
vendored
Normal file
68
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vm/time_defs.h
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __TIME_DEFS_H__
|
||||
#define __TIME_DEFS_H__
|
||||
|
||||
#include "mfxdefs.h"
|
||||
#include "mfx_itt_trace.h"
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define MSDK_SLEEP(msec) Sleep(msec)
|
||||
|
||||
#define MSDK_USLEEP(usec) \
|
||||
{ \
|
||||
LARGE_INTEGER due; \
|
||||
due.QuadPart = -(10*(int)usec); \
|
||||
HANDLE t = CreateWaitableTimer(NULL, TRUE, NULL); \
|
||||
SetWaitableTimer(t, &due, 0, NULL, NULL, 0); \
|
||||
WaitForSingleObject(t, INFINITE); \
|
||||
CloseHandle(t); \
|
||||
}
|
||||
|
||||
#else // #if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define MSDK_SLEEP(msec) \
|
||||
do { \
|
||||
MFX_ITT_TASK("MSDK_SLEEP"); \
|
||||
usleep(1000*msec); \
|
||||
} while(0)
|
||||
|
||||
#define MSDK_USLEEP(usec) \
|
||||
do { \
|
||||
MFX_ITT_TASK("MSDK_USLEEP"); \
|
||||
usleep(usec); \
|
||||
} while(0)
|
||||
|
||||
#endif // #if defined(_WIN32) || defined(_WIN64)
|
||||
|
||||
#define MSDK_GET_TIME(T,S,F) ((mfxF64)((T)-(S))/(mfxF64)(F))
|
||||
|
||||
typedef mfxI64 msdk_tick;
|
||||
|
||||
msdk_tick msdk_time_get_tick(void);
|
||||
msdk_tick msdk_time_get_frequency(void);
|
||||
mfxU64 rdtsc(void);
|
||||
|
||||
#endif // #ifndef __TIME_DEFS_H__
|
||||
59
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vpp_ex.h
vendored
Normal file
59
libs/hwcodec/externals/MediaSDK_22.5.4/samples/sample_common/include/vpp_ex.h
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/******************************************************************************\
|
||||
Copyright (c) 2005-2019, Intel Corporation
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This sample was distributed or derived from the Intel's Media Samples package.
|
||||
The original version of this sample may be obtained from https://software.intel.com/en-us/intel-media-server-studio
|
||||
or https://software.intel.com/en-us/media-client-solutions-support.
|
||||
\**********************************************************************************/
|
||||
|
||||
#ifndef __VPP_EX_H__
|
||||
#define __VPP_EX_H__
|
||||
|
||||
#include "sample_utils.h"
|
||||
#include "mfxvideo++.h"
|
||||
#include <vector>
|
||||
|
||||
/* #define USE_VPP_EX */
|
||||
|
||||
class MFXVideoVPPEx : public MFXVideoVPP
|
||||
{
|
||||
|
||||
public:
|
||||
MFXVideoVPPEx(mfxSession session);
|
||||
|
||||
#if defined USE_VPP_EX
|
||||
|
||||
mfxStatus QueryIOSurf(mfxVideoParam *par, mfxFrameAllocRequest request[2]);
|
||||
mfxStatus Query(mfxVideoParam *in, mfxVideoParam *out);
|
||||
mfxStatus Init(mfxVideoParam *par);
|
||||
mfxStatus RunFrameVPPAsync(mfxFrameSurface1 *in, mfxFrameSurface1 *out, mfxExtVppAuxData *aux, mfxSyncPoint *syncp);
|
||||
mfxStatus GetVideoParam(mfxVideoParam *par);
|
||||
mfxStatus Close(void);
|
||||
|
||||
protected:
|
||||
|
||||
std::vector<mfxFrameSurface1*> m_LockedSurfacesList;
|
||||
mfxVideoParam m_VideoParams;
|
||||
|
||||
mfxU64 m_nCurrentPTS;
|
||||
|
||||
mfxU64 m_nIncreaseTime;
|
||||
mfxU64 m_nArraySize;
|
||||
mfxU64 m_nInputTimeStamp;
|
||||
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif //__VPP_EX_H__
|
||||
Reference in New Issue
Block a user