diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h index 90578d5a1c4ee851a01c6289021030dc1c880682..85a0fcf7259cbe87a0fbfa786e94019c52dc8ce7 100644 --- a/libavcodec/nvdec.h +++ b/libavcodec/nvdec.h @@ -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; diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c index ba54d210e820a50aacd419ee26593064eda75cf6..e89256d75a9119394c5406c8dfc4bd43327d0a50 100644 --- a/libavcodec/nvdec_hevc.c +++ b/libavcodec/nvdec_hevc.c @@ -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, diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 9d07c260d03515b732e34e12923e9066b8c70e25..c14112c3663dc95c581ca193e2aa3b09581be6f8 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -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 diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h index 2d6e78173933642f6ec58178b6634b68dcffd6c0..c7506d6a1526f2037d3a922c26146f1ace513953 100644 --- a/libavcodec/nvenc.h +++ b/libavcodec/nvenc.h @@ -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