[FFmpeg-devel] lavfi/vf_srcnn: use avio_check instead of access

Submitted by Hendrik Leppkes on May 8, 2018, 3:27 p.m.

Details

Message ID 20180508152728.7176-1-h.leppkes@gmail.com
State New
Headers show

Commit Message

Hendrik Leppkes May 8, 2018, 3:27 p.m.
The filter uses avio for file access already, and avio_check is
portable.

Fixes trac #7192.
---
 libavfilter/vf_srcnn.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

James Almer May 8, 2018, 3:47 p.m.
On 5/8/2018 12:27 PM, Hendrik Leppkes wrote:
> The filter uses avio for file access already, and avio_check is
> portable.
> 
> Fixes trac #7192.

Remove the access dep in configure while at it.

LGTM is confirmed working.

> ---
>  libavfilter/vf_srcnn.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/libavfilter/vf_srcnn.c b/libavfilter/vf_srcnn.c
> index dace2b99b5..edffebb278 100644
> --- a/libavfilter/vf_srcnn.c
> +++ b/libavfilter/vf_srcnn.c
> @@ -28,9 +28,6 @@
>  #include "formats.h"
>  #include "internal.h"
>  #include "libavutil/opt.h"
> -#if HAVE_UNISTD_H
> -#include <unistd.h>
> -#endif
>  #include "vf_srcnn.h"
>  #include "libavformat/avio.h"
>  
> @@ -145,7 +142,7 @@ static av_cold int init(AVFilterContext* context)
>          srcnn_context->conv3.size = 5;
>          CHECK_ALLOCATION(allocate_copy_conv_data(&srcnn_context->conv3, conv3_kernel, conv3_biases), )
>      }
> -    else if (access(srcnn_context->config_file_path, R_OK) != -1){
> +    else if (avio_check(srcnn_context->config_file_path, AVIO_FLAG_READ) > 0){
>          if (avio_open(&config_file_context, srcnn_context->config_file_path, AVIO_FLAG_READ) < 0){
>              av_log(context, AV_LOG_ERROR, "failed to open configuration file\n");
>              return AVERROR(EIO);
>
Hendrik Leppkes May 8, 2018, 4:03 p.m.
On Tue, May 8, 2018 at 5:47 PM, James Almer <jamrial@gmail.com> wrote:
> On 5/8/2018 12:27 PM, Hendrik Leppkes wrote:
>> The filter uses avio for file access already, and avio_check is
>> portable.
>>
>> Fixes trac #7192.
>
> Remove the access dep in configure while at it.
>
> LGTM is confirmed working.
>

Amended, tested and pushed. Builds have been broken long enough.

Patch hide | download patch | download mbox

diff --git a/libavfilter/vf_srcnn.c b/libavfilter/vf_srcnn.c
index dace2b99b5..edffebb278 100644
--- a/libavfilter/vf_srcnn.c
+++ b/libavfilter/vf_srcnn.c
@@ -28,9 +28,6 @@ 
 #include "formats.h"
 #include "internal.h"
 #include "libavutil/opt.h"
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include "vf_srcnn.h"
 #include "libavformat/avio.h"
 
@@ -145,7 +142,7 @@  static av_cold int init(AVFilterContext* context)
         srcnn_context->conv3.size = 5;
         CHECK_ALLOCATION(allocate_copy_conv_data(&srcnn_context->conv3, conv3_kernel, conv3_biases), )
     }
-    else if (access(srcnn_context->config_file_path, R_OK) != -1){
+    else if (avio_check(srcnn_context->config_file_path, AVIO_FLAG_READ) > 0){
         if (avio_open(&config_file_context, srcnn_context->config_file_path, AVIO_FLAG_READ) < 0){
             av_log(context, AV_LOG_ERROR, "failed to open configuration file\n");
             return AVERROR(EIO);