Compare commits
2 Commits
android-15
...
android-15
Author | SHA1 | Date | |
---|---|---|---|
e59c874768 | |||
badc846536 |
@ -1,5 +1,6 @@
|
||||
| Pull Request | Commit | Title | Author | Merged? |
|
||||
|----|----|----|----|----|
|
||||
| [12274](https://github.com/yuzu-emu/yuzu//pull/12274) | [`6b7dc587c`](https://github.com/yuzu-emu/yuzu//pull/12274/files) | renderer_vulkan: do not recreate swapchain for srgb | [liamwhite](https://github.com/liamwhite/) | Yes |
|
||||
|
||||
|
||||
End of merge log. You can find the original README.md below the break.
|
||||
|
19
dist/72-yuzu-input.rules
vendored
19
dist/72-yuzu-input.rules
vendored
@ -1,19 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2023 yuzu Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# Allow systemd-logind to manage user access to hidraw with this file
|
||||
# On most systems, this file should be installed to /etc/udev/rules.d/72-yuzu-input.rules
|
||||
# Consult your distro if this is not the case
|
||||
|
||||
# Switch Pro Controller (USB/Bluetooth)
|
||||
KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="2009", MODE="0660", TAG+="uaccess"
|
||||
KERNEL=="hidraw*", KERNELS=="*057e:2009*", MODE="0660", TAG+="uaccess"
|
||||
|
||||
# Joy-Con L (Bluetooth)
|
||||
KERNEL=="hidraw*", KERNELS=="*057e:2006*", MODE="0660", TAG+="uaccess"
|
||||
|
||||
# Joy-Con R (Bluetooth)
|
||||
KERNEL=="hidraw*", KERNELS=="*057e:2007*", MODE="0660", TAG+="uaccess"
|
||||
|
||||
# Joy-Con Charging Grip (USB)
|
||||
KERNEL=="hidraw*", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="200e", MODE="0660", TAG+="uaccess"
|
@ -2,7 +2,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <cstring>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
#include "common/alignment.h"
|
||||
#include "common/assert.h"
|
||||
@ -135,7 +134,7 @@ void RomFSBuildContext::VisitDirectory(VirtualDir romfs_dir, VirtualDir ext_dir,
|
||||
|
||||
child->size = child->source->GetSize();
|
||||
|
||||
AddFile(parent, std::move(child));
|
||||
AddFile(parent, child);
|
||||
}
|
||||
|
||||
for (auto& child_romfs_dir : romfs_dir->GetSubdirectories()) {
|
||||
@ -164,24 +163,36 @@ void RomFSBuildContext::VisitDirectory(VirtualDir romfs_dir, VirtualDir ext_dir,
|
||||
|
||||
bool RomFSBuildContext::AddDirectory(std::shared_ptr<RomFSBuildDirectoryContext> parent_dir_ctx,
|
||||
std::shared_ptr<RomFSBuildDirectoryContext> dir_ctx) {
|
||||
// Check whether it's already in the known directories.
|
||||
const auto [it, is_new] = directories.emplace(dir_ctx->path, nullptr);
|
||||
if (!is_new) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add a new directory.
|
||||
num_dirs++;
|
||||
dir_table_size +=
|
||||
sizeof(RomFSDirectoryEntry) + Common::AlignUp(dir_ctx->path_len - dir_ctx->cur_path_ofs, 4);
|
||||
dir_ctx->parent = std::move(parent_dir_ctx);
|
||||
directories.emplace_back(std::move(dir_ctx));
|
||||
dir_ctx->parent = parent_dir_ctx;
|
||||
it->second = dir_ctx;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RomFSBuildContext::AddFile(std::shared_ptr<RomFSBuildDirectoryContext> parent_dir_ctx,
|
||||
std::shared_ptr<RomFSBuildFileContext> file_ctx) {
|
||||
// Check whether it's already in the known files.
|
||||
const auto [it, is_new] = files.emplace(file_ctx->path, nullptr);
|
||||
if (!is_new) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add a new file.
|
||||
num_files++;
|
||||
file_table_size +=
|
||||
sizeof(RomFSFileEntry) + Common::AlignUp(file_ctx->path_len - file_ctx->cur_path_ofs, 4);
|
||||
file_ctx->parent = std::move(parent_dir_ctx);
|
||||
files.emplace_back(std::move(file_ctx));
|
||||
file_ctx->parent = parent_dir_ctx;
|
||||
it->second = file_ctx;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -190,7 +201,7 @@ RomFSBuildContext::RomFSBuildContext(VirtualDir base_, VirtualDir ext_)
|
||||
: base(std::move(base_)), ext(std::move(ext_)) {
|
||||
root = std::make_shared<RomFSBuildDirectoryContext>();
|
||||
root->path = "\0";
|
||||
directories.emplace_back(root);
|
||||
directories.emplace(root->path, root);
|
||||
num_dirs = 1;
|
||||
dir_table_size = 0x18;
|
||||
|
||||
@ -199,43 +210,28 @@ RomFSBuildContext::RomFSBuildContext(VirtualDir base_, VirtualDir ext_)
|
||||
|
||||
RomFSBuildContext::~RomFSBuildContext() = default;
|
||||
|
||||
std::vector<std::pair<u64, VirtualFile>> RomFSBuildContext::Build() {
|
||||
std::multimap<u64, VirtualFile> RomFSBuildContext::Build() {
|
||||
const u64 dir_hash_table_entry_count = romfs_get_hash_table_count(num_dirs);
|
||||
const u64 file_hash_table_entry_count = romfs_get_hash_table_count(num_files);
|
||||
dir_hash_table_size = 4 * dir_hash_table_entry_count;
|
||||
file_hash_table_size = 4 * file_hash_table_entry_count;
|
||||
|
||||
// Assign metadata pointers.
|
||||
// Assign metadata pointers
|
||||
RomFSHeader header{};
|
||||
|
||||
std::vector<u8> metadata(file_hash_table_size + file_table_size + dir_hash_table_size +
|
||||
dir_table_size);
|
||||
u32* const dir_hash_table_pointer = reinterpret_cast<u32*>(metadata.data());
|
||||
u8* const dir_table_pointer = metadata.data() + dir_hash_table_size;
|
||||
u32* const file_hash_table_pointer =
|
||||
reinterpret_cast<u32*>(metadata.data() + dir_hash_table_size + dir_table_size);
|
||||
u8* const file_table_pointer =
|
||||
metadata.data() + dir_hash_table_size + dir_table_size + file_hash_table_size;
|
||||
std::vector<u32> dir_hash_table(dir_hash_table_entry_count, ROMFS_ENTRY_EMPTY);
|
||||
std::vector<u32> file_hash_table(file_hash_table_entry_count, ROMFS_ENTRY_EMPTY);
|
||||
|
||||
std::span<u32> dir_hash_table(dir_hash_table_pointer, dir_hash_table_entry_count);
|
||||
std::span<u32> file_hash_table(file_hash_table_pointer, file_hash_table_entry_count);
|
||||
std::span<u8> dir_table(dir_table_pointer, dir_table_size);
|
||||
std::span<u8> file_table(file_table_pointer, file_table_size);
|
||||
std::vector<u8> dir_table(dir_table_size);
|
||||
std::vector<u8> file_table(file_table_size);
|
||||
|
||||
// Initialize hash tables.
|
||||
std::memset(dir_hash_table.data(), 0xFF, dir_hash_table.size_bytes());
|
||||
std::memset(file_hash_table.data(), 0xFF, file_hash_table.size_bytes());
|
||||
|
||||
// Sort tables by name.
|
||||
std::sort(files.begin(), files.end(),
|
||||
[](const auto& a, const auto& b) { return a->path < b->path; });
|
||||
std::sort(directories.begin(), directories.end(),
|
||||
[](const auto& a, const auto& b) { return a->path < b->path; });
|
||||
std::shared_ptr<RomFSBuildFileContext> cur_file;
|
||||
|
||||
// Determine file offsets.
|
||||
u32 entry_offset = 0;
|
||||
std::shared_ptr<RomFSBuildFileContext> prev_file = nullptr;
|
||||
for (const auto& cur_file : files) {
|
||||
for (const auto& it : files) {
|
||||
cur_file = it.second;
|
||||
file_partition_size = Common::AlignUp(file_partition_size, 16);
|
||||
cur_file->offset = file_partition_size;
|
||||
file_partition_size += cur_file->size;
|
||||
@ -247,48 +243,34 @@ std::vector<std::pair<u64, VirtualFile>> RomFSBuildContext::Build() {
|
||||
}
|
||||
// Assign deferred parent/sibling ownership.
|
||||
for (auto it = files.rbegin(); it != files.rend(); ++it) {
|
||||
auto& cur_file = *it;
|
||||
cur_file = it->second;
|
||||
cur_file->sibling = cur_file->parent->file;
|
||||
cur_file->parent->file = cur_file;
|
||||
}
|
||||
|
||||
std::shared_ptr<RomFSBuildDirectoryContext> cur_dir;
|
||||
|
||||
// Determine directory offsets.
|
||||
entry_offset = 0;
|
||||
for (const auto& cur_dir : directories) {
|
||||
for (const auto& it : directories) {
|
||||
cur_dir = it.second;
|
||||
cur_dir->entry_offset = entry_offset;
|
||||
entry_offset +=
|
||||
static_cast<u32>(sizeof(RomFSDirectoryEntry) +
|
||||
Common::AlignUp(cur_dir->path_len - cur_dir->cur_path_ofs, 4));
|
||||
}
|
||||
// Assign deferred parent/sibling ownership.
|
||||
for (auto it = directories.rbegin(); (*it) != root; ++it) {
|
||||
auto& cur_dir = *it;
|
||||
for (auto it = directories.rbegin(); it->second != root; ++it) {
|
||||
cur_dir = it->second;
|
||||
cur_dir->sibling = cur_dir->parent->child;
|
||||
cur_dir->parent->child = cur_dir;
|
||||
}
|
||||
|
||||
// Create output map.
|
||||
std::vector<std::pair<u64, VirtualFile>> out;
|
||||
out.reserve(num_files + 2);
|
||||
|
||||
// Set header fields.
|
||||
header.header_size = sizeof(RomFSHeader);
|
||||
header.file_hash_table_size = file_hash_table_size;
|
||||
header.file_table_size = file_table_size;
|
||||
header.dir_hash_table_size = dir_hash_table_size;
|
||||
header.dir_table_size = dir_table_size;
|
||||
header.file_partition_ofs = ROMFS_FILEPARTITION_OFS;
|
||||
header.dir_hash_table_ofs = Common::AlignUp(header.file_partition_ofs + file_partition_size, 4);
|
||||
header.dir_table_ofs = header.dir_hash_table_ofs + header.dir_hash_table_size;
|
||||
header.file_hash_table_ofs = header.dir_table_ofs + header.dir_table_size;
|
||||
header.file_table_ofs = header.file_hash_table_ofs + header.file_hash_table_size;
|
||||
|
||||
std::vector<u8> header_data(sizeof(RomFSHeader));
|
||||
std::memcpy(header_data.data(), &header, header_data.size());
|
||||
out.emplace_back(0, std::make_shared<VectorVfsFile>(std::move(header_data)));
|
||||
std::multimap<u64, VirtualFile> out;
|
||||
|
||||
// Populate file tables.
|
||||
for (const auto& cur_file : files) {
|
||||
for (const auto& it : files) {
|
||||
cur_file = it.second;
|
||||
RomFSFileEntry cur_entry{};
|
||||
|
||||
cur_entry.parent = cur_file->parent->entry_offset;
|
||||
@ -305,7 +287,7 @@ std::vector<std::pair<u64, VirtualFile>> RomFSBuildContext::Build() {
|
||||
|
||||
cur_entry.name_size = name_size;
|
||||
|
||||
out.emplace_back(cur_file->offset + ROMFS_FILEPARTITION_OFS, std::move(cur_file->source));
|
||||
out.emplace(cur_file->offset + ROMFS_FILEPARTITION_OFS, std::move(cur_file->source));
|
||||
std::memcpy(file_table.data() + cur_file->entry_offset, &cur_entry, sizeof(RomFSFileEntry));
|
||||
std::memset(file_table.data() + cur_file->entry_offset + sizeof(RomFSFileEntry), 0,
|
||||
Common::AlignUp(cur_entry.name_size, 4));
|
||||
@ -314,7 +296,8 @@ std::vector<std::pair<u64, VirtualFile>> RomFSBuildContext::Build() {
|
||||
}
|
||||
|
||||
// Populate dir tables.
|
||||
for (const auto& cur_dir : directories) {
|
||||
for (const auto& it : directories) {
|
||||
cur_dir = it.second;
|
||||
RomFSDirectoryEntry cur_entry{};
|
||||
|
||||
cur_entry.parent = cur_dir == root ? 0 : cur_dir->parent->entry_offset;
|
||||
@ -340,13 +323,34 @@ std::vector<std::pair<u64, VirtualFile>> RomFSBuildContext::Build() {
|
||||
cur_dir->path.data() + cur_dir->cur_path_ofs, name_size);
|
||||
}
|
||||
|
||||
// Write metadata.
|
||||
out.emplace_back(header.dir_hash_table_ofs,
|
||||
std::make_shared<VectorVfsFile>(std::move(metadata)));
|
||||
// Set header fields.
|
||||
header.header_size = sizeof(RomFSHeader);
|
||||
header.file_hash_table_size = file_hash_table_size;
|
||||
header.file_table_size = file_table_size;
|
||||
header.dir_hash_table_size = dir_hash_table_size;
|
||||
header.dir_table_size = dir_table_size;
|
||||
header.file_partition_ofs = ROMFS_FILEPARTITION_OFS;
|
||||
header.dir_hash_table_ofs = Common::AlignUp(header.file_partition_ofs + file_partition_size, 4);
|
||||
header.dir_table_ofs = header.dir_hash_table_ofs + header.dir_hash_table_size;
|
||||
header.file_hash_table_ofs = header.dir_table_ofs + header.dir_table_size;
|
||||
header.file_table_ofs = header.file_hash_table_ofs + header.file_hash_table_size;
|
||||
|
||||
// Sort the output.
|
||||
std::sort(out.begin(), out.end(),
|
||||
[](const auto& a, const auto& b) { return a.first < b.first; });
|
||||
std::vector<u8> header_data(sizeof(RomFSHeader));
|
||||
std::memcpy(header_data.data(), &header, header_data.size());
|
||||
out.emplace(0, std::make_shared<VectorVfsFile>(std::move(header_data)));
|
||||
|
||||
std::vector<u8> metadata(file_hash_table_size + file_table_size + dir_hash_table_size +
|
||||
dir_table_size);
|
||||
std::size_t index = 0;
|
||||
std::memcpy(metadata.data(), dir_hash_table.data(), dir_hash_table.size() * sizeof(u32));
|
||||
index += dir_hash_table.size() * sizeof(u32);
|
||||
std::memcpy(metadata.data() + index, dir_table.data(), dir_table.size());
|
||||
index += dir_table.size();
|
||||
std::memcpy(metadata.data() + index, file_hash_table.data(),
|
||||
file_hash_table.size() * sizeof(u32));
|
||||
index += file_hash_table.size() * sizeof(u32);
|
||||
std::memcpy(metadata.data() + index, file_table.data(), file_table.size());
|
||||
out.emplace(header.dir_hash_table_ofs, std::make_shared<VectorVfsFile>(std::move(metadata)));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ public:
|
||||
~RomFSBuildContext();
|
||||
|
||||
// This finalizes the context.
|
||||
std::vector<std::pair<u64, VirtualFile>> Build();
|
||||
std::multimap<u64, VirtualFile> Build();
|
||||
|
||||
private:
|
||||
VirtualDir base;
|
||||
VirtualDir ext;
|
||||
std::shared_ptr<RomFSBuildDirectoryContext> root;
|
||||
std::vector<std::shared_ptr<RomFSBuildDirectoryContext>> directories;
|
||||
std::vector<std::shared_ptr<RomFSBuildFileContext>> files;
|
||||
std::map<std::string, std::shared_ptr<RomFSBuildDirectoryContext>, std::less<>> directories;
|
||||
std::map<std::string, std::shared_ptr<RomFSBuildFileContext>, std::less<>> files;
|
||||
u64 num_dirs = 0;
|
||||
u64 num_files = 0;
|
||||
u64 dir_table_size = 0;
|
||||
|
@ -55,68 +55,44 @@ struct FileEntry {
|
||||
};
|
||||
static_assert(sizeof(FileEntry) == 0x20, "FileEntry has incorrect size.");
|
||||
|
||||
struct RomFSTraversalContext {
|
||||
RomFSHeader header;
|
||||
VirtualFile file;
|
||||
std::vector<u8> directory_meta;
|
||||
std::vector<u8> file_meta;
|
||||
};
|
||||
|
||||
template <typename EntryType, auto Member>
|
||||
std::pair<EntryType, std::string> GetEntry(const RomFSTraversalContext& ctx, size_t offset) {
|
||||
const size_t entry_end = offset + sizeof(EntryType);
|
||||
const std::vector<u8>& vec = ctx.*Member;
|
||||
const size_t size = vec.size();
|
||||
const u8* data = vec.data();
|
||||
EntryType entry{};
|
||||
|
||||
if (entry_end > size) {
|
||||
template <typename Entry>
|
||||
std::pair<Entry, std::string> GetEntry(const VirtualFile& file, std::size_t offset) {
|
||||
Entry entry{};
|
||||
if (file->ReadObject(&entry, offset) != sizeof(Entry))
|
||||
return {};
|
||||
}
|
||||
std::memcpy(&entry, data + offset, sizeof(EntryType));
|
||||
|
||||
const size_t name_length = std::min(entry_end + entry.name_length, size) - entry_end;
|
||||
std::string name(reinterpret_cast<const char*>(data + entry_end), name_length);
|
||||
|
||||
return {entry, std::move(name)};
|
||||
std::string string(entry.name_length, '\0');
|
||||
if (file->ReadArray(&string[0], string.size(), offset + sizeof(Entry)) != string.size())
|
||||
return {};
|
||||
return {entry, string};
|
||||
}
|
||||
|
||||
std::pair<DirectoryEntry, std::string> GetDirectoryEntry(const RomFSTraversalContext& ctx,
|
||||
size_t directory_offset) {
|
||||
return GetEntry<DirectoryEntry, &RomFSTraversalContext::directory_meta>(ctx, directory_offset);
|
||||
}
|
||||
|
||||
std::pair<FileEntry, std::string> GetFileEntry(const RomFSTraversalContext& ctx,
|
||||
size_t file_offset) {
|
||||
return GetEntry<FileEntry, &RomFSTraversalContext::file_meta>(ctx, file_offset);
|
||||
}
|
||||
|
||||
void ProcessFile(const RomFSTraversalContext& ctx, u32 this_file_offset,
|
||||
std::shared_ptr<VectorVfsDirectory>& parent) {
|
||||
void ProcessFile(const VirtualFile& file, std::size_t file_offset, std::size_t data_offset,
|
||||
u32 this_file_offset, std::shared_ptr<VectorVfsDirectory>& parent) {
|
||||
while (this_file_offset != ROMFS_ENTRY_EMPTY) {
|
||||
auto entry = GetFileEntry(ctx, this_file_offset);
|
||||
auto entry = GetEntry<FileEntry>(file, file_offset + this_file_offset);
|
||||
|
||||
parent->AddFile(std::make_shared<OffsetVfsFile>(ctx.file, entry.first.size,
|
||||
entry.first.offset + ctx.header.data_offset,
|
||||
std::move(entry.second)));
|
||||
parent->AddFile(std::make_shared<OffsetVfsFile>(
|
||||
file, entry.first.size, entry.first.offset + data_offset, entry.second));
|
||||
|
||||
this_file_offset = entry.first.sibling;
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessDirectory(const RomFSTraversalContext& ctx, u32 this_dir_offset,
|
||||
void ProcessDirectory(const VirtualFile& file, std::size_t dir_offset, std::size_t file_offset,
|
||||
std::size_t data_offset, u32 this_dir_offset,
|
||||
std::shared_ptr<VectorVfsDirectory>& parent) {
|
||||
while (this_dir_offset != ROMFS_ENTRY_EMPTY) {
|
||||
auto entry = GetDirectoryEntry(ctx, this_dir_offset);
|
||||
auto entry = GetEntry<DirectoryEntry>(file, dir_offset + this_dir_offset);
|
||||
auto current = std::make_shared<VectorVfsDirectory>(
|
||||
std::vector<VirtualFile>{}, std::vector<VirtualDir>{}, entry.second);
|
||||
|
||||
if (entry.first.child_file != ROMFS_ENTRY_EMPTY) {
|
||||
ProcessFile(ctx, entry.first.child_file, current);
|
||||
ProcessFile(file, file_offset, data_offset, entry.first.child_file, current);
|
||||
}
|
||||
|
||||
if (entry.first.child_dir != ROMFS_ENTRY_EMPTY) {
|
||||
ProcessDirectory(ctx, entry.first.child_dir, current);
|
||||
ProcessDirectory(file, dir_offset, file_offset, data_offset, entry.first.child_dir,
|
||||
current);
|
||||
}
|
||||
|
||||
parent->AddDirectory(current);
|
||||
@ -131,25 +107,22 @@ VirtualDir ExtractRomFS(VirtualFile file) {
|
||||
return root_container;
|
||||
}
|
||||
|
||||
RomFSTraversalContext ctx{};
|
||||
|
||||
if (file->ReadObject(&ctx.header) != sizeof(RomFSHeader)) {
|
||||
return nullptr;
|
||||
RomFSHeader header{};
|
||||
if (file->ReadObject(&header) != sizeof(RomFSHeader)) {
|
||||
return root_container;
|
||||
}
|
||||
|
||||
if (ctx.header.header_size != sizeof(RomFSHeader)) {
|
||||
return nullptr;
|
||||
if (header.header_size != sizeof(RomFSHeader)) {
|
||||
return root_container;
|
||||
}
|
||||
|
||||
ctx.file = file;
|
||||
ctx.directory_meta =
|
||||
file->ReadBytes(ctx.header.directory_meta.size, ctx.header.directory_meta.offset);
|
||||
ctx.file_meta = file->ReadBytes(ctx.header.file_meta.size, ctx.header.file_meta.offset);
|
||||
const u64 file_offset = header.file_meta.offset;
|
||||
const u64 dir_offset = header.directory_meta.offset;
|
||||
|
||||
ProcessDirectory(ctx, 0, root_container);
|
||||
ProcessDirectory(file, dir_offset, file_offset, header.data_offset, 0, root_container);
|
||||
|
||||
if (auto root = root_container->GetSubdirectory(""); root) {
|
||||
return root;
|
||||
return std::make_shared<CachedVfsDirectory>(std::move(root));
|
||||
}
|
||||
|
||||
ASSERT(false);
|
||||
|
@ -59,8 +59,8 @@ VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(std::string&& name,
|
||||
return VirtualFile(new ConcatenatedVfsFile(std::move(name), std::move(concatenation_map)));
|
||||
}
|
||||
|
||||
VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(
|
||||
u8 filler_byte, std::string&& name, std::vector<std::pair<u64, VirtualFile>>&& files) {
|
||||
VirtualFile ConcatenatedVfsFile::MakeConcatenatedFile(u8 filler_byte, std::string&& name,
|
||||
std::multimap<u64, VirtualFile>&& files) {
|
||||
// Fold trivial cases.
|
||||
if (files.empty()) {
|
||||
return nullptr;
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
/// Convenience function that turns a map of offsets to files into a concatenated file, filling
|
||||
/// gaps with a given filler byte.
|
||||
static VirtualFile MakeConcatenatedFile(u8 filler_byte, std::string&& name,
|
||||
std::vector<std::pair<u64, VirtualFile>>&& files);
|
||||
std::multimap<u64, VirtualFile>&& files);
|
||||
|
||||
std::string GetName() const override;
|
||||
std::size_t GetSize() const override;
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include "core/file_sys/vfs_layered.h"
|
||||
|
||||
@ -60,12 +59,13 @@ std::string LayeredVfsDirectory::GetFullPath() const {
|
||||
|
||||
std::vector<VirtualFile> LayeredVfsDirectory::GetFiles() const {
|
||||
std::vector<VirtualFile> out;
|
||||
std::unordered_set<std::string> out_names;
|
||||
std::set<std::string, std::less<>> out_names;
|
||||
|
||||
for (const auto& layer : dirs) {
|
||||
for (auto& file : layer->GetFiles()) {
|
||||
const auto [it, is_new] = out_names.emplace(file->GetName());
|
||||
if (is_new) {
|
||||
auto file_name = file->GetName();
|
||||
if (!out_names.contains(file_name)) {
|
||||
out_names.emplace(std::move(file_name));
|
||||
out.emplace_back(std::move(file));
|
||||
}
|
||||
}
|
||||
@ -75,19 +75,18 @@ std::vector<VirtualFile> LayeredVfsDirectory::GetFiles() const {
|
||||
}
|
||||
|
||||
std::vector<VirtualDir> LayeredVfsDirectory::GetSubdirectories() const {
|
||||
std::vector<VirtualDir> out;
|
||||
std::unordered_set<std::string> out_names;
|
||||
|
||||
std::vector<std::string> names;
|
||||
for (const auto& layer : dirs) {
|
||||
for (const auto& sd : layer->GetSubdirectories()) {
|
||||
out_names.emplace(sd->GetName());
|
||||
if (std::find(names.begin(), names.end(), sd->GetName()) == names.end())
|
||||
names.push_back(sd->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
out.reserve(out_names.size());
|
||||
for (const auto& subdir : out_names) {
|
||||
std::vector<VirtualDir> out;
|
||||
out.reserve(names.size());
|
||||
for (const auto& subdir : names)
|
||||
out.emplace_back(GetSubdirectory(subdir));
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -233,12 +233,7 @@ std::unique_ptr<Frame> DecoderContext::ReceiveFrame(bool* out_is_interlaced) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*out_is_interlaced =
|
||||
#if defined(FF_API_INTERLACED_FRAME) || LIBAVUTIL_VERSION_MAJOR >= 59
|
||||
(frame->flags & AV_FRAME_FLAG_INTERLACED) != 0;
|
||||
#else
|
||||
frame->interlaced_frame != 0;
|
||||
#endif
|
||||
*out_is_interlaced = frame->interlaced_frame != 0;
|
||||
return true;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user