From fcd63b9358d1573f0aa49565ea66a53f0d7c5bec Mon Sep 17 00:00:00 2001 From: jeffqjiangNew <142832361+jeffqjiangNew@users.noreply.github.com> Date: Wed, 6 Dec 2023 09:39:49 -0500 Subject: [PATCH] * rocDecode/HEVC: In flush DPB function, added a check for any buffers that need for output before any actions. This prevents any potential issues. (#121) --- src/parser/hevc_parser.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/parser/hevc_parser.cpp b/src/parser/hevc_parser.cpp index 03e7a530a5..b8326de318 100644 --- a/src/parser/hevc_parser.cpp +++ b/src/parser/hevc_parser.cpp @@ -2235,16 +2235,17 @@ void HEVCVideoParser::EmptyDpb() { } int HEVCVideoParser::FlushDpb() { - dpb_buffer_.num_output_pics = 0; - // Bump the remaining pictures - while (dpb_buffer_.num_needed_for_output) { - if (BumpPicFromDpb() != PARSER_OK) { - return PARSER_FAIL; + if (dpb_buffer_.num_needed_for_output) { + // Bump the remaining pictures + while (dpb_buffer_.num_needed_for_output) { + if (BumpPicFromDpb() != PARSER_OK) { + return PARSER_FAIL; + } } - } - if (pfn_display_picture_cb_ && dpb_buffer_.num_output_pics > 0) { - if (OutputDecodedPictures() != PARSER_OK) { - return PARSER_FAIL; + if (pfn_display_picture_cb_ && dpb_buffer_.num_output_pics > 0) { + if (OutputDecodedPictures() != PARSER_OK) { + return PARSER_FAIL; + } } } return PARSER_OK;