summaryrefslogtreecommitdiff
path: root/libavcodec/cuvid.c
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2017-02-09 22:29:47 +0100
committerTimo Rothenpieler <timo@rothenpieler.org>2017-02-14 11:43:47 +0100
commitb7d480f4312c5ce7d8ce2f6eb7189f0d96ad5bde (patch)
tree7b06cfe1a292a6e51756b48df44872e4ea937f41 /libavcodec/cuvid.c
parentbe74ba648cf4063c9805ebe95ee83fd7299f7fd5 (diff)
avcodec/cuvid: update hw_frames_ctx reference after get_format call
Diffstat (limited to 'libavcodec/cuvid.c')
-rw-r--r--libavcodec/cuvid.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index 9b35476f2a..2a305abd07 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -143,6 +143,19 @@ static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form
avctx->pix_fmt = surface_fmt;
+ // Update our hwframe ctx, as the get_format callback might have refreshed it!
+ if (avctx->hw_frames_ctx) {
+ av_buffer_unref(&ctx->hwframe);
+
+ ctx->hwframe = av_buffer_ref(avctx->hw_frames_ctx);
+ if (!ctx->hwframe) {
+ ctx->internal_error = AVERROR(ENOMEM);
+ return 0;
+ }
+
+ hwframe_ctx = (AVHWFramesContext*)ctx->hwframe->data;
+ }
+
avctx->width = format->display_area.right;
avctx->height = format->display_area.bottom;