• Home
  • Raw
  • Download

Lines Matching refs:mem

40 static gpointer cuda_mem_map (GstCudaMemory * mem, gsize maxsize,
42 static void cuda_mem_unmap_full (GstCudaMemory * mem, GstMapInfo * info);
43 static GstMemory *cuda_mem_copy (GstMemory * mem, gssize offset, gssize size);
106 GstCudaMemory *mem; in gst_cuda_allocator_alloc() local
136 mem = g_new0 (GstCudaMemory, 1); in gst_cuda_allocator_alloc()
137 g_mutex_init (&mem->lock); in gst_cuda_allocator_alloc()
138 mem->data = data; in gst_cuda_allocator_alloc()
139 mem->alloc_params = *params; in gst_cuda_allocator_alloc()
140 mem->stride = stride; in gst_cuda_allocator_alloc()
144 mem->offset[i] = plane_offset; in gst_cuda_allocator_alloc()
148 mem->context = gst_object_ref (self->context); in gst_cuda_allocator_alloc()
150 gst_memory_init (GST_MEMORY_CAST (mem), in gst_cuda_allocator_alloc()
153 return GST_MEMORY_CAST (mem); in gst_cuda_allocator_alloc()
160 GstCudaMemory *mem = GST_CUDA_MEMORY_CAST (memory); in gst_cuda_allocator_free() local
164 g_mutex_clear (&mem->lock); in gst_cuda_allocator_free()
167 if (mem->data) in gst_cuda_allocator_free()
168 gst_cuda_result (CuMemFree (mem->data)); in gst_cuda_allocator_free()
170 if (mem->map_alloc_data) in gst_cuda_allocator_free()
171 gst_cuda_result (CuMemFreeHost (mem->map_alloc_data)); in gst_cuda_allocator_free()
174 gst_object_unref (mem->context); in gst_cuda_allocator_free()
176 g_free (mem); in gst_cuda_allocator_free()
181 gst_cuda_memory_upload_transfer (GstCudaMemory * mem) in gst_cuda_memory_upload_transfer() argument
184 GstVideoInfo *info = &mem->alloc_params.info; in gst_cuda_memory_upload_transfer()
187 if (!mem->map_data) { in gst_cuda_memory_upload_transfer()
197 (guint8 *) mem->map_data + GST_VIDEO_INFO_PLANE_OFFSET (info, i); in gst_cuda_memory_upload_transfer()
201 param.dstDevice = mem->data + mem->offset[i]; in gst_cuda_memory_upload_transfer()
202 param.dstPitch = mem->stride; in gst_cuda_memory_upload_transfer()
220 gst_cuda_memory_download_transfer (GstCudaMemory * mem) in gst_cuda_memory_download_transfer() argument
223 GstVideoInfo *info = &mem->alloc_params.info; in gst_cuda_memory_download_transfer()
225 if (!mem->map_data) { in gst_cuda_memory_download_transfer()
234 param.srcDevice = mem->data + mem->offset[i]; in gst_cuda_memory_download_transfer()
235 param.srcPitch = mem->stride; in gst_cuda_memory_download_transfer()
239 (guint8 *) mem->map_data + GST_VIDEO_INFO_PLANE_OFFSET (info, i); in gst_cuda_memory_download_transfer()
247 CuMemFreeHost (mem->map_alloc_data); in gst_cuda_memory_download_transfer()
248 mem->map_alloc_data = mem->map_data = mem->align_data = NULL; in gst_cuda_memory_download_transfer()
254 return ! !mem->map_data; in gst_cuda_memory_download_transfer()
258 gst_cuda_memory_device_memory_map (GstCudaMemory * mem) in gst_cuda_memory_device_memory_map() argument
260 GstMemory *memory = GST_MEMORY_CAST (mem); in gst_cuda_memory_device_memory_map()
265 if (mem->map_data) { in gst_cuda_memory_device_memory_map()
266 return mem->map_data; in gst_cuda_memory_device_memory_map()
271 if (!mem->map_alloc_data) { in gst_cuda_memory_device_memory_map()
276 if (!gst_cuda_context_push (mem->context)) { in gst_cuda_memory_device_memory_map()
293 mem->map_alloc_data = data; in gst_cuda_memory_device_memory_map()
301 mem->align_data = align_data; in gst_cuda_memory_device_memory_map()
304 GST_MINI_OBJECT_FLAG_SET (mem, GST_CUDA_MEMORY_TRANSFER_NEED_DOWNLOAD); in gst_cuda_memory_device_memory_map()
307 mem->map_data = mem->align_data; in gst_cuda_memory_device_memory_map()
309 if (GST_MEMORY_FLAG_IS_SET (mem, GST_CUDA_MEMORY_TRANSFER_NEED_DOWNLOAD)) { in gst_cuda_memory_device_memory_map()
310 if (!gst_cuda_context_push (mem->context)) { in gst_cuda_memory_device_memory_map()
316 gst_cuda_memory_download_transfer (mem); in gst_cuda_memory_device_memory_map()
323 return mem->map_data; in gst_cuda_memory_device_memory_map()
327 cuda_mem_map (GstCudaMemory * mem, gsize maxsize, GstMapFlags flags) in cuda_mem_map() argument
331 g_mutex_lock (&mem->lock); in cuda_mem_map()
332 mem->map_count++; in cuda_mem_map()
336 if (GST_MEMORY_FLAG_IS_SET (mem, GST_CUDA_MEMORY_TRANSFER_NEED_UPLOAD)) { in cuda_mem_map()
337 if (!gst_cuda_context_push (mem->context)) { in cuda_mem_map()
339 g_mutex_unlock (&mem->lock); in cuda_mem_map()
344 if (!gst_cuda_memory_upload_transfer (mem)) { in cuda_mem_map()
345 g_mutex_unlock (&mem->lock); in cuda_mem_map()
352 GST_MEMORY_FLAG_UNSET (mem, GST_CUDA_MEMORY_TRANSFER_NEED_UPLOAD); in cuda_mem_map()
355 GST_MINI_OBJECT_FLAG_SET (mem, GST_CUDA_MEMORY_TRANSFER_NEED_DOWNLOAD); in cuda_mem_map()
357 g_mutex_unlock (&mem->lock); in cuda_mem_map()
358 return (gpointer) mem->data; in cuda_mem_map()
361 ret = gst_cuda_memory_device_memory_map (mem); in cuda_mem_map()
363 mem->map_count--; in cuda_mem_map()
364 g_mutex_unlock (&mem->lock); in cuda_mem_map()
369 GST_MINI_OBJECT_FLAG_SET (mem, GST_CUDA_MEMORY_TRANSFER_NEED_UPLOAD); in cuda_mem_map()
371 GST_MEMORY_FLAG_UNSET (mem, GST_CUDA_MEMORY_TRANSFER_NEED_DOWNLOAD); in cuda_mem_map()
373 g_mutex_unlock (&mem->lock); in cuda_mem_map()
379 cuda_mem_unmap_full (GstCudaMemory * mem, GstMapInfo * info) in cuda_mem_unmap_full() argument
381 g_mutex_lock (&mem->lock); in cuda_mem_unmap_full()
382 mem->map_count--; in cuda_mem_unmap_full()
385 mem, mem->map_count, mem->map_data ? "true" : "false"); in cuda_mem_unmap_full()
389 GST_MINI_OBJECT_FLAG_SET (mem, GST_CUDA_MEMORY_TRANSFER_NEED_DOWNLOAD); in cuda_mem_unmap_full()
391 g_mutex_unlock (&mem->lock); in cuda_mem_unmap_full()
396 GST_MINI_OBJECT_FLAG_SET (mem, GST_CUDA_MEMORY_TRANSFER_NEED_UPLOAD); in cuda_mem_unmap_full()
398 if (mem->map_count > 0 || !mem->map_data) { in cuda_mem_unmap_full()
399 g_mutex_unlock (&mem->lock); in cuda_mem_unmap_full()
403 mem->map_data = NULL; in cuda_mem_unmap_full()
404 g_mutex_unlock (&mem->lock); in cuda_mem_unmap_full()
410 cuda_mem_copy (GstMemory * mem, gssize offset, gssize size) in cuda_mem_copy() argument
413 GstCudaMemory *src_mem = GST_CUDA_MEMORY_CAST (mem); in cuda_mem_copy()
415 GstCudaContext *ctx = GST_CUDA_ALLOCATOR_CAST (mem->allocator)->context; in cuda_mem_copy()
420 copy = gst_cuda_allocator_alloc (mem->allocator, mem->size, in cuda_mem_copy()
429 gst_cuda_allocator_free (mem->allocator, copy); in cuda_mem_copy()
450 mem->allocator, "Failed to copy %dth plane", i); in cuda_mem_copy()
452 gst_cuda_allocator_free (mem->allocator, copy); in cuda_mem_copy()
481 gst_is_cuda_memory (GstMemory * mem) in gst_is_cuda_memory() argument
483 return mem != NULL && mem->allocator != NULL && in gst_is_cuda_memory()
484 GST_IS_CUDA_ALLOCATOR (mem->allocator); in gst_is_cuda_memory()