Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_vulkan: check both vendor and PCI IDs
Mar 18, 2024, 07:33 by haihao.xiang-at-intel@ffmpeg.org: > On Ma, 2024-03-18 at 07:18 +0100, Lynne wrote: > >> Mar 18, 2024, 06:57 by haihao.xiang-at-intel@ffmpeg.org: >> >> > On Vr, 2024-03-08 at 15:13 +0800, Xiang, Haihao wrote: >> > >> > > From: Haihao Xiang >> > > >> > > Otherwise the derived device and the source device might have different >> > > PCI ID or vendor ID in a multiple-device system. >> > > >> > > Signed-off-by: Haihao Xiang >> > > --- >> > > libavutil/hwcontext_vulkan.c | 31 +-- >> > > 1 file changed, 29 insertions(+), 2 deletions(-) >> > > >> > > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c >> > > index 855f099e26..9d94f74d78 100644 >> > > --- a/libavutil/hwcontext_vulkan.c >> > > +++ b/libavutil/hwcontext_vulkan.c >> > > @@ -975,6 +975,20 @@ static int find_device(AVHWDeviceContext *ctx, >> > > VulkanDeviceSelection *select) >> > > select->name); >> > > err = AVERROR(ENODEV); >> > > goto end; >> > > + } else if (select->vendor_id && select->pci_device) { >> > > + av_log(ctx, AV_LOG_VERBOSE, "Requested vendor:device >> > > %04x:%04x\n", >> > > + select->vendor_id, select->pci_device); >> > > + for (int i = 0; i < num; i++) { >> > > + if (select->vendor_id == prop[i].properties.vendorID && >> > > + select->pci_device == prop[i].properties.deviceID) { >> > > + choice = i; >> > > + goto end; >> > > + } >> > > + } >> > > + av_log(ctx, AV_LOG_ERROR, "Unable to find device with vendor ID >> > > 0x%x >> > > " >> > > + "and PCI ID 0x%x!\n", select->vendor_id, select- >> > > >pci_device); >> > > + err = AVERROR(EINVAL); >> > > + goto end; >> > > } else if (select->pci_device) { >> > > av_log(ctx, AV_LOG_VERBOSE, "Requested device: 0x%x\n", select- >> > > > pci_device); >> > > for (int i = 0; i < num; i++) { >> > > @@ -1597,8 +1611,14 @@ static int vulkan_device_derive(AVHWDeviceContext >> > > *ctx, >> > > #if CONFIG_VAAPI >> > > case AV_HWDEVICE_TYPE_VAAPI: { >> > > AVVAAPIDeviceContext *src_hwctx = src_ctx->hwctx; >> > > - >> > > - const char *vendor = vaQueryVendorString(src_hwctx->display); >> > > + VADisplay dpy = src_hwctx->display; >> > > +#if VA_CHECK_VERSION(1, 15, 0) >> > > + VAStatus vas; >> > > + VADisplayAttribute attr = { >> > > + .type = VADisplayPCIID, >> > > + }; >> > > +#endif >> > > + const char *vendor = vaQueryVendorString(dpy); >> > > if (!vendor) { >> > > av_log(ctx, AV_LOG_ERROR, "Unable to get device info from >> > > VAAPI!\n"); >> > > return AVERROR_EXTERNAL; >> > > @@ -1607,6 +1627,13 @@ static int vulkan_device_derive(AVHWDeviceContext >> > > *ctx, >> > > if (strstr(vendor, "AMD")) >> > > dev_select.vendor_id = 0x1002; >> > > >> > > +#if VA_CHECK_VERSION(1, 15, 0) >> > > + vas = vaGetDisplayAttributes(dpy, &attr, 1); >> > > + if (vas == VA_STATUS_SUCCESS && attr.flags != >> > > VA_DISPLAY_ATTRIB_NOT_SUPPORTED) { >> > > + dev_select.vendor_id = ((attr.value >> 16) & 0x); >> > > + dev_select.pci_device = (attr.value & 0x); >> > > + } >> > > +#endif >> > > return vulkan_device_create_internal(ctx, &dev_select, 0, opts, >> > > flags); >> > > } >> > > #endif >> > > >> > >> > Hi, >> > >> > Any comment for this patch ? >> > >> >> Is this possible? For two devices from different vendors to have the same PCI >> ID? >> > > I'm not sure for different vendors. But when two devices come from the same > vendor (e.g. 8086:56a0 and 8086:4682), vulkan always picks up 8086:56a0 no > matter the source device is 8086:4682 if we don't set the device id here. > Do you need to check for both vendor and PCI ID? If not, could you resend without the custom vendor+pci check and just using the regular pci ID check? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_vulkan: check both vendor and PCI IDs
On Ma, 2024-03-18 at 07:18 +0100, Lynne wrote: > Mar 18, 2024, 06:57 by haihao.xiang-at-intel@ffmpeg.org: > > > On Vr, 2024-03-08 at 15:13 +0800, Xiang, Haihao wrote: > > > > > From: Haihao Xiang > > > > > > Otherwise the derived device and the source device might have different > > > PCI ID or vendor ID in a multiple-device system. > > > > > > Signed-off-by: Haihao Xiang > > > --- > > > libavutil/hwcontext_vulkan.c | 31 +-- > > > 1 file changed, 29 insertions(+), 2 deletions(-) > > > > > > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c > > > index 855f099e26..9d94f74d78 100644 > > > --- a/libavutil/hwcontext_vulkan.c > > > +++ b/libavutil/hwcontext_vulkan.c > > > @@ -975,6 +975,20 @@ static int find_device(AVHWDeviceContext *ctx, > > > VulkanDeviceSelection *select) > > > select->name); > > > err = AVERROR(ENODEV); > > > goto end; > > > + } else if (select->vendor_id && select->pci_device) { > > > + av_log(ctx, AV_LOG_VERBOSE, "Requested vendor:device > > > %04x:%04x\n", > > > + select->vendor_id, select->pci_device); > > > + for (int i = 0; i < num; i++) { > > > + if (select->vendor_id == prop[i].properties.vendorID && > > > + select->pci_device == prop[i].properties.deviceID) { > > > + choice = i; > > > + goto end; > > > + } > > > + } > > > + av_log(ctx, AV_LOG_ERROR, "Unable to find device with vendor ID > > > 0x%x > > > " > > > + "and PCI ID 0x%x!\n", select->vendor_id, select- > > > >pci_device); > > > + err = AVERROR(EINVAL); > > > + goto end; > > > } else if (select->pci_device) { > > > av_log(ctx, AV_LOG_VERBOSE, "Requested device: 0x%x\n", select- > > > > pci_device); > > > for (int i = 0; i < num; i++) { > > > @@ -1597,8 +1611,14 @@ static int vulkan_device_derive(AVHWDeviceContext > > > *ctx, > > > #if CONFIG_VAAPI > > > case AV_HWDEVICE_TYPE_VAAPI: { > > > AVVAAPIDeviceContext *src_hwctx = src_ctx->hwctx; > > > - > > > - const char *vendor = vaQueryVendorString(src_hwctx->display); > > > + VADisplay dpy = src_hwctx->display; > > > +#if VA_CHECK_VERSION(1, 15, 0) > > > + VAStatus vas; > > > + VADisplayAttribute attr = { > > > + .type = VADisplayPCIID, > > > + }; > > > +#endif > > > + const char *vendor = vaQueryVendorString(dpy); > > > if (!vendor) { > > > av_log(ctx, AV_LOG_ERROR, "Unable to get device info from > > > VAAPI!\n"); > > > return AVERROR_EXTERNAL; > > > @@ -1607,6 +1627,13 @@ static int vulkan_device_derive(AVHWDeviceContext > > > *ctx, > > > if (strstr(vendor, "AMD")) > > > dev_select.vendor_id = 0x1002; > > > > > > +#if VA_CHECK_VERSION(1, 15, 0) > > > + vas = vaGetDisplayAttributes(dpy, &attr, 1); > > > + if (vas == VA_STATUS_SUCCESS && attr.flags != > > > VA_DISPLAY_ATTRIB_NOT_SUPPORTED) { > > > + dev_select.vendor_id = ((attr.value >> 16) & 0x); > > > + dev_select.pci_device = (attr.value & 0x); > > > + } > > > +#endif > > > return vulkan_device_create_internal(ctx, &dev_select, 0, opts, > > > flags); > > > } > > > #endif > > > > > > > Hi, > > > > Any comment for this patch ? > > > > Is this possible? For two devices from different vendors to have the same PCI > ID? I'm not sure for different vendors. But when two devices come from the same vendor (e.g. 8086:56a0 and 8086:4682), vulkan always picks up 8086:56a0 no matter the source device is 8086:4682 if we don't set the device id here. 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-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_vulkan: check both vendor and PCI IDs
Mar 18, 2024, 06:57 by haihao.xiang-at-intel@ffmpeg.org: > On Vr, 2024-03-08 at 15:13 +0800, Xiang, Haihao wrote: > >> From: Haihao Xiang >> >> Otherwise the derived device and the source device might have different >> PCI ID or vendor ID in a multiple-device system. >> >> Signed-off-by: Haihao Xiang >> --- >> libavutil/hwcontext_vulkan.c | 31 +-- >> 1 file changed, 29 insertions(+), 2 deletions(-) >> >> diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c >> index 855f099e26..9d94f74d78 100644 >> --- a/libavutil/hwcontext_vulkan.c >> +++ b/libavutil/hwcontext_vulkan.c >> @@ -975,6 +975,20 @@ static int find_device(AVHWDeviceContext *ctx, >> VulkanDeviceSelection *select) >> select->name); >> err = AVERROR(ENODEV); >> goto end; >> + } else if (select->vendor_id && select->pci_device) { >> + av_log(ctx, AV_LOG_VERBOSE, "Requested vendor:device %04x:%04x\n", >> + select->vendor_id, select->pci_device); >> + for (int i = 0; i < num; i++) { >> + if (select->vendor_id == prop[i].properties.vendorID && >> + select->pci_device == prop[i].properties.deviceID) { >> + choice = i; >> + goto end; >> + } >> + } >> + av_log(ctx, AV_LOG_ERROR, "Unable to find device with vendor ID 0x%x >> " >> + "and PCI ID 0x%x!\n", select->vendor_id, select->pci_device); >> + err = AVERROR(EINVAL); >> + goto end; >> } else if (select->pci_device) { >> av_log(ctx, AV_LOG_VERBOSE, "Requested device: 0x%x\n", select- >> >pci_device); >> for (int i = 0; i < num; i++) { >> @@ -1597,8 +1611,14 @@ static int vulkan_device_derive(AVHWDeviceContext >> *ctx, >> #if CONFIG_VAAPI >> case AV_HWDEVICE_TYPE_VAAPI: { >> AVVAAPIDeviceContext *src_hwctx = src_ctx->hwctx; >> - >> - const char *vendor = vaQueryVendorString(src_hwctx->display); >> + VADisplay dpy = src_hwctx->display; >> +#if VA_CHECK_VERSION(1, 15, 0) >> + VAStatus vas; >> + VADisplayAttribute attr = { >> + .type = VADisplayPCIID, >> + }; >> +#endif >> + const char *vendor = vaQueryVendorString(dpy); >> if (!vendor) { >> av_log(ctx, AV_LOG_ERROR, "Unable to get device info from >> VAAPI!\n"); >> return AVERROR_EXTERNAL; >> @@ -1607,6 +1627,13 @@ static int vulkan_device_derive(AVHWDeviceContext >> *ctx, >> if (strstr(vendor, "AMD")) >> dev_select.vendor_id = 0x1002; >> >> +#if VA_CHECK_VERSION(1, 15, 0) >> + vas = vaGetDisplayAttributes(dpy, &attr, 1); >> + if (vas == VA_STATUS_SUCCESS && attr.flags != >> VA_DISPLAY_ATTRIB_NOT_SUPPORTED) { >> + dev_select.vendor_id = ((attr.value >> 16) & 0x); >> + dev_select.pci_device = (attr.value & 0x); >> + } >> +#endif >> return vulkan_device_create_internal(ctx, &dev_select, 0, opts, >> flags); >> } >> #endif >> > > Hi, > > Any comment for this patch ? > Is this possible? For two devices from different vendors to have the same PCI ID? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] Changelog: Add pad_vaapi, drawbox_vaapi entry
From: Haihao Xiang Signed-off-by: Haihao Xiang --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index b7d7535a9e..27da4b77f0 100644 --- a/Changelog +++ b/Changelog @@ -34,6 +34,7 @@ version : - ffprobe (with -export_side_data film_grain) now prints film grain metadata - AEA muxer - ffmpeg CLI loopback decoders +- pad_vaapi, drawbox_vaapi filters version 6.1: -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] lavfi: Add drawbox_vaapi filter
From: Haihao Xiang Signed-off-by: Haihao Xiang --- configure | 1 + doc/filters.texi | 85 libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_drawbox_vaapi.c | 369 + 5 files changed, 457 insertions(+) create mode 100644 libavfilter/vf_drawbox_vaapi.c diff --git a/configure b/configure index 4f64f48b38..3102689392 100755 --- a/configure +++ b/configure @@ -3891,6 +3891,7 @@ vstack_qsv_filter_select="qsvvpp" xstack_qsv_filter_deps="libmfx" xstack_qsv_filter_select="qsvvpp" pad_vaapi_filter_deps="vaapi_1" +drawbox_vaapi_filter_deps="vaapi_1" # examples avio_http_serve_files_deps="avformat avutil fork" diff --git a/doc/filters.texi b/doc/filters.texi index 2bd1a5b9e7..82bea77107 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -28018,6 +28018,91 @@ input sample aspect ratio input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar} @end table +@section drawbox_vaapi + +Draw a colored box on the input image. + +It accepts the following parameters: + +@table @option +@item x +@item y +The expressions which specify the top left corner coordinates of the box. It defaults to 0. + +@item width, w +@item height, h +The expressions which specify the width and height of the box; if 0 they are interpreted as +the input width and height. It defaults to 0. + +@item color, c +Specify the color of the box to write. For the general syntax of this option, +check the @ref{color syntax,,"Color" section in the ffmpeg-utils manual,ffmpeg-utils}. + +@item thickness, t +The expression which sets the thickness of the box edge. +A value of @code{fill} will create a filled box. Default value is @code{3}. + +See below for the list of accepted constants. + +@item replace +With value @code{1}, the pixels of the painted box will overwrite the video's color and alpha pixels. +Default is @code{0}, which composites the box onto the input video. +@end table + +The parameters for @var{x}, @var{y}, @var{w} and @var{h} and @var{t} are expressions containing the +following constants: + +@table @option +@item in_h, ih +@item in_w, iw +The input width and height. + +@item x +@item y +The x and y offset coordinates where the box is drawn. + +@item w +@item h +The width and height of the drawn box. + +@item t +The thickness of the drawn box. + +@end table + +@subsection Examples + +@itemize +@item +Draw a black box around the edge of the input image: +@example +drawbox +@end example + +@item +Draw a box with color red and an opacity of 50%: +@example +drawbox=10:20:200:60:red@@0.5 +@end example + +The previous example can be specified as: +@example +drawbox=x=10:y=20:w=200:h=60:color=red@@0.5 +@end example + +@item +Fill the box with pink color: +@example +drawbox=x=10:y=10:w=100:h=100:color=pink@@0.5:t=fill +@end example + +@item +Draw a 2-pixel red 2.40:1 mask: +@example +drawbox=x=-t:y=0.5*(ih-iw/2.4)-t:w=iw+t*2:h=iw/2.4+t*2:t=2:c=red +@end example +@end itemize + @c man end VAAPI VIDEO FILTERS @chapter Vulkan Video Filters diff --git a/libavfilter/Makefile b/libavfilter/Makefile index babcc7b676..8571e9e2af 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -582,6 +582,7 @@ OBJS-$(CONFIG_HSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o OBJS-$(CONFIG_VSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o OBJS-$(CONFIG_XSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o OBJS-$(CONFIG_PAD_VAAPI_FILTER) += vf_pad_vaapi.o vaapi_vpp.o +OBJS-$(CONFIG_DRAWBOX_VAAPI_FILTER) += vf_drawbox_vaapi.o vaapi_vpp.o OBJS-$(CONFIG_ALLRGB_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 1e024b3376..c532682fc2 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -547,6 +547,7 @@ extern const AVFilter ff_vf_hstack_qsv; extern const AVFilter ff_vf_vstack_qsv; extern const AVFilter ff_vf_xstack_qsv; extern const AVFilter ff_vf_pad_vaapi; +extern const AVFilter ff_vf_drawbox_vaapi; extern const AVFilter ff_vsrc_allrgb; extern const AVFilter ff_vsrc_allyuv; diff --git a/libavfilter/vf_drawbox_vaapi.c b/libavfilter/vf_drawbox_vaapi.c new file mode 100644 index 00..1081d463e9 --- /dev/null +++ b/libavfilter/vf_drawbox_vaapi.c @@ -0,0 +1,369 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License fo
[FFmpeg-devel] [PATCH 1/3] lavfi: Add pad_vaapi filter
From: Haihao Xiang Signed-off-by: Haihao Xiang --- configure | 1 + doc/filters.texi | 77 ++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_pad_vaapi.c | 283 + 5 files changed, 363 insertions(+) create mode 100644 libavfilter/vf_pad_vaapi.c diff --git a/configure b/configure index 2b4c4ec9a2..4f64f48b38 100755 --- a/configure +++ b/configure @@ -3890,6 +3890,7 @@ vstack_qsv_filter_deps="libmfx" vstack_qsv_filter_select="qsvvpp" xstack_qsv_filter_deps="libmfx" xstack_qsv_filter_select="qsvvpp" +pad_vaapi_filter_deps="vaapi_1" # examples avio_http_serve_files_deps="avformat avutil fork" diff --git a/doc/filters.texi b/doc/filters.texi index 913365671d..2bd1a5b9e7 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -27941,6 +27941,83 @@ first input stream. For the syntax of this option, check the See @ref{xstack}. @end table +@section pad_vaapi + +Add paddings to the input image, and place the original input at the +provided @var{x}, @var{y} coordinates. + +It accepts the following options: + +@table @option +@item width, w +@item height, h +Specify an expression for the size of the output image with the +paddings added. If the value for @var{width} or @var{height} is 0, the +corresponding input size is used for the output. + +The @var{width} expression can reference the value set by the +@var{height} expression, and vice versa. + +The default value of @var{width} and @var{height} is 0. + +@item x +@item y +Specify the offsets to place the input image at within the padded area, +with respect to the top/left border of the output image. + +The @var{x} expression can reference the value set by the @var{y} +expression, and vice versa. + +The default value of @var{x} and @var{y} is 0. + +If @var{x} or @var{y} evaluate to a negative number, they'll be changed +so the input image is centered on the padded area. + +@item color +Specify the color of the padded area. For the syntax of this option, +check the @ref{color syntax,,"Color" section in the ffmpeg-utils +manual,ffmpeg-utils}. + +@item aspect +Pad to an aspect instead to a resolution. +@end table + +The value for the @var{width}, @var{height}, @var{x}, and @var{y} +options are expressions containing the following constants: + +@table @option +@item in_w +@item in_h +The input video width and height. + +@item iw +@item ih +These are the same as @var{in_w} and @var{in_h}. + +@item out_w +@item out_h +The output width and height (the size of the padded area), as +specified by the @var{width} and @var{height} expressions. + +@item ow +@item oh +These are the same as @var{out_w} and @var{out_h}. + +@item x +@item y +The x and y offsets as specified by the @var{x} and @var{y} +expressions, or NAN if not yet specified. + +@item a +same as @var{iw} / @var{ih} + +@item sar +input sample aspect ratio + +@item dar +input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar} +@end table + @c man end VAAPI VIDEO FILTERS @chapter Vulkan Video Filters diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 994d9773ba..babcc7b676 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -581,6 +581,7 @@ OBJS-$(CONFIG_XSTACK_VAAPI_FILTER) += vf_stack_vaapi.o framesync.o vaa OBJS-$(CONFIG_HSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o OBJS-$(CONFIG_VSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o OBJS-$(CONFIG_XSTACK_QSV_FILTER) += vf_stack_qsv.o framesync.o +OBJS-$(CONFIG_PAD_VAAPI_FILTER) += vf_pad_vaapi.o vaapi_vpp.o OBJS-$(CONFIG_ALLRGB_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_ALLYUV_FILTER) += vsrc_testsrc.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 149bf50997..1e024b3376 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -546,6 +546,7 @@ extern const AVFilter ff_vf_xstack_vaapi; extern const AVFilter ff_vf_hstack_qsv; extern const AVFilter ff_vf_vstack_qsv; extern const AVFilter ff_vf_xstack_qsv; +extern const AVFilter ff_vf_pad_vaapi; extern const AVFilter ff_vsrc_allrgb; extern const AVFilter ff_vsrc_allyuv; diff --git a/libavfilter/vf_pad_vaapi.c b/libavfilter/vf_pad_vaapi.c new file mode 100644 index 00..98f6285222 --- /dev/null +++ b/libavfilter/vf_pad_vaapi.c @@ -0,0 +1,283 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You
Re: [FFmpeg-devel] [PATCH v3] lavc/vaapi_encode: Enable block level bitrate control
On Vr, 2024-03-15 at 02:46 +, Xiang, Haihao wrote: > On Vr, 2024-03-08 at 16:45 +0800, fei.w.wang-at-intel@ffmpeg.org wrote: > > From: Fei Wang > > > > Signed-off-by: Fei Wang > > --- > > doc/encoders.texi | 4 > > libavcodec/vaapi_encode.c | 13 - > > libavcodec/vaapi_encode.h | 9 - > > 3 files changed, 24 insertions(+), 2 deletions(-) > > > > diff --git a/doc/encoders.texi b/doc/encoders.texi > > index 5f7864770e..7c223ed74c 100644 > > --- a/doc/encoders.texi > > +++ b/doc/encoders.texi > > @@ -4089,6 +4089,10 @@ Quality-defined variable-bitrate. > > Average variable bitrate. > > @end table > > > > +@item blbrc > > +Enable block level rate control, which assigns different bitrate block by > > block. > > +Invalid for CQP mode. > > + > > @end table > > > > Each encoder also has its own specific options: > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c > > index 808b79c0c7..940f0678a5 100644 > > --- a/libavcodec/vaapi_encode.c > > +++ b/libavcodec/vaapi_encode.c > > @@ -1805,6 +1805,11 @@ static av_cold int > > vaapi_encode_init_rate_control(AVCodecContext *avctx) > > int i, first = 1, res; > > > > supported_va_rc_modes = rc_attr.value; > > + if (ctx->blbrc && !(supported_va_rc_modes & VA_RC_MB)) { > > + ctx->blbrc = 0; > > + av_log(avctx, AV_LOG_WARNING, "Driver does not support > > BLBRC.\n"); > > + } > > + > > for (i = 0; i < FF_ARRAY_ELEMS(vaapi_encode_rc_modes); i++) { > > rc_mode = &vaapi_encode_rc_modes[i]; > > if (supported_va_rc_modes & rc_mode->va_mode) { > > @@ -2016,13 +2021,18 @@ rc_mode_found: > > ctx->va_bit_rate = rc_bits_per_second; > > > > av_log(avctx, AV_LOG_VERBOSE, "RC mode: %s.\n", rc_mode->name); > > + > > + if (ctx->blbrc && ctx->va_rc_mode == VA_RC_CQP) > > + ctx->blbrc = 0; > > + av_log(avctx, AV_LOG_VERBOSE, "Block Level bitrate control: %s.\n", > > ctx- > > > blbrc ? "ON" : "OFF"); > > + > > if (rc_attr.value == VA_ATTRIB_NOT_SUPPORTED) { > > // This driver does not want the RC mode attribute to be set. > > } else { > > ctx->config_attributes[ctx->nb_config_attributes++] = > > (VAConfigAttrib) { > > .type = VAConfigAttribRateControl, > > - .value = ctx->va_rc_mode, > > + .value = ctx->blbrc ? ctx->va_rc_mode | VA_RC_MB : ctx- > > > va_rc_mode, > > }; > > } > > > > @@ -2051,6 +2061,7 @@ rc_mode_found: > > #if VA_CHECK_VERSION(1, 1, 0) > > .ICQ_quality_factor = av_clip(rc_quality, 1, 51), > > .max_qp = (avctx->qmax > 0 ? avctx->qmax : 0), > > + .rc_flags.bits.mb_rate_control = ctx->blbrc ? 1 : 2, > > #endif > > #if VA_CHECK_VERSION(1, 3, 0) > > .quality_factor = rc_quality, > > diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h > > index 6964055b93..0eed9691ca 100644 > > --- a/libavcodec/vaapi_encode.h > > +++ b/libavcodec/vaapi_encode.h > > @@ -216,6 +216,9 @@ typedef struct VAAPIEncodeContext { > > // available modes). > > int explicit_rc_mode; > > > > + // Block Level based bitrate control. > > + int blbrc; > > + > > // Explicitly-set QP, for use with the "qp" options. > > // (Forces CQP mode when set, overriding everything else.) > > int explicit_qp; > > @@ -538,7 +541,11 @@ int ff_vaapi_encode_close(AVCodecContext *avctx); > > VAAPI_ENCODE_RC_MODE(VBR, "Variable-bitrate"), \ > > VAAPI_ENCODE_RC_MODE(ICQ, "Intelligent constant-quality"), \ > > VAAPI_ENCODE_RC_MODE(QVBR, "Quality-defined variable-bitrate"), \ > > - VAAPI_ENCODE_RC_MODE(AVBR, "Average variable-bitrate") > > + VAAPI_ENCODE_RC_MODE(AVBR, "Average variable-bitrate"), \ > > + { "blbrc", \ > > + "Block level based bitrate control",\ > > + OFFSET(common.blbrc), AV_OPT_TYPE_BOOL, \ > > + { .i64 = 0 }, 0, 1, FLAGS } > > > > > > #endif /* AVCODEC_VAAPI_ENCODE_H */ > > LGTM, I will push this patch if there is no objection. Pushed. - 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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vulkan_av1: port to the new stable API
> > > -/* Workaround for a spec issue. > > - *Can be removed once no longer needed, and threading can be enabled. > */ > > +/* TODO: investigate if this can be removed to make decoding > completely > > + * independent. */ > > FFVulkanDecodeContext *dec; > > Can you explain what the id_alloc_mask thing is doing which needs this? (The > 32 size in particular seems suspicious.) This is for DPB slot management, 32 is the wrong limit, I think I just picked uint32_t and bitshifting as a quick option. We should limit this to maxDpbSlots I suspect, probably still use a uint32_t bitmask to track it. Dave. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_vulkan: check both vendor and PCI IDs
On Vr, 2024-03-08 at 15:13 +0800, Xiang, Haihao wrote: > From: Haihao Xiang > > Otherwise the derived device and the source device might have different > PCI ID or vendor ID in a multiple-device system. > > Signed-off-by: Haihao Xiang > --- > libavutil/hwcontext_vulkan.c | 31 +-- > 1 file changed, 29 insertions(+), 2 deletions(-) > > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c > index 855f099e26..9d94f74d78 100644 > --- a/libavutil/hwcontext_vulkan.c > +++ b/libavutil/hwcontext_vulkan.c > @@ -975,6 +975,20 @@ static int find_device(AVHWDeviceContext *ctx, > VulkanDeviceSelection *select) > select->name); > err = AVERROR(ENODEV); > goto end; > + } else if (select->vendor_id && select->pci_device) { > + av_log(ctx, AV_LOG_VERBOSE, "Requested vendor:device %04x:%04x\n", > + select->vendor_id, select->pci_device); > + for (int i = 0; i < num; i++) { > + if (select->vendor_id == prop[i].properties.vendorID && > + select->pci_device == prop[i].properties.deviceID) { > + choice = i; > + goto end; > + } > + } > + av_log(ctx, AV_LOG_ERROR, "Unable to find device with vendor ID 0x%x > " > + "and PCI ID 0x%x!\n", select->vendor_id, select->pci_device); > + err = AVERROR(EINVAL); > + goto end; > } else if (select->pci_device) { > av_log(ctx, AV_LOG_VERBOSE, "Requested device: 0x%x\n", select- > >pci_device); > for (int i = 0; i < num; i++) { > @@ -1597,8 +1611,14 @@ static int vulkan_device_derive(AVHWDeviceContext *ctx, > #if CONFIG_VAAPI > case AV_HWDEVICE_TYPE_VAAPI: { > AVVAAPIDeviceContext *src_hwctx = src_ctx->hwctx; > - > - const char *vendor = vaQueryVendorString(src_hwctx->display); > + VADisplay dpy = src_hwctx->display; > +#if VA_CHECK_VERSION(1, 15, 0) > + VAStatus vas; > + VADisplayAttribute attr = { > + .type = VADisplayPCIID, > + }; > +#endif > + const char *vendor = vaQueryVendorString(dpy); > if (!vendor) { > av_log(ctx, AV_LOG_ERROR, "Unable to get device info from > VAAPI!\n"); > return AVERROR_EXTERNAL; > @@ -1607,6 +1627,13 @@ static int vulkan_device_derive(AVHWDeviceContext *ctx, > if (strstr(vendor, "AMD")) > dev_select.vendor_id = 0x1002; > > +#if VA_CHECK_VERSION(1, 15, 0) > + vas = vaGetDisplayAttributes(dpy, &attr, 1); > + if (vas == VA_STATUS_SUCCESS && attr.flags != > VA_DISPLAY_ATTRIB_NOT_SUPPORTED) { > + dev_select.vendor_id = ((attr.value >> 16) & 0x); > + dev_select.pci_device = (attr.value & 0x); > + } > +#endif > return vulkan_device_create_internal(ctx, &dev_select, 0, opts, > flags); > } > #endif Hi, Any comment for this 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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/get_buffer: Add a warning on failed allocation from a fixed pool
On So, 2024-03-17 at 20:51 +, Mark Thompson wrote: > For hardware cases where we are forced to have a fixed pool of frames > allocated up-front (such as array textures on decoder output), suggest > a possible workaround to the user if an allocation fails because the > pool is exhausted. > --- > Perhaps helpful; any thoughts? > > The warning comes out before any errors, looking like: > > [mpeg2video @ 0x560ff51b4600] Failed to allocate a vaapi/nv12 frame from a > fixed pool of hardware frames. > [mpeg2video @ 0x560ff51b4600] Consider setting extra_hw_frames to a larger > value (currently set to 8, giving a pool size of 14). > [mpeg2video @ 0x560ff51b4600] get_buffer() failed > [vist#0:0/mpeg2video @ 0x560ff5199840] [dec:mpeg2video @ 0x560ff51b3b40] Error > submitting packet to decoder: Operation not permitted I'm OK to print such warning so user may know how to work around it. But now many cases are impacted by this error (e.g. https://trac.ffmpeg.org/ticket/10856 ), I think it is a regression to user. I still prefer to use a dynamic buffer pool instead fixed frame pool to avoid such error when the dynamic buffer pool can work. Thanks Haihao > > libavcodec/get_buffer.c | 16 > libavcodec/internal.h | 6 ++ > 2 files changed, 22 insertions(+) > > diff --git a/libavcodec/get_buffer.c b/libavcodec/get_buffer.c > index 46c20781af..9b35fde7c6 100644 > --- a/libavcodec/get_buffer.c > +++ b/libavcodec/get_buffer.c > @@ -257,6 +257,22 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, > AVFrame *frame, int flags > > if (avctx->hw_frames_ctx) { > ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0); > + if (ret == AVERROR(ENOMEM)) { > + AVHWFramesContext *frames_ctx = > + (AVHWFramesContext*)avctx->hw_frames_ctx->data; > + if (frames_ctx->initial_pool_size > 0 && > + !avctx->internal- > >warned_on_failed_allocation_from_fixed_pool) { > + av_log(avctx, AV_LOG_WARNING, "Failed to allocate a %s/%s " > + "frame from a fixed pool of hardware frames.\n", > + av_get_pix_fmt_name(frames_ctx->format), > + av_get_pix_fmt_name(frames_ctx->sw_format)); > + av_log(avctx, AV_LOG_WARNING, "Consider setting " > + "extra_hw_frames to a larger value " > + "(currently set to %d, giving a pool size of %d).\n", > + avctx->extra_hw_frames, frames_ctx- > >initial_pool_size); > + avctx->internal->warned_on_failed_allocation_from_fixed_pool > = 1; > + } > + } > frame->width = avctx->coded_width; > frame->height = avctx->coded_height; > return ret; > diff --git a/libavcodec/internal.h b/libavcodec/internal.h > index 04f7cebdcb..64fe0122c8 100644 > --- a/libavcodec/internal.h > +++ b/libavcodec/internal.h > @@ -144,6 +144,12 @@ typedef struct AVCodecInternal { > #if CONFIG_LCMS2 > FFIccContext icc; /* used to read and write embedded ICC profiles */ > #endif > + > + /** > + * Set when the user has been warned about a failed allocation from > + * a fixed frame pool. > + */ > + int warned_on_failed_allocation_from_fixed_pool; > } AVCodecInternal; > > /** ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 1/2] ffmpeg: set extra_hw_frames to account for frames held in queues
On So, 2024-03-17 at 20:49 +, Mark Thompson wrote: > Since e0da916b8f5b079a4865eef7f64863f50785463d the ffmpeg utility has > held multiple frames output by the decoder in internal queues without > telling the decoder that it is going to do so. When the decoder has a > fixed-size pool of frames (common in some hardware APIs where the output > frames must be stored as an array texture) this could lead to the pool > being exhausted and the decoder getting stuck. Fix this by telling the > decoder to allocate additional frames according to the queue size. > --- > Rebased but otherwise unchanged since previous version. > > fftools/ffmpeg_dec.c | 13 + > fftools/ffmpeg_sched.c | 16 +++- > fftools/ffmpeg_sched.h | 12 > 3 files changed, 40 insertions(+), 1 deletion(-) > > diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c > index c41c5748e5..ed411b6bf8 100644 > --- a/fftools/ffmpeg_dec.c > +++ b/fftools/ffmpeg_dec.c > @@ -1207,6 +1207,19 @@ static int dec_open(DecoderPriv *dp, AVDictionary > **dec_opts, > return ret; > } > > + if (dp->dec_ctx->hw_device_ctx) { > + // Update decoder extra_hw_frames option to account for the > + // frames held in queues inside the ffmpeg utility. This is > + // called after avcodec_open2() because the user-set value of > + // extra_hw_frames becomes valid in there, and we need to add > + // this on top of it. > + int extra_frames = DEFAULT_FRAME_THREAD_QUEUE_SIZE; > + if (dp->dec_ctx->extra_hw_frames >= 0) > + dp->dec_ctx->extra_hw_frames += extra_frames; > + else > + dp->dec_ctx->extra_hw_frames = extra_frames; > + } > + > ret = check_avoptions(*dec_opts); > if (ret < 0) > return ret; > diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c > index f739066921..ec88017e21 100644 > --- a/fftools/ffmpeg_sched.c > +++ b/fftools/ffmpeg_sched.c > @@ -365,7 +365,21 @@ static int queue_alloc(ThreadQueue **ptq, unsigned > nb_streams, unsigned queue_si > ThreadQueue *tq; > ObjPool *op; > > - queue_size = queue_size > 0 ? queue_size : 8; > + if (queue_size <= 0) { > + if (type == QUEUE_FRAMES) > + queue_size = DEFAULT_FRAME_THREAD_QUEUE_SIZE; > + else > + queue_size = DEFAULT_PACKET_THREAD_QUEUE_SIZE; > + } > + > + if (type == QUEUE_FRAMES) { > + // This queue length is used in the decoder code to ensure that > + // there are enough entries in fixed-size frame pools to account > + // for frames held in queues inside the ffmpeg utility. If this > + // can ever dynamically change then the corresponding decode > + // code needs to be updated as well. > + av_assert0(queue_size == DEFAULT_FRAME_THREAD_QUEUE_SIZE); > + } > > op = (type == QUEUE_PACKETS) ? objpool_alloc_packets() : > objpool_alloc_frames(); > diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h > index a9190bd3d1..e51c26cec9 100644 > --- a/fftools/ffmpeg_sched.h > +++ b/fftools/ffmpeg_sched.h > @@ -233,6 +233,18 @@ int sch_add_filtergraph(Scheduler *sch, unsigned > nb_inputs, unsigned nb_outputs, > */ > int sch_add_mux(Scheduler *sch, SchThreadFunc func, int (*init)(void *), > void *ctx, int sdp_auto, unsigned thread_queue_size); > + > +/** > + * Default size of a packet thread queue. For muxing this can be overridden > by > + * the thread_queue_size option as passed to a call to sch_add_mux(). > + */ > +#define DEFAULT_PACKET_THREAD_QUEUE_SIZE 8 > + > +/** > + * Default size of a frame thread queue. > + */ > +#define DEFAULT_FRAME_THREAD_QUEUE_SIZE 8 > + > /** > * Add a muxed stream for a previously added muxer. LGTM - 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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vulkan_av1: port to the new stable API
Mar 17, 2024, 16:36 by s...@jkqxz.net: > On 13/03/2024 16:38, Lynne wrote: > >> Tested by multiple users on multiple operating systems, >> driver implementations and test samples to work. >> >> Co-Authored-by: Dave Airlie >> >> From e2d31951f46fcc10e1263b8603e486e111e9578c Mon Sep 17 00:00:00 2001 >> From: Lynne >> Date: Fri, 19 Jan 2024 10:49:02 +1000 >> Subject: [PATCH v3 2/2] lavc/vulkan_av1: port to the new stable API >> >> Co-Authored-by: Dave Airlie >> --- >> configure | 4 +- >> libavcodec/Makefile | 5 +- >> libavcodec/av1.h | 2 + >> libavcodec/vulkan_av1.c | 502 ++ >> libavcodec/vulkan_decode.c| 31 +- >> libavcodec/vulkan_decode.h| 2 +- >> libavcodec/vulkan_video.h | 2 - >> .../vulkan_video_codec_av1std_decode_mesa.h | 36 -- >> libavcodec/vulkan_video_codec_av1std_mesa.h | 403 -- >> libavutil/hwcontext_vulkan.c | 2 +- >> libavutil/vulkan_functions.h | 2 +- >> libavutil/vulkan_loader.h | 2 +- >> 12 files changed, 300 insertions(+), 693 deletions(-) >> delete mode 100644 libavcodec/vulkan_video_codec_av1std_decode_mesa.h >> delete mode 100644 libavcodec/vulkan_video_codec_av1std_mesa.h >> >> diff --git a/configure b/configure >> index 05f8283af9..b07a742a74 100755 >> --- a/configure >> +++ b/configure >> @@ -7229,8 +7229,8 @@ enabled vdpau && >> check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 >> -lvdpau -lX11 >> >> if enabled vulkan; then >> -check_pkg_config_header_only vulkan "vulkan >= 1.3.255" >> "vulkan/vulkan.h" "defined VK_VERSION_1_3" || >> -check_cpp_condition vulkan "vulkan/vulkan.h" >> "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= >> 255)" >> +check_pkg_config_header_only vulkan "vulkan >= 1.3.277" >> "vulkan/vulkan.h" "defined VK_VERSION_1_3" || >> +check_cpp_condition vulkan "vulkan/vulkan.h" >> "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= >> 277)" >> > > This bumping the requirement to the latest version needs to stop at some > point. Vulkan is not an experimental thing any more, it should be usable in > released distributions. > The headers are a build-time dep that anyone can copy over without installing. Do you insist on making this optional? I'd rather not quite start ifdeffing code, but if you think so, I will. >> if disabled vulkan; then >> diff --git a/libavcodec/Makefile b/libavcodec/Makefile >> index 708434ac76..c552f034b7 100644 >> --- a/libavcodec/Makefile >> +++ b/libavcodec/Makefile >> @@ -1258,8 +1258,7 @@ SKIPHEADERS+= %_tablegen.h >> \ >> aacenc_quantization.h \ >> aacenc_quantization_misc.h\ >> bitstream_template.h \ >> - vulkan_video_codec_av1std_mesa.h \ >> - $(ARCH)/vpx_arith.h \ >> + $(ARCH)/vpx_arith.h \ >> >> SKIPHEADERS-$(CONFIG_AMF) += amfenc.h >> SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h >> @@ -1280,7 +1279,7 @@ SKIPHEADERS-$(CONFIG_QSVENC) += qsvenc.h >> SKIPHEADERS-$(CONFIG_VAAPI)+= vaapi_decode.h vaapi_hevc.h >> vaapi_encode.h >> SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h >> SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h >> -SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h >> vulkan_decode.h vulkan_video_codec_av1std_decode_mesa.h >> +SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h >> vulkan_decode.h >> SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h >> v4l2_m2m.h >> SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h >> >> diff --git a/libavcodec/av1.h b/libavcodec/av1.h >> index 8704bc41c1..18d5fa9e7f 100644 >> --- a/libavcodec/av1.h >> +++ b/libavcodec/av1.h >> @@ -121,6 +121,8 @@ enum { >> AV1_DIV_LUT_NUM = 257, >> >> AV1_MAX_LOOP_FILTER = 63, >> + >> +AV1_RESTORATION_TILESIZE_MAX = 256, >> > > ? This isn't used anywhere. > Removed. >> }; >> >> >> diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c >> index 5afd5353cc..dc71ecf1fa 100644 >> --- a/libavcodec/vulkan_av1.c >> +++ b/libavcodec/vulkan_av1.c >> @@ -26,7 +26,7 @@ >> const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = { >> .codec_id = AV_CODEC_ID_AV1, >> .decode_extension = FF_VK_EXT_VIDEO_DECODE_AV1, >> -.decode_op= 0x0100, /* TODO fix this */ >> +.decode_op= VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR, >> .ext_props = { >> .extensionName = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME, >> .specVersion = VK_STD_V
Re: [FFmpeg-devel] [PATCH v2 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile
On Fri, 2024-03-15 at 02:22 +, Xiang, Haihao wrote: > On Vr, 2024-03-08 at 16:47 +0800, fei.w.wang-at-intel@ffmpeg.org > wrote: > > From: Fei Wang > > > > According to Table A.2 in spec. > > > > Signed-off-by: Fei Wang > > --- > > libavcodec/vaapi_encode_h265.c | 181 +++ > > -- > > 1 file changed, 128 insertions(+), 53 deletions(-) > > > > diff --git a/libavcodec/vaapi_encode_h265.c > > b/libavcodec/vaapi_encode_h265.c > > index 43755e2188..7c9916eac8 100644 > > --- a/libavcodec/vaapi_encode_h265.c > > +++ b/libavcodec/vaapi_encode_h265.c > > @@ -258,6 +258,129 @@ fail: > > return err; > > } > > > > +static int vaapi_encode_h265_init_ptl(AVCodecContext *avctx) > > +{ > > +VAAPIEncodeContext *ctx = avctx->priv_data; > > +VAAPIEncodeH265Context *priv = avctx->priv_data; > > +H265RawVPS *vps = &priv->raw_vps; > > +H265RawProfileTierLevel *ptl = &vps->profile_tier_level; > > + > > +ptl->general_profile_space = 0; > > +ptl->general_profile_idc = avctx->profile; > > +ptl->general_tier_flag = priv->tier; > > + > > +ptl->general_profile_compatibility_flag[ptl- > > >general_profile_idc] = 1; > > + > > +if (ptl->general_profile_compatibility_flag[1]) > > +ptl->general_profile_compatibility_flag[2] = 1; > > +if (ptl->general_profile_compatibility_flag[3]) { > > +ptl->general_profile_compatibility_flag[1] = 1; > > +ptl->general_profile_compatibility_flag[2] = 1; > > +} > > + > > +ptl->general_progressive_source_flag= 1; > > +ptl->general_interlaced_source_flag = 0; > > +ptl->general_non_packed_constraint_flag = 1; > > +ptl->general_frame_only_constraint_flag = 1; > > + > > +if (avctx->profile >= 4) { > > +ptl->general_intra_constraint_flag= ctx- > > >gop_size == 1; > > +ptl->general_one_picture_only_constraint_flag = 0; > > +ptl->general_lower_bit_rate_constraint_flag = 1; > > + > > +switch (ctx->va_profile) { > > +#if VA_CHECK_VERSION(1, 2, 0) > > +case VAProfileHEVCMain12: > > +// Main 12 > > +ptl->general_max_14bit_constraint_flag = 0; > > There isn't a requirement about general_max_14bit_constraint_flag in > Table A.2, > it is unnecessary to set this flag here. Fixed in V3. Thanks Fei > > Thanks > Haihao > > > +ptl->general_max_12bit_constraint_flag = 1; > > +ptl->general_max_10bit_constraint_flag = 0; > > +ptl->general_max_8bit_constraint_flag = 0; > > +ptl->general_max_422chroma_constraint_flag = 1; > > +ptl->general_max_420chroma_constraint_flag = 1; > > +ptl->general_max_monochrome_constraint_flag = 0; > > +break; > > +case VAProfileHEVCMain422_10: > > +// Main 4:2:2 10 > > +ptl->general_max_14bit_constraint_flag = 0; > > +ptl->general_max_12bit_constraint_flag = 1; > > +ptl->general_max_10bit_constraint_flag = 1; > > +ptl->general_max_8bit_constraint_flag = 0; > > +ptl->general_max_422chroma_constraint_flag = 1; > > +ptl->general_max_420chroma_constraint_flag = 0; > > +ptl->general_max_monochrome_constraint_flag = 0; > > +break; > > +case VAProfileHEVCMain422_12: > > +// Main 4:2:2 12 > > +ptl->general_max_14bit_constraint_flag = 0; > > +ptl->general_max_12bit_constraint_flag = 1; > > +ptl->general_max_10bit_constraint_flag = 0; > > +ptl->general_max_8bit_constraint_flag = 0; > > +ptl->general_max_422chroma_constraint_flag = 1; > > +ptl->general_max_420chroma_constraint_flag = 0; > > +ptl->general_max_monochrome_constraint_flag = 0; > > +break; > > +case VAProfileHEVCMain444: > > +// Main 4:4:4 > > +ptl->general_max_14bit_constraint_flag = 0; > > +ptl->general_max_12bit_constraint_flag = 1; > > +ptl->general_max_10bit_constraint_flag = 1; > > +ptl->general_max_8bit_constraint_flag = 1; > > +ptl->general_max_422chroma_constraint_flag = 0; > > +ptl->general_max_420chroma_constraint_flag = 0; > > +ptl->general_max_monochrome_constraint_flag = 0; > > +break; > > +case VAProfileHEVCMain444_10: > > +// Main 4:4:4 10 > > +ptl->general_max_14bit_constraint_flag = 0; > > +ptl->general_max_12bit_constraint_flag = 1; > > +ptl->general_max_10bit_constraint_flag = 1; > > +ptl->general_max_8bit_constraint_flag = 0; > > +ptl->general_max_422chroma_constraint_flag = 0; > > +ptl->general_max_420chroma_constraint_flag = 0; > > +ptl->gener
[FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile
From: Fei Wang According to Table A.2 in spec. Signed-off-by: Fei Wang --- libavcodec/vaapi_encode_h265.c | 176 +++-- 1 file changed, 123 insertions(+), 53 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 43755e2188..5ed317ce11 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -258,6 +258,124 @@ fail: return err; } +static int vaapi_encode_h265_init_ptl(AVCodecContext *avctx) +{ +VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodeH265Context *priv = avctx->priv_data; +H265RawVPS *vps = &priv->raw_vps; +H265RawProfileTierLevel *ptl = &vps->profile_tier_level; + +ptl->general_profile_space = 0; +ptl->general_profile_idc = avctx->profile; +ptl->general_tier_flag = priv->tier; + +ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1; + +if (ptl->general_profile_compatibility_flag[1]) +ptl->general_profile_compatibility_flag[2] = 1; +if (ptl->general_profile_compatibility_flag[3]) { +ptl->general_profile_compatibility_flag[1] = 1; +ptl->general_profile_compatibility_flag[2] = 1; +} + +ptl->general_progressive_source_flag= 1; +ptl->general_interlaced_source_flag = 0; +ptl->general_non_packed_constraint_flag = 1; +ptl->general_frame_only_constraint_flag = 1; + +if (avctx->profile >= 4) { +ptl->general_intra_constraint_flag= ctx->gop_size == 1; +ptl->general_one_picture_only_constraint_flag = 0; +ptl->general_lower_bit_rate_constraint_flag = 1; +ptl->general_max_14bit_constraint_flag= 0; + +switch (ctx->va_profile) { +#if VA_CHECK_VERSION(1, 2, 0) +case VAProfileHEVCMain12: +// Main 12 +ptl->general_max_12bit_constraint_flag = 1; +ptl->general_max_10bit_constraint_flag = 0; +ptl->general_max_8bit_constraint_flag = 0; +ptl->general_max_422chroma_constraint_flag = 1; +ptl->general_max_420chroma_constraint_flag = 1; +ptl->general_max_monochrome_constraint_flag = 0; +break; +case VAProfileHEVCMain422_10: +// Main 4:2:2 10 +ptl->general_max_12bit_constraint_flag = 1; +ptl->general_max_10bit_constraint_flag = 1; +ptl->general_max_8bit_constraint_flag = 0; +ptl->general_max_422chroma_constraint_flag = 1; +ptl->general_max_420chroma_constraint_flag = 0; +ptl->general_max_monochrome_constraint_flag = 0; +break; +case VAProfileHEVCMain422_12: +// Main 4:2:2 12 +ptl->general_max_12bit_constraint_flag = 1; +ptl->general_max_10bit_constraint_flag = 0; +ptl->general_max_8bit_constraint_flag = 0; +ptl->general_max_422chroma_constraint_flag = 1; +ptl->general_max_420chroma_constraint_flag = 0; +ptl->general_max_monochrome_constraint_flag = 0; +break; +case VAProfileHEVCMain444: +// Main 4:4:4 +ptl->general_max_12bit_constraint_flag = 1; +ptl->general_max_10bit_constraint_flag = 1; +ptl->general_max_8bit_constraint_flag = 1; +ptl->general_max_422chroma_constraint_flag = 0; +ptl->general_max_420chroma_constraint_flag = 0; +ptl->general_max_monochrome_constraint_flag = 0; +break; +case VAProfileHEVCMain444_10: +// Main 4:4:4 10 +ptl->general_max_12bit_constraint_flag = 1; +ptl->general_max_10bit_constraint_flag = 1; +ptl->general_max_8bit_constraint_flag = 0; +ptl->general_max_422chroma_constraint_flag = 0; +ptl->general_max_420chroma_constraint_flag = 0; +ptl->general_max_monochrome_constraint_flag = 0; +break; +case VAProfileHEVCMain444_12: +// Main 4:4:4 12 +ptl->general_max_12bit_constraint_flag = 1; +ptl->general_max_10bit_constraint_flag = 0; +ptl->general_max_8bit_constraint_flag = 0; +ptl->general_max_422chroma_constraint_flag = 0; +ptl->general_max_420chroma_constraint_flag = 0; +ptl->general_max_monochrome_constraint_flag = 0; +break; +#endif +default: +av_log(avctx, AV_LOG_ERROR, "Unknown profile to init PTL.\n"); +return AVERROR(EINVAL); +} +} + +if (avctx->level != AV_LEVEL_UNKNOWN) { +ptl->general_level_idc = avctx->level; +} else { +const H265LevelDescriptor *level; + +level = ff_h265_guess_level(ptl, avctx->bit_rate, +ctx->surface_width, ctx->surface_height, +
[FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile
From: Fei Wang There is no Main8/10 profile defined in HEVC REXT profiles. Use Main12 which is compatible with 8/10bit. Signed-off-by: Fei Wang --- libavcodec/vaapi_encode_h265.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index c4aabbf5ed..43755e2188 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1305,12 +1305,12 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = { { AV_PROFILE_HEVC_MAIN, 8, 3, 1, 1, VAProfileHEVCMain }, -{ AV_PROFILE_HEVC_REXT, 8, 3, 1, 1, VAProfileHEVCMain }, #if VA_CHECK_VERSION(0, 37, 0) { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, VAProfileHEVCMain10 }, -{ AV_PROFILE_HEVC_REXT,10, 3, 1, 1, VAProfileHEVCMain10 }, #endif #if VA_CHECK_VERSION(1, 2, 0) +{ AV_PROFILE_HEVC_REXT, 8, 3, 1, 1, VAProfileHEVCMain12 }, +{ AV_PROFILE_HEVC_REXT,10, 3, 1, 1, VAProfileHEVCMain12 }, { AV_PROFILE_HEVC_REXT,12, 3, 1, 1, VAProfileHEVCMain12 }, { AV_PROFILE_HEVC_REXT, 8, 3, 1, 0, VAProfileHEVCMain422_10 }, { AV_PROFILE_HEVC_REXT,10, 3, 1, 0, VAProfileHEVCMain422_10 }, -- 2.25.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
Le 17 mars 2024 18:21:23 GMT-07:00, Timo Rothenpieler a écrit : >On 18.03.2024 01:32, Rémi Denis-Courmont wrote: >> >> >> Le 17 mars 2024 14:13:18 GMT-07:00, Timo Rothenpieler >> a écrit : >>> On 17.03.2024 18:37, Rémi Denis-Courmont wrote: Le 17 mars 2024 10:29:39 GMT-07:00, Andreas Rheinhardt a écrit : > Rémi Denis-Courmont: >> >> >> Le 16 mars 2024 13:58:23 GMT-07:00, James Almer a >> écrit : Seems the conflict comes from https://code.videolan.org/videolan/libbluray/-/blob/master/src/libbluray/disc/dec.c?ref_type=heads#L287 and https://github.com/FFmpeg/FFmpeg/commit/c4de5778bceab3c15f1239f1f16816749a7fd3b6 Perhaps you could also try asking libbluray if they could use an internal prefix. Otherwise you might need to do a rename of that function on ffmpeg's side. >>> >>> libbluray 100% needs to either prefix it, or hid it so it's not >>> exported. It's a library, so it should not be exporting such simple and >>> short unprefix named symbols. >> >> AFAICT, FFmpeg is just as guilty as Libbluray there. To support static >> linking, all non-static symbols should be name-spaced, and here both >> FFmpeg and libbluray are failing, and thus both should be fixed IMO. >> > > You forgot that FFmpeg's dec_init is in fftools/the executable, whereas > libbluray's is in the library. Oh well then it's 100% a problem with FFmpeg, or with the build system used by OP (Possibly a problem with Apple's tools). A static library being imported is not supposed to be able to cause symbol conflicts. >>> >>> A static library, as opposed to a shared one, has no concept of private >>> symbols. >>> The symbol already is not exported by libbr, but in the case of static >>> linking, there is no distinction between exported and hidden symbols. >> >> Yes. But an symbol from an import library is not supposed to conflict with a >> symbol from the executable (or library) being linked. Hence this looks like >> a bug in the FFmpeg build system (or whatever OP did with it). > >How would it be a bug in the ffmpeg build system? >What is it supposed to do? When statically linking, there simply is nothing >that can be done about it. Obviously not. Imported libraries are only there to resolve missing symbols. They don't and can't cause duplicate symbol errors when the build system and tools work correctly. >Again: static linking has no concept of public and private symbols. It's just >pulling in object files relatively mindlessly. You're confusing visibility, a notion specific to dynamic linking, with needed, undefined and duplicate symbols, which do exist regardless of static vs dynamic linking. This is clearly a bug in however OP is building FFmpeg. I don't know if that's a bug in FFmpeg proper or something else in OP's setup, but libbr is just the canary exposing a bug here. > >> Of course libbr should not leak unprefixed symbols regardless, but that's >> *not* the root cause. > >Yes, as long as they claim to support static linking, having such symbols is >definitely an issue on their side. Absolutely not. The issue on their side is that they implicitly rely on `-Bsymbolic` type behaviour which can't work with static linkage. That does not cause the linkage error here which **cannot** be libbr bug. >___ >ffmpeg-devel mailing list >ffmpeg-devel@ffmpeg.org >https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >To unsubscribe, visit link above, or email >ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC PATCH] avformat/rtpdec: Audio level RTP extension RFC6464
On Sat, Feb 10, 2024, at 9:30 PM, j...@jonb.org wrote: > From: Jonathan Baudanza > > libwebrtc will add audio level (in decibels) and VAD status to each RTP > packet. > > This patch will add both values to the packet sidedata. > > I've been using this patch in production for about a year on live audio RTP > streams to detect when users are speaking without needing to decode the audio > data. > Does anyone have any feedback on this patch? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
On 18.03.2024 01:32, Rémi Denis-Courmont wrote: Le 17 mars 2024 14:13:18 GMT-07:00, Timo Rothenpieler a écrit : On 17.03.2024 18:37, Rémi Denis-Courmont wrote: Le 17 mars 2024 10:29:39 GMT-07:00, Andreas Rheinhardt a écrit : Rémi Denis-Courmont: Le 16 mars 2024 13:58:23 GMT-07:00, James Almer a écrit : Seems the conflict comes from https://code.videolan.org/videolan/libbluray/-/blob/master/src/libbluray/disc/dec.c?ref_type=heads#L287 and https://github.com/FFmpeg/FFmpeg/commit/c4de5778bceab3c15f1239f1f16816749a7fd3b6 Perhaps you could also try asking libbluray if they could use an internal prefix. Otherwise you might need to do a rename of that function on ffmpeg's side. libbluray 100% needs to either prefix it, or hid it so it's not exported. It's a library, so it should not be exporting such simple and short unprefix named symbols. AFAICT, FFmpeg is just as guilty as Libbluray there. To support static linking, all non-static symbols should be name-spaced, and here both FFmpeg and libbluray are failing, and thus both should be fixed IMO. You forgot that FFmpeg's dec_init is in fftools/the executable, whereas libbluray's is in the library. Oh well then it's 100% a problem with FFmpeg, or with the build system used by OP (Possibly a problem with Apple's tools). A static library being imported is not supposed to be able to cause symbol conflicts. A static library, as opposed to a shared one, has no concept of private symbols. The symbol already is not exported by libbr, but in the case of static linking, there is no distinction between exported and hidden symbols. Yes. But an symbol from an import library is not supposed to conflict with a symbol from the executable (or library) being linked. Hence this looks like a bug in the FFmpeg build system (or whatever OP did with it). How would it be a bug in the ffmpeg build system? What is it supposed to do? When statically linking, there simply is nothing that can be done about it. Again: static linking has no concept of public and private symbols. It's just pulling in object files relatively mindlessly. Of course libbr should not leak unprefixed symbols regardless, but that's *not* the root cause. Yes, as long as they claim to support static linking, having such symbols is definitely an issue on their side. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avformat/aeadec: Export title
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavformat/aeadec.c | 15 --- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/libavformat/aeadec.c b/libavformat/aeadec.c > index 4cb2da6639..20170a89b3 100644 > --- a/libavformat/aeadec.c > +++ b/libavformat/aeadec.c > @@ -23,6 +23,7 @@ > #include "libavutil/channel_layout.h" > #include "libavutil/intreadwrite.h" > #include "avformat.h" > +#include "avio_internal.h" > #include "demux.h" > #include "pcm.h" > > @@ -59,12 +60,20 @@ static int aea_read_probe(const AVProbeData *p) > static int aea_read_header(AVFormatContext *s) > { > AVStream *st = avformat_new_stream(s, NULL); > -int channels; > +char title[256 + 1]; > +int channels, ret; > if (!st) > return AVERROR(ENOMEM); > > -/* Parse the amount of channels and skip to pos 2048(0x800) */ > -avio_skip(s->pb, 264); > +/* Read the title, parse the number of channels and skip to pos > 2048(0x800) */ > +avio_rl32(s->pb); // magic > +ret = ffio_read_size(s->pb, title, sizeof(title) - 1); > +if (ret < 0) > +return ret; > +title[sizeof(title) - 1] = '\0'; > +if (title[0] != '\0') > +av_dict_set(&st->metadata, "title", title, 0); > +avio_rl32(s->pb); // Block count > channels = avio_r8(s->pb); > avio_skip(s->pb, 1783); > Will apply this patchset tonight unless there are objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
Le 17 mars 2024 14:13:18 GMT-07:00, Timo Rothenpieler a écrit : >On 17.03.2024 18:37, Rémi Denis-Courmont wrote: >> >> >> Le 17 mars 2024 10:29:39 GMT-07:00, Andreas Rheinhardt >> a écrit : >>> Rémi Denis-Courmont: Le 16 mars 2024 13:58:23 GMT-07:00, James Almer a écrit : >> Seems the conflict comes from >> https://code.videolan.org/videolan/libbluray/-/blob/master/src/libbluray/disc/dec.c?ref_type=heads#L287 >>and >> https://github.com/FFmpeg/FFmpeg/commit/c4de5778bceab3c15f1239f1f16816749a7fd3b6 >> >> Perhaps you could also try asking libbluray if they could use an internal >> prefix. Otherwise you might need to do a rename of that function on >> ffmpeg's side. > > libbluray 100% needs to either prefix it, or hid it so it's not exported. > It's a library, so it should not be exporting such simple and short > unprefix named symbols. AFAICT, FFmpeg is just as guilty as Libbluray there. To support static linking, all non-static symbols should be name-spaced, and here both FFmpeg and libbluray are failing, and thus both should be fixed IMO. >>> >>> You forgot that FFmpeg's dec_init is in fftools/the executable, whereas >>> libbluray's is in the library. >> >> Oh well then it's 100% a problem with FFmpeg, or with the build system used >> by OP (Possibly a problem with Apple's tools). A static library being >> imported is not supposed to be able to cause symbol conflicts. > >A static library, as opposed to a shared one, has no concept of private >symbols. >The symbol already is not exported by libbr, but in the case of static >linking, there is no distinction between exported and hidden symbols. Yes. But an symbol from an import library is not supposed to conflict with a symbol from the executable (or library) being linked. Hence this looks like a bug in the FFmpeg build system (or whatever OP did with it). Of course libbr should not leak unprefixed symbols regardless, but that's *not* the root cause. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/mov_chan: respect channel order when parsing and creating chan atom
On Mon, 18 Mar 2024, Andreas Rheinhardt wrote: Marton Balint: Previously we always assumed that the channels are in native order, even if they were not. The new channel layout API allows us to signal the proper channel order, so let's do so. Fixes ticket #98. --- libavformat/mov_chan.c | 464 +++-- 1 file changed, 211 insertions(+), 253 deletions(-) diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c index ead3a9b91b..d48cfeabb0 100644 --- a/libavformat/mov_chan.c +++ b/libavformat/mov_chan.c @@ -25,228 +25,163 @@ #include +#include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavcodec/codec_id.h" #include "mov_chan.h" -struct MovChannelLayoutMap { -uint32_t tag; -uint64_t layout; -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_misc[] = { -{ MOV_CH_LAYOUT_USE_DESCRIPTIONS, 0 }, -{ MOV_CH_LAYOUT_USE_BITMAP, 0 }, -{ MOV_CH_LAYOUT_DISCRETEINORDER,0 }, -{ MOV_CH_LAYOUT_UNKNOWN,0 }, -{ MOV_CH_LAYOUT_TMH_10_2_STD, 0 }, // L, R, C,Vhc, Lsd, Rsd, - // Ls, Rs, Vhl, Vhr, Lw, Rw, - // Csd, Cs, LFE1, LFE2 -{ MOV_CH_LAYOUT_TMH_10_2_FULL, 0 }, // L, R, C,Vhc, Lsd, Rsd, - // Ls, Rs, Vhl, Vhr, Lw, Rw, - // Csd, Cs, LFE1, LFE2, Lc, Rc, - // HI, VI, Haptic -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_1ch[] = { -{ MOV_CH_LAYOUT_MONO, AV_CH_LAYOUT_MONO }, // C -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_2ch[] = { -{ MOV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_STEREO }, // L, R -{ MOV_CH_LAYOUT_STEREOHEADPHONES, AV_CH_LAYOUT_STEREO }, // L, R -{ MOV_CH_LAYOUT_BINAURAL, AV_CH_LAYOUT_STEREO }, // L, R -{ MOV_CH_LAYOUT_MIDSIDE,AV_CH_LAYOUT_STEREO }, // C, sides -{ MOV_CH_LAYOUT_XY, AV_CH_LAYOUT_STEREO }, // X (left), Y (right) - -{ MOV_CH_LAYOUT_MATRIXSTEREO, AV_CH_LAYOUT_STEREO_DOWNMIX }, // Lt, Rt - -{ MOV_CH_LAYOUT_AC3_1_0_1, AV_CH_LAYOUT_MONO |// C, LFE -AV_CH_LOW_FREQUENCY }, -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_3ch[] = { -{ MOV_CH_LAYOUT_MPEG_3_0_A, AV_CH_LAYOUT_SURROUND }, // L, R, C -{ MOV_CH_LAYOUT_MPEG_3_0_B, AV_CH_LAYOUT_SURROUND }, // C, L, R -{ MOV_CH_LAYOUT_AC3_3_0,AV_CH_LAYOUT_SURROUND }, // L, C, R - -{ MOV_CH_LAYOUT_ITU_2_1,AV_CH_LAYOUT_2_1 }, // L, R, Cs - -{ MOV_CH_LAYOUT_DVD_4, AV_CH_LAYOUT_2POINT1 }, // L, R, LFE -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_4ch[] = { -{ MOV_CH_LAYOUT_AMBISONIC_B_FORMAT, 0 },// W, X, Y, Z - -{ MOV_CH_LAYOUT_QUADRAPHONIC, AV_CH_LAYOUT_QUAD}, // L, R, Rls, Rrs - -{ MOV_CH_LAYOUT_MPEG_4_0_A, AV_CH_LAYOUT_4POINT0 }, // L, R, C, Cs -{ MOV_CH_LAYOUT_MPEG_4_0_B, AV_CH_LAYOUT_4POINT0 }, // C, L, R, Cs -{ MOV_CH_LAYOUT_AC3_3_1,AV_CH_LAYOUT_4POINT0 }, // L, C, R, Cs - -{ MOV_CH_LAYOUT_ITU_2_2,AV_CH_LAYOUT_2_2 }, // L, R, Ls, Rs - -{ MOV_CH_LAYOUT_DVD_5, AV_CH_LAYOUT_2_1 | // L, R, LFE, Cs -AV_CH_LOW_FREQUENCY }, -{ MOV_CH_LAYOUT_AC3_2_1_1, AV_CH_LAYOUT_2_1 | // L, R, Cs, LFE -AV_CH_LOW_FREQUENCY }, - -{ MOV_CH_LAYOUT_DVD_10, AV_CH_LAYOUT_3POINT1 }, // L, R, C, LFE -{ MOV_CH_LAYOUT_AC3_3_0_1, AV_CH_LAYOUT_3POINT1 }, // L, C, R, LFE -{ MOV_CH_LAYOUT_DTS_3_1,AV_CH_LAYOUT_3POINT1 }, // C, L, R, LFE -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_5ch[] = { -{ MOV_CH_LAYOUT_PENTAGONAL, AV_CH_LAYOUT_5POINT0_BACK }, // L, R, Rls, Rrs, C - -{ MOV_CH_LAYOUT_MPEG_5_0_A, AV_CH_LAYOUT_5POINT0 }, // L, R, C, Ls, Rs -{ MOV_CH_LAYOUT_MPEG_5_0_B, AV_CH_LAYOUT_5POINT0 }, // L, R, Ls, Rs, C -{ MOV_CH_LAYOUT_MPEG_5_0_C, AV_CH_LAYOUT_5POINT0 }, // L, C, R, Ls, Rs -{ MOV_CH_LAYOUT_MPEG_5_0_D, AV_CH_LAYOUT_5POINT0 }, // C, L, R, Ls, Rs - -{ MOV_CH_LAYOUT_DVD_6, AV_CH_LAYOUT_2_2 | // L, R, LFE, Ls, Rs -AV_CH_LOW_FREQUENCY }, -{ MOV_CH_LAYOUT_DVD_18, AV_CH_LAYOUT_2_2 | // L, R, Ls, Rs, LFE -AV_CH_LOW_FREQUENCY }, - -{ MOV_CH_LAYOUT_DVD_11, AV
Re: [FFmpeg-devel] [PATCH] avformat/mov_chan: respect channel order when parsing and creating chan atom
Marton Balint: > Previously we always assumed that the channels are in native order, even if > they were not. The new channel layout API allows us to signal the proper > channel order, so let's do so. > > Fixes ticket #98. > --- > libavformat/mov_chan.c | 464 +++-- > 1 file changed, 211 insertions(+), 253 deletions(-) > > diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c > index ead3a9b91b..d48cfeabb0 100644 > --- a/libavformat/mov_chan.c > +++ b/libavformat/mov_chan.c > @@ -25,228 +25,163 @@ > > #include > > +#include "libavutil/avassert.h" > #include "libavutil/channel_layout.h" > #include "libavcodec/codec_id.h" > #include "mov_chan.h" > > -struct MovChannelLayoutMap { > -uint32_t tag; > -uint64_t layout; > -}; > - > -static const struct MovChannelLayoutMap mov_ch_layout_map_misc[] = { > -{ MOV_CH_LAYOUT_USE_DESCRIPTIONS, 0 }, > -{ MOV_CH_LAYOUT_USE_BITMAP, 0 }, > -{ MOV_CH_LAYOUT_DISCRETEINORDER,0 }, > -{ MOV_CH_LAYOUT_UNKNOWN,0 }, > -{ MOV_CH_LAYOUT_TMH_10_2_STD, 0 }, // L, R, C,Vhc, Lsd, Rsd, > - // Ls, Rs, Vhl, Vhr, Lw, Rw, > - // Csd, Cs, LFE1, LFE2 > -{ MOV_CH_LAYOUT_TMH_10_2_FULL, 0 }, // L, R, C,Vhc, Lsd, > Rsd, > - // Ls, Rs, Vhl, Vhr, Lw, Rw, > - // Csd, Cs, LFE1, LFE2, Lc, Rc, > - // HI, VI, Haptic > -{ 0, 0 }, > -}; > - > -static const struct MovChannelLayoutMap mov_ch_layout_map_1ch[] = { > -{ MOV_CH_LAYOUT_MONO, AV_CH_LAYOUT_MONO }, // C > -{ 0, 0 }, > -}; > - > -static const struct MovChannelLayoutMap mov_ch_layout_map_2ch[] = { > -{ MOV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_STEREO }, // L, > R > -{ MOV_CH_LAYOUT_STEREOHEADPHONES, AV_CH_LAYOUT_STEREO }, // L, > R > -{ MOV_CH_LAYOUT_BINAURAL, AV_CH_LAYOUT_STEREO }, // L, > R > -{ MOV_CH_LAYOUT_MIDSIDE,AV_CH_LAYOUT_STEREO }, // C, > sides > -{ MOV_CH_LAYOUT_XY, AV_CH_LAYOUT_STEREO }, // X > (left), Y (right) > - > -{ MOV_CH_LAYOUT_MATRIXSTEREO, AV_CH_LAYOUT_STEREO_DOWNMIX }, // > Lt, Rt > - > -{ MOV_CH_LAYOUT_AC3_1_0_1, AV_CH_LAYOUT_MONO |// C, > LFE > -AV_CH_LOW_FREQUENCY }, > -{ 0, 0 }, > -}; > - > -static const struct MovChannelLayoutMap mov_ch_layout_map_3ch[] = { > -{ MOV_CH_LAYOUT_MPEG_3_0_A, AV_CH_LAYOUT_SURROUND }, // L, R, C > -{ MOV_CH_LAYOUT_MPEG_3_0_B, AV_CH_LAYOUT_SURROUND }, // C, L, R > -{ MOV_CH_LAYOUT_AC3_3_0,AV_CH_LAYOUT_SURROUND }, // L, C, R > - > -{ MOV_CH_LAYOUT_ITU_2_1,AV_CH_LAYOUT_2_1 }, // L, R, Cs > - > -{ MOV_CH_LAYOUT_DVD_4, AV_CH_LAYOUT_2POINT1 }, // L, R, LFE > -{ 0, 0 }, > -}; > - > -static const struct MovChannelLayoutMap mov_ch_layout_map_4ch[] = { > -{ MOV_CH_LAYOUT_AMBISONIC_B_FORMAT, 0 },// W, X, Y, Z > - > -{ MOV_CH_LAYOUT_QUADRAPHONIC, AV_CH_LAYOUT_QUAD}, // L, R, > Rls, Rrs > - > -{ MOV_CH_LAYOUT_MPEG_4_0_A, AV_CH_LAYOUT_4POINT0 }, // L, R, C, > Cs > -{ MOV_CH_LAYOUT_MPEG_4_0_B, AV_CH_LAYOUT_4POINT0 }, // C, L, R, > Cs > -{ MOV_CH_LAYOUT_AC3_3_1,AV_CH_LAYOUT_4POINT0 }, // L, C, R, > Cs > - > -{ MOV_CH_LAYOUT_ITU_2_2,AV_CH_LAYOUT_2_2 }, // L, R, Ls, > Rs > - > -{ MOV_CH_LAYOUT_DVD_5, AV_CH_LAYOUT_2_1 | // L, R, > LFE, Cs > -AV_CH_LOW_FREQUENCY }, > -{ MOV_CH_LAYOUT_AC3_2_1_1, AV_CH_LAYOUT_2_1 | // L, R, Cs, > LFE > -AV_CH_LOW_FREQUENCY }, > - > -{ MOV_CH_LAYOUT_DVD_10, AV_CH_LAYOUT_3POINT1 }, // L, R, C, > LFE > -{ MOV_CH_LAYOUT_AC3_3_0_1, AV_CH_LAYOUT_3POINT1 }, // L, C, R, > LFE > -{ MOV_CH_LAYOUT_DTS_3_1,AV_CH_LAYOUT_3POINT1 }, // C, L, R, > LFE > -{ 0, 0 }, > -}; > - > -static const struct MovChannelLayoutMap mov_ch_layout_map_5ch[] = { > -{ MOV_CH_LAYOUT_PENTAGONAL, AV_CH_LAYOUT_5POINT0_BACK }, // L, > R, Rls, Rrs, C > - > -{ MOV_CH_LAYOUT_MPEG_5_0_A, AV_CH_LAYOUT_5POINT0 }, // L, > R, C, Ls, Rs > -{ MOV_CH_LAYOUT_MPEG_5_0_B, AV_CH_LAYOUT_5POINT0 }, // L, > R, Ls, Rs, C > -{ MOV_CH_LAYOUT_MPEG_5_0_C, AV_CH_LAYOUT_5POINT0 }, // L, > C, R, Ls, Rs > -{ MOV_CH_LAYOUT_MPEG_5_0_D, AV_CH_LAYOUT_5POINT0 }, // C, > L, R, Ls, Rs > - > -{ MOV_CH_LAYOUT_DVD_6, AV_CH_LAYOUT_2_2 | // L, > R, LFE, Ls, Rs > -AV_CH_LO
Re: [FFmpeg-devel] [PATCH] change av_ts_make_time_string precision
On Wed, 13 Mar 2024, Allan Cady via ffmpeg-devel wrote: On Tuesday, March 12, 2024 at 02:24:47 PM PDT, Marton Balint wrote: On Tue, 12 Mar 2024, Allan Cady via ffmpeg-devel wrote: On Monday, March 11, 2024 at 12:11:45 PM PDT, Marton Balint wrote: On Mon, 11 Mar 2024, Andreas Rheinhardt wrote: Allan Cady via ffmpeg-devel: From: "Allan Cady" [...] One thing to notice is that you will not need to use the scientific representation at all, because maximum value this function prints is the product of an INT32 and an INT64, and that is 96 bit, which is at most 29 chars. Adding the optional sign and the decimal point, that is still only 31. So we can be sure that by using %.6f, the first character of the decimal point is going to be present in the output. I had done some similar calculation and came to a similar conclusion. Which is great, because that means we only have to - do a single snprintf("%.6f") - calculate last char position by subtracting 1 from the minimum of AV_TS_MAX_STRING_SIZE-1 and the result of the snprintf() call. - decrement string length while last char is '0' to remove trailing 0s - decrement string length while last char is non-digit to remove decimal point (which can be a multiple chars for some locales). - update last+1 char to \0. Ot is it still too complex to keep it inline? I'll give your suggestion a spin tomorrow. Thanks. In the end I posted a patch myself, sorry if you were working on it too, it just looked a bit too complex for a new developer, since it touched API/build system/etc... I hope you don't mind. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avutil/timestamp: keep microsecond precision in av_ts_make_time_string
av_ts_make_time_string() used "%.6g" format in the past, but this format was losing precision even when the timestamp to be printed was not that large. For example for 3 hours (10800) seconds, only 1 decimal digit was printed, which made this format inaccurate when it was used in e.g. the silencedetect filter. Other detection filters printing timestamps had similar issues. So let's change the used format to "%.6f" instead, we have plenty of space in the string buffer, we can somewhat imitate existing behaviour of %g by trimming ending zeroes and the potential decimal point, which can be any non-numeric character. In order not to trim "inf" as well, we assume that the decimal point does not contain the letter "f". We also no longer use scientific representation to make parsing and printing easier, because the theoretical maximum of INT64_MAX*INT32_MAX still fits into the string buffer in normal form. Since the additional processing yields more code, inlineing this function no longer make sense, so this commit also changes the API to actually export the function instead of having it inlinable in the header. Thanks for Allan Cady for bringing up this issue. Signed-off-by: Marton Balint --- doc/APIchanges | 3 ++ libavutil/Makefile | 1 + libavutil/timestamp.c| 33 libavutil/timestamp.h| 8 + libavutil/version.h | 2 +- tests/ref/fate/filter-metadata-scdet | 12 +++ tests/ref/fate/filter-metadata-silencedetect | 2 +- 7 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 libavutil/timestamp.c diff --git a/doc/APIchanges b/doc/APIchanges index a44c8e4f10..1afde062a5 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-03-xx - xx - lavu 59.3.100 - timestamp.h + av_ts_make_time_string() is no longer an inline function. It is now exported. + 2024-03-xx - xx - lavu 59.2.100 - channel_layout.h Add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL. diff --git a/libavutil/Makefile b/libavutil/Makefile index e7709b97d0..5e75aa1855 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -174,6 +174,7 @@ OBJS = adler32.o \ threadmessage.o \ time.o \ timecode.o \ + timestamp.o \ tree.o \ twofish.o\ utils.o \ diff --git a/libavutil/timestamp.c b/libavutil/timestamp.c new file mode 100644 index 00..06fb47e94c --- /dev/null +++ b/libavutil/timestamp.c @@ -0,0 +1,33 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "timestamp.h" + +char *av_ts_make_time_string(char *buf, int64_t ts, const AVRational *tb) +{ +if (ts == AV_NOPTS_VALUE) { +snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS"); +} else { +int last = snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.6f", av_q2d(*tb) * ts); +last = FFMIN(last, AV_TS_MAX_STRING_SIZE - 1) - 1; +for (; last && buf[last] == '0'; last--); +for (; last && buf[last] != 'f' && (buf[last] < '0' || buf[0] > '9'); last--); +buf[last + 1] = '\0'; +} +return buf; +} diff --git a/libavutil/timestamp.h b/libavutil/timestamp.h index 2b37781eba..a02d873060 100644 --- a/libavutil/timestamp.h +++ b/libavutil/timestamp.h @@ -62,13 +62,7 @@ static inline char *av_ts_make_string(char *buf, int64_t ts) * @param tb the timebase of the timestamp * @return the buffer in input */ -static inline char *av_ts_make_time_string(char *buf, int64_t ts, - const AVRational *tb) -{ -if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS"); -else
Re: [FFmpeg-devel] [PATCH v4 1/6] avcodec: add av_jni_{get, set}_android_app_ctx helper
On Sun, Mar 17, 2024 at 11:38 PM Andreas Rheinhardt wrote: > > Matthieu Bouron: > > This will allow users to pass the Android ApplicationContext which is > > mandatory > > to retrieve the ContentResolver responsible to resolve/open Android > > content-uri. > > --- > > doc/APIchanges | 3 +++ > > libavcodec/jni.c | 42 ++ > > libavcodec/jni.h | 17 + > > 3 files changed, 62 insertions(+) > > > > diff --git a/doc/APIchanges b/doc/APIchanges > > index a44c8e4f10..ae1868047e 100644 > > --- a/doc/APIchanges > > +++ b/doc/APIchanges > > @@ -2,6 +2,9 @@ The last version increases of all libraries were on > > 2024-03-07 > > > > API changes, most recent first: > > > > +2024-03-xx - xx - lavc 61.2.100 - jni.h > > + Add av_jni_set_android_app_ctx() and av_jni_get_android_app_ctx(). > > + > > 2024-03-xx - xx - lavu 59.2.100 - channel_layout.h > >Add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL. > > > > diff --git a/libavcodec/jni.c b/libavcodec/jni.c > > index ae6490de9d..cfe95bd1ec 100644 > > --- a/libavcodec/jni.c > > +++ b/libavcodec/jni.c > > @@ -77,3 +77,45 @@ void *av_jni_get_java_vm(void *log_ctx) > > } > > > > #endif > > + > > +#if defined(__ANDROID__) > > + > > +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx) > > +{ > > +#if CONFIG_JNI > > +JNIEnv *env = ff_jni_get_env(log_ctx); > > +if (!env) > > +return AVERROR(EINVAL); > > + > > +jobjectRefType type = (*env)->GetObjectRefType(env, app_ctx); > > +if (type != JNIGlobalRefType) { > > +av_log(log_ctx, AV_LOG_ERROR, "Application context must be passed > > as a global reference"); > > +return AVERROR(EINVAL); > > +} > > + > > +pthread_mutex_lock(&lock); > > +android_app_ctx = app_ctx; > > +pthread_mutex_unlock(&lock); > > + > > +return 0; > > +#else > > +return AVERROR(ENOSYS); > > +#endif > > +} > > + > > +void *av_jni_get_android_app_ctx(void) > > +{ > > +#if CONFIG_JNI > > +void *ctx; > > + > > +pthread_mutex_lock(&lock); > > +ctx = android_app_ctx; > > +pthread_mutex_unlock(&lock); > > + > > +return ctx; > > +#else > > +return NULL; > > +#endif > > +} > > + > > +#endif > > diff --git a/libavcodec/jni.h b/libavcodec/jni.h > > index dd99e92611..da8025f830 100644 > > --- a/libavcodec/jni.h > > +++ b/libavcodec/jni.h > > @@ -43,4 +43,21 @@ int av_jni_set_java_vm(void *vm, void *log_ctx); > > */ > > void *av_jni_get_java_vm(void *log_ctx); > > > > +/* > > + * Set the Android application context which will be used to retrieve the > > Android > > + * content resolver to resolve content uris. > > + * > > + * @param app_ctx global JNI reference to the Android application context > > + * @return 0 on success, < 0 otherwise > > + */ > > +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx); > > + > > +/* > > + * Get the Android application context that has been set with > > + * av_jni_set_android_app_ctx. > > + * > > + * @return a pointer the the Android application context > > + */ > > +void *av_jni_get_android_app_ctx(void); > > This should mention that these functions are only available on android. Added the following chunk locally to both functions: * + * This function is only available on Android. + * ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 1/6] avcodec: add av_jni_{get, set}_android_app_ctx helper
Matthieu Bouron: > This will allow users to pass the Android ApplicationContext which is > mandatory > to retrieve the ContentResolver responsible to resolve/open Android > content-uri. > --- > doc/APIchanges | 3 +++ > libavcodec/jni.c | 42 ++ > libavcodec/jni.h | 17 + > 3 files changed, 62 insertions(+) > > diff --git a/doc/APIchanges b/doc/APIchanges > index a44c8e4f10..ae1868047e 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 > > API changes, most recent first: > > +2024-03-xx - xx - lavc 61.2.100 - jni.h > + Add av_jni_set_android_app_ctx() and av_jni_get_android_app_ctx(). > + > 2024-03-xx - xx - lavu 59.2.100 - channel_layout.h >Add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL. > > diff --git a/libavcodec/jni.c b/libavcodec/jni.c > index ae6490de9d..cfe95bd1ec 100644 > --- a/libavcodec/jni.c > +++ b/libavcodec/jni.c > @@ -77,3 +77,45 @@ void *av_jni_get_java_vm(void *log_ctx) > } > > #endif > + > +#if defined(__ANDROID__) > + > +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx) > +{ > +#if CONFIG_JNI > +JNIEnv *env = ff_jni_get_env(log_ctx); > +if (!env) > +return AVERROR(EINVAL); > + > +jobjectRefType type = (*env)->GetObjectRefType(env, app_ctx); > +if (type != JNIGlobalRefType) { > +av_log(log_ctx, AV_LOG_ERROR, "Application context must be passed as > a global reference"); > +return AVERROR(EINVAL); > +} > + > +pthread_mutex_lock(&lock); > +android_app_ctx = app_ctx; > +pthread_mutex_unlock(&lock); > + > +return 0; > +#else > +return AVERROR(ENOSYS); > +#endif > +} > + > +void *av_jni_get_android_app_ctx(void) > +{ > +#if CONFIG_JNI > +void *ctx; > + > +pthread_mutex_lock(&lock); > +ctx = android_app_ctx; > +pthread_mutex_unlock(&lock); > + > +return ctx; > +#else > +return NULL; > +#endif > +} > + > +#endif > diff --git a/libavcodec/jni.h b/libavcodec/jni.h > index dd99e92611..da8025f830 100644 > --- a/libavcodec/jni.h > +++ b/libavcodec/jni.h > @@ -43,4 +43,21 @@ int av_jni_set_java_vm(void *vm, void *log_ctx); > */ > void *av_jni_get_java_vm(void *log_ctx); > > +/* > + * Set the Android application context which will be used to retrieve the > Android > + * content resolver to resolve content uris. > + * > + * @param app_ctx global JNI reference to the Android application context > + * @return 0 on success, < 0 otherwise > + */ > +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx); > + > +/* > + * Get the Android application context that has been set with > + * av_jni_set_android_app_ctx. > + * > + * @return a pointer the the Android application context > + */ > +void *av_jni_get_android_app_ctx(void); This should mention that these functions are only available on android. > + > #endif /* AVCODEC_JNI_H */ ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 2/6] avformat: add Android content resolver protocol support
On Sun, Mar 17, 2024 at 12:33:04PM +0800, Zhao Zhili wrote: > Sorry for the long delay of review. > > > On Mar 5, 2024, at 03:37, Matthieu Bouron wrote: > > > > On Tue, Feb 27, 2024 at 03:50:38PM +0100, Matthieu Bouron wrote: > >> Handles Android content-uri starting with content://. > >> --- > > > > [...] > > > > > Handles Android content-uri starting with content://. > > --- > > configure | 2 + > > doc/APIchanges | 3 + > > libavcodec/jni.c| 1 + > > libavformat/Makefile| 1 + > > libavformat/file.c | 157 > > libavformat/protocols.c | 1 + > > 6 files changed, 165 insertions(+) > > > > diff --git a/configure b/configure > > index bb5e630bad..790a1df7c8 100755 > > --- a/configure > > +++ b/configure > > @@ -3655,6 +3655,8 @@ xcbgrab_indev_suggest="libxcb_shm libxcb_shape > > libxcb_xfixes" > > xv_outdev_deps="xlib_xv xlib_x11 xlib_xext" > > > > # protocols > > +android_content_protocol_deps="jni" > > +android_content_protocol_select="file_protocol" > > async_protocol_deps="threads" > > bluray_protocol_deps="libbluray" > > ffrtmpcrypt_protocol_conflict="librtmp_protocol" > > diff --git a/doc/APIchanges b/doc/APIchanges > > index 10f6667e9e..258e953ca6 100644 > > --- a/doc/APIchanges > > +++ b/doc/APIchanges > > @@ -2,6 +2,9 @@ The last version increases of all libraries were on > > 2023-02-09 > > > > API changes, most recent first: > > > > +2024-02-xx - xx - lavc 60.41.100 - jni.h > > + Add av_jni_set_android_app_ctx() and av_jni_get_android_app_ctx(). > > Should be added together with patch 1/6. Fixed. > > > + > > 2024-02-26 - xx - lavf 60.22.101 - avformat.h > >AV_DISPOSITION_DEPENDENT may now also be used for video streams > >intended to be merged with other video streams for presentation. > > diff --git a/libavcodec/jni.c b/libavcodec/jni.c > > index cfe95bd1ec..1193c608c3 100644 > > --- a/libavcodec/jni.c > > +++ b/libavcodec/jni.c > > @@ -35,6 +35,7 @@ > > #include "ffjni.h" > > > > static void *java_vm; > > +static void *android_app_ctx; > > static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; > > > > int av_jni_set_java_vm(void *vm, void *log_ctx) > > diff --git a/libavformat/Makefile b/libavformat/Makefile > > index 4a380668bd..08fe98a535 100644 > > --- a/libavformat/Makefile > > +++ b/libavformat/Makefile > > @@ -657,6 +657,7 @@ OBJS-$(CONFIG_LIBOPENMPT_DEMUXER)+= libopenmpt.o > > OBJS-$(CONFIG_VAPOURSYNTH_DEMUXER) += vapoursynth.o > > > > # protocols I/O > > +OBJS-$(CONFIG_ANDROID_CONTENT_PROTOCOL) += file.o > > OBJS-$(CONFIG_ASYNC_PROTOCOL)+= async.o > > OBJS-$(CONFIG_APPLEHTTP_PROTOCOL)+= hlsproto.o > > OBJS-$(CONFIG_BLURAY_PROTOCOL) += bluray.o > > diff --git a/libavformat/file.c b/libavformat/file.c > > index 64df7ff6fb..1b2b69f090 100644 > > --- a/libavformat/file.c > > +++ b/libavformat/file.c > > @@ -40,6 +40,12 @@ > > #include > > #include "os_support.h" > > #include "url.h" > > +#if CONFIG_ANDROID_CONTENT_PROTOCOL > > +#include > > +#include "libavcodec/jni.h" > > +#include "libavcodec/ffjni.c" > > +#endif > > + > > > > /* Some systems may not have S_ISFIFO */ > > #ifndef S_ISFIFO > > @@ -101,6 +107,21 @@ typedef struct FileContext { > > int64_t initial_pos; > > } FileContext; > > > > + > > +#if CONFIG_ANDROID_CONTENT_PROTOCOL > > +static const AVOption android_content_options[] = { > > +{ "blocksize", "set I/O operation maximum block size", > > offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, > > INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, > > +{ NULL } > > +}; > > + > > +static const AVClass android_content_class = { > > +.class_name = "android_content", > > +.item_name = av_default_item_name, > > +.option = android_content_options, > > +.version= LIBAVUTIL_VERSION_INT, > > +}; > > +#endif > > + > > static const AVOption file_options[] = { > > { "truncate", "truncate existing files on write", > > offsetof(FileContext, trunc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, > > AV_OPT_FLAG_ENCODING_PARAM }, > > { "blocksize", "set I/O operation maximum block size", > > offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, > > INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, > > @@ -524,3 +545,139 @@ const URLProtocol ff_fd_protocol = { > > }; > > > > #endif /* CONFIG_FD_PROTOCOL */ > > + > > +#if CONFIG_ANDROID_CONTENT_PROTOCOL > > + > > +struct JFields { > > +jclass uri_class; > > +jmethodID parse_id; > > + > > +jclass context_class; > > +jmethodID get_content_resolver_id; > > + > > +jclass content_resolver_class; > > +jmethodID open_file_descriptor_id; > > + > > +jclass parcel_file_descriptor_class; > > +jmethodID detach_fd_id; > > +}; > > typedef struct is the preferred coding style of FFmpeg, it’s mentioned in > developer.texi. Fixed. > > > + > > +#def
[FFmpeg-devel] [PATCH v4 6/6] avcodec/mediacodec_wrapper: remove unnecessary NULL checks before calling Delete{Global, Local}Ref()
Delete{Global,Local}Ref already handle NULL. --- libavcodec/mediacodec_wrapper.c | 189 1 file changed, 47 insertions(+), 142 deletions(-) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index 78cd28f53d..306359071e 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -549,10 +549,8 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e goto done; } -if (codec_name) { -(*env)->DeleteLocalRef(env, codec_name); -codec_name = NULL; -} +(*env)->DeleteLocalRef(env, codec_name); +codec_name = NULL; /* Skip software decoders */ if ( @@ -616,10 +614,8 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e found_codec = profile == supported_profile; -if (profile_level) { -(*env)->DeleteLocalRef(env, profile_level); -profile_level = NULL; -} +(*env)->DeleteLocalRef(env, profile_level); +profile_level = NULL; if (found_codec) { break; @@ -627,20 +623,14 @@ char *ff_AMediaCodecList_getCodecNameByType(const char *mime, int profile, int e } done_with_type: -if (profile_levels) { -(*env)->DeleteLocalRef(env, profile_levels); -profile_levels = NULL; -} +(*env)->DeleteLocalRef(env, profile_levels); +profile_levels = NULL; -if (capabilities) { -(*env)->DeleteLocalRef(env, capabilities); -capabilities = NULL; -} +(*env)->DeleteLocalRef(env, capabilities); +capabilities = NULL; -if (type) { -(*env)->DeleteLocalRef(env, type); -type = NULL; -} +(*env)->DeleteLocalRef(env, type); +type = NULL; av_freep(&supported_type); @@ -650,15 +640,11 @@ done_with_type: } done_with_info: -if (info) { -(*env)->DeleteLocalRef(env, info); -info = NULL; -} +(*env)->DeleteLocalRef(env, info); +info = NULL; -if (types) { -(*env)->DeleteLocalRef(env, types); -types = NULL; -} +(*env)->DeleteLocalRef(env, types); +types = NULL; if (found_codec) { break; @@ -668,33 +654,13 @@ done_with_info: } done: -if (codec_name) { -(*env)->DeleteLocalRef(env, codec_name); -} - -if (info) { -(*env)->DeleteLocalRef(env, info); -} - -if (type) { -(*env)->DeleteLocalRef(env, type); -} - -if (types) { -(*env)->DeleteLocalRef(env, types); -} - -if (capabilities) { -(*env)->DeleteLocalRef(env, capabilities); -} - -if (profile_level) { -(*env)->DeleteLocalRef(env, profile_level); -} - -if (profile_levels) { -(*env)->DeleteLocalRef(env, profile_levels); -} +(*env)->DeleteLocalRef(env, codec_name); +(*env)->DeleteLocalRef(env, info); +(*env)->DeleteLocalRef(env, type); +(*env)->DeleteLocalRef(env, types); +(*env)->DeleteLocalRef(env, capabilities); +(*env)->DeleteLocalRef(env, profile_level); +(*env)->DeleteLocalRef(env, profile_levels); av_freep(&supported_type); @@ -741,9 +707,7 @@ static FFAMediaFormat *mediaformat_jni_new(void) } fail: -if (object) { -(*env)->DeleteLocalRef(env, object); -} +(*env)->DeleteLocalRef(env, object); if (!format->object) { ff_jni_reset_jfields(env, &format->jfields, jni_amediaformat_mapping, 1, format); @@ -828,9 +792,7 @@ static char* mediaformat_jni_toString(FFAMediaFormat* ctx) ret = ff_jni_jstring_to_utf_chars(env, description, format); fail: -if (description) { -(*env)->DeleteLocalRef(env, description); -} +(*env)->DeleteLocalRef(env, description); return ret; } @@ -867,9 +829,7 @@ static int mediaformat_jni_getInt32(FFAMediaFormat* ctx, const char *name, int32 ret = 1; fail: -if (key) { -(*env)->DeleteLocalRef(env, key); -} +(*env)->DeleteLocalRef(env, key); return ret; } @@ -906,9 +866,7 @@ static int mediaformat_jni_getInt64(FFAMediaFormat* ctx, const char *name, int64 ret = 1; fail: -if (key) { -(*env)->DeleteLocalRef(env, key); -} +(*env)->DeleteLocalRef(env, key); return ret; } @@ -945,9 +903,7 @@ static int mediaformat_jni_getFloat(FFAMediaFormat* ctx, const char *name, float ret = 1; fail: -if (key) { -(*env)->DeleteLocalRef(env, key); -} +(*env)->DeleteLocalRef(env, key); return ret; } @@ -999,13 +955,8 @@ static int mediaformat_jni_getBuffer(FFAMed
[FFmpeg-devel] [PATCH v4 5/6] avcodec/mediacodec_wrapper: use an OFFSET() macro where relevant
Reduces a bit the horizontal spacing. --- libavcodec/mediacodec_wrapper.c | 138 +--- 1 file changed, 72 insertions(+), 66 deletions(-) diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c index 0880ddd3ef..78cd28f53d 100644 --- a/libavcodec/mediacodec_wrapper.c +++ b/libavcodec/mediacodec_wrapper.c @@ -60,31 +60,33 @@ struct JNIAMediaCodecListFields { jfieldID level_id; }; +#define OFFSET(x) offsetof(struct JNIAMediaCodecListFields, x) static const struct FFJniField jni_amediacodeclist_mapping[] = { -{ "android/media/MediaCodecList", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, mediacodec_list_class), 1 }, -{ "android/media/MediaCodecList", "", "(I)V", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, init_id), 0 }, -{ "android/media/MediaCodecList", "findDecoderForFormat", "(Landroid/media/MediaFormat;)Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, find_decoder_for_format_id), 0 }, +{ "android/media/MediaCodecList", NULL, NULL, FF_JNI_CLASS, OFFSET(mediacodec_list_class), 1 }, +{ "android/media/MediaCodecList", "", "(I)V", FF_JNI_METHOD, OFFSET(init_id), 0 }, +{ "android/media/MediaCodecList", "findDecoderForFormat", "(Landroid/media/MediaFormat;)Ljava/lang/String;", FF_JNI_METHOD, OFFSET(find_decoder_for_format_id), 0 }, -{ "android/media/MediaCodecList", "getCodecCount", "()I", FF_JNI_STATIC_METHOD, offsetof(struct JNIAMediaCodecListFields, get_codec_count_id), 1 }, -{ "android/media/MediaCodecList", "getCodecInfoAt", "(I)Landroid/media/MediaCodecInfo;", FF_JNI_STATIC_METHOD, offsetof(struct JNIAMediaCodecListFields, get_codec_info_at_id), 1 }, +{ "android/media/MediaCodecList", "getCodecCount", "()I", FF_JNI_STATIC_METHOD, OFFSET(get_codec_count_id), 1 }, +{ "android/media/MediaCodecList", "getCodecInfoAt", "(I)Landroid/media/MediaCodecInfo;", FF_JNI_STATIC_METHOD, OFFSET(get_codec_info_at_id), 1 }, -{ "android/media/MediaCodecInfo", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, mediacodec_info_class), 1 }, -{ "android/media/MediaCodecInfo", "getName", "()Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_name_id), 1 }, -{ "android/media/MediaCodecInfo", "getCapabilitiesForType", "(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_codec_capabilities_id), 1 }, -{ "android/media/MediaCodecInfo", "getSupportedTypes", "()[Ljava/lang/String;", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, get_supported_types_id), 1 }, -{ "android/media/MediaCodecInfo", "isEncoder", "()Z", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, is_encoder_id), 1 }, -{ "android/media/MediaCodecInfo", "isSoftwareOnly", "()Z", FF_JNI_METHOD, offsetof(struct JNIAMediaCodecListFields, is_software_only_id), 0 }, +{ "android/media/MediaCodecInfo", NULL, NULL, FF_JNI_CLASS, OFFSET(mediacodec_info_class), 1 }, +{ "android/media/MediaCodecInfo", "getName", "()Ljava/lang/String;", FF_JNI_METHOD, OFFSET(get_name_id), 1 }, +{ "android/media/MediaCodecInfo", "getCapabilitiesForType", "(Ljava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;", FF_JNI_METHOD, OFFSET(get_codec_capabilities_id), 1 }, +{ "android/media/MediaCodecInfo", "getSupportedTypes", "()[Ljava/lang/String;", FF_JNI_METHOD, OFFSET(get_supported_types_id), 1 }, +{ "android/media/MediaCodecInfo", "isEncoder", "()Z", FF_JNI_METHOD, OFFSET(is_encoder_id), 1 }, +{ "android/media/MediaCodecInfo", "isSoftwareOnly", "()Z", FF_JNI_METHOD, OFFSET(is_software_only_id), 0 }, -{ "android/media/MediaCodecInfo$CodecCapabilities", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, codec_capabilities_class), 1 }, -{ "android/media/MediaCodecInfo$CodecCapabilities", "colorFormats", "[I", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, color_formats_id), 1 }, -{ "android/media/MediaCodecInfo$CodecCapabilities", "profileLevels", "[Landroid/media/MediaCodecInfo$CodecProfileLevel;", FF_JNI_FIELD, offsetof(struct JNIAMediaCodecListFields, profile_levels_id), 1 }, +{ "android/media/MediaCodecInfo$CodecCapabilities", NULL, NULL, FF_JNI_CLASS, OFFSET(codec_capabilities_class), 1 }, +{ "android/media/MediaCodecInfo$CodecCapabilities", "colorFormats", "[I", FF_JNI_FIELD, OFFSET(color_formats_id), 1 }, +{ "android/media/MediaCodecInfo$CodecCapabilities", "profileLevels", "[Landroid/media/MediaCodecInfo$CodecProfileLevel;", FF_JNI_FIELD, OFFSET(profile_levels_id), 1 }, -{ "android/media/MediaCodecInfo$CodecProfileLevel", NULL, NULL, FF_JNI_CLASS, offsetof(struct JNIAMediaCodecListFields, codec_profile_level_class), 1 }, -{ "android/media/
[FFmpeg-devel] [PATCH v4 4/6] avcodec/jni: remove unnecessary NULL checks before calling DeleteLocalRef()
Delete{Global,Local}Ref() already handle NULL. --- libavcodec/ffjni.c | 14 +++--- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libavcodec/ffjni.c b/libavcodec/ffjni.c index e3cf24d3e2..69d9a9faa3 100644 --- a/libavcodec/ffjni.c +++ b/libavcodec/ffjni.c @@ -236,17 +236,9 @@ done: av_free(name); av_free(message); -if (class_class) { -(*env)->DeleteLocalRef(env, class_class); -} - -if (exception_class) { -(*env)->DeleteLocalRef(env, exception_class); -} - -if (string) { -(*env)->DeleteLocalRef(env, string); -} +(*env)->DeleteLocalRef(env, class_class); +(*env)->DeleteLocalRef(env, exception_class); +(*env)->DeleteLocalRef(env, string); return ret; } -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 3/6] avcodec/jni: use size_t to store structure offsets
--- libavcodec/ffjni.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/ffjni.h b/libavcodec/ffjni.h index 6027bac0ab..d1e86f8329 100644 --- a/libavcodec/ffjni.h +++ b/libavcodec/ffjni.h @@ -24,6 +24,7 @@ #define AVCODEC_FFJNI_H #include +#include /* * Attach permanently a JNI environment to the current thread and retrieve it. @@ -105,7 +106,7 @@ struct FFJniField { const char *method; const char *signature; enum FFJniFieldType type; -int offset; +size_t offset; int mandatory; }; -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 2/6] avformat: add Android content resolver protocol support
Handles Android content-uri starting with content://. --- configure | 2 + libavcodec/jni.c| 1 + libavformat/Makefile| 1 + libavformat/file.c | 160 libavformat/protocols.c | 1 + 5 files changed, 165 insertions(+) diff --git a/configure b/configure index 2b4c4ec9a2..9ef432fddf 100755 --- a/configure +++ b/configure @@ -3656,6 +3656,8 @@ xcbgrab_indev_suggest="libxcb_shm libxcb_shape libxcb_xfixes" xv_outdev_deps="xlib_xv xlib_x11 xlib_xext" # protocols +android_content_protocol_deps="jni" +android_content_protocol_select="file_protocol" async_protocol_deps="threads" bluray_protocol_deps="libbluray" ffrtmpcrypt_protocol_conflict="librtmp_protocol" diff --git a/libavcodec/jni.c b/libavcodec/jni.c index cfe95bd1ec..1193c608c3 100644 --- a/libavcodec/jni.c +++ b/libavcodec/jni.c @@ -35,6 +35,7 @@ #include "ffjni.h" static void *java_vm; +static void *android_app_ctx; static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; int av_jni_set_java_vm(void *vm, void *log_ctx) diff --git a/libavformat/Makefile b/libavformat/Makefile index 94a949f555..44aa485029 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -658,6 +658,7 @@ OBJS-$(CONFIG_LIBOPENMPT_DEMUXER)+= libopenmpt.o OBJS-$(CONFIG_VAPOURSYNTH_DEMUXER) += vapoursynth.o # protocols I/O +OBJS-$(CONFIG_ANDROID_CONTENT_PROTOCOL) += file.o OBJS-$(CONFIG_ASYNC_PROTOCOL)+= async.o OBJS-$(CONFIG_APPLEHTTP_PROTOCOL)+= hlsproto.o OBJS-$(CONFIG_BLURAY_PROTOCOL) += bluray.o diff --git a/libavformat/file.c b/libavformat/file.c index 64df7ff6fb..dd5819c06f 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -40,6 +40,12 @@ #include #include "os_support.h" #include "url.h" +#if CONFIG_ANDROID_CONTENT_PROTOCOL +#include +#include "libavcodec/jni.h" +#include "libavcodec/ffjni.c" +#endif + /* Some systems may not have S_ISFIFO */ #ifndef S_ISFIFO @@ -101,6 +107,21 @@ typedef struct FileContext { int64_t initial_pos; } FileContext; + +#if CONFIG_ANDROID_CONTENT_PROTOCOL +static const AVOption android_content_options[] = { +{ "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, +{ NULL } +}; + +static const AVClass android_content_class = { +.class_name = "android_content", +.item_name = av_default_item_name, +.option = android_content_options, +.version= LIBAVUTIL_VERSION_INT, +}; +#endif + static const AVOption file_options[] = { { "truncate", "truncate existing files on write", offsetof(FileContext, trunc), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AV_OPT_FLAG_ENCODING_PARAM }, { "blocksize", "set I/O operation maximum block size", offsetof(FileContext, blocksize), AV_OPT_TYPE_INT, { .i64 = INT_MAX }, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, @@ -524,3 +545,142 @@ const URLProtocol ff_fd_protocol = { }; #endif /* CONFIG_FD_PROTOCOL */ + +#if CONFIG_ANDROID_CONTENT_PROTOCOL + +typedef struct JFields { +jclass uri_class; +jmethodID parse_id; + +jclass context_class; +jmethodID get_content_resolver_id; + +jclass content_resolver_class; +jmethodID open_file_descriptor_id; + +jclass parcel_file_descriptor_class; +jmethodID detach_fd_id; +} JFields; + +#define OFFSET(x) offsetof(JFields, x) +static const struct FFJniField jfields_mapping[] = { +{ "android/net/Uri", NULL, NULL, FF_JNI_CLASS, OFFSET(uri_class), 1 }, +{ "android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;", FF_JNI_STATIC_METHOD, OFFSET(parse_id), 1 }, + +{ "android/content/Context", NULL, NULL, FF_JNI_CLASS, OFFSET(context_class), 1 }, +{ "android/content/Context", "getContentResolver", "()Landroid/content/ContentResolver;", FF_JNI_METHOD, OFFSET(get_content_resolver_id), 1 }, + +{ "android/content/ContentResolver", NULL, NULL, FF_JNI_CLASS, OFFSET(content_resolver_class), 1 }, +{ "android/content/ContentResolver", "openFileDescriptor", "(Landroid/net/Uri;Ljava/lang/String;)Landroid/os/ParcelFileDescriptor;", FF_JNI_METHOD, OFFSET(open_file_descriptor_id), 1 }, + +{ "android/os/ParcelFileDescriptor", NULL, NULL, FF_JNI_CLASS, OFFSET(parcel_file_descriptor_class), 1 }, +{ "android/os/ParcelFileDescriptor", "detachFd", "()I", FF_JNI_METHOD, OFFSET(detach_fd_id), 1 }, + +{ NULL } +}; +#undef OFFSET + +static int android_content_open(URLContext *h, const char *filename, int flags) +{ +FileContext *c = h->priv_data; +int fd, ret; +struct stat st; +const char *mode_str = "r"; + +JNIEnv *env; +JFields jfields = { 0 }; +jobject application_context = NULL; +jobject url = NULL; +jobject mode = NULL; +jobject uri = NULL; +jobject content_resolver = NULL; +jobject parcel_file_descriptor = NULL; + +env = ff_jni_get_env(c); +
[FFmpeg-devel] [PATCH v4 1/6] avcodec: add av_jni_{get, set}_android_app_ctx helper
This will allow users to pass the Android ApplicationContext which is mandatory to retrieve the ContentResolver responsible to resolve/open Android content-uri. --- doc/APIchanges | 3 +++ libavcodec/jni.c | 42 ++ libavcodec/jni.h | 17 + 3 files changed, 62 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index a44c8e4f10..ae1868047e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-03-xx - xx - lavc 61.2.100 - jni.h + Add av_jni_set_android_app_ctx() and av_jni_get_android_app_ctx(). + 2024-03-xx - xx - lavu 59.2.100 - channel_layout.h Add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL. diff --git a/libavcodec/jni.c b/libavcodec/jni.c index ae6490de9d..cfe95bd1ec 100644 --- a/libavcodec/jni.c +++ b/libavcodec/jni.c @@ -77,3 +77,45 @@ void *av_jni_get_java_vm(void *log_ctx) } #endif + +#if defined(__ANDROID__) + +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx) +{ +#if CONFIG_JNI +JNIEnv *env = ff_jni_get_env(log_ctx); +if (!env) +return AVERROR(EINVAL); + +jobjectRefType type = (*env)->GetObjectRefType(env, app_ctx); +if (type != JNIGlobalRefType) { +av_log(log_ctx, AV_LOG_ERROR, "Application context must be passed as a global reference"); +return AVERROR(EINVAL); +} + +pthread_mutex_lock(&lock); +android_app_ctx = app_ctx; +pthread_mutex_unlock(&lock); + +return 0; +#else +return AVERROR(ENOSYS); +#endif +} + +void *av_jni_get_android_app_ctx(void) +{ +#if CONFIG_JNI +void *ctx; + +pthread_mutex_lock(&lock); +ctx = android_app_ctx; +pthread_mutex_unlock(&lock); + +return ctx; +#else +return NULL; +#endif +} + +#endif diff --git a/libavcodec/jni.h b/libavcodec/jni.h index dd99e92611..da8025f830 100644 --- a/libavcodec/jni.h +++ b/libavcodec/jni.h @@ -43,4 +43,21 @@ int av_jni_set_java_vm(void *vm, void *log_ctx); */ void *av_jni_get_java_vm(void *log_ctx); +/* + * Set the Android application context which will be used to retrieve the Android + * content resolver to resolve content uris. + * + * @param app_ctx global JNI reference to the Android application context + * @return 0 on success, < 0 otherwise + */ +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx); + +/* + * Get the Android application context that has been set with + * av_jni_set_android_app_ctx. + * + * @return a pointer the the Android application context + */ +void *av_jni_get_android_app_ctx(void); + #endif /* AVCODEC_JNI_H */ -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] Add protocol for Android content providers (v4)
Diff with previous iteration: - rebaed on latest master - applied feedback from Zhao (removed HAVE_SETMODE block, use a typedef struct, check that the fd is seekable, moved doc/APIChanges changes to the right commit) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
I fixed it on my dev machine by renaming the function in libbluray and creating a new lib. I still think that this is a temporary hack and should be fixed properly. I've opened an issue with libbluray, so I hope that I'll get a reply at one point. I'm still not entirely sure who actually has to fix this. But I guess it will be determined in due time. Cheers, K. C. OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
On 17.03.2024 18:37, Rémi Denis-Courmont wrote: Le 17 mars 2024 10:29:39 GMT-07:00, Andreas Rheinhardt a écrit : Rémi Denis-Courmont: Le 16 mars 2024 13:58:23 GMT-07:00, James Almer a écrit : Seems the conflict comes from https://code.videolan.org/videolan/libbluray/-/blob/master/src/libbluray/disc/dec.c?ref_type=heads#L287 and https://github.com/FFmpeg/FFmpeg/commit/c4de5778bceab3c15f1239f1f16816749a7fd3b6 Perhaps you could also try asking libbluray if they could use an internal prefix. Otherwise you might need to do a rename of that function on ffmpeg's side. libbluray 100% needs to either prefix it, or hid it so it's not exported. It's a library, so it should not be exporting such simple and short unprefix named symbols. AFAICT, FFmpeg is just as guilty as Libbluray there. To support static linking, all non-static symbols should be name-spaced, and here both FFmpeg and libbluray are failing, and thus both should be fixed IMO. You forgot that FFmpeg's dec_init is in fftools/the executable, whereas libbluray's is in the library. Oh well then it's 100% a problem with FFmpeg, or with the build system used by OP (Possibly a problem with Apple's tools). A static library being imported is not supposed to be able to cause symbol conflicts. A static library, as opposed to a shared one, has no concept of private symbols. The symbol already is not exported by libbr, but in the case of static linking, there is no distinction between exported and hidden symbols. To be clear, the poor choice of symbol name in libbluray might cause Libbluray to misbehave at runtime (due to its own fault), but not to fail linking. In other words, it's still two bugs, one in each project. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 2/2] lavc/get_buffer: Add a warning on failed allocation from a fixed pool
For hardware cases where we are forced to have a fixed pool of frames allocated up-front (such as array textures on decoder output), suggest a possible workaround to the user if an allocation fails because the pool is exhausted. --- Perhaps helpful; any thoughts? The warning comes out before any errors, looking like: [mpeg2video @ 0x560ff51b4600] Failed to allocate a vaapi/nv12 frame from a fixed pool of hardware frames. [mpeg2video @ 0x560ff51b4600] Consider setting extra_hw_frames to a larger value (currently set to 8, giving a pool size of 14). [mpeg2video @ 0x560ff51b4600] get_buffer() failed [vist#0:0/mpeg2video @ 0x560ff5199840] [dec:mpeg2video @ 0x560ff51b3b40] Error submitting packet to decoder: Operation not permitted libavcodec/get_buffer.c | 16 libavcodec/internal.h | 6 ++ 2 files changed, 22 insertions(+) diff --git a/libavcodec/get_buffer.c b/libavcodec/get_buffer.c index 46c20781af..9b35fde7c6 100644 --- a/libavcodec/get_buffer.c +++ b/libavcodec/get_buffer.c @@ -257,6 +257,22 @@ int avcodec_default_get_buffer2(AVCodecContext *avctx, AVFrame *frame, int flags if (avctx->hw_frames_ctx) { ret = av_hwframe_get_buffer(avctx->hw_frames_ctx, frame, 0); +if (ret == AVERROR(ENOMEM)) { +AVHWFramesContext *frames_ctx = +(AVHWFramesContext*)avctx->hw_frames_ctx->data; +if (frames_ctx->initial_pool_size > 0 && +!avctx->internal->warned_on_failed_allocation_from_fixed_pool) { +av_log(avctx, AV_LOG_WARNING, "Failed to allocate a %s/%s " + "frame from a fixed pool of hardware frames.\n", + av_get_pix_fmt_name(frames_ctx->format), + av_get_pix_fmt_name(frames_ctx->sw_format)); +av_log(avctx, AV_LOG_WARNING, "Consider setting " + "extra_hw_frames to a larger value " + "(currently set to %d, giving a pool size of %d).\n", + avctx->extra_hw_frames, frames_ctx->initial_pool_size); +avctx->internal->warned_on_failed_allocation_from_fixed_pool = 1; +} +} frame->width = avctx->coded_width; frame->height = avctx->coded_height; return ret; diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 04f7cebdcb..64fe0122c8 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -144,6 +144,12 @@ typedef struct AVCodecInternal { #if CONFIG_LCMS2 FFIccContext icc; /* used to read and write embedded ICC profiles */ #endif + +/** + * Set when the user has been warned about a failed allocation from + * a fixed frame pool. + */ +int warned_on_failed_allocation_from_fixed_pool; } AVCodecInternal; /** -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 1/2] ffmpeg: set extra_hw_frames to account for frames held in queues
Since e0da916b8f5b079a4865eef7f64863f50785463d the ffmpeg utility has held multiple frames output by the decoder in internal queues without telling the decoder that it is going to do so. When the decoder has a fixed-size pool of frames (common in some hardware APIs where the output frames must be stored as an array texture) this could lead to the pool being exhausted and the decoder getting stuck. Fix this by telling the decoder to allocate additional frames according to the queue size. --- Rebased but otherwise unchanged since previous version. fftools/ffmpeg_dec.c | 13 + fftools/ffmpeg_sched.c | 16 +++- fftools/ffmpeg_sched.h | 12 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index c41c5748e5..ed411b6bf8 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -1207,6 +1207,19 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts, return ret; } +if (dp->dec_ctx->hw_device_ctx) { +// Update decoder extra_hw_frames option to account for the +// frames held in queues inside the ffmpeg utility. This is +// called after avcodec_open2() because the user-set value of +// extra_hw_frames becomes valid in there, and we need to add +// this on top of it. +int extra_frames = DEFAULT_FRAME_THREAD_QUEUE_SIZE; +if (dp->dec_ctx->extra_hw_frames >= 0) +dp->dec_ctx->extra_hw_frames += extra_frames; +else +dp->dec_ctx->extra_hw_frames = extra_frames; +} + ret = check_avoptions(*dec_opts); if (ret < 0) return ret; diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c index f739066921..ec88017e21 100644 --- a/fftools/ffmpeg_sched.c +++ b/fftools/ffmpeg_sched.c @@ -365,7 +365,21 @@ static int queue_alloc(ThreadQueue **ptq, unsigned nb_streams, unsigned queue_si ThreadQueue *tq; ObjPool *op; -queue_size = queue_size > 0 ? queue_size : 8; +if (queue_size <= 0) { +if (type == QUEUE_FRAMES) +queue_size = DEFAULT_FRAME_THREAD_QUEUE_SIZE; +else +queue_size = DEFAULT_PACKET_THREAD_QUEUE_SIZE; +} + +if (type == QUEUE_FRAMES) { +// This queue length is used in the decoder code to ensure that +// there are enough entries in fixed-size frame pools to account +// for frames held in queues inside the ffmpeg utility. If this +// can ever dynamically change then the corresponding decode +// code needs to be updated as well. +av_assert0(queue_size == DEFAULT_FRAME_THREAD_QUEUE_SIZE); +} op = (type == QUEUE_PACKETS) ? objpool_alloc_packets() : objpool_alloc_frames(); diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h index a9190bd3d1..e51c26cec9 100644 --- a/fftools/ffmpeg_sched.h +++ b/fftools/ffmpeg_sched.h @@ -233,6 +233,18 @@ int sch_add_filtergraph(Scheduler *sch, unsigned nb_inputs, unsigned nb_outputs, */ int sch_add_mux(Scheduler *sch, SchThreadFunc func, int (*init)(void *), void *ctx, int sdp_auto, unsigned thread_queue_size); + +/** + * Default size of a packet thread queue. For muxing this can be overridden by + * the thread_queue_size option as passed to a call to sch_add_mux(). + */ +#define DEFAULT_PACKET_THREAD_QUEUE_SIZE 8 + +/** + * Default size of a frame thread queue. + */ +#define DEFAULT_FRAME_THREAD_QUEUE_SIZE 8 + /** * Add a muxed stream for a previously added muxer. * -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 14/14] avcodec/libx265: add support for writing out CLL and MDCV
The newer of these two are the separate integers for content light level, introduced in 3952bf3e98c76c31594529a3fe34e056d3e3e2ea , with X265_BUILD 75. As we already require X265_BUILD of at least 89, no further conditions are required. --- libavcodec/libx265.c | 89 tests/fate/enc_external.mak | 5 ++ tests/ref/fate/libx265-hdr10 | 16 +++ 3 files changed, 110 insertions(+) create mode 100644 tests/ref/fate/libx265-hdr10 diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 92183b9ca2..0c884fe04d 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -28,9 +28,11 @@ #include #include "libavutil/avassert.h" +#include "libavutil/bprint.h" #include "libavutil/buffer.h" #include "libavutil/internal.h" #include "libavutil/common.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avcodec.h" @@ -176,6 +178,86 @@ static av_cold int libx265_param_parse_int(AVCodecContext *avctx, return 0; } +static int handle_mdcv(const AVClass **avcl, const x265_api *api, + x265_param *params, + const AVMasteringDisplayMetadata *mdcv) +{ +int ret = AVERROR_BUG; +AVBPrint buf; +av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC); + +// G(%hu,%hu)B(%hu,%hu)R(%hu,%hu)WP(%hu,%hu)L(%u,%u) +av_bprintf( +&buf, +"G(%"PRId64",%"PRId64")B(%"PRId64",%"PRId64")R(%"PRId64",%"PRId64")" +"WP(%"PRId64",%"PRId64")L(%"PRId64",%"PRId64")", +av_rescale_q(1, mdcv->display_primaries[1][0], (AVRational){ 1, 5 }), +av_rescale_q(1, mdcv->display_primaries[1][1], (AVRational){ 1, 5 }), +av_rescale_q(1, mdcv->display_primaries[2][0], (AVRational){ 1, 5 }), +av_rescale_q(1, mdcv->display_primaries[2][1], (AVRational){ 1, 5 }), +av_rescale_q(1, mdcv->display_primaries[0][0], (AVRational){ 1, 5 }), +av_rescale_q(1, mdcv->display_primaries[0][1], (AVRational){ 1, 5 }), +av_rescale_q(1, mdcv->white_point[0], (AVRational){ 1, 5 }), +av_rescale_q(1, mdcv->white_point[1], (AVRational){ 1, 5 }), +av_rescale_q(1, mdcv->max_luminance, (AVRational){ 1, 1 }), +av_rescale_q(1, mdcv->min_luminance, (AVRational){ 1, 1 })); + +if (!av_bprint_is_complete(&buf)) { +av_log(avcl, AV_LOG_ERROR, + "MDCV string too long for its available space!\n"); +ret = AVERROR(ENOMEM); +goto end; +} + +if (api->param_parse(params, "master-display", buf.str) == +X265_PARAM_BAD_VALUE) { +av_log(avcl, AV_LOG_ERROR, + "Invalid value \"%s\" for param \"master-display\".\n", + buf.str); +ret = AVERROR(EINVAL); +goto end; +} + +ret = 0; + +end: +av_bprint_finalize(&buf, NULL); + +return ret; +} + +static int handle_side_data(AVCodecContext *avctx, const x265_api *api, +x265_param *params) +{ +const AVFrameSideData *cll_sd = +av_frame_side_data_get( +(const AVFrameSideData **)avctx->encoder_side_data, +avctx->nb_encoder_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); +const AVFrameSideData *mdcv_sd = +av_frame_side_data_get( +(const AVFrameSideData **)avctx->encoder_side_data, +avctx->nb_encoder_side_data, +AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + +if (cll_sd) { +const AVContentLightMetadata *cll = +(AVContentLightMetadata *)cll_sd->data; + +params->maxCLL = cll->MaxCLL; +params->maxFALL = cll->MaxFALL; +} + +if (mdcv_sd) { +int ret = handle_mdcv( +&avctx->av_class, api, params, +(AVMasteringDisplayMetadata *)mdcv_sd->data); +if (ret < 0) +return ret; +} + +return 0; +} + static av_cold int libx265_encode_init(AVCodecContext *avctx) { libx265Context *ctx = avctx->priv_data; @@ -336,6 +418,13 @@ FF_ENABLE_DEPRECATION_WARNINGS return AVERROR_BUG; } +ret = handle_side_data(avctx, ctx->api, ctx->params); +if (ret < 0) { +av_log(avctx, AV_LOG_ERROR, "Failed handling side data! (%s)\n", + av_err2str(ret)); +return ret; +} + if (ctx->crf >= 0) { char crf[6]; diff --git a/tests/fate/enc_external.mak b/tests/fate/enc_external.mak index 4095a4b51a..30021efbcd 100644 --- a/tests/fate/enc_external.mak +++ b/tests/fate/enc_external.mak @@ -12,5 +12,10 @@ FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 HEVC, MOV, LIBX264_HDR10 HEVC_DEMUXER H fate-libx264-hdr10: CMD = enc_external $(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \ mp4 "-c:v libx264" "-show_frames -show_entries frame=side_data_list -of flat" +# test for x265 MDCV and CLL passthrough during encoding +FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX265 HEVC, MOV, HE
[FFmpeg-devel] [PATCH v9 13/14] avcodec/libx264: add support for writing out CLL and MDCV
Both of these two structures were first available with X264_BUILD 163, so make relevant functionality conditional on the version being at least such. Keep handle_side_data available in all cases as this way X264_init does not require additional version based conditions within it. Finally, add a FATE test which verifies that pass-through of the MDCV/CLL side data is working during encoding. --- configure| 2 + libavcodec/libx264.c | 80 tests/fate/enc_external.mak | 5 +++ tests/ref/fate/libx264-hdr10 | 15 +++ 4 files changed, 102 insertions(+) create mode 100644 tests/ref/fate/libx264-hdr10 diff --git a/configure b/configure index 2b4c4ec9a2..44be4ef819 100755 --- a/configure +++ b/configure @@ -2531,6 +2531,7 @@ CONFIG_EXTRA=" jpegtables lgplv3 libx262 +libx264_hdr10 llauddsp llviddsp llvidencdsp @@ -6925,6 +6926,7 @@ enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h" x require_cpp_condition libx264 x264.h "X264_BUILD >= 122" && { [ "$toolchain" != "msvc" ] || require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } && + check_cpp_condition libx264_hdr10 x264.h "X264_BUILD >= 163" && check_cpp_condition libx262 x264.h "X264_MPEG2" enabled libx265 && require_pkg_config libx265 x265 x265.h x265_api_get && require_cpp_condition libx265 x265.h "X265_BUILD >= 89" diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 0997c4e134..2a8d71cd0b 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -25,6 +25,7 @@ #include "libavutil/eval.h" #include "libavutil/internal.h" #include "libavutil/opt.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/mem.h" #include "libavutil/pixdesc.h" #include "libavutil/stereo3d.h" @@ -853,6 +854,83 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt) return AVERROR(EINVAL);\ } +#if CONFIG_LIBX264_HDR10 +static void handle_mdcv(x264_param_t *params, +const AVMasteringDisplayMetadata *mdcv) +{ +if (!mdcv->has_primaries && !mdcv->has_luminance) +return; + +params->mastering_display.b_mastering_display = 1; + +if (mdcv->has_primaries) { +int *const points[][2] = { +{ +¶ms->mastering_display.i_red_x, +¶ms->mastering_display.i_red_y +}, +{ +¶ms->mastering_display.i_green_x, +¶ms->mastering_display.i_green_y +}, +{ +¶ms->mastering_display.i_blue_x, +¶ms->mastering_display.i_blue_y +}, +}; + +for (int i = 0; i < 3; i++) { +const AVRational *src = mdcv->display_primaries[i]; +int *dst[2] = { points[i][0], points[i][1] }; + +*dst[0] = av_rescale_q(1, src[0], (AVRational){ 1, 5 }); +*dst[1] = av_rescale_q(1, src[1], (AVRational){ 1, 5 }); +} + +params->mastering_display.i_white_x = +av_rescale_q(1, mdcv->white_point[0], (AVRational){ 1, 5 }); +params->mastering_display.i_white_y = +av_rescale_q(1, mdcv->white_point[1], (AVRational){ 1, 5 }); +} + +if (mdcv->has_luminance) { +params->mastering_display.i_display_max = +av_rescale_q(1, mdcv->max_luminance, (AVRational){ 1, 1 }); +params->mastering_display.i_display_min = +av_rescale_q(1, mdcv->min_luminance, (AVRational){ 1, 1 }); +} +} +#endif // CONFIG_LIBX264_HDR10 + +static void handle_side_data(AVCodecContext *avctx, x264_param_t *params) +{ +#if CONFIG_LIBX264_HDR10 +const AVFrameSideData *cll_sd = +av_frame_side_data_get( +(const AVFrameSideData **)avctx->encoder_side_data, +avctx->nb_encoder_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); +const AVFrameSideData *mdcv_sd = +av_frame_side_data_get( +(const AVFrameSideData **)avctx->encoder_side_data, +avctx->nb_encoder_side_data, +AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + +if (cll_sd) { +const AVContentLightMetadata *cll = +(AVContentLightMetadata *)cll_sd->data; + +params->content_light_level.i_max_cll = cll->MaxCLL; +params->content_light_level.i_max_fall = cll->MaxFALL; + +params->content_light_level.b_cll = 1; +} + +if (mdcv_sd) { +handle_mdcv(params, (AVMasteringDisplayMetadata *)mdcv_sd->data); +} +#endif // CONFIG_LIBX264_HDR10 +} + static av_cold int X264_init(AVCodecContext *avctx) { X264Context *x4 = avctx->priv_data; @@ -1153,6 +1231,8 @@ FF_ENABLE_DEPRECATION_WARNINGS if (avctx->chroma_sample_location != AVCHROMA_LOC
[FFmpeg-devel] [PATCH v9 12/14] avcodec/libsvtav1: add support for writing out CLL and MDCV
These two were added in 28e23d7f348c78d49a726c7469f9d4e38edec341 and 3558c1f2e97455e0b89edef31b9a72ab7fa30550 for version 0.9.0 of SVT-AV1, which is also our minimum requirement right now. In other words, no additional version limiting conditions seem to be required. Additionally, add a FATE test which verifies that pass-through of the MDCV/CLL side data is working during encoding. --- libavcodec/libsvtav1.c | 69 ++ tests/fate/enc_external.mak| 5 +++ tests/ref/fate/libsvtav1-hdr10 | 14 +++ 3 files changed, 88 insertions(+) create mode 100644 tests/ref/fate/libsvtav1-hdr10 diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 7721e01677..73bfdba3cf 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -27,6 +27,8 @@ #include "libavutil/common.h" #include "libavutil/frame.h" #include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/avassert.h" @@ -136,6 +138,71 @@ static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc) } +static void handle_mdcv(struct EbSvtAv1MasteringDisplayInfo *dst, +const AVMasteringDisplayMetadata *mdcv) +{ +if (mdcv->has_primaries) { +const struct EbSvtAv1ChromaPoints *const points[] = { +&dst->r, +&dst->g, +&dst->b, +}; + +for (int i = 0; i < 3; i++) { +const struct EbSvtAv1ChromaPoints *dst = points[i]; +const AVRational *src = mdcv->display_primaries[i]; + +AV_WB16(&dst->x, +av_rescale_q(1, src[0], (AVRational){ 1, (1 << 16) })); +AV_WB16(&dst->y, +av_rescale_q(1, src[1], (AVRational){ 1, (1 << 16) })); +} + +AV_WB16(&dst->white_point.x, +av_rescale_q(1, mdcv->white_point[0], + (AVRational){ 1, (1 << 16) })); +AV_WB16(&dst->white_point.y, +av_rescale_q(1, mdcv->white_point[1], + (AVRational){ 1, (1 << 16) })); +} + +if (mdcv->has_luminance) { +AV_WB32(&dst->max_luma, +av_rescale_q(1, mdcv->max_luminance, + (AVRational){ 1, (1 << 8) })); +AV_WB32(&dst->min_luma, +av_rescale_q(1, mdcv->min_luminance, + (AVRational){ 1, (1 << 14) })); +} +} + +static void handle_side_data(AVCodecContext *avctx, + EbSvtAv1EncConfiguration *param) +{ +const AVFrameSideData *cll_sd = +av_frame_side_data_get( +(const AVFrameSideData **)avctx->encoder_side_data, +avctx->nb_encoder_side_data, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); +const AVFrameSideData *mdcv_sd = +av_frame_side_data_get( +(const AVFrameSideData **)avctx->encoder_side_data, +avctx->nb_encoder_side_data, +AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); + +if (cll_sd) { +const AVContentLightMetadata *cll = +(AVContentLightMetadata *)cll_sd->data; + +AV_WB16(¶m->content_light_level.max_cll, cll->MaxCLL); +AV_WB16(¶m->content_light_level.max_fall, cll->MaxFALL); +} + +if (mdcv_sd) { +handle_mdcv(¶m->mastering_display, +(AVMasteringDisplayMetadata *)mdcv_sd->data); +} +} + static int config_enc_params(EbSvtAv1EncConfiguration *param, AVCodecContext *avctx) { @@ -254,6 +321,8 @@ FF_ENABLE_DEPRECATION_WARNINGS /* 2 = IDR, closed GOP, 1 = CRA, open GOP */ param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1; +handle_side_data(avctx, param); + #if SVT_AV1_CHECK_VERSION(0, 9, 1) while ((en = av_dict_get(svt_enc->svtav1_opts, "", en, AV_DICT_IGNORE_SUFFIX))) { EbErrorType ret = svt_av1_enc_parse_parameter(param, en->key, en->value); diff --git a/tests/fate/enc_external.mak b/tests/fate/enc_external.mak index 7eabebcc51..d787941c16 100644 --- a/tests/fate/enc_external.mak +++ b/tests/fate/enc_external.mak @@ -2,5 +2,10 @@ FATE_ENC_EXTERNAL-$(call ENCDEC, LIBX264 H264, MOV, H264_DEMUXER) += fate-libx26 fate-libx264-simple: CMD = enc_external $(TARGET_SAMPLES)/h264-conformance/BA1_Sony_D.jsv \ mp4 "-c:v libx264" "-show_entries frame=width,height,pix_fmt,pts,pkt_dts -of flat" +# test for SVT-AV1 MDCV and CLL passthrough during encoding +FATE_ENC_EXTERNAL-$(call ENCDEC, LIBSVTAV1 HEVC, MOV, HEVC_DEMUXER LIBDAV1D_DECODER) += fate-libsvtav1-hdr10 +fate-libsvtav1-hdr10: CMD = enc_external $(TARGET_SAMPLES)/hevc/hdr10_plus_h265_sample.hevc \ +mp4 "-c:v libsvtav1" "-show_frames -show_entries frame=side_data_list -of flat" + FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_ENC_EXTERNAL-yes) fate-enc-external: $(FATE_ENC_EXTERNAL-yes) d
[FFmpeg-devel] [PATCH v9 11/14] ffmpeg: pass first video AVFrame's side data to encoder
This enables further configuration of output based on the results of input decoding and filtering in a similar manner as the color information. --- fftools/ffmpeg_enc.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index c9a12af139..c8d15fb999 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -246,6 +246,16 @@ int enc_open(void *opaque, const AVFrame *frame) enc_ctx->colorspace = frame->colorspace; enc_ctx->chroma_sample_location = frame->chroma_location; +ret = avcodec_configure_side_data( +enc_ctx, +(const AVFrameSideData **)frame->side_data, frame->nb_side_data, +AV_FRAME_SIDE_DATA_FLAG_UNIQUE); +if (ret < 0) { +av_log(NULL, AV_LOG_ERROR, "failed to configure video encoder: %s!\n", + av_err2str(ret)); +return ret; +} + if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) || (frame->flags & AV_FRAME_FLAG_INTERLACED) #if FFMPEG_OPT_TOP -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 10/14] avcodec: add helper for configuring AVCodecContext's frame side data
This allows API clients that wish to configure multiple entries at a time to do so without writing the looping code themselves. --- libavcodec/avcodec.c | 31 +++ libavcodec/avcodec.h | 21 + 2 files changed, 52 insertions(+) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index a9a87bb58c..3183952172 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -686,3 +686,34 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr return ff_decode_receive_frame(avctx, frame); return ff_encode_receive_frame(avctx, frame); } + +int avcodec_configure_side_data(AVCodecContext *avctx, +const AVFrameSideData **sd, const int nb_sd, +unsigned int flags) +{ +if (!avctx) +return AVERROR(EINVAL); + +if (!sd) { +av_frame_side_data_free( +&avctx->encoder_side_data, &avctx->nb_encoder_side_data); +return 0; +} + +if (nb_sd > 0 && nb_sd == avctx->nb_encoder_side_data && +sd == (const AVFrameSideData **)avctx->encoder_side_data) +return AVERROR(EINVAL); + +for (int i = 0; i < nb_sd; i++) { +int ret = av_frame_side_data_clone( +&avctx->encoder_side_data, &avctx->nb_encoder_side_data, sd[i], +flags); +if (ret < 0) { +av_frame_side_data_free( +&avctx->encoder_side_data, &avctx->nb_encoder_side_data); +return ret; +} +} + +return 0; +} diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 550df0e589..01085cc3c8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3079,6 +3079,27 @@ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size); */ int avcodec_is_open(AVCodecContext *s); +/** + * Add multiple side data entries to an AVCodecContext's array in one go, for + * example from an AVFrame. + * + * In case the function fails to add a side data entry, it will clear the + * whole side data set. + * + * @param avctx context to which the side data should be added + * @param sdarray of side data to use as input. + * if null, clears out the side data for this context. + * @param nb_sd integer containing the number of entries in the array. + * @param flags Some combination of AV_FRAME_SIDE_DATA_SET_FLAG_* flags, or 0. + * + * @return negative error code on failure, >=0 on success. + * + * @see av_frame_side_data_new regarding the flags. + */ +int avcodec_configure_side_data(AVCodecContext *avctx, +const AVFrameSideData **sd, const int nb_sd, +unsigned int flags); + /** * @} */ -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 09/14] avcodec: add frame side data array to AVCodecContext
This allows configuring an encoder by using AVFrameSideData. --- libavcodec/avcodec.h | 12 libavcodec/options.c | 2 ++ 2 files changed, 14 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 554501aa44..550df0e589 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2062,6 +2062,18 @@ typedef struct AVCodecContext { * Number of entries in side_data_prefer_packet. */ unsigned nb_side_data_prefer_packet; + +/** + * Array containing static side data, such as HDR10 CLL / MDCV structures. + * Side data entries should be allocated by usage of helpers defined in + * libavutil/frame.h. + * + * - encoding: may be set by user before calling avcodec_open2() for + * encoder configuration. + * - decoding: unused + */ +AVFrameSideData **encoder_side_data; +int nb_encoder_side_data; } AVCodecContext; /** diff --git a/libavcodec/options.c b/libavcodec/options.c index dcc67e497a..dd5c697da3 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -176,6 +176,8 @@ void avcodec_free_context(AVCodecContext **pavctx) av_freep(&avctx->inter_matrix); av_freep(&avctx->rc_override); av_channel_layout_uninit(&avctx->ch_layout); +av_frame_side_data_free( +&avctx->encoder_side_data, &avctx->nb_encoder_side_data); av_freep(pavctx); } -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 08/14] avutil/frame: add helper for getting side data from array
--- libavutil/frame.c | 20 +++- libavutil/frame.h | 14 ++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 30db83a5e5..47ecd964b8 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -830,16 +830,26 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, return 0; } -AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, -enum AVFrameSideDataType type) +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type) { -for (int i = 0; i < frame->nb_side_data; i++) { -if (frame->side_data[i]->type == type) -return frame->side_data[i]; +for (int i = 0; i < nb_sd; i++) { +if (sd[i]->type == type) +return sd[i]; } return NULL; } +AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, +enum AVFrameSideDataType type) +{ +return (AVFrameSideData *)av_frame_side_data_get( +(const AVFrameSideData **)frame->side_data, frame->nb_side_data, +type +); +} + static int frame_copy_video(AVFrame *dst, const AVFrame *src) { int planes; diff --git a/libavutil/frame.h b/libavutil/frame.h index a7e62ded15..e59f033cce 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1062,6 +1062,20 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags); +/** + * Get a side data entry of a specific type from an array. + * + * @param sdarray of side data. + * @param nb_sd integer containing the number of entries in the array. + * @param type type of side data to be queried + * + * @return a pointer to the side data of a given type on success, NULL if there + * is no side data with such type in this set. + */ +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type); + /** * @} */ -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 07/14] avutil/frame: add helper for adding side data w/ AVBufferRef to array
This was requested to be added in review. --- libavutil/frame.c | 43 ++- libavutil/frame.h | 21 + 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 46f976a3ed..30db83a5e5 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -781,29 +781,46 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, return ret; } -int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, - const AVFrameSideData *src, unsigned int flags) +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, +enum AVFrameSideDataType type, +const AVBufferRef *buf, +unsigned int flags) { -AVBufferRef *buf= NULL; -AVFrameSideData *sd_dst = NULL; -int ret= AVERROR_BUG; +AVBufferRef *new_buf = NULL; +AVFrameSideData *sd_dst = NULL; -if (!sd || !src || !nb_sd || (*nb_sd && !*sd)) -return AVERROR(EINVAL); +if (!sd || !buf || !nb_sd || (*nb_sd && !*sd)) +return NULL; -buf = av_buffer_ref(src->buf); +new_buf = av_buffer_ref(buf); if (!buf) -return AVERROR(ENOMEM); +return NULL; if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) -remove_side_data(sd, nb_sd, src->type); +remove_side_data(sd, nb_sd, type); -sd_dst = add_side_data_to_set_from_buf(sd, nb_sd, src->type, buf); +sd_dst = add_side_data_to_set_from_buf(sd, nb_sd, type, new_buf); if (!sd_dst) { -av_buffer_unref(&buf); -return AVERROR(ENOMEM); +av_buffer_unref(&new_buf); +return NULL; } +return sd_dst; +} + +int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, unsigned int flags) +{ +AVFrameSideData *sd_dst = NULL; +int ret= AVERROR_BUG; + +if (!src) +return AVERROR(EINVAL); + +sd_dst = av_frame_side_data_add(sd, nb_sd, src->type, src->buf, flags); +if (!sd_dst) +return AVERROR(ENOMEM); + ret = av_dict_copy(&sd_dst->metadata, src->metadata, 0); if (ret < 0) { remove_side_data_by_entry(sd, nb_sd, sd_dst); diff --git a/libavutil/frame.h b/libavutil/frame.h index ce93421d60..a7e62ded15 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1021,6 +1021,27 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags); +/** + * Add a new side data entry to an array from an existing AVBufferRef. + * + * @param sdpointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param type type of the added side data + * @param buf AVBufferRef for which a new reference will be made + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return newly added side data on success, NULL on error. In case of + * AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching + * AVFrameSideDataType will be removed before the addition is + * attempted. + */ +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, +enum AVFrameSideDataType type, +const AVBufferRef *buf, +unsigned int flags); + /** * Add a new side data entry to an array based on existing side data, taking * a reference towards the contained AVBufferRef. -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 06/14] avutil/frame: add helper for adding existing side data to array
--- libavutil/frame.c | 49 +++ libavutil/frame.h | 20 +++ 2 files changed, 69 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index 4074391a92..46f976a3ed 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -98,6 +98,23 @@ static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data, } } +static void remove_side_data_by_entry(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *target) +{ +for (int i = *nb_sd - 1; i >= 0; i--) { +AVFrameSideData *entry = ((*sd)[i]); +if (entry != target) +continue; + +free_side_data(&entry); + +((*sd)[i]) = ((*sd)[*nb_sd - 1]); +(*nb_sd)--; + +return; +} +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_malloc(sizeof(*frame)); @@ -764,6 +781,38 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, return ret; } +int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, unsigned int flags) +{ +AVBufferRef *buf= NULL; +AVFrameSideData *sd_dst = NULL; +int ret= AVERROR_BUG; + +if (!sd || !src || !nb_sd || (*nb_sd && !*sd)) +return AVERROR(EINVAL); + +buf = av_buffer_ref(src->buf); +if (!buf) +return AVERROR(ENOMEM); + +if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) +remove_side_data(sd, nb_sd, src->type); + +sd_dst = add_side_data_to_set_from_buf(sd, nb_sd, src->type, buf); +if (!sd_dst) { +av_buffer_unref(&buf); +return AVERROR(ENOMEM); +} + +ret = av_dict_copy(&sd_dst->metadata, src->metadata, 0); +if (ret < 0) { +remove_side_data_by_entry(sd, nb_sd, sd_dst); +return ret; +} + +return 0; +} + AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 5d68d1e7af..ce93421d60 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1021,6 +1021,26 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags); +/** + * Add a new side data entry to an array based on existing side data, taking + * a reference towards the contained AVBufferRef. + * + * @param sdpointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param src side data to be cloned, with a new reference utilized + * for the buffer. + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return negative error code on failure, >=0 on success. In case of + * AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching + * AVFrameSideDataType will be removed before the addition is + * attempted. + */ +int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, + const AVFrameSideData *src, unsigned int flags); + /** * @} */ -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 05/14] avutil/frame: add helper for adding side data to array
Additionally, add an API test to check that the no-duplicates addition works after duplicates have been inserted. --- libavutil/Makefile | 1 + libavutil/frame.c | 17 ++ libavutil/frame.h | 22 +++ libavutil/tests/side_data_set.c | 103 tests/fate/libavutil.mak| 4 ++ tests/ref/fate/side_data_set| 14 + 6 files changed, 161 insertions(+) create mode 100644 libavutil/tests/side_data_set.c create mode 100644 tests/ref/fate/side_data_set diff --git a/libavutil/Makefile b/libavutil/Makefile index e7709b97d0..4415c913a1 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -271,6 +271,7 @@ TESTPROGS = adler32 \ ripemd \ sha \ sha512 \ +side_data_set \ softfloat \ tree\ twofish \ diff --git a/libavutil/frame.c b/libavutil/frame.c index dd27456031..4074391a92 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -747,6 +747,23 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame, return ret; } +AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, +enum AVFrameSideDataType type, +size_t size, unsigned int flags) +{ +AVBufferRef *buf = av_buffer_alloc(size); +AVFrameSideData *ret = NULL; + +if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) +remove_side_data(sd, nb_sd, type); + +ret = add_side_data_to_set_from_buf(sd, nb_sd, type, buf); +if (!ret) +av_buffer_unref(&buf); + +return ret; +} + AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 27281c168f..5d68d1e7af 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -999,6 +999,28 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type); */ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); +#define AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0) + +/** + * Add new side data entry to an array. + * + * @param sdpointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param type type of the added side data + * @param size size of the side data + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return newly added side data on success, NULL on error. In case of + * AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching + * AVFrameSideDataType will be removed before the addition is + * attempted. + */ +AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, +enum AVFrameSideDataType type, +size_t size, unsigned int flags); + /** * @} */ diff --git a/libavutil/tests/side_data_set.c b/libavutil/tests/side_data_set.c new file mode 100644 index 00..793a62c009 --- /dev/null +++ b/libavutil/tests/side_data_set.c @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2023 Jan Ekström + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libavutil/frame.c" +#include "libavutil/mastering_display_metadata.h" + +static void print_clls(const AVFrameSideData **sd, const int nb_sd) +{ +for (int i = 0; i < nb_sd; i++) { +const AVFrameSideData *entry = sd[i]; + +printf("sd %d, %s", + i, av_frame_side_data_name(entry->type)); + +if (entry->type != AV_FRAME_DATA_CONTENT_LIGHT_LEVEL) { +putchar('\n'); +continue; +
[FFmpeg-devel] [PATCH v9 04/14] avutil/frame: split side data removal out to non-AVFrame function
This will make it possible to reuse logic in further commits. --- libavutil/frame.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 9ebe830c5c..dd27456031 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -83,6 +83,21 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd) wipe_side_data(sd, nb_sd); } +static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data, + const enum AVFrameSideDataType type) +{ +for (int i = *nb_side_data - 1; i >= 0; i--) { +AVFrameSideData *entry = ((*sd)[i]); +if (entry->type != type) +continue; + +free_side_data(&entry); + +((*sd)[i]) = ((*sd)[*nb_side_data - 1]); +(*nb_side_data)--; +} +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_malloc(sizeof(*frame)); @@ -801,14 +816,7 @@ int av_frame_copy(AVFrame *dst, const AVFrame *src) void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type) { -for (int i = frame->nb_side_data - 1; i >= 0; i--) { -AVFrameSideData *sd = frame->side_data[i]; -if (sd->type == type) { -free_side_data(&frame->side_data[i]); -frame->side_data[i] = frame->side_data[frame->nb_side_data - 1]; -frame->nb_side_data--; -} -} +remove_side_data(&frame->side_data, &frame->nb_side_data, type); } const char *av_frame_side_data_name(enum AVFrameSideDataType type) -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 03/14] avutil/frame: split side_data_from_buf to base and AVFrame func
--- libavutil/frame.c | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index baac0706db..9ebe830c5c 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -679,23 +679,23 @@ AVBufferRef *av_frame_get_plane_buffer(const AVFrame *frame, int plane) return NULL; } -AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, - enum AVFrameSideDataType type, - AVBufferRef *buf) +static AVFrameSideData *add_side_data_to_set_from_buf(AVFrameSideData ***sd, + int *nb_sd, + enum AVFrameSideDataType type, + AVBufferRef *buf) { AVFrameSideData *ret, **tmp; if (!buf) return NULL; -if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1) +if (*nb_sd > INT_MAX / sizeof(*sd) - 1) return NULL; -tmp = av_realloc(frame->side_data, - (frame->nb_side_data + 1) * sizeof(*frame->side_data)); +tmp = av_realloc(*sd, (*nb_sd + 1) * sizeof(*sd)); if (!tmp) return NULL; -frame->side_data = tmp; +*sd = tmp; ret = av_mallocz(sizeof(*ret)); if (!ret) @@ -706,11 +706,20 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, ret->size = buf->size; ret->type = type; -frame->side_data[frame->nb_side_data++] = ret; +(*sd)[(*nb_sd)++] = ret; return ret; } +AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, + enum AVFrameSideDataType type, + AVBufferRef *buf) +{ +return +add_side_data_to_set_from_buf(&frame->side_data, &frame->nb_side_data, + type, buf); +} + AVFrameSideData *av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size) -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 02/14] avutil/frame: add helper for freeing arrays of side data
--- libavutil/frame.c | 5 + libavutil/frame.h | 11 +++ 2 files changed, 16 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index ab425b2235..baac0706db 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -78,6 +78,11 @@ static void frame_side_data_wipe(AVFrame *frame) wipe_side_data(&frame->side_data, &frame->nb_side_data); } +void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd) +{ +wipe_side_data(sd, nb_sd); +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_malloc(sizeof(*frame)); diff --git a/libavutil/frame.h b/libavutil/frame.h index b94687941d..27281c168f 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -988,6 +988,17 @@ int av_frame_apply_cropping(AVFrame *frame, int flags); */ const char *av_frame_side_data_name(enum AVFrameSideDataType type); +/** + * Free all side data entries and their contents, then zeroes out the + * values which the pointers are pointing to. + * + * @param sdpointer to array of side data to free. Will be set to NULL + * upon return. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. Will be set to 0 upon return. + */ +void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); + /** * @} */ -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 01/14] avutil/frame: split side data list wiping out to non-AVFrame function
This will make it possible to to reuse logic in further commits. --- libavutil/frame.c | 23 ++- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 079cf6595b..ab425b2235 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -63,14 +63,19 @@ static void free_side_data(AVFrameSideData **ptr_sd) av_freep(ptr_sd); } -static void wipe_side_data(AVFrame *frame) +static void wipe_side_data(AVFrameSideData ***sd, int *nb_side_data) { -for (int i = 0; i < frame->nb_side_data; i++) { -free_side_data(&frame->side_data[i]); +for (int i = 0; i < *nb_side_data; i++) { +free_side_data(&((*sd)[i])); } -frame->nb_side_data = 0; +*nb_side_data = 0; + +av_freep(sd); +} -av_freep(&frame->side_data); +static void frame_side_data_wipe(AVFrame *frame) +{ +wipe_side_data(&frame->side_data, &frame->nb_side_data); } AVFrame *av_frame_alloc(void) @@ -288,7 +293,7 @@ FF_ENABLE_DEPRECATION_WARNINGS sd_dst = av_frame_new_side_data(dst, sd_src->type, sd_src->size); if (!sd_dst) { -wipe_side_data(dst); +frame_side_data_wipe(dst); return AVERROR(ENOMEM); } memcpy(sd_dst->data, sd_src->data, sd_src->size); @@ -297,7 +302,7 @@ FF_ENABLE_DEPRECATION_WARNINGS sd_dst = av_frame_new_side_data_from_buf(dst, sd_src->type, ref); if (!sd_dst) { av_buffer_unref(&ref); -wipe_side_data(dst); +frame_side_data_wipe(dst); return AVERROR(ENOMEM); } } @@ -437,7 +442,7 @@ int av_frame_replace(AVFrame *dst, const AVFrame *src) if (ret < 0) goto fail; -wipe_side_data(dst); +frame_side_data_wipe(dst); av_dict_free(&dst->metadata); ret = frame_copy_props(dst, src, 0); if (ret < 0) @@ -536,7 +541,7 @@ void av_frame_unref(AVFrame *frame) if (!frame) return; -wipe_side_data(frame); +frame_side_data_wipe(frame); for (int i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++) av_buffer_unref(&frame->buf[i]); -- 2.44.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v9 00/14] encoder AVCodecContext configuration side data
Differences to v8: 1. rebased on top of current master 2. Applied changes based on comments done regarding the AVCodecContext, such as added details to the docstring as well as renaming the variable to `encoder_side_data` (ref: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20240229164307.3535613-10-jee...@gmail.com/ ). Comparison URL (mostly configure and wrappers, avutil/frame.c): https://github.com/jeeb/ffmpeg/compare/avcodec_cll_mdcv_side_data_v8..avcodec_cll_mdcv_side_data_v9 This patch set I've now been working for a while since I felt like it was weird we couldn't pass through information such as static HDR metadata to encoders from decoded input. This initial version adds the necessary framework, as well as adds static HDR metadata support for libsvtav1, libx264 as well as libx265 wrappers. An alternative to this would be to make encoders only properly initialize when they receive the first AVFrame, but that seems to be a bigger, nastier change than introducing an AVFrameSideDataSet in avctx as everything seems to presume that extradata etc are available after opening the encoder. Note: Any opinions on whether FFCodec or AVCodec should have handled_side_data list, so that if format specific generic logic is added, it could be checked whether the codec itself handles this side data? This could also be utilized to list handled side data from f.ex. `ffmpeg -h encoder=libsvtav1`. Jan Jan Ekström (14): avutil/frame: split side data list wiping out to non-AVFrame function avutil/frame: add helper for freeing arrays of side data avutil/frame: split side_data_from_buf to base and AVFrame func avutil/frame: split side data removal out to non-AVFrame function avutil/frame: add helper for adding side data to array avutil/frame: add helper for adding existing side data to array avutil/frame: add helper for adding side data w/ AVBufferRef to array avutil/frame: add helper for getting side data from array avcodec: add frame side data array to AVCodecContext avcodec: add helper for configuring AVCodecContext's frame side data ffmpeg: pass first video AVFrame's side data to encoder avcodec/libsvtav1: add support for writing out CLL and MDCV avcodec/libx264: add support for writing out CLL and MDCV avcodec/libx265: add support for writing out CLL and MDCV configure | 2 + fftools/ffmpeg_enc.c| 10 ++ libavcodec/avcodec.c| 31 ++ libavcodec/avcodec.h| 33 ++ libavcodec/libsvtav1.c | 69 libavcodec/libx264.c| 80 ++ libavcodec/libx265.c| 89 libavcodec/options.c| 2 + libavutil/Makefile | 1 + libavutil/frame.c | 180 ++-- libavutil/frame.h | 88 libavutil/tests/side_data_set.c | 103 ++ tests/fate/enc_external.mak | 15 +++ tests/fate/libavutil.mak| 4 + tests/ref/fate/libsvtav1-hdr10 | 14 +++ tests/ref/fate/libx264-hdr10| 15 +++ tests/ref/fate/libx265-hdr10| 16 +++ tests/ref/fate/side_data_set| 14 +++ 18 files changed, 736 insertions(+), 30 deletions(-) create mode 100644 libavutil/tests/side_data_set.c create mode 100644 tests/ref/fate/libsvtav1-hdr10 create mode 100644 tests/ref/fate/libx264-hdr10 create mode 100644 tests/ref/fate/libx265-hdr10 create mode 100644 tests/ref/fate/side_data_set Full diff based on the same base hash for v8->v9: diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 0ced87b946..3183952172 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -696,20 +696,21 @@ int avcodec_configure_side_data(AVCodecContext *avctx, if (!sd) { av_frame_side_data_free( -&avctx->frame_side_data, &avctx->nb_frame_side_data); +&avctx->encoder_side_data, &avctx->nb_encoder_side_data); return 0; } -if (nb_sd > 0 && nb_sd == avctx->nb_frame_side_data && -sd == (const AVFrameSideData **)avctx->frame_side_data) +if (nb_sd > 0 && nb_sd == avctx->nb_encoder_side_data && +sd == (const AVFrameSideData **)avctx->encoder_side_data) return AVERROR(EINVAL); for (int i = 0; i < nb_sd; i++) { int ret = av_frame_side_data_clone( -&avctx->frame_side_data, &avctx->nb_frame_side_data, sd[i], flags); +&avctx->encoder_side_data, &avctx->nb_encoder_side_data, sd[i], +flags); if (ret < 0) { av_frame_side_data_free( -&avctx->frame_side_data, &avctx->nb_frame_side_data); +&avctx->encoder_side_data, &avctx->nb_encoder_side_data); return ret; } } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 46523698ae..01085cc3c8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2064,12 +2064,16 @@ typedef
[FFmpeg-devel] [PATCH 2/2] avformat/riffdec: follow the MS docs more strictly for setting wav channel layouts
- Only parse the defined masks in dwChannelMask, unless strict_std_compliance is less than normal. This matches with the behaviour of the wav muxer. - Ignore additional bits in dwChannelMasks as the MS documentation suggests [1] - Assume UNKNOWN channels for missing bits as the MS documentation suggests [1] [1] https://learn.microsoft.com/en-us/previous-versions/windows/hardware/design/dn653308(v=vs.85)#details-about-dwchannelmask Signed-off-by: Marton Balint --- libavformat/riffdec.c | 28 +--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index 6cc912133c..0c7b2c6bdb 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -58,7 +58,7 @@ enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid) * an openended structure. */ -static void parse_waveformatex(AVFormatContext *ctx, AVIOContext *pb, AVCodecParameters *par) +static int parse_waveformatex(AVFormatContext *ctx, AVIOContext *pb, AVCodecParameters *par, int channels) { ff_asf_guid subformat; int bps; @@ -69,7 +69,26 @@ static void parse_waveformatex(AVFormatContext *ctx, AVIOContext *pb, AVCodecPar par->bits_per_coded_sample = bps; mask = avio_rl32(pb); /* dwChannelMask */ -av_channel_layout_from_mask(&par->ch_layout, mask); +if (ctx->strict_std_compliance >= FF_COMPLIANCE_NORMAL) +mask &= 0x3; + +/* According to MS docs, most significant bits should be ignored if mask + * has more bits than the number of channels */ +while (av_popcount64(mask) > channels) +mask &= ~(1LL << av_log2(mask)); + +/* If the mask has less bits than channels, then we assign the remaining + * channels as UNKNOWN. */ +if (mask && av_popcount64(mask) < channels) { +int ret = av_channel_layout_custom_init(&par->ch_layout, channels); +if (ret < 0) +return ret; +for (int i = 0, idx = 0; mask; i++, mask >>= 1) +if (mask & 1) +par->ch_layout.u.map[idx++].id = i; +} else { +av_channel_layout_from_mask(&par->ch_layout, mask); +} ff_get_guid(pb, &subformat); if (!memcmp(subformat + 4, @@ -88,6 +107,7 @@ static void parse_waveformatex(AVFormatContext *ctx, AVIOContext *pb, AVCodecPar "unknown subformat:"FF_PRI_GUID"\n", FF_ARG_GUID(subformat)); } +return 0; } /* "big_endian" values are needed for RIFX file format */ @@ -145,7 +165,9 @@ int ff_get_wav_header(AVFormatContext *ctx, AVIOContext *pb, size -= 18; cbSize = FFMIN(size, cbSize); if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */ -parse_waveformatex(ctx, pb, par); +ret = parse_waveformatex(ctx, pb, par, channels); +if (ret < 0) +return ret; cbSize -= 22; size -= 22; } -- 2.35.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avformat/riff: pass an AVFormatContext explicitly to ff_get_wav_header
Will be useful later. --- libavformat/riff.h| 2 +- libavformat/riffdec.c | 18 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libavformat/riff.h b/libavformat/riff.h index a93eadfeca..719fd7a17d 100644 --- a/libavformat/riff.h +++ b/libavformat/riff.h @@ -67,7 +67,7 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters *par, int for_asf, int int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags); enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps); -int ff_get_wav_header(void *logctx, AVIOContext *pb, AVCodecParameters *par, +int ff_get_wav_header(AVFormatContext *ctx, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian); extern const AVCodecTag ff_codec_bmp_tags[]; // exposed through avformat_get_riff_video_tags() diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c index 0fe4e02b7b..6cc912133c 100644 --- a/libavformat/riffdec.c +++ b/libavformat/riffdec.c @@ -58,7 +58,7 @@ enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid) * an openended structure. */ -static void parse_waveformatex(void *logctx, AVIOContext *pb, AVCodecParameters *par) +static void parse_waveformatex(AVFormatContext *ctx, AVIOContext *pb, AVCodecParameters *par) { ff_asf_guid subformat; int bps; @@ -84,21 +84,21 @@ static void parse_waveformatex(void *logctx, AVIOContext *pb, AVCodecParameters } else { par->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subformat); if (!par->codec_id) -av_log(logctx, AV_LOG_WARNING, +av_log(ctx, AV_LOG_WARNING, "unknown subformat:"FF_PRI_GUID"\n", FF_ARG_GUID(subformat)); } } /* "big_endian" values are needed for RIFX file format */ -int ff_get_wav_header(void *logctx, AVIOContext *pb, +int ff_get_wav_header(AVFormatContext *ctx, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian) { int id, channels = 0, ret; uint64_t bitrate = 0; if (size < 14) { -avpriv_request_sample(logctx, "wav header size < 14"); +avpriv_request_sample(ctx, "wav header size < 14"); return AVERROR_INVALIDDATA; } @@ -139,18 +139,18 @@ int ff_get_wav_header(void *logctx, AVIOContext *pb, if (size >= 18 && id != 0x0165) { /* We're obviously dealing with WAVEFORMATEX */ int cbSize = avio_rl16(pb); /* cbSize */ if (big_endian) { -avpriv_report_missing_feature(logctx, "WAVEFORMATEX support for RIFX files"); +avpriv_report_missing_feature(ctx, "WAVEFORMATEX support for RIFX files"); return AVERROR_PATCHWELCOME; } size -= 18; cbSize = FFMIN(size, cbSize); if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */ -parse_waveformatex(logctx, pb, par); +parse_waveformatex(ctx, pb, par); cbSize -= 22; size -= 22; } if (cbSize > 0) { -ret = ff_get_extradata(logctx, par, pb, cbSize); +ret = ff_get_extradata(ctx, par, pb, cbSize); if (ret < 0) return ret; size -= cbSize; @@ -163,7 +163,7 @@ int ff_get_wav_header(void *logctx, AVIOContext *pb, int nb_streams, i; size -= 4; -ret = ff_get_extradata(logctx, par, pb, size); +ret = ff_get_extradata(ctx, par, pb, size); if (ret < 0) return ret; nb_streams = AV_RL16(par->extradata + 4); @@ -179,7 +179,7 @@ int ff_get_wav_header(void *logctx, AVIOContext *pb, par->bit_rate = bitrate; if (par->sample_rate <= 0) { -av_log(logctx, AV_LOG_ERROR, +av_log(ctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", par->sample_rate); return AVERROR_INVALIDDATA; } -- 2.35.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/mov_chan: respect channel order when parsing and creating chan atom
Previously we always assumed that the channels are in native order, even if they were not. The new channel layout API allows us to signal the proper channel order, so let's do so. Fixes ticket #98. --- libavformat/mov_chan.c | 464 +++-- 1 file changed, 211 insertions(+), 253 deletions(-) diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c index ead3a9b91b..d48cfeabb0 100644 --- a/libavformat/mov_chan.c +++ b/libavformat/mov_chan.c @@ -25,228 +25,163 @@ #include +#include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavcodec/codec_id.h" #include "mov_chan.h" -struct MovChannelLayoutMap { -uint32_t tag; -uint64_t layout; -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_misc[] = { -{ MOV_CH_LAYOUT_USE_DESCRIPTIONS, 0 }, -{ MOV_CH_LAYOUT_USE_BITMAP, 0 }, -{ MOV_CH_LAYOUT_DISCRETEINORDER,0 }, -{ MOV_CH_LAYOUT_UNKNOWN,0 }, -{ MOV_CH_LAYOUT_TMH_10_2_STD, 0 }, // L, R, C,Vhc, Lsd, Rsd, - // Ls, Rs, Vhl, Vhr, Lw, Rw, - // Csd, Cs, LFE1, LFE2 -{ MOV_CH_LAYOUT_TMH_10_2_FULL, 0 }, // L, R, C,Vhc, Lsd, Rsd, - // Ls, Rs, Vhl, Vhr, Lw, Rw, - // Csd, Cs, LFE1, LFE2, Lc, Rc, - // HI, VI, Haptic -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_1ch[] = { -{ MOV_CH_LAYOUT_MONO, AV_CH_LAYOUT_MONO }, // C -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_2ch[] = { -{ MOV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_STEREO }, // L, R -{ MOV_CH_LAYOUT_STEREOHEADPHONES, AV_CH_LAYOUT_STEREO }, // L, R -{ MOV_CH_LAYOUT_BINAURAL, AV_CH_LAYOUT_STEREO }, // L, R -{ MOV_CH_LAYOUT_MIDSIDE,AV_CH_LAYOUT_STEREO }, // C, sides -{ MOV_CH_LAYOUT_XY, AV_CH_LAYOUT_STEREO }, // X (left), Y (right) - -{ MOV_CH_LAYOUT_MATRIXSTEREO, AV_CH_LAYOUT_STEREO_DOWNMIX }, // Lt, Rt - -{ MOV_CH_LAYOUT_AC3_1_0_1, AV_CH_LAYOUT_MONO |// C, LFE -AV_CH_LOW_FREQUENCY }, -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_3ch[] = { -{ MOV_CH_LAYOUT_MPEG_3_0_A, AV_CH_LAYOUT_SURROUND }, // L, R, C -{ MOV_CH_LAYOUT_MPEG_3_0_B, AV_CH_LAYOUT_SURROUND }, // C, L, R -{ MOV_CH_LAYOUT_AC3_3_0,AV_CH_LAYOUT_SURROUND }, // L, C, R - -{ MOV_CH_LAYOUT_ITU_2_1,AV_CH_LAYOUT_2_1 }, // L, R, Cs - -{ MOV_CH_LAYOUT_DVD_4, AV_CH_LAYOUT_2POINT1 }, // L, R, LFE -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_4ch[] = { -{ MOV_CH_LAYOUT_AMBISONIC_B_FORMAT, 0 },// W, X, Y, Z - -{ MOV_CH_LAYOUT_QUADRAPHONIC, AV_CH_LAYOUT_QUAD}, // L, R, Rls, Rrs - -{ MOV_CH_LAYOUT_MPEG_4_0_A, AV_CH_LAYOUT_4POINT0 }, // L, R, C, Cs -{ MOV_CH_LAYOUT_MPEG_4_0_B, AV_CH_LAYOUT_4POINT0 }, // C, L, R, Cs -{ MOV_CH_LAYOUT_AC3_3_1,AV_CH_LAYOUT_4POINT0 }, // L, C, R, Cs - -{ MOV_CH_LAYOUT_ITU_2_2,AV_CH_LAYOUT_2_2 }, // L, R, Ls, Rs - -{ MOV_CH_LAYOUT_DVD_5, AV_CH_LAYOUT_2_1 | // L, R, LFE, Cs -AV_CH_LOW_FREQUENCY }, -{ MOV_CH_LAYOUT_AC3_2_1_1, AV_CH_LAYOUT_2_1 | // L, R, Cs, LFE -AV_CH_LOW_FREQUENCY }, - -{ MOV_CH_LAYOUT_DVD_10, AV_CH_LAYOUT_3POINT1 }, // L, R, C, LFE -{ MOV_CH_LAYOUT_AC3_3_0_1, AV_CH_LAYOUT_3POINT1 }, // L, C, R, LFE -{ MOV_CH_LAYOUT_DTS_3_1,AV_CH_LAYOUT_3POINT1 }, // C, L, R, LFE -{ 0, 0 }, -}; - -static const struct MovChannelLayoutMap mov_ch_layout_map_5ch[] = { -{ MOV_CH_LAYOUT_PENTAGONAL, AV_CH_LAYOUT_5POINT0_BACK }, // L, R, Rls, Rrs, C - -{ MOV_CH_LAYOUT_MPEG_5_0_A, AV_CH_LAYOUT_5POINT0 }, // L, R, C, Ls, Rs -{ MOV_CH_LAYOUT_MPEG_5_0_B, AV_CH_LAYOUT_5POINT0 }, // L, R, Ls, Rs, C -{ MOV_CH_LAYOUT_MPEG_5_0_C, AV_CH_LAYOUT_5POINT0 }, // L, C, R, Ls, Rs -{ MOV_CH_LAYOUT_MPEG_5_0_D, AV_CH_LAYOUT_5POINT0 }, // C, L, R, Ls, Rs - -{ MOV_CH_LAYOUT_DVD_6, AV_CH_LAYOUT_2_2 | // L, R, LFE, Ls, Rs -AV_CH_LOW_FREQUENCY }, -{ MOV_CH_LAYOUT_DVD_18, AV_CH_LAYOUT_2_2 | // L, R, Ls, Rs, LFE -AV_CH_LOW_FREQUENCY }, - -{ MOV_CH_LAYOUT_DVD_11, AV_CH_LAYOUT_4POINT1 }, // L, R, C, LFE, Cs -{ MOV_CH_LAYO
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
On 2024-03-17 08:10, Timo Rothenpieler wrote It only breaks when statically linking. The symbol is not exported by libbr. In this case the only fix is to use a prefix in libbr, and who knows whether they will do that. I opened an issue with them but haven't received a reply yet. Just rename it with a define in CPPFLAGS and call it a day until they fix it in libbr. What is "it" and where? in the ffmpeg code or libbr? Cheers, K. C. -- regards Helmut K. C. Tessarek KeyID 0x172380A011EF4944 Key fingerprint = 8A55 70C1 BD85 D34E ADBC 386C 1723 80A0 11EF 4944 /* Thou shalt not follow the NULL pointer for chaos and madness await thee at its end. */ OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
Le 17 mars 2024 10:29:39 GMT-07:00, Andreas Rheinhardt a écrit : >Rémi Denis-Courmont: >> >> >> Le 16 mars 2024 13:58:23 GMT-07:00, James Almer a écrit : Seems the conflict comes from https://code.videolan.org/videolan/libbluray/-/blob/master/src/libbluray/disc/dec.c?ref_type=heads#L287 and https://github.com/FFmpeg/FFmpeg/commit/c4de5778bceab3c15f1239f1f16816749a7fd3b6 Perhaps you could also try asking libbluray if they could use an internal prefix. Otherwise you might need to do a rename of that function on ffmpeg's side. >>> >>> libbluray 100% needs to either prefix it, or hid it so it's not exported. >>> It's a library, so it should not be exporting such simple and short >>> unprefix named symbols. >> >> AFAICT, FFmpeg is just as guilty as Libbluray there. To support static >> linking, all non-static symbols should be name-spaced, and here both FFmpeg >> and libbluray are failing, and thus both should be fixed IMO. >> > >You forgot that FFmpeg's dec_init is in fftools/the executable, whereas >libbluray's is in the library. Oh well then it's 100% a problem with FFmpeg, or with the build system used by OP (Possibly a problem with Apple's tools). A static library being imported is not supposed to be able to cause symbol conflicts. To be clear, the poor choice of symbol name in libbluray might cause Libbluray to misbehave at runtime (due to its own fault), but not to fail linking. In other words, it's still two bugs, one in each project. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vulkan_av1: port to the new stable API
Mar 17, 2024, 16:36 by s...@jkqxz.net: > On 13/03/2024 16:38, Lynne wrote: > >> Tested by multiple users on multiple operating systems, >> driver implementations and test samples to work. >> >> Co-Authored-by: Dave Airlie >> >> From e2d31951f46fcc10e1263b8603e486e111e9578c Mon Sep 17 00:00:00 2001 >> From: Lynne >> Date: Fri, 19 Jan 2024 10:49:02 +1000 >> Subject: [PATCH v3 2/2] lavc/vulkan_av1: port to the new stable API >> >> Co-Authored-by: Dave Airlie >> --- >> configure | 4 +- >> libavcodec/Makefile | 5 +- >> libavcodec/av1.h | 2 + >> libavcodec/vulkan_av1.c | 502 ++ >> libavcodec/vulkan_decode.c| 31 +- >> libavcodec/vulkan_decode.h| 2 +- >> libavcodec/vulkan_video.h | 2 - >> .../vulkan_video_codec_av1std_decode_mesa.h | 36 -- >> libavcodec/vulkan_video_codec_av1std_mesa.h | 403 -- >> libavutil/hwcontext_vulkan.c | 2 +- >> libavutil/vulkan_functions.h | 2 +- >> libavutil/vulkan_loader.h | 2 +- >> 12 files changed, 300 insertions(+), 693 deletions(-) >> delete mode 100644 libavcodec/vulkan_video_codec_av1std_decode_mesa.h >> delete mode 100644 libavcodec/vulkan_video_codec_av1std_mesa.h >> >> diff --git a/configure b/configure >> index 05f8283af9..b07a742a74 100755 >> --- a/configure >> +++ b/configure >> @@ -7229,8 +7229,8 @@ enabled vdpau && >> check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 >> -lvdpau -lX11 >> >> if enabled vulkan; then >> -check_pkg_config_header_only vulkan "vulkan >= 1.3.255" >> "vulkan/vulkan.h" "defined VK_VERSION_1_3" || >> -check_cpp_condition vulkan "vulkan/vulkan.h" >> "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= >> 255)" >> +check_pkg_config_header_only vulkan "vulkan >= 1.3.277" >> "vulkan/vulkan.h" "defined VK_VERSION_1_3" || >> +check_cpp_condition vulkan "vulkan/vulkan.h" >> "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= >> 277)" >> > > This bumping the requirement to the latest version needs to stop at some > point. Vulkan is not an experimental thing any more, it should be usable in > released distributions. > >> fi >> >> if disabled vulkan; then >> diff --git a/libavcodec/Makefile b/libavcodec/Makefile >> index 708434ac76..c552f034b7 100644 >> --- a/libavcodec/Makefile >> +++ b/libavcodec/Makefile >> @@ -1258,8 +1258,7 @@ SKIPHEADERS+= %_tablegen.h >> \ >> aacenc_quantization.h \ >> aacenc_quantization_misc.h\ >> bitstream_template.h \ >> - vulkan_video_codec_av1std_mesa.h \ >> - $(ARCH)/vpx_arith.h \ >> + $(ARCH)/vpx_arith.h \ >> >> SKIPHEADERS-$(CONFIG_AMF) += amfenc.h >> SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h >> @@ -1280,7 +1279,7 @@ SKIPHEADERS-$(CONFIG_QSVENC) += qsvenc.h >> SKIPHEADERS-$(CONFIG_VAAPI)+= vaapi_decode.h vaapi_hevc.h >> vaapi_encode.h >> SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h >> SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h >> -SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h >> vulkan_decode.h vulkan_video_codec_av1std_decode_mesa.h >> +SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h >> vulkan_decode.h >> SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h >> v4l2_m2m.h >> SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h >> >> diff --git a/libavcodec/av1.h b/libavcodec/av1.h >> index 8704bc41c1..18d5fa9e7f 100644 >> --- a/libavcodec/av1.h >> +++ b/libavcodec/av1.h >> @@ -121,6 +121,8 @@ enum { >> AV1_DIV_LUT_NUM = 257, >> >> AV1_MAX_LOOP_FILTER = 63, >> + >> +AV1_RESTORATION_TILESIZE_MAX = 256, >> > > ? This isn't used anywhere. > >> }; >> >> >> diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c >> index 5afd5353cc..dc71ecf1fa 100644 >> --- a/libavcodec/vulkan_av1.c >> +++ b/libavcodec/vulkan_av1.c >> @@ -26,7 +26,7 @@ >> const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = { >> .codec_id = AV_CODEC_ID_AV1, >> .decode_extension = FF_VK_EXT_VIDEO_DECODE_AV1, >> -.decode_op= 0x0100, /* TODO fix this */ >> +.decode_op= VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR, >> .ext_props = { >> .extensionName = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME, >> .specVersion = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION, >> @@ -36,22 +36,34 @@ const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = { >> typedef struct AV1VulkanDecodePicture { >> FFVulkanDecodePicture
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
Rémi Denis-Courmont: > > > Le 16 mars 2024 13:58:23 GMT-07:00, James Almer a écrit : >>> Seems the conflict comes from >>> https://code.videolan.org/videolan/libbluray/-/blob/master/src/libbluray/disc/dec.c?ref_type=heads#L287 >>> and >>> https://github.com/FFmpeg/FFmpeg/commit/c4de5778bceab3c15f1239f1f16816749a7fd3b6 >>> >>> Perhaps you could also try asking libbluray if they could use an internal >>> prefix. Otherwise you might need to do a rename of that function on >>> ffmpeg's side. >> >> libbluray 100% needs to either prefix it, or hid it so it's not exported. >> It's a library, so it should not be exporting such simple and short unprefix >> named symbols. > > AFAICT, FFmpeg is just as guilty as Libbluray there. To support static > linking, all non-static symbols should be name-spaced, and here both FFmpeg > and libbluray are failing, and thus both should be fixed IMO. > You forgot that FFmpeg's dec_init is in fftools/the executable, whereas libbluray's is in the library. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
Le 16 mars 2024 13:58:23 GMT-07:00, James Almer a écrit : >> Seems the conflict comes from >> https://code.videolan.org/videolan/libbluray/-/blob/master/src/libbluray/disc/dec.c?ref_type=heads#L287 >> and >> https://github.com/FFmpeg/FFmpeg/commit/c4de5778bceab3c15f1239f1f16816749a7fd3b6 >> >> Perhaps you could also try asking libbluray if they could use an internal >> prefix. Otherwise you might need to do a rename of that function on >> ffmpeg's side. > >libbluray 100% needs to either prefix it, or hid it so it's not exported. It's >a library, so it should not be exporting such simple and short unprefix named >symbols. AFAICT, FFmpeg is just as guilty as Libbluray there. To support static linking, all non-static symbols should be name-spaced, and here both FFmpeg and libbluray are failing, and thus both should be fixed IMO. >___ >ffmpeg-devel mailing list >ffmpeg-devel@ffmpeg.org >https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > >To unsubscribe, visit link above, or email >ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavcodec/amfenc: Update AMF encoder options
On 14/03/2024 10:51, Araz Iusubov wrote: The encoder options have been updated to the current version of the AMF. Signed-off-by: Araz Iusubov --- libavcodec/amfenc.c | 1 + libavcodec/amfenc.h | 4 + libavcodec/amfenc_av1.c | 154 +- libavcodec/amfenc_h264.c | 155 +- libavcodec/amfenc_hevc.c | 158 ++- 5 files changed, 314 insertions(+), 158 deletions(-) This needs more explanation. What is different about the current version and why does it require these changes? The change is also mixing cosmetic changes and refactoring of some existing elements with addition of new options; ideally you would want to split this into multiple patches for each change. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] lavc/vp8dsp: R-V V put_bilin_h
ping flow gg 于2024年3月3日周日 23:03写道: > Sorry since I did not send the emails all at once, so cannot apply all 4 > patches together with git am *.patch. Instead, it needs to first apply the > patch with 'git am '[PATCH] lavc/vp8dsp: R-V V put_vp8_pixels'', and then > apply the patches 1-3 in the series with 'git am *.patch'. > > Rémi Denis-Courmont 于2024年3月3日周日 22:39写道: > >> Le perjantaina 23. helmikuuta 2024, 16.45.46 EET flow gg a écrit : >> > >> >> Looks like this needs rebasing, or otherwise does not apply. >> >> -- >> Rémi Denis-Courmont >> http://www.remlab.net/ >> >> >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> >> To unsubscribe, visit link above, or email >> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". >> > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vulkan_av1: port to the new stable API
On 13/03/2024 16:38, Lynne wrote: Tested by multiple users on multiple operating systems, driver implementations and test samples to work. Co-Authored-by: Dave Airlie > From e2d31951f46fcc10e1263b8603e486e111e9578c Mon Sep 17 00:00:00 2001 > From: Lynne > Date: Fri, 19 Jan 2024 10:49:02 +1000 > Subject: [PATCH v3 2/2] lavc/vulkan_av1: port to the new stable API > > Co-Authored-by: Dave Airlie > --- > configure | 4 +- > libavcodec/Makefile | 5 +- > libavcodec/av1.h | 2 + > libavcodec/vulkan_av1.c | 502 ++ > libavcodec/vulkan_decode.c| 31 +- > libavcodec/vulkan_decode.h| 2 +- > libavcodec/vulkan_video.h | 2 - > .../vulkan_video_codec_av1std_decode_mesa.h | 36 -- > libavcodec/vulkan_video_codec_av1std_mesa.h | 403 -- > libavutil/hwcontext_vulkan.c | 2 +- > libavutil/vulkan_functions.h | 2 +- > libavutil/vulkan_loader.h | 2 +- > 12 files changed, 300 insertions(+), 693 deletions(-) > delete mode 100644 libavcodec/vulkan_video_codec_av1std_decode_mesa.h > delete mode 100644 libavcodec/vulkan_video_codec_av1std_mesa.h > > diff --git a/configure b/configure > index 05f8283af9..b07a742a74 100755 > --- a/configure > +++ b/configure > @@ -7229,8 +7229,8 @@ enabled vdpau && > check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau -lX11 > > if enabled vulkan; then > -check_pkg_config_header_only vulkan "vulkan >= 1.3.255" "vulkan/vulkan.h" "defined VK_VERSION_1_3" || > -check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 255)" > +check_pkg_config_header_only vulkan "vulkan >= 1.3.277" "vulkan/vulkan.h" "defined VK_VERSION_1_3" || > +check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 277)" This bumping the requirement to the latest version needs to stop at some point. Vulkan is not an experimental thing any more, it should be usable in released distributions. > fi > > if disabled vulkan; then > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 708434ac76..c552f034b7 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1258,8 +1258,7 @@ SKIPHEADERS+= %_tablegen.h \ >aacenc_quantization.h \ >aacenc_quantization_misc.h\ >bitstream_template.h \ > - vulkan_video_codec_av1std_mesa.h \ > - $(ARCH)/vpx_arith.h \ > + $(ARCH)/vpx_arith.h \ > > SKIPHEADERS-$(CONFIG_AMF) += amfenc.h > SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h > @@ -1280,7 +1279,7 @@ SKIPHEADERS-$(CONFIG_QSVENC) += qsvenc.h > SKIPHEADERS-$(CONFIG_VAAPI)+= vaapi_decode.h vaapi_hevc.h vaapi_encode.h > SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h > SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h > -SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_decode.h vulkan_video_codec_av1std_decode_mesa.h > +SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_decode.h > SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m.h > SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h > > diff --git a/libavcodec/av1.h b/libavcodec/av1.h > index 8704bc41c1..18d5fa9e7f 100644 > --- a/libavcodec/av1.h > +++ b/libavcodec/av1.h > @@ -121,6 +121,8 @@ enum { > AV1_DIV_LUT_NUM = 257, > > AV1_MAX_LOOP_FILTER = 63, > + > +AV1_RESTORATION_TILESIZE_MAX = 256, ? This isn't used anywhere. > }; > > > diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c > index 5afd5353cc..dc71ecf1fa 100644 > --- a/libavcodec/vulkan_av1.c > +++ b/libavcodec/vulkan_av1.c > @@ -26,7 +26,7 @@ > const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = { > .codec_id = AV_CODEC_ID_AV1, > .decode_extension = FF_VK_EXT_VIDEO_DECODE_AV1, > -.decode_op= 0x0100, /* TODO fix this */ > +.decode_op= VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR, > .ext_props = { > .extensionName = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME, > .specVersion = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION, > @@ -36,22 +36,34 @@ const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = { > typedef struct AV1VulkanDecodePicture { > FFVulkanDecodePicture vp; > > -/* Workarou
Re: [FFmpeg-devel] [PATCH 1/3] tools/target_dem_fuzzer: add libavformat/demux.h
Michael Niedermayer: > needed for FFInputFormat > > Signed-off-by: Michael Niedermayer > --- > tools/target_dem_fuzzer.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/target_dem_fuzzer.c b/tools/target_dem_fuzzer.c > index 76eed9f6a2..fe69eb9be0 100644 > --- a/tools/target_dem_fuzzer.c > +++ b/tools/target_dem_fuzzer.c > @@ -23,7 +23,7 @@ > #include "libavcodec/avcodec.h" > #include "libavcodec/bytestream.h" > #include "libavformat/avformat.h" > - > +#include "libavformat/demux.h" > > typedef struct IOContext { > int64_t pos; LGTM. Sorry for the breakage. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] avutil/hwcontext_d3d11va: add logging to dxgi debug interfaces
On 14.03.2024 22:26, Timo Rothenpieler wrote: --- libavutil/hwcontext_d3d11va.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 1b96c38d25..e30c8fc238 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -685,9 +685,17 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, if (pf_DXGIGetDebugInterface) { IDXGIDebug *dxgi_debug = NULL; hr = pf_DXGIGetDebugInterface(&IID_IDXGIDebug, (void**)&dxgi_debug); -if (SUCCEEDED(hr) && dxgi_debug) +if (SUCCEEDED(hr) && dxgi_debug) { IDXGIDebug_ReportLiveObjects(dxgi_debug, DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL); +av_log(ctx, AV_LOG_INFO, "Enabled dxgi debugging.\n"); +} else { +av_log(ctx, AV_LOG_WARNING, "Failed enabling dxgi debugging.\n"); +} +} else { +av_log(ctx, AV_LOG_WARNING, "Failed getting dxgi debug interface.\n"); } +} else { +av_log(ctx, AV_LOG_WARNING, "Failed loading dxgi debug library.\n"); } } #endif will apply series soon if nobody objects ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] fate/lavf-audio: Test writing AIFF-native tags
Andreas Rheinhardt: > In particular, test writing tags with odd strlen. > (These tags are zero-padded to even size.) > > Signed-off-by: Andreas Rheinhardt > --- > tests/fate/lavf-audio.mak | 1 + > tests/ref/lavf/aiff | 4 ++-- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/tests/fate/lavf-audio.mak b/tests/fate/lavf-audio.mak > index d54cd107e0..7ea0c41da9 100644 > --- a/tests/fate/lavf-audio.mak > +++ b/tests/fate/lavf-audio.mak > @@ -28,6 +28,7 @@ $(FATE_LAVF_AUDIO): CMD = lavf_audio > $(FATE_LAVF_AUDIO): REF = $(SRC_PATH)/tests/ref/lavf/$(@:fate-lavf-%=%) > $(FATE_LAVF_AUDIO): $(AREF) > > +fate-lavf-aiff: CMD = lavf_audio "" "-metadata copyright=noone" > fate-lavf-al fate-lavf-ul: CMD = lavf_audio "" "" "-ar 44100" > fate-lavf-dfpwm: CMD = lavf_audio "" "" "-sample_rate 44100" > fate-lavf-ogg: CMD = lavf_audio "" "-c:a flac" > diff --git a/tests/ref/lavf/aiff b/tests/ref/lavf/aiff > index d72ec85150..e208ff3e16 100644 > --- a/tests/ref/lavf/aiff > +++ b/tests/ref/lavf/aiff > @@ -1,3 +1,3 @@ > -2c129d88acef834e32869145fe792b9c *tests/data/lavf/lavf.aiff > -88270 tests/data/lavf/lavf.aiff > +655b5bd68e7a59599ab6663de0015324 *tests/data/lavf/lavf.aiff > +88284 tests/data/lavf/lavf.aiff > tests/data/lavf/lavf.aiff CRC=0x3a1da17e Will apply this patchset with the fate references updated. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avutil/hash: Avoid relocations for hash names
Andreas Rheinhardt: > These strings are so short (longest takes 11B) that using > pointers is wasteful. Avoiding them also moves hashdesc > into .rodata (from .data.rel.ro). > > Signed-off-by: Andreas Rheinhardt > --- > libavutil/hash.c | 71 +++- > 1 file changed, 40 insertions(+), 31 deletions(-) > > diff --git a/libavutil/hash.c b/libavutil/hash.c > index 12333982fb..43f77852da 100644 > --- a/libavutil/hash.c > +++ b/libavutil/hash.c > @@ -38,22 +38,27 @@ > #include "intreadwrite.h" > #include "mem.h" > > +// ENTRY(HASH_TYPE, HASH_NAME, HASH_SIZE) > +#define HASHES(ENTRY) \ > +ENTRY(MD5,"MD5",16) \ > +ENTRY(MURMUR3,"murmur3",16) \ > +ENTRY(RIPEMD128, "RIPEMD128", 16) \ > +ENTRY(RIPEMD160, "RIPEMD160", 20) \ > +ENTRY(RIPEMD256, "RIPEMD256", 32) \ > +ENTRY(RIPEMD320, "RIPEMD320", 40) \ > +ENTRY(SHA160, "SHA160", 20) \ > +ENTRY(SHA224, "SHA224", 28) \ > +ENTRY(SHA256, "SHA256", 32) \ > +ENTRY(SHA512_224, "SHA512/224", 28) \ > +ENTRY(SHA512_256, "SHA512/256", 32) \ > +ENTRY(SHA384, "SHA384", 48) \ > +ENTRY(SHA512, "SHA512", 64) \ > +ENTRY(CRC32, "CRC32", 4) \ > +ENTRY(ADLER32,"adler32", 4) \ > + > enum hashtype { > -MD5, > -MURMUR3, > -RIPEMD128, > -RIPEMD160, > -RIPEMD256, > -RIPEMD320, > -SHA160, > -SHA224, > -SHA256, > -SHA512_224, > -SHA512_256, > -SHA384, > -SHA512, > -CRC32, > -ADLER32, > +#define HASH_TYPE(TYPE, NAME, SIZE) TYPE, > +HASHES(HASH_TYPE) > NUM_HASHES > }; > > @@ -64,25 +69,29 @@ typedef struct AVHashContext { > uint32_t crc; > } AVHashContext; > > +#define HASH_MAX_SIZE(TYPE, NAME, SIZE) \ > +HASH_MAX_SIZE_BEFORE_ ## TYPE, \ > +HASH_MAX_SIZE_UNTIL_ ## TYPE ## _MINUS_ONE = FFMAX(SIZE, > HASH_MAX_SIZE_BEFORE_ ## TYPE) - 1, > +enum { > +HASHES(HASH_MAX_SIZE) > +MAX_HASH_SIZE > +}; > +_Static_assert(AV_HASH_MAX_SIZE >= MAX_HASH_SIZE, "AV_HASH_MAX_SIZE needs to > be updated!"); > + > +#define HASH_MAX_NAME_SIZE(TYPE, NAME, SIZE) \ > +HASH_MAX_NAME_SIZE_BEFORE_ ## TYPE, \ > +HASH_MAX_NAME_SIZE_UNTIL_ ## TYPE ## _MINUS_ONE = FFMAX(sizeof(NAME), > HASH_MAX_NAME_SIZE_BEFORE_ ## TYPE) - 1, > +enum { > +HASHES(HASH_MAX_NAME_SIZE) > +MAX_HASH_NAME_SIZE > +}; > + > static const struct { > -const char *name; > +const char name[MAX_HASH_NAME_SIZE]; > int size; > } hashdesc[] = { > -[MD5] = {"MD5", 16}, > -[MURMUR3] = {"murmur3", 16}, > -[RIPEMD128] = {"RIPEMD128", 16}, > -[RIPEMD160] = {"RIPEMD160", 20}, > -[RIPEMD256] = {"RIPEMD256", 32}, > -[RIPEMD320] = {"RIPEMD320", 40}, > -[SHA160] = {"SHA160", 20}, > -[SHA224] = {"SHA224", 28}, > -[SHA256] = {"SHA256", 32}, > -[SHA512_224] = {"SHA512/224", 28}, > -[SHA512_256] = {"SHA512/256", 32}, > -[SHA384] = {"SHA384", 48}, > -[SHA512] = {"SHA512", 64}, > -[CRC32] = {"CRC32",4}, > -[ADLER32] = {"adler32", 4}, > +#define HASH_DESC(TYPE, NAME, SIZE) [TYPE] = { NAME, SIZE }, > +HASHES(HASH_DESC) > }; > > const char *av_hash_names(int i) Will apply tomorrow unless there are objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/mips/aaccoder_mips: Remove MIPS-specific aaccoder
Andreas Rheinhardt: > ff_aac_coder_init_mips() modifies a static const structure of > function pointers. This will crash if the binary uses relro > and is a data race in any case. > > Furthermore it points to a maintainability issue: The > AACCoefficientsEncoder structures have been constified > in commit fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3, > a Libav commit merged in 318778de9ebec276cb9dfc65509231ca56590d13. > Libav did not have the MIPS-specific AAC code and so this was > fine for them; yet FFmpeg had them, but this was not recognized. > > Commit 75a099fc734a4ee2b1347d0a3d8c53d883b95174 points to another > maintainability issue: Contrary to ordinary DSP code, this code > here is way more complex and needs to be constantly kept in sync > with the ordinary code which it mimicks and replaces. Said commit > is the only commit actually changing aaccoder.c in the last few > years and the same change has not been performed for the MIPS > clone; before that, it even happened several times that the mips > code was broken due to changes of the generic code (see commits > 97437bd17a8c5d4135b2f3b1b299bd7bb72ce02c and > de262d018d7d7d9c967af1dfd1b861c4b9eb2a60 or > 860dbe0275e57cbf4228f3f653f872ff66ca596b or > 933309a6ca0f18bf1d40e917fff455221f57fb4b or > b65ffa316e377213c29736929beba584d0d80d7c). This might even lead > to scenarios where someone changing non-dsp aacenc code would > have to modify mips inline asm in order to keep them in sync. > This is obviously a significant burden (if the AAC encoder were > actively developed). > > Finally, the code does not even compile here due to errors like > "Error: float register should be even, was 1". > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/aacenc.c |4 - > libavcodec/aacenc.h |1 - > libavcodec/mips/Makefile|1 - > libavcodec/mips/aaccoder_mips.c | 2503 --- > 4 files changed, 2509 deletions(-) > delete mode 100644 libavcodec/mips/aaccoder_mips.c > > diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c > index 3f99188be4..55fa307809 100644 > --- a/libavcodec/aacenc.c > +++ b/libavcodec/aacenc.c > @@ -1383,10 +1383,6 @@ static av_cold int aac_encode_init(AVCodecContext > *avctx) > > ff_aacenc_dsp_init(&s->aacdsp); > > -#if HAVE_MIPSDSP > -ff_aac_coder_init_mips(s); > -#endif > - > ff_af_queue_init(avctx, &s->afq); > > return 0; > diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h > index c18e828905..8899f90ac7 100644 > --- a/libavcodec/aacenc.h > +++ b/libavcodec/aacenc.h > @@ -241,7 +241,6 @@ typedef struct AACEncContext { > } buffer; > } AACEncContext; > > -void ff_aac_coder_init_mips(AACEncContext *c); > void ff_quantize_band_cost_cache_init(struct AACEncContext *s); > > > diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile > index 45c56e8ad9..50fe38a50e 100644 > --- a/libavcodec/mips/Makefile > +++ b/libavcodec/mips/Makefile > @@ -19,7 +19,6 @@ OBJS-$(CONFIG_AAC_DECODER)+= > mips/aacdec_mips.o\ > mips/aacsbr_mips.o\ > mips/sbrdsp_mips.o\ > mips/aacpsdsp_mips.o > -MIPSDSP-OBJS-$(CONFIG_AAC_ENCODER)+= mips/aaccoder_mips.o > MIPSFPU-OBJS-$(CONFIG_AAC_ENCODER)+= mips/iirfilter_mips.o > OBJS-$(CONFIG_HEVC_DECODER) += mips/hevcdsp_init_mips.o \ > mips/hevcpred_init_mips.o > diff --git a/libavcodec/mips/aaccoder_mips.c b/libavcodec/mips/aaccoder_mips.c > deleted file mode 100644 > index dd9661fbdd..00 > --- a/libavcodec/mips/aaccoder_mips.c > +++ /dev/null > @@ -1,2503 +0,0 @@ > -/* > - * Copyright (c) 2012 > - * MIPS Technologies, Inc., California. > - * > - * Redistribution and use in source and binary forms, with or without > - * modification, are permitted provided that the following conditions > - * are met: > - * 1. Redistributions of source code must retain the above copyright > - *notice, this list of conditions and the following disclaimer. > - * 2. Redistributions in binary form must reproduce the above copyright > - *notice, this list of conditions and the following disclaimer in the > - *documentation and/or other materials provided with the distribution. > - * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its > - *contributors may be used to endorse or promote products derived from > - *this software without specific prior written permission. > - * > - * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND > - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > - * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE > - * FOR ANY DIRECT, INDIR
Re: [FFmpeg-devel] [PATCH] avformat/crypto: Avoid cast, use proper printf specifier
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavformat/crypto.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/crypto.c b/libavformat/crypto.c > index 75b00020bc..4393fb6399 100644 > --- a/libavformat/crypto.c > +++ b/libavformat/crypto.c > @@ -254,7 +254,7 @@ static int64_t crypto_seek(URLContext *h, int64_t pos, > int whence) > newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); > if (newpos < 0) { > av_log(h, AV_LOG_ERROR, > -"Crypto: seek_end - can't get file size (pos=%lld)\r\n", > (long long int)pos); > +"Crypto: seek_end - can't get file size > (pos=%"PRId64")\r\n", pos); > return newpos; > } > pos = newpos - pos; Will apply tomorrow unless there are objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/ccaption_dec: Use static_assert instead of _Static_assert
Andreas Rheinhardt: > The latter is not supported by MSVC 19.27. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/ccaption_dec.c | 7 --- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c > index faf058ce97..d8b992bb94 100644 > --- a/libavcodec/ccaption_dec.c > +++ b/libavcodec/ccaption_dec.c > @@ -19,6 +19,7 @@ > * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > */ > > +#include > #include "avcodec.h" > #include "ass.h" > #include "codec_internal.h" > @@ -180,9 +181,9 @@ static const char > charset_overrides[4][128][sizeof("\u266a")] = > }; > #define EMPTY_START(IDX) > #define EMPTY_END > -#define ASSERT_ENTRY(IDX, str) \ > -_Static_assert(sizeof(str) <= sizeof(charset_overrides[0][0]), \ > - "'" str "' string takes too much space"); > +#define ASSERT_ENTRY(IDX, str)\ > +static_assert(sizeof(str) <= sizeof(charset_overrides[0][0]), \ > + "'" str "' string takes too much space"); > CHARSET_OVERRIDE_LIST(EMPTY_START, ASSERT_ENTRY, EMPTY_END) > > static const unsigned char bg_attribs[8] = // Color Will apply tomorrow unless there are objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/aeaenc: Fix printf-specifier
Andreas Rheinhardt: > Signed-off-by: Andreas Rheinhardt > --- > libavformat/aeaenc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/aeaenc.c b/libavformat/aeaenc.c > index 65d018c844..495e98c6a2 100644 > --- a/libavformat/aeaenc.c > +++ b/libavformat/aeaenc.c > @@ -91,7 +91,7 @@ static int aea_write_trailer(struct AVFormatContext *s) > avio_seek(pb, 260, SEEK_SET); > total_blocks = st->nb_frames * st->codecpar->ch_layout.nb_channels; > if (total_blocks > UINT32_MAX) { > -av_log(s, AV_LOG_WARNING, "Too many frames in the file to > properly encode the header (%ld)." > +av_log(s, AV_LOG_WARNING, "Too many frames in the file to > properly encode the header (%"PRId64")." > " Block count in the header will be truncated.\n", > total_blocks); > total_blocks = UINT32_MAX; > } Will apply tomorrow unless there are objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avutil/x86util: Fix broken pre-SSE4.1 PMINSD emulation
On Sun, Mar 17, 2024 at 1:44 PM James Almer wrote: > LGTM. I wonder why we even added a float based fallback for this. Thanks, pushed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 9/9] avformat/pcm: decrease target audio frame per sec to 10
On Thu, Mar 14, 2024 at 11:30 PM Marton Balint wrote: > > > On Thu, 14 Mar 2024, Paul B Mahol wrote: > > > This is just ugly hack for workaround around broken ffmpeg threading. > > This actually improves single threaded performance as well, check it with > ffprobe if you want. Sure, the reason I turned my attention to this is > the speed loss of ffmpeg.c because of threaded processing, but this is an > improvement regardless of threaded or non-threaded use. > The single thread improvement is less drastic than multi-threading drop with small packets. Just compare with using API directly and avoiding ffmpeg.c threading mess. > > Regards, > Marton > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avutil/x86util: Fix broken pre-SSE4.1 PMINSD emulation
On 3/17/2024 9:27 AM, Henrik Gramner via ffmpeg-devel wrote: Fixes yadif-16 which allows FATE to pass. Broken since 2904db90458a1253e4aea6844ba9a59ac11923b6 (2017). LGTM. I wonder why we even added a float based fallback for this. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avutil/x86util: Fix broken pre-SSE4.1 PMINSD emulation
Fixes yadif-16 which allows FATE to pass. Broken since 2904db90458a1253e4aea6844ba9a59ac11923b6 (2017). pminsd_emulation.patch Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
On 17.03.2024 09:05, Gnattu OC via ffmpeg-devel wrote: Can you try to change the `BD_PRIVATE` to `__attribute__((visibility("hidden")))` in the line defines `dec_init` src/libbluray/disc/dec.h then recompile libbluray to see if it fixes the linking issue? It only breaks when statically linking. The symbol is not exported by libbr. Just rename it with a define in CPPFLAGS and call it a day until they fix it in libbr. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] duplicate symbol '_dec_init' in: fftools/ffmpeg_dec.o
Can you try to change the `BD_PRIVATE` to `__attribute__((visibility("hidden")))` in the line defines `dec_init` src/libbluray/disc/dec.h then recompile libbluray to see if it fixes the linking issue? > On Mar 17, 2024, at 05:09, Helmut K. C. Tessarek wrote: > > Hi, > > On 2024-03-16 10:26, Christopher Degawa wrote: >> Seems the conflict comes from >> https://code.videolan.org/videolan/libbluray/-/blob/master/src/libbluray/disc/dec.c?ref_type=heads#L287 >> and >> https://github.com/FFmpeg/FFmpeg/commit/c4de5778bceab3c15f1239f1f16816749a7fd3b6 >> Perhaps you could also try asking libbluray if they could use an internal >> prefix. Otherwise you might need to do a rename of that function on >> ffmpeg's side. > > Hmm, this commit in ffmpeg broke the possibility to link ffmpeg with > libbluray. Just to make this perfectly clear, before that commit it worked > without issues. > > This means that nobody is able to use libbluray and ffmpeg from this point > forward. I am sorry, but this commit should be reverted. > > The commit message reads: Rename dec_open to dec_init(), as it is more > descriptive of its new purpose. > > Who cares about how descriptive it is as long as it works. Now it doesn't. > This was not a change to implement a feature or fix a bug, but a simple > refactor, because somebody didn't like the name. > > In reality I agree with you that it might be better for libbluray to use a > prefix/namespace or whatever. But until then, ffmpeg should still be able to > be linked with libbluray. > > Is my standpoint unreasonable? If so, why? > > Cheers, > K. C. > > -- > regards Helmut K. C. Tessarek KeyID 0x172380A011EF4944 > Key fingerprint = 8A55 70C1 BD85 D34E ADBC 386C 1723 80A0 11EF 4944 > > /* > Thou shalt not follow the NULL pointer for chaos and madness > await thee at its end. > */ > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".