From bf4922060d26027486f19da297986743fe860bc6 Mon Sep 17 00:00:00 2001 From: Aryan Salmanpour Date: Wed, 11 Jun 2025 11:44:20 -0400 Subject: [PATCH] Utils - Remove the call to rocDecGetDecodeStatus after rocDecGetVideoFrame (#600) * Utils - Remove the call to rocDecGetDecodeStatus after rocDecGetVideoFrame * Remove other occurrences of rocDecGetDecodeStatus that are not necessary * Update the description of the rocDecGetDecodeStatus and rocDecGetVideoFrame APIs * Add missing including thread in avcodec_videodecoder.h for fixing the Azure build issue --- api/rocdecode/rocdecode.h | 9 ++++++--- samples/rocdecDecode/rocdecdecode.cpp | 8 -------- src/rocdecode-host/avcodec/avcodec_videodecoder.h | 1 + src/rocdecode/rocdecode_api.cpp | 9 ++++++--- src/rocdecode/vaapi/vaapi_videodecoder.cpp | 3 --- utils/rocvideodecode/roc_video_dec.cpp | 12 ------------ 6 files changed, 13 insertions(+), 29 deletions(-) diff --git a/api/rocdecode/rocdecode.h b/api/rocdecode/rocdecode.h index a333030912..30440cf488 100644 --- a/api/rocdecode/rocdecode.h +++ b/api/rocdecode/rocdecode.h @@ -1717,9 +1717,10 @@ extern rocDecStatus ROCDECAPI rocDecDecodeFrame(rocDecDecoderHandle decoder_hand /************************************************************************************************************/ //! \fn rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle decoder_handle, int pic_idx, RocdecDecodeStatus* decode_status); //! \ingroup group_amd_rocdecode -//! Get the decode status for frame corresponding to nPicIdx -//! API is currently supported for HEVC, AVC/H264 and JPEG codecs. -//! API returns ROCDEC_NOT_SUPPORTED error code for unsupported GPU or codec. +//! Get the decode status for frame corresponding to nPicIdx. +//! Please note that this API makes a non-blocking call and returns the status of the frame associated with nPicIdx at the time of the call, +//! without waiting for the decoding to complete. The decode_status->decode_status can be either rocDecodeStatus_Success, indicating that +//! the decoding has been completed, or rocDecodeStatus_InProgress, which means that the decoding is still in progress. /************************************************************************************************************/ extern rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle decoder_handle, int pic_idx, RocdecDecodeStatus *decode_status); @@ -1739,6 +1740,8 @@ extern rocDecStatus ROCDECAPI rocDecReconfigureDecoder(rocDecDecoderHandle decod //! Post-process and map video frame corresponding to pic_idx for use in HIP. Returns HIP device pointer and associated //! pitch(horizontal stride) of the video frame. Returns device memory pointers and pitch for each plane (Y, U and V) seperately //! horizontal_pitch is a pointer to an unsigned 32-bit integer array of size 3. +//! Please note that this API is a blocking call. If the video frame associated with the pic_idx is not ready, the call +//! will wait for the decoding to complete before mapping the video frame for use in HIP. /************************************************************************************************************************/ extern rocDecStatus ROCDECAPI rocDecGetVideoFrame(rocDecDecoderHandle decoder_handle, int pic_idx, void *dev_mem_ptr[3], uint32_t *horizontal_pitch, diff --git a/samples/rocdecDecode/rocdecdecode.cpp b/samples/rocdecDecode/rocdecdecode.cpp index bc175dab6b..2bf624a369 100644 --- a/samples/rocdecDecode/rocdecdecode.cpp +++ b/samples/rocdecDecode/rocdecdecode.cpp @@ -515,14 +515,6 @@ int ROCDECAPI handle_picture_display(void* user_data, RocdecParserDispInfo* disp RocdecProcParams params = {}; params.progressive_frame = disp_info->progressive_frame; params.top_field_first = disp_info->top_field_first; - // check if decoding is complete - RocdecDecodeStatus dec_status; - memset(&dec_status, 0, sizeof(dec_status)); - CHECK(rocDecGetDecodeStatus(p_dec_info->decoder, disp_info->picture_index, &dec_status)); - if ((dec_status.decode_status == rocDecodeStatus_Error || dec_status.decode_status == rocDecodeStatus_Error_Concealed)) { - std::cerr << "Decode Error occurred for picture: " << disp_info->picture_index << std::endl; - return 0; - } // get device memory pointer for decoded output surface void* dev_mem_ptr[3] = { 0 }; uint32_t pitch[3] = { 0 }; diff --git a/src/rocdecode-host/avcodec/avcodec_videodecoder.h b/src/rocdecode-host/avcodec/avcodec_videodecoder.h index b44412ba3c..6b0fbbdab0 100644 --- a/src/rocdecode-host/avcodec/avcodec_videodecoder.h +++ b/src/rocdecode-host/avcodec/avcodec_videodecoder.h @@ -40,6 +40,7 @@ extern "C" { #include #include #include +#include #include "../src/commons.h" #include "../api/rocdecode/rocdecode.h" #include "../api/rocdecode/rocdecode_host.h" diff --git a/src/rocdecode/rocdecode_api.cpp b/src/rocdecode/rocdecode_api.cpp index 7e696eea6d..c95ed8ee44 100644 --- a/src/rocdecode/rocdecode_api.cpp +++ b/src/rocdecode/rocdecode_api.cpp @@ -108,8 +108,9 @@ rocDecDecodeFrame(rocDecDecoderHandle decoder_handle, RocdecPicParams *pic_param /************************************************************************************************************/ //! \fn rocDecStatus ROCDECAPI RocdecGetDecodeStatus(rocDecDecoderHandle decoder_handle, int pic_idx, RocdecDecodeStatus* decode_status); //! Get the decode status for frame corresponding to pic_idx -//! API is currently supported for HEVC codec. -//! API returns ROCDEC_NOT_SUPPORTED error code for unsupported GPU or codec. +//! Please note that this API makes a non-blocking call and returns the status of the frame associated with nPicIdx at the time of the call, +//! without waiting for the decoding to complete. The decode_status->decode_status can be either rocDecodeStatus_Success, indicating that +//! the decoding has been completed, or rocDecodeStatus_InProgress, which means that the decoding is still in progress. /************************************************************************************************************/ rocDecStatus ROCDECAPI rocDecGetDecodeStatus(rocDecDecoderHandle decoder_handle, int pic_idx, RocdecDecodeStatus* decode_status) { @@ -156,7 +157,9 @@ rocDecReconfigureDecoder(rocDecDecoderHandle decoder_handle, RocdecReconfigureDe //! \fn rocDecStatus ROCDECAPI rocDecGetVideoFrame(rocDecDecoderHandle decoder_handle, int pic_idx, unsigned int *dev_mem_ptr, //! unsigned int *horizontal_pitch, RocdecProcParams *vid_postproc_params); //! Post-process and map video frame corresponding to pic_idx for use in HIP. Returns HIP device pointer and associated -//! pitch(horizontal stride) of the video frame. Returns device memory pointers for each plane (Y, U and V) seperately +//! pitch(horizontal stride) of the video frame. Returns device memory pointers for each plane (Y, U and V) seperately. +//! Please note that this API is a blocking call. If the video frame associated with the pic_idx is not ready, the call +//! will wait for the decoding to complete before mapping the video frame for use in HIP. /************************************************************************************************************************/ rocDecStatus ROCDECAPI rocDecGetVideoFrame(rocDecDecoderHandle decoder_handle, int pic_idx, diff --git a/src/rocdecode/vaapi/vaapi_videodecoder.cpp b/src/rocdecode/vaapi/vaapi_videodecoder.cpp index e8e3e45294..39a2b142d9 100644 --- a/src/rocdecode/vaapi/vaapi_videodecoder.cpp +++ b/src/rocdecode/vaapi/vaapi_videodecoder.cpp @@ -286,9 +286,6 @@ rocDecStatus VaapiVideoDecoder::GetDecodeStatus(int pic_idx, RocdecDecodeStatus case VASurfaceReady: decode_status->decode_status = rocDecodeStatus_Success; break; - case VASurfaceDisplaying: - decode_status->decode_status = rocDecodeStatus_Displaying; - break; default: decode_status->decode_status = rocDecodeStatus_Invalid; } diff --git a/utils/rocvideodecode/roc_video_dec.cpp b/utils/rocvideodecode/roc_video_dec.cpp index 479b8b11cd..33e89ebfa7 100644 --- a/utils/rocvideodecode/roc_video_dec.cpp +++ b/utils/rocvideodecode/roc_video_dec.cpp @@ -720,12 +720,6 @@ int RocVideoDecoder::HandlePictureDisplay(RocdecParserDispInfo *pDispInfo) { void * src_dev_ptr[3] = { 0 }; uint32_t src_pitch[3] = { 0 }; ROCDEC_API_CALL(rocDecGetVideoFrame(roc_decoder_, pDispInfo->picture_index, src_dev_ptr, src_pitch, &video_proc_params)); - RocdecDecodeStatus dec_status; - memset(&dec_status, 0, sizeof(dec_status)); - rocDecStatus result = rocDecGetDecodeStatus(roc_decoder_, pDispInfo->picture_index, &dec_status); - if (result == ROCDEC_SUCCESS && (dec_status.decode_status == rocDecodeStatus_Error || dec_status.decode_status == rocDecodeStatus_Error_Concealed)) { - std::cerr << "Decode Error occurred for picture: " << pic_num_in_dec_order_[pDispInfo->picture_index] << std::endl; - } if (out_mem_type_ == OUT_SURFACE_MEM_DEV_INTERNAL) { DecFrameBuffer dec_frame = { 0 }; dec_frame.frame_ptr = (uint8_t *)(src_dev_ptr[0]); @@ -803,12 +797,6 @@ int RocVideoDecoder::HandlePictureDisplay(RocdecParserDispInfo *pDispInfo) { HIP_API_CALL(hipStreamSynchronize(hip_stream_)); } } else { - RocdecDecodeStatus dec_status; - memset(&dec_status, 0, sizeof(dec_status)); - rocDecStatus result = rocDecGetDecodeStatus(roc_decoder_, pDispInfo->picture_index, &dec_status); - if (result == ROCDEC_SUCCESS && (dec_status.decode_status == rocDecodeStatus_Error || dec_status.decode_status == rocDecodeStatus_Error_Concealed)) { - std::cerr << "Decode Error occurred for picture: " << pic_num_in_dec_order_[pDispInfo->picture_index] << std::endl; - } output_frame_cnt_++; }