Skip to content

Commit

Permalink
File overwrite error.
Browse files Browse the repository at this point in the history
  • Loading branch information
manoreken2 committed Jan 3, 2021
1 parent ba4e0f4 commit a1ff2c8
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 34 deletions.
4 changes: 4 additions & 0 deletions HDR10Capture2019/00README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Extract all and run HDR10Capture.exe

Tested capture card: DeckLink Mini Recorder 4K.

Version 1.2

-File overwrite error.

Version 1.1

-Fix OpenEXR write alpha value bug.
Expand Down
70 changes: 43 additions & 27 deletions HDR10Capture2019/MLDX12App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "MLVideoCaptureEnumToStr.h"
#include "MLVideoTime.h"
#include "MLExrWriter.h"
#include <shlwapi.h>

// D3D12HelloFrameBuffering sample
//*********************************************************
Expand Down Expand Up @@ -518,8 +519,8 @@ MLDX12App::SetDefaultImgTexture(void)

mMutex.unlock();

mTexImg[mRenderTexImgIdx].Reset();
CreateTexture(mTexImg[mRenderTexImgIdx], TCE_TEX_IMG0, texW, texH, DXGI_FORMAT_R16G16B16A16_FLOAT, pixelBytes, (uint8_t*)buff);
mTexImg[mTexImgIdx].Reset();
CreateTexture(mTexImg[mTexImgIdx], TCE_TEX_IMG0, texW, texH, DXGI_FORMAT_R16G16B16A16_FLOAT, pixelBytes, (uint8_t*)buff);

