forked from intel/libyami
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vpp: add opencl based alpha blending
it's just a bare-bone application to test all base class works. it waiting for opencl kernels.
- Loading branch information
1 parent
8bedf1f
commit 9db518b
Showing
7 changed files
with
249 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* oclpostprocess_base.cpp - base class for opencl based vpp | ||
* | ||
* Copyright (C) 2015 Intel Corporation | ||
* Author: Xu Guangxin <[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
|
||
#include "oclpostprocess_base.h" | ||
#include "common/log.h" | ||
#include "ocl/oclcontext.h" | ||
|
||
namespace YamiMediaCodec{ | ||
|
||
OclPostProcessBase::OclPostProcessBase() | ||
:m_kernel(0) | ||
{ | ||
} | ||
|
||
YamiStatus OclPostProcessBase::setNativeDisplay(const NativeDisplay& display) | ||
{ | ||
if (display.type != NATIVE_DISPLAY_VA | ||
|| !display.handle) { | ||
ERROR("vpp only support va display as NativeDisplay"); | ||
return YAMI_INVALID_PARAM; | ||
} | ||
m_display = (VADisplay)display.handle; | ||
return YAMI_SUCCESS; | ||
} | ||
|
||
YamiStatus OclPostProcessBase::ensureContext(const char* kernalName) | ||
{ | ||
if (m_kernel) | ||
return YAMI_SUCCESS; | ||
m_context = OclContext::create(); | ||
if (!m_context || !m_context->createKernel(kernalName,m_kernel)) | ||
return YAMI_DRIVER_FAIL; | ||
return YAMI_SUCCESS; | ||
} | ||
|
||
OclPostProcessBase::~OclPostProcessBase() | ||
{ | ||
if (m_kernel) { | ||
checkOclStatus(clReleaseKernel(m_kernel), "ReleaseKernel"); | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* oclpostprocess_base.h- base class for opencl based video post process | ||
* | ||
* Copyright (C) 2015 Intel Corporation | ||
* Author: XuGuangxin<[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#ifndef vaapipostprocess_base_h | ||
#define vaapipostprocess_base_h | ||
|
||
#include "VideoPostProcessInterface.h" | ||
#include <CL/opencl.h> | ||
#include <va/va.h> | ||
|
||
namespace YamiMediaCodec{ | ||
class OclContext; | ||
/** | ||
* \class OclPostProcessBase | ||
* \brief Abstract video post process base on opencl | ||
* | ||
*/ | ||
class OclPostProcessBase : public IVideoPostProcess { | ||
public: | ||
// set native display | ||
virtual YamiStatus setNativeDisplay(const NativeDisplay& display); | ||
|
||
YamiStatus ensureContext(const char* kernalName); | ||
// | ||
virtual YamiStatus process(const SharedPtr<VideoFrame>& src, | ||
const SharedPtr<VideoFrame>& dest) = 0; | ||
OclPostProcessBase(); | ||
virtual ~OclPostProcessBase(); | ||
protected: | ||
VADisplay m_display; | ||
cl_kernel m_kernel; | ||
SharedPtr<OclContext> m_context; | ||
}; | ||
} | ||
#endif /* vaapipostprocess_base_h */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* oclpostprocess_blend.cpp - ocl based alpha blending | ||
* | ||
* Copyright (C) 2015 Intel Corporation | ||
* Author: XuGuangxin<[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
|
||
#include "oclpostprocess_blender.h" | ||
#include "vaapipostprocess_factory.h" | ||
#include "common/log.h" | ||
|
||
namespace YamiMediaCodec{ | ||
|
||
|
||
YamiStatus | ||
OclPostProcessBlender::process(const SharedPtr<VideoFrame>& src, | ||
const SharedPtr<VideoFrame>& dest) | ||
{ | ||
YamiStatus status = ensureContext("blend"); | ||
if (status != YAMI_SUCCESS) | ||
return status; | ||
return YAMI_SUCCESS; | ||
} | ||
|
||
const bool OclPostProcessBlender::s_registered = | ||
VaapiPostProcessFactory::register_<OclPostProcessBlender>(YAMI_VPP_OCL_BLENDER); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* oclpostprocess_blend.h - ocl based alpha blending | ||
* | ||
* Copyright (C) 2015 Intel Corporation | ||
* Author: XuGuangxin<[email protected]> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public License | ||
* as published by the Free Software Foundation; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
#ifndef oclpostprocess_blender_h | ||
#define oclpostprocess_blender_h | ||
|
||
|
||
#include "interface/VideoCommonDefs.h" | ||
#include "oclpostprocess_base.h" | ||
|
||
namespace YamiMediaCodec{ | ||
|
||
/** | ||
* \class OclPostProcessBlend | ||
* \brief alpha blending base on opencl | ||
*/ | ||
class OclPostProcessBlender : public OclPostProcessBase { | ||
public: | ||
virtual YamiStatus process(const SharedPtr<VideoFrame>& src, | ||
const SharedPtr<VideoFrame>& dest); | ||
|
||
private: | ||
static const bool s_registered; // VaapiPostProcessFactory registration result | ||
}; | ||
|
||
} | ||
#endif //oclpostprocess_blend_h |