Skip to content

Commit eb3b779

Browse files
committed
postprocessor: run channel_remap even if kernel==0
If output was planar and copied directly, the channel remap was not performed (early return). + create the macro from the common feature_check/action/check procedure
1 parent dc2f3e7 commit eb3b779

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/gpujpeg_postprocessor.cu

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -432,18 +432,23 @@ gpujpeg_preprocessor_decoder_copy_planar_data(struct gpujpeg_coder * coder, cuda
432432
return 0;
433433
}
434434

435+
#define PERFORM_IF_ENABLED_CHECK(cond, command) \
436+
if ( cond ) { \
437+
const int ret = command; \
438+
if ( ret != 0 ) { \
439+
return ret; \
440+
} \
441+
}
442+
435443
/* Documented at declaration */
436444
int
437445
gpujpeg_postprocessor_decode(struct gpujpeg_coder* coder, cudaStream_t stream)
438446
{
439-
if ( coder->preprocessor.flipped ) {
440-
int ret = gpujpeg_preprocessor_flip_lines(coder, stream);
441-
if ( ret != 0 ) {
442-
return ret;
443-
}
444-
}
447+
PERFORM_IF_ENABLED_CHECK(coder->preprocessor.flipped, gpujpeg_preprocessor_flip_lines(coder, stream));
445448

446449
if ( coder->preprocessor.kernel == nullptr ) {
450+
PERFORM_IF_ENABLED_CHECK(coder->preprocessor.channel_remap != 0,
451+
gpujpeg_preprocessor_channel_remap(coder, stream));
447452
return gpujpeg_preprocessor_decoder_copy_planar_data(coder, stream);
448453
}
449454

@@ -486,12 +491,7 @@ gpujpeg_postprocessor_decode(struct gpujpeg_coder* coder, cudaStream_t stream)
486491
);
487492
gpujpeg_cuda_check_error("Preprocessor encoding failed", return -1);
488493

489-
if ( coder->preprocessor.channel_remap != 0 ) {
490-
const int ret = gpujpeg_preprocessor_channel_remap(coder, stream);
491-
if ( ret != 0 ) {
492-
return ret;
493-
}
494-
}
494+
PERFORM_IF_ENABLED_CHECK(coder->preprocessor.channel_remap != 0, gpujpeg_preprocessor_channel_remap(coder, stream));
495495

496496
return 0;
497497
}

0 commit comments

Comments
 (0)