Skip to content

Commit

Permalink
[Encode] Add support for VP9 seg id block size
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen, Bohan authored and gfxVPLsdm committed Aug 7, 2024
1 parent 9c93cd6 commit 8d5a2e1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ namespace MfxHwVP9Encode
MFX_FOURCC_VP9_SEGMAP = MFX_MAKEFOURCC('V','P','8','S'),
};

enum
{
BLOCK_16x16 = 0,
BLOCK_32x32 = 1,
BLOCK_64x64 = 2,
BLOCK_8x8 = 4
};

typedef struct
{
VASurfaceID surface;
Expand Down
22 changes: 20 additions & 2 deletions _studio/mfx_lib/encode_hw/vp9/src/mfx_vp9_encode_hw_vaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,22 @@ namespace MfxHwVP9Encode
}
} // mfxU16 ConvertSegmentRefControlToVAAPI(mfxU16 refFrameControl)

mfxU32 MapSegIdBlockSizeToVAAPI(mfxU16 size)
{
switch (size)
{
case MFX_VP9_SEGMENT_ID_BLOCK_SIZE_8x8:
return BLOCK_8x8;
case MFX_VP9_SEGMENT_ID_BLOCK_SIZE_32x32:
return BLOCK_32x32;
case MFX_VP9_SEGMENT_ID_BLOCK_SIZE_64x64:
return BLOCK_64x64;
case MFX_VP9_SEGMENT_ID_BLOCK_SIZE_16x16:
default:
return BLOCK_16x16;
}
}

void FillSpsBuffer(mfxVideoParam const & par, VAEncSequenceParameterBufferVP9 & sps)
{
MFX_AUTO_LTRACE(MFX_TRACE_LEVEL_HOTSPOTS, "FillSpsBuffer");
Expand Down Expand Up @@ -166,10 +182,12 @@ namespace MfxHwVP9Encode
if (pps.pic_flags.bits.show_frame == 0)
pps.pic_flags.bits.super_frame_flag = 1;

//segmentation functionality is not fully implemented yet
if (framePar.segmentation == APP_SEGMENTATION)
{
//pps.pic_flags.bits.seg_id_block_size = BLOCK_16x16; //no such parameter in va
#if VA_CHECK_VERSION(1, 23, 0)
mfxExtVP9Segmentation const & seg = GetActualExtBufferRef(*task.m_pParam, task.m_ctrl);
pps.seg_id_block_size = MapSegIdBlockSizeToVAAPI(seg.SegmentIdBlockSize);
#endif
pps.pic_flags.bits.segmentation_update_map = task.m_frameParam.segmentationUpdateMap;
pps.pic_flags.bits.segmentation_temporal_update = task.m_frameParam.segmentationTemporalUpdate;
pps.pic_flags.bits.auto_segmentation = false; //not supported for now
Expand Down

0 comments on commit 8d5a2e1

Please sign in to comment.