summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibVideo/VP9
AgeCommit message (Collapse)Author
2022-10-13LibVideo: Check parsed superframe sizes when decoding VP9 framesAndrew Kaster
Make sure that the next parsed superframe size will not overflow the chunk data before splitting it out to decode a frame.
2022-10-12LibVideo: Allow the VP9 decoder to decode ultra high resolution videoZaggy1024
Previously, some integer overflows and truncations were causing parsing errors for 4K videos, with those fixed it can fully decode 8K video. This adds a test to ensure that 4K video will continue to be decoded. Note: There seems to be unexpectedly high memory usage while decoding them, causing 8K video to require more than a gigabyte of RAM. (!!!)
2022-10-10LibVideo: Initialize VP9 BitStream's reservoir fieldZaggy1024
Leaving it uninitialized could lead to undefined behavior.
2022-10-09LibVideo: Remove unnecessary dbgln callsZaggy1024
Debug prints are expensive, so doing them every frame seems excessive now that the decoder is completely functional on some test videos.
2022-10-09LibVideo: Make probability tables save to the specified indexZaggy1024
Previously, saved probability tables were being inserted, causing the Vector to increase in size when it should say fixed at a size of 4. This changes the Vector to an Array<T, 4> which will default-initalize and allow assigning to any index without previously setting size.
2022-10-09LibVideo: Ensure that syntax element counts don't overflowZaggy1024
Integer overflow could sometimes occur due to counts going above 255, where the values should instead be clamped at their maximum to avoid wrapping to 0.
2022-10-09LibVideo: Prevent decode_block from saving motion vectors out of boundsZaggy1024
This fixes an issue causing frame 3 of the test video to fail to parse because a reference vector was incorrectly within the range for a high precision delta vector read.
2022-10-09LibVideo: Add support for VP9 superframesZaggy1024
This allows the second shown frame of the VP9 test video to be decoded, as the second chunk uses a superframe to encode a reference frame and a second to inter predict between the keyframe and the reference frame.
2022-10-09LibVideo: Implement inter predictionZaggy1024
This enables the second frame of the test video to be decoded. It appears that the test video uses a superframe (group of multiple frames) for the first chunk of the file, but we haven't implemented superframe parsing. We also ignore the show_frame flag, so for now, this means that the second frame read out is shown when it should not be. To fix this, another error type needs to be implemented that is "thrown" to decoder's client so they know to send another sample buffer.
2022-10-09LibVideo: Look up interpolation filter probability correctlyZaggy1024
The above interpolation filter mode was being taken from the left side instead, causing some parsing errors. This also changes the magic number 3 to SWITCHABLE_FILTERS. Unfortunately, the spec uses the magic number, so this value was taken instead from the reference codec, libvpx.
2022-10-09LibVideo: Fix incorrect VP9 InterMode enum valuesZaggy1024
These values were referencing the wrong column of a table in the spec, the values should start from 10.
2022-10-09LibVideo: Implement block parsing for inter framesZaggy1024
This gets the decoder closer to fully parsing the second frame without any errors. It will still be unable to output an inter-predicted frame. The lack of output causes VideoPlayer to crash if it attempts to read the buffers for frame 1, so it is still limited to the first frame.
2022-10-09LibVideo: Add MotionVector lookup tables as constant expressionsZaggy1024
This changes MotionVector by removing the cpp file and moving all functions to the header, where they are now declared as constexpr so that they can be compile-time evaluated in LookupTables.h.
2022-10-09LibVideo: Rename MV to MotionVector for clarityZaggy1024
2022-10-09LibVideo: Implement VP9 intra-predicted frame decodingZaggy1024
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.
2022-10-09LibVideo: Make new DecoderError class to report useful errorsZaggy1024
This allows runtime strings, so we can format the errors to make them more helpful. Errors in the VP9 decoder will now print out a function, filename and line number for where a read or bitstream requirement has failed. The DecoderErrorCategory enum will classify the errors so library users can show general user-friendly error messages, while providing the debug information separately. Any non-DecoderErrorOr<> results can be wrapped by DECODER_TRY to return from decoder functions. This will also add the extra information mentioned above to the error message.
2022-10-09LibVideo: Change decode_term_subexp read to the correct number of bitsZaggy1024
This allows parsing of the implemented functions from the VP9 spec in the test video included in /home/anon/Videos.
2022-10-09LibVideo: Read multiple raw bits at once to refill the range decoderZaggy1024
This will allow BitStream::read_bool() to read more than one bit from the range-coded bitstream at a time if needed.
2022-10-09LibVideo: Improve error reporting for VP9 range decoderZaggy1024
init_bool will now check whether there is enough data in the bitstream for the range coding size to be fully read. exit_bool will now read the entire padding element regardless of size, which the spec does not specify a limit on.
2022-10-09LibVideo: Cache 64 bits at a time for reading in BitStreamZaggy1024
Reads will now be done in larger chunks at a time. The public read_byte() function was removed in favor of a private fill_reservoir() function which will be used to fill the 64-bit reservoir field which will then be bit-shifted and masked as necessary for subsequent arbitrary bit-sized reads. read_f(n) was renamed to read_bits to be clearer about its use.
2022-10-09LibVideo: Allow bit stream reads to throw errorsZaggy1024
Errors are propagated to the user of the decoder so that they can be aware of specific places where a read failed.
2022-10-09LibVideo: Remove MV class's copy assignment overloadZaggy1024
This was unnecessary, as the implicit one works correctly.
2022-10-09LibVideo: Remove printing of the interpolation filter in VP9 dump_infoZaggy1024
The interpolation filter value is not set when reading an intra-only frame, so printing this for the first keyframe of the file was printing "220", which is invalid.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-01-01LibVideo/VP9: Do not `null` guard calls to `free`Michel Hermier
2021-08-08Userland: Use kmalloc_array() where appropriateAndreas Kling
2021-07-10LibVideo/VP9: Implement MV reading & rectify MV storage issuesFalseHonesty
With this patch we are finally done with section 6.4.X of the spec :^) The only parsing left to be done is 6.5.X, motion vector prediction. Additionally, this patch fixes how MVs were being stored in the parser. Originally, due to the spec naming two very different values very similarly, these properties had totally wrong data types, but this has now been rectified.
2021-07-10LibVideo/VP9: Finish implementing block decoding (6.4.4)FalseHonesty
Though technically block decoding calls into some other incomplete methods, so it isn't functionally complete yet. However, we are very close to being done with the 6.4.X sections :)
2021-07-10LibVideo/VP9: Implement parsing Token and MoreCoefs treesFalseHonesty
These elements were being used in the new tokens implementation, so support for them in the TreeParser has been added. Additionally, this uncovered a bug where the nonzero contexts were being cleared with the wrong size.
2021-07-10LibVideo/VP9: Implement token parsing (6.4.24-6.4.26)FalseHonesty
Note that this now requires a couple new syntax types to be parsed in the TreeParser, so a follow-up commit will implement that behavior.
2021-07-10LibVideo/VP9: Implement sections 6.1.2 and 8.4.1-8.4.4FalseHonesty
These section implement the behavior to refresh the probability tables after parsing a frame.
2021-07-10LibVideo/VP9: Begin reference frame update process (8.10)FalseHonesty
This was required for correctly parsing more than one frame's height/width data properly. Additionally, start handling failure a little more gracefully. Since we don't fully parse a tile before starting to parse the next tile, we will now no longer make it past the first tile mark, meaning we should not handle that scenario well.
2021-07-10LibVideo/VP9: Rename Decoder -> Parser & create an actual Decoder classFalseHonesty
The class that was previously named Decoder handled section 6.X.X of the spec, which actually deals with parsing out the syntax of the data, not the actual decoding logic which is specified in section 8.X.X. The new Decoder class will be in charge of owning and running the Parser, as well as implementing all of the decoding behavior.
2021-07-10LibVideo/VP9: Start parsing residuals (6.4.21-6.4.23)FalseHonesty
Additionally, this uncovered a couple bugs with existing code, so those have been fixed. Currently, parsing a whole video does fail because we are now using a new calculation for frame width, but it hasn't been fully implemented yet.
2021-07-10LibVideo/VP9: Refactor how above & left contexts are stored & clearedFalseHonesty
These make more sense as Vectors, and it makes it much easier to manage their sizing.
2021-07-10LibVideo/VP9: Specify which spec section defines certain behaviorsFalseHonesty
2021-07-10LibVideo/VP9: Clean up formatting & use range-based for loopsFalseHonesty
2021-07-10LibVideo/VP9: Implement simple FIXMEs that use now supported dataFalseHonesty
2021-07-10LibVideo/VP9: Implement more TreeParser probability calculationsFalseHonesty
Now TreeParser has mostly complete probability calculation implementations for all currently used syntax elements. Some of these calculation methods aren't actually finished because they use data we have yet to parse in the Decoder, but they're close to finished.
2021-07-10LibVideo/VP9: Implement syntax element counting for supported elementsFalseHonesty
With the progress made in the Decoder thus far, we have the ability to support most of the syntax element counters in the tree parser. Additionally, it will now crash when trying to count unsupported elements.
2021-06-30LibVideo: Migrate to east-const style & apply other minor fixesFalseHonesty
This patch brings all of LibVideo up to the east-const style in the project. Additionally, it applies a few fixes from the reviews in #8170 that referred to older LibVideo code.
2021-06-30LibVideo/VP9: Implement most of block_mode_info methods (6.4.15-6.4.18)FalseHonesty
2021-06-30LibVideo/VP9: Implement most of inter_frame_mode_info (6.4.11-6.4.14)FalseHonesty
2021-06-30LibVideo/VP9: Implement intra_frame_mode_info procedure (6.4.6)FalseHonesty
2021-06-30LibVideo/VP9: Add SAFE_CALL macro to help propagate failure stateFalseHonesty
2021-06-30LibVideo/VP9: Refactor how TreeParser accesses decoder dataFalseHonesty
The TreeParser requires information about a lot of the decoder's current state in order to parse syntax tree elements correctly, so there has to be some communication between the Decoder and the TreeParser. Previously, the Decoder would copy its state to the TreeParser when it changed, however, this was a poor choice. Now, the TreeParser simply has a reference to its owning Decoder, and accesses its state directly.
2021-06-30LibVideo/VP9: Begin decoding VP9 blocksFalseHonesty
2021-06-30LibVideo/VP9: Successfully parse partition syntax elementFalseHonesty
2021-06-30LibVideo/VP9: Begin creating a tree parser to parse syntax elementsFalseHonesty
2021-06-30LibVideo/VP9: Begin decoding tilesFalseHonesty