From 577d1e842d4b18feff41f192090f7fdd59d9b8b1 Mon Sep 17 00:00:00 2001 From: Kiriti Gowda Date: Tue, 18 Nov 2025 22:06:46 -0800 Subject: [PATCH] Tests and samples - Bugfix (#673) * Tests and samples - bugfixes * CMakeLists - add CMAKE_MODULE_PATH * Fix header - Host * Host - decouple * Host Utils - Reset * Test - enable advanced test with host lib [ROCm/rocdecode commit: a1b958335308b0ed00674edb35f03191fa021cf4] --- .../samples/videoDecode/videodecode.cpp | 3 + .../videoDecodePerf/videodecodeperf.cpp | 3 + .../videodecodepicfiles.cpp | 7 +- projects/rocdecode/test/CMakeLists.txt | 266 +++++++++--------- 4 files changed, 147 insertions(+), 132 deletions(-) diff --git a/projects/rocdecode/samples/videoDecode/videodecode.cpp b/projects/rocdecode/samples/videoDecode/videodecode.cpp index 9cfff7f7fe..42da6010f5 100644 --- a/projects/rocdecode/samples/videoDecode/videodecode.cpp +++ b/projects/rocdecode/samples/videoDecode/videodecode.cpp @@ -41,6 +41,9 @@ THE SOFTWARE. #include "roc_video_dec.h" #include "ffmpeg_video_dec.h" #include "common.h" +#if ENABLE_HOST_DECODE + #include "rocdecode/rocdecode_host.h" +#endif //hardcoding for host based decoder creation if demux is not available #define DEFAULT_WIDTH 2912 diff --git a/projects/rocdecode/samples/videoDecodePerf/videodecodeperf.cpp b/projects/rocdecode/samples/videoDecodePerf/videodecodeperf.cpp index d789f2ee47..91ee49429c 100644 --- a/projects/rocdecode/samples/videoDecodePerf/videodecodeperf.cpp +++ b/projects/rocdecode/samples/videoDecodePerf/videodecodeperf.cpp @@ -37,6 +37,9 @@ THE SOFTWARE. #include "roc_video_dec.h" #include "ffmpeg_video_dec.h" #include "common.h" +#if ENABLE_HOST_DECODE + #include "rocdecode/rocdecode_host.h" +#endif void DecProc(RocVideoDecoder *p_dec, VideoDemuxer *demuxer, int *pn_frame, int *pn_pic_dec, double *pn_fps, double *pn_fps_dec, int max_num_frames, OutputSurfaceMemoryType mem_type) { int n_video_bytes = 0, n_frame_returned = 0, n_frame = 0; diff --git a/projects/rocdecode/samples/videoDecodePicFiles/videodecodepicfiles.cpp b/projects/rocdecode/samples/videoDecodePicFiles/videodecodepicfiles.cpp index 53db80c91c..03435fecce 100644 --- a/projects/rocdecode/samples/videoDecodePicFiles/videodecodepicfiles.cpp +++ b/projects/rocdecode/samples/videoDecodePicFiles/videodecodepicfiles.cpp @@ -36,6 +36,9 @@ THE SOFTWARE. #include "roc_video_dec.h" #include "ffmpeg_video_dec.h" #include "common.h" +#if ENABLE_HOST_DECODE + #include "rocdecode/rocdecode_host.h" +#endif void ShowHelpAndExit(const char *option = NULL) { std::cout << "Options:" << std::endl @@ -387,8 +390,8 @@ int main(int argc, char **argv) { delete md5_generator; } } catch (const std::exception &ex) { - std::cout << ex.what() << std::endl; - exit(1); + std::cout << ex.what() << std::endl; + exit(1); } return 0; diff --git a/projects/rocdecode/test/CMakeLists.txt b/projects/rocdecode/test/CMakeLists.txt index d6a51c6cbb..a3dbea2727 100644 --- a/projects/rocdecode/test/CMakeLists.txt +++ b/projects/rocdecode/test/CMakeLists.txt @@ -56,6 +56,7 @@ include(CTest) # add ROCm find Config location list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/lib/cmake) +list(APPEND CMAKE_MODULE_PATH ${ROCM_PATH}/share/rocdecode/cmake) # find rocdecode if(BUILD_FROM_SOURCE) @@ -90,165 +91,61 @@ else() message("-- ${Yellow}${PROJECT_NAME} requires rocdecode-host. Install rocdecode-host before running CTests") endif(rocdecode-host_FOUND) endif(BUILD_FROM_SOURCE) +find_package(FFmpeg QUIET) -# 1 - videoDecode HEVC -add_test( - NAME - video_decode-HEVC - COMMAND - "${CMAKE_CTEST_COMMAND}" - --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecode" - --build-generator "${CMAKE_GENERATOR}" - --test-command "videodecode" - -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 -) - -# 2 - videoDecode AVC -add_test( - NAME - video_decode-AVC - COMMAND - "${CMAKE_CTEST_COMMAND}" - --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecode" - --build-generator "${CMAKE_GENERATOR}" - --test-command "videodecode" - -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H264.mp4 -) - -# 3 - videoDecode AV1 -add_test( - NAME - video_decode-AV1 - COMMAND - "${CMAKE_CTEST_COMMAND}" - --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecode" - --build-generator "${CMAKE_GENERATOR}" - --test-command "videodecode" - -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-AV1.mp4 -) - -# 4 - videoDecode VP9 -add_test( - NAME - video_decode-VP9 - COMMAND - "${CMAKE_CTEST_COMMAND}" - --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecode" - --build-generator "${CMAKE_GENERATOR}" - --test-command "videodecode" - -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-VP9.ivf -) - -# 5 - videoDecodePerf -add_test( - NAME - video_decodePerf-HEVC - COMMAND - "${CMAKE_CTEST_COMMAND}" - --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodePerf" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecodePerf" - --build-generator "${CMAKE_GENERATOR}" - --test-command "videodecodeperf" - -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 -) - -# 6 - videoDecodeBatch -add_test( - NAME - video_decodeBatch - COMMAND - "${CMAKE_CTEST_COMMAND}" - --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeBatch" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeBatch" - --build-generator "${CMAKE_GENERATOR}" - --test-command "videodecodebatch" - -i ${ROCM_PATH}/share/rocdecode/video/ -t 2 -) - -# 7 - videoDecodeRGB -add_test( - NAME - video_decodeRGB-HEVC - COMMAND - "${CMAKE_CTEST_COMMAND}" - --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeRGB" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRGB" - --build-generator "${CMAKE_GENERATOR}" - --test-command "videodecodergb" - -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 -of rgb -) - - -# 8 - videoDecodeMem -add_test( - NAME - video_decodeMem-HEVC - COMMAND - "${CMAKE_CTEST_COMMAND}" - --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeMem" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeMem" - --build-generator "${CMAKE_GENERATOR}" - --test-command "videodecodemem" - -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 -) - -# 9 - videoDecodeRaw HEVC +# 1 - videoDecodeRaw HEVC add_test( NAME video_decodeRaw-HEVC COMMAND "${CMAKE_CTEST_COMMAND}" --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeRaw" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRaw" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRaw-HEVC" --build-generator "${CMAKE_GENERATOR}" --test-command "videodecoderaw" -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.265 ) -# 10 - videoDecodeRaw AVC +# 2 - videoDecodeRaw AVC add_test( NAME video_decodeRaw-AVC COMMAND "${CMAKE_CTEST_COMMAND}" --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeRaw" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRaw" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRaw-AVC" --build-generator "${CMAKE_GENERATOR}" --test-command "videodecoderaw" -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H264.264 ) -# 11 - videoDecodeRaw AV1 +# 3 - videoDecodeRaw AV1 add_test( NAME video_decodeRaw-AV1 COMMAND "${CMAKE_CTEST_COMMAND}" --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeRaw" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRaw" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRaw-AV1" --build-generator "${CMAKE_GENERATOR}" --test-command "videodecoderaw" -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-AV1.ivf ) -# 12 - videoDecodeRaw VP9 +# 4 - videoDecodeRaw VP9 add_test( NAME video_decodeRaw-VP9 COMMAND "${CMAKE_CTEST_COMMAND}" --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeRaw" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRaw" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRaw-VP9" --build-generator "${CMAKE_GENERATOR}" --test-command "videodecoderaw" -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-VP9.ivf ) -# 13 - rocDecodeNegativeApiTests +# 5 - rocDecodeNegativeApiTests add_test( NAME rocDecode_Negative_API_Tests @@ -260,29 +157,138 @@ add_test( --test-command "rocdecodenegativetest" ) -# 14 - videoDecodeRGBResize -add_test( - NAME - video_decodeRGB-Resize - COMMAND - "${CMAKE_CTEST_COMMAND}" +if(FFMPEG_FOUND AND rocdecode-host_FOUND) + message("-- ${Green}${PROJECT_NAME} FFmpeg found - rocdecode tests requiring FFmpeg added") + # 6 - videoDecode HEVC + add_test( + NAME + video_decode-HEVC + COMMAND + "${CMAKE_CTEST_COMMAND}" + --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecode-HEVC" + --build-generator "${CMAKE_GENERATOR}" + --test-command "videodecode" + -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 + ) + + # 7 - videoDecode AVC + add_test( + NAME + video_decode-AVC + COMMAND + "${CMAKE_CTEST_COMMAND}" + --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecode-AVC" + --build-generator "${CMAKE_GENERATOR}" + --test-command "videodecode" + -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H264.mp4 + ) + + # 8 - videoDecode AV1 + add_test( + NAME + video_decode-AV1 + COMMAND + "${CMAKE_CTEST_COMMAND}" + --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecode-AV1" + --build-generator "${CMAKE_GENERATOR}" + --test-command "videodecode" + -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-AV1.mp4 + ) + + # 9 - videoDecode VP9 + add_test( + NAME + video_decode-VP9 + COMMAND + "${CMAKE_CTEST_COMMAND}" + --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecode-VP9" + --build-generator "${CMAKE_GENERATOR}" + --test-command "videodecode" + -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-VP9.ivf + ) + + # 10 - videoDecodePerf + add_test( + NAME + video_decodePerf-HEVC + COMMAND + "${CMAKE_CTEST_COMMAND}" + --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodePerf" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecodePerf" + --build-generator "${CMAKE_GENERATOR}" + --test-command "videodecodeperf" + -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 + ) + + # 11 - videoDecodeBatch + add_test( + NAME + video_decodeBatch + COMMAND + "${CMAKE_CTEST_COMMAND}" + --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeBatch" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeBatch" + --build-generator "${CMAKE_GENERATOR}" + --test-command "videodecodebatch" + -i ${ROCM_PATH}/share/rocdecode/video/ -t 2 + ) + + # 12 - videoDecodeRGB + add_test( + NAME + video_decodeRGB-HEVC + COMMAND + "${CMAKE_CTEST_COMMAND}" --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeRGB" "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRGB" --build-generator "${CMAKE_GENERATOR}" --test-command "videodecodergb" - -i "${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4" -resize 640x360 -of rgb -) + -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 -of rgb + ) -# 15 - videoDecode Host backend -add_test( - NAME - video_decode-Host-Backend - COMMAND - "${CMAKE_CTEST_COMMAND}" + # 13 - videoDecodeMem + add_test( + NAME + video_decodeMem-HEVC + COMMAND + "${CMAKE_CTEST_COMMAND}" + --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeMem" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeMem" + --build-generator "${CMAKE_GENERATOR}" + --test-command "videodecodemem" + -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 + ) + + # 14 - videoDecodeRGBResize + add_test( + NAME + video_decodeRGB-Resize + COMMAND + "${CMAKE_CTEST_COMMAND}" + --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecodeRGB" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecodeRGB-Resize" + --build-generator "${CMAKE_GENERATOR}" + --test-command "videodecodergb" + -i "${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4" -resize 640x360 -of rgb + ) + + # 15 - videoDecode Host backend + add_test( + NAME + video_decode-Host-Backend + COMMAND + "${CMAKE_CTEST_COMMAND}" --build-and-test "${ROCM_PATH}/share/rocdecode/samples/videoDecode" - "${CMAKE_CURRENT_BINARY_DIR}/videoDecode" + "${CMAKE_CURRENT_BINARY_DIR}/videoDecode-Host" --build-generator "${CMAKE_GENERATOR}" --test-command "videodecode" -i ${ROCM_PATH}/share/rocdecode/video/AMD_driving_virtual_20-H265.mp4 -backend 1 -) + ) +else() + message("-- ${Yellow}${PROJECT_NAME} FFmpeg and rocdecode-host NOT found. rocdecode tests requiring FFmpeg and rocdecode-host excluded") +endif(FFMPEG_FOUND AND rocdecode-host_FOUND)