Error resilience: Added a few error handling measures. (#581)

* * Error resilience: Added a few error handling measures.
 - AV1: Added check flags to sequence header and frame header to indicate if the headers are parsed without errors. The flags are used to check if the parsing process which refers to the headers can proceed or stop.
 - AV1: Added divide by 0 check on tile columns in tile group parsing.
 - AV1: Added invalid OBU size check in AV1 elementary stream parsing in bitstream reader.
 - All codecs: Added divide by 0 check in display aspect ratio calculation.

* * Error resilience: Fixed a typo in an error message.

[ROCm/rocdecode commit: a861d6f1d2]
This commit is contained in:
jeffqjiangNew
2025-05-06 12:02:51 -04:00
committed by GitHub
parent 798a4a03f0
commit 6e1cd70811
6 changed files with 40 additions and 9 deletions
@@ -859,7 +859,7 @@ uint32_t RocVideoESParser::ReadUVLC(const uint8_t *p_stream, size_t &bit_offset)
int RocVideoESParser::CheckAv1EStream(uint8_t *p_stream, int stream_size) {
int score = 0;
uint8_t *obu_stream = p_stream;
int curr_offset = 0;
uint32_t curr_offset = 0;
int temporal_delimiter_obu_present = 0;
int seq_header_obu_present = 0;
int frame_header_obu_present = 0;
@@ -1080,6 +1080,10 @@ int RocVideoESParser::CheckAv1EStream(uint8_t *p_stream, int stream_size) {
break;
}
// Check before update
if (obu_size > (stream_size - curr_offset)) {
break;
}
curr_offset += obu_size;
}
if (syntax_error) {