ModeInfo.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using Ryujinx.Common.Memory;
  2. using System.Diagnostics;
  3. namespace Ryujinx.Graphics.Nvdec.Vp9.Types
  4. {
  5. internal struct ModeInfo
  6. {
  7. // Common for both Inter and Intra blocks
  8. public BlockSize SbType;
  9. public PredictionMode Mode;
  10. public TxSize TxSize;
  11. public sbyte Skip;
  12. public sbyte SegmentId;
  13. public sbyte SegIdPredicted; // Valid only when TemporalUpdate is enabled
  14. // Only for Intra blocks
  15. public PredictionMode UvMode;
  16. // Only for Inter blocks
  17. public byte InterpFilter;
  18. // if ref_frame[idx] is equal to AltRefFrame then
  19. // MacroBlockD.BlockRef[idx] is an altref
  20. public Array2<sbyte> RefFrame;
  21. public Array2<Mv> Mv;
  22. public Array4<BModeInfo> Bmi;
  23. public PredictionMode GetYMode(int block)
  24. {
  25. return SbType < BlockSize.Block8x8 ? Bmi[block].Mode : Mode;
  26. }
  27. public TxSize GetUvTxSize(ref MacroBlockDPlane pd)
  28. {
  29. Debug.Assert(SbType < BlockSize.Block8x8 ||
  30. Luts.SsSizeLookup[(int)SbType][pd.SubsamplingX][pd.SubsamplingY] != BlockSize.BlockInvalid);
  31. return Luts.UvTxsizeLookup[(int)SbType][(int)TxSize][pd.SubsamplingX][pd.SubsamplingY];
  32. }
  33. public bool IsInterBlock()
  34. {
  35. return RefFrame[0] > Constants.IntraFrame;
  36. }
  37. public bool HasSecondRef()
  38. {
  39. return RefFrame[1] > Constants.IntraFrame;
  40. }
  41. private static readonly int[][] IdxNColumnToSubblock = new int[][]
  42. {
  43. new int[] { 1, 2 }, new int[] { 1, 3 }, new int[] { 3, 2 }, new int[] { 3, 3 }
  44. };
  45. // This function returns either the appropriate sub block or block's mv
  46. // on whether the block_size < 8x8 and we have check_sub_blocks set.
  47. public Mv GetSubBlockMv(int whichMv, int searchCol, int blockIdx)
  48. {
  49. return blockIdx >= 0 && SbType < BlockSize.Block8x8
  50. ? Bmi[IdxNColumnToSubblock[blockIdx][searchCol == 0 ? 1 : 0]].Mv[whichMv]
  51. : Mv[whichMv];
  52. }
  53. }
  54. }