Skip to content

Commit

Permalink
[VP] Use forward_references as the reference for ADI
Browse files Browse the repository at this point in the history
Use forward_references as the reference for ADI_
  • Loading branch information
jiafengy1 authored and intel-mediadev committed Jul 31, 2024
1 parent 7c96458 commit 8017d9c
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 40 deletions.
17 changes: 17 additions & 0 deletions media_driver/linux/common/ddi/media_libva.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6722,6 +6722,23 @@ DdiMedia_QueryVideoProcPipelineCaps(
pipeline_caps->min_output_width = VP_MIN_PIC_WIDTH;
pipeline_caps->min_output_height = VP_MIN_PIC_WIDTH;
}


for (int i = 0; i < num_filters; i++) {
void *pData;
DdiMedia_MapBuffer(ctx, filters[i], &pData);
DDI_CHK_NULL(pData, "nullptr pData", VA_STATUS_ERROR_INVALID_PARAMETER);
VAProcFilterParameterBufferBase* base_param = (VAProcFilterParameterBufferBase*) pData;
if (base_param->type == VAProcFilterDeinterlacing)
{
VAProcFilterParameterBufferDeinterlacing *di_param = (VAProcFilterParameterBufferDeinterlacing *)base_param;
if (di_param->algorithm == VAProcDeinterlacingMotionAdaptive ||
di_param->algorithm == VAProcDeinterlacingMotionCompensated)
{
pipeline_caps->num_forward_references = 1;
}
}
}
return VA_STATUS_SUCCESS;
}

