| 104 | } |
| 105 | |
| 106 | static int nvdec_test_capabilities(NVDECDecoder *decoder, |
| 107 | CUVIDDECODECREATEINFO *params, void *logctx) |
| 108 | { |
| 109 | int ret; |
| 110 | CUVIDDECODECAPS caps = { 0 }; |
| 111 | |
| 112 | caps.eCodecType = params->CodecType; |
| 113 | caps.eChromaFormat = params->ChromaFormat; |
| 114 | caps.nBitDepthMinus8 = params->bitDepthMinus8; |
| 115 | |
| 116 | if (!decoder->cvdl->cuvidGetDecoderCaps) { |
| 117 | av_log(logctx, AV_LOG_WARNING, "Used Nvidia driver is too old to perform a capability check.\n"); |
| 118 | av_log(logctx, AV_LOG_WARNING, "The minimum required version is " |
| 119 | #if defined(_WIN32) || defined(__CYGWIN__) |
| 120 | "378.66" |
| 121 | #else |
| 122 | "378.13" |
| 123 | #endif |
| 124 | ". Continuing blind.\n"); |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | ret = CHECK_CU(decoder->cvdl->cuvidGetDecoderCaps(&caps)); |
| 129 | if (ret < 0) |
| 130 | return ret; |
| 131 | |
| 132 | av_log(logctx, AV_LOG_VERBOSE, "NVDEC capabilities:\n"); |
| 133 | av_log(logctx, AV_LOG_VERBOSE, "format supported: %s, max_mb_count: %d\n", |
| 134 | caps.bIsSupported ? "yes" : "no", caps.nMaxMBCount); |
| 135 | av_log(logctx, AV_LOG_VERBOSE, "min_width: %d, max_width: %d\n", |
| 136 | caps.nMinWidth, caps.nMaxWidth); |
| 137 | av_log(logctx, AV_LOG_VERBOSE, "min_height: %d, max_height: %d\n", |
| 138 | caps.nMinHeight, caps.nMaxHeight); |
| 139 | |
| 140 | if (!caps.bIsSupported) { |
| 141 | av_log(logctx, AV_LOG_ERROR, "Hardware is lacking required capabilities\n"); |
| 142 | return AVERROR(EINVAL); |
| 143 | } |
| 144 | |
| 145 | if (params->ulWidth > caps.nMaxWidth || params->ulWidth < caps.nMinWidth) { |
| 146 | av_log(logctx, AV_LOG_ERROR, "Video width %d not within range from %d to %d\n", |
| 147 | (int)params->ulWidth, caps.nMinWidth, caps.nMaxWidth); |
| 148 | return AVERROR(EINVAL); |
| 149 | } |
| 150 | |
| 151 | if (params->ulHeight > caps.nMaxHeight || params->ulHeight < caps.nMinHeight) { |
| 152 | av_log(logctx, AV_LOG_ERROR, "Video height %d not within range from %d to %d\n", |
| 153 | (int)params->ulHeight, caps.nMinHeight, caps.nMaxHeight); |
| 154 | return AVERROR(EINVAL); |
| 155 | } |
| 156 | |
| 157 | if ((params->ulWidth * params->ulHeight) / 256 > caps.nMaxMBCount) { |
| 158 | av_log(logctx, AV_LOG_ERROR, "Video macroblock count %d exceeds maximum of %d\n", |
| 159 | (int)(params->ulWidth * params->ulHeight) / 256, caps.nMaxMBCount); |
| 160 | return AVERROR(EINVAL); |
| 161 | } |
| 162 | |
| 163 | return 0; |
no test coverage detected