Message ID | f6eb3f73-01a3-84a3-ff9f-671f810ce460@gmail.com |
---|---|
State | New |
Headers | show |
On 20/11/17 00:36, Jun Zhao wrote: > From 5cbcd032de46e6a3f9563d1781776ea26728079d Mon Sep 17 00:00:00 2001 > From: Jun Zhao <jun.zhao@intel.com> > Date: Sat, 18 Nov 2017 10:44:44 +0800 > Subject: [PATCH 1/2] hwcontext_vaapi: add support when driver return > unimplemented. > > iHD driver sometime return unimplemented when query surface attributes, > we just ignore and give a warning in this case. Sometimes? In any case, I think this sort of behaviour should be characterised and covered by a driver quirk, as it already is with similar issues in the same driver (missing memtype attribute) and the VDPAU wrapper (doesn't implement surface attributes at all). - Mark > Signed-off-by: Jun Zhao <jun.zhao@intel.com> > --- > libavutil/hwcontext_vaapi.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c > index 0382eb06f2..f246639021 100644 > --- a/libavutil/hwcontext_vaapi.c > +++ b/libavutil/hwcontext_vaapi.c > @@ -169,7 +169,10 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, > attr_count = 0; > vas = vaQuerySurfaceAttributes(hwctx->display, config->config_id, > 0, &attr_count); > - if (vas != VA_STATUS_SUCCESS) { > + // Sometime driver return unimplemeted - ignore and warning. > + if (vas == VA_STATUS_ERROR_UNIMPLEMENTED) { > + av_log(hwdev, AV_LOG_WARNING, "Query surface attributes not implemented.\n"); > + } else if (vas != VA_STATUS_SUCCESS) { > av_log(hwdev, AV_LOG_ERROR, "Failed to query surface attributes: " > "%d (%s).\n", vas, vaErrorStr(vas)); > err = AVERROR(ENOSYS); > @@ -177,14 +180,17 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, > } > > attr_list = av_malloc(attr_count * sizeof(*attr_list)); > - if (!attr_list) { > + if (attr_count != 0 && !attr_list) { > err = AVERROR(ENOMEM); > goto fail; > } > > vas = vaQuerySurfaceAttributes(hwctx->display, config->config_id, > attr_list, &attr_count); > - if (vas != VA_STATUS_SUCCESS) { > + // Sometime driver return unimplemeted - ignore and warning. > + if (vas == VA_STATUS_ERROR_UNIMPLEMENTED) { > + av_log(hwdev, AV_LOG_WARNING, "Query surface attributes not implemented.\n"); > + } else if (vas != VA_STATUS_SUCCESS) { > av_log(hwdev, AV_LOG_ERROR, "Failed to query surface attributes: " > "%d (%s).\n", vas, vaErrorStr(vas)); > err = AVERROR(ENOSYS); > -- > 2.14.1 >
On 2017/11/20 19:37, Mark Thompson wrote: > On 20/11/17 00:36, Jun Zhao wrote: >> From 5cbcd032de46e6a3f9563d1781776ea26728079d Mon Sep 17 00:00:00 2001 >> From: Jun Zhao <jun.zhao@intel.com> >> Date: Sat, 18 Nov 2017 10:44:44 +0800 >> Subject: [PATCH 1/2] hwcontext_vaapi: add support when driver return >> unimplemented. >> >> iHD driver sometime return unimplemented when query surface attributes, >> we just ignore and give a warning in this case. > Sometimes? > > In any case, I think this sort of behaviour should be characterised and covered by a driver quirk, as it already is with similar issues in the same driver (missing memtype attribute) and the VDPAU wrapper (doesn't implement surface attributes at all). > > - Mark I know driver quirk, but as my debug result, iHD driver only report unimplemented in Encoder case. (Decoder and VPP have support vaQuerySurfaceAttributes in iHD) and vaapi_frames_get_constraints use by Decoder/Encoder/VPP as a public check point, I can't find a suitable way to use driver quirk in this case. Do you have any suggestion? > > >> Signed-off-by: Jun Zhao <jun.zhao@intel.com> >> --- >> libavutil/hwcontext_vaapi.c | 12 +++++++++--- >> 1 file changed, 9 insertions(+), 3 deletions(-) >> >> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c >> index 0382eb06f2..f246639021 100644 >> --- a/libavutil/hwcontext_vaapi.c >> +++ b/libavutil/hwcontext_vaapi.c >> @@ -169,7 +169,10 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, >> attr_count = 0; >> vas = vaQuerySurfaceAttributes(hwctx->display, config->config_id, >> 0, &attr_count); >> - if (vas != VA_STATUS_SUCCESS) { >> + // Sometime driver return unimplemeted - ignore and warning. >> + if (vas == VA_STATUS_ERROR_UNIMPLEMENTED) { >> + av_log(hwdev, AV_LOG_WARNING, "Query surface attributes not implemented.\n"); >> + } else if (vas != VA_STATUS_SUCCESS) { >> av_log(hwdev, AV_LOG_ERROR, "Failed to query surface attributes: " >> "%d (%s).\n", vas, vaErrorStr(vas)); >> err = AVERROR(ENOSYS); >> @@ -177,14 +180,17 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, >> } >> >> attr_list = av_malloc(attr_count * sizeof(*attr_list)); >> - if (!attr_list) { >> + if (attr_count != 0 && !attr_list) { >> err = AVERROR(ENOMEM); >> goto fail; >> } >> >> vas = vaQuerySurfaceAttributes(hwctx->display, config->config_id, >> attr_list, &attr_count); >> - if (vas != VA_STATUS_SUCCESS) { >> + // Sometime driver return unimplemeted - ignore and warning. >> + if (vas == VA_STATUS_ERROR_UNIMPLEMENTED) { >> + av_log(hwdev, AV_LOG_WARNING, "Query surface attributes not implemented.\n"); >> + } else if (vas != VA_STATUS_SUCCESS) { >> av_log(hwdev, AV_LOG_ERROR, "Failed to query surface attributes: " >> "%d (%s).\n", vas, vaErrorStr(vas)); >> err = AVERROR(ENOSYS); >> -- >> 2.14.1 >> > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 0382eb06f2..f246639021 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -169,7 +169,10 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, attr_count = 0; vas = vaQuerySurfaceAttributes(hwctx->display, config->config_id, 0, &attr_count); - if (vas != VA_STATUS_SUCCESS) { + // Sometime driver return unimplemeted - ignore and warning. + if (vas == VA_STATUS_ERROR_UNIMPLEMENTED) { + av_log(hwdev, AV_LOG_WARNING, "Query surface attributes not implemented.\n"); + } else if (vas != VA_STATUS_SUCCESS) { av_log(hwdev, AV_LOG_ERROR, "Failed to query surface attributes: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(ENOSYS); @@ -177,14 +180,17 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev, } attr_list = av_malloc(attr_count * sizeof(*attr_list)); - if (!attr_list) { + if (attr_count != 0 && !attr_list) { err = AVERROR(ENOMEM); goto fail; } vas = vaQuerySurfaceAttributes(hwctx->display, config->config_id, attr_list, &attr_count); - if (vas != VA_STATUS_SUCCESS) { + // Sometime driver return unimplemeted - ignore and warning. + if (vas == VA_STATUS_ERROR_UNIMPLEMENTED) { + av_log(hwdev, AV_LOG_WARNING, "Query surface attributes not implemented.\n"); + } else if (vas != VA_STATUS_SUCCESS) { av_log(hwdev, AV_LOG_ERROR, "Failed to query surface attributes: " "%d (%s).\n", vas, vaErrorStr(vas)); err = AVERROR(ENOSYS);