1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
// Copyright (c) 2008-2018 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef __MFX_MPEG2_ENCODE_HW_H__
#define __MFX_MPEG2_ENCODE_HW_H__
#include "mfx_common.h"
#if defined (MFX_ENABLE_MPEG2_VIDEO_ENCODE)
#include "mfxvideo++int.h"
#include "mfx_mpeg2_encode_full_hw.h"
#include "mfx_mpeg2_encode_utils_hw.h"
class MFXVideoENCODEMPEG2_HW : public VideoENCODE
{
public:
static mfxStatus Query(VideoCORE *core, mfxVideoParam *in, mfxVideoParam *out)
{
return MPEG2EncoderHW::ControllerBase::Query(core,in,out);
}
static mfxStatus QueryIOSurf(VideoCORE *core, mfxVideoParam *par, mfxFrameAllocRequest *request)
{
return MPEG2EncoderHW::ControllerBase::QueryIOSurf(core,par,request);
}
static mfxStatus QueryImplsDescription(VideoCORE& core, mfxEncoderDescription::encoder& caps, mfx::PODArraysHolder& ah)
{
return MPEG2EncoderHW::ControllerBase::QueryImplsDescription(core, caps, ah);
}
MFXVideoENCODEMPEG2_HW(VideoCORE *core, mfxStatus *sts)
{
m_pCore = core;
pEncoder = 0;
*sts = MFX_ERR_NONE;
}
virtual ~MFXVideoENCODEMPEG2_HW() override {Close();}
virtual mfxStatus Init(mfxVideoParam *par) override
{
mfxStatus sts = MFX_ERR_NONE;
ENCODE_CAPS Caps = {};
MPEG2EncoderHW::HW_MODE mode = MPEG2EncoderHW::UNSUPPORTED;
if (pEncoder)
{
return MFX_ERR_UNDEFINED_BEHAVIOR;
}
sts = MPEG2EncoderHW::CheckHwCaps(m_pCore, par, 0, &Caps);
MFX_CHECK_STS(sts);
mode = MPEG2EncoderHW::GetHwEncodeMode(Caps);
if (mode == MPEG2EncoderHW::FULL_ENCODE)
{
pEncoder = new MPEG2EncoderHW::FullEncode(m_pCore,&sts);
}
else
{
return MFX_ERR_UNSUPPORTED;
}
sts = pEncoder->Init(par);
if (sts < MFX_ERR_NONE)
{
Close();
return sts;
}
return sts;
}
virtual mfxStatus Reset(mfxVideoParam *par) override
{
if (!pEncoder)
{
return MFX_ERR_NOT_INITIALIZED;
}
return pEncoder->Reset(par);
}
virtual mfxStatus Close(void) override
{
mfxStatus sts = MFX_ERR_NONE;
if (pEncoder)
{
sts = pEncoder->Close();
delete pEncoder;
pEncoder = 0;
}
return sts;
}
virtual mfxStatus GetVideoParam(mfxVideoParam *par) override
{
if (!pEncoder)
{
return MFX_ERR_NOT_INITIALIZED;
}
return pEncoder->GetVideoParam(par);
}
virtual mfxStatus GetFrameParam(mfxFrameParam *) override
{
return MFX_ERR_UNSUPPORTED;
}
virtual mfxStatus GetEncodeStat(mfxEncodeStat *stat) override
{
if (!pEncoder)
{
return MFX_ERR_NOT_INITIALIZED;
}
return pEncoder->GetEncodeStat(stat);
}
virtual mfxStatus EncodeFrameCheck(mfxEncodeCtrl *ctrl,
mfxFrameSurface1 *surface,
mfxBitstream *bs, mfxFrameSurface1 **reordered_surface,
mfxEncodeInternalParams *pInternalParams) override
{
if (!pEncoder)
{
return MFX_ERR_NOT_INITIALIZED;
}
return pEncoder->EncodeFrameCheck(ctrl,surface,bs,reordered_surface,pInternalParams);
}
virtual mfxStatus EncodeFrame(mfxEncodeCtrl *ctrl,
mfxEncodeInternalParams *pInternalParams,
mfxFrameSurface1 *surface,
mfxBitstream *bs) override
{
if (!pEncoder)
{
return MFX_ERR_NOT_INITIALIZED;
}
return pEncoder->EncodeFrame(ctrl,pInternalParams,surface,bs);
}
virtual mfxStatus CancelFrame(mfxEncodeCtrl *ctrl,
mfxEncodeInternalParams *pInternalParams,
mfxFrameSurface1 *surface,
mfxBitstream *bs) override
{
if (!pEncoder)
{
return MFX_ERR_NOT_INITIALIZED;
}
return pEncoder->CancelFrame(ctrl,pInternalParams,surface,bs);
}
virtual
mfxStatus EncodeFrameCheck(mfxEncodeCtrl *ctrl,
mfxFrameSurface1 *surface,
mfxBitstream *bs,
mfxFrameSurface1 **reordered_surface,
mfxEncodeInternalParams *pInternalParams,
MFX_ENTRY_POINT pEntryPoints[],
mfxU32 &numEntryPoints) override
{
if (!pEncoder)
{
return MFX_ERR_NOT_INITIALIZED;
}
return pEncoder->EncodeFrameCheck(ctrl,surface,bs,reordered_surface,pInternalParams,pEntryPoints,numEntryPoints);
}
virtual
mfxTaskThreadingPolicy GetThreadingPolicy(void) override
{
if (!pEncoder)
{
return MFX_TASK_THREADING_DEFAULT;
}
return pEncoder->GetThreadingPolicy();
}
MFX_PROPAGATE_GetSurface_VideoENCODE_Definition;
private:
VideoCORE* m_pCore;
MPEG2EncoderHW::EncoderBase* pEncoder;
};
MFX_PROPAGATE_GetSurface_VideoENCODE_Impl(MFXVideoENCODEMPEG2_HW);
#endif // MFX_ENABLE_MPEG2_VIDEO_ENCODE
#endif
|