Skip to content

Commit f96264b

Browse files
committed
slightly simplify
1 parent 82db435 commit f96264b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/torchcodec/_core/BetaCudaDeviceInterface.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ bool nativeNVDECSupport(const SharedAVCodecContext& codecContext) {
187187

188188
auto coded_width = static_cast<unsigned int>(codecContext->coded_width);
189189
auto coded_height = static_cast<unsigned int>(codecContext->coded_height);
190-
if (!(coded_width >= static_cast<unsigned int>(caps.nMinWidth) &&
191-
coded_height >= static_cast<unsigned int>(caps.nMinHeight) &&
192-
coded_width <= caps.nMaxWidth && coded_height <= caps.nMaxHeight)) {
190+
if (coded_width < static_cast<unsigned int>(caps.nMinWidth) ||
191+
coded_height < static_cast<unsigned int>(caps.nMinHeight) ||
192+
coded_width > caps.nMaxWidth || coded_height > caps.nMaxHeight) {
193193
return false;
194194
}
195195

196196
// See nMaxMBCount in cuviddec.h
197197
constexpr unsigned int macroblockConstant = 256;
198-
if (!(coded_width * coded_height / macroblockConstant <= caps.nMaxMBCount)) {
198+
if (coded_width * coded_height / macroblockConstant > caps.nMaxMBCount) {
199199
return false;
200200
}
201201

@@ -204,7 +204,9 @@ bool nativeNVDECSupport(const SharedAVCodecContext& codecContext) {
204204
// TODO: If this fail, we could consider decoding to something else than NV12
205205
// (like cudaVideoSurfaceFormat_P016) instead of falling back to CPU. This is
206206
// what FFmpeg does.
207-
if (!((caps.nOutputFormatMask >> cudaVideoSurfaceFormat_NV12) & 1)) {
207+
bool supportsNV12Output =
208+
(caps.nOutputFormatMask >> cudaVideoSurfaceFormat_NV12) & 1;
209+
if (!supportsNV12Output) {
208210
return false;
209211
}
210212

0 commit comments

Comments
 (0)