avcodec/nv{enc,dec}: use sane version checking macro

For some odd reason, the Nvidia version macros puts the minor version in
the msb, so comparing against it is impossible.
This commit is contained in:
Timo Rothenpieler 2018-04-13 09:36:49 +02:00
parent 987026adda
commit 9f3902f107
4 changed files with 15 additions and 3 deletions

View File

@ -32,6 +32,15 @@
#include "avcodec.h"
#if defined(NVDECAPI_MAJOR_VERSION) && defined(NVDECAPI_MINOR_VERSION)
# define NVDECAPI_CHECK_VERSION(major, minor) \
((major) < NVDECAPI_MAJOR_VERSION || ((major) == NVDECAPI_MAJOR_VERSION && (minor) <= NVDECAPI_MINOR_VERSION))
#else
/* version macros were added in SDK 8.1 ffnvcodec */
# define NVDECAPI_CHECK_VERSION(major, minor) \
((major) < 8 || ((major) == 8 && (minor) <= 0))
#endif
typedef struct NVDECFrame {
unsigned int idx;
AVBufferRef *idx_ref;

View File

@ -107,7 +107,7 @@ static int nvdec_hevc_start_frame(AVCodecContext *avctx,
.log2_diff_max_min_pcm_luma_coding_block_size = sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size,
.pcm_sample_bit_depth_luma_minus1 = sps->pcm_enabled_flag ? sps->pcm.bit_depth - 1 : 0,
.pcm_sample_bit_depth_chroma_minus1 = sps->pcm_enabled_flag ? sps->pcm.bit_depth_chroma - 1 : 0,
#if defined(NVDECAPI_VERSION) && NVDECAPI_VERSION >= 0x01000008
#if NVDECAPI_CHECK_VERSION(8, 1)
.log2_max_transform_skip_block_size_minus2 = pps->log2_max_transform_skip_block_size - 2,
.log2_sao_offset_scale_luma = pps->log2_sao_offset_scale_luma,
.log2_sao_offset_scale_chroma = pps->log2_sao_offset_scale_chroma,

View File

@ -119,7 +119,7 @@ static int nvenc_print_error(void *log_ctx, NVENCSTATUS err,
static void nvenc_print_driver_requirement(AVCodecContext *avctx, int level)
{
#if NVENCAPI_VERSION >= 0x01000008
#if NVENCAPI_CHECK_VERSION(8, 1)
# if defined(_WIN32) || defined(__CYGWIN__)
const char *minver = "390.77";
# else

View File

@ -40,8 +40,11 @@ typedef void ID3D11Device;
#define RC_MODE_DEPRECATED 0x800000
#define RCD(rc_mode) ((rc_mode) | RC_MODE_DEPRECATED)
#define NVENCAPI_CHECK_VERSION(major, minor) \
((major) < NVENCAPI_MAJOR_VERSION || ((major) == NVENCAPI_MAJOR_VERSION && (minor) <= NVENCAPI_MINOR_VERSION))
// SDK 8.1 compile time feature checks
#if NVENCAPI_VERSION >= 0x01000008
#if NVENCAPI_CHECK_VERSION(8, 1)
#define NVENC_HAVE_BFRAME_REF_MODE
#define NVENC_HAVE_QP_MAP_MODE
#endif