FFmpeg
load_helper.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "config.h"
20 
21 #include "libavutil/hwcontext.h"
23 #include "libavutil/cuda_check.h"
24 #include "libavutil/mem.h"
25 
26 #if CONFIG_SHADER_COMPRESSION
27 #include "libavutil/zlib_utils.h"
28 #endif
29 
30 #include "load_helper.h"
31 
32 #define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, cu, x)
33 
34 int ff_cuda_load_module(void *avctx, AVCUDADeviceContext *hwctx, CUmodule *cu_module,
35  const unsigned char *data, const unsigned int length)
36 {
37  CudaFunctions *cu = hwctx->internal->cuda_dl;
38 
39 #if CONFIG_SHADER_COMPRESSION
40  uint8_t *out;
41  size_t out_len;
42  int ret = ff_zlib_expand(avctx, &out, &out_len,
43  data, length);
44  if (ret < 0)
45  return ret;
46 
47  ret = CHECK_CU(cu->cuModuleLoadData(cu_module, out));
48  av_free(out);
49  return ret;
50 #else
51  return CHECK_CU(cu->cuModuleLoadData(cu_module, data));
52 #endif
53 }
ff_zlib_expand
static int ff_zlib_expand(void *ctx, uint8_t **out, size_t *out_len, const uint8_t *src, int src_len)
Definition: zlib_utils.h:30
hwcontext_cuda_internal.h
out
FILE * out
Definition: movenc.c:55
ff_cuda_load_module
int ff_cuda_load_module(void *avctx, AVCUDADeviceContext *hwctx, CUmodule *cu_module, const unsigned char *data, const unsigned int length)
Loads a CUDA module and applies any decompression, if necessary.
Definition: load_helper.c:34
data
const char data[16]
Definition: mxf.c:149
CHECK_CU
#define CHECK_CU(x)
Definition: load_helper.c:32
zlib_utils.h
load_helper.h
AVCUDADeviceContext::internal
AVCUDADeviceContextInternal * internal
Definition: hwcontext_cuda.h:45
AVCUDADeviceContextInternal::cuda_dl
CudaFunctions * cuda_dl
Definition: hwcontext_cuda_internal.h:32
AVCUDADeviceContext
This struct is allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_cuda.h:42
ret
ret
Definition: filter_design.txt:187
cuda_check.h
mem.h
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
hwcontext.h