VP9: Added support for video size change (scaling down) on inter frames. (#508)

* * rocDecode/VP9: Added support for video size change (scaling down) on inter frames.
 - A new reconfigure mode is added, where we keep the existing VAAPI surfaces and context, and work on the smaller images and store the images in the surfaces.

* * rocDecode/VP9 resize: Added changes based on review comments.
Esse commit está contido em:
jeffqjiangNew
2025-02-12 17:18:09 -05:00
commit de GitHub
commit 2af7bbf4e7
7 arquivos alterados com 58 adições e 13 exclusões
+12 -8
Ver Arquivo
@@ -528,15 +528,19 @@ int RocVideoDecoder::ReconfigureDecoder(RocdecVideoFormat *p_video_format) {
}
}
if (out_mem_type_ == OUT_SURFACE_MEM_DEV_INTERNAL || out_mem_type_ == OUT_SURFACE_MEM_NOT_MAPPED) {
GetSurfaceStrideInternal(video_surface_format_, coded_width_, coded_height_, &surface_stride_, &surface_vstride_);
} else {
surface_stride_ = target_width_ * byte_per_pixel_;
if (p_video_format->reconfig_options == ROCDEC_RECONFIG_NEW_SURFACES) {
if (out_mem_type_ == OUT_SURFACE_MEM_DEV_INTERNAL || out_mem_type_ == OUT_SURFACE_MEM_NOT_MAPPED) {
GetSurfaceStrideInternal(video_surface_format_, coded_width_, coded_height_, &surface_stride_, &surface_vstride_);
} else {
surface_stride_ = target_width_ * byte_per_pixel_;
}
}
chroma_height_ = static_cast<int>(ceil(target_height_ * GetChromaHeightFactor(video_surface_format_)));
num_chroma_planes_ = GetChromaPlaneCount(video_surface_format_);
if (p_video_format->chroma_format == rocDecVideoChromaFormat_Monochrome) num_chroma_planes_ = 0;
chroma_vstride_ = static_cast<int>(std::ceil(surface_vstride_ * GetChromaHeightFactor(video_surface_format_)));
if (p_video_format->reconfig_options == ROCDEC_RECONFIG_NEW_SURFACES) {
chroma_vstride_ = static_cast<int>(std::ceil(surface_vstride_ * GetChromaHeightFactor(video_surface_format_)));
}
// Fill output_surface_info_
output_surface_info_.output_width = target_width_;
output_surface_info_.output_height = target_height_;
@@ -590,8 +594,9 @@ int RocVideoDecoder::ReconfigureDecoder(RocdecVideoFormat *p_video_format) {
ROCDEC_THROW("Reconfigurition of the decoder detected but the decoder was not initialized previoulsy!", ROCDEC_NOT_SUPPORTED);
return 0;
}
ROCDEC_API_CALL(rocDecReconfigureDecoder(roc_decoder_, &reconfig_params));
if (p_video_format->reconfig_options == ROCDEC_RECONFIG_NEW_SURFACES) {
ROCDEC_API_CALL(rocDecReconfigureDecoder(roc_decoder_, &reconfig_params));
}
input_video_info_str_.str("");
input_video_info_str_.clear();
@@ -908,7 +913,6 @@ bool RocVideoDecoder::ReleaseInternalFrames() {
return true;
}
void RocVideoDecoder::SaveFrameToFile(std::string output_file_name, void *surf_mem, OutputSurfaceInfo *surf_info, size_t rgb_image_size) {
uint8_t *hst_ptr = nullptr;
bool is_rgb = (rgb_image_size != 0);