diff --git a/ProxyEdit.vcxproj b/ProxyEdit.vcxproj
index 6509b62..cd939e1 100644
--- a/ProxyEdit.vcxproj
+++ b/ProxyEdit.vcxproj
@@ -67,7 +67,7 @@
Windows
- user32.lib;gdi32.lib;ole32.lib;shlwapi.lib;windowscodecs.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;d3d11.lib;%(AdditionalDependencies)
+ user32.lib;gdi32.lib;ole32.lib;shlwapi.lib;windowscodecs.lib;mfplat.lib;mfreadwrite.lib;mfuuid.lib;%(AdditionalDependencies)
true
diff --git a/src/MediaDecoder.cpp b/src/MediaDecoder.cpp
index 6433f34..a0e0c25 100644
--- a/src/MediaDecoder.cpp
+++ b/src/MediaDecoder.cpp
@@ -1,6 +1,5 @@
#include "MediaDecoder.h"
-#include
#include
#include
#include
@@ -79,34 +78,14 @@ MediaDecoder::~MediaDecoder() {
Close();
}
-bool MediaDecoder::Open(const std::wstring& path, bool hardware) {
+bool MediaDecoder::Open(const std::wstring& path) {
Close();
if (!StartMediaFoundation()) return false;
std::lock_guard lock(mutex_);
- if (hardware) {
- UINT flags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT | D3D11_CREATE_DEVICE_BGRA_SUPPORT;
- if (SUCCEEDED(D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, flags, nullptr, 0,
- D3D11_SDK_VERSION, &device_, nullptr, nullptr)) &&
- device_) {
- ID3D10Multithread* threading = nullptr;
- if (SUCCEEDED(device_->QueryInterface(IID_PPV_ARGS(&threading)))) {
- threading->SetMultithreadProtected(TRUE);
- threading->Release();
- }
- if (FAILED(MFCreateDXGIDeviceManager(&token_, &manager_)) ||
- FAILED(manager_->ResetDevice(device_, token_))) {
- if (manager_) {
- manager_->Release();
- manager_ = nullptr;
- }
- }
- }
- }
IMFAttributes* attributes = nullptr;
if (FAILED(MFCreateAttributes(&attributes, 4))) return false;
attributes->SetUINT32(MF_SOURCE_READER_ENABLE_ADVANCED_VIDEO_PROCESSING, TRUE);
- attributes->SetUINT32(MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, hardware ? TRUE : FALSE);
- if (manager_) attributes->SetUnknown(MF_SOURCE_READER_D3D_MANAGER, manager_);
+ attributes->SetUINT32(MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, FALSE);
HRESULT result = MFCreateSourceReaderFromURL(path.c_str(), attributes, &reader_);
attributes->Release();
if (FAILED(result) || !reader_) return false;
@@ -167,14 +146,6 @@ void MediaDecoder::Close() {
reader_->Release();
reader_ = nullptr;
}
- if (manager_) {
- manager_->Release();
- manager_ = nullptr;
- }
- if (device_) {
- device_->Release();
- device_ = nullptr;
- }
next_index_ = -1;
}
diff --git a/src/MediaDecoder.h b/src/MediaDecoder.h
index ffa6827..39406b3 100644
--- a/src/MediaDecoder.h
+++ b/src/MediaDecoder.h
@@ -8,8 +8,6 @@
#include
struct IMFSourceReader;
-struct IMFDXGIDeviceManager;
-struct ID3D11Device;
namespace pe {
@@ -19,7 +17,7 @@ void StopMediaFoundation();
class MediaDecoder {
public:
~MediaDecoder();
- bool Open(const std::wstring& path, bool hardware);
+ bool Open(const std::wstring& path);
void Close();
bool IsOpen() const;
@@ -37,9 +35,6 @@ private:
long long FrameToTime(long long index) const;
IMFSourceReader* reader_ = nullptr;
- IMFDXGIDeviceManager* manager_ = nullptr;
- ID3D11Device* device_ = nullptr;
- unsigned token_ = 0;
int width_ = 0;
int height_ = 0;
int rate_ = 0;
diff --git a/src/ProxyBuilder.cpp b/src/ProxyBuilder.cpp
index 5f1bc6f..939a865 100644
--- a/src/ProxyBuilder.cpp
+++ b/src/ProxyBuilder.cpp
@@ -110,18 +110,28 @@ void MarkChunk(const JobPointer& job, int chunk, unsigned char state) {
bool OpenDecoder(const JobPointer& job) {
if (job->opened.load()) return true;
- if (!job->decoder.Open(job->key.path, true)) {
- if (!job->decoder.Open(job->key.path, false)) {
- job->failed.store(true);
+ if (!job->decoder.Open(job->key.path)) {
+ job->failed.store(true);
+ {
std::lock_guard lock(job->state_lock);
job->message = L"この形式は Media Foundation で読み込めません";
- return false;
}
+ Warn(L"元素材を開けませんでした: %s", job->key.path.c_str());
+ return false;
}
job->opened.store(true);
return true;
}
+void FailJob(const JobPointer& job, const wchar_t* reason) {
+ job->failed.store(true);
+ {
+ std::lock_guard lock(job->state_lock);
+ job->message = reason;
+ }
+ Warn(L"生成を中止しました: %s (%s)", reason, job->key.path.c_str());
+}
+
void ProcessChunk(const JobPointer& job, int chunk) {
const ProxyHeader& header = job->header;
const int begin = chunk * header.chunk_frames;
@@ -136,24 +146,18 @@ void ProcessChunk(const JobPointer& job, int chunk) {
for (int frame = begin; frame < end && !g_stop.load(); frame++) {
if (job->writer.HasFrame(frame)) continue;
if (!job->decoder.ReadFrameYuy2(frame, picture.data(), stride, header.source_height)) {
- job->failed.store(true);
- std::lock_guard lock(job->state_lock);
- job->message = L"復号できないフレームがありました";
+ FailJob(job, L"復号できないフレームがありました");
break;
}
Yuy2ToBgrScaled(picture.data(), header.source_width, header.source_height, stride, reduced.data(),
header.proxy_width, header.proxy_height);
if (!EncodeJpeg(reduced.data(), header.proxy_width, header.proxy_height, header.proxy_width,
header.proxy_height, header.quality, encoded)) {
- job->failed.store(true);
- std::lock_guard lock(job->state_lock);
- job->message = L"プロキシの符号化に失敗しました";
+ FailJob(job, L"プロキシの符号化に失敗しました");
break;
}
if (!job->writer.WriteFrame(frame, encoded.data(), (int)encoded.size())) {
- job->failed.store(true);
- std::lock_guard lock(job->state_lock);
- job->message = L"プロキシを書き込めませんでした";
+ FailJob(job, L"プロキシを書き込めませんでした");
break;
}
produced++;
@@ -260,7 +264,7 @@ bool RegisterSource(const std::wstring& source, std::wstring& proxy_path) {
job->proxy = ProxyPathFor(key);
MediaDecoder probe;
- if (!probe.Open(source, true) && !probe.Open(source, false)) return false;
+ if (!probe.Open(source)) return false;
const Settings& settings = CurrentSettings();
int proxy_width = probe.Width() * settings.scale_percent / 100;
int proxy_height = probe.Height() * settings.scale_percent / 100;
diff --git a/src/ProxyInput.cpp b/src/ProxyInput.cpp
index 9525468..c018998 100644
--- a/src/ProxyInput.cpp
+++ b/src/ProxyInput.cpp
@@ -75,7 +75,7 @@ bool DecodeOriginalFrame(Session* session, int frame, unsigned char* destination
if (session->original_failed.load()) return false;
std::lock_guard lock(session->original_lock);
if (!session->original_ready.load()) {
- if (!session->original.Open(session->header.source_path, false)) {
+ if (!session->original.Open(session->header.source_path)) {
session->original_failed.store(true);
Warn(L"元素材を読み込めませんでした: %s", session->header.source_path);
return false;
diff --git a/src/ScanController.cpp b/src/ScanController.cpp
index 0b94d04..ebc83e2 100644
--- a/src/ScanController.cpp
+++ b/src/ScanController.cpp
@@ -2,8 +2,12 @@
#include
#include
+#include
#include