Skip to content

Commit

Permalink
[Decode] BMG CodecHal Layer Open Source
Browse files Browse the repository at this point in the history
This patch is to open source BMG CodecHal code from decode
  • Loading branch information
SteveZIntel authored and intel-mediadev committed Aug 21, 2024
1 parent d9e615e commit f852e1d
Show file tree
Hide file tree
Showing 78 changed files with 5,282 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright (c) 2024, 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.
*/

//!
//! \file decode_av1_downsampling_feature_xe2_hpm.cpp
//! \brief Defines the interface for Av1 decode downsampling feature
//! \details The Av1 decode downsampling feature interface is maintaining the down sampling context.
//!
#include "decode_av1_downsampling_feature_xe2_hpm.h"
#include "decode_av1_basic_feature.h"
#include "decode_av1_reference_frames.h"
#include "decode_utils.h"

#ifdef _DECODE_PROCESSING_SUPPORTED

namespace decode
{
Av1DownSamplingFeatureXe2_Hpm::Av1DownSamplingFeatureXe2_Hpm(
MediaFeatureManager *featureManager, DecodeAllocator *allocator, PMOS_INTERFACE osInterface)
: DecodeDownSamplingFeature(featureManager, allocator, osInterface)
{
}

Av1DownSamplingFeatureXe2_Hpm::~Av1DownSamplingFeatureXe2_Hpm()
{
}

MOS_STATUS Av1DownSamplingFeatureXe2_Hpm::GetRefFrameList(std::vector<uint32_t> &refFrameList)
{
DECODE_FUNC_CALL();
Av1BasicFeature *av1BasicFeature = dynamic_cast<Av1BasicFeature *>(m_basicFeature);
DECODE_CHK_NULL(av1BasicFeature);

std::vector<uint32_t> refFrameIndexList;
refFrameIndexList.clear();
for (auto i = 0; i < av1TotalRefsPerFrame; i++)
{
uint8_t index = av1BasicFeature->m_av1PicParams->m_refFrameMap[i].FrameIdx;
if (index < CODECHAL_MAX_DPB_NUM_AV1)
{
refFrameIndexList.push_back(index);
}
}

refFrameList.clear();
for (uint32_t frameIdx : refFrameIndexList)
{
refFrameList.push_back(frameIdx);
}
return MOS_STATUS_SUCCESS;
}

MOS_STATUS Av1DownSamplingFeatureXe2_Hpm::GetDecodeTargetSize(SurfaceWidthT &width, SurfaceHeightT &height)
{
width = m_basicFeature->m_width;
height = m_basicFeature->m_height;
return MOS_STATUS_SUCCESS;
}

MOS_STATUS Av1DownSamplingFeatureXe2_Hpm::GetDecodeTargetFormat(MOS_FORMAT &format)
{
DECODE_FUNC_CALL()

auto av1BasicFeature = dynamic_cast<Av1BasicFeature *>(m_basicFeature);
DECODE_CHK_NULL(av1BasicFeature);

auto av1PicParams = av1BasicFeature->m_av1PicParams;
DECODE_CHK_NULL(av1PicParams);

if (av1PicParams->m_profile == 0)
{
if (av1PicParams->m_bitDepthIdx == 0)
{
format = Format_NV12;
}
else if (av1PicParams->m_bitDepthIdx == 1)
{
format = Format_P010;
}
else
{
DECODE_ASSERTMESSAGE("Unsupported sub-sampling format!");
}
}
else
{
DECODE_ASSERTMESSAGE("The profile has not been supported yet!");
return MOS_STATUS_UNKNOWN;
}

return MOS_STATUS_SUCCESS;
}

MOS_STATUS Av1DownSamplingFeatureXe2_Hpm::UpdateDecodeTarget(MOS_SURFACE &surface)
{
DECODE_FUNC_CALL();
Av1BasicFeature *av1BasicFeature = dynamic_cast<Av1BasicFeature *>(m_basicFeature);
DECODE_CHK_NULL(av1BasicFeature);

DECODE_CHK_STATUS(av1BasicFeature->UpdateDestSurface(surface));

Av1ReferenceFrames &refFrame = av1BasicFeature->m_refFrames;
PCODEC_REF_LIST_AV1 pRefList = refFrame.m_currRefList;
DECODE_CHK_NULL(pRefList);
DECODE_CHK_STATUS(refFrame.UpdateCurResource(pRefList));
return MOS_STATUS_SUCCESS;
}

} // namespace decode

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2024, 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.
*/
//!
//! \file decode_av1_downsampling_feature_xe2_hpm.h
//! \brief Defines the interface for Av1 decode downsampling feature
//! \details The Av1 decode downsampling feature interface is maintaining the down sampling context.
//!
#ifndef __DECODE_AV1_DOWNSAMPLING_FEATURE_XE2_HPM_H__
#define __DECODE_AV1_DOWNSAMPLING_FEATURE_XE2_HPM_H__

#include "decode_downsampling_feature.h"

#ifdef _DECODE_PROCESSING_SUPPORTED

namespace decode
{
class Av1DownSamplingFeatureXe2_Hpm : public DecodeDownSamplingFeature
{
public:
Av1DownSamplingFeatureXe2_Hpm(MediaFeatureManager *featureManager, DecodeAllocator *allocator, PMOS_INTERFACE osInterface);
virtual ~Av1DownSamplingFeatureXe2_Hpm();

protected:
//virtual MOS_STATUS UpdateInternalTargets(DecodeBasicFeature &basicFeature);
virtual MOS_STATUS GetRefFrameList(std::vector<uint32_t> &refFrameList) override;
virtual MOS_STATUS GetDecodeTargetSize(SurfaceWidthT &width, SurfaceHeightT &height) override;
virtual MOS_STATUS GetDecodeTargetFormat(MOS_FORMAT &format) override;
virtual MOS_STATUS UpdateDecodeTarget(MOS_SURFACE &surface) override;

MEDIA_CLASS_DEFINE_END(decode__Av1DownSamplingFeatureXe2_Hpm)
};
} // namespace decode

