mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:37:35 +00:00
LibVideo: Implement VP9 intra-predicted frame decoding
The first keyframe of the test video can be decoded with these changes. Raw memory allocations in the Parser have been replaced with Vector or Array to avoid memory leaks and OOBs.
This commit is contained in:
parent
da9ff31166
commit
1514004cd5
10 changed files with 1445 additions and 146 deletions
|
@ -11,7 +11,35 @@
|
|||
|
||||
namespace Video::VP9 {
|
||||
|
||||
u8 clip_3(u8 x, u8 y, u8 z);
|
||||
u8 round_2(u8 x, u8 n);
|
||||
// FIXME: Once everything is working, replace this with plain clamp
|
||||
// since parameter order is different
|
||||
template<typename T>
|
||||
T clip_3(T x, T y, T z)
|
||||
{
|
||||
return clamp(z, x, y);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
u16 clip_1(u8 bit_depth, T x)
|
||||
{
|
||||
if (x < 0) {
|
||||
return 0u;
|
||||
}
|
||||
const T max = (1u << bit_depth) - 1u;
|
||||
if (x > max)
|
||||
return max;
|
||||
return x;
|
||||
}
|
||||
|
||||
template<typename T, typename C>
|
||||
inline T brev(C bit_count, T value)
|
||||
{
|
||||
T result = 0;
|
||||
for (C i = 0; i < bit_count; i++) {
|
||||
auto bit = (value >> i) & 1;
|
||||
result |= bit << (bit_count - 1 - i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue