diff mbox

[FFmpeg-devel,1/3] hwcontext: Do not call device_init again when deriving an existing device

Message ID 20180514215858.11461-1-sw@jkqxz.net
State Accepted
Commit 136260eb88e80ed4f4712a341805ec1d0d69bbca
Headers show

Commit Message

Mark Thompson May 14, 2018, 9:58 p.m. UTC
The change in 309d660775e2b47af6723a0477c4d753bc0c54f4 to call device_init
when doing derivation missed this case - we should only call it if we
actually made a new device.
---
 libavutil/hwcontext.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

mypopy@gmail.com May 15, 2018, 12:42 a.m. UTC | #1
2018-05-15 5:58 GMT+08:00 Mark Thompson <sw@jkqxz.net>:
> The change in 309d660775e2b47af6723a0477c4d753bc0c54f4 to call device_init
> when doing derivation missed this case - we should only call it if we
> actually made a new device.
> ---
>  libavutil/hwcontext.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
> index 70c556ecac..745016ed7e 100644
> --- a/libavutil/hwcontext.c
> +++ b/libavutil/hwcontext.c
> @@ -646,6 +646,9 @@ int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
>                      ret = AVERROR(ENOMEM);
>                      goto fail;
>                  }
> +                ret = av_hwdevice_ctx_init(dst_ref);
> +                if (ret < 0)
> +                    goto fail;
>                  goto done;
>              }
>              if (ret != AVERROR(ENOSYS))
> @@ -658,10 +661,6 @@ 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;
>
> --
Patchset LGTM, thanks.
> 2.16.3
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Mark Thompson May 15, 2018, 9:23 p.m. UTC | #2
On 15/05/18 01:42, mypopy@gmail.com wrote:
> 2018-05-15 5:58 GMT+08:00 Mark Thompson <sw@jkqxz.net>:
>> The change in 309d660775e2b47af6723a0477c4d753bc0c54f4 to call device_init
>> when doing derivation missed this case - we should only call it if we
>> actually made a new device.
>> ---
>>  libavutil/hwcontext.c | 7 +++----
>>  1 file changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
>> index 70c556ecac..745016ed7e 100644
>> --- a/libavutil/hwcontext.c
>> +++ b/libavutil/hwcontext.c
>> @@ -646,6 +646,9 @@ int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
>>                      ret = AVERROR(ENOMEM);
>>                      goto fail;
>>                  }
>> +                ret = av_hwdevice_ctx_init(dst_ref);
>> +                if (ret < 0)
>> +                    goto fail;
>>                  goto done;
>>              }
>>              if (ret != AVERROR(ENOSYS))
>> @@ -658,10 +661,6 @@ 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;
>>
>> --
> Patchset LGTM, thanks.

Ok, I've applied 1 and 2.  I'll send a new version of 3 addressing other comments soon.

Thanks,

- Mark
diff mbox

Patch

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 70c556ecac..745016ed7e 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -646,6 +646,9 @@  int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ref_ptr,
                     ret = AVERROR(ENOMEM);
                     goto fail;
                 }
+                ret = av_hwdevice_ctx_init(dst_ref);
+                if (ret < 0)
+                    goto fail;
                 goto done;
             }
             if (ret != AVERROR(ENOSYS))
@@ -658,10 +661,6 @@  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;