Commit 8f138250 authored by Gurulev, Dmitry's avatar Gurulev, Dmitry Committed by Oleg Nabiullin

h265d: cleanup VA packers

Cleanup packer interface, remove redundant method args,
use unsigned types & const whenever it's possible

Issue: MDP-52201
Test: hevcd_conf, hevcd_sbe, hevcd_conf_allegro, hevcd_afl_broken
parent 41f252bd
......@@ -250,7 +250,7 @@ public:
}
// Return bitstream array base address and size
void GetOrg(uint32_t **pbs, uint32_t *size);
void GetOrg(uint32_t **pbs, uint32_t *size) const;
// Return current bitstream address and bit offset
void GetState(uint32_t **pbs, uint32_t *bitOffset);
// Set current bitstream address and bit offset
......
......@@ -151,7 +151,10 @@ public: // DEBUG !!!! should remove dependence
H265HeadersBitstream m_BitStream; // (H265Bitstream) slice bit stream
// Obtain bit stream object
H265HeadersBitstream *GetBitStream(){return &m_BitStream;}
H265HeadersBitstream* GetBitStream()
{ return &m_BitStream; }
H265HeadersBitstream const* GetBitStream() const
{ return &m_BitStream; }
protected:
const H265PicParamSet* m_pPicParamSet; // (H265PicParamSet *) pointer to array of picture parameters sets
......
......@@ -159,57 +159,52 @@ public:
virtual void BeginFrame(H265DecoderFrame*) = 0;
virtual void EndFrame() = 0;
virtual void PackAU(const H265DecoderFrame *pCurrentFrame, TaskSupplier_H265 * supplier) = 0;
virtual void PackPicParams(const H265DecoderFrame *pCurrentFrame,
H265DecoderFrameInfo * pSliceInfo,
TaskSupplier_H265 * supplier) = 0;
virtual bool PackSliceParams(H265Slice *pSlice, uint32_t &sliceNum, bool isLastSlice) = 0;
virtual void PackAU(H265DecoderFrame const*, TaskSupplier_H265*) = 0;
virtual void PackPicParams(H265DecoderFrame const*, TaskSupplier_H265*) = 0;
virtual void PackSliceParams(H265Slice const*, size_t, bool isLastSlice) = 0;
virtual void PackQmatrix(const H265Slice *pSlice) = 0;
static Packer * CreatePacker(UMC::VideoAccelerator * va);
protected:
UMC::VideoAccelerator *m_va;
};
class PackerVA : public Packer
class PackerVA
: public Packer
{
public:
PackerVA(UMC::VideoAccelerator * va);
virtual UMC::Status GetStatusReport(void * pStatusReport, size_t size);
virtual UMC::Status SyncTask(int32_t index, void * error) { return m_va->SyncTask(index, error); }
virtual void PackQmatrix(const H265Slice *pSlice);
PackerVA(UMC::VideoAccelerator* va)
: Packer(va)
{}
virtual void PackPicParams(const H265DecoderFrame *pCurrentFrame,
H265DecoderFrameInfo * pSliceInfo,
TaskSupplier_H265 * supplier);
UMC::Status GetStatusReport(void*, size_t) override
{ return UMC::UMC_OK; }
virtual bool PackSliceParams(H265Slice *pSlice, uint32_t &sliceNum, bool isLastSlice);
UMC::Status SyncTask(int32_t index, void* error) override
{ return m_va->SyncTask(index, error); }
virtual void BeginFrame(H265DecoderFrame*);
virtual void EndFrame();
void BeginFrame(H265DecoderFrame*) override;
void EndFrame() override
{ /* Nothing to do */ }
virtual void PackAU(const H265DecoderFrame *pCurrentFrame, TaskSupplier_H265 * supplier);
void PackAU(H265DecoderFrame const*, TaskSupplier_H265*) override;
private:
void CreateSliceDataBuffer(H265DecoderFrameInfo * sliceInfo);
void CreateSliceParamBuffer(H265DecoderFrameInfo * sliceInfo);
};
void PackPicParams(H265DecoderFrame const*, TaskSupplier_H265*) override;
void PackSliceParams(H265Slice const*, size_t, bool isLastSlice) override;
void PackQmatrix(H265Slice const*) override;
private:
void CreateSliceDataBuffer(H265DecoderFrameInfo const*);
void CreateSliceParamBuffer(H265DecoderFrameInfo const*);
};
inline bool IsVLDProfile (int32_t profile)
{
return (profile & UMC::VA_VLD) != 0;
}
} // namespace UMC_HEVC_DECODER
......
......@@ -65,7 +65,7 @@ void H265BaseBitstream::Reset(uint8_t * const pb, int32_t offset, const uint32_t
} // void Reset(uint8_t * const pb, int32_t offset, const uint32_t maxsize)
// Return bitstream array base address and size
void H265BaseBitstream::GetOrg(uint32_t **pbs, uint32_t *size)
void H265BaseBitstream::GetOrg(uint32_t **pbs, uint32_t *size) const
{
*pbs = m_pbsBase;
*size = m_maxBsSize;
......
......@@ -79,11 +79,7 @@ namespace UMC_HEVC_DECODER
Packer * Packer::CreatePacker(UMC::VideoAccelerator * va)
{
Packer * packer = 0;
packer = new PackerVA(va);
return packer;
return new PackerVA{va};
}
Packer::Packer(UMC::VideoAccelerator * va)
......@@ -98,19 +94,14 @@ Packer::~Packer()
/****************************************************************************************************/
// VA linux packer implementation
/****************************************************************************************************/
PackerVA::PackerVA(VideoAccelerator * va)
: Packer(va)
{
}
Status PackerVA::GetStatusReport(void * , size_t )
void PackerVA::PackPicParams(const H265DecoderFrame *pCurrentFrame, TaskSupplier_H265 *supplier)
{
return UMC_OK;
}
H265DecoderFrameInfo const* pSliceInfo = pCurrentFrame->GetAU();
if (!pSliceInfo)
throw h265_exception(UMC::UMC_ERR_FAILED);
void PackerVA::PackPicParams(const H265DecoderFrame *pCurrentFrame, H265DecoderFrameInfo * pSliceInfo, TaskSupplier_H265 *supplier)
{
H265Slice * pSlice = pSliceInfo->GetSlice(0);
auto pSlice = pSliceInfo->GetSlice(0);
const H265SliceHeader* sliceHeader = pSlice->GetSliceHeader();
const H265SeqParamSet* pSeqParamSet = pSlice->GetSeqParam();
const H265PicParamSet* pPicParamSet = pSlice->GetPicParam();
......@@ -122,7 +113,7 @@ void PackerVA::PackPicParams(const H265DecoderFrame *pCurrentFrame, H265DecoderF
UMCVACompBuffer *picParamBuf = nullptr;
#if (MFX_VERSION >= 1027)
if (m_va->m_Profile &VA_PROFILE_REXT)
if (m_va->m_Profile & VA_PROFILE_REXT)
{
picParamExt = (VAPictureParameterBufferHEVCExtension*)m_va->GetCompBuffer(VAPictureParameterBufferType, &picParamBuf, sizeof(VAPictureParameterBufferHEVCExtension));
if (!picParamExt)
......@@ -180,7 +171,7 @@ void PackerVA::PackPicParams(const H265DecoderFrame *pCurrentFrame, H265DecoderF
picParam->ReferenceFrames[n].flags = VA_PICTURE_HEVC_INVALID;
}
ReferencePictureSet *rps = pSlice->getRPS();
auto rps = pSlice->getRPS();
uint32_t index;
int32_t pocList[3*8];
int32_t numRefPicSetStCurrBefore = 0,
......@@ -346,14 +337,14 @@ void PackerVA::PackPicParams(const H265DecoderFrame *pCurrentFrame, H265DecoderF
#endif // #if (MFX_VERSION >= 1027)
}
void PackerVA::CreateSliceParamBuffer(H265DecoderFrameInfo * sliceInfo)
void PackerVA::CreateSliceParamBuffer(H265DecoderFrameInfo const* sliceInfo)
{
int32_t count = sliceInfo->GetSliceCount();
UMCVACompBuffer *pSliceParamBuf;
size_t sizeOfStruct = m_va->IsLongSliceControl() ? sizeof(VASliceParameterBufferHEVC) : sizeof(VASliceParameterBufferBase);
#if (MFX_VERSION >= 1027)
if (m_va->m_Profile &VA_PROFILE_REXT) /* RExt cases*/
if (m_va->m_Profile & VA_PROFILE_REXT) /* RExt cases*/
{
sizeOfStruct = m_va->IsLongSliceControl() ? sizeof(VASliceParameterBufferHEVCExtension) : sizeof(VASliceParameterBufferBase);
}
......@@ -365,7 +356,7 @@ void PackerVA::CreateSliceParamBuffer(H265DecoderFrameInfo * sliceInfo)
pSliceParamBuf->SetNumOfItem(count);
}
void PackerVA::CreateSliceDataBuffer(H265DecoderFrameInfo * sliceInfo)
void PackerVA::CreateSliceDataBuffer(H265DecoderFrameInfo const* sliceInfo)
{
int32_t count = sliceInfo->GetSliceCount();
......@@ -396,7 +387,7 @@ void PackerVA::CreateSliceDataBuffer(H265DecoderFrameInfo * sliceInfo)
compBuf->SetDataSize(0);
}
bool PackerVA::PackSliceParams(H265Slice *pSlice, uint32_t &sliceNum, bool isLastSlice)
void PackerVA::PackSliceParams(H265Slice const* pSlice, size_t sliceNum, bool isLastSlice)
{
static uint8_t start_code_prefix[] = {0, 0, 1};
......@@ -416,7 +407,7 @@ bool PackerVA::PackSliceParams(H265Slice *pSlice, uint32_t &sliceNum, bool isLas
UMCVACompBuffer* compBuf = nullptr;
#if (MFX_VERSION >= 1027)
if (m_va->m_Profile &VA_PROFILE_REXT)
if (m_va->m_Profile & VA_PROFILE_REXT)
{
picParamsExt = (VAPictureParameterBufferHEVCExtension*)m_va->GetCompBuffer(VAPictureParameterBufferType);
if (!picParamsExt)
......@@ -489,7 +480,7 @@ bool PackerVA::PackSliceParams(H265Slice *pSlice, uint32_t &sliceNum, bool isLas
compBuf->SetDataSize(sliceParams->slice_data_offset + sliceParams->slice_data_size);
if (!m_va->IsLongSliceControl())
return true;
return;
sliceParams->slice_data_byte_offset = pSlice->m_BitStream.BytesDecoded() + sizeof(start_code_prefix);
sliceParams->slice_segment_address = sliceHeader->slice_segment_address;
......@@ -645,8 +636,6 @@ bool PackerVA::PackSliceParams(H265Slice *pSlice, uint32_t &sliceNum, bool isLas
sliceParamsRExt->slice_act_cr_qp_offset = (int8_t)sliceHeader->slice_act_cr_qp_offset;
}
#endif // #if (MFX_VERSION >= 1027)
return true;
}
void PackerVA::PackQmatrix(const H265Slice *pSlice)
......@@ -711,9 +700,11 @@ void PackerVA::PackQmatrix(const H265Slice *pSlice)
void PackerVA::PackAU(const H265DecoderFrame *frame, TaskSupplier_H265 * supplier)
{
H265DecoderFrameInfo * sliceInfo = frame->m_pSlicesInfo;
int sliceCount = sliceInfo->GetSliceCount();
if (!frame || !supplier)
throw h265_exception(UMC_ERR_NULL_PTR);
H265DecoderFrameInfo const* sliceInfo = frame->m_pSlicesInfo;
size_t const sliceCount = sliceInfo->GetSliceCount();
if (!sliceCount)
return;
......@@ -721,7 +712,7 @@ void PackerVA::PackAU(const H265DecoderFrame *frame, TaskSupplier_H265 * supplie
const H265SeqParamSet *pSeqParamSet = pSlice->GetSeqParam();
H265DecoderFrame *pCurrentFrame = pSlice->GetCurrentFrame();
PackPicParams(pCurrentFrame, sliceInfo, supplier);
PackPicParams(pCurrentFrame, supplier);
if (pSeqParamSet->scaling_list_enabled_flag)
{
......@@ -731,8 +722,8 @@ void PackerVA::PackAU(const H265DecoderFrame *frame, TaskSupplier_H265 * supplie
CreateSliceParamBuffer(sliceInfo);
CreateSliceDataBuffer(sliceInfo);
uint32_t sliceNum = 0;
for (int32_t n = 0; n < sliceCount; n++)
size_t sliceNum = 0;
for (size_t n = 0; n < sliceCount; n++)
{
PackSliceParams(sliceInfo->GetSlice(n), sliceNum, n == sliceCount - 1);
sliceNum++;
......@@ -747,11 +738,6 @@ void PackerVA::BeginFrame(H265DecoderFrame* /* frame */)
{
}
void PackerVA::EndFrame()
{
}
} // namespace UMC_HEVC_DECODER
#endif // MFX_ENABLE_H265_VIDEO_DECODE
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment