MCPcopy
hub / github.com/tinygrad/tinygrad / decode_hevc_frame

Method decode_hevc_frame

tinygrad/tensor.py:1319–1330  ·  view source on GitHub ↗

Creates a Tensor by decoding an HEVC frame chunk. You must provide the output shape of the decoded data (`shape`), the HEVC context (`vstate`), and, if required by the chunk, the reference frames (`ref_frames`).

(self, frame_pos:Variable, shape:tuple[int,...], state:Tensor, ref_frames:list[Tensor]|None=None)

Source from the content-addressed store, hash-verified

1317 # ***** encoding/decoding ops *****
1318
1319 def decode_hevc_frame(self, frame_pos:Variable, shape:tuple[int,...], state:Tensor, ref_frames:list[Tensor]|None=None) -> Tensor:
1320 """
1321 Creates a Tensor by decoding an HEVC frame chunk.
1322
1323 You must provide the output shape of the decoded data (`shape`), the HEVC context (`vstate`), and, if required by the chunk,
1324 the reference frames (`ref_frames`).
1325 """
1326 ref_frames = [x.contiguous() for x in ref_frames or []]
1327 assert frame_pos.op is Ops.BIND, "frame_pos must be a bound Variable"
1328 srcs = (out:=Tensor.empty(*shape, device=self.device, dtype=self.dtype), self.contiguous(), state.contiguous(), *ref_frames)
1329 fn = UOp(Ops.CUSTOM_FUNCTION, dtypes.void, src=(frame_pos.src[0], *[UOp.const(dtypes.int, s) for s in shape]), arg="encdec")
1330 return Tensor(out.uop.after(fn.call(*[s.uop for s in srcs], frame_pos)))
1331
1332 # ***** functional nn ops *****
1333

Callers 1

hevc_decode_frameFunction · 0.80

Calls 7

contiguousMethod · 0.95
callMethod · 0.95
UOpClass · 0.90
TensorClass · 0.85
emptyMethod · 0.45
constMethod · 0.45
afterMethod · 0.45

Tested by

no test coverage detected