diff --git a/src/parser/hevc_parser.cpp b/src/parser/hevc_parser.cpp index a03f75eadc..07c6dc1627 100644 --- a/src/parser/hevc_parser.cpp +++ b/src/parser/hevc_parser.cpp @@ -566,7 +566,7 @@ ParserResult HevcVideoParser::ParsePictureData(const uint8_t* p_stream, uint32_t return ret; } // Parse the NAL unit - if (nal_unit_size_) { + if (nal_unit_size_ >= 5) { // start code + NAL unit header = 5 bytes int ebsp_size = nal_unit_size_ - 5 > RBSP_BUF_SIZE ? RBSP_BUF_SIZE : nal_unit_size_ - 5; // only copy enough bytes for header parsing diff --git a/src/parser/roc_video_parser.cpp b/src/parser/roc_video_parser.cpp index e146a554b9..499fdce3fb 100644 --- a/src/parser/roc_video_parser.cpp +++ b/src/parser/roc_video_parser.cpp @@ -139,11 +139,10 @@ ParserResult RocVideoParser::GetNalUnit() { start_code_found = true; start_code_num_++; next_start_code_offset_ = curr_byte_offset_; - // Move the pointer (3 + 2) bytes forward (start_code + nal header) - curr_byte_offset_ += 5; + // Move the pointer 3 bytes forward + curr_byte_offset_ += 3; // For the very first NAL unit, search for the next start code (or reach the end of frame) - // also detect empty nal units with no data if (start_code_num_ == 1 ) { start_code_found = false; curr_start_code_offset_ = next_start_code_offset_; @@ -153,7 +152,7 @@ ParserResult RocVideoParser::GetNalUnit() { } } curr_byte_offset_++; - } + } if (start_code_num_ == 0) { // No NAL unit in the frame data return PARSER_NOT_FOUND; @@ -164,7 +163,7 @@ ParserResult RocVideoParser::GetNalUnit() { } else { nal_unit_size_ = pic_data_size_ - curr_start_code_offset_; return PARSER_EOF; - } + } } size_t RocVideoParser::EbspToRbsp(uint8_t *streamBuffer,size_t begin_bytepos, size_t end_bytepos) {