MCPcopy Create free account
hub / github.com/BabitMF/bmf / process

Method process

bmf/python_modules/scale_gpu/scale_gpu.py:50–143  ·  view source on GitHub ↗
(self, task)

Source from the content-addressed store, hash-verified

48 }
49
50 def process(self, task):
51
52 # get input and output packet queue
53 input_queue = task.get_inputs()[0]
54 output_queue = task.get_outputs()[0]
55
56 # add all input frames into frame cache
57 while not input_queue.empty():
58 in_pkt = input_queue.get()
59
60 if in_pkt.timestamp == Timestamp.EOF:
61 # we should done all frames processing in following loop
62 self.eof_received_ = True
63 continue
64
65 in_frame = in_pkt.get(VideoFrame)
66 # pdb.set_trace()
67 if (in_frame.frame().device() == hmp.Device('cpu')):
68 in_frame = in_frame.cuda()
69 tensor_list = in_frame.frame().data()
70 # frame_out = hmp.Frame(self.w, self.h, in_frame.frame().pix_info(), device='cuda')
71 videoframe_out = VideoFrame(self.w,
72 self.h,
73 in_frame.frame().pix_info(),
74 device='cuda')
75 frame_out = videoframe_out.frame()
76
77 out_list = frame_out.data()
78 stream = hmp.current_stream(hmp.kCUDA)
79 cvstream = cvcuda.cuda.as_stream(stream.handle())
80
81 # deal with nv12 special case
82 if (in_frame.frame().format() == hmp.PixelFormat.kPF_NV12 or
83 in_frame.frame().format() == hmp.PixelFormat.kPF_P010LE):
84 cvimg_batch = cvcuda.ImageBatchVarShape(3)
85 cvimg_batch_out = cvcuda.ImageBatchVarShape(3)
86
87 in_420 = hmp.Frame(in_frame.width,
88 in_frame.height,
89 self.pinfo_map[in_frame.frame().format()],
90 device='cuda')
91 out_420 = hmp.Frame(self.w,
92 self.h,
93 self.pinfo_map[in_frame.frame().format()],
94 device='cuda')
95 hmp.img.yuv_to_yuv(in_420.data(),
96 in_frame.frame().data(),
97 self.pinfo_map[in_frame.frame().format()],
98 in_frame.frame().pix_info())
99 in_list = in_420.data()
100 out_list = out_420.data()
101 cvimg_batch.pushback([cvcuda.as_image(x) for x in in_list])
102 cvimg_batch_out.pushback(
103 [cvcuda.as_image(x) for x in out_list])
104
105 cvcuda.resize_into(cvimg_batch_out,
106 cvimg_batch,
107 self.algo,

Callers

nothing calls this directly

Calls 15

deviceMethod · 0.80
cudaMethod · 0.80
putMethod · 0.80
generate_eof_packetMethod · 0.80
log_nodeMethod · 0.80
VideoFrameFunction · 0.50
PacketFunction · 0.50
emptyMethod · 0.45
getMethod · 0.45
DeviceMethod · 0.45
dataMethod · 0.45
handleMethod · 0.45

Tested by

no test coverage detected