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.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
25463e594b
Коммит
2af7bbf4e7
@@ -230,6 +230,7 @@ ParserResult Av1VideoParser::NotifyNewSequence(Av1SequenceHeader *p_seq_header,
|
||||
video_format_params_.display_aspect_ratio.x = disp_width / gcd;
|
||||
video_format_params_.display_aspect_ratio.y = disp_height / gcd;
|
||||
|
||||
video_format_params_.reconfig_options = ROCDEC_RECONFIG_NEW_SURFACES;
|
||||
video_format_params_.video_signal_description = {0};
|
||||
video_format_params_.seqhdr_data_length = 0;
|
||||
|
||||
|
||||
@@ -387,6 +387,7 @@ ParserResult AvcVideoParser::NotifyNewSps(AvcSeqParameterSet *p_sps) {
|
||||
video_format_params_.display_aspect_ratio.x = disp_width / gcd;
|
||||
video_format_params_.display_aspect_ratio.y = disp_height / gcd;
|
||||
|
||||
video_format_params_.reconfig_options = ROCDEC_RECONFIG_NEW_SURFACES;
|
||||
if (p_sps->vui_parameters_present_flag) {
|
||||
video_format_params_.video_signal_description.video_format = p_sps->vui_seq_parameters.video_format;
|
||||
video_format_params_.video_signal_description.video_full_range_flag = p_sps->vui_seq_parameters.video_full_range_flag;
|
||||
|
||||
@@ -190,6 +190,7 @@ int HevcVideoParser::FillSeqCallbackFn(HevcSeqParamSet* sps_data) {
|
||||
video_format_params_.display_aspect_ratio.x = disp_width / gcd;
|
||||
video_format_params_.display_aspect_ratio.y = disp_height / gcd;
|
||||
|
||||
video_format_params_.reconfig_options = ROCDEC_RECONFIG_NEW_SURFACES;
|
||||
if (sps_data->vui_parameters_present_flag) {
|
||||
video_format_params_.video_signal_description.video_format = sps_data->vui_parameters.video_format;
|
||||
video_format_params_.video_signal_description.video_full_range_flag = sps_data->vui_parameters.video_full_range_flag;
|
||||
|
||||
@@ -35,6 +35,9 @@ Vp9VideoParser::Vp9VideoParser() {
|
||||
InitDpb();
|
||||
num_frames_in_chunck_ = 1;
|
||||
frame_sizes_.assign(1, 0);
|
||||
curr_surface_width_ = 0;
|
||||
curr_surface_height_ = 0;
|
||||
reconfig_option_ = ROCDEC_RECONFIG_NEW_SURFACES;
|
||||
}
|
||||
|
||||
Vp9VideoParser::~Vp9VideoParser() {
|
||||
@@ -88,6 +91,9 @@ ParserResult Vp9VideoParser::ParsePictureData(const uint8_t *p_stream, uint32_t
|
||||
}
|
||||
// Init Roc decoder for the first time or reconfigure the existing decoder
|
||||
if (new_seq_activated_) {
|
||||
if ((ret = FlushDpb()) != PARSER_OK) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = NotifyNewSequence(&uncompressed_header_)) != PARSER_OK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -212,8 +218,8 @@ ParserResult Vp9VideoParser::NotifyNewSequence(Vp9UncompressedHeader *p_uncomp_h
|
||||
|
||||
video_format_params_.display_area.left = 0;
|
||||
video_format_params_.display_area.top = 0;
|
||||
video_format_params_.display_area.right = p_uncomp_header->render_size.render_width;
|
||||
video_format_params_.display_area.bottom = p_uncomp_header->render_size.render_height;
|
||||
video_format_params_.display_area.right = p_uncomp_header->frame_size.frame_width;
|
||||
video_format_params_.display_area.bottom = p_uncomp_header->frame_size.frame_height;
|
||||
video_format_params_.bitrate = 0;
|
||||
|
||||
// Dispaly aspect ratio
|
||||
@@ -223,6 +229,7 @@ ParserResult Vp9VideoParser::NotifyNewSequence(Vp9UncompressedHeader *p_uncomp_h
|
||||
video_format_params_.display_aspect_ratio.x = disp_width / gcd;
|
||||
video_format_params_.display_aspect_ratio.y = disp_height / gcd;
|
||||
|
||||
video_format_params_.reconfig_options = reconfig_option_;
|
||||
video_format_params_.video_signal_description = {0};
|
||||
video_format_params_.seqhdr_data_length = 0;
|
||||
|
||||
@@ -546,12 +553,27 @@ ParserResult Vp9VideoParser::ParseUncompressedHeader(uint8_t *p_stream, size_t s
|
||||
|
||||
p_uncomp_header->header_size_in_bytes = Parser::ReadBits(p_stream, offset, 16);
|
||||
|
||||
// Arbitrary size change is only supported on key frames. For other frame types, particularly inter-coded frames, only size down is
|
||||
// supported where the existing surface can be re-used.
|
||||
if (pic_width_ != p_uncomp_header->frame_size.frame_width || pic_height_ != p_uncomp_header->frame_size.frame_height) {
|
||||
pic_width_ = p_uncomp_header->frame_size.frame_width;
|
||||
pic_height_ = p_uncomp_header->frame_size.frame_height;
|
||||
if (p_uncomp_header->frame_type == kVp9KeyFrame) {
|
||||
curr_surface_width_ = pic_width_;
|
||||
curr_surface_height_ = pic_height_;
|
||||
reconfig_option_ = ROCDEC_RECONFIG_NEW_SURFACES; // Normal mode: free existing surfaces and allocate new surfaces.
|
||||
} else {
|
||||
if (pic_width_ <= curr_surface_width_ && pic_height_ <= curr_surface_height_) {
|
||||
reconfig_option_ = ROCDEC_RECONFIG_KEEP_SURFACES; // Keep the existing surfaces
|
||||
} else {
|
||||
ERR("VP9 video size (up) change on non-key frames is not supported. Decode errors can occur.");
|
||||
curr_surface_width_ = pic_width_;
|
||||
curr_surface_height_ = pic_height_;
|
||||
reconfig_option_ = ROCDEC_RECONFIG_NEW_SURFACES; // Normal mode: free existing surfaces and allocate new surfaces.
|
||||
}
|
||||
}
|
||||
new_seq_activated_ = true;
|
||||
}
|
||||
|
||||
uncomp_header_size_ = (offset + 7) >> 3;
|
||||
return PARSER_OK;
|
||||
}
|
||||
|
||||
@@ -90,6 +90,12 @@ protected:
|
||||
DecodedPictureBuffer dpb_buffer_;
|
||||
Vp9Picture curr_pic_;
|
||||
|
||||
// Current surface size, used to support size change (down) on inter frames, where we keep the
|
||||
// previously allocated surfaces and use them to store the smaller images.
|
||||
uint32_t curr_surface_width_;
|
||||
uint32_t curr_surface_height_;
|
||||
uint32_t reconfig_option_;
|
||||
|
||||
/*! \brief Function to parse one picture bit stream received from the demuxer.
|
||||
* \param [in] p_stream A pointer of <tt>uint8_t</tt> for the input stream to be parsed
|
||||
* \param [in] pic_data_size Size of the input stream
|
||||
|
||||
Ссылка в новой задаче
Block a user