Skip to content

Commit 8f13028

Browse files
authored
Fix NvDec decoder stale state when cropping (#1165)
This commit address an issue where executing `test_nvdec_decode_crop_resize` before `test_nvdec_decode_h264_420p_crop` causes the latter to return wrong results due to bad state left behind. ~The fix involves modifying the `NvDecDecoderCore::reset()` method to properly clean up state, including resetting crop, target width and height, and source information to default values. This ensures that the thread-local cached decoder does not carry over stale parameters from previous test runs.~ Modifying the `NvDecDecoderCore` is more elaborated, so, for now, we disable cache if crop is provided. ~This commit also adds the stand alone test that would repro the issue without the patch.~ Moved to 7619393 as the test manifests a different issue. - w/o fix https://github.com/facebookresearch/spdl/actions/runs/19650268816 - w/ fix https://github.com/facebookresearch/spdl/actions/runs/19641739313 Closes #1159
1 parent 37bfdf7 commit 8f13028

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/spdl/io/_core.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,11 @@ def nvdec_decoder(
10391039
The old pattern of calling ``decoder.init()`` after ``nvdec_decoder()``
10401040
will be removed in a future version.
10411041
"""
1042+
# Force recreation if crop is provided, regardless of use_cache
1043+
crop_params = (crop_left, crop_top, crop_right, crop_bottom)
1044+
if any(param != 0 for param in crop_params):
1045+
use_cache = False
1046+
10421047
if use_cache:
10431048
decoder = _get_decoder()
10441049
decoder.reset()

0 commit comments

Comments
 (0)