Repository navigation
fix(rocDecode): check decode caps up front in video_decode_batch, stop fake passes, and fix TheRock link order and enable its tests - #561
Open
zichguan-amd wants to merge 3 commits into
Conversation
…p fake passes, and fix TheRock link order Query rocDecGetDecoderCaps for every input file on every GPU device the decoder threads use before creating any decoder. Files whose codec isn't supported (e.g. AV1 on gfx90a) are dropped from the batch; a failed query is an error. If no file is supported, exit with skip_exit_code (77), and report that as a skip in ctest (SKIP_RETURN_CODE) and make test. Also fail instead of exiting 0 when the input directory is empty, when no frames were decoded, and when an exception is caught, matching upstream rocm-systems#8636. On TheRock installs, CMake placed the FFmpeg libraries ahead of librocdecode on the link line (rocdecode::rocdecode is an INTERFACE target), so the system libva won symbol interposition over rocDecode's vendored one and vaInitialize failed. Add link_rocdecode_first() in cmake/RocDecodeLinkOrder.cmake, the same workaround as upstream rocm-systems#8869, and call it in the rocDecode examples that link FFmpeg. Co-Authored-By: Claude <noreply@anthropic.com>
The tests of video_decode, video_decode_batch, video_decode_mem, video_decode_perf and video_decode_rgb were disabled on TheRock installs by a gate copied from rocm-systems#3768. With the link order fixed, they pass there, and upstream rocDecode runs them on TheRock again since rocm-systems#8869. Remove the gates. As upstream does, the rocdecode-host backend test still doesn't run on TheRock. Co-Authored-By: Claude <noreply@anthropic.com>
Open
1 task done
VideoDemuxer doesn't throw when it can't open a file or find a video stream; it leaves the bit depth at 0 and the codec ID unset. The capability check then read the unset codec ID and reported such a file as an unsupported codec, so a non-video file in the input directory was skipped (exit 77, or exit 0 next to valid files). Report it as an error. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
GPU doesn't support codec!rocm-systems#13446: upstreamvideo_decodeBatchstill fails on gfx90a (MI210) after #13518. The batch test decodes the whole rocDecode test-video directory, which includes two AV1 files, and gfx90a has no AV1 decode. The agreed redesign: 1) check the decode capability first, and 2) decode only the supported files. This PR applies that design to the rocm-examples port.video_decode_batchexits 0 even when it decodes nothing:RocVideoDecoder::CodecSupported(), which returnsfalseboth for an unsupported codec and for a failedrocDecGetDecoderCapsquery. A broken VA-API setup therefore looks like "every codec unsupported":Total frame decoded: 0, exit 0.mainis printed, and the example still returns 0.vaInitializethen fails androcDecGetDecoderCapsreturnsROCDEC_RUNTIME_ERROR(reproduced withvideo_decode_batch;rocdec_decodefails the same way only if forced to link FFmpeg, which it doesn't do on TheRock). The Makefile builds are unaffected. CI always installs TheRock, so it doesn't catch this: these examples' ctests are disabled on TheRock by a gate copied from rocm-systems#3768, andmake testruns the Makefile builds. With the oldvideo_decode_batchthis showed up asTotal frame decoded: 0, exit 0.Technical Details
Libraries/rocDecode/video_decode_batch/main.cpp:rocDecGetDecoderCapsdirectly on every GPU device the decoder threads use. This is the same per-thread device mapping as before, now in adec_device_id(i)lambda that is shared with the thread setup.ROCDEC_SUCCESSwithis_supported == 0): the file is dropped from the batch withinfo: skipping <file>, its codec isn't supported on the GPU.Error: rocDecGetDecoderCaps failed for <file>: <status>, exit 1.skip_exit_code(77,Common/example_utils.hpp), asvideo_decodeandvideo_decode_rawalready do since feat(rocDecode): add video_decode_caps example and skip unsupported codecs #550.CodecSupported()check in the dispatch loop is removed.Error: Failed to open <file> as a video file.n_total == 0is an error:Error: No frames were decoded!.catchblock returns 1.CMakeLists.txt:SKIP_RETURN_CODE 77on the test.Makefile:make testprints==> Skipping (no codec supported on this GPU): ...on exit 77 instead of failing, matchingvideo_decode_raw.README.md: Application Flow updated, androcDecGetDecoderCapsadded to the API list.New
cmake/RocDecodeLinkOrder.cmake, the TheRock link-order fix:lib/rocm_sysdeps/lib, while FFmpeg links the system libva, so both load.rocdecode::rocdecodeis an INTERFACE target, so CMake puts${FFMPEG_LIBRARIES}ahead of librocdecode on the link line.libavcodecbecomes the firstNEEDEDentry.vaInitializefails.-lrocdecodebefore FFmpeg and work.link_rocdecode_first(<target>)links${rocdecode_LIBRARY}as a raw path (-Wl,--push-state,--no-as-needed ... -Wl,--pop-state) ahead of the other libraries, on TheRock installs only.video_decode,video_decode_batch,video_decode_mem,video_decode_multi_files,video_decode_perf,video_decode_pic_files,video_decode_rgbandvideo_to_sequence.rocdec_decodeonly links FFmpeg on non-TheRock installs, so it is unchanged.TheRock test gates removed, synced with upstream rocDecode tests:
if (NOT USING_THE_ROCK)blocks around the tests ofvideo_decode,video_decode_batch,video_decode_mem,video_decode_perfandvideo_decode_rgbare removed, so these tests now run on TheRock too. They still skip when the test video isn't installed.video_decode-HEVC-host(rocdecode-host backend) still doesn't run on TheRock.video_decodealready reports-AV1as skipped (exit 77) on GPUs without AV1 decode.Upstream counterpart (rocm-systems
samples/videoDecodeBatch): ROCm/rocm-systems#14383 applies the same design upstream for ROCm/rocm-systems#13446.Test Plan
On gfx1100 (RX 7900 XTX) in
ghcr.io/rocm/rocm-examples-ubuntu-24.04-rocm:10.1(TheRock install, rocDecode 1.10.0):makeandmake test.Libraries/rocDecode:ctestwith no preload, and the firstNEEDEDentry of each binary.link_rocdecode_first()disabled, for comparison.LD_PRELOADshim onrocDecGetDecoderCaps, in three modes:is_supportedfor AV1, to simulate gfx90aROCDEC_RUNTIME_ERROR-t 1/2/4,-m 0 -o <dir>,HIP_VISIBLE_DEVICES=0, and an empty input directory.pre-commiton the changed files.Test Result
-t 1/4andHIP_VISIBLE_DEVICES=0)make testskip lineError: rocDecGetDecoderCaps failed ..., exit 1: ctest Failed,make testfailsError: No input files found ..., exit 1Error: Failed to open ... as a video file, exit 1librocdecode.so.1as their firstNEEDEDentry.rocdec_decode,video_decode_caps,video_decode_raw-*,video_decode-*,video_decode_batch,video_decode_mem,video_decode_perfandvideo_decode_rgb[-resize].video_decode-AV1is Skipped andvideo_decode_batchpasses.link_rocdecode_first(), the 9 newly enabled tests fail (video_decode_perfsegfaults).video_decode_batchfailsvaInitializeand reports 0 frames, exit 0.-m 0 -o, output files are written only for the decoded files.main.cpp.pre-commitpasses.Added/Updated documentation?
Included Visual Studio files?
Submission Checklist
🤖 Generated with Claude Code