Add support for rocDecReconfigureDecoder API (#116)
* Add support for rocDecReconfigureDecoder API
* adrress reviewer's comemnts
* Add doxygen comment for ReconfigureDecoder function
[ROCm/rocdecode commit: 875994bb4f]
This commit is contained in:
@@ -77,11 +77,15 @@ rocDecStatus RocDecoder::GetDecodeStatus(int pic_idx, RocdecDecodeStatus* decode
|
||||
}
|
||||
|
||||
rocDecStatus RocDecoder::ReconfigureDecoder(RocdecReconfigureDecoderInfo *reconfig_params) {
|
||||
// todo:: return appropriate decStatus
|
||||
// this will be called when the current configuration is changed during decoding
|
||||
// release the current va-api decoder instance and create a new one with the new parameters (or reinit if available)
|
||||
// return status
|
||||
return ROCDEC_NOT_IMPLEMENTED;
|
||||
if (reconfig_params == nullptr) {
|
||||
return ROCDEC_INVALID_PARAMETER;
|
||||
}
|
||||
rocDecStatus rocdec_status = va_video_decoder_.ReconfigureDecoder(reconfig_params);
|
||||
if (rocdec_status != ROCDEC_SUCCESS) {
|
||||
ERR("ERROR: Reconfiguration of the decoder failed with rocDecStatus# " + TOSTR(rocdec_status));
|
||||
return rocdec_status;
|
||||
}
|
||||
return rocdec_status;
|
||||
}
|
||||
|
||||
rocDecStatus RocDecoder::MapVideoFrame(int pic_idx, void *dev_mem_ptr[3], uint32_t horizontal_pitch[3], RocdecProcParams *vid_postproc_params) {
|
||||
|
||||
@@ -143,6 +143,9 @@ rocDecGetDecodeStatus(rocDecDecoderHandle decoder_handle, int pic_idx, RocdecDec
|
||||
/*********************************************************************************************************/
|
||||
rocDecStatus ROCDECAPI
|
||||
rocDecReconfigureDecoder(rocDecDecoderHandle decoder_handle, RocdecReconfigureDecoderInfo *reconfig_params) {
|
||||
if (decoder_handle == nullptr || reconfig_params == nullptr) {
|
||||
return ROCDEC_INVALID_PARAMETER;
|
||||
}
|
||||
auto handle = static_cast<DecHandle *> (decoder_handle);
|
||||
rocDecStatus ret;
|
||||
try {
|
||||
|
||||
@@ -323,3 +323,44 @@ rocDecStatus VaapiVideoDecoder::ExportSurface(int pic_idx, VADRMPRIMESurfaceDesc
|
||||
|
||||
return ROCDEC_SUCCESS;
|
||||
}
|
||||
|
||||
rocDecStatus VaapiVideoDecoder::ReconfigureDecoder(RocdecReconfigureDecoderInfo *reconfig_params) {
|
||||
if (reconfig_params == nullptr) {
|
||||
return ROCDEC_INVALID_PARAMETER;
|
||||
}
|
||||
if (va_display_ == 0) {
|
||||
ERR("ERROR: VAAPI decoder has not been initialized but reconfiguration of the decoder has been requested!");
|
||||
return ROCDEC_NOT_SUPPORTED;
|
||||
}
|
||||
rocDecStatus rocdec_status = DestroyDataBuffers();
|
||||
if (rocdec_status != ROCDEC_SUCCESS) {
|
||||
ERR("ERROR: Failed to destroy VAAPI buffers during the reconfiguration, with rocDecStatus# " + TOSTR(rocdec_status));
|
||||
return rocdec_status;
|
||||
}
|
||||
CHECK_VAAPI(vaDestroySurfaces(va_display_, va_surface_ids_.data(), va_surface_ids_.size()));
|
||||
CHECK_VAAPI(vaDestroyContext(va_display_, va_context_id_));
|
||||
|
||||
va_surface_ids_.clear();
|
||||
decoder_create_info_.ulWidth = reconfig_params->ulWidth;
|
||||
decoder_create_info_.ulHeight = reconfig_params->ulHeight;
|
||||
decoder_create_info_.ulNumDecodeSurfaces = reconfig_params->ulNumDecodeSurfaces;
|
||||
decoder_create_info_.ulTargetHeight = reconfig_params->ulTargetHeight;
|
||||
decoder_create_info_.ulTargetWidth = reconfig_params->ulTargetWidth;
|
||||
|
||||
rocdec_status = CreateSurfaces();
|
||||
if (rocdec_status != ROCDEC_SUCCESS) {
|
||||
ERR("ERROR: Failed to create VAAPI surfaces during the decoder reconfiguration " + TOSTR(rocdec_status));
|
||||
return rocdec_status;
|
||||
}
|
||||
rocdec_status = CreateContext();
|
||||
if (rocdec_status != ROCDEC_SUCCESS) {
|
||||
ERR("ERROR: Failed to create a VAAPI context during the decoder reconfiguration " + TOSTR(rocdec_status));
|
||||
return rocdec_status;
|
||||
}
|
||||
rocdec_status = CreateDataBuffers();
|
||||
if (rocdec_status != ROCDEC_SUCCESS) {
|
||||
ERR("ERROR: Failed to create VAAPI buffers during the decoder reconfiguration " + TOSTR(rocdec_status));
|
||||
return rocdec_status;
|
||||
}
|
||||
return rocdec_status;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
rocDecStatus SubmitDecode(RocdecPicParams *pPicParams);
|
||||
rocDecStatus GetDecodeStatus(int pic_idx, RocdecDecodeStatus* decode_status);
|
||||
rocDecStatus ExportSurface(int pic_idx, VADRMPRIMESurfaceDescriptor &va_drm_prime_surface_desc);
|
||||
|
||||
rocDecStatus ReconfigureDecoder(RocdecReconfigureDecoderInfo *reconfig_params);
|
||||
private:
|
||||
RocDecoderCreateInfo decoder_create_info_;
|
||||
int drm_fd_;
|
||||
|
||||
Reference in New Issue
Block a user