diff mbox

[FFmpeg-devel,5/6] hwcontext: Perform usual initialisation on derived device contexts

Message ID 20171008151146.13505-5-sw@jkqxz.net
State Accepted
Commit 309d660775e2b47af6723a0477c4d753bc0c54f4
Headers show

Commit Message

Mark Thompson Oct. 8, 2017, 3:11 p.m. UTC
The initialisation should be common.  For libmfx, it was previously
happening in the derivation function and this moves it out.  For VAAPI,
it fixes some failures when deriving from a DRM device because this
initialisation did not run.
---
 libavutil/hwcontext.c     |  4 ++++
 libavutil/hwcontext_qsv.c | 10 ----------
 2 files changed, 4 insertions(+), 10 deletions(-)

Comments

Derek Buitenhuis Oct. 8, 2017, 3:49 p.m. UTC | #1
On 10/8/2017 4:11 PM, Mark Thompson wrote:
> -    ret = qsv_device_init(ctx);
> -    if (ret < 0)
> -        goto fail;

From the patch context alone, this looks kinda iffy. I assume
qsv_device_init is now called via av_hwdevice_ctx_init?

- Derek
Mark Thompson Oct. 8, 2017, 3:52 p.m. UTC | #2
On 08/10/17 16:49, Derek Buitenhuis wrote:
> On 10/8/2017 4:11 PM, Mark Thompson wrote:
>> -    ret = qsv_device_init(ctx);
>> -    if (ret < 0)
>> -        goto fail;
> 
> From the patch context alone, this looks kinda iffy. I assume
> qsv_device_init is now called via av_hwdevice_ctx_init?

Yes.  It always was for the non-derived case, resulting in it being called twice (for qsv it doesn't actually do anything beyond some checks, so this was harmless).

- Mark
Derek Buitenhuis Oct. 8, 2017, 3:53 p.m. UTC | #3
On 10/8/2017 4:52 PM, Mark Thompson wrote:
> Yes.  It always was for the non-derived case, resulting in it being called twice (for qsv it doesn't actually do anything beyond some checks, so this was harmless).

Looks OK, then.

- Derek
diff mbox

Patch

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 2f4ee9661e..048e82126f 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -650,6 +650,10 @@  int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
     goto fail;
 
 done:
+    ret = av_hwdevice_ctx_init(dst_ref);
+    if (ret < 0)
+        goto fail;
+
     *dst_ref_ptr = dst_ref;
     return 0;
 
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 75057f7d52..f1d16d8bf9 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1037,16 +1037,6 @@  static int qsv_device_derive_from_child(AVHWDeviceContext *ctx,
         goto fail;
     }
 
-    ret = qsv_device_init(ctx);
-    if (ret < 0)
-        goto fail;
-    if (s->handle_type != handle_type) {
-        av_log(ctx, AV_LOG_ERROR, "Error in child device handle setup: "
-               "type mismatch (%d != %d).\n", s->handle_type, handle_type);
-        err = AVERROR_UNKNOWN;
-        goto fail;
-    }
-
     return 0;
 
 fail: