Skip to content

Commit

Permalink
Print errors and warnings to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
YourMJK committed Feb 2, 2024
1 parent 8e40d24 commit 617f4e5
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,11 @@ bool parseCutMerge(t_cutMerge* cutMerge) {
beg = timestampToMs(strBeg);
end = timestampToMs(strEnd);
if (beg == -1) {
std::printf("Timestamp %s is invalid\n", strBeg);
std::fprintf(stderr, "Timestamp %s is invalid\n", strBeg);
return false;
}
if (beg == -1) {
std::printf("Timestamp %s is invalid\n", strEnd);
std::fprintf(stderr, "Timestamp %s is invalid\n", strEnd);
return false;
}

Expand Down Expand Up @@ -523,7 +523,7 @@ bool ParseCMD(int32_t argc, char** argv, t_cmd& cmd) {
//backward compatibility
cmd.delay = (int32_t)std::round(atof(argv[3]) * MS_TO_PTS_MULT);
if (cmd.delay != 0) {
std::printf("Running in backwards-compatibility mode\n");
std::fprintf(stderr, "Running in backwards-compatibility mode\n");
return true;
}
}
Expand All @@ -537,7 +537,7 @@ bool ParseCMD(int32_t argc, char** argv, t_cmd& cmd) {
i += 2;

if (cmd.cutMerge.doCutMerge) {
std::printf("Delay parameter will NOT be applied to Cut&Merge\n");
std::fprintf(stderr, "Delay parameter will NOT be applied to Cut&Merge\n");
/*
for (int i = 0; i < cmd.cutMerge.section.size(); i++) {
cmd.cutMerge.section[i].begin += cmd.delay;
Expand Down Expand Up @@ -574,7 +574,7 @@ bool ParseCMD(int32_t argc, char** argv, t_cmd& cmd) {
cmd.delay = (int32_t)std::round(((double)cmd.delay * cmd.resync));

if (cmd.cutMerge.doCutMerge) {
std::printf("Resync parameter will NOT be applied to Cut&Merge\n");
std::fprintf(stderr, "Resync parameter will NOT be applied to Cut&Merge\n");
/*
for (int i = 0; i < cmd.cutMerge.section.size(); i++) {
cmd.cutMerge.section[i].begin *= cmd.resync;
Expand Down Expand Up @@ -679,7 +679,7 @@ bool ParseCMD(int32_t argc, char** argv, t_cmd& cmd) {
if (cmd.cutMerge.doCutMerge) {
if ( cmd.cutMerge.format == e_cutMergeFormat::vapoursynth
&& cmd.cutMerge.timeMode == e_cutMergeTimeMode::timestamp) {
std::printf("Compat mode VapourSynth cannot be used alongside timestamp time mode\n");
std::fprintf(stderr, "Compat mode VapourSynth cannot be used alongside timestamp time mode\n");

return false;
}
Expand Down Expand Up @@ -719,13 +719,13 @@ int main(int32_t argc, char** argv)


if (argc < 4) {
std::printf("%s", usageHelp);
std::fprintf(stderr, "%s", usageHelp);
return -1;
}
t_cmd cmd = {};

if (!ParseCMD(argc, argv, cmd)) {
std::printf("Error parsing input\r\n");
std::fprintf(stderr, "Error parsing input\n");
return -1;
}

Expand All @@ -740,12 +740,12 @@ int main(int32_t argc, char** argv)

FILE* input = std::fopen(argv[1], "rb");
if (input == nullptr) {
std::printf("Unable to open input file!");
std::fprintf(stderr, "Unable to open input file!\n");
return -1;
}
FILE* output = std::fopen(argv[2], "wb");
if (output == nullptr) {
std::printf("Unable to open output file!");
std::fprintf(stderr, "Unable to open output file!\n");
std::fclose(input);
return -1;
}
Expand Down Expand Up @@ -792,7 +792,7 @@ int main(int32_t argc, char** argv)
for (start = 0; start < size; start = start + HEADER_SIZE + header.dataLength) {
header = ReadHeader(&buffer[start]);
if (header.header != 0x5047) {
std::printf("Correct header not found at position %zd, abort!", start);
std::fprintf(stderr, "Correct header not found at position %zd, abort!\n", start);
std::fclose(input);
std::fclose(output);
return -1;
Expand Down Expand Up @@ -848,13 +848,13 @@ int main(int32_t argc, char** argv)

if (pcs.numCompositionObject > 1) {
t_timestamp timestamp = PTStoTimestamp(header.pts1);
std::printf("Multiple composition object at timestamp %lu:%02lu:%02lu.%03lu! Please Check!\r\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
std::fprintf(stderr, "Multiple composition object at timestamp %lu:%02lu:%02lu.%03lu! Please Check!\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
}

for (int i = 0; i < pcs.numCompositionObject; i++) {
if (pcs.compositionObject[i].objectCroppedFlag == 0x40) {
t_timestamp timestamp = PTStoTimestamp(header.pts1);
std::printf("Object Cropped Flag set at timestamp %lu:%02lu:%02lu.%03lu! Implement it!\r\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
std::fprintf(stderr, "Object Cropped Flag set at timestamp %lu:%02lu:%02lu.%03lu! Implement it!\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
}

if (cmd.crop.left > pcs.compositionObject[i].objectHorPos) {
Expand Down Expand Up @@ -909,7 +909,7 @@ int main(int32_t argc, char** argv)
WriteHeader(zeroHeader, &zeroBuffer[pos]);
pos += 13;

std::printf("Writing %d bytes as first display set\n", pos);
std::fprintf(stderr, "Writing %d bytes as first display set\n", pos);
std::fwrite(zeroBuffer, pos, 1, output);

//For Cut&Merge functionality we don't need to save the added segment as it
Expand All @@ -934,14 +934,14 @@ int main(int32_t argc, char** argv)
}
break;
case 0x17:
//std::printf("WDS\r\n");
//std::fprintf(stderr, "WDS\r\n");
fixPCS = false;
if (doMove || doCrop) {
wds = ReadWDS(&buffer[start + HEADER_SIZE]);

if (wds.numberOfWindows > 1) {
t_timestamp timestamp = PTStoTimestamp(header.pts1);
std::printf("Multiple windows at timestamp %lu:%02lu:%02lu.%03lu! Please Check!\r\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
std::fprintf(stderr, "Multiple windows at timestamp %lu:%02lu:%02lu.%03lu! Please Check!\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
}

if (doMove) {
Expand All @@ -963,7 +963,7 @@ int main(int32_t argc, char** argv)

if (object->objectCroppedFlag == 0x40) {
t_timestamp timestamp = PTStoTimestamp(header.pts1);
std::printf("Object Cropped Flag set at timestamp %lu:%02lu:%02lu.%03lu! Crop fields are not supported yet.\r\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
std::fprintf(stderr, "Object Cropped Flag set at timestamp %lu:%02lu:%02lu.%03lu! Crop fields are not supported yet.\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
/*
object->objCropHorPos += clampedDeltaX;
object->objCropVerPos += clampedDeltaY;
Expand All @@ -990,8 +990,8 @@ int main(int32_t argc, char** argv)
if (wndRect.width > screenRect.width
|| wndRect.height > screenRect.height) {
t_timestamp timestamp = PTStoTimestamp(header.pts1);
std::printf("Window is bigger then new screen area at timestamp %lu:%02lu:%02lu.%03lu\r\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
std::printf("Implement it!\r\n");
std::fprintf(stderr, "Window is bigger then new screen area at timestamp %lu:%02lu:%02lu.%03lu\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
std::fprintf(stderr, "Implement it!\n");
/*
pcs.width = wndRect.width;
pcs.height = wndRect.height;
Expand All @@ -1001,7 +1001,7 @@ int main(int32_t argc, char** argv)
else {
if (!rectIsContained(screenRect, wndRect)) {
t_timestamp timestamp = PTStoTimestamp(header.pts1);
std::printf("Window is outside new screen area at timestamp %lu:%02lu:%02lu.%03lu\r\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);
std::fprintf(stderr, "Window is outside new screen area at timestamp %lu:%02lu:%02lu.%03lu\n", timestamp.hh, timestamp.mm, timestamp.ss, timestamp.ms);

uint16_t wndRightPoint = wndRect.x + wndRect.width;
uint16_t screenRightPoint = screenRect.x + screenRect.width;
Expand All @@ -1016,7 +1016,7 @@ int main(int32_t argc, char** argv)
}

if (corrHor + corrVer != 0) {
std::printf("Please check\r\n");
std::fprintf(stderr, "Please check\n");
}
}
}
Expand Down

0 comments on commit 617f4e5

Please sign in to comment.