Skip to content

Commit

Permalink
Fixed potential rare corner cases
Browse files Browse the repository at this point in the history
  • Loading branch information
t-boiko committed Dec 2, 2024
1 parent d78acbe commit d124c90
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ size_t VulkanVideoDecoder::next_start_code<SIMD_ISA::AVX2>(const uint8_t *pdatai
}
} // main processing loop end
m_BitBfr = (pdatain[i-2] << 8) | pdatain[i-1];
if (i >= datasize) {
found_start_code = false;
return datasize;
}
}
// process a tail (rest):
uint32_t bfr = m_BitBfr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ size_t VulkanVideoDecoder::next_start_code<SIMD_ISA::AVX512>(const uint8_t *pdat
}
} // main processing loop end
m_BitBfr = (pdatain[i-2] << 8) | pdatain[i-1];
if (i >= datasize) {
found_start_code = false;
return datasize;
}
}
// process a tail (rest):
uint32_t bfr = m_BitBfr;
Expand Down
4 changes: 4 additions & 0 deletions vk_video_decoder/libs/NvVideoParser/src/NextStartCodeNEON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ size_t VulkanVideoDecoder::next_start_code<SIMD_ISA::NEON>(const uint8_t *pdatai
}
} // main processing loop end
m_BitBfr = (pdatain[i-2] << 8) | pdatain[i-1];
if (i >= datasize) {
found_start_code = false;
return datasize;
}
}
// process a tail (rest):
uint32_t bfr = m_BitBfr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ size_t VulkanVideoDecoder::next_start_code<SIMD_ISA::SSSE3>(const uint8_t *pdata
}
} // main processing loop end
m_BitBfr = (pdatain[i-2] << 8) | pdatain[i-1];
if (i >= datasize) {
found_start_code = false;
return datasize;
}
}
// process a tail (rest):
uint32_t bfr = m_BitBfr;
Expand Down
8 changes: 6 additions & 2 deletions vk_video_decoder/libs/NvVideoParser/src/NextStartCodeSVE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ size_t VulkanVideoDecoder::next_start_code<SIMD_ISA::SVE>(const uint8_t *pdatain
// hotspot end
}
}
m_BitBfr = (pdatain[datasize-2] << 8) | pdatain[datasize-1];
found_start_code = ((m_BitBfr & 0x00ffffff) == 1);
// a very rare case:
if (datasize >= 2) {
m_BitBfr = pdatain[datasize-2];
}
m_BitBfr = (m_BitBfr << 8) | pdatain[datasize >= 1 ? datasize - 1 : 0];
found_start_code = false;
return datasize;
}
#undef SVE_REGISTER_MAX_BYTES
Expand Down

0 comments on commit d124c90

Please sign in to comment.