delete[] buff;
}
Expand Down Expand Up @@ -886,7 +887,7 @@ MLDX12App::PopulateCommandList(void) {

// 全クライアント領域に画像を描画。
DrawFullscreenTexture(
(TextureEnum)(TCE_TEX_IMG0 + mRenderTexImgIdx),
(TextureEnum)(TCE_TEX_IMG0 + mTexImgIdx),
mRenderImg);

// Start the Dear ImGui frame
Expand Down Expand Up @@ -1043,7 +1044,7 @@ MLDX12App::ShowVideoCaptureWindow(void)
// 選択デバイスを使用開始。
hr = mVCU.UseDevice(mVCDeviceToUse.device);
if (FAILED(hr)) {
sprintf_s(mErrorVCMsg, "Use DeckLink Device failed %08x", hr);
sprintf_s(mErrorVCMsg, "Error: Use DeckLink Device failed %08x", hr);
ImGui::OpenPopup("ErrorVCPopup");
} else {
// 成功。
Expand Down Expand Up @@ -1098,20 +1099,25 @@ MLDX12App::ShowVideoCaptureWindow(void)
if (MLIF_Unknown != aviIF) {
ImGui::InputText("Record AVI filename ##VCS", mAviFilePath, sizeof mAviFilePath - 1);
if (ImGui::Button("Record ## VCS", ImVec2(256, 48))) {
wchar_t path[512];
memset(path, 0, sizeof path);
MultiByteToWideChar(CP_UTF8, 0, mAviFilePath, sizeof mAviFilePath, path, 511);

bool bRv = mVCU.AviWriter().Start(
path, fmt.width, fmt.height,
(double)fmt.frameRateTS/fmt.frameRateTV,
aviIF, true);
if (bRv) {
mVCState = VCS_Recording;
mErrorVCMsg[0] = 0;
} else {
sprintf_s(mErrorVCMsg, "Record Failed.\nFile open error : %s", mAviFilePath);
if (PathFileExistsA(mAviFilePath)) {
sprintf_s(mErrorVCMsg, "Error: File exists.\nPlease input different file name. %s", mAviFilePath);
ImGui::OpenPopup("ErrorVCPopup");
} else {
wchar_t path[512];
memset(path, 0, sizeof path);
MultiByteToWideChar(CP_UTF8, 0, mAviFilePath, sizeof mAviFilePath, path, 511);

bool bRv = mVCU.AviWriter().Start(
path, fmt.width, fmt.height,
(double)fmt.frameRateTS/fmt.frameRateTV,
aviIF, true);
if (bRv) {
mVCState = VCS_Recording;
mErrorVCMsg[0] = 0;
} else {
sprintf_s(mErrorVCMsg, "Error: Record Failed.\nFile open error : %s", mAviFilePath);
ImGui::OpenPopup("ErrorVCPopup");
}
}
}
}
Expand Down Expand Up @@ -1370,21 +1376,31 @@ MLDX12App::ShowImageFileRWWindow(void) {
switch (et) {
case ET_PNG:
if (ImGui::Button("Write PNG Image ##RF0", ImVec2(256, 48))) {
hr = MLPngWrite(mImgFilePath, mWriteImg);

if (FAILED(hr)) {
sprintf_s(mErrorFileReadMsg, "Write Image Failed.\nFile Write error : %s", mImgFilePath);
if (PathFileExistsA(mImgFilePath)) {
sprintf_s(mErrorFileReadMsg, "Error: File exists.\nPlease input different file name. %s", mImgFilePath);
ImGui::OpenPopup("ErrorImageFileRWPopup");
} else {
hr = MLPngWrite(mImgFilePath, mWriteImg);

if (FAILED(hr)) {
sprintf_s(mErrorFileReadMsg, "Error: Write Image Failed.\nFile Write error : %s", mImgFilePath);
ImGui::OpenPopup("ErrorImageFileRWPopup");
}
}
}
break;
case ET_EXR:
if (ImGui::Button("Write EXR Image ##RF0", ImVec2(256, 48))) {
hr = mExrWriter.Write(mImgFilePath, mWriteImg);
if (PathFileExistsA(mImgFilePath)) {
sprintf_s(mErrorFileReadMsg, "Error: File exists.\nPlease input different file name. %s", mImgFilePath);

if (FAILED(hr)) {
sprintf_s(mErrorFileReadMsg, "Write Image Failed.\nFile Write error : %s", mImgFilePath);
ImGui::OpenPopup("ErrorImageFileRWPopup");
} else {
hr = mExrWriter.Write(mImgFilePath, mWriteImg);
if (FAILED(hr)) {
sprintf_s(mErrorFileReadMsg, "Error: Write Image Failed.\nFile Write error : %s", mImgFilePath);
ImGui::OpenPopup("ErrorImageFileRWPopup");
}
}
}
break;
Expand All @@ -1410,7 +1426,7 @@ MLDX12App::ShowImageFileRWWindow(void) {
}
mMutex.unlock();
if (hr < 0) {
sprintf_s(mErrorFileReadMsg, "Read Image Failed.\nFile open error : %s", mImgFilePath);
sprintf_s(mErrorFileReadMsg, "Error: Read Image Failed.\nFile open error : %s", mImgFilePath);
ImGui::OpenPopup("ErrorImageFileRWPopup");
} else {
mState = S_ImageViewing;
Expand Down Expand Up @@ -1449,12 +1465,12 @@ MLDX12App::UpdateImgTexture(void) {

mMutex.unlock();

int uploadTexIdx = !mRenderTexImgIdx;
int uploadTexIdx = !mTexImgIdx;
UploadImgToGpu(mRenderImg, mTexImg[uploadTexIdx],
(TextureEnum)(TCE_TEX_IMG0 + uploadTexIdx));

mRenderImg.DeleteData();
mRenderTexImgIdx = uploadTexIdx;
mTexImgIdx = uploadTexIdx;


return true;
Expand Down
3 changes: 1 addition & 2 deletions HDR10Capture2019/MLDX12App.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class MLDX12App : public MLDX12 {
/// 描画中テクスチャが0番の場合、アップロード用テクスチャは1番。
/// 描画中テクスチャが1番の場合、アップロード用テクスチャは0番。
/// </summary>
int mRenderTexImgIdx = 0;
int mTexImgIdx = 0;

/// <summary>
/// 使用中のmFenceValues[]要素番号。
Expand Down Expand Up @@ -163,7 +163,6 @@ class MLDX12App : public MLDX12 {
void SetDefaultImgTexture(void);
bool UpdateImgTexture(void);


void CreateTexture(ComPtr<ID3D12Resource>& tex, int texIdx, int w, int h, DXGI_FORMAT fmt, int pixelBytes, uint8_t* data);
void CreateImguiTexture(void);
void ImGuiCommands(void);
Expand Down
8 changes: 4 additions & 4 deletions HDR10Capture2019/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,0,1
PRODUCTVERSION 1,1,0,1
FILEVERSION 1,2,0,1
PRODUCTVERSION 1,2,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "TODO: <Company name>"
VALUE "FileDescription", "HDR10Capture"
VALUE "FileVersion", "1.1.0.1"
VALUE "FileVersion", "1.2.0.1"
VALUE "InternalName", "HDR10Capture"
VALUE "LegalCopyright", "Copyright (C) 2020"
VALUE "OriginalFilename", "HDR10Capture.exe"
VALUE "ProductName", "HDR10Capture"
VALUE "ProductVersion", "1.1.0.1"
VALUE "ProductVersion", "1.2.0.1"
END
END
BLOCK "VarFileInfo"
Expand Down
2 changes: 1 addition & 1 deletion HDR10Capture2019/imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void ImGui::StyleColorsDark(ImGuiStyle* dst)

colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.96f); //< original alpha == 0.94f
colors[ImGuiCol_ChildBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.00f);
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
Expand Down

0 comments on commit a1ff2c8

Please sign in to comment.