Commit 7faadad
{CUDA Decoding} Add NvCodecConfig.h, migrate WITH_NVCODEC guards to XPRS_HAS_NVDEC/XPRS_HAS_NVENC (#259)
Summary:
Pull Request resolved: #259
This is D1b in the GPU-accelerated H.265 decoding stack for projectaria-tools (plan v11 at ~/gdrive/plans/2026-04-03-gpu-accelerated-h265-decoding-pat-v11.md, tech design at https://docs.google.com/document/d/1TMeLy0TqvAdlYo0IY3Qm4BrzE8i035z9MzYvGl_CzeM/edit by Lou Yang).
Refactor only — no behavior change. Replaces 22 in-source `#ifdef WITH_NVCODEC` directives with self-documenting `XPRS_HAS_NVDEC` (decoder side) and `XPRS_HAS_NVENC` (encoder side) macros, defined by a new `NvCodecConfig.h` single-source-of-truth header. Build-system flags (`-DWITH_NVCODEC=1` in BUCK and CMake) remain as the upstream input.
Why split the macro: today both halves are gated together (`WITH_NVCODEC` is set or unset for both encoder and decoder). The split prepares for build configurations that ship only one half — most importantly the OSS PyPI wheel will want NVDEC without NVENC, since PyPI users typically want decode acceleration but the encode path requires hardware NVIDIA explicitly doesn't support across all SKUs (e.g., A100 has NVDEC but no NVENC). At the call site, `#ifdef XPRS_HAS_NVDEC` makes the intent clear in a way that `#ifdef WITH_NVCODEC` does not.
Files changed:
NEW arvr/projects/compression/xprs/NvCodecConfig.h — defines XPRS_HAS_NVDEC + XPRS_HAS_NVENC under WITH_NVCODEC, with explanatory comment.
arvr/projects/compression/xprs/Codecs.h — removed `#include "nvEncoder.h"` (its only consumers — xprsEncApi.cpp, xprsEncoder.cpp, xprs_gtest_common.h — already include nvEncoder.h directly). Adds an explanatory comment so the next reader doesn't re-add it.
arvr/projects/compression/xprs/xprsDecApi.cpp — added `#include "NvCodecConfig.h"`, replaced 4× `WITH_NVCODEC` with `XPRS_HAS_NVDEC`.
arvr/projects/compression/xprs/xprsDecoder.h — added include, swapped the nvDecoder.h gate to XPRS_HAS_NVDEC.
arvr/projects/compression/xprs/xprsDecoder.cpp — added include, consolidated two redundant adjacent `#ifdef WITH_NVCODEC` blocks (one wrapping `cudaContextProvider.h`, one wrapping `Codecs.h` — Codecs.h was unconditionally needed and didn't actually need a guard), used XPRS_HAS_NVDEC.
arvr/projects/compression/xprs/xprsEncApi.cpp — added include, replaced 6× `WITH_NVCODEC` with `XPRS_HAS_NVENC`, updated TODO comment to reference the new macro.
arvr/projects/compression/xprs/xprsEncoder.cpp — added include, replaced 2× `WITH_NVCODEC` with `XPRS_HAS_NVENC`.
arvr/projects/compression/xprs/test/xprs_gtest_codec.cpp — added include, replaced 1× `WITH_NVCODEC` with `XPRS_HAS_NVENC` (test exercises NV encoders by name).
arvr/projects/compression/xprs/test/xprs_gtest_common.h — added include, replaced 2× `WITH_NVCODEC` with `XPRS_HAS_NVENC`.
arvr/projects/compression/xprs/BUCK — added `NvCodecConfig.h` to `SUPPORTED_PLATFORMS_HEADERS` so it's exposed to consumers.
NOT changed (out of scope):
arvr/projects/compression/xprs/CMakeLists.txt — has the existing `target_compile_options` instead of `target_compile_definitions` bug for ENABLE_NVCODEC; D2 fixes this.
arvr/projects/compression/xprs/BUCK line 209 (`-DWITH_NVCODEC=1`) and the test BUCK / helpers.bzl equivalents — these are intentionally still WITH_NVCODEC since they pass the upstream flag that NvCodecConfig.h reads.
arvr/projects/oatmeal/acro_conversion/test/BUCK (`-DWITH_NVCODEC=1`) — out-of-tree consumer, unchanged.
Reviewed By: PiotrBrzyski
Differential Revision: D103253723
fbshipit-source-id: b6a18ba251d66859f40ac4f4dfa6d7d81d55fb151 parent 5e68695 commit 7faadad
5 files changed
Lines changed: 51 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
| 120 | + | |
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
| |||
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
171 | | - | |
| 172 | + | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 22 | + | |
26 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
0 commit comments