MCPcopy Create free account
hub / github.com/CVCUDA/CV-CUDA / generate_decoded_frames

Method generate_decoded_frames

bench/python/nvcodec_utils.py:188–200  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

186
187 # frame iterator
188 def generate_decoded_frames(self):
189 for packet in self.nvDemux:
190 for decodedFrame in self.nvDec.Decode(packet):
191 cvcudaTensor = cvcuda.as_tensor(
192 cvcuda.as_image(decodedFrame.nvcv_image(), cvcuda.Format.U8)
193 )
194 if cvcudaTensor.layout == "NCHW":
195 # This will re-format the NCHW tensor to a NHWC tensor which will create
196 # a copy in the CUDA device decoded frame will go out of scope and the
197 # backing memory will be available by the decoder.
198 yield cvcuda.reformat(cvcudaTensor, "NHWC")
199 else:
200 raise ValueError("Unexpected tensor layout, NCHW expected.")
201
202 def get_next_frames(self, N):
203 decoded_frames = list(itertools.islice(self.generate_decoded_frames(), N))

Callers 1

get_next_framesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected