mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-01-27 21:35:32 +00:00
Fix video bitstream corruption when matching replacement isn't found
NVENC doesn't always include the HEVC bitstream prefix that Sunshine is looking to patch. When this happens replace() appends a spurious 00 00 00 01 28 NALU prefix to the end of the bitstream rather than simply doing nothing. This causes varying degrees of malfunctioning depending on the client, with the worst being complete video corruption on iOS.
This commit is contained in:
parent
e8feb00b33
commit
43dc7cf7c0
@ -410,11 +410,14 @@ std::vector<uint8_t> replace(const std::string_view &original, const std::string
|
||||
std::vector<uint8_t> replaced;
|
||||
|
||||
auto begin = std::begin(original);
|
||||
auto next = std::search(begin, std::end(original), std::begin(old), std::end(old));
|
||||
auto end = std::end(original);
|
||||
auto next = std::search(begin, end, std::begin(old), std::end(old));
|
||||
|
||||
std::copy(begin, next, std::back_inserter(replaced));
|
||||
std::copy(std::begin(_new), std::end(_new), std::back_inserter(replaced));
|
||||
std::copy(next + old.size(), std::end(original), std::back_inserter(replaced));
|
||||
if(next != end) {
|
||||
std::copy(std::begin(_new), std::end(_new), std::back_inserter(replaced));
|
||||
std::copy(next + old.size(), end, std::back_inserter(replaced));
|
||||
}
|
||||
|
||||
return replaced;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user