[FFmpeg-cvslog] avcodec/cuvid: update hw_frames_ctx reference after get_format call

Timo Rothenpieler git at videolan.org
Tue Feb 14 13:03:52 EET 2017


ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Thu Feb  9 22:29:47 2017 +0100| [b7d480f4312c5ce7d8ce2f6eb7189f0d96ad5bde] | committer: Timo Rothenpieler

avcodec/cuvid: update hw_frames_ctx reference after get_format call

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7d480f4312c5ce7d8ce2f6eb7189f0d96ad5bde
---

 libavcodec/cuvid.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index 9b35476..2a305ab 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;
 



More information about the ffmpeg-cvslog mailing list