Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/argparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ void ArgParse::printHelp()

}
}

std::exit(0);
}

void ArgParse::parse()
Expand Down
20 changes: 18 additions & 2 deletions src/braw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ Braw::Braw()

Braw::~Braw()
{
codec->FlushJobs();
if (codec) {
codec->FlushJobs();
}

if (clip != nullptr)
clip->Release();
Expand All @@ -136,9 +138,23 @@ void Braw::openFile(std::string filepath)

// Setup BRAW SDK
factory = CreateBlackmagicRawFactoryInstanceFromPath(lib);
if (factory == nullptr) {
throw std::runtime_error("Failed to initialize BRAW SDK");
}
factory->CreateCodec(&codec);
const char *c = info->filename.c_str();
codec->OpenClip(c, &clip);
HRESULT hr = codec->OpenClip(c, &clip);
if (hr == E_INVALIDARG) {
throw std::runtime_error("Invalid filename: " + filepath);
}
if (hr == E_FAIL) {
throw std::runtime_error("Failed to open clip. File might be corrupt");
}
if (hr != S_OK) {
std::stringstream ss;
ss << "Internal Braw error. HRESULT=" << hr;
throw std::runtime_error(ss.str());
}
codec->SetCallback(&frameProcessor);

clip->GetFrameCount(&(info->frameCount));
Expand Down
14 changes: 12 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void test_func()
void help()
{
args->printHelp();
std::exit(0);
}


Expand All @@ -30,13 +31,22 @@ int main(int argc, char *argv[])
std::vector<std::string> files = args->getArgsRemaining();
if(files.size() == 1)
{
braw_decoder.openFile(files[0]);
}else{
try {
braw_decoder.openFile(files[0]);
} catch (std::exception& e) {
std::cerr << "ERROR: " << e.what() << std::endl;
return 1;
}
} else if (files.size() == 0) {
std::cerr << "Missing input file argument" << std::endl;
return 1;
} else {
std::cerr << "Too many files provided" << std::endl;
for(int i = 0; i != files.size(); ++i)
{
std::cerr << "[" << i << "] " << files[i] << std::endl;
}
return 1;
}

return 0;
Expand Down