Library version: PyNvVideoCodec 2.1.0 (pip, pynvvideocodec==2.1.0)
Bug:
SimpleDecoder.__getitem__ calls self.validate_index(key.stop) on the exclusive stop of a Python slice. This raises IndexError when stop == len(decoder), which is the normal Python convention for "all remaining elements."
Location: SimpleDecoder.py, lines 88–94
elif isinstance(key, slice):
indices = range(key.start, key.stop, key.step) # stop is exclusive here ✓
idxs = list(iter(indices))
if not idxs:
raise ValueError(f"Invalid input.")
self.validate_index(key.start)
self.validate_index(key.stop) # ← BUG: validates exclusive stop as if inclusive
return self.simple_decoder[idxs]
Reproduce:
import PyNvVideoCodec as nvc
dec = nvc.SimpleDecoder("any_video.mp4", output_color_type=nvc.OutputColorType.RGB)
n = len(dec) # e.g. 107
frames = dec[0:n:1] # IndexError: Index 107 is out of range [0, 106]
Expected: dec[0:n:1] should return all n frames, consistent with standard Python slice semantics where stop is exclusive.
Fix:
self.validate_index(key.stop - 1). Also, I'd probably move the self.validate(key.start) and self.validate(key.stop) before the whole range to list to reduce unnecessary computation before you know the range is safe.
Library version: PyNvVideoCodec 2.1.0 (pip, pynvvideocodec==2.1.0)
Bug:
SimpleDecoder.__getitem__callsself.validate_index(key.stop)on the exclusive stop of a Python slice. This raisesIndexErrorwhenstop == len(decoder), which is the normal Python convention for "all remaining elements."Location:
SimpleDecoder.py, lines 88–94Reproduce:
Expected:
dec[0:n:1]should return allnframes, consistent with standard Python slice semantics wherestopis exclusive.Fix:
self.validate_index(key.stop - 1). Also, I'd probably move theself.validate(key.start)andself.validate(key.stop)before the whole range to list to reduce unnecessary computation before you know the range is safe.