diff options
Diffstat (limited to 'libavcodec/nvenc.h')
-rw-r--r-- | libavcodec/nvenc.h | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index e7e6182196..961cbc7e64 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -1,18 +1,18 @@ /* - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * 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. * - * Libav is distributed in the hope that it will be useful, + * 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 Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -29,7 +29,7 @@ #include "avcodec.h" #if CONFIG_CUDA -#include <cuda.h> +#include "libavutil/hwcontext_cuda.h" #else #if defined(_WIN32) @@ -48,16 +48,20 @@ typedef void* CUdeviceptr; #define MAX_REGISTERED_FRAMES 64 -typedef struct NVENCFrame { - NV_ENC_INPUT_PTR in; - AVFrame *in_ref; +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 out; + NV_ENC_OUTPUT_PTR output_surface; NV_ENC_BUFFER_FORMAT format; - int locked; -} NVENCFrame; + int size; + int lockCount; +} NvencSurface; typedef CUresult(CUDAAPI *PCUINIT)(unsigned int Flags); typedef CUresult(CUDAAPI *PCUDEVICEGETCOUNT)(int *count); @@ -70,7 +74,7 @@ typedef CUresult(CUDAAPI *PCUCTXDESTROY)(CUcontext ctx); typedef NVENCSTATUS (NVENCAPI *PNVENCODEAPICREATEINSTANCE)(NV_ENCODE_API_FUNCTION_LIST *functionList); -typedef struct NVENCLibraryContext +typedef struct NvencDynLoadFunctions { #if !CONFIG_CUDA void *cuda; @@ -87,17 +91,21 @@ typedef struct NVENCLibraryContext PCUCTXDESTROY cu_ctx_destroy; NV_ENCODE_API_FUNCTION_LIST nvenc_funcs; -} NVENCLibraryContext; + int nvenc_device_count; +} NvencDynLoadFunctions; enum { - PRESET_DEFAULT, + PRESET_DEFAULT = 0, + PRESET_SLOW, + PRESET_MEDIUM, + PRESET_FAST, PRESET_HP, PRESET_HQ, PRESET_BD , PRESET_LOW_LATENCY_DEFAULT , PRESET_LOW_LATENCY_HQ , PRESET_LOW_LATENCY_HP, - PRESET_LOSSLESS_DEFAULT, + PRESET_LOSSLESS_DEFAULT, // lossless presets must be the last ones PRESET_LOSSLESS_HP, }; @@ -105,13 +113,14 @@ enum { NV_ENC_H264_PROFILE_BASELINE, NV_ENC_H264_PROFILE_MAIN, NV_ENC_H264_PROFILE_HIGH, - NV_ENC_H264_PROFILE_HIGH_444, - NV_ENC_H264_PROFILE_CONSTRAINED_HIGH, + NV_ENC_H264_PROFILE_HIGH_444P, }; enum { NVENC_LOWLATENCY = 1, - NVENC_LOSSLESS, + NVENC_LOSSLESS = 2, + NVENC_ONE_PASS = 4, + NVENC_TWO_PASSES = 8, }; enum { @@ -119,20 +128,23 @@ enum { ANY_DEVICE, }; -typedef struct NVENCContext { - AVClass *class; - NVENCLibraryContext nvel; +typedef struct NvencContext +{ + AVClass *avclass; - NV_ENC_INITIALIZE_PARAMS params; - NV_ENC_CONFIG config; + NvencDynLoadFunctions nvenc_dload_funcs; + NV_ENC_INITIALIZE_PARAMS init_encode_params; + NV_ENC_CONFIG encode_config; CUcontext cu_context; CUcontext cu_context_internal; int nb_surfaces; - NVENCFrame *frames; - AVFifoBuffer *timestamps; - AVFifoBuffer *pending, *ready; + NvencSurface *surfaces; + + AVFifoBuffer *output_surface_queue; + AVFifoBuffer *output_surface_ready_queue; + AVFifoBuffer *timestamp_list; struct { CUdeviceptr ptr; @@ -150,17 +162,19 @@ typedef struct NVENCContext { int64_t initial_pts[2]; int first_packet_output; - void *nvenc_ctx; + void *nvencoder; int preset; int profile; int level; int tier; int rc; + int cbr; + int twopass; int device; int flags; int async_depth; -} NVENCContext; +} NvencContext; int ff_nvenc_encode_init(AVCodecContext *avctx); |