diff options
| author | 2020-11-26 00:18:26 -0500 | |
|---|---|---|
| committer | 2020-11-26 00:18:26 -0500 | |
| commit | c9e3abe2060760d71c83a1574559b6e479e637d2 (patch) | |
| tree | 2c29ff2c4ba95f7219b0654b5c1c32b23288cd54 /src | |
| parent | Queue decoded frames, cleanup decoders (diff) | |
| download | yuzu-c9e3abe2060760d71c83a1574559b6e479e637d2.tar.gz yuzu-c9e3abe2060760d71c83a1574559b6e479e637d2.tar.xz yuzu-c9e3abe2060760d71c83a1574559b6e479e637d2.zip | |
Address PR feedback
remove some redundant moves, make deleter match naming guidelines.
Co-Authored-By: LC <712067+lioncash@users.noreply.github.com>
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/command_classes/codecs/codec.cpp | 15 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/codec.h | 4 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/vp9.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/command_classes/codecs/vp9_types.h | 44 |
4 files changed, 33 insertions, 32 deletions
diff --git a/src/video_core/command_classes/codecs/codec.cpp b/src/video_core/command_classes/codecs/codec.cpp index 1a19341c8..412e1e41c 100644 --- a/src/video_core/command_classes/codecs/codec.cpp +++ b/src/video_core/command_classes/codecs/codec.cpp | |||
| @@ -18,7 +18,7 @@ extern "C" { | |||
| 18 | 18 | ||
| 19 | namespace Tegra { | 19 | namespace Tegra { |
| 20 | 20 | ||
| 21 | void av_frame_deleter(AVFrame* ptr) { | 21 | void AVFrameDeleter(AVFrame* ptr) { |
| 22 | av_frame_unref(ptr); | 22 | av_frame_unref(ptr); |
| 23 | av_free(ptr); | 23 | av_free(ptr); |
| 24 | } | 24 | } |
| @@ -101,7 +101,7 @@ void Codec::Decode() { | |||
| 101 | 101 | ||
| 102 | if (!vp9_hidden_frame) { | 102 | if (!vp9_hidden_frame) { |
| 103 | // Only receive/store visible frames | 103 | // Only receive/store visible frames |
| 104 | AVFramePtr frame = AVFramePtr{av_frame_alloc(), av_frame_deleter}; | 104 | AVFramePtr frame = AVFramePtr{av_frame_alloc(), AVFrameDeleter}; |
| 105 | avcodec_receive_frame(av_codec_ctx, frame.get()); | 105 | avcodec_receive_frame(av_codec_ctx, frame.get()); |
| 106 | av_frames.push(std::move(frame)); | 106 | av_frames.push(std::move(frame)); |
| 107 | } | 107 | } |
| @@ -110,12 +110,13 @@ void Codec::Decode() { | |||
| 110 | AVFramePtr Codec::GetCurrentFrame() { | 110 | AVFramePtr Codec::GetCurrentFrame() { |
| 111 | // Sometimes VIC will request more frames than have been decoded. | 111 | // Sometimes VIC will request more frames than have been decoded. |
| 112 | // in this case, return a nullptr and don't overwrite previous frame data | 112 | // in this case, return a nullptr and don't overwrite previous frame data |
| 113 | if (av_frames.size() > 0) { | 113 | if (av_frames.empty()) { |
| 114 | AVFramePtr frame = std::move(av_frames.front()); | 114 | return AVFramePtr{nullptr, AVFrameDeleter}; |
| 115 | av_frames.pop(); | ||
| 116 | return frame; | ||
| 117 | } | 115 | } |
| 118 | return AVFramePtr{nullptr, av_frame_deleter}; | 116 | |
| 117 | AVFramePtr frame = std::move(av_frames.front()); | ||
| 118 | av_frames.pop(); | ||
| 119 | return frame; | ||
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | NvdecCommon::VideoCodec Codec::GetCurrentCodec() const { | 122 | NvdecCommon::VideoCodec Codec::GetCurrentCodec() const { |
diff --git a/src/video_core/command_classes/codecs/codec.h b/src/video_core/command_classes/codecs/codec.h index c26b59fde..0c6dde405 100644 --- a/src/video_core/command_classes/codecs/codec.h +++ b/src/video_core/command_classes/codecs/codec.h | |||
| @@ -23,8 +23,8 @@ namespace Tegra { | |||
| 23 | class GPU; | 23 | class GPU; |
| 24 | struct VicRegisters; | 24 | struct VicRegisters; |
| 25 | 25 | ||
| 26 | void av_frame_deleter(AVFrame* ptr); | 26 | void AVFrameDeleter(AVFrame* ptr); |
| 27 | using AVFramePtr = std::unique_ptr<AVFrame, decltype(&av_frame_deleter)>; | 27 | using AVFramePtr = std::unique_ptr<AVFrame, decltype(&AVFrameDeleter)>; |
| 28 | 28 | ||
| 29 | namespace Decoder { | 29 | namespace Decoder { |
| 30 | class H264; | 30 | class H264; |
diff --git a/src/video_core/command_classes/codecs/vp9.cpp b/src/video_core/command_classes/codecs/vp9.cpp index 31e00c27d..b1d675cdb 100644 --- a/src/video_core/command_classes/codecs/vp9.cpp +++ b/src/video_core/command_classes/codecs/vp9.cpp | |||
| @@ -306,7 +306,7 @@ void VP9::WriteCoefProbabilityUpdate(VpxRangeEncoder& writer, s32 tx_mode, | |||
| 306 | const std::array<u8, 1728>& old_prob) { | 306 | const std::array<u8, 1728>& old_prob) { |
| 307 | constexpr u32 block_bytes = 2 * 2 * 6 * 6 * 3; | 307 | constexpr u32 block_bytes = 2 * 2 * 6 * 6 * 3; |
| 308 | 308 | ||
| 309 | const auto needs_update = [&](u32 base_index) -> bool { | 309 | const auto needs_update = [&](u32 base_index) { |
| 310 | return !std::equal(new_prob.begin() + base_index, | 310 | return !std::equal(new_prob.begin() + base_index, |
| 311 | new_prob.begin() + base_index + block_bytes, | 311 | new_prob.begin() + base_index + block_bytes, |
| 312 | old_prob.begin() + base_index); | 312 | old_prob.begin() + base_index); |
diff --git a/src/video_core/command_classes/codecs/vp9_types.h b/src/video_core/command_classes/codecs/vp9_types.h index 5ca944f2a..139501a1c 100644 --- a/src/video_core/command_classes/codecs/vp9_types.h +++ b/src/video_core/command_classes/codecs/vp9_types.h | |||
| @@ -245,33 +245,33 @@ struct EntropyProbs { | |||
| 245 | std::array<u8, 2304> coef_probs{}; | 245 | std::array<u8, 2304> coef_probs{}; |
| 246 | 246 | ||
| 247 | void Convert(Vp9EntropyProbs& fc) { | 247 | void Convert(Vp9EntropyProbs& fc) { |
| 248 | fc.inter_mode_prob = std::move(inter_mode_prob); | 248 | fc.inter_mode_prob = inter_mode_prob; |
| 249 | fc.intra_inter_prob = std::move(intra_inter_prob); | 249 | fc.intra_inter_prob = intra_inter_prob; |
| 250 | fc.tx_8x8_prob = std::move(tx_8x8_prob); | 250 | fc.tx_8x8_prob = tx_8x8_prob; |
| 251 | fc.tx_16x16_prob = std::move(tx_16x16_prob); | 251 | fc.tx_16x16_prob = tx_16x16_prob; |
| 252 | fc.tx_32x32_prob = std::move(tx_32x32_prob); | 252 | fc.tx_32x32_prob = tx_32x32_prob; |
| 253 | 253 | ||
| 254 | for (s32 i = 0; i < 4; i++) { | 254 | for (std::size_t i = 0; i < 4; i++) { |
| 255 | for (s32 j = 0; j < 9; j++) { | 255 | for (std::size_t j = 0; j < 9; j++) { |
| 256 | fc.y_mode_prob[j + 9 * i] = j < 8 ? y_mode_prob_e0e7[i][j] : y_mode_prob_e8[i]; | 256 | fc.y_mode_prob[j + 9 * i] = j < 8 ? y_mode_prob_e0e7[i][j] : y_mode_prob_e8[i]; |
| 257 | } | 257 | } |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | fc.partition_prob = std::move(partition_prob); | 260 | fc.partition_prob = partition_prob; |
| 261 | fc.switchable_interp_prob = std::move(switchable_interp_prob); | 261 | fc.switchable_interp_prob = switchable_interp_prob; |
| 262 | fc.comp_inter_prob = std::move(comp_inter_prob); | 262 | fc.comp_inter_prob = comp_inter_prob; |
| 263 | fc.skip_probs = std::move(skip_probs); | 263 | fc.skip_probs = skip_probs; |
| 264 | fc.joints = std::move(joints); | 264 | fc.joints = joints; |
| 265 | fc.sign = std::move(sign); | 265 | fc.sign = sign; |
| 266 | fc.class_0 = std::move(class_0); | 266 | fc.class_0 = class_0; |
| 267 | fc.fr = std::move(fr); | 267 | fc.fr = fr; |
| 268 | fc.class_0_hp = std::move(class_0_hp); | 268 | fc.class_0_hp = class_0_hp; |
| 269 | fc.high_precision = std::move(high_precision); | 269 | fc.high_precision = high_precision; |
| 270 | fc.classes = std::move(classes); | 270 | fc.classes = classes; |
| 271 | fc.class_0_fr = std::move(class_0_fr); | 271 | fc.class_0_fr = class_0_fr; |
| 272 | fc.prob_bits = std::move(pred_bits); | 272 | fc.prob_bits = pred_bits; |
| 273 | fc.single_ref_prob = std::move(single_ref_prob); | 273 | fc.single_ref_prob = single_ref_prob; |
| 274 | fc.comp_ref_prob = std::move(comp_ref_prob); | 274 | fc.comp_ref_prob = comp_ref_prob; |
| 275 | 275 | ||
| 276 | // Skip the 4th element as it goes unused | 276 | // Skip the 4th element as it goes unused |
| 277 | for (std::size_t i = 0; i < coef_probs.size(); i += 4) { | 277 | for (std::size_t i = 0; i < coef_probs.size(); i += 4) { |