You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The EbmlId class is very loose. It's possible to create an EbmlId with a bogus size and use it in a class without anyone noticing. We just assume the values are correct in the spec/custom code.
The constructors only allows 4 byte values so we already have constraints on the max ID size. We just need to generate the length automatically. EbmlId should be only created once per class. After that they should be used as const references. So the cost on creation shouldn't be too much.
The spectool generates the ID size based on the size of the id attribute string.
The text was updated successfully, but these errors were encountered:
robUx4
added
the
api-break
breaks the API (e.g. programs using it will have to adjust their source code)
label
Dec 20, 2023
Maybe a IsValid() method would be enough and we can assert in the constructor that it is indeed valid. That would be enough to check all used IDs are valid in debug builds.
Checking if an ID is valid would indeed be a great function to have. Would need some kind of top-level EbmlContext to check against, I guess; with Matroska that would be the one from KaxSegment.
The EbmlId class is very loose. It's possible to create an EbmlId with a bogus size and use it in a class without anyone noticing. We just assume the values are correct in the spec/custom code.
There are easy tools like gcc/clang clz (https://en.cppreference.com/w/cpp/numeric/countl_zero in C++20) and even in MSVC (https://stackoverflow.com/questions/355967/how-to-use-msvc-intrinsics-to-get-the-equivalent-of-this-gcc-code) that can quickly find the proper size. We should not have to set the size manually at all.
The constructors only allows 4 byte values so we already have constraints on the max ID size. We just need to generate the length automatically. EbmlId should be only created once per class. After that they should be used as const references. So the cost on creation shouldn't be too much.
The spectool generates the ID size based on the size of the
id
attribute string.The text was updated successfully, but these errors were encountered: