* [FFmpeg-devel] [PATCH] Re-enable support for libva v1 @ 2022-02-24 9:53 Ingo Brückl 2022-03-05 20:46 ` Ingo Brückl 0 siblings, 1 reply; 7+ messages in thread From: Ingo Brückl @ 2022-02-24 9:53 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Bas Nieuwenhuizen [-- Attachment #1: Type: text/plain, Size: 175 bytes --] FFmpeg 4.4.1 still supported libva v1, FFmpeg 5.0 does not do that anymore. If dropping support for libva v1 wasn't an intentional decision, it's easy to re-enable it. Ingo [-- Attachment #2: 0001-Re-enable-support-for-libva-v1.patch --] [-- Type: text/x-diff, Size: 4330 bytes --] From f8cc63a789eabd8b7381e94767dff850977d0971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Br=C3=BCckl?= <ib@wupperonline.de> Date: Thu, 24 Feb 2022 00:17:11 +0100 Subject: [PATCH] libavutil/hwcontext_vaapi: Re-enable support for libva v1 Commit e050959103f375e6494937fa28ef2c4d2d15c9ef implemented passing in modifiers by using the PRIME_2 memory type, which only exists in v2 of the library. To still support v1 of the library, conditionally compile using VA_CHECK_VERSION() for both the new code and the old code before the commit. --- libavutil/hwcontext_vaapi.c | 57 ++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 994b744e4d..799490442e 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1026,7 +1026,12 @@ static void vaapi_unmap_from_drm(AVHWFramesContext *dst_fc, static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, const AVFrame *src, int flags) { +#if VA_CHECK_VERSION(2, 0, 0) VAAPIFramesContext *src_vafc = src_fc->internal->priv; + int use_prime2; +#else + int k; +#endif AVHWFramesContext *dst_fc = (AVHWFramesContext*)dst->hw_frames_ctx->data; AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; @@ -1034,10 +1039,28 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, const VAAPIFormatDescriptor *format_desc; VASurfaceID surface_id; VAStatus vas = VA_STATUS_SUCCESS; - int use_prime2; uint32_t va_fourcc; int err, i, j; +#if !VA_CHECK_VERSION(2, 0, 0) + unsigned long buffer_handle; + VASurfaceAttribExternalBuffers buffer_desc; + VASurfaceAttrib attrs[2] = { + { + .type = VASurfaceAttribMemoryType, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypeInteger, + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, + }, + { + .type = VASurfaceAttribExternalBufferDescriptor, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypePointer, + .value.value.p = &buffer_desc, + } + }; +#endif + desc = (AVDRMFrameDescriptor*)src->data[0]; if (desc->nb_objects != 1) { @@ -1072,6 +1095,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, format_desc = vaapi_format_from_fourcc(va_fourcc); av_assert0(format_desc); +#if VA_CHECK_VERSION(2, 0, 0) use_prime2 = !src_vafc->prime_2_import_unsupported && desc->objects[0].format_modifier != DRM_FORMAT_MOD_INVALID; if (use_prime2) { @@ -1183,6 +1207,37 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, &surface_id, 1, buffer_attrs, FF_ARRAY_ELEMS(buffer_attrs)); } +#else + buffer_handle = desc->objects[0].fd; + buffer_desc.pixel_format = va_fourcc; + buffer_desc.width = src_fc->width; + buffer_desc.height = src_fc->height; + buffer_desc.data_size = desc->objects[0].size; + buffer_desc.buffers = &buffer_handle; + buffer_desc.num_buffers = 1; + buffer_desc.flags = 0; + + k = 0; + for (i = 0; i < desc->nb_layers; i++) { + for (j = 0; j < desc->layers[i].nb_planes; j++) { + buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch; + buffer_desc.offsets[k] = desc->layers[i].planes[j].offset; + ++k; + } + } + buffer_desc.num_planes = k; + + if (format_desc->chroma_planes_swapped && + buffer_desc.num_planes == 3) { + FFSWAP(uint32_t, buffer_desc.pitches[1], buffer_desc.pitches[2]); + FFSWAP(uint32_t, buffer_desc.offsets[1], buffer_desc.offsets[2]); + } + + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, + src->width, src->height, + &surface_id, 1, + attrs, FF_ARRAY_ELEMS(attrs)); +#endif if (vas != VA_STATUS_SUCCESS) { av_log(dst_fc, AV_LOG_ERROR, "Failed to create surface from DRM " "object: %d (%s).\n", vas, vaErrorStr(vas)); -- 2.30.2 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 7+ messages in thread
* [FFmpeg-devel] [PATCH] Re-enable support for libva v1 2022-02-24 9:53 [FFmpeg-devel] [PATCH] Re-enable support for libva v1 Ingo Brückl @ 2022-03-05 20:46 ` Ingo Brückl 2022-03-11 12:24 ` [FFmpeg-devel] [PATCH] libavutil/hwcontext_vaapi: " Ingo Brückl 0 siblings, 1 reply; 7+ messages in thread From: Ingo Brückl @ 2022-03-05 20:46 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Haihao Xiang, Mark Thompson [-- Attachment #1: Type: text/plain, Size: 175 bytes --] FFmpeg 4.4.1 still supported libva v1, FFmpeg 5.0 does not do that anymore. If dropping support for libva v1 wasn't an intentional decision, it's easy to re-enable it. Ingo [-- Attachment #2: 0001-Re-enable-support-for-libva-v1.patch --] [-- Type: text/x-diff, Size: 4330 bytes --] From f8cc63a789eabd8b7381e94767dff850977d0971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Br=C3=BCckl?= <ib@wupperonline.de> Date: Thu, 24 Feb 2022 00:17:11 +0100 Subject: [PATCH] libavutil/hwcontext_vaapi: Re-enable support for libva v1 Commit e050959103f375e6494937fa28ef2c4d2d15c9ef implemented passing in modifiers by using the PRIME_2 memory type, which only exists in v2 of the library. To still support v1 of the library, conditionally compile using VA_CHECK_VERSION() for both the new code and the old code before the commit. --- libavutil/hwcontext_vaapi.c | 57 ++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 994b744e4d..799490442e 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1026,7 +1026,12 @@ static void vaapi_unmap_from_drm(AVHWFramesContext *dst_fc, static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, const AVFrame *src, int flags) { +#if VA_CHECK_VERSION(2, 0, 0) VAAPIFramesContext *src_vafc = src_fc->internal->priv; + int use_prime2; +#else + int k; +#endif AVHWFramesContext *dst_fc = (AVHWFramesContext*)dst->hw_frames_ctx->data; AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; @@ -1034,10 +1039,28 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, const VAAPIFormatDescriptor *format_desc; VASurfaceID surface_id; VAStatus vas = VA_STATUS_SUCCESS; - int use_prime2; uint32_t va_fourcc; int err, i, j; +#if !VA_CHECK_VERSION(2, 0, 0) + unsigned long buffer_handle; + VASurfaceAttribExternalBuffers buffer_desc; + VASurfaceAttrib attrs[2] = { + { + .type = VASurfaceAttribMemoryType, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypeInteger, + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, + }, + { + .type = VASurfaceAttribExternalBufferDescriptor, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypePointer, + .value.value.p = &buffer_desc, + } + }; +#endif + desc = (AVDRMFrameDescriptor*)src->data[0]; if (desc->nb_objects != 1) { @@ -1072,6 +1095,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, format_desc = vaapi_format_from_fourcc(va_fourcc); av_assert0(format_desc); +#if VA_CHECK_VERSION(2, 0, 0) use_prime2 = !src_vafc->prime_2_import_unsupported && desc->objects[0].format_modifier != DRM_FORMAT_MOD_INVALID; if (use_prime2) { @@ -1183,6 +1207,37 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, &surface_id, 1, buffer_attrs, FF_ARRAY_ELEMS(buffer_attrs)); } +#else + buffer_handle = desc->objects[0].fd; + buffer_desc.pixel_format = va_fourcc; + buffer_desc.width = src_fc->width; + buffer_desc.height = src_fc->height; + buffer_desc.data_size = desc->objects[0].size; + buffer_desc.buffers = &buffer_handle; + buffer_desc.num_buffers = 1; + buffer_desc.flags = 0; + + k = 0; + for (i = 0; i < desc->nb_layers; i++) { + for (j = 0; j < desc->layers[i].nb_planes; j++) { + buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch; + buffer_desc.offsets[k] = desc->layers[i].planes[j].offset; + ++k; + } + } + buffer_desc.num_planes = k; + + if (format_desc->chroma_planes_swapped && + buffer_desc.num_planes == 3) { + FFSWAP(uint32_t, buffer_desc.pitches[1], buffer_desc.pitches[2]); + FFSWAP(uint32_t, buffer_desc.offsets[1], buffer_desc.offsets[2]); + } + + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, + src->width, src->height, + &surface_id, 1, + attrs, FF_ARRAY_ELEMS(attrs)); +#endif if (vas != VA_STATUS_SUCCESS) { av_log(dst_fc, AV_LOG_ERROR, "Failed to create surface from DRM " "object: %d (%s).\n", vas, vaErrorStr(vas)); -- 2.30.2 [-- Attachment #3: Type: text/plain, Size: 251 bytes --] _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 7+ messages in thread
* [FFmpeg-devel] [PATCH] libavutil/hwcontext_vaapi: Re-enable support for libva v1 2022-03-05 20:46 ` Ingo Brückl @ 2022-03-11 12:24 ` Ingo Brückl 2022-03-29 14:37 ` Xiang, Haihao 0 siblings, 1 reply; 7+ messages in thread From: Ingo Brückl @ 2022-03-11 12:24 UTC (permalink / raw) To: ffmpeg-devel Commit e050959103f375e6494937fa28ef2c4d2d15c9ef implemented passing in modifiers by using the PRIME_2 memory type, which only exists in v2 of the library. To still support v1 of the library, conditionally compile using VA_CHECK_VERSION() for both the new code and the old code before the commit. --- libavutil/hwcontext_vaapi.c | 57 ++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 994b744e4d..799490442e 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -1026,7 +1026,12 @@ static void vaapi_unmap_from_drm(AVHWFramesContext *dst_fc, static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, const AVFrame *src, int flags) { +#if VA_CHECK_VERSION(2, 0, 0) VAAPIFramesContext *src_vafc = src_fc->internal->priv; + int use_prime2; +#else + int k; +#endif AVHWFramesContext *dst_fc = (AVHWFramesContext*)dst->hw_frames_ctx->data; AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; @@ -1034,10 +1039,28 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, const VAAPIFormatDescriptor *format_desc; VASurfaceID surface_id; VAStatus vas = VA_STATUS_SUCCESS; - int use_prime2; uint32_t va_fourcc; int err, i, j; +#if !VA_CHECK_VERSION(2, 0, 0) + unsigned long buffer_handle; + VASurfaceAttribExternalBuffers buffer_desc; + VASurfaceAttrib attrs[2] = { + { + .type = VASurfaceAttribMemoryType, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypeInteger, + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, + }, + { + .type = VASurfaceAttribExternalBufferDescriptor, + .flags = VA_SURFACE_ATTRIB_SETTABLE, + .value.type = VAGenericValueTypePointer, + .value.value.p = &buffer_desc, + } + }; +#endif + desc = (AVDRMFrameDescriptor*)src->data[0]; if (desc->nb_objects != 1) { @@ -1072,6 +1095,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, format_desc = vaapi_format_from_fourcc(va_fourcc); av_assert0(format_desc); +#if VA_CHECK_VERSION(2, 0, 0) use_prime2 = !src_vafc->prime_2_import_unsupported && desc->objects[0].format_modifier != DRM_FORMAT_MOD_INVALID; if (use_prime2) { @@ -1183,6 +1207,37 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, &surface_id, 1, buffer_attrs, FF_ARRAY_ELEMS(buffer_attrs)); } +#else + buffer_handle = desc->objects[0].fd; + buffer_desc.pixel_format = va_fourcc; + buffer_desc.width = src_fc->width; + buffer_desc.height = src_fc->height; + buffer_desc.data_size = desc->objects[0].size; + buffer_desc.buffers = &buffer_handle; + buffer_desc.num_buffers = 1; + buffer_desc.flags = 0; + + k = 0; + for (i = 0; i < desc->nb_layers; i++) { + for (j = 0; j < desc->layers[i].nb_planes; j++) { + buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch; + buffer_desc.offsets[k] = desc->layers[i].planes[j].offset; + ++k; + } + } + buffer_desc.num_planes = k; + + if (format_desc->chroma_planes_swapped && + buffer_desc.num_planes == 3) { + FFSWAP(uint32_t, buffer_desc.pitches[1], buffer_desc.pitches[2]); + FFSWAP(uint32_t, buffer_desc.offsets[1], buffer_desc.offsets[2]); + } + + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, + src->width, src->height, + &surface_id, 1, + attrs, FF_ARRAY_ELEMS(attrs)); +#endif if (vas != VA_STATUS_SUCCESS) { av_log(dst_fc, AV_LOG_ERROR, "Failed to create surface from DRM " "object: %d (%s).\n", vas, vaErrorStr(vas)); -- 2.30.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavutil/hwcontext_vaapi: Re-enable support for libva v1 2022-03-11 12:24 ` [FFmpeg-devel] [PATCH] libavutil/hwcontext_vaapi: " Ingo Brückl @ 2022-03-29 14:37 ` Xiang, Haihao 2022-03-31 14:58 ` Xiang, Haihao 0 siblings, 1 reply; 7+ messages in thread From: Xiang, Haihao @ 2022-03-29 14:37 UTC (permalink / raw) To: ffmpeg-devel On Fri, 2022-03-11 at 13:24 +0100, Ingo Brückl wrote: > Commit e050959103f375e6494937fa28ef2c4d2d15c9ef implemented passing in > modifiers by using the PRIME_2 memory type, which only exists in v2 of > the library. > > To still support v1 of the library, conditionally compile using > VA_CHECK_VERSION() for both the new code and the old code before > the commit. > --- > libavutil/hwcontext_vaapi.c | 57 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 56 insertions(+), 1 deletion(-) > > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c > index 994b744e4d..799490442e 100644 > --- a/libavutil/hwcontext_vaapi.c > +++ b/libavutil/hwcontext_vaapi.c > @@ -1026,7 +1026,12 @@ static void vaapi_unmap_from_drm(AVHWFramesContext > *dst_fc, > static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, > const AVFrame *src, int flags) > { > +#if VA_CHECK_VERSION(2, 0, 0) > VAAPIFramesContext *src_vafc = src_fc->internal->priv; > + int use_prime2; > +#else > + int k; > +#endif > AVHWFramesContext *dst_fc = > (AVHWFramesContext*)dst->hw_frames_ctx->data; > AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; > @@ -1034,10 +1039,28 @@ static int vaapi_map_from_drm(AVHWFramesContext > *src_fc, AVFrame *dst, > const VAAPIFormatDescriptor *format_desc; > VASurfaceID surface_id; > VAStatus vas = VA_STATUS_SUCCESS; > - int use_prime2; > uint32_t va_fourcc; > int err, i, j; > > +#if !VA_CHECK_VERSION(2, 0, 0) > + unsigned long buffer_handle; > + VASurfaceAttribExternalBuffers buffer_desc; > + VASurfaceAttrib attrs[2] = { > + { > + .type = VASurfaceAttribMemoryType, > + .flags = VA_SURFACE_ATTRIB_SETTABLE, > + .value.type = VAGenericValueTypeInteger, > + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, > + }, > + { > + .type = VASurfaceAttribExternalBufferDescriptor, > + .flags = VA_SURFACE_ATTRIB_SETTABLE, > + .value.type = VAGenericValueTypePointer, > + .value.value.p = &buffer_desc, > + } > + }; > +#endif > + > desc = (AVDRMFrameDescriptor*)src->data[0]; > > if (desc->nb_objects != 1) { > @@ -1072,6 +1095,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, > AVFrame *dst, > format_desc = vaapi_format_from_fourcc(va_fourcc); > av_assert0(format_desc); > > +#if VA_CHECK_VERSION(2, 0, 0) > use_prime2 = !src_vafc->prime_2_import_unsupported && > desc->objects[0].format_modifier != DRM_FORMAT_MOD_INVALID; > if (use_prime2) { > @@ -1183,6 +1207,37 @@ static int vaapi_map_from_drm(AVHWFramesContext > *src_fc, AVFrame *dst, > &surface_id, 1, > buffer_attrs, FF_ARRAY_ELEMS(buffer_attrs)); > } > +#else > + buffer_handle = desc->objects[0].fd; > + buffer_desc.pixel_format = va_fourcc; > + buffer_desc.width = src_fc->width; > + buffer_desc.height = src_fc->height; > + buffer_desc.data_size = desc->objects[0].size; > + buffer_desc.buffers = &buffer_handle; > + buffer_desc.num_buffers = 1; > + buffer_desc.flags = 0; > + > + k = 0; > + for (i = 0; i < desc->nb_layers; i++) { > + for (j = 0; j < desc->layers[i].nb_planes; j++) { > + buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch; > + buffer_desc.offsets[k] = desc->layers[i].planes[j].offset; > + ++k; > + } > + } > + buffer_desc.num_planes = k; > + > + if (format_desc->chroma_planes_swapped && > + buffer_desc.num_planes == 3) { > + FFSWAP(uint32_t, buffer_desc.pitches[1], buffer_desc.pitches[2]); > + FFSWAP(uint32_t, buffer_desc.offsets[1], buffer_desc.offsets[2]); > + } > + > + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, > + src->width, src->height, > + &surface_id, 1, > + attrs, FF_ARRAY_ELEMS(attrs)); > +#endif > if (vas != VA_STATUS_SUCCESS) { > av_log(dst_fc, AV_LOG_ERROR, "Failed to create surface from DRM " > "object: %d (%s).\n", vas, vaErrorStr(vas)); LGTM, will apply -Haihao _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavutil/hwcontext_vaapi: Re-enable support for libva v1 2022-03-29 14:37 ` Xiang, Haihao @ 2022-03-31 14:58 ` Xiang, Haihao 2022-03-31 15:26 ` Xiang, Haihao 0 siblings, 1 reply; 7+ messages in thread From: Xiang, Haihao @ 2022-03-31 14:58 UTC (permalink / raw) To: ffmpeg-devel On Tue, 2022-03-29 at 14:37 +0000, Xiang, Haihao wrote: > On Fri, 2022-03-11 at 13:24 +0100, Ingo Brückl wrote: > > Commit e050959103f375e6494937fa28ef2c4d2d15c9ef implemented passing in > > modifiers by using the PRIME_2 memory type, which only exists in v2 of > > the library. > > > > To still support v1 of the library, conditionally compile using > > VA_CHECK_VERSION() for both the new code and the old code before > > the commit. > > --- > > libavutil/hwcontext_vaapi.c | 57 ++++++++++++++++++++++++++++++++++++- > > 1 file changed, 56 insertions(+), 1 deletion(-) > > > > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c > > index 994b744e4d..799490442e 100644 > > --- a/libavutil/hwcontext_vaapi.c > > +++ b/libavutil/hwcontext_vaapi.c > > @@ -1026,7 +1026,12 @@ static void vaapi_unmap_from_drm(AVHWFramesContext > > *dst_fc, > > static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, > > const AVFrame *src, int flags) > > { > > +#if VA_CHECK_VERSION(2, 0, 0) > > VAAPIFramesContext *src_vafc = src_fc->internal->priv; > > + int use_prime2; > > +#else > > + int k; > > +#endif > > AVHWFramesContext *dst_fc = > > (AVHWFramesContext*)dst->hw_frames_ctx->data; > > AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; > > @@ -1034,10 +1039,28 @@ static int vaapi_map_from_drm(AVHWFramesContext > > *src_fc, AVFrame *dst, > > const VAAPIFormatDescriptor *format_desc; > > VASurfaceID surface_id; > > VAStatus vas = VA_STATUS_SUCCESS; > > - int use_prime2; > > uint32_t va_fourcc; > > int err, i, j; > > > > +#if !VA_CHECK_VERSION(2, 0, 0) > > + unsigned long buffer_handle; > > + VASurfaceAttribExternalBuffers buffer_desc; > > + VASurfaceAttrib attrs[2] = { > > + { > > + .type = VASurfaceAttribMemoryType, > > + .flags = VA_SURFACE_ATTRIB_SETTABLE, > > + .value.type = VAGenericValueTypeInteger, > > + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, > > + }, > > + { > > + .type = VASurfaceAttribExternalBufferDescriptor, > > + .flags = VA_SURFACE_ATTRIB_SETTABLE, > > + .value.type = VAGenericValueTypePointer, > > + .value.value.p = &buffer_desc, > > + } > > + }; > > +#endif > > + > > desc = (AVDRMFrameDescriptor*)src->data[0]; > > > > if (desc->nb_objects != 1) { > > @@ -1072,6 +1095,7 @@ static int vaapi_map_from_drm(AVHWFramesContext > > *src_fc, > > AVFrame *dst, > > format_desc = vaapi_format_from_fourcc(va_fourcc); > > av_assert0(format_desc); > > > > +#if VA_CHECK_VERSION(2, 0, 0) > > use_prime2 = !src_vafc->prime_2_import_unsupported && > > desc->objects[0].format_modifier != > > DRM_FORMAT_MOD_INVALID; > > if (use_prime2) { > > @@ -1183,6 +1207,37 @@ static int vaapi_map_from_drm(AVHWFramesContext > > *src_fc, AVFrame *dst, > > &surface_id, 1, > > buffer_attrs, FF_ARRAY_ELEMS(buffer_attrs)); > > } > > +#else > > + buffer_handle = desc->objects[0].fd; > > + buffer_desc.pixel_format = va_fourcc; > > + buffer_desc.width = src_fc->width; > > + buffer_desc.height = src_fc->height; > > + buffer_desc.data_size = desc->objects[0].size; > > + buffer_desc.buffers = &buffer_handle; > > + buffer_desc.num_buffers = 1; > > + buffer_desc.flags = 0; > > + > > + k = 0; > > + for (i = 0; i < desc->nb_layers; i++) { > > + for (j = 0; j < desc->layers[i].nb_planes; j++) { > > + buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch; > > + buffer_desc.offsets[k] = desc->layers[i].planes[j].offset; > > + ++k; > > + } > > + } > > + buffer_desc.num_planes = k; > > + > > + if (format_desc->chroma_planes_swapped && > > + buffer_desc.num_planes == 3) { > > + FFSWAP(uint32_t, buffer_desc.pitches[1], buffer_desc.pitches[2]); > > + FFSWAP(uint32_t, buffer_desc.offsets[1], buffer_desc.offsets[2]); > > + } > > + > > + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, > > + src->width, src->height, > > + &surface_id, 1, > > + attrs, FF_ARRAY_ELEMS(attrs)); > > +#endif > > if (vas != VA_STATUS_SUCCESS) { > > av_log(dst_fc, AV_LOG_ERROR, "Failed to create surface from DRM " > > "object: %d (%s).\n", vas, vaErrorStr(vas)); > > LGTM, will apply I'm sorry I didn't notice you are using `VA_CHECK_VERSION(2, 0, 0)`. PRIME_2 is available since VA-API 1.0, so you should use `VA_CHECK_VERSION(1, 0, 0)`, could you please update your patch ? Thanks Haihao _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavutil/hwcontext_vaapi: Re-enable support for libva v1 2022-03-31 14:58 ` Xiang, Haihao @ 2022-03-31 15:26 ` Xiang, Haihao 2022-04-06 11:57 ` Xiang, Haihao 0 siblings, 1 reply; 7+ messages in thread From: Xiang, Haihao @ 2022-03-31 15:26 UTC (permalink / raw) To: ffmpeg-devel On Thu, 2022-03-31 at 14:58 +0000, Xiang, Haihao wrote: > On Tue, 2022-03-29 at 14:37 +0000, Xiang, Haihao wrote: > > On Fri, 2022-03-11 at 13:24 +0100, Ingo Brückl wrote: > > > Commit e050959103f375e6494937fa28ef2c4d2d15c9ef implemented passing in > > > modifiers by using the PRIME_2 memory type, which only exists in v2 of > > > the library. > > > > > > To still support v1 of the library, conditionally compile using > > > VA_CHECK_VERSION() for both the new code and the old code before > > > the commit. > > > --- > > > libavutil/hwcontext_vaapi.c | 57 ++++++++++++++++++++++++++++++++++++- > > > 1 file changed, 56 insertions(+), 1 deletion(-) > > > > > > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c > > > index 994b744e4d..799490442e 100644 > > > --- a/libavutil/hwcontext_vaapi.c > > > +++ b/libavutil/hwcontext_vaapi.c > > > @@ -1026,7 +1026,12 @@ static void vaapi_unmap_from_drm(AVHWFramesContext > > > *dst_fc, > > > static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, > > > const AVFrame *src, int flags) > > > { > > > +#if VA_CHECK_VERSION(2, 0, 0) > > > VAAPIFramesContext *src_vafc = src_fc->internal->priv; > > > + int use_prime2; > > > +#else > > > + int k; > > > +#endif > > > AVHWFramesContext *dst_fc = > > > (AVHWFramesContext*)dst->hw_frames_ctx->data; > > > AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; > > > @@ -1034,10 +1039,28 @@ static int vaapi_map_from_drm(AVHWFramesContext > > > *src_fc, AVFrame *dst, > > > const VAAPIFormatDescriptor *format_desc; > > > VASurfaceID surface_id; > > > VAStatus vas = VA_STATUS_SUCCESS; > > > - int use_prime2; > > > uint32_t va_fourcc; > > > int err, i, j; > > > > > > +#if !VA_CHECK_VERSION(2, 0, 0) > > > + unsigned long buffer_handle; > > > + VASurfaceAttribExternalBuffers buffer_desc; > > > + VASurfaceAttrib attrs[2] = { > > > + { > > > + .type = VASurfaceAttribMemoryType, > > > + .flags = VA_SURFACE_ATTRIB_SETTABLE, > > > + .value.type = VAGenericValueTypeInteger, > > > + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, > > > + }, > > > + { > > > + .type = VASurfaceAttribExternalBufferDescriptor, > > > + .flags = VA_SURFACE_ATTRIB_SETTABLE, > > > + .value.type = VAGenericValueTypePointer, > > > + .value.value.p = &buffer_desc, > > > + } > > > + }; > > > +#endif > > > + > > > desc = (AVDRMFrameDescriptor*)src->data[0]; > > > > > > if (desc->nb_objects != 1) { > > > @@ -1072,6 +1095,7 @@ static int vaapi_map_from_drm(AVHWFramesContext > > > *src_fc, > > > AVFrame *dst, > > > format_desc = vaapi_format_from_fourcc(va_fourcc); > > > av_assert0(format_desc); > > > > > > +#if VA_CHECK_VERSION(2, 0, 0) > > > use_prime2 = !src_vafc->prime_2_import_unsupported && > > > desc->objects[0].format_modifier != > > > DRM_FORMAT_MOD_INVALID; > > > if (use_prime2) { > > > @@ -1183,6 +1207,37 @@ static int vaapi_map_from_drm(AVHWFramesContext > > > *src_fc, AVFrame *dst, > > > &surface_id, 1, > > > buffer_attrs, > > > FF_ARRAY_ELEMS(buffer_attrs)); > > > } > > > +#else > > > + buffer_handle = desc->objects[0].fd; > > > + buffer_desc.pixel_format = va_fourcc; > > > + buffer_desc.width = src_fc->width; > > > + buffer_desc.height = src_fc->height; > > > + buffer_desc.data_size = desc->objects[0].size; > > > + buffer_desc.buffers = &buffer_handle; > > > + buffer_desc.num_buffers = 1; > > > + buffer_desc.flags = 0; > > > + > > > + k = 0; > > > + for (i = 0; i < desc->nb_layers; i++) { > > > + for (j = 0; j < desc->layers[i].nb_planes; j++) { > > > + buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch; > > > + buffer_desc.offsets[k] = desc->layers[i].planes[j].offset; > > > + ++k; > > > + } > > > + } > > > + buffer_desc.num_planes = k; > > > + > > > + if (format_desc->chroma_planes_swapped && > > > + buffer_desc.num_planes == 3) { > > > + FFSWAP(uint32_t, buffer_desc.pitches[1], buffer_desc.pitches[2]); > > > + FFSWAP(uint32_t, buffer_desc.offsets[1], buffer_desc.offsets[2]); > > > + } > > > + > > > + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, > > > + src->width, src->height, > > > + &surface_id, 1, > > > + attrs, FF_ARRAY_ELEMS(attrs)); > > > +#endif > > > if (vas != VA_STATUS_SUCCESS) { > > > av_log(dst_fc, AV_LOG_ERROR, "Failed to create surface from DRM " > > > "object: %d (%s).\n", vas, vaErrorStr(vas)); > > > > LGTM, will apply > > I'm sorry I didn't notice you are using `VA_CHECK_VERSION(2, 0, 0)`. PRIME_2 > is > available since VA-API 1.0, so you should use `VA_CHECK_VERSION(1, 0, 0)`, > could > you please update your patch ? The first version supporting VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 is VA-API 1.1, please use VA_CHECK_VERSION(1, 1, 0) instead. BRs Haihao _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavutil/hwcontext_vaapi: Re-enable support for libva v1 2022-03-31 15:26 ` Xiang, Haihao @ 2022-04-06 11:57 ` Xiang, Haihao 0 siblings, 0 replies; 7+ messages in thread From: Xiang, Haihao @ 2022-04-06 11:57 UTC (permalink / raw) To: ffmpeg-devel On Thu, 2022-03-31 at 15:26 +0000, Xiang, Haihao wrote: > On Thu, 2022-03-31 at 14:58 +0000, Xiang, Haihao wrote: > > On Tue, 2022-03-29 at 14:37 +0000, Xiang, Haihao wrote: > > > On Fri, 2022-03-11 at 13:24 +0100, Ingo Brückl wrote: > > > > Commit e050959103f375e6494937fa28ef2c4d2d15c9ef implemented passing in > > > > modifiers by using the PRIME_2 memory type, which only exists in v2 of > > > > the library. > > > > > > > > To still support v1 of the library, conditionally compile using > > > > VA_CHECK_VERSION() for both the new code and the old code before > > > > the commit. > > > > --- > > > > libavutil/hwcontext_vaapi.c | 57 ++++++++++++++++++++++++++++++++++++- > > > > 1 file changed, 56 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c > > > > index 994b744e4d..799490442e 100644 > > > > --- a/libavutil/hwcontext_vaapi.c > > > > +++ b/libavutil/hwcontext_vaapi.c > > > > @@ -1026,7 +1026,12 @@ static void > > > > vaapi_unmap_from_drm(AVHWFramesContext > > > > *dst_fc, > > > > static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, > > > > const AVFrame *src, int flags) > > > > { > > > > +#if VA_CHECK_VERSION(2, 0, 0) > > > > VAAPIFramesContext *src_vafc = src_fc->internal->priv; > > > > + int use_prime2; > > > > +#else > > > > + int k; > > > > +#endif > > > > AVHWFramesContext *dst_fc = > > > > (AVHWFramesContext*)dst->hw_frames_ctx->data; > > > > AVVAAPIDeviceContext *dst_dev = dst_fc->device_ctx->hwctx; > > > > @@ -1034,10 +1039,28 @@ static int vaapi_map_from_drm(AVHWFramesContext > > > > *src_fc, AVFrame *dst, > > > > const VAAPIFormatDescriptor *format_desc; > > > > VASurfaceID surface_id; > > > > VAStatus vas = VA_STATUS_SUCCESS; > > > > - int use_prime2; > > > > uint32_t va_fourcc; > > > > int err, i, j; > > > > > > > > +#if !VA_CHECK_VERSION(2, 0, 0) > > > > + unsigned long buffer_handle; > > > > + VASurfaceAttribExternalBuffers buffer_desc; > > > > + VASurfaceAttrib attrs[2] = { > > > > + { > > > > + .type = VASurfaceAttribMemoryType, > > > > + .flags = VA_SURFACE_ATTRIB_SETTABLE, > > > > + .value.type = VAGenericValueTypeInteger, > > > > + .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME, > > > > + }, > > > > + { > > > > + .type = VASurfaceAttribExternalBufferDescriptor, > > > > + .flags = VA_SURFACE_ATTRIB_SETTABLE, > > > > + .value.type = VAGenericValueTypePointer, > > > > + .value.value.p = &buffer_desc, > > > > + } > > > > + }; > > > > +#endif > > > > + > > > > desc = (AVDRMFrameDescriptor*)src->data[0]; > > > > > > > > if (desc->nb_objects != 1) { > > > > @@ -1072,6 +1095,7 @@ static int vaapi_map_from_drm(AVHWFramesContext > > > > *src_fc, > > > > AVFrame *dst, > > > > format_desc = vaapi_format_from_fourcc(va_fourcc); > > > > av_assert0(format_desc); > > > > > > > > +#if VA_CHECK_VERSION(2, 0, 0) > > > > use_prime2 = !src_vafc->prime_2_import_unsupported && > > > > desc->objects[0].format_modifier != > > > > DRM_FORMAT_MOD_INVALID; > > > > if (use_prime2) { > > > > @@ -1183,6 +1207,37 @@ static int vaapi_map_from_drm(AVHWFramesContext > > > > *src_fc, AVFrame *dst, > > > > &surface_id, 1, > > > > buffer_attrs, > > > > FF_ARRAY_ELEMS(buffer_attrs)); > > > > } > > > > +#else > > > > + buffer_handle = desc->objects[0].fd; > > > > + buffer_desc.pixel_format = va_fourcc; > > > > + buffer_desc.width = src_fc->width; > > > > + buffer_desc.height = src_fc->height; > > > > + buffer_desc.data_size = desc->objects[0].size; > > > > + buffer_desc.buffers = &buffer_handle; > > > > + buffer_desc.num_buffers = 1; > > > > + buffer_desc.flags = 0; > > > > + > > > > + k = 0; > > > > + for (i = 0; i < desc->nb_layers; i++) { > > > > + for (j = 0; j < desc->layers[i].nb_planes; j++) { > > > > + buffer_desc.pitches[k] = desc->layers[i].planes[j].pitch; > > > > + buffer_desc.offsets[k] = desc->layers[i].planes[j].offset; > > > > + ++k; > > > > + } > > > > + } > > > > + buffer_desc.num_planes = k; > > > > + > > > > + if (format_desc->chroma_planes_swapped && > > > > + buffer_desc.num_planes == 3) { > > > > + FFSWAP(uint32_t, buffer_desc.pitches[1], > > > > buffer_desc.pitches[2]); > > > > + FFSWAP(uint32_t, buffer_desc.offsets[1], > > > > buffer_desc.offsets[2]); > > > > + } > > > > + > > > > + vas = vaCreateSurfaces(dst_dev->display, format_desc->rt_format, > > > > + src->width, src->height, > > > > + &surface_id, 1, > > > > + attrs, FF_ARRAY_ELEMS(attrs)); > > > > +#endif > > > > if (vas != VA_STATUS_SUCCESS) { > > > > av_log(dst_fc, AV_LOG_ERROR, "Failed to create surface from DRM > > > > " > > > > "object: %d (%s).\n", vas, vaErrorStr(vas)); > > > > > > LGTM, will apply > > > > I'm sorry I didn't notice you are using `VA_CHECK_VERSION(2, 0, 0)`. PRIME_2 > > is > > available since VA-API 1.0, so you should use `VA_CHECK_VERSION(1, 0, 0)`, > > could > > you please update your patch ? > > The first version supporting VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2 is VA-API > 1.1, please use VA_CHECK_VERSION(1, 1, 0) instead. Applied with a fix for version check at compile time to avoid breaking PRIME_2. BRs Haihao _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-04-06 11:57 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-02-24 9:53 [FFmpeg-devel] [PATCH] Re-enable support for libva v1 Ingo Brückl 2022-03-05 20:46 ` Ingo Brückl 2022-03-11 12:24 ` [FFmpeg-devel] [PATCH] libavutil/hwcontext_vaapi: " Ingo Brückl 2022-03-29 14:37 ` Xiang, Haihao 2022-03-31 14:58 ` Xiang, Haihao 2022-03-31 15:26 ` Xiang, Haihao 2022-04-06 11:57 ` Xiang, Haihao
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git