Expand Down
42 changes: 22 additions & 20 deletions media_driver/linux/common/vp/ddi/media_libva_vp.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ VAStatus DdiVp_SetProcFilterTotalColorCorrectionParams(PDDI_VP_CONTEXT, uint
VAStatus DdiVp_SetProcFilterHdrTmParams(PDDI_VP_CONTEXT, uint32_t, VAProcFilterParameterBufferHDRToneMapping*);
VAStatus DdiVp_SetProcPipelineBlendingParams(PDDI_VP_CONTEXT pVpCtx, uint32_t uiSurfIndex, VAProcPipelineParameterBuffer* pPipelineParam);
VAStatus DdiVp_ConvertSurface (VADriverContextP ctx, DDI_MEDIA_SURFACE *srcSurface, int16_t srcx, int16_t srcy, uint16_t srcw, uint16_t srch, DDI_MEDIA_SURFACE *dstSurface, int16_t destx, int16_t desty, uint16_t destw, uint16_t desth );
VAStatus DdiVp_UpdateProcPipelineForwardReferenceFrames(PDDI_VP_CONTEXT pVpCtx, VADriverContextP pVaDrvCtx, PVPHAL_SURFACE pVpHalSrcSurf, VAProcPipelineParameterBuffer* pPipelineParam);
VAStatus DdiVp_UpdateProcPipelineBackwardReferenceFrames(PDDI_VP_CONTEXT pVpCtx, VADriverContextP pVaDrvCtx, PVPHAL_SURFACE pVpHalSrcSurf, VAProcPipelineParameterBuffer* pPipelineParam);
VAStatus DdiVp_UpdateProcPipelineFutureReferenceFrames(PDDI_VP_CONTEXT pVpCtx, VADriverContextP pVaDrvCtx, PVPHAL_SURFACE pVpHalSrcSurf, VAProcPipelineParameterBuffer* pPipelineParam);
VAStatus DdiVp_UpdateProcPipelinePastReferenceFrames(PDDI_VP_CONTEXT pVpCtx, VADriverContextP pVaDrvCtx, PVPHAL_SURFACE pVpHalSrcSurf, VAProcPipelineParameterBuffer* pPipelineParam);
VAStatus DdiVp_UpdateVphalTargetSurfColorSpace(VADriverContextP, PDDI_VP_CONTEXT, VAProcPipelineParameterBuffer*, uint32_t targetIndex);
VAStatus DdiVp_BeginPictureInt(VADriverContextP pVaDrvCtx, PDDI_VP_CONTEXT pVpCtx, VASurfaceID vaSurfID);
#if VA_CHECK_VERSION(1, 12, 0)
Expand Down Expand Up @@ -1192,15 +1192,15 @@ DdiVp_SetProcPipelineParams(

// Update fwd and bkward ref frames: Required for Advanced processing - will be supported in the future

pVpHalSrcSurf->uFwdRefCount = pPipelineParam->num_forward_references;
pVpHalSrcSurf->uFwdRefCount = pPipelineParam->num_backward_references;

vaStatus = DdiVp_UpdateProcPipelineForwardReferenceFrames(pVpCtx, pVaDrvCtx, pVpHalSrcSurf, pPipelineParam);
DDI_CHK_RET(vaStatus, "Failed to update forward reference frames!");
vaStatus = DdiVp_UpdateProcPipelineFutureReferenceFrames(pVpCtx, pVaDrvCtx, pVpHalSrcSurf, pPipelineParam);
DDI_CHK_RET(vaStatus, "Failed to update future reference frames!");

pVpHalSrcSurf->uBwdRefCount = pPipelineParam->num_backward_references;
pVpHalSrcSurf->uBwdRefCount = pPipelineParam->num_forward_references;

vaStatus = DdiVp_UpdateProcPipelineBackwardReferenceFrames(pVpCtx, pVaDrvCtx, pVpHalSrcSurf, pPipelineParam);
DDI_CHK_RET(vaStatus, "Failed to update backward reference frames!");
vaStatus = DdiVp_UpdateProcPipelinePastReferenceFrames(pVpCtx, pVaDrvCtx, pVpHalSrcSurf, pPipelineParam);
DDI_CHK_RET(vaStatus, "Failed to update past reference frames!");

// Check if filter values changed,if yes, then reset all filters for this surface

Expand Down Expand Up @@ -3945,7 +3945,7 @@ DdiVp_SetProcPipelineBlendingParams(
}

////////////////////////////////////////////////////////////////////////////////
//! \purpose Update the forward reference frames for VPHAL input surface
//! \purpose Update the future reference frames for VPHAL input surface
//! \params
//! [in] pVpCtx : VP context
//! [in] pVaDrvCtx : VA Driver context
Expand All @@ -3955,7 +3955,7 @@ DdiVp_SetProcPipelineBlendingParams(
//! \returns VA_STATUS_SUCCESS if call succeeds
////////////////////////////////////////////////////////////////////////////////
VAStatus
DdiVp_UpdateProcPipelineForwardReferenceFrames(
DdiVp_UpdateProcPipelineFutureReferenceFrames(
PDDI_VP_CONTEXT pVpCtx,
VADriverContextP pVaDrvCtx,
PVPHAL_SURFACE pVpHalSrcSurf,
Expand Down Expand Up @@ -3985,9 +3985,10 @@ DdiVp_UpdateProcPipelineForwardReferenceFrames(

pSurface = pVpHalSrcSurf;

if (pPipelineParam->forward_references != nullptr)
// DDI regard backward_references as future frame, but VPHAL regard pFwdRef as future frame
if (pPipelineParam->backward_references != nullptr)
{
for (i = 0;i < pPipelineParam->num_forward_references; i++)
for (i = 0;i < pPipelineParam->num_backward_references; i++)
{
PDDI_MEDIA_SURFACE pRefSurfBuffObj = nullptr;
if(pSurface->pFwdRef == nullptr)
Expand All @@ -4007,9 +4008,9 @@ DdiVp_UpdateProcPipelineForwardReferenceFrames(
pSurface->pFwdRef->dwWidth = pVpHalSrcSurf->dwWidth;
pSurface->pFwdRef->dwHeight = pVpHalSrcSurf->dwHeight;
pSurface->pFwdRef->dwPitch = pVpHalSrcSurf->dwPitch;
pSurface->uFwdRefCount = pPipelineParam->num_forward_references - i;
pSurface->uFwdRefCount = pPipelineParam->num_backward_references - i;
}
pRefSurfBuffObj = DdiMedia_GetSurfaceFromVASurfaceID(pMediaCtx, pPipelineParam->forward_references[i]);
pRefSurfBuffObj = DdiMedia_GetSurfaceFromVASurfaceID(pMediaCtx, pPipelineParam->backward_references[i]);
DDI_CHK_NULL(pRefSurfBuffObj,
"Null pRefSurfBuffObj!",
VA_STATUS_ERROR_INVALID_SURFACE);
Expand All @@ -4034,7 +4035,7 @@ DdiVp_UpdateProcPipelineForwardReferenceFrames(
}

////////////////////////////////////////////////////////////////////////////////
//! \purpose Update the backward reference frames for VPHAL input surface
//! \purpose Update the past reference frames for VPHAL input surface
//! \params
//! [in] pVpCtx : VP context
//! [in] pVaDrvCtx : VA Driver context
Expand All @@ -4044,7 +4045,7 @@ DdiVp_UpdateProcPipelineForwardReferenceFrames(
//! \returns VA_STATUS_SUCCESS if call succeeds
////////////////////////////////////////////////////////////////////////////////
VAStatus
DdiVp_UpdateProcPipelineBackwardReferenceFrames(
DdiVp_UpdateProcPipelinePastReferenceFrames(
PDDI_VP_CONTEXT pVpCtx,
VADriverContextP pVaDrvCtx,
PVPHAL_SURFACE pVpHalSrcSurf,
Expand Down Expand Up @@ -4074,9 +4075,10 @@ DdiVp_UpdateProcPipelineBackwardReferenceFrames(

pSurface = pVpHalSrcSurf;

if (pPipelineParam->backward_references != nullptr)
// DDI regard forward_references as past frame, but VPHAL regard pBwdRef as past frame
if (pPipelineParam->forward_references != nullptr)
{
for (i = 0;i < pPipelineParam->num_backward_references; i++)
for (i = 0;i < pPipelineParam->num_forward_references ; i++)
{
PDDI_MEDIA_SURFACE pRefSurfBuffObj = nullptr;
if(pSurface->pBwdRef == nullptr)
Expand All @@ -4096,9 +4098,9 @@ DdiVp_UpdateProcPipelineBackwardReferenceFrames(
pSurface->pBwdRef->dwWidth = pVpHalSrcSurf->dwWidth;
pSurface->pBwdRef->dwHeight = pVpHalSrcSurf->dwHeight;
pSurface->pBwdRef->dwPitch = pVpHalSrcSurf->dwPitch;
pSurface->uBwdRefCount = pPipelineParam->num_backward_references - i;;
pSurface->uBwdRefCount = pPipelineParam->num_forward_references - i;;
}
pRefSurfBuffObj = DdiMedia_GetSurfaceFromVASurfaceID(pMediaCtx, pPipelineParam->backward_references[i]);
pRefSurfBuffObj = DdiMedia_GetSurfaceFromVASurfaceID(pMediaCtx, pPipelineParam->forward_references [i]);
DDI_CHK_NULL(pRefSurfBuffObj,
"Null pRefSurfBuffObj!",
VA_STATUS_ERROR_INVALID_SURFACE);
Expand Down
49 changes: 33 additions & 16 deletions media_softlet/linux/common/vp/ddi/ddi_vp_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,23 @@ VAStatus DdiVpFunctions::QueryVideoProcPipelineCaps(
pipelineCaps->min_output_width = VP_MIN_PIC_WIDTH;
pipelineCaps->min_output_height = VP_MIN_PIC_WIDTH;


for (int i = 0; i < filtersNum; i++) {
void *pData;
DdiMedia_MapBuffer(ctx, filters[i], &pData);
DDI_CHK_NULL(pData, "nullptr pData", VA_STATUS_ERROR_INVALID_PARAMETER);
VAProcFilterParameterBufferBase* base_param = (VAProcFilterParameterBufferBase*) pData;
if (base_param->type == VAProcFilterDeinterlacing)
{
VAProcFilterParameterBufferDeinterlacing *di_param = (VAProcFilterParameterBufferDeinterlacing *)base_param;
if (di_param->algorithm == VAProcDeinterlacingMotionAdaptive ||
di_param->algorithm == VAProcDeinterlacingMotionCompensated)
{
pipelineCaps->num_forward_references = 1;
}
}
}

return VA_STATUS_SUCCESS;
}

Expand Down Expand Up @@ -2209,7 +2226,7 @@ MOS_STATUS DdiVpFunctions::VpHalDdiSetupSplitScreenDemoMode(
return eStatus;
}

VAStatus DdiVpFunctions::DdiUpdateProcPipelineForwardReferenceFrames(
VAStatus DdiVpFunctions::DdiUpdateProcPipelineFutureReferenceFrames(
PDDI_VP_CONTEXT vpCtx,
VADriverContextP vaDrvCtx,
PVPHAL_SURFACE vpHalSrcSurf,
Expand All @@ -2230,13 +2247,13 @@ VAStatus DdiVpFunctions::DdiUpdateProcPipelineForwardReferenceFrames(
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx!", VA_STATUS_ERROR_INVALID_CONTEXT);

surface = vpHalSrcSurf;
if (!pipelineParam->forward_references)
if (!pipelineParam->backward_references)
{
DDI_VP_NORMALMESSAGE("nullptr pipelineParam->forward_references");
return VA_STATUS_SUCCESS;
}

for (uint32_t i = 0; i < pipelineParam->num_forward_references; i++)
for (uint32_t i = 0; i < pipelineParam->num_backward_references; i++)
{
if (surface->pFwdRef == nullptr)
{
Expand All @@ -2255,9 +2272,9 @@ VAStatus DdiVpFunctions::DdiUpdateProcPipelineForwardReferenceFrames(
surface->pFwdRef->dwWidth = vpHalSrcSurf->dwWidth;
surface->pFwdRef->dwHeight = vpHalSrcSurf->dwHeight;
surface->pFwdRef->dwPitch = vpHalSrcSurf->dwPitch;
surface->uFwdRefCount = pipelineParam->num_forward_references - i;
surface->uFwdRefCount = pipelineParam->num_backward_references - i;
}
refSurfBuffObj = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, pipelineParam->forward_references[i]);
refSurfBuffObj = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, pipelineParam->backward_references[i]);
DDI_VP_CHK_NULL(refSurfBuffObj, "nullptr refSurfBuffObj!", VA_STATUS_ERROR_INVALID_SURFACE);

surface->pFwdRef->OsResource.bo = refSurfBuffObj->bo;
Expand All @@ -2277,7 +2294,7 @@ VAStatus DdiVpFunctions::DdiUpdateProcPipelineForwardReferenceFrames(
return VA_STATUS_SUCCESS;
}

VAStatus DdiVpFunctions::DdiUpdateProcPipelineBackwardReferenceFrames(
VAStatus DdiVpFunctions::DdiUpdateProcPipelinePastReferenceFrames(
PDDI_VP_CONTEXT vpCtx,
VADriverContextP vaDrvCtx,
PVPHAL_SURFACE vpHalSrcSurf,
Expand All @@ -2298,13 +2315,13 @@ VAStatus DdiVpFunctions::DdiUpdateProcPipelineBackwardReferenceFrames(
DDI_VP_CHK_NULL(mediaCtx, "nullptr mediaCtx!", VA_STATUS_ERROR_INVALID_CONTEXT);

surface = vpHalSrcSurf;
if(!pipelineParam->backward_references)
if(!pipelineParam->forward_references)
{
DDI_VP_NORMALMESSAGE("nullptr pipelineParam->backward_references");
return VA_STATUS_SUCCESS;
}

for (uint32_t i = 0; i < pipelineParam->num_backward_references; i++)
for (uint32_t i = 0; i < pipelineParam->num_forward_references; i++)
{
if (surface->pBwdRef == nullptr)
{
Expand All @@ -2323,9 +2340,9 @@ VAStatus DdiVpFunctions::DdiUpdateProcPipelineBackwardReferenceFrames(
surface->pBwdRef->dwWidth = vpHalSrcSurf->dwWidth;
surface->pBwdRef->dwHeight = vpHalSrcSurf->dwHeight;
surface->pBwdRef->dwPitch = vpHalSrcSurf->dwPitch;
surface->uBwdRefCount = pipelineParam->num_backward_references - i;
surface->uBwdRefCount = pipelineParam->num_forward_references - i;
}
refSurfBuffObj = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, pipelineParam->backward_references[i]);
refSurfBuffObj = MediaLibvaCommonNext::GetSurfaceFromVASurfaceID(mediaCtx, pipelineParam->forward_references[i]);
DDI_VP_CHK_NULL(refSurfBuffObj, "nullptr refSurfBuffObj!", VA_STATUS_ERROR_INVALID_SURFACE);

surface->pBwdRef->OsResource.bo = refSurfBuffObj->bo;
Expand Down Expand Up @@ -4097,15 +4114,15 @@ VAStatus DdiVpFunctions::DdiSetProcPipelineParams(
}

// Update fwd and bkward ref frames: Required for Advanced processing - will be supported in the future
vpHalSrcSurf->uFwdRefCount = pipelineParam->num_forward_references;
vpHalSrcSurf->uFwdRefCount = pipelineParam->num_backward_references;

vaStatus = DdiUpdateProcPipelineForwardReferenceFrames(vpCtx, vaDrvCtx, vpHalSrcSurf, pipelineParam);
DDI_CHK_RET(vaStatus, "Failed to update forward reference frames!");
vaStatus = DdiUpdateProcPipelineFutureReferenceFrames(vpCtx, vaDrvCtx, vpHalSrcSurf, pipelineParam);
DDI_CHK_RET(vaStatus, "Failed to update future reference frames!");

vpHalSrcSurf->uBwdRefCount = pipelineParam->num_backward_references;
vpHalSrcSurf->uBwdRefCount = pipelineParam->num_forward_references;

vaStatus = DdiUpdateProcPipelineBackwardReferenceFrames(vpCtx, vaDrvCtx, vpHalSrcSurf, pipelineParam);
DDI_CHK_RET(vaStatus, "Failed to update backward reference frames!");
vaStatus = DdiUpdateProcPipelinePastReferenceFrames(vpCtx, vaDrvCtx, vpHalSrcSurf, pipelineParam);
DDI_CHK_RET(vaStatus, "Failed to update past reference frames!");

// Check if filter values changed,if yes, then reset all filters for this surface

Expand Down
8 changes: 4 additions & 4 deletions media_softlet/linux/common/vp/ddi/ddi_vp_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ class DdiVpFunctions :public DdiMediaFunctions
PMOS_INTERFACE osInterface);

//!
//! \brief Update the forward reference frames for VPHAL input surface
//! \brief Update the future reference frames for VPHAL input surface
//! \param [in] vpCtx
//! VP context
//! \param [in] vaDrvCtx
Expand All @@ -1047,14 +1047,14 @@ class DdiVpFunctions :public DdiMediaFunctions
//!
//! \returns VA_STATUS_SUCCESS if call succeeds
//!
VAStatus DdiUpdateProcPipelineForwardReferenceFrames(
VAStatus DdiUpdateProcPipelineFutureReferenceFrames(
PDDI_VP_CONTEXT vpCtx,
VADriverContextP vaDrvCtx,
PVPHAL_SURFACE vpHalSrcSurf,
VAProcPipelineParameterBuffer *pipelineParam);

//!
//! \brief Update the backward reference frames for VPHAL input surface
//! \brief Update the past reference frames for VPHAL input surface
//!
//! \param [in] vpCtx
//! VP context
Expand All @@ -1066,7 +1066,7 @@ class DdiVpFunctions :public DdiMediaFunctions
//! Pipeline parameter from application (VAProcPipelineParameterBuffer)
//! \returns VA_STATUS_SUCCESS if call succeeds
//!
VAStatus DdiUpdateProcPipelineBackwardReferenceFrames(
VAStatus DdiUpdateProcPipelinePastReferenceFrames(
PDDI_VP_CONTEXT vpCtx,
VADriverContextP vaDrvCtx,
PVPHAL_SURFACE vpHalSrcSurf,
Expand Down

0 comments on commit 8017d9c

Please sign in to comment.