#endif // !_DECODE_PROCESSING_SUPPORTED

#endif // !__DECODE_AV1_DOWNSAMPLING_FEATURE_XE2_HPM_H__
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2024, 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.
*/

//!
//! \file decode_av1_feature_manager_xe2_hpm.cpp
//! \brief Defines the common interface for av1 decode feature manager
//! \details The av1 decode feature manager is further sub-divided by codec type
//! this file is for the base interface which is shared by all components.
//!

#include "decode_av1_feature_manager_xe2_hpm.h"
#include "decode_utils.h"
#include "decode_av1_basic_feature_xe_lpm_plus_base.h"
#include "decode_av1_downsampling_feature_xe2_hpm.h"

namespace decode
{
MOS_STATUS DecodeAv1FeatureManagerXe2_Hpm::CreateFeatures(void *codecSettings)
{
DECODE_FUNC_CALL()

DECODE_CHK_STATUS(DecodeFeatureManager::CreateFeatures(codecSettings));

Av1BasicFeature *decBasic = MOS_New(Av1BasicFeatureXe_Lpm_Plus_Base, m_allocator, m_hwInterface, m_osInterface);
DECODE_CHK_STATUS(RegisterFeatures(FeatureIDs::basicFeature, decBasic));

#ifdef _DECODE_PROCESSING_SUPPORTED
auto decDownSampling = MOS_New(Av1DownSamplingFeatureXe2_Hpm, this, m_allocator, m_osInterface);
DECODE_CHK_STATUS(RegisterFeatures(DecodeFeatureIDs::decodeDownSampling, decDownSampling));
#endif

return MOS_STATUS_SUCCESS;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright (c) 2024, 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.
*/

//!
//! \file decode_av1_feature_manager_xe2_hpm.h
//! \brief Defines the common interface for av1 decode feature manager for Xe2_HPM+
//! \details The av1 decode feature manager is further sub-divided by codec type
//! this file is for the base interface which is shared by all components.
//!

#ifndef __DECODE_AV1_FEATURE_MANAGER_XE2_HPM_BASE_H__
#define __DECODE_AV1_FEATURE_MANAGER_XE2_HPM_BASE_H__

#include <vector>
#include "decode_av1_feature_manager_xe_lpm_plus_base.h"

namespace decode
{
class DecodeAv1FeatureManagerXe2_Hpm : public DecodeAv1FeatureManagerXe_Lpm_Plus_Base
{
public:
//!
//! \brief DecodeAv1FeatureManagerXe2_Hpm_Base constructor
//! \param [in] allocator
//! Pointer to DecodeAllocator
//! \param [in] hwInterface
//! Pointer to CodechalHwInterface
//! \param [in] trackedBuf
//! Pointer to TrackedBuffer
//! \param [in] recycleBuf
//! Pointer to RecycleResource
//!
DecodeAv1FeatureManagerXe2_Hpm(DecodeAllocator *allocator, void *hwInterface, PMOS_INTERFACE osInterface)
: DecodeAv1FeatureManagerXe_Lpm_Plus_Base(allocator, hwInterface, osInterface)
{}

//!
//! \brief DecodeAv1FeatureManager deconstructor
//!
virtual ~DecodeAv1FeatureManagerXe2_Hpm() {}

protected:
//!
//! \brief Create features
//! \param [in] codecSettings
//! codec settings
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
virtual MOS_STATUS CreateFeatures(void *codecSettings) override;

MEDIA_CLASS_DEFINE_END(decode__DecodeAv1FeatureManagerXe2_Hpm)
};

}
#endif // !__DECODE_AV1_FEATURE_MANAGER_XE2_HPM_BASE_H__
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2021-2024, 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.

if(${AV1_Decode_Supported} STREQUAL "yes")
set(SOFTLET_DECODE_AV1_SOURCES_
${SOFTLET_DECODE_AV1_SOURCES_}
${CMAKE_CURRENT_LIST_DIR}/decode_av1_downsampling_feature_xe2_hpm.cpp
${CMAKE_CURRENT_LIST_DIR}/decode_av1_feature_manager_xe2_hpm.cpp
)

set(SOFTLET_DECODE_AV1_HEADERS_
${SOFTLET_DECODE_AV1_HEADERS_}
${CMAKE_CURRENT_LIST_DIR}/decode_av1_downsampling_feature_xe2_hpm.h
${CMAKE_CURRENT_LIST_DIR}/decode_av1_feature_manager_xe2_hpm.h
)
source_group( CodecHalNext\\Xe2_HPM\\Decode FILES ${SOFTLET_DECODE_AV1_SOURCES_} ${SOFTLET_DECODE_AV1_HEADERS_} )

endif()

set(SOFTLET_DECODE_AV1_PRIVATE_INCLUDE_DIRS_
${SOFTLET_DECODE_AV1_PRIVATE_INCLUDE_DIRS_}
${CMAKE_CURRENT_LIST_DIR}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2024, 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.

media_include_subdirectory(pipeline)
media_include_subdirectory(packet)
media_include_subdirectory(features)
Loading

0 comments on commit f852e1d

Please sign in to comment.