- CUVIDDECODECREATEINFO cuinfo;
- CUvideodecoder cudec = 0;
- int ret = 0;
-
- memset(&cuinfo, 0, sizeof(cuinfo));
-
- cuinfo.CodecType = cuparseinfo->CodecType;
- cuinfo.ChromaFormat = cudaVideoChromaFormat_420;
- cuinfo.OutputFormat = cudaVideoSurfaceFormat_NV12;
-
- cuinfo.ulWidth = probed_width;
- cuinfo.ulHeight = probed_height;
- cuinfo.ulTargetWidth = cuinfo.ulWidth;
- cuinfo.ulTargetHeight = cuinfo.ulHeight;
-
- cuinfo.target_rect.left = 0;
- cuinfo.target_rect.top = 0;
- cuinfo.target_rect.right = cuinfo.ulWidth;
- cuinfo.target_rect.bottom = cuinfo.ulHeight;
+ CUVIDDECODECAPS *caps;
+ int res8 = 0, res10 = 0, res12 = 0;
+
+ ctx->caps8.eCodecType = ctx->caps10.eCodecType = ctx->caps12.eCodecType
+ = cuparseinfo->CodecType;
+ ctx->caps8.eChromaFormat = ctx->caps10.eChromaFormat = ctx->caps12.eChromaFormat
+ = cudaVideoChromaFormat_420;
+
+ ctx->caps8.nBitDepthMinus8 = 0;
+ ctx->caps10.nBitDepthMinus8 = 2;
+ ctx->caps12.nBitDepthMinus8 = 4;
+
+ res8 = CHECK_CU(ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps8));
+ res10 = CHECK_CU(ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps10));
+ res12 = CHECK_CU(ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps12));
+
+ av_log(avctx, AV_LOG_VERBOSE, "CUVID capabilities for %s:\n", avctx->codec->name);
+ av_log(avctx, AV_LOG_VERBOSE, "8 bit: supported: %d, min_width: %d, max_width: %d, min_height: %d, max_height: %d\n",
+ ctx->caps8.bIsSupported, ctx->caps8.nMinWidth, ctx->caps8.nMaxWidth, ctx->caps8.nMinHeight, ctx->caps8.nMaxHeight);
+ av_log(avctx, AV_LOG_VERBOSE, "10 bit: supported: %d, min_width: %d, max_width: %d, min_height: %d, max_height: %d\n",
+ ctx->caps10.bIsSupported, ctx->caps10.nMinWidth, ctx->caps10.nMaxWidth, ctx->caps10.nMinHeight, ctx->caps10.nMaxHeight);
+ av_log(avctx, AV_LOG_VERBOSE, "12 bit: supported: %d, min_width: %d, max_width: %d, min_height: %d, max_height: %d\n",
+ ctx->caps12.bIsSupported, ctx->caps12.nMinWidth, ctx->caps12.nMaxWidth, ctx->caps12.nMinHeight, ctx->caps12.nMaxHeight);
+
+ switch (bit_depth) {
+ case 10:
+ caps = &ctx->caps10;
+ if (res10 < 0)
+ return res10;
+ break;
+ case 12:
+ caps = &ctx->caps12;
+ if (res12 < 0)
+ return res12;
+ break;
+ default:
+ caps = &ctx->caps8;
+ if (res8 < 0)
+ return res8;
+ }