diff options
| author | 2020-10-29 22:40:46 -0400 | |
|---|---|---|
| committer | 2020-10-29 22:57:32 -0400 | |
| commit | 0d713cf8eb8c8b8802584c73b83d5ca9d88c70b2 (patch) | |
| tree | da460c31a61ce87e17d94a9da12010755b9c2554 | |
| parent | vp9: Provide a default initializer for "hidden" member (diff) | |
| download | yuzu-0d713cf8eb8c8b8802584c73b83d5ca9d88c70b2.tar.gz yuzu-0d713cf8eb8c8b8802584c73b83d5ca9d88c70b2.tar.xz yuzu-0d713cf8eb8c8b8802584c73b83d5ca9d88c70b2.zip | |
vp9: Mark functions with [[nodiscard]] where applicable
Prevents values from mistakenly being discarded in cases where it's a
bug to do so.
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/command_classes/codecs/vp9.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/vp9.h | 18 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/video_core/command_classes/codecs/vp9.cpp b/src/video_core/command_classes/codecs/vp9.cpp index aeb9866de..42520f856 100644 --- a/src/video_core/command_classes/codecs/vp9.cpp +++ b/src/video_core/command_classes/codecs/vp9.cpp | |||
| @@ -200,7 +200,7 @@ constexpr std::array<s32, 254> map_lut{ | |||
| 200 | 200 | ||
| 201 | // 6.2.14 Tile size calculation | 201 | // 6.2.14 Tile size calculation |
| 202 | 202 | ||
| 203 | s32 CalcMinLog2TileCols(s32 frame_width) { | 203 | [[nodiscard]] s32 CalcMinLog2TileCols(s32 frame_width) { |
| 204 | const s32 sb64_cols = (frame_width + 63) / 64; | 204 | const s32 sb64_cols = (frame_width + 63) / 64; |
| 205 | s32 min_log2 = 0; | 205 | s32 min_log2 = 0; |
| 206 | 206 | ||
| @@ -211,7 +211,7 @@ s32 CalcMinLog2TileCols(s32 frame_width) { | |||
| 211 | return min_log2; | 211 | return min_log2; |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | s32 CalcMaxLog2TileCols(s32 frame_width) { | 214 | [[nodiscard]] s32 CalcMaxLog2TileCols(s32 frame_width) { |
| 215 | const s32 sb64_cols = (frame_width + 63) / 64; | 215 | const s32 sb64_cols = (frame_width + 63) / 64; |
| 216 | s32 max_log2 = 1; | 216 | s32 max_log2 = 1; |
| 217 | 217 | ||
| @@ -223,7 +223,7 @@ s32 CalcMaxLog2TileCols(s32 frame_width) { | |||
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | // Recenters probability. Based on section 6.3.6 of VP9 Specification | 225 | // Recenters probability. Based on section 6.3.6 of VP9 Specification |
| 226 | s32 RecenterNonNeg(s32 new_prob, s32 old_prob) { | 226 | [[nodiscard]] s32 RecenterNonNeg(s32 new_prob, s32 old_prob) { |
| 227 | if (new_prob > old_prob * 2) { | 227 | if (new_prob > old_prob * 2) { |
| 228 | return new_prob; | 228 | return new_prob; |
| 229 | } | 229 | } |
| @@ -236,7 +236,7 @@ s32 RecenterNonNeg(s32 new_prob, s32 old_prob) { | |||
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | // Adjusts old_prob depending on new_prob. Based on section 6.3.5 of VP9 Specification | 238 | // Adjusts old_prob depending on new_prob. Based on section 6.3.5 of VP9 Specification |
| 239 | s32 RemapProbability(s32 new_prob, s32 old_prob) { | 239 | [[nodiscard]] s32 RemapProbability(s32 new_prob, s32 old_prob) { |
| 240 | new_prob--; | 240 | new_prob--; |
| 241 | old_prob--; | 241 | old_prob--; |
| 242 | 242 | ||
diff --git a/src/video_core/command_classes/codecs/vp9.h b/src/video_core/command_classes/codecs/vp9.h index 94e8f9090..76b5a8283 100644 --- a/src/video_core/command_classes/codecs/vp9.h +++ b/src/video_core/command_classes/codecs/vp9.h | |||
| @@ -37,11 +37,11 @@ public: | |||
| 37 | /// Signal the end of the bitstream | 37 | /// Signal the end of the bitstream |
| 38 | void End(); | 38 | void End(); |
| 39 | 39 | ||
| 40 | std::vector<u8>& GetBuffer() { | 40 | [[nodiscard]] std::vector<u8>& GetBuffer() { |
| 41 | return base_stream.GetBuffer(); | 41 | return base_stream.GetBuffer(); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | const std::vector<u8>& GetBuffer() const { | 44 | [[nodiscard]] const std::vector<u8>& GetBuffer() const { |
| 45 | return base_stream.GetBuffer(); | 45 | return base_stream.GetBuffer(); |
| 46 | } | 46 | } |
| 47 | 47 | ||
| @@ -75,10 +75,10 @@ public: | |||
| 75 | void Flush(); | 75 | void Flush(); |
| 76 | 76 | ||
| 77 | /// Returns byte_array | 77 | /// Returns byte_array |
| 78 | std::vector<u8>& GetByteArray(); | 78 | [[nodiscard]] std::vector<u8>& GetByteArray(); |
| 79 | 79 | ||
| 80 | /// Returns const byte_array | 80 | /// Returns const byte_array |
| 81 | const std::vector<u8>& GetByteArray() const; | 81 | [[nodiscard]] const std::vector<u8>& GetByteArray() const; |
| 82 | 82 | ||
| 83 | private: | 83 | private: |
| 84 | /// Write bit_count bits from value into buffer | 84 | /// Write bit_count bits from value into buffer |
| @@ -104,7 +104,7 @@ public: | |||
| 104 | std::vector<u8>& ComposeFrameHeader(NvdecCommon::NvdecRegisters& state); | 104 | std::vector<u8>& ComposeFrameHeader(NvdecCommon::NvdecRegisters& state); |
| 105 | 105 | ||
| 106 | /// Returns true if the most recent frame was a hidden frame. | 106 | /// Returns true if the most recent frame was a hidden frame. |
| 107 | bool WasFrameHidden() const { | 107 | [[nodiscard]] bool WasFrameHidden() const { |
| 108 | return hidden; | 108 | return hidden; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| @@ -141,17 +141,17 @@ private: | |||
| 141 | void WriteMvProbabilityUpdate(VpxRangeEncoder& writer, u8 new_prob, u8 old_prob); | 141 | void WriteMvProbabilityUpdate(VpxRangeEncoder& writer, u8 new_prob, u8 old_prob); |
| 142 | 142 | ||
| 143 | /// Returns VP9 information from NVDEC provided offset and size | 143 | /// Returns VP9 information from NVDEC provided offset and size |
| 144 | Vp9PictureInfo GetVp9PictureInfo(const NvdecCommon::NvdecRegisters& state); | 144 | [[nodiscard]] Vp9PictureInfo GetVp9PictureInfo(const NvdecCommon::NvdecRegisters& state); |
| 145 | 145 | ||
| 146 | /// Read and convert NVDEC provided entropy probs to Vp9EntropyProbs struct | 146 | /// Read and convert NVDEC provided entropy probs to Vp9EntropyProbs struct |
| 147 | void InsertEntropy(u64 offset, Vp9EntropyProbs& dst); | 147 | void InsertEntropy(u64 offset, Vp9EntropyProbs& dst); |
| 148 | 148 | ||
| 149 | /// Returns frame to be decoded after buffering | 149 | /// Returns frame to be decoded after buffering |
| 150 | Vp9FrameContainer GetCurrentFrame(const NvdecCommon::NvdecRegisters& state); | 150 | [[nodiscard]] Vp9FrameContainer GetCurrentFrame(const NvdecCommon::NvdecRegisters& state); |
| 151 | 151 | ||
| 152 | /// Use NVDEC providied information to compose the headers for the current frame | 152 | /// Use NVDEC providied information to compose the headers for the current frame |
| 153 | std::vector<u8> ComposeCompressedHeader(); | 153 | [[nodiscard]] std::vector<u8> ComposeCompressedHeader(); |
| 154 | VpxBitStreamWriter ComposeUncompressedHeader(); | 154 | [[nodiscard]] VpxBitStreamWriter ComposeUncompressedHeader(); |
| 155 | 155 | ||
| 156 | GPU& gpu; | 156 | GPU& gpu; |
| 157 | std::vector<u8> frame; | 157 | std::vector<u8> frame; |