Commit d47de793 authored by Philip Langdale's avatar Philip Langdale

Revert "Merge commit 'b08caa87'"

This reverts commit d8bbb99c, reversing
changes made to d0d09137.
Signed-off-by: 's avatarPhilip Langdale <philipl@overt.org>
parent 58b49f78
...@@ -24,7 +24,6 @@ version <next>: ...@@ -24,7 +24,6 @@ version <next>:
- WebPAnimEncoder API when available for encoding and muxing WebP - WebPAnimEncoder API when available for encoding and muxing WebP
- Direct3D11-accelerated decoding - Direct3D11-accelerated decoding
- Support Secure Transport - Support Secure Transport
- NVIDIA NVENC-accelerated H.264 and HEVC encoding support
version 2.6: version 2.6:
......
...@@ -269,7 +269,7 @@ External library support: ...@@ -269,7 +269,7 @@ External library support:
--disable-lzma disable lzma [autodetect] --disable-lzma disable lzma [autodetect]
--enable-decklink enable Blackmagick DeckLink I/O support [no] --enable-decklink enable Blackmagick DeckLink I/O support [no]
--enable-mmal enable decoding via MMAL [no] --enable-mmal enable decoding via MMAL [no]
--enable-nvenc enable encoding via NVENC [no] --enable-nvenc enable NVIDIA NVENC support [no]
--enable-openal enable OpenAL 1.1 capture support [no] --enable-openal enable OpenAL 1.1 capture support [no]
--enable-opencl enable OpenCL code --enable-opencl enable OpenCL code
--enable-opengl enable OpenGL rendering [no] --enable-opengl enable OpenGL rendering [no]
...@@ -1771,7 +1771,6 @@ SYSTEM_FUNCS=" ...@@ -1771,7 +1771,6 @@ SYSTEM_FUNCS="
isatty isatty
jack_port_get_latency_range jack_port_get_latency_range
kbhit kbhit
LoadLibrary
localtime_r localtime_r
lzo1x_999_compress lzo1x_999_compress
mach_absolute_time mach_absolute_time
...@@ -2115,8 +2114,6 @@ mpegaudio_select="mpegaudiodsp" ...@@ -2115,8 +2114,6 @@ mpegaudio_select="mpegaudiodsp"
mpegaudiodsp_select="dct" mpegaudiodsp_select="dct"
mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp videodsp" mpegvideo_select="blockdsp h264chroma hpeldsp idctdsp me_cmp videodsp"
mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp" mpegvideoenc_select="me_cmp mpegvideo pixblockdsp qpeldsp"
nvenc_deps_any="dlopen LoadLibrary"
nvenc_extralibs='$ldl'
qsvdec_select="qsv" qsvdec_select="qsv"
qsvenc_select="qsv" qsvenc_select="qsv"
...@@ -2194,13 +2191,11 @@ h263p_decoder_select="h263_decoder" ...@@ -2194,13 +2191,11 @@ h263p_decoder_select="h263_decoder"
h263p_encoder_select="h263_encoder" h263p_encoder_select="h263_encoder"
h264_decoder_select="cabac golomb h264chroma h264dsp h264pred h264qpel startcode videodsp" h264_decoder_select="cabac golomb h264chroma h264dsp h264pred h264qpel startcode videodsp"
h264_decoder_suggest="error_resilience" h264_decoder_suggest="error_resilience"
h264_nvenc_encoder_deps="nvenc"
h264_qsv_decoder_deps="libmfx" h264_qsv_decoder_deps="libmfx"
h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel" h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec h264_qsv_hwaccel"
h264_qsv_encoder_deps="libmfx" h264_qsv_encoder_deps="libmfx"
h264_qsv_encoder_select="qsvenc" h264_qsv_encoder_select="qsvenc"
hevc_decoder_select="bswapdsp cabac golomb videodsp" hevc_decoder_select="bswapdsp cabac golomb videodsp"
hevc_nvenc_encoder_deps="nvenc"
huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp" huffyuv_decoder_select="bswapdsp huffyuvdsp llviddsp"
huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llviddsp" huffyuv_encoder_select="bswapdsp huffman huffyuvencdsp llviddsp"
iac_decoder_select="imc_decoder" iac_decoder_select="imc_decoder"
...@@ -4981,7 +4976,6 @@ check_func_headers windows.h CoTaskMemFree -lole32 ...@@ -4981,7 +4976,6 @@ check_func_headers windows.h CoTaskMemFree -lole32
check_func_headers windows.h GetProcessAffinityMask check_func_headers windows.h GetProcessAffinityMask
check_func_headers windows.h GetProcessTimes check_func_headers windows.h GetProcessTimes
check_func_headers windows.h GetSystemTimeAsFileTime check_func_headers windows.h GetSystemTimeAsFileTime
check_func_headers windows.h LoadLibrary
check_func_headers windows.h MapViewOfFile check_func_headers windows.h MapViewOfFile
check_func_headers windows.h PeekNamedPipe check_func_headers windows.h PeekNamedPipe
check_func_headers windows.h SetConsoleTextAttribute check_func_headers windows.h SetConsoleTextAttribute
...@@ -5179,6 +5173,10 @@ enabled mmal && { check_lib interface/mmal/mmal.h mmal_port_connect ...@@ -5179,6 +5173,10 @@ enabled mmal && { check_lib interface/mmal/mmal.h mmal_port_connect
check_lib interface/mmal/mmal.h mmal_port_connect ; } check_lib interface/mmal/mmal.h mmal_port_connect ; }
check_lib interface/mmal/mmal.h mmal_port_connect ; } || check_lib interface/mmal/mmal.h mmal_port_connect ; } ||
die "ERROR: mmal not found"; } die "ERROR: mmal not found"; }
enabled nvenc && { check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found."; } &&
{ check_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 5" ||
die "ERROR: NVENC API version 4 or older is not supported"; } &&
{ [ $target_os != cygwin ] || die "ERROR: NVENC is not supported on Cygwin currently."; }
enabled openal && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do enabled openal && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do
check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } || check_lib 'AL/al.h' alGetError "${al_libs}" && break; done } ||
die "ERROR: openal not found"; } && die "ERROR: openal not found"; } &&
...@@ -5215,15 +5213,6 @@ if enabled libdc1394; then ...@@ -5215,15 +5213,6 @@ if enabled libdc1394; then
enable libdc1394_1; } || enable libdc1394_1; } ||
die "ERROR: No version of libdc1394 found " die "ERROR: No version of libdc1394 found "
fi fi
if enabled nvenc; then
check_header cuda.h || die "ERROR: cuda.h not found.";
check_header nvEncodeAPI.h || die "ERROR: nvEncodeAPI.h not found.";
check_cpp_condition nvEncodeAPI.h "NVENCAPI_MAJOR_VERSION >= 5" ||
die "ERROR: NVENC API version 4 or older is not supported";
{ [ $target_os != cygwin ] || die "ERROR: NVENC is not supported on Cygwin currently."; }
fi
if ! disabled sdl; then if ! disabled sdl; then
SDL_CONFIG="${cross_prefix}sdl-config" SDL_CONFIG="${cross_prefix}sdl-config"
if check_pkg_config sdl SDL_events.h SDL_PollEvent; then if check_pkg_config sdl SDL_events.h SDL_PollEvent; then
......
...@@ -94,7 +94,6 @@ OBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideo_enc.o mpeg12data.o \ ...@@ -94,7 +94,6 @@ OBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideo_enc.o mpeg12data.o \
mpegvideoencdsp.o mpegvideoencdsp.o
OBJS-$(CONFIG_NVENC) += nvenc_a.o OBJS-$(CONFIG_NVENC) += nvenc_a.o
OBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o OBJS-$(CONFIG_PIXBLOCKDSP) += pixblockdsp.o
#OBJS-${CONFIG_NVENC} += nvenc_b.o
OBJS-$(CONFIG_QPELDSP) += qpeldsp.o OBJS-$(CONFIG_QPELDSP) += qpeldsp.o
OBJS-$(CONFIG_QSV) += qsv.o OBJS-$(CONFIG_QSV) += qsv.o
OBJS-$(CONFIG_QSVDEC) += qsvdec.o OBJS-$(CONFIG_QSVDEC) += qsvdec.o
...@@ -276,13 +275,11 @@ OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \ ...@@ -276,13 +275,11 @@ OBJS-$(CONFIG_H264_DECODER) += h264.o h264_cabac.o h264_cavlc.o \
h264_refs.o h264_sei.o h264_slice.o h264_refs.o h264_sei.o h264_slice.o
OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o OBJS-$(CONFIG_H264_VDA_DECODER) += vda_h264_dec.o
#OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_b_h264.o
OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec_h264.o OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec_h264.o
OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o
OBJS-$(CONFIG_HEVC_DECODER) += hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o \ OBJS-$(CONFIG_HEVC_DECODER) += hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o \
hevc_cabac.o hevc_refs.o hevcpred.o \ hevc_cabac.o hevc_refs.o hevcpred.o \
hevcdsp.o hevc_filter.o hevcdsp.o hevc_filter.o
#OBJS-$(CONFIG_HEVC_NVENC_ENCODER) += nvenc_b_hevc.o
OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o
OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \ OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \
canopus.o canopus.o
......
...@@ -563,9 +563,7 @@ void avcodec_register_all(void) ...@@ -563,9 +563,7 @@ void avcodec_register_all(void)
/* external libraries, that shouldn't be used by default if one of the /* external libraries, that shouldn't be used by default if one of the
* above is available */ * above is available */
REGISTER_ENCODER(LIBOPENH264, libopenh264); REGISTER_ENCODER(LIBOPENH264, libopenh264);
REGISTER_ENCODER(H264_NVENC, h264_nvenc);
REGISTER_ENCODER(H264_QSV, h264_qsv); REGISTER_ENCODER(H264_QSV, h264_qsv);
REGISTER_ENCODER(HEVC_NVENC, hevc_nvenc);
/* parsers */ /* parsers */
REGISTER_PARSER(AAC, aac); REGISTER_PARSER(AAC, aac);
......
This diff is collapsed.
/*
* 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 <cuda.h>
#include <nvEncodeAPI.h>
#include "libavutil/fifo.h"
#include "libavutil/opt.h"
#include "avcodec.h"
typedef struct NVENCInputSurface {
NV_ENC_INPUT_PTR in;
NV_ENC_BUFFER_FORMAT format;
int locked;
} NVENCInputSurface;
typedef struct NVENCOutputSurface {
NV_ENC_OUTPUT_PTR out;
NVENCInputSurface *in;
int busy;
} NVENCOutputSurface;
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 NVENCLibraryContext
{
void *cuda;
void *nvenc;
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;
} NVENCLibraryContext;
enum {
PRESET_DEFAULT,
PRESET_HP,
PRESET_HQ,
PRESET_BD ,
PRESET_LOW_LATENCY_DEFAULT ,
PRESET_LOW_LATENCY_HQ ,
PRESET_LOW_LATENCY_HP,
PRESET_LOSSLESS_DEFAULT,
PRESET_LOSSLESS_HP,
};
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,
};
enum {
NVENC_LOWLATENCY = 1,
NVENC_LOSSLESS,
};
enum {
LIST_DEVICES = -2,
ANY_DEVICE,
};
typedef struct NVENCContext {
AVClass *class;
NVENCLibraryContext nvel;
NV_ENC_INITIALIZE_PARAMS params;
NV_ENC_CONFIG config;
CUcontext cu_context;
int nb_surfaces;
NVENCInputSurface *in;
NVENCOutputSurface *out;
AVFifoBuffer *timestamps;
AVFifoBuffer *pending, *ready;
int64_t last_dts;
void *nvenc_ctx;
int preset;
int profile;
int level;
int tier;
int rc;
int device;
int flags;
} 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);
#endif /* AVCODEC_NVENC_H */
/*
* 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
*/
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include "nvenc.h"
#define OFFSET(x) offsetof(NVENCContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = PRESET_HQ }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" },
{ "default", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_DEFAULT }, 0, 0, VE, "preset" },
{ "hp", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HP }, 0, 0, VE, "preset" },
{ "hq", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HQ }, 0, 0, VE, "preset" },
{ "bd", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_BD }, 0, 0, VE, "preset" },
{ "ll", "low latency", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_DEFAULT }, 0, 0, VE, "preset" },
{ "llhq", "low latency hq", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HQ }, 0, 0, VE, "preset" },
{ "llhp", "low latency hp", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HP }, 0, 0, VE, "preset" },
{ "profile", "Set the encoding profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = NV_ENC_H264_PROFILE_HIGH }, NV_ENC_H264_PROFILE_BASELINE, NV_ENC_H264_PROFILE_CONSTRAINED_HIGH, VE, "profile" },
{ "baseline", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_BASELINE }, 0, 0, VE, "profile" },
{ "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_MAIN }, 0, 0, VE, "profile" },
{ "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_HIGH }, 0, 0, VE, "profile" },
{ "high_444", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_HIGH_444 }, 0, 0, VE, "profile" },
{ "constrained_high", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_H264_PROFILE_CONSTRAINED_HIGH }, 0, 0, VE, "profile" },
{ "level", "Set the encoding level restriction", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = NV_ENC_LEVEL_AUTOSELECT }, NV_ENC_LEVEL_AUTOSELECT, NV_ENC_LEVEL_H264_51, VE, "level" },
{ "1.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_1 }, 0, 0, VE, "level" },
{ "1.b", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_1b }, 0, 0, VE, "level" },
{ "1.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_11 }, 0, 0, VE, "level" },
{ "1.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_12 }, 0, 0, VE, "level" },
{ "1.3", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_13 }, 0, 0, VE, "level" },
{ "2.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_2 }, 0, 0, VE, "level" },
{ "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_21 }, 0, 0, VE, "level" },
{ "2.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_22 }, 0, 0, VE, "level" },
{ "3.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_3 }, 0, 0, VE, "level" },
{ "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_31 }, 0, 0, VE, "level" },
{ "3.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_32 }, 0, 0, VE, "level" },
{ "4.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_4 }, 0, 0, VE, "level" },
{ "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_41 }, 0, 0, VE, "level" },
{ "4.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_42 }, 0, 0, VE, "level" },
{ "5.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_5 }, 0, 0, VE, "level" },
{ "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_H264_51 }, 0, 0, VE, "level" },
{ "rc", "Override the preset rate-control", OFFSET(rc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, VE },
{ "constqp", "Constant QP mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0, 0, VE, "rc" },
{ "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0, 0, VE, "rc" },
{ "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0, 0, VE, "rc" },
{ "vbr_minqp", "Variable bitrate mode with MinQP", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR_MINQP }, 0, 0, VE, "rc" },
{ "ll_2pass_quality", "Multi-pass optimized for image quality (only for low-latency presets)", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_QUALITY }, 0, 0, VE, "rc" },
{ "ll_2pass_size", "Multi-pass optimized for constant frame size (only for low-latency presets)", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP }, 0, 0, VE, "rc" },
{ "vbr_2pass", "Multi-pass variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_VBR }, 0, 0, VE, "rc" },
{ "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 32 }, 0, INT_MAX, VE },
{ "device", "Select a specific NVENC device", OFFSET(device), AV_OPT_TYPE_INT, { .i64 = -1 }, -2, INT_MAX, VE, "device" },
{ "any", "Pick the first device available", 0, AV_OPT_TYPE_CONST, { .i64 = ANY_DEVICE }, 0, 0, VE, "device" },
{ "list", "List the available devices", 0, AV_OPT_TYPE_CONST, { .i64 = LIST_DEVICES }, 0, 0, VE, "device" },
{ NULL }
};
static const AVClass nvenc_hevc_class = {
.class_name = "nvenc_h264",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
static const AVCodecDefault defaults[] = {
{ "b", "0" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "qdiff", "-1" },
{ "qblur", "-1" },
{ "qcomp", "-1" },
{ NULL },
};
AVCodec ff_h264_nvenc_encoder = {
.name = "nvenc_h264",
.long_name = NULL_IF_CONFIG_SMALL("NVIDIA NVENC H264 encoder"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_H264,
.init = ff_nvenc_encode_init,
.encode2 = ff_nvenc_encode_frame,
.close = ff_nvenc_encode_close,
.priv_data_size = sizeof(NVENCContext),
.priv_class = &nvenc_hevc_class,
.defaults = defaults,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_YUV444P,
AV_PIX_FMT_NONE },
.capabilities = CODEC_CAP_DELAY,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
/*
* 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
*/
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include "nvenc.h"
#define OFFSET(x) offsetof(NVENCContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = PRESET_HQ }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" },
{ "default", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_DEFAULT }, 0, 0, VE, "preset" },
{ "hp", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HP }, 0, 0, VE, "preset" },
{ "hq", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HQ }, 0, 0, VE, "preset" },
{ "bd", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_BD }, 0, 0, VE, "preset" },
{ "ll", "low latency", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_DEFAULT }, 0, 0, VE, "preset" },
{ "llhq", "low latency hq", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HQ }, 0, 0, VE, "preset" },
{ "llhp", "low latency hp", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOW_LATENCY_HP }, 0, 0, VE, "preset" },
{ "lossless", "lossless", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOSSLESS_DEFAULT }, 0, 0, VE, "preset" },
{ "losslesshp", "lossless hp", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_LOSSLESS_HP }, 0, 0, VE, "preset" },
{ "profile", "Set the encoding profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = FF_PROFILE_HEVC_MAIN }, FF_PROFILE_HEVC_MAIN, FF_PROFILE_HEVC_MAIN, VE, "profile" },
{ "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_HEVC_MAIN }, 0, 0, VE, "profile" },
{ "level", "Set the encoding level restriction", OFFSET(level), AV_OPT_TYPE_INT, { .i64 = NV_ENC_LEVEL_AUTOSELECT }, NV_ENC_LEVEL_AUTOSELECT, NV_ENC_LEVEL_HEVC_62, VE, "level" },
{ "1.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_1 }, 0, 0, VE, "level" },
{ "2.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_2 }, 0, 0, VE, "level" },
{ "2.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_21 }, 0, 0, VE, "level" },
{ "3.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_3 }, 0, 0, VE, "level" },
{ "3.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_31 }, 0, 0, VE, "level" },
{ "4.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_4 }, 0, 0, VE, "level" },
{ "4.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_41 }, 0, 0, VE, "level" },
{ "5.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_5 }, 0, 0, VE, "level" },
{ "5.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_51 }, 0, 0, VE, "level" },
{ "5.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_52 }, 0, 0, VE, "level" },
{ "6.0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_6 }, 0, 0, VE, "level" },
{ "6.1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_61 }, 0, 0, VE, "level" },
{ "6.2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LEVEL_HEVC_62 }, 0, 0, VE, "level" },
{ "tier", "Set the encoding tier", OFFSET(tier), AV_OPT_TYPE_INT, { .i64 = NV_ENC_TIER_HEVC_MAIN }, NV_ENC_TIER_HEVC_MAIN, NV_ENC_TIER_HEVC_HIGH, VE, "tier"},
{ "main", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_TIER_HEVC_MAIN }, 0, 0, VE, "tier" },
{ "high", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_TIER_HEVC_HIGH }, 0, 0, VE, "tier" },
{ "rc", "Override the preset rate-control", OFFSET(rc), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 0, VE, "rc" },
{ "constqp", "Constant QP mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0, 0, VE, "rc" },
{ "vbr", "Variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0, 0, VE, "rc" },
{ "cbr", "Constant bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0, 0, VE, "rc" },
{ "vbr_minqp", "Variable bitrate mode with MinQP", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR_MINQP }, 0, 0, VE, "rc" },
{ "ll_2pass_quality", "Multi-pass optimized for image quality (only for low-latency presets)", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_QUALITY }, 0, 0, VE, "rc" },
{ "ll_2pass_size", "Multi-pass optimized for constant frame size (only for low-latency presets)", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_FRAMESIZE_CAP }, 0, 0, VE, "rc" },
{ "vbr_2pass", "Multi-pass variable bitrate mode", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_2_PASS_VBR }, 0, 0, VE, "rc" },
{ "surfaces", "Number of concurrent surfaces", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 32 }, 0, INT_MAX, VE },
{ "device", "Select a specific NVENC device", OFFSET(device), AV_OPT_TYPE_INT, { .i64 = -1 }, -2, INT_MAX, VE, "device" },
{ "any", "Pick the first device available", 0, AV_OPT_TYPE_CONST, { .i64 = ANY_DEVICE }, 0, 0, VE, "device" },
{ "list", "List the available devices", 0, AV_OPT_TYPE_CONST, { .i64 = LIST_DEVICES }, 0, 0, VE, "device" },
{ NULL }
};
static const AVClass nvenc_hevc_class = {
.class_name = "nvenc_hevc",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
static const AVCodecDefault defaults[] = {
{ "b", "0" },
{ "qmin", "-1" },
{ "qmax", "-1" },
{ "qdiff", "-1" },
{ "qblur", "-1" },
{ "qcomp", "-1" },
{ NULL },
};
AVCodec ff_hevc_nvenc_encoder = {
.name = "nvenc_hevc",
.long_name = NULL_IF_CONFIG_SMALL("NVIDIA NVENC HEVC encoder"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_HEVC,
.init = ff_nvenc_encode_init,
.encode2 = ff_nvenc_encode_frame,
.close = ff_nvenc_encode_close,
.priv_data_size = sizeof(NVENCContext),
.priv_class = &nvenc_hevc_class,
.defaults = defaults,
.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_YUV444P,
AV_PIX_FMT_NONE },
.capabilities = CODEC_CAP_DELAY,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
};
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define LIBAVCODEC_VERSION_MAJOR 56 #define LIBAVCODEC_VERSION_MAJOR 56
#define LIBAVCODEC_VERSION_MINOR 41 #define LIBAVCODEC_VERSION_MINOR 41
#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment