[FFmpeg-devel] lavu/hwcontext_vaapi: provide detailed warning if directly mapping fails

Submitted by Linjie Fu on Aug. 14, 2019, 9:24 a.m.

Details

Message ID 20190814092445.23653-1-linjie.fu@intel.com
State New
Headers show

Commit Message

Linjie Fu Aug. 14, 2019, 9:24 a.m.
Detailed message could be helpful when using hwmap=mode=direct,format=xxx
for both qsv and vaapi.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
---
 libavutil/hwcontext_vaapi.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Zhong Li Aug. 14, 2019, 2:36 p.m.
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Linjie Fu

> Sent: Wednesday, August 14, 2019 5:25 PM

> To: ffmpeg-devel@ffmpeg.org

> Cc: Fu, Linjie <linjie.fu@intel.com>

> Subject: [FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: provide detailed

> warning if directly mapping fails

> 

> Detailed message could be helpful when using

> hwmap=mode=direct,format=xxx for both qsv and vaapi.

> 

> Signed-off-by: Linjie Fu <linjie.fu@intel.com>

> ---

>  libavutil/hwcontext_vaapi.c | 9 ++++++---

>  1 file changed, 6 insertions(+), 3 deletions(-)

> 

> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index

> cf117640f2..30c42e4385 100644

> --- a/libavutil/hwcontext_vaapi.c

> +++ b/libavutil/hwcontext_vaapi.c

> @@ -747,19 +747,22 @@ static int vaapi_map_frame(AVHWFramesContext

> *hwfc,

>      av_log(hwfc, AV_LOG_DEBUG, "Map surface %#x.\n", surface_id);

> 

>      if (!ctx->derive_works && (flags & AV_HWFRAME_MAP_DIRECT)) {

> -        // Requested direct mapping but it is not possible.

> +        av_log(hwfc, AV_LOG_WARNING, "Requested direct mapping but

> "

> +                                            "it is not

> possible.\n");

>          return AVERROR(EINVAL);

>      }

>      if (dst->format == AV_PIX_FMT_NONE)

>          dst->format = hwfc->sw_format;

>      if (dst->format != hwfc->sw_format && (flags &

> AV_HWFRAME_MAP_DIRECT)) {

> -        // Requested direct mapping but the formats do not match.

> +        av_log(hwfc, AV_LOG_WARNING, "Requested direct mapping but

> "

> +                                        "the formats do not

> match.\n");

>          return AVERROR(EINVAL);

>      }

> 

>      err = vaapi_get_image_format(hwfc->device_ctx, dst->format,

> &image_format);

>      if (err < 0) {

> -        // Requested format is not a valid output format.

> +        av_log(hwfc, AV_LOG_WARNING, "Requested format is "

> +                                        "not a valid output

> + format.\n");

>          return AVERROR(EINVAL);

>      }

> 

> --

> 2.17.1


Why just give a warning message when you need to return an error?
Linjie Fu Aug. 15, 2019, 2:30 a.m.
> -----Original Message-----

> From: Li, Zhong

> Sent: Wednesday, August 14, 2019 22:37

> To: FFmpeg development discussions and patches <ffmpeg-

> devel@ffmpeg.org>

> Cc: Fu, Linjie <linjie.fu@intel.com>

> Subject: RE: [FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: provide

> detailed warning if directly mapping fails

> 

> > From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On

> Behalf

> > Of Linjie Fu

> > Sent: Wednesday, August 14, 2019 5:25 PM

> > To: ffmpeg-devel@ffmpeg.org

> > Cc: Fu, Linjie <linjie.fu@intel.com>

> > Subject: [FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: provide detailed

> > warning if directly mapping fails

> >

> > Detailed message could be helpful when using

> > hwmap=mode=direct,format=xxx for both qsv and vaapi.

> >

> > Signed-off-by: Linjie Fu <linjie.fu@intel.com>

> > ---

> >  libavutil/hwcontext_vaapi.c | 9 ++++++---

> >  1 file changed, 6 insertions(+), 3 deletions(-)

> >

> 

> Why just give a warning message when you need to return an error?


Previously these messages are hidden in the code, thus a warning info  could be
a more gentle improvement IMHO. (since there will be other error logs prompted
when av_hwframe_map() fails)

It sounds  an error message is necessary.

Patch hide | download patch | download mbox

diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index cf117640f2..30c42e4385 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -747,19 +747,22 @@  static int vaapi_map_frame(AVHWFramesContext *hwfc,
     av_log(hwfc, AV_LOG_DEBUG, "Map surface %#x.\n", surface_id);
 
     if (!ctx->derive_works && (flags & AV_HWFRAME_MAP_DIRECT)) {
-        // Requested direct mapping but it is not possible.
+        av_log(hwfc, AV_LOG_WARNING, "Requested direct mapping but "
+                                            "it is not possible.\n");
         return AVERROR(EINVAL);
     }
     if (dst->format == AV_PIX_FMT_NONE)
         dst->format = hwfc->sw_format;
     if (dst->format != hwfc->sw_format && (flags & AV_HWFRAME_MAP_DIRECT)) {
-        // Requested direct mapping but the formats do not match.
+        av_log(hwfc, AV_LOG_WARNING, "Requested direct mapping but "
+                                        "the formats do not match.\n");
         return AVERROR(EINVAL);
     }
 
     err = vaapi_get_image_format(hwfc->device_ctx, dst->format, &image_format);
     if (err < 0) {
-        // Requested format is not a valid output format.
+        av_log(hwfc, AV_LOG_WARNING, "Requested format is "
+                                        "not a valid output format.\n");
         return AVERROR(EINVAL);
     }