This is a newer API that is intended for decoders like the cuvid wrapper. Until now, the wrapper required to set an awkward "incomplete" hw_frames_ctx to set the device. Now the device can be set directly, and the user can get AV_PIX_FMT_CUDA output for a specific device simply by setting hw_device_ctx. This still does a dummy ff_get_format() call at init time, and should be fully backward compatible.
Unified · Split
| @@ -15,6 +15,11 @@ libavutil: 2015-08-28 · 14 unmodified lines | |||
| 15 | 15 | ||
| 16 | API changes, most recent first: | 16 | API changes, most recent first: |
| 17 | 17 | ||
| 18 | 2017-05-05 - xxxxxxxxxx - lavc 57.94.100 - avcodec.h | ||
| 19 | The cuvid decoders now support AVCodecContext.hw_device_ctx, which removes | ||
| 20 | the requirement to set an incomplete AVCodecContext.hw_frames_ctx only to | ||
| 21 | set the Cuda device handle. | ||
| 22 | |||
| 18 | 2017-04-11 - 8378466507 - lavu 55.61.100 - avstring.h | 23 | 2017-04-11 - 8378466507 - lavu 55.61.100 - avstring.h |
| 19 | Add av_strireplace(). | 24 | Add av_strireplace(). |
| 20 | 25 | ||
| @@ -802,9 +802,17 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) · 801 unmodified lines | |||
| 802 | goto error; | 802 | goto error; |
| 803 | } | 803 | } |
| 804 | } else { | 804 | } else { |
| 805 | ret = av_hwdevice_ctx_create(&ctx->hwdevice, AV_HWDEVICE_TYPE_CUDA, ctx->cu_gpu, NULL, 0); | 805 | if (avctx->hw_device_ctx) { |
| 806 | if (ret < 0) | 806 | ctx->hwdevice = av_buffer_ref(avctx->hw_device_ctx); |
| 807 | goto error; | 807 | if (!ctx->hwdevice) { |
| 808 | ret = AVERROR(ENOMEM); | ||
| 809 | goto error; | ||
| 810 | } | ||
| 811 | } else { | ||
| 812 | ret = av_hwdevice_ctx_create(&ctx->hwdevice, AV_HWDEVICE_TYPE_CUDA, ctx->cu_gpu, NULL, 0); | ||
| 813 | if (ret < 0) | ||
| 814 | goto error; | ||
| 815 | } | ||
| 808 | 816 | ||
| 809 | ctx->hwframe = av_hwframe_ctx_alloc(ctx->hwdevice); | 817 | ctx->hwframe = av_hwframe_ctx_alloc(ctx->hwdevice); |
| 810 | if (!ctx->hwframe) { | 818 | if (!ctx->hwframe) { |
| @@ -28,7 +28,7 @@ · 27 unmodified lines | |||
| 28 | #include "libavutil/version.h" | 28 | #include "libavutil/version.h" |
| 29 | 29 | ||
| 30 | #define LIBAVCODEC_VERSION_MAJOR 57 | 30 | #define LIBAVCODEC_VERSION_MAJOR 57 |
| 31 | #define LIBAVCODEC_VERSION_MINOR 93 | 31 | #define LIBAVCODEC_VERSION_MINOR 94 |
| 32 | #define LIBAVCODEC_VERSION_MICRO 100 | 32 | #define LIBAVCODEC_VERSION_MICRO 100 |
| 33 | 33 | ||
| 34 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | 34 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |