Skip to content

Commit 4ebee82

Browse files
committed
updated logic according to Larry's feedback
Signed-off-by: Lydia Zheng <[email protected]>
1 parent 9bf4627 commit 4ebee82

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/oiiotool/expressions.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,29 +320,26 @@ Oiiotool::express_parse_atom(const string_view expr, string_view& s,
320320

321321
} else if (metadata == "IS_CONSTANT") {
322322
std::vector<float> color((*img)(0, 0).nchannels());
323-
if (ImageBufAlgo::isConstantColor((*img)(0, 0), color)) {
323+
if (ImageBufAlgo::isConstantColor((*img)(0, 0), 0.0f, color)) {
324324
result = "1";
325325
} else {
326326
result = "0";
327327
}
328328

329329

330330
} else if (metadata == "IS_BLACK") {
331-
auto pixstat = ImageBufAlgo::computePixelStats((*img)(0, 0));
332331
std::vector<float> color((*img)(0, 0).nchannels());
333332
// Check constant first to guard against false positive average of 0 with negative values i.e. -2, 1, 1
334-
if (ImageBufAlgo::isConstantColor((*img)(0, 0), color)) {
335-
// Do we need this loop if we know that all channels should be the same value in constant frame?
336-
for (size_t i = 0; i < pixstat.avg.size(); ++i) {
337-
// If any of the pixel doesn't have an average of (0,0,0), then we don't have a black frame
338-
// Is this the best way to check? Feels fishy to have the specified number...should we look at 0.0f or other formats?
339-
if (pixstat.avg[i] == 0.000000) {
340-
result = "1";
341-
} else {
342-
result = "0";
343-
}
333+
if (ImageBufAlgo::isConstantColor((*img)(0, 0), 0.0f, color)) {
334+
// trusting that the constantcolor check means all channels have the same value, so we only check the first channel
335+
if (color[0] == 0.0f) {
336+
result = "1";
337+
}
338+
else {
339+
result = "0";
344340
}
345341
} else {
342+
// Not even constant color case -> We don't want those to count as black frames.
346343
result = "0";
347344
}
348345

0 commit comments

Comments
 (0)