/ src / Ryujinx.Graphics.Nvdec / Vp8Decoder.cs
Vp8Decoder.cs
 1  using Ryujinx.Graphics.Nvdec.FFmpeg.Vp8;
 2  using Ryujinx.Graphics.Nvdec.Image;
 3  using Ryujinx.Graphics.Nvdec.Types.Vp8;
 4  using Ryujinx.Graphics.Video;
 5  using System;
 6  
 7  namespace Ryujinx.Graphics.Nvdec
 8  {
 9      static class Vp8Decoder
10      {
11          public static void Decode(NvdecDecoderContext context, ResourceManager rm, ref NvdecRegisters state)
12          {
13              PictureInfo pictureInfo = rm.MemoryManager.DeviceRead<PictureInfo>(state.SetDrvPicSetupOffset);
14              ReadOnlySpan<byte> bitstream = rm.MemoryManager.DeviceGetSpan(state.SetInBufBaseOffset, (int)pictureInfo.VLDBufferSize);
15  
16              Decoder decoder = context.GetVp8Decoder();
17  
18              ISurface outputSurface = rm.Cache.Get(decoder, 0, 0, pictureInfo.FrameWidth, pictureInfo.FrameHeight);
19  
20              Vp8PictureInfo info = pictureInfo.Convert();
21  
22              uint lumaOffset = state.SetPictureLumaOffset[3];
23              uint chromaOffset = state.SetPictureChromaOffset[3];
24  
25              if (decoder.Decode(ref info, outputSurface, bitstream))
26              {
27                  SurfaceWriter.Write(rm.MemoryManager, outputSurface, lumaOffset, chromaOffset);
28              }
29  
30              rm.Cache.Put(outputSurface);
31          }
32      }
33  }