History

cuvid: support AVCodecContext.hw_device_ctx API

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.

wm4 committed 9 years ago

Commit c0f17a91 parent 974ee163 files · +17 −4Browse files

Showing the changes to libavcodec (2 of 3 files). Show all

Unified · Split

2 files
  1. libavcodec/cuvid.c +11 −3
  2. libavcodec/version.h +1 −1
libavcodec/cuvid.c+11−3
@@ -802,9 +802,17 @@ static av_cold int cuvid_decode_init(AVCodecContext *avctx) · 801 unmodified lines
802802 goto error;
803803 }
804804 } else {
805− ret = av_hwdevice_ctx_create(&ctx->hwdevice, AV_HWDEVICE_TYPE_CUDA, ctx->cu_gpu, NULL, 0);
806− if (ret < 0)
807− goto error;
805+ if (avctx->hw_device_ctx) {
806+ ctx->hwdevice = av_buffer_ref(avctx->hw_device_ctx);
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+ }
808816
809817 ctx->hwframe = av_hwframe_ctx_alloc(ctx->hwdevice);
810818 if (!ctx->hwframe) {
libavcodec/version.h+1−1
@@ -28,7 +28,7 @@ · 27 unmodified lines
2828 #include "libavutil/version.h"
2929
3030 #define LIBAVCODEC_VERSION_MAJOR 57
31−#define LIBAVCODEC_VERSION_MINOR 93
31+#define LIBAVCODEC_VERSION_MINOR 94
3232 #define LIBAVCODEC_VERSION_MICRO 100
3333
3434 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t