Implement VP9 loop filtering (#550)

Unmerged PR from OG Ryujinx (#4367). From @gdkchan:

> The main goal of this change is porting the loop filtering from
libvpx, which should fix the block artifacts on some VP9 videos on games
using NVDEC to decode them. In addition to that, there are two other
changes:
> 
> - The remaining decoder code required to decode a VP9 video (with
headers included) has been added. That was done because it's much better
to test the decoder standalone with a video file. I decided to keep that
code on the emulator, even if some of it is unused, since it makes
standalone testing easier in the future too, and we can include unit
tests with video files.
> - Large refactoring of both new and existing code to conform with our
conding [sic] styles, done by @TSRBerry (thanks!) Some of it has been
automated.
> 
> Since we had no loop filtering before, this change will make video
decoding slower. That may cause frame drop etc if the decoder is not
fast enough in some games. I plan to optimize the decoder more in the
future to make up for that, but if possible I'd prefer to not do it as
part of this PR, but if the perf loss is too severe I might consider.
> 
> This will need to be tested on games that had the block artifacts, it
would be nice to confirm if they match hardware now, and get some
before/after screenshots etc.

Comment from @Bjorn29512:

> Significantly improves the block artifacts in FE: Engage.
> 
> Before:
>
![](https://user-images.githubusercontent.com/110204265/216882414-ec88dbda-7544-4490-8a47-37f074056ae3.png)
> 
> After:
>
![](https://user-images.githubusercontent.com/110204265/216882478-4e81fead-1033-4877-b282-f9cac6d6aa3b.png)

---------

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
Co-authored-by: TSR Berry <20988865+TSRBerry@users.noreply.github.com>
This commit is contained in:
Keaton 2025-02-18 20:59:36 -06:00 committed by GitHub
parent 920933bc9f
commit f91cd05260
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
79 changed files with 11343 additions and 3036 deletions

View file

@ -1,56 +1,75 @@
namespace Ryujinx.Graphics.Nvdec.Vp9
namespace Ryujinx.Graphics.Nvdec.Vp9
{
internal enum CodecErr
{
/*!\brief Operation completed without error */
CodecOk,
/// <summary>
/// Operation completed without error
/// </summary>
Ok,
/*!\brief Unspecified error */
CodecError,
/// <summary>
/// Unspecified error
/// </summary>
Error,
/*!\brief Memory operation failed */
CodecMemError,
/// <summary>
/// Memory operation failed
/// </summary>
MemError,
/*!\brief ABI version mismatch */
CodecAbiMismatch,
/// <summary>
/// ABI version mismatch
/// </summary>
AbiMismatch,
/*!\brief Algorithm does not have required capability */
CodecIncapable,
/// <summary>
/// Algorithm does not have required capability
/// </summary>
Incapable,
/*!\brief The given bitstream is not supported.
*
* The bitstream was unable to be parsed at the highest level. The decoder
* is unable to proceed. This error \ref SHOULD be treated as fatal to the
* stream. */
CodecUnsupBitstream,
/// <summary>
/// The given bitstream is not supported.
/// </summary>
/// <remarks>
/// The bitstream was unable to be parsed at the highest level.<br/>
/// The decoder is unable to proceed.<br/>
/// This error SHOULD be treated as fatal to the stream.
/// </remarks>
UnsupBitstream,
/*!\brief Encoded bitstream uses an unsupported feature
*
* The decoder does not implement a feature required by the encoder. This
* return code should only be used for features that prevent future
* pictures from being properly decoded. This error \ref MAY be treated as
* fatal to the stream or \ref MAY be treated as fatal to the current GOP.
*/
CodecUnsupFeature,
/// <summary>
/// Encoded bitstream uses an unsupported feature
/// </summary>
/// <remarks>
/// The decoder does not implement a feature required by the encoder.<br/>
/// This return code should only be used for features that prevent future
/// pictures from being properly decoded.<br/>
/// <br/>
/// This error MAY be treated as fatal to the stream or MAY be treated as fatal to the current GOP.
/// </remarks>
UnsupFeature,
/*!\brief The coded data for this stream is corrupt or incomplete
*
* There was a problem decoding the current frame. This return code
* should only be used for failures that prevent future pictures from
* being properly decoded. This error \ref MAY be treated as fatal to the
* stream or \ref MAY be treated as fatal to the current GOP. If decoding
* is continued for the current GOP, artifacts may be present.
*/
CodecCorruptFrame,
/// <summary>
/// The coded data for this stream is corrupt or incomplete.
/// </summary>
/// <remarks>
/// There was a problem decoding the current frame.<br/>
/// This return code should only be used
/// for failures that prevent future pictures from being properly decoded.<br/>
/// <br/>
/// This error MAY be treated as fatal to the stream or MAY be treated as fatal to the current GOP.<br/>
/// If decoding is continued for the current GOP, artifacts may be present.
/// </remarks>
CorruptFrame,
/*!\brief An application-supplied parameter is not valid.
*
*/
CodecInvalidParam,
/// <summary>
/// An application-supplied parameter is not valid.
/// </summary>
InvalidParam,
/*!\brief An iterator reached the end of list.
*
*/
CodecListEnd,
/// <summary>
/// An iterator reached the end of list.
/// </summary>
ListEnd
}
}
}