Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Turkin <andrey.turkin@gmail.com>2016-05-25 16:04:28 +0300
committerUbuntu <ubuntu@ip-172-31-24-241.eu-west-1.compute.internal>2016-05-31 14:15:19 +0300
commit7aa16d59bfc537db69ffb08b9d5ec5f868cff56a (patch)
tree396a00b334ba0a84717e0617e576d0bfb2f8c381 /libavcodec/nvenc.h
parenta1953d4cec1609e010cde895cac649feb9f5fdaa (diff)
avcodec/nvenc: split H264/HEVC encoder definitions into separate files
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Diffstat (limited to 'libavcodec/nvenc.h')
-rw-r--r--libavcodec/nvenc.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
new file mode 100644
index 0000000000..fdb63505ef
--- /dev/null
+++ b/libavcodec/nvenc.h
@@ -0,0 +1,159 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_NVENC_H
+#define AVCODEC_NVENC_H
+
+#include <nvEncodeAPI.h>
+
+#include "config.h"
+
+#include "libavutil/fifo.h"
+#include "libavutil/opt.h"
+
+#include "avcodec.h"
+
+#if CONFIG_CUDA
+#include <cuda.h>
+#else
+
+#if defined(_WIN32)
+#define CUDAAPI __stdcall
+#else
+#define CUDAAPI
+#endif
+
+typedef enum cudaError_enum {
+ CUDA_SUCCESS = 0
+} CUresult;
+typedef int CUdevice;
+typedef void* CUcontext;
+typedef void* CUdeviceptr;
+#endif
+
+#define MAX_REGISTERED_FRAMES 64
+
+typedef struct NvencSurface
+{
+ NV_ENC_INPUT_PTR input_surface;
+ AVFrame *in_ref;
+ NV_ENC_MAP_INPUT_RESOURCE in_map;
+ int reg_idx;
+ int width;
+ int height;
+
+ NV_ENC_OUTPUT_PTR output_surface;
+ NV_ENC_BUFFER_FORMAT format;
+ int size;
+ int lockCount;
+} NvencSurface;
+
+typedef CUresult(CUDAAPI *PCUINIT)(unsigned int Flags);
+typedef CUresult(CUDAAPI *PCUDEVICEGETCOUNT)(int *count);
+typedef CUresult(CUDAAPI *PCUDEVICEGET)(CUdevice *device, int ordinal);
+typedef CUresult(CUDAAPI *PCUDEVICEGETNAME)(char *name, int len, CUdevice dev);
+typedef CUresult(CUDAAPI *PCUDEVICECOMPUTECAPABILITY)(int *major, int *minor, CUdevice dev);
+typedef CUresult(CUDAAPI *PCUCTXCREATE)(CUcontext *pctx, unsigned int flags, CUdevice dev);
+typedef CUresult(CUDAAPI *PCUCTXPOPCURRENT)(CUcontext *pctx);
+typedef CUresult(CUDAAPI *PCUCTXDESTROY)(CUcontext ctx);
+
+typedef NVENCSTATUS (NVENCAPI *PNVENCODEAPICREATEINSTANCE)(NV_ENCODE_API_FUNCTION_LIST *functionList);
+
+typedef struct NvencDynLoadFunctions
+{
+#if !CONFIG_CUDA
+#if defined(_WIN32)
+ HMODULE cuda_lib;
+#else
+ void* cuda_lib;
+#endif
+#endif
+#if defined(_WIN32)
+ HMODULE nvenc_lib;
+#else
+ void* nvenc_lib;
+#endif
+
+ PCUINIT cu_init;
+ PCUDEVICEGETCOUNT cu_device_get_count;
+ PCUDEVICEGET cu_device_get;
+ PCUDEVICEGETNAME cu_device_get_name;
+ PCUDEVICECOMPUTECAPABILITY cu_device_compute_capability;
+ PCUCTXCREATE cu_ctx_create;
+ PCUCTXPOPCURRENT cu_ctx_pop_current;
+ PCUCTXDESTROY cu_ctx_destroy;
+
+ NV_ENCODE_API_FUNCTION_LIST nvenc_funcs;
+ int nvenc_device_count;
+ CUdevice nvenc_devices[16];
+
+} NvencDynLoadFunctions;
+
+typedef struct NvencContext
+{
+ AVClass *avclass;
+
+ NvencDynLoadFunctions nvenc_dload_funcs;
+
+ NV_ENC_INITIALIZE_PARAMS init_encode_params;
+ NV_ENC_CONFIG encode_config;
+ CUcontext cu_context;
+ CUcontext cu_context_internal;
+
+ int max_surface_count;
+ NvencSurface *surfaces;
+
+ AVFifoBuffer *output_surface_queue;
+ AVFifoBuffer *output_surface_ready_queue;
+ AVFifoBuffer *timestamp_list;
+
+ struct {
+ CUdeviceptr ptr;
+ NV_ENC_REGISTERED_PTR regptr;
+ int mapped;
+ } registered_frames[MAX_REGISTERED_FRAMES];
+ int nb_registered_frames;
+
+ /* the actual data pixel format, different from
+ * AVCodecContext.pix_fmt when using hwaccel frames on input */
+ enum AVPixelFormat data_pix_fmt;
+
+ int64_t last_dts;
+
+ void *nvencoder;
+
+ char *preset;
+ char *profile;
+ char *level;
+ char *tier;
+ int cbr;
+ int twopass;
+ int gpu;
+ int buffer_delay;
+} NvencContext;
+
+int ff_nvenc_encode_init(AVCodecContext *avctx);
+
+int ff_nvenc_encode_close(AVCodecContext *avctx);
+
+int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
+ const AVFrame *frame, int *got_packet);
+
+extern const enum AVPixelFormat ff_nvenc_pix_fmts[];
+
+#endif /* AVCODEC_NVENC_H */