diff mbox

[FFmpeg-devel,v2,8/8] avcodec/cuvid: update hw_frames_ctx reference after get_format call

Message ID 20170215092423.5358-9-nfxjfg@googlemail.com
State Accepted
Headers show

Commit Message

wm4 Feb. 15, 2017, 9:24 a.m. UTC
From: Timo Rothenpieler <timo@rothenpieler.org>

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

Comments

wm4 Feb. 15, 2017, 9:39 a.m. UTC | #1
On Wed, 15 Feb 2017 10:24:23 +0100
wm4 <nfxjfg@googlemail.com> wrote:

> From: Timo Rothenpieler <timo@rothenpieler.org>
> 
> ---
>  libavcodec/cuvid.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
> index f5a49ce86f..a0682e3cdc 100644
> --- a/libavcodec/cuvid.c
> +++ b/libavcodec/cuvid.c
> @@ -140,6 +140,19 @@ static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form
>          return 0;
>      }
>  
> +    // 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;
> +    }
> +
>      av_log(avctx, AV_LOG_VERBOSE, "Formats: Original: %s | HW: %s | SW: %s\n",
>             av_get_pix_fmt_name(avctx->pix_fmt),
>             av_get_pix_fmt_name(surface_fmt),

Dropping this patch - it's already in master.
diff mbox

Patch

diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index f5a49ce86f..a0682e3cdc 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -140,6 +140,19 @@  static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form
         return 0;
     }
 
+    // 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;
+    }
+
     av_log(avctx, AV_LOG_VERBOSE, "Formats: Original: %s | HW: %s | SW: %s\n",
            av_get_pix_fmt_name(avctx->pix_fmt),
            av_get_pix_fmt_name(surface_fmt),