Re: [FFmpeg-devel] [PATCH v2] avutils/hwcontext: When deriving a hwdevice, search for existing device in both directions
> -Original Message- > From: ffmpeg-devel On Behalf Of Soft > Works > Sent: Wednesday, September 8, 2021 2:25 PM > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH v2] avutils/hwcontext: When deriving a > hwdevice, search for existing device in both directions > > > > > -Original Message- > > From: ffmpeg-devel On Behalf Of > > Chen, Wenbin > > Sent: Wednesday, 8 September 2021 07:58 > > To: FFmpeg development discussions and patches > de...@ffmpeg.org> > > Subject: Re: [FFmpeg-devel] [PATCH v2] avutils/hwcontext: When > > deriving a hwdevice, search for existing device in both directions > > > > Hi softworkz: > > > > Any updates on this patch? > > I want to submit pathes to qsv, but they depends on this patch > > > > Thanks > > Wenbin > > Hi Wenbin, > > Haihao has discovered a regression but I haven't looked into it > yet. Will do within the next few days. > > softworkz Got it Thank you > ___ > 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] libavfilter: add a gblur_vulkan filter
On Wed, Sep 8, 2021 at 8:13 AM Wu Jianhua wrote: > This commit adds a powerful and customizable gblur Vulkan filter, > which provides a maximum 127x127 kernel size of Gaussian Filter. > The size could be adjusted by requirements on quality or performance. > > The following command is on how to apply gblur_vulkan filter: > > ffmpeg -init_hw_device vulkan=vul:0 -filter_hw_device vul -i input.264 > -vf hwupload=extra_hw_frames=16,gblur_vulkan,hwdownload,format=yuv420p > output.264 > > Signed-off-by: Wu Jianhua > --- > Changelog | 2 +- > configure | 1 + > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/vf_gblur_vulkan.c | 509 ++ > 5 files changed, 513 insertions(+), 1 deletion(-) > create mode 100644 libavfilter/vf_gblur_vulkan.c > > diff --git a/Changelog b/Changelog > index 5b58401183..bc36fa09e4 100644 > --- a/Changelog > +++ b/Changelog > @@ -148,7 +148,7 @@ version 4.3: > - LEGO Racers ALP (.tun & .pcm) demuxer > - AMQP 0-9-1 protocol (RabbitMQ) > - Vulkan support > -- avgblur_vulkan, overlay_vulkan, scale_vulkan and chromaber_vulkan > filters > +- avgblur_vulkan, overlay_vulkan, scale_vulkan, chromaber_vulkan and > gblur_vulkan filters > Can't do that. > - ADPCM IMA MTF decoder > - FWSE demuxer > - DERF DPCM decoder > diff --git a/configure b/configure > index af410a9d11..4b9a0d8e07 100755 > --- a/configure > +++ b/configure > @@ -3601,6 +3601,7 @@ freezedetect_filter_select="scene_sad" > frei0r_filter_deps="frei0r libdl" > frei0r_src_filter_deps="frei0r libdl" > fspp_filter_deps="gpl" > +gblur_vulkan_filter_deps="vulkan_lib libglslang" > histeq_filter_deps="gpl" > hqdn3d_filter_deps="gpl" > interlace_filter_deps="gpl" > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index af957a5ac0..5f74e33599 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -286,6 +286,7 @@ OBJS-$(CONFIG_FREEZEFRAMES_FILTER) += > vf_freezeframes.o > OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o > OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o qp_table.o > OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o > +OBJS-$(CONFIG_GBLUR_VULKAN_FILTER) += vf_gblur_vulkan.o vulkan.o > OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o > OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o > OBJS-$(CONFIG_GRAPHMONITOR_FILTER) += f_graphmonitor.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index 0c6b2347c8..b5576de3af 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -271,6 +271,7 @@ extern const AVFilter ff_vf_freezeframes; > extern const AVFilter ff_vf_frei0r; > extern const AVFilter ff_vf_fspp; > extern const AVFilter ff_vf_gblur; > +extern const AVFilter ff_vf_gblur_vulkan; > extern const AVFilter ff_vf_geq; > extern const AVFilter ff_vf_gradfun; > extern const AVFilter ff_vf_graphmonitor; > diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c > new file mode 100644 > index 00..c1693f5d66 > --- /dev/null > +++ b/libavfilter/vf_gblur_vulkan.c > @@ -0,0 +1,509 @@ > +/* > + * copyright (c) 2021 Wu Jianhua > + * 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 "libavutil/random_seed.h" > +#include "libavutil/opt.h" > +#include "vulkan.h" > +#include "internal.h" > + > +#define CGS 32 > +#define GBLUR_MAX_KERNEL_SIZE 127 > + > +typedef struct GBlurVulkanContext { > +VulkanFilterContext vkctx; > +FFVkExecContext *exec; > +VulkanPipeline *pl_hor; > +VulkanPipeline *pl_ver; > +FFVkBuffer params_buf_hor; > +FFVkBuffer params_buf_ver; > + > +VkDescriptorImageInfo input_images[3]; > +VkDescriptorImageInfo tmp_images[3]; > +VkDescriptorImageInfo output_images[3]; > +VkDescriptorBufferInfo params_desc_hor; > +VkDescriptorBufferInfo params_desc_ver; > + > +int initialized; > +int planes; > +int kernel_size; > +int size; > +float sigma; > +float sigmaV; > +float *kernel; > +} GBlurVulkanContext; > + > +static const char gblur_horizontal[] = { > +C(0, void gblur(const ivec2 pos, const
[FFmpeg-devel] [PATCH v2] libavfilter: add a gblur_vulkan filter
This commit adds a powerful and customizable gblur Vulkan filter, which provides a maximum 127x127 kernel size of Gaussian Filter. The size could be adjusted by requirements on quality or performance. The following command is on how to apply gblur_vulkan filter: ffmpeg -init_hw_device vulkan=vul:0 -filter_hw_device vul -i input.264 -vf hwupload=extra_hw_frames=16,gblur_vulkan,hwdownload,format=yuv420p output.264 Signed-off-by: Wu Jianhua --- configure | 1 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_gblur_vulkan.c | 509 ++ 4 files changed, 512 insertions(+) create mode 100644 libavfilter/vf_gblur_vulkan.c diff --git a/configure b/configure index af410a9d11..4b9a0d8e07 100755 --- a/configure +++ b/configure @@ -3601,6 +3601,7 @@ freezedetect_filter_select="scene_sad" frei0r_filter_deps="frei0r libdl" frei0r_src_filter_deps="frei0r libdl" fspp_filter_deps="gpl" +gblur_vulkan_filter_deps="vulkan_lib libglslang" histeq_filter_deps="gpl" hqdn3d_filter_deps="gpl" interlace_filter_deps="gpl" diff --git a/libavfilter/Makefile b/libavfilter/Makefile index af957a5ac0..5f74e33599 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -286,6 +286,7 @@ OBJS-$(CONFIG_FREEZEFRAMES_FILTER) += vf_freezeframes.o OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o qp_table.o OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o +OBJS-$(CONFIG_GBLUR_VULKAN_FILTER) += vf_gblur_vulkan.o vulkan.o OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o OBJS-$(CONFIG_GRAPHMONITOR_FILTER) += f_graphmonitor.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 0c6b2347c8..b5576de3af 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -271,6 +271,7 @@ extern const AVFilter ff_vf_freezeframes; extern const AVFilter ff_vf_frei0r; extern const AVFilter ff_vf_fspp; extern const AVFilter ff_vf_gblur; +extern const AVFilter ff_vf_gblur_vulkan; extern const AVFilter ff_vf_geq; extern const AVFilter ff_vf_gradfun; extern const AVFilter ff_vf_graphmonitor; diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c new file mode 100644 index 00..c1693f5d66 --- /dev/null +++ b/libavfilter/vf_gblur_vulkan.c @@ -0,0 +1,509 @@ +/* + * copyright (c) 2021 Wu Jianhua + * 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 "libavutil/random_seed.h" +#include "libavutil/opt.h" +#include "vulkan.h" +#include "internal.h" + +#define CGS 32 +#define GBLUR_MAX_KERNEL_SIZE 127 + +typedef struct GBlurVulkanContext { +VulkanFilterContext vkctx; +FFVkExecContext *exec; +VulkanPipeline *pl_hor; +VulkanPipeline *pl_ver; +FFVkBuffer params_buf_hor; +FFVkBuffer params_buf_ver; + +VkDescriptorImageInfo input_images[3]; +VkDescriptorImageInfo tmp_images[3]; +VkDescriptorImageInfo output_images[3]; +VkDescriptorBufferInfo params_desc_hor; +VkDescriptorBufferInfo params_desc_ver; + +int initialized; +int planes; +int kernel_size; +int size; +float sigma; +float sigmaV; +float *kernel; +} GBlurVulkanContext; + +static const char gblur_horizontal[] = { +C(0, void gblur(const ivec2 pos, const int index) ) +C(0, { ) +C(1, vec4 sum = texture(input_image[index], pos) * kernel[0]; ) +C(0, ) +C(1, for(int i = 1; i < kernel.length(); i++) { ) +C(2, sum += texture(input_image[index], pos + vec2(i, 0.0)) * kernel[i]; ) +C(2, sum += texture(input_image[index], pos - vec2(i, 0.0)) * kernel[i]; ) +C(1, } ) +C(0, ) +C(1, imageStore(output_image[index], pos, sum);
Re: [FFmpeg-devel] [PATCH] libavfilter: add a gblur_vulkan filter
Paul B Mahol wrote: > On Wed, Sep 8, 2021 at 8:13 AM Wu Jianhua > mailto:jianhua...@intel.com>> wrote: >> -- avgblur_vulkan, overlay_vulkan, scale_vulkan and chromaber_vulkan filters >> +- avgblur_vulkan, overlay_vulkan, scale_vulkan, chromaber_vulkan and >> gblur_vulkan filters > Can't do that. Got it. I’ll fix it soon. ___ 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] lavfi: add nlmeans CUDA filter
From f8b8a250a2c4b092747d632adc7dafccfc474140 Mon Sep 17 00:00:00 2001 From: Dylan Fernando Date: Wed, 8 Sep 2021 18:19:40 + Subject: [PATCH] lavfi: add nlmeans_cuda filter Signed-off-by: Dylan Fernando --- configure | 2 + doc/filters.texi | 4 + libavfilter/Makefile | 2 + libavfilter/allfilters.c | 1 + libavfilter/version.h | 4 +- libavfilter/vf_nlmeans_cuda.c | 883 + libavfilter/vf_nlmeans_cuda.cu | 378 ++ 7 files changed, 1272 insertions(+), 2 deletions(-) create mode 100644 libavfilter/vf_nlmeans_cuda.c create mode 100644 libavfilter/vf_nlmeans_cuda.cu diff --git a/configure b/configure index af410a9d11..7fa67e415e 100755 --- a/configure +++ b/configure @@ -3094,6 +3094,8 @@ thumbnail_cuda_filter_deps_any="cuda_nvcc cuda_llvm" transpose_npp_filter_deps="ffnvcodec libnpp" overlay_cuda_filter_deps="ffnvcodec" overlay_cuda_filter_deps_any="cuda_nvcc cuda_llvm" +nlmeans_cuda_filter_deps="ffnvcodec" +nlmeans_cuda_filter_deps_any="cuda_nvcc cuda_llvm" amf_deps_any="libdl LoadLibrary" nvenc_deps="ffnvcodec" diff --git a/doc/filters.texi b/doc/filters.texi index 9ad6031d23..b5eb9ecd33 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -15380,6 +15380,10 @@ Same as @option{r} but for chroma planes. The default value is @var{0} and means automatic. @end table +@section nlmeans_cuda + +Non-local Means denoise filter through CUDA, this filter accepts same options as @ref{nlmeans}. + @section nnedi Deinterlace video using neural network edge directed interpolation. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index af957a5ac0..7a61d7591e 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -347,6 +347,8 @@ OBJS-$(CONFIG_MPDECIMATE_FILTER) += vf_mpdecimate.o OBJS-$(CONFIG_NEGATE_FILTER) += vf_lut.o OBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o OBJS-$(CONFIG_NLMEANS_OPENCL_FILTER) += vf_nlmeans_opencl.o opencl.o opencl/nlmeans.o +OBJS-$(CONFIG_NLMEANS_CUDA_FILTER) += vf_nlmeans_cuda.o vf_nlmeans_cuda.ptx.o \ +cuda/load_helper.o OBJS-$(CONFIG_NNEDI_FILTER) += vf_nnedi.o OBJS-$(CONFIG_NOFORMAT_FILTER) += vf_format.o OBJS-$(CONFIG_NOISE_FILTER) += vf_noise.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 0c6b2347c8..d65c13011c 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -333,6 +333,7 @@ extern const AVFilter ff_vf_msad; extern const AVFilter ff_vf_negate; extern const AVFilter ff_vf_nlmeans; extern const AVFilter ff_vf_nlmeans_opencl; +extern const AVFilter ff_vf_nlmeans_cuda; extern const AVFilter ff_vf_nnedi; extern const AVFilter ff_vf_noformat; extern const AVFilter ff_vf_noise; diff --git a/libavfilter/version.h b/libavfilter/version.h index 2110048b77..306bb62ff4 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -30,8 +30,8 @@ #include "libavutil/version.h" #define LIBAVFILTER_VERSION_MAJOR 8 -#define LIBAVFILTER_VERSION_MINOR 7 -#define LIBAVFILTER_VERSION_MICRO 101 +#define LIBAVFILTER_VERSION_MINOR 8 +#define LIBAVFILTER_VERSION_MICRO 100 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_nlmeans_cuda.c b/libavfilter/vf_nlmeans_cuda.c new file mode 100644 index 00..3ecc7c8945 --- /dev/null +++ b/libavfilter/vf_nlmeans_cuda.c @@ -0,0 +1,883 @@ +/* + * 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 "libavutil/hwcontext.h" +#include "libavutil/hwcontext_cuda_internal.h" +#include "libavutil/cuda_check.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" + +#include "avfilter.h" +#include "internal.h" + +#include "cuda/load_helper.h" + +static const enum AVPixelFormat supported_formats[] = { +AV_PIX_FMT_NV12, +AV_PIX_FMT_YUV420P, +AV_PIX_FMT_YUV444P +}; + + +#define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x) + +#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) ) +#define BLOCKX 32 +#define BLOCKY 16 + + + +typedef struct NLMeansCudaContext { +const AVClass *class; + +
Re: [FFmpeg-devel] [PATCH v1 1/1] libavformat/amr.c: remove mode range check
On Wed, Sep 8, 2021 at 4:23 AM Sun Zhenliang wrote: > 在 2021年9月8日 +0800 00:14,Paul B Mahol ,写道: > > On Tue, Sep 7, 2021 at 4:48 PM Sun Zhenliang > > > wrote: > > > > > 在 2021年9月7日 +0800 19:13,Paul B Mahol ,写道: > > > > On Tue, Sep 7, 2021 at 11:36 AM Sun Zhenliang < > > > hisunzhenli...@outlook.com> > > > > wrote: > > > > > > > > > 在 2021年9月7日 +0800 14:16,Paul B Mahol ,写道: > > > > > > On Tue, Sep 7, 2021 at 7:34 AM Sun Zhenliang < > > > hisunzhenli...@outlook.com > > > > > > > > > > > > wrote: > > > > > > > > > > > > > 在 2021年9月7日 +0800 00:55,Paul B Mahol ,写道: > > > > > > > > On Sat, Sep 4, 2021 at 1:52 PM Sun Zhenliang < > > > > > hisunzhenli...@outlook.com > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Sep 4, 2021, at 16:01, Hendrik Leppkes < > > > h.lepp...@gmail.com> > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > On Sat, Sep 4, 2021 at 9:10 AM sunzhenliang < > > > > > > > hisunzhenli...@outlook.com> > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > Those comfort noise frames and empty frames should be > > > > > > > > > > > considered the correct frame. And > amr.c/amr_read_packet() > > > > > > > > > > > also takes them as correct frames too. > > > > > > > > > > > > > > > > > > > > > > Signed-off-by: sunzhenliang < > hisunzhenli...@outlook.com> > > > > > > > > > > > --- > > > > > > > > > > > libavformat/amr.c | 4 ++-- > > > > > > > > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > > > > > > > > > > > > > > > diff --git a/libavformat/amr.c b/libavformat/amr.c > > > > > > > > > > > index 836b276fd5..540d8033d8 100644 > > > > > > > > > > > --- a/libavformat/amr.c > > > > > > > > > > > +++ b/libavformat/amr.c > > > > > > > > > > > @@ -178,7 +178,7 @@ static int amrnb_probe(const > > > AVProbeData > > > > > *p) > > > > > > > > > > > > > > > > > > > > > > while (i < p->buf_size) { > > > > > > > > > > > mode = b[i] >> 3 & 0x0F; > > > > > > > > > > > - if (mode < 9 && (b[i] & 0x4) == 0x4) { > > > > > > > > > > > + if ((b[i] & 0x4) == 0x4) { > > > > > > > > > > > int last = b[i]; > > > > > > > > > > > int size = amrnb_packed_size[mode]; > > > > > > > > > > > while (size--) { > > > > > > > > > > > @@ -234,7 +234,7 @@ static int amrwb_probe(const > > > AVProbeData > > > > > *p) > > > > > > > > > > > > > > > > > > > > > > while (i < p->buf_size) { > > > > > > > > > > > mode = b[i] >> 3 & 0x0F; > > > > > > > > > > > - if (mode < 10 && (b[i] & 0x4) == 0x4) { > > > > > > > > > > > + if ((b[i] & 0x4) == 0x4) { > > > > > > > > > > > int last = b[i]; > > > > > > > > > > > int size = amrwb_packed_size[mode]; > > > > > > > > > > > while (size--) { > > > > > > > > > > > > > > > > > > > > This is just probing, and expecting to find a significant > > > amount > > > > > of > > > > > > > > > > non-empty/non-noise frames seems like something you would > > > want in > > > > > > > > > > probing. > > > > > > > > > > Does this actually fix detection of any samples? > > > > > > > > > > > > > > > > > > > > It seems like this has the potential of quite > substantially > > > > > reducing > > > > > > > > > > the number of checked bits and thus invalid detections. > > > > > > > > > > > > > > > > > > > > - Hendrik > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks for reviewing. > > > > > > > > > > > > > > > > > > Probing is expecting to find “correct” frames, which > includes > > > those > > > > > > > kinds > > > > > > > > > of comfort noise and NO_DATA frames mentioned in 3GPP > > > > > Specifications. > > > > > > > > > > > > > > > > > > Besides, those frames are considered as normal frames while > > > reading > > > > > > > > > packets. It seems better to take the same standard of > frames in > > > > > both > > > > > > > > > reading and probing. > > > > > > > > > > > > > > > > > > > > > > > > > > Yes, but in past IIRC it caused misdetection when probing. > > > > > > > But it may cause misdetection when probing audios with many > > > > > > > comfort noise and NO_DATA frames. Maybe we should stick to > > > > > > > 3GPP Specifications. > > > > > > > > > > > > > > > > > > > And at same time not broke probing for more more important > formats. > > > > > > Have you checked that your patch does not cause regressions? > > > > > > > > > > > I have done fate-test, but can not submit the results with > fate_recv. > > > > > I have sent the public ssh key to fate-ad...@ffmpeg.org, maybe it > > > > > needs some time? > > > > > > > > > > > > > I mean regressions not covered by FATE. > > > > > > > > Also you misunderstood fate-test, this patch have nothing to do with > > > > sending your fate testing reports to FFmpeg. > > > > > > > Sorry, could you explain more in details? I am confused. > > > > > > I have checked this patch, which works fine with those amr files. > > > > > > > What about non-amr files mentioned in tickets in git log history of this > > demuxer. > > > Than
Re: [FFmpeg-devel] [PATCH v1 1/1] libavformat/amr.c: remove mode range check
在 2021年9月8日 +0800 16:37,Paul B Mahol ,写道: > On Wed, Sep 8, 2021 at 4:23 AM Sun Zhenliang > wrote: > > > 在 2021年9月8日 +0800 00:14,Paul B Mahol ,写道: > > > On Tue, Sep 7, 2021 at 4:48 PM Sun Zhenliang > > > > > wrote: > > > > > > > 在 2021年9月7日 +0800 19:13,Paul B Mahol ,写道: > > > > > On Tue, Sep 7, 2021 at 11:36 AM Sun Zhenliang < > > > > hisunzhenli...@outlook.com> > > > > > wrote: > > > > > > > > > > > 在 2021年9月7日 +0800 14:16,Paul B Mahol ,写道: > > > > > > > On Tue, Sep 7, 2021 at 7:34 AM Sun Zhenliang < > > > > hisunzhenli...@outlook.com > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > 在 2021年9月7日 +0800 00:55,Paul B Mahol ,写道: > > > > > > > > > On Sat, Sep 4, 2021 at 1:52 PM Sun Zhenliang < > > > > > > hisunzhenli...@outlook.com > > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Sep 4, 2021, at 16:01, Hendrik Leppkes < > > > > h.lepp...@gmail.com> > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > On Sat, Sep 4, 2021 at 9:10 AM sunzhenliang < > > > > > > > > hisunzhenli...@outlook.com> > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > Those comfort noise frames and empty frames should be > > > > > > > > > > > > considered the correct frame. And > > amr.c/amr_read_packet() > > > > > > > > > > > > also takes them as correct frames too. > > > > > > > > > > > > > > > > > > > > > > > > Signed-off-by: sunzhenliang < > > hisunzhenli...@outlook.com> > > > > > > > > > > > > --- > > > > > > > > > > > > libavformat/amr.c | 4 ++-- > > > > > > > > > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > > > > > > > > > > > > > > > > > diff --git a/libavformat/amr.c b/libavformat/amr.c > > > > > > > > > > > > index 836b276fd5..540d8033d8 100644 > > > > > > > > > > > > --- a/libavformat/amr.c > > > > > > > > > > > > +++ b/libavformat/amr.c > > > > > > > > > > > > @@ -178,7 +178,7 @@ static int amrnb_probe(const > > > > AVProbeData > > > > > > *p) > > > > > > > > > > > > > > > > > > > > > > > > while (i < p->buf_size) { > > > > > > > > > > > > mode = b[i] >> 3 & 0x0F; > > > > > > > > > > > > - if (mode < 9 && (b[i] & 0x4) == 0x4) { > > > > > > > > > > > > + if ((b[i] & 0x4) == 0x4) { > > > > > > > > > > > > int last = b[i]; > > > > > > > > > > > > int size = amrnb_packed_size[mode]; > > > > > > > > > > > > while (size--) { > > > > > > > > > > > > @@ -234,7 +234,7 @@ static int amrwb_probe(const > > > > AVProbeData > > > > > > *p) > > > > > > > > > > > > > > > > > > > > > > > > while (i < p->buf_size) { > > > > > > > > > > > > mode = b[i] >> 3 & 0x0F; > > > > > > > > > > > > - if (mode < 10 && (b[i] & 0x4) == 0x4) { > > > > > > > > > > > > + if ((b[i] & 0x4) == 0x4) { > > > > > > > > > > > > int last = b[i]; > > > > > > > > > > > > int size = amrwb_packed_size[mode]; > > > > > > > > > > > > while (size--) { > > > > > > > > > > > > > > > > > > > > > > This is just probing, and expecting to find a significant > > > > amount > > > > > > of > > > > > > > > > > > non-empty/non-noise frames seems like something you would > > > > want in > > > > > > > > > > > probing. > > > > > > > > > > > Does this actually fix detection of any samples? > > > > > > > > > > > > > > > > > > > > > > It seems like this has the potential of quite > > substantially > > > > > > reducing > > > > > > > > > > > the number of checked bits and thus invalid detections. > > > > > > > > > > > > > > > > > > > > > > - Hendrik > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks for reviewing. > > > > > > > > > > > > > > > > > > > > Probing is expecting to find “correct” frames, which > > includes > > > > those > > > > > > > > kinds > > > > > > > > > > of comfort noise and NO_DATA frames mentioned in 3GPP > > > > > > Specifications. > > > > > > > > > > > > > > > > > > > > Besides, those frames are considered as normal frames while > > > > reading > > > > > > > > > > packets. It seems better to take the same standard of > > frames in > > > > > > both > > > > > > > > > > reading and probing. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Yes, but in past IIRC it caused misdetection when probing. > > > > > > > > But it may cause misdetection when probing audios with many > > > > > > > > comfort noise and NO_DATA frames. Maybe we should stick to > > > > > > > > 3GPP Specifications. > > > > > > > > > > > > > > > > > > > > > > And at same time not broke probing for more more important > > formats. > > > > > > > Have you checked that your patch does not cause regressions? > > > > > > > > > > > > > I have done fate-test, but can not submit the results with > > fate_recv. > > > > > > I have sent the public ssh key to fate-ad...@ffmpeg.org, maybe it > > > > > > needs some time? > > > > > > > > > > > > > > > > I mean regressions not covered by FATE. > > > > > > > > > > Also you misunderstood fate-test, this patch have nothing to do with > > > > > sending you
Re: [FFmpeg-devel] [PATCH v1 1/1] libavformat/amr.c: remove mode range check
On Wed, Sep 8, 2021 at 10:56 AM Sun Zhenliang wrote: > 在 2021年9月8日 +0800 16:37,Paul B Mahol ,写道: > > On Wed, Sep 8, 2021 at 4:23 AM Sun Zhenliang > > > wrote: > > > > > 在 2021年9月8日 +0800 00:14,Paul B Mahol ,写道: > > > > On Tue, Sep 7, 2021 at 4:48 PM Sun Zhenliang < > hisunzhenli...@outlook.com > > > > > > > > wrote: > > > > > > > > > 在 2021年9月7日 +0800 19:13,Paul B Mahol ,写道: > > > > > > On Tue, Sep 7, 2021 at 11:36 AM Sun Zhenliang < > > > > > hisunzhenli...@outlook.com> > > > > > > wrote: > > > > > > > > > > > > > 在 2021年9月7日 +0800 14:16,Paul B Mahol ,写道: > > > > > > > > On Tue, Sep 7, 2021 at 7:34 AM Sun Zhenliang < > > > > > hisunzhenli...@outlook.com > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > 在 2021年9月7日 +0800 00:55,Paul B Mahol >,写道: > > > > > > > > > > On Sat, Sep 4, 2021 at 1:52 PM Sun Zhenliang < > > > > > > > hisunzhenli...@outlook.com > > > > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Sep 4, 2021, at 16:01, Hendrik Leppkes < > > > > > h.lepp...@gmail.com> > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > On Sat, Sep 4, 2021 at 9:10 AM sunzhenliang < > > > > > > > > > hisunzhenli...@outlook.com> > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > Those comfort noise frames and empty frames should > be > > > > > > > > > > > > > considered the correct frame. And > > > amr.c/amr_read_packet() > > > > > > > > > > > > > also takes them as correct frames too. > > > > > > > > > > > > > > > > > > > > > > > > > > Signed-off-by: sunzhenliang < > > > hisunzhenli...@outlook.com> > > > > > > > > > > > > > --- > > > > > > > > > > > > > libavformat/amr.c | 4 ++-- > > > > > > > > > > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > > > > > > > > > > > > > > > > > > > diff --git a/libavformat/amr.c b/libavformat/amr.c > > > > > > > > > > > > > index 836b276fd5..540d8033d8 100644 > > > > > > > > > > > > > --- a/libavformat/amr.c > > > > > > > > > > > > > +++ b/libavformat/amr.c > > > > > > > > > > > > > @@ -178,7 +178,7 @@ static int amrnb_probe(const > > > > > AVProbeData > > > > > > > *p) > > > > > > > > > > > > > > > > > > > > > > > > > > while (i < p->buf_size) { > > > > > > > > > > > > > mode = b[i] >> 3 & 0x0F; > > > > > > > > > > > > > - if (mode < 9 && (b[i] & 0x4) == 0x4) { > > > > > > > > > > > > > + if ((b[i] & 0x4) == 0x4) { > > > > > > > > > > > > > int last = b[i]; > > > > > > > > > > > > > int size = amrnb_packed_size[mode]; > > > > > > > > > > > > > while (size--) { > > > > > > > > > > > > > @@ -234,7 +234,7 @@ static int amrwb_probe(const > > > > > AVProbeData > > > > > > > *p) > > > > > > > > > > > > > > > > > > > > > > > > > > while (i < p->buf_size) { > > > > > > > > > > > > > mode = b[i] >> 3 & 0x0F; > > > > > > > > > > > > > - if (mode < 10 && (b[i] & 0x4) == 0x4) { > > > > > > > > > > > > > + if ((b[i] & 0x4) == 0x4) { > > > > > > > > > > > > > int last = b[i]; > > > > > > > > > > > > > int size = amrwb_packed_size[mode]; > > > > > > > > > > > > > while (size--) { > > > > > > > > > > > > > > > > > > > > > > > > This is just probing, and expecting to find a > significant > > > > > amount > > > > > > > of > > > > > > > > > > > > non-empty/non-noise frames seems like something you > would > > > > > want in > > > > > > > > > > > > probing. > > > > > > > > > > > > Does this actually fix detection of any samples? > > > > > > > > > > > > > > > > > > > > > > > > It seems like this has the potential of quite > > > substantially > > > > > > > reducing > > > > > > > > > > > > the number of checked bits and thus invalid > detections. > > > > > > > > > > > > > > > > > > > > > > > > - Hendrik > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks for reviewing. > > > > > > > > > > > > > > > > > > > > > > Probing is expecting to find “correct” frames, which > > > includes > > > > > those > > > > > > > > > kinds > > > > > > > > > > > of comfort noise and NO_DATA frames mentioned in 3GPP > > > > > > > Specifications. > > > > > > > > > > > > > > > > > > > > > > Besides, those frames are considered as normal frames > while > > > > > reading > > > > > > > > > > > packets. It seems better to take the same standard of > > > frames in > > > > > > > both > > > > > > > > > > > reading and probing. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Yes, but in past IIRC it caused misdetection when > probing. > > > > > > > > > But it may cause misdetection when probing audios with many > > > > > > > > > comfort noise and NO_DATA frames. Maybe we should stick to > > > > > > > > > 3GPP Specifications. > > > > > > > > > > > > > > > > > > > > > > > > > And at same time not broke probing for more more important > > > formats. > > > > > > > > Have you checked that your patch does not cause regressions? > > > > > > > > > > > > > > > I have done fate-test, b
Re: [FFmpeg-devel] [PATCH v1 1/1] libavformat/amr.c: remove mode range check
On Sat, Sep 4, 2021 at 1:52 PM Sun Zhenliang wrote: > > Thanks for reviewing. > > Probing is expecting to find “correct” frames, which includes those kinds of > comfort noise and NO_DATA frames mentioned in 3GPP Specifications. > > Besides, those frames are considered as normal frames while reading packets. > It seems better to take the same standard of frames in both reading and > probing. > Can you answer the second question? Does this actually fix any files? If so, can you provide one? As mentioned above, correct or not, this patch makes the probing accept very loose bit patterns and is likely rather prone to misdetections, so no matter if its more "correct", there are other considerations here. So instead, lets start with seeing what it actually fixes. - Hendrik ___ 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] libavfilter: add a gblur_vulkan filter
Wu Jianhua: > This commit adds a powerful and customizable gblur Vulkan filter, > which provides a maximum 127x127 kernel size of Gaussian Filter. > The size could be adjusted by requirements on quality or performance. > > The following command is on how to apply gblur_vulkan filter: > > ffmpeg -init_hw_device vulkan=vul:0 -filter_hw_device vul -i input.264 > -vf hwupload=extra_hw_frames=16,gblur_vulkan,hwdownload,format=yuv420p > output.264 > > Signed-off-by: Wu Jianhua > --- > configure | 1 + > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/vf_gblur_vulkan.c | 509 ++ > 4 files changed, 512 insertions(+) > create mode 100644 libavfilter/vf_gblur_vulkan.c > > diff --git a/configure b/configure > index af410a9d11..4b9a0d8e07 100755 > --- a/configure > +++ b/configure > @@ -3601,6 +3601,7 @@ freezedetect_filter_select="scene_sad" > frei0r_filter_deps="frei0r libdl" > frei0r_src_filter_deps="frei0r libdl" > fspp_filter_deps="gpl" > +gblur_vulkan_filter_deps="vulkan_lib libglslang" > histeq_filter_deps="gpl" > hqdn3d_filter_deps="gpl" > interlace_filter_deps="gpl" > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index af957a5ac0..5f74e33599 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -286,6 +286,7 @@ OBJS-$(CONFIG_FREEZEFRAMES_FILTER) += > vf_freezeframes.o > OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o > OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o qp_table.o > OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o > +OBJS-$(CONFIG_GBLUR_VULKAN_FILTER) += vf_gblur_vulkan.o vulkan.o > OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o > OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o > OBJS-$(CONFIG_GRAPHMONITOR_FILTER) += f_graphmonitor.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index 0c6b2347c8..b5576de3af 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -271,6 +271,7 @@ extern const AVFilter ff_vf_freezeframes; > extern const AVFilter ff_vf_frei0r; > extern const AVFilter ff_vf_fspp; > extern const AVFilter ff_vf_gblur; > +extern const AVFilter ff_vf_gblur_vulkan; > extern const AVFilter ff_vf_geq; > extern const AVFilter ff_vf_gradfun; > extern const AVFilter ff_vf_graphmonitor; > diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c > new file mode 100644 > index 00..c1693f5d66 > --- /dev/null > +++ b/libavfilter/vf_gblur_vulkan.c > @@ -0,0 +1,509 @@ > +/* > + * copyright (c) 2021 Wu Jianhua > + * 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 "libavutil/random_seed.h" > +#include "libavutil/opt.h" > +#include "vulkan.h" > +#include "internal.h" > + > +#define CGS 32 > +#define GBLUR_MAX_KERNEL_SIZE 127 > + > +typedef struct GBlurVulkanContext { > +VulkanFilterContext vkctx; > +FFVkExecContext *exec; > +VulkanPipeline *pl_hor; > +VulkanPipeline *pl_ver; > +FFVkBuffer params_buf_hor; > +FFVkBuffer params_buf_ver; > + > +VkDescriptorImageInfo input_images[3]; > +VkDescriptorImageInfo tmp_images[3]; > +VkDescriptorImageInfo output_images[3]; > +VkDescriptorBufferInfo params_desc_hor; > +VkDescriptorBufferInfo params_desc_ver; > + > +int initialized; > +int planes; > +int kernel_size; > +int size; > +float sigma; > +float sigmaV; > +float *kernel; > +} GBlurVulkanContext; > + > +static const char gblur_horizontal[] = { > +C(0, void gblur(const ivec2 pos, const int index) > ) > +C(0, { > ) > +C(1, vec4 sum = texture(input_image[index], pos) * kernel[0]; > ) > +C(0, > ) > +C(1, for(int i = 1; i < kernel.length(); i++) { > ) > +C(2, sum += texture(input_image[index], pos + vec2(i, 0.0)) * > kernel[i]; ) > +C(2, sum += texture(input_image[index], pos - vec2(i, 0.0))
Re: [FFmpeg-devel] [PATCH] avfilter/frei0r: use win32dlfcn wrapper
Will push soon smime.p7s Description: S/MIME Cryptographic 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".
[FFmpeg-devel] [PATCH] avcodec/nvenc: remove useless context pop
Signed-off-by: leozhang --- libavcodec/nvenc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index ae25afd7f8..fdf06d6102 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -607,9 +607,6 @@ static av_cold int nvenc_check_device(AVCodecContext *avctx, int idx) ctx->cu_context = ctx->cu_context_internal; ctx->cu_stream = NULL; -if ((ret = nvenc_pop_context(avctx)) < 0) -goto fail2; - if ((ret = nvenc_open_session(avctx)) < 0) goto fail2; -- 2.28.0.windows.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] avcodec/nvenc: remove useless context pop
Signed-off-by: leozhang --- libavcodec/nvenc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index ae25afd7f8..fdf06d6102 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -607,9 +607,6 @@ static av_cold int nvenc_check_device(AVCodecContext *avctx, int idx) ctx->cu_context = ctx->cu_context_internal; ctx->cu_stream = NULL; -if ((ret = nvenc_pop_context(avctx)) < 0) -goto fail2; - if ((ret = nvenc_open_session(avctx)) < 0) goto fail2; -- 2.28.0.windows.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] avformat/libsrt: data transmission bitrate control
The patch adds 3 parameters ("bitrate", "burst_bits", "fifo_size") and output bitrate control to the libsrt muxer. The code is mostly taken from udp.c and the reasoning is the same: data transmission bursts cause decoding errors on some decoders. Windows-specific APIs (performance counters and waitable timers) are used instead of standard FFmpeg routines to measure time intervals and to delay thread execution in Windows build: standard ones don't provide sub-millisecond precision and accuracy which are required for smooth outbound traffic. Muxer URL would look like this: "srt://10.10.10.10:12345?mode=caller&bitrate=1500&burst_bits=15" Signed-off-by: Dmitry Bartsevich --- libavformat/libsrt.c | 275 +++ 1 file changed, 275 insertions(+) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index e5701625b8..0a00277d80 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -23,6 +23,9 @@ #include +#include "libavutil/avassert.h" +#include "libavutil/fifo.h" +#include "libavutil/intreadwrite.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" #include "libavutil/time.h" @@ -33,6 +36,15 @@ #include "os_support.h" #include "url.h" +#if HAVE_W32THREADS +#undef HAVE_PTHREAD_CANCEL +#define HAVE_PTHREAD_CANCEL 1 +#endif + +#if HAVE_PTHREAD_CANCEL +#include "libavutil/thread.h" +#endif + /* This is for MPEG-TS and it's a default SRTO_PAYLOADSIZE for SRTT_LIVE (8 TS packets) */ #ifndef SRT_LIVE_DEFAULT_PAYLOAD_SIZE #define SRT_LIVE_DEFAULT_PAYLOAD_SIZE 1316 @@ -90,6 +102,21 @@ typedef struct SRTContext { SRT_TRANSTYPE transtype; int linger; int tsbpd; + +/* Circular Buffer variables for use in SRT sending code */ +int circular_buffer_size; +AVFifoBuffer *fifo; +int circular_buffer_error; +int64_t bitrate; /* number of bits to send per second */ +int64_t burst_bits; +int close_req; +#if HAVE_PTHREAD_CANCEL +pthread_t circular_buffer_thread; +pthread_mutex_t mutex; +pthread_cond_t cond; +int thread_started; +#endif +uint8_t tmp[SRT_LIVE_MAX_PAYLOAD_SIZE+4]; } SRTContext; #define D AV_OPT_FLAG_DECODING_PARAM @@ -142,6 +169,9 @@ static const AVOption libsrt_options[] = { { "file", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRTT_FILE }, INT_MIN, INT_MAX, .flags = D|E, "transtype" }, { "linger", "Number of seconds that the socket waits for unsent data when closing", OFFSET(linger), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, .flags = D|E }, { "tsbpd", "Timestamp-based packet delivery", OFFSET(tsbpd),AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, .flags = D|E }, +{ "bitrate","Bits to send per second", OFFSET(bitrate), AV_OPT_TYPE_INT64,{ .i64 = 0 }, 0, INT64_MAX, .flags = E }, +{ "burst_bits", "Max length of bursts in bits (when using bitrate)", OFFSET(burst_bits), AV_OPT_TYPE_INT64,{ .i64 = 0 }, 0, INT64_MAX, .flags = E }, +{ "fifo_size", "set the SRT sending circular buffer size, expressed as a number of packets with size of 188 bytes", OFFSET(circular_buffer_size), AV_OPT_TYPE_INT, {.i64 = 7*4096}, 0, INT_MAX, .flags = E }, { NULL } }; @@ -165,6 +195,138 @@ static int libsrt_socket_nonblock(int socket, int enable) return srt_setsockopt(socket, 0, SRTO_RCVSYN, &blocking, sizeof(blocking)); } +#if HAVE_PTHREAD_CANCEL + +/* More precise time measurement in Windows, call default routine otherwise */ +static int64_t av_gettime_relative_precise(void) +{ +#ifdef _WIN32 +static LARGE_INTEGER freq; +LARGE_INTEGER t; + +if (freq.QuadPart == 0) { +QueryPerformanceFrequency(&freq); +} + +QueryPerformanceCounter(&t); +return t.QuadPart * 100 / freq.QuadPart; +#else +return av_gettime_relative(); +#endif +} + +static void *circular_buffer_task_tx(void *_URLContext) +{ +URLContext *h = _URLContext; +SRTContext *s = h->priv_data; +int old_cancelstate; +int64_t target_timestamp = av_gettime_relative_precise(); +int64_t start_timestamp = av_gettime_relative_precise(); +int64_t sent_bits = 0; +int64_t burst_interval = s->bitrate ? (s->burst_bits * 100 / s->bitrate) : 0; +int64_t max_delay = s->bitrate ? ((int64_t)h->max_packet_size * 8 * 100 / s->bitrate + 1) : 0; +#ifdef _WIN32 +/* Use waitable timers to delay thread execution in Windows, as default + Sleep() API call has 1ms resolution and is not accurate enough */ +LARGE_INTEGER timeout; +HANDLE waitable_timer = CreateWaitableTimer(NULL, FALSE, NULL); +#endif + +pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old_cancelstate); +pthread_mutex_lock(&s->mutex); + +if (libsrt_socket_nonblock(s->fd, 0) < 0) { +av_log(h, AV_LOG_ERROR, "Failed to set blocking mode"); +
Re: [FFmpeg-devel] [PATCH 01/11] avcodec/bsf: ff_list_bsf static
Andreas Rheinhardt: > It is a special BSF that is only available via the av_bsf_list-API; > it is not part of the list generated from the declarations in > bitstream_filters.c and therefore needn't have external linkage. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/bsf.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/bsf.c b/libavcodec/bsf.c > index 57034ce646..d9c8395260 100644 > --- a/libavcodec/bsf.c > +++ b/libavcodec/bsf.c > @@ -394,7 +394,7 @@ static const AVClass bsf_list_class = { > .version= LIBAVUTIL_VERSION_INT, > }; > > -const AVBitStreamFilter ff_list_bsf = { > +static const AVBitStreamFilter list_bsf = { > .name = "bsf_list", > .priv_data_size = sizeof(BSFListContext), > .priv_class = &bsf_list_class, > @@ -490,7 +490,7 @@ int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext > **bsf) > goto end; > } > > -ret = av_bsf_alloc(&ff_list_bsf, bsf); > +ret = av_bsf_alloc(&list_bsf, bsf); > if (ret < 0) > return ret; > > @@ -544,5 +544,5 @@ end: > > int av_bsf_get_null_filter(AVBSFContext **bsf) > { > -return av_bsf_alloc(&ff_list_bsf, bsf); > +return av_bsf_alloc(&list_bsf, bsf); > } > Will apply this patchset later tonight. - 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 v1 1/1] libavformat/amr.c: remove mode range check
在 2021年9月8日 +0800 17:55,Hendrik Leppkes ,写道: > On Sat, Sep 4, 2021 at 1:52 PM Sun Zhenliang > wrote: > > > > Thanks for reviewing. > > > > Probing is expecting to find “correct” frames, which includes those kinds > > of comfort noise and NO_DATA frames mentioned in 3GPP Specifications. > > > > Besides, those frames are considered as normal frames while reading > > packets. It seems better to take the same standard of frames in both > > reading and probing. > > > > Can you answer the second question? Does this actually fix any files? > If so, can you provide one? > > As mentioned above, correct or not, this patch makes the probing > accept very loose bit patterns and is likely rather prone to > misdetections, so no matter if its more "correct", there are other > considerations here. So instead, lets start with seeing what it > actually fixes. Ok, there is the file that this patch fixed. It’s made by some kind of phone with header. I removed it’s header to test the probing at raw amr files. https://github.com/HiSunzhenliang/patch/blob/main/ffmpeg/silence-head.amrnb And this is ffmpeg log. https://github.com/HiSunzhenliang/patch/blob/main/ffmpeg/ffmpeg_i.log > > - Hendrik > ___ > 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 v1 1/1] libavformat/amr.c: remove mode range check
在 2021年9月8日 +0800 17:10,Paul B Mahol ,写道: > On Wed, Sep 8, 2021 at 10:56 AM Sun Zhenliang > wrote: > > > 在 2021年9月8日 +0800 16:37,Paul B Mahol ,写道: > > > On Wed, Sep 8, 2021 at 4:23 AM Sun Zhenliang > > > > > wrote: > > > > > > > 在 2021年9月8日 +0800 00:14,Paul B Mahol ,写道: > > > > > On Tue, Sep 7, 2021 at 4:48 PM Sun Zhenliang < > > hisunzhenli...@outlook.com > > > > > > > > > > wrote: > > > > > > > > > > > 在 2021年9月7日 +0800 19:13,Paul B Mahol ,写道: > > > > > > > On Tue, Sep 7, 2021 at 11:36 AM Sun Zhenliang < > > > > > > hisunzhenli...@outlook.com> > > > > > > > wrote: > > > > > > > > > > > > > > > 在 2021年9月7日 +0800 14:16,Paul B Mahol ,写道: > > > > > > > > > On Tue, Sep 7, 2021 at 7:34 AM Sun Zhenliang < > > > > > > hisunzhenli...@outlook.com > > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > 在 2021年9月7日 +0800 00:55,Paul B Mahol > > ,写道: > > > > > > > > > > > On Sat, Sep 4, 2021 at 1:52 PM Sun Zhenliang < > > > > > > > > hisunzhenli...@outlook.com > > > > > > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Sep 4, 2021, at 16:01, Hendrik Leppkes < > > > > > > h.lepp...@gmail.com> > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > On Sat, Sep 4, 2021 at 9:10 AM sunzhenliang < > > > > > > > > > > hisunzhenli...@outlook.com> > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Those comfort noise frames and empty frames should > > be > > > > > > > > > > > > > > considered the correct frame. And > > > > amr.c/amr_read_packet() > > > > > > > > > > > > > > also takes them as correct frames too. > > > > > > > > > > > > > > > > > > > > > > > > > > > > Signed-off-by: sunzhenliang < > > > > hisunzhenli...@outlook.com> > > > > > > > > > > > > > > --- > > > > > > > > > > > > > > libavformat/amr.c | 4 ++-- > > > > > > > > > > > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > > > > > > > > > > > > > > > > > > > > > diff --git a/libavformat/amr.c b/libavformat/amr.c > > > > > > > > > > > > > > index 836b276fd5..540d8033d8 100644 > > > > > > > > > > > > > > --- a/libavformat/amr.c > > > > > > > > > > > > > > +++ b/libavformat/amr.c > > > > > > > > > > > > > > @@ -178,7 +178,7 @@ static int amrnb_probe(const > > > > > > AVProbeData > > > > > > > > *p) > > > > > > > > > > > > > > > > > > > > > > > > > > > > while (i < p->buf_size) { > > > > > > > > > > > > > > mode = b[i] >> 3 & 0x0F; > > > > > > > > > > > > > > - if (mode < 9 && (b[i] & 0x4) == 0x4) { > > > > > > > > > > > > > > + if ((b[i] & 0x4) == 0x4) { > > > > > > > > > > > > > > int last = b[i]; > > > > > > > > > > > > > > int size = amrnb_packed_size[mode]; > > > > > > > > > > > > > > while (size--) { > > > > > > > > > > > > > > @@ -234,7 +234,7 @@ static int amrwb_probe(const > > > > > > AVProbeData > > > > > > > > *p) > > > > > > > > > > > > > > > > > > > > > > > > > > > > while (i < p->buf_size) { > > > > > > > > > > > > > > mode = b[i] >> 3 & 0x0F; > > > > > > > > > > > > > > - if (mode < 10 && (b[i] & 0x4) == 0x4) { > > > > > > > > > > > > > > + if ((b[i] & 0x4) == 0x4) { > > > > > > > > > > > > > > int last = b[i]; > > > > > > > > > > > > > > int size = amrwb_packed_size[mode]; > > > > > > > > > > > > > > while (size--) { > > > > > > > > > > > > > > > > > > > > > > > > > > This is just probing, and expecting to find a > > significant > > > > > > amount > > > > > > > > of > > > > > > > > > > > > > non-empty/non-noise frames seems like something you > > would > > > > > > want in > > > > > > > > > > > > > probing. > > > > > > > > > > > > > Does this actually fix detection of any samples? > > > > > > > > > > > > > > > > > > > > > > > > > > It seems like this has the potential of quite > > > > substantially > > > > > > > > reducing > > > > > > > > > > > > > the number of checked bits and thus invalid > > detections. > > > > > > > > > > > > > > > > > > > > > > > > > > - Hendrik > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Thanks for reviewing. > > > > > > > > > > > > > > > > > > > > > > > > Probing is expecting to find “correct” frames, which > > > > includes > > > > > > those > > > > > > > > > > kinds > > > > > > > > > > > > of comfort noise and NO_DATA frames mentioned in 3GPP > > > > > > > > Specifications. > > > > > > > > > > > > > > > > > > > > > > > > Besides, those frames are considered as normal frames > > while > > > > > > reading > > > > > > > > > > > > packets. It seems better to take the same standard of > > > > frames in > > > > > > > > both > > > > > > > > > > > > reading and probing. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Yes, but in past IIRC it caused misdetection when > > probing. > > > > > > > > > > But it may cause misdetection when probing audios with many > > > > > > > > > > comfort noise and NO_DATA frames. Maybe we should stick to > > > >
Re: [FFmpeg-devel] [PATCH] avformat/libsrt: data transmission bitrate control
> On Sep 8, 2021, at 7:37 PM, Bartsevich, Dmitry wrote: > > The patch adds 3 parameters ("bitrate", "burst_bits", "fifo_size") and output > bitrate control to the libsrt muxer. The code is mostly taken from udp.c and > the reasoning is the same: data transmission bursts cause decoding errors on > some decoders. Windows-specific APIs (performance counters and waitable > timers) are used instead of standard FFmpeg routines to measure time > intervals and to delay thread execution in Windows build: standard ones don't > provide sub-millisecond precision and accuracy which are required for smooth > outbound traffic. > > Muxer URL would look like this: > "srt://10.10.10.10:12345?mode=caller&bitrate=1500&burst_bits=15" No, this is reinvent pacing control which libsrt has builtin implementation and doing better. Have a look at SRTO_MAXBW, SRTO_INPUTBW and SRTO_OHEADBW options. SRTO_MAXBW has a default value 1 Gbps which is too high for regular video bitrate and network condition. > > Signed-off-by: Dmitry Bartsevich > --- > libavformat/libsrt.c | 275 +++ > 1 file changed, 275 insertions(+) > > diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c > index e5701625b8..0a00277d80 100644 > --- a/libavformat/libsrt.c > +++ b/libavformat/libsrt.c > @@ -23,6 +23,9 @@ > #include > +#include "libavutil/avassert.h" > +#include "libavutil/fifo.h" > +#include "libavutil/intreadwrite.h" > #include "libavutil/opt.h" > #include "libavutil/parseutils.h" > #include "libavutil/time.h" > @@ -33,6 +36,15 @@ > #include "os_support.h" > #include "url.h" > +#if HAVE_W32THREADS > +#undef HAVE_PTHREAD_CANCEL > +#define HAVE_PTHREAD_CANCEL 1 > +#endif > + > +#if HAVE_PTHREAD_CANCEL > +#include "libavutil/thread.h" > +#endif > + > /* This is for MPEG-TS and it's a default SRTO_PAYLOADSIZE for SRTT_LIVE (8 > TS packets) */ > #ifndef SRT_LIVE_DEFAULT_PAYLOAD_SIZE > #define SRT_LIVE_DEFAULT_PAYLOAD_SIZE 1316 > @@ -90,6 +102,21 @@ typedef struct SRTContext { > SRT_TRANSTYPE transtype; > int linger; > int tsbpd; > + > +/* Circular Buffer variables for use in SRT sending code */ > +int circular_buffer_size; > +AVFifoBuffer *fifo; > +int circular_buffer_error; > +int64_t bitrate; /* number of bits to send per second */ > +int64_t burst_bits; > +int close_req; > +#if HAVE_PTHREAD_CANCEL > +pthread_t circular_buffer_thread; > +pthread_mutex_t mutex; > +pthread_cond_t cond; > +int thread_started; > +#endif > +uint8_t tmp[SRT_LIVE_MAX_PAYLOAD_SIZE+4]; > } SRTContext; > #define D AV_OPT_FLAG_DECODING_PARAM > @@ -142,6 +169,9 @@ static const AVOption libsrt_options[] = { > { "file", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = SRTT_FILE }, > INT_MIN, INT_MAX, .flags = D|E, "transtype" }, > { "linger", "Number of seconds that the socket waits for unsent > data when closing", OFFSET(linger), AV_OPT_TYPE_INT, { .i64 = > -1 }, -1, INT_MAX, .flags = D|E }, > { "tsbpd", "Timestamp-based packet delivery", > OFFSET(tsbpd),AV_OPT_TYPE_BOOL, { .i64 = -1 > }, -1, 1, .flags = D|E }, > +{ "bitrate","Bits to send per second", >OFFSET(bitrate), AV_OPT_TYPE_INT64,{ .i64 = 0 > }, 0, INT64_MAX, .flags = E }, > +{ "burst_bits", "Max length of bursts in bits (when using bitrate)", >OFFSET(burst_bits), AV_OPT_TYPE_INT64,{ .i64 = 0 > }, 0, INT64_MAX, .flags = E }, > +{ "fifo_size", "set the SRT sending circular buffer size, expressed > as a number of packets with size of 188 bytes", OFFSET(circular_buffer_size), > AV_OPT_TYPE_INT, {.i64 = 7*4096}, 0, INT_MAX, .flags = E }, > { NULL } > }; > @@ -165,6 +195,138 @@ static int libsrt_socket_nonblock(int socket, int > enable) > return srt_setsockopt(socket, 0, SRTO_RCVSYN, &blocking, > sizeof(blocking)); > } > +#if HAVE_PTHREAD_CANCEL > + > +/* More precise time measurement in Windows, call default routine otherwise > */ > +static int64_t av_gettime_relative_precise(void) > +{ > +#ifdef _WIN32 > +static LARGE_INTEGER freq; > +LARGE_INTEGER t; > + > +if (freq.QuadPart == 0) { > +QueryPerformanceFrequency(&freq); > +} > + > +QueryPerformanceCounter(&t); > +return t.QuadPart * 100 / freq.QuadPart; > +#else > +return av_gettime_relative(); > +#endif > +} > + > +static void *circular_buffer_task_tx(void *_URLContext) > +{ > +URLContext *h = _URLContext; > +SRTContext *s = h->priv_data; > +int old_cancelstate; > +int64_t target_timestamp = av_gettime_relative_precise(); > +int64_t start_timestamp = av_gettime_relative_precise(); > +int64_t sent_bits = 0; > +int64_t burst_interval = s->bitrate ? (s->burst_bits * 100 / > s->bitrate) : 0; > +int64_t max_delay = s->bitrate ?
[FFmpeg-devel] [PATCH] avfilter: add (a)latency filters
Signed-off-by: Paul B Mahol --- libavfilter/Makefile | 2 + libavfilter/allfilters.c | 2 + libavfilter/f_latency.c | 171 +++ 3 files changed, 175 insertions(+) create mode 100644 libavfilter/f_latency.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 8031f59af5..d12f7dc3a5 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -60,6 +60,7 @@ OBJS-$(CONFIG_AGATE_FILTER) += af_agate.o OBJS-$(CONFIG_AIIR_FILTER) += af_aiir.o OBJS-$(CONFIG_AINTEGRAL_FILTER) += af_aderivative.o OBJS-$(CONFIG_AINTERLEAVE_FILTER)+= f_interleave.o +OBJS-$(CONFIG_ALATENCY_FILTER) += f_latency.o OBJS-$(CONFIG_ALIMITER_FILTER) += af_alimiter.o OBJS-$(CONFIG_ALLPASS_FILTER)+= af_biquads.o OBJS-$(CONFIG_ALOOP_FILTER) += f_loop.o @@ -317,6 +318,7 @@ OBJS-$(CONFIG_INTERLEAVE_FILTER) += f_interleave.o OBJS-$(CONFIG_KERNDEINT_FILTER) += vf_kerndeint.o OBJS-$(CONFIG_KIRSCH_FILTER) += vf_convolution.o OBJS-$(CONFIG_LAGFUN_FILTER) += vf_lagfun.o +OBJS-$(CONFIG_LATENCY_FILTER)+= f_latency.o OBJS-$(CONFIG_LENSCORRECTION_FILTER) += vf_lenscorrection.o OBJS-$(CONFIG_LENSFUN_FILTER)+= vf_lensfun.o OBJS-$(CONFIG_LIBVMAF_FILTER)+= vf_libvmaf.o framesync.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index e1e43726b5..e809d3b7c4 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -53,6 +53,7 @@ extern const AVFilter ff_af_agate; extern const AVFilter ff_af_aiir; extern const AVFilter ff_af_aintegral; extern const AVFilter ff_af_ainterleave; +extern const AVFilter ff_af_alatency; extern const AVFilter ff_af_alimiter; extern const AVFilter ff_af_allpass; extern const AVFilter ff_af_aloop; @@ -302,6 +303,7 @@ extern const AVFilter ff_vf_interleave; extern const AVFilter ff_vf_kerndeint; extern const AVFilter ff_vf_kirsch; extern const AVFilter ff_vf_lagfun; +extern const AVFilter ff_vf_latency; extern const AVFilter ff_vf_lenscorrection; extern const AVFilter ff_vf_lensfun; extern const AVFilter ff_vf_libvmaf; diff --git a/libavfilter/f_latency.c b/libavfilter/f_latency.c new file mode 100644 index 00..324040922f --- /dev/null +++ b/libavfilter/f_latency.c @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2021 Paul B Mahol + * + * 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 "libavutil/opt.h" +#include "avfilter.h" +#include "filters.h" +#include "formats.h" +#include "internal.h" + +typedef struct LatencyContext { +const AVClass *class; + +int64_t min_latency; +int64_t max_latency; +int64_t sum; +} LatencyContext; + +#define OFFSET(x) offsetof(LatencyContext, x) +#define VF AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption latency_options[] = { +{ NULL } +}; + +static av_cold int init(AVFilterContext *ctx) +{ +LatencyContext *s = ctx->priv; + +s->min_latency = INT64_MAX; +s->max_latency = INT64_MIN; + +return 0; +} + +static int activate(AVFilterContext *ctx) +{ +LatencyContext *s = ctx->priv; +AVFilterLink *inlink = ctx->inputs[0]; +AVFilterLink *outlink = ctx->outputs[0]; + +FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + +if (ctx->inputs[0]->src && +ctx->inputs[0]->src->nb_inputs > 0) { +AVFilterLink *prevlink = ctx->inputs[0]->src->inputs[0]; +int64_t delta = 0; + +switch (prevlink->type) { +case AVMEDIA_TYPE_AUDIO: +delta = prevlink->sample_count_in - inlink->sample_count_out; +break; +case AVMEDIA_TYPE_VIDEO: +delta = prevlink->frame_count_in - inlink->frame_count_out; +break; +} + +if (delta > 0) { +s->min_latency = FFMIN(s->min_latency, delta); +s->max_latency = FFMAX(s->max_latency, delta); +} +} + +if (ff_inlink_queued_frames(inlink)) { +AVFrame *frame = NULL; +int ret; + +ret = ff_inlink_consume_frame(inlink, &frame); +if (ret < 0) +return ret; +if (ret > 0) +
[FFmpeg-devel] [PATCH 1/4] avcodec/mjpegdec: export display matrix frame side data when available
Signed-off-by: James Almer --- libavcodec/mjpegdec.c | 53 +++ 1 file changed, 53 insertions(+) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 2a5868fe1d..7bec5ce221 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -30,6 +30,7 @@ * MJPEG decoder. */ +#include "libavutil/display.h" #include "libavutil/imgutils.h" #include "libavutil/avassert.h" #include "libavutil/opt.h" @@ -2406,6 +2407,7 @@ int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) int i, index; int ret = 0; int is16bit; +AVDictionaryEntry *e = NULL; s->force_pal8 = 0; @@ -2864,6 +2866,57 @@ the_end: } } +if (e = av_dict_get(s->exif_metadata, "Orientation", e, AV_DICT_IGNORE_SUFFIX)) { +char *value = e->value + strspn(e->value, " \n\t\r"), *endptr; +int orientation = strtol(value, &endptr, 0); + +if (!*endptr) { +AVFrameSideData *sd = NULL; + +if (orientation >= 2 && orientation <= 8) { +int32_t *matrix; + +sd = av_frame_new_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); +if (!sd) { +av_log(s->avctx, AV_LOG_ERROR, "Could not allocate frame side data\n"); +return AVERROR(ENOMEM); +} + +matrix = (int32_t *)sd->data; + +switch (orientation) { +case 2: +av_display_rotation_set(matrix, 0.0); +av_display_matrix_flip(matrix, 1, 0); +break; +case 3: +av_display_rotation_set(matrix, 180.0); +break; +case 4: +av_display_rotation_set(matrix, 180.0); +av_display_matrix_flip(matrix, 1, 0); +break; +case 5: +av_display_rotation_set(matrix, 90.0); +av_display_matrix_flip(matrix, 0, 1); +break; +case 6: +av_display_rotation_set(matrix, 90.0); +break; +case 7: +av_display_rotation_set(matrix, -90.0); +av_display_matrix_flip(matrix, 0, 1); +break; +case 8: +av_display_rotation_set(matrix, -90.0); +break; +default: +av_assert0(0); +} +} +} +} + av_dict_copy(&frame->metadata, s->exif_metadata, 0); av_dict_free(&s->exif_metadata); -- 2.33.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 2/4] cmdutils: round rotation value to nearest integer
As recommended by the doxy for av_display_rotation_get(). Signed-off-by: James Almer --- fftools/cmdutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index ac172dbd65..7e9c4299fa 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -2207,7 +2207,7 @@ double get_rotation(AVStream *st) AV_PKT_DATA_DISPLAYMATRIX, NULL); double theta = 0; if (displaymatrix) -theta = -av_display_rotation_get((int32_t*) displaymatrix); +theta = -round(av_display_rotation_get((int32_t*) displaymatrix)); theta -= 360*floor(theta/360 + 0.9/360); -- 2.33.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 3/4] ffmpeg: use display matrix frame side data for autorotation
And give it priority over stream side data when present. Fixes part of ticket #6945. Signed-off-by: James Almer --- fftools/cmdutils.c | 4 +--- fftools/cmdutils.h | 2 +- fftools/ffmpeg.c| 8 fftools/ffmpeg.h| 1 + fftools/ffmpeg_filter.c | 14 +- fftools/ffplay.c| 3 ++- 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 7e9c4299fa..ed3dcd31f4 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -2201,10 +2201,8 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) return array; } -double get_rotation(AVStream *st) +double get_rotation(int32_t *displaymatrix) { -uint8_t* displaymatrix = av_stream_get_side_data(st, - AV_PKT_DATA_DISPLAYMATRIX, NULL); double theta = 0; if (displaymatrix) theta = -round(av_display_rotation_get((int32_t*) displaymatrix)); diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index 9caad01865..30f0b79725 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -648,6 +648,6 @@ void *grow_array(void *array, int elem_size, int *size, int new_size); char name[128];\ av_get_channel_layout_string(name, sizeof(name), 0, ch_layout); -double get_rotation(AVStream *st); +double get_rotation(int32_t *displaymatrix); #endif /* FFTOOLS_CMDUTILS_H */ diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index a9bb9d964d..5365f711e5 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -535,6 +535,7 @@ static void ffmpeg_cleanup(int ret) av_frame_free(&frame); } av_fifo_freep(&ifilter->frame_queue); +av_freep(&ifilter->displaymatrix); if (ist->sub2video.sub_queue) { while (av_fifo_size(ist->sub2video.sub_queue)) { AVSubtitle sub; @@ -2183,6 +2184,7 @@ static int ifilter_has_all_input_formats(FilterGraph *fg) static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) { FilterGraph *fg = ifilter->graph; +AVFrameSideData *sd; int need_reinit, ret, i; /* determine if the parameters for this input changed */ @@ -2207,6 +2209,12 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) (ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data)) need_reinit = 1; +if (sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX)) { +if (!ifilter->displaymatrix || memcmp(sd->data, ifilter->displaymatrix, sizeof(int32_t) * 9)) +need_reinit = 1; +} else if (ifilter->displaymatrix) +need_reinit = 1; + if (need_reinit) { ret = ifilter_parameters_from_frame(ifilter, frame); if (ret < 0) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1194bb0cae..30225e9ffe 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -258,6 +258,7 @@ typedef struct InputFilter { uint64_t channel_layout; AVBufferRef *hw_frames_ctx; +int32_t *displaymatrix; int eof; } InputFilter; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 6b7b6ca1b3..a4c2de07da 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -757,7 +757,12 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, last_filter = ifilter->filter; if (ist->autorotate) { -double theta = get_rotation(ist->st); +int32_t *displaymatrix = ifilter->displaymatrix; +double theta; + +if (!displaymatrix) +displaymatrix = (int32_t *)av_stream_get_side_data(ist->st, AV_PKT_DATA_DISPLAYMATRIX, NULL); +theta = get_rotation(displaymatrix); if (fabs(theta - 90) < 1.0) { ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock"); @@ -1127,6 +1132,8 @@ fail: int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame) { +AVFrameSideData *sd; + av_buffer_unref(&ifilter->hw_frames_ctx); ifilter->format = frame->format; @@ -1139,6 +1146,11 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame) ifilter->channels= frame->channels; ifilter->channel_layout = frame->channel_layout; +av_freep(&ifilter->displaymatrix); +sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX); +if (sd) +ifilter->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9); + if (frame->hw_frames_ctx) { ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx); if (!ifilter->hw_frames_ctx) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 46758b9f55..ccea0e4578 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -1925,7 +1925,8 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c } while (0) if (autorotate) { -double theta = get_ro
[FFmpeg-devel] [PATCH 4/4] ffmpeg: take into account image flipping in the display matrix
This covers only standard rotations. Finishes fixing ticket #6945. Signed-off-by: James Almer --- fftools/ffmpeg_filter.c | 26 ++ 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index a4c2de07da..da0d4faf54 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -765,18 +765,36 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, theta = get_rotation(displaymatrix); if (fabs(theta - 90) < 1.0) { +if (displaymatrix[3] > 0) { +ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); +if (ret < 0) +return ret; +} ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock"); } else if (fabs(theta - 180) < 1.0) { -ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); -if (ret < 0) -return ret; -ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); +if (displaymatrix[0] < 0) { +ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); +if (ret < 0) +return ret; +} +if (displaymatrix[4] < 0) { +ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); +} } else if (fabs(theta - 270) < 1.0) { +if (displaymatrix[3] < 0) { +ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); +if (ret < 0) +return ret; +} ret = insert_filter(&last_filter, &pad_idx, "transpose", "cclock"); } else if (fabs(theta) > 1.0) { char rotate_buf[64]; snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta); ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf); +} else if (fabs(theta) < 1.0) { +if (displaymatrix && displaymatrix[4] < 0) { +ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); +} } if (ret < 0) return ret; -- 2.33.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] avformat/webpdec: WebP demuxer implementation
From: Martin Reboredo FFmpeg has the ability to mux encoded WebP packets, but it cannot demux the format. The purpose of this patch is to add a way to extract pictures from a WebP stream. Any other side data processing (mainly ICC profiles) is left up for later work. Although we have a demuxer with `image2`, it doesn't have support for animated frames like this patch. The WebP format is based on RIFF, and due to the charasteristics of the latter, I've took advantage from chunking for processing purposes. Package reading is done by taking chunks in a specific way. Starts by splitting the `RIFF`/`WEBP` header, then it goes by any of the three `VP8 ` (lossy)/`VP8L` (lossless)/`VP8X` (extended format). In the case of a `VP8X` chunk we check for relevant flags. We then follow by grabbing the `VP8 `/`ALPH` (alpha frame) + `VP8 `/`VP8L` chunks accourdingly. If the container specifies that is an animated package we take `ANIM` for the animation parameters and the many `ANMF` animation frames, which every of them contains an image chunk (`VP8 `/`ALPH` + `VP8 `/`VP8L`). Otherwise, if an unknown chunk is found, we just simply ignore it. Tested by remuxing WebP images (using `ffmpeg -i testa.webp -codec:v copy testb.webp`), viewed the images in my browser and compared the checksums. Mostly followed the WebP container specification [1] for the implementation, the VP8 bitstream [2] and the WebP lossless specs were used too. Partially fixes #4907. [1]: https://developers.google.com/speed/webp/docs/riff_container [2]: https://datatracker.ietf.org/doc/html/rfc6386 [3]: https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification Signed-off-by: Martin Reboredo --- .gitignore | 2 + MAINTAINERS | 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/riff.c | 1 + libavformat/webpdec.c| 333 +++ libavformat/webpenc.c| 13 +- 7 files changed, 349 insertions(+), 3 deletions(-) create mode 100644 libavformat/webpdec.c diff --git a/.gitignore b/.gitignore index 9ed24b542e..0e8334d227 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ *.ptx.c *.ptx.gz *_g +compile_commands.json \#* .\#* /.config @@ -34,6 +35,7 @@ /config.h /coverage.info /avversion.h +/.cache/ /lcov/ /src /mapfile diff --git a/MAINTAINERS b/MAINTAINERS index dcac46003e..f2d8f5eb17 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -505,6 +505,7 @@ Muxers/Demuxers: wav.c Michael Niedermayer wc3movie.cMike Melanson webm dash (matroskaenc.c) Vignesh Venkatasubramanian + webp*.c Martin Reboredo webvtt* Matthew J Heaney westwood.cMike Melanson wtv.c Peter Ross diff --git a/libavformat/Makefile b/libavformat/Makefile index f7e47563da..aec2833c52 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -581,6 +581,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o matroska.o \ OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER) += webmdashenc.o OBJS-$(CONFIG_WEBM_CHUNK_MUXER) += webm_chunk.o OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o +OBJS-$(CONFIG_WEBP_DEMUXER) += webpdec.o OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o OBJS-$(CONFIG_WEBVTT_MUXER) += webvttenc.o OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood_aud.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 5471f7c16f..55f3c9a956 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -473,6 +473,7 @@ extern const AVOutputFormat ff_webm_muxer; extern const AVInputFormat ff_webm_dash_manifest_demuxer; extern const AVOutputFormat ff_webm_dash_manifest_muxer; extern const AVOutputFormat ff_webm_chunk_muxer; +extern const AVInputFormat ff_webp_demuxer; extern const AVOutputFormat ff_webp_muxer; extern const AVInputFormat ff_webvtt_demuxer; extern const AVOutputFormat ff_webvtt_muxer; diff --git a/libavformat/riff.c b/libavformat/riff.c index 27a9706510..9bd940ba52 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -321,6 +321,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { AV_CODEC_ID_VP7, MKTAG('V', 'P', '7', '1') }, { AV_CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') }, { AV_CODEC_ID_VP9, MKTAG('V', 'P', '9', '0') }, +{ AV_CODEC_ID_WEBP, MKTAG('W', 'E', 'B', 'P') }, { AV_CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') }, { AV_CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') }, { AV_CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') }, diff --git a/libavformat/webpdec.c b/libavformat/webpdec.c new file mode 100644 index 00..d2d95aea4e --- /dev/null +++ b/libavformat/webpdec.c @@ -0,0 +1,333 @@ +/* + * webp demuxer + * Copyright (
Re: [FFmpeg-devel] [PATCH] avformat/webpdec: WebP demuxer implementation
yakoy...@gmail.com: > From: Martin Reboredo > > FFmpeg has the ability to mux encoded WebP packets, but it cannot demux the > format. > The purpose of this patch is to add a way to extract pictures from a WebP > stream. > Any other side data processing (mainly ICC profiles) is left up for later > work. > Although we have a demuxer with `image2`, it doesn't have support for > animated frames like this patch. > > The WebP format is based on RIFF, and due to the charasteristics of the > latter, I've took advantage from chunking for processing purposes. > Package reading is done by taking chunks in a specific way. Starts by > splitting the `RIFF`/`WEBP` header, then it goes by any of the three > `VP8 ` (lossy)/`VP8L` (lossless)/`VP8X` (extended format). In the case of a > `VP8X` chunk we check for relevant flags. We then follow by grabbing the > `VP8 `/`ALPH` (alpha frame) + `VP8 `/`VP8L` chunks accourdingly. If the > container specifies that is an animated package we take `ANIM` for the > animation > parameters and the many `ANMF` animation frames, which every of them contains > an image chunk (`VP8 `/`ALPH` + `VP8 `/`VP8L`). Otherwise, if an unknown > chunk is found, we just simply ignore it. > > Tested by remuxing WebP images (using `ffmpeg -i testa.webp -codec:v copy > testb.webp`), viewed the images in my browser and compared the checksums. > > Mostly followed the WebP container specification [1] for the implementation, > the VP8 bitstream [2] and the WebP lossless specs were used too. > > Partially fixes #4907. > > [1]: https://developers.google.com/speed/webp/docs/riff_container > [2]: https://datatracker.ietf.org/doc/html/rfc6386 > [3]: > https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification > > Signed-off-by: Martin Reboredo > --- > .gitignore | 2 + > MAINTAINERS | 1 + > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/riff.c | 1 + > libavformat/webpdec.c| 333 +++ > libavformat/webpenc.c| 13 +- > 7 files changed, 349 insertions(+), 3 deletions(-) > create mode 100644 libavformat/webpdec.c > > diff --git a/.gitignore b/.gitignore > index 9ed24b542e..0e8334d227 100644 > --- a/.gitignore > +++ b/.gitignore > @@ -23,6 +23,7 @@ > *.ptx.c > *.ptx.gz > *_g > +compile_commands.json > \#* > .\#* > /.config > @@ -34,6 +35,7 @@ > /config.h > /coverage.info > /avversion.h > +/.cache/ This should not be part of this patch; I don't even know whether it should be committed at all. One can make ignore files by adding them to .git/info/exclude which is not copied over with git clone. Maybe you should add this to your exclude file? > /lcov/ > /src > /mapfile > diff --git a/MAINTAINERS b/MAINTAINERS > index dcac46003e..f2d8f5eb17 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -505,6 +505,7 @@ Muxers/Demuxers: >wav.c Michael Niedermayer >wc3movie.cMike Melanson >webm dash (matroskaenc.c) Vignesh Venkatasubramanian > + webp*.c Martin Reboredo >webvtt* Matthew J Heaney >westwood.cMike Melanson >wtv.c Peter Ross > diff --git a/libavformat/Makefile b/libavformat/Makefile > index f7e47563da..aec2833c52 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -581,6 +581,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o > matroska.o \ > OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER) += webmdashenc.o > OBJS-$(CONFIG_WEBM_CHUNK_MUXER) += webm_chunk.o > OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o > +OBJS-$(CONFIG_WEBP_DEMUXER) += webpdec.o > OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o > OBJS-$(CONFIG_WEBVTT_MUXER) += webvttenc.o > OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood_aud.o > diff --git a/libavformat/allformats.c b/libavformat/allformats.c > index 5471f7c16f..55f3c9a956 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -473,6 +473,7 @@ extern const AVOutputFormat ff_webm_muxer; > extern const AVInputFormat ff_webm_dash_manifest_demuxer; > extern const AVOutputFormat ff_webm_dash_manifest_muxer; > extern const AVOutputFormat ff_webm_chunk_muxer; > +extern const AVInputFormat ff_webp_demuxer; > extern const AVOutputFormat ff_webp_muxer; > extern const AVInputFormat ff_webvtt_demuxer; > extern const AVOutputFormat ff_webvtt_muxer; > diff --git a/libavformat/riff.c b/libavformat/riff.c > index 27a9706510..9bd940ba52 100644 > --- a/libavformat/riff.c > +++ b/libavformat/riff.c > @@ -321,6 +321,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { > { AV_CODEC_ID_VP7, MKTAG('V', 'P', '7', '1') }, > { AV_CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') }, > { AV_CODEC_
[FFmpeg-devel] [PATCH v2 1/2] avformat/webpdec: WebP demuxer implementation
FFmpeg has the ability to mux encoded WebP packets, but it cannot demux the format. The purpose of this patch is to add a way to extract pictures from a WebP stream. Any other side data processing (mainly ICC profiles) is left up for later work. Although we have a demuxer with `image2`, it doesn't have support for animated frames like this patch. The WebP format is based on RIFF, and due to the charasteristics of the latter, I've took advantage from chunking for processing purposes. Package reading is done by taking chunks in a specific way. Starts by splitting the `RIFF`/`WEBP` header, then it goes by any of the three `VP8 ` (lossy)/`VP8L` (lossless)/`VP8X` (extended format). In the case of a `VP8X` chunk we check for relevant flags. We then follow by grabbing the `VP8 `/`ALPH` (alpha frame) + `VP8 `/`VP8L` chunks accourdingly. If the container specifies that is an animated package we take `ANIM` for the animation parameters and the many `ANMF` animation frames, which every of them contains an image chunk (`VP8 `/`ALPH` + `VP8 `/`VP8L`). Otherwise, if an unknown chunk is found, we just simply ignore it. Tested by remuxing WebP images (using `ffmpeg -i testa.webp -codec:v copy testb.webp`), viewed the images in my browser and compared the checksums. Mostly followed the WebP container specification [1] for the implementation, the VP8 bitstream [2] and the WebP lossless specs were used too. Partially fixes #4907. [1]: https://developers.google.com/speed/webp/docs/riff_container [2]: https://datatracker.ietf.org/doc/html/rfc6386 [3]: https://developers.google.com/speed/webp/docs/webp_lossless_bitstream_specification Signed-off-by: Martin Reboredo --- MAINTAINERS | 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/riff.c | 1 + libavformat/webpdec.c| 326 +++ 5 files changed, 330 insertions(+) create mode 100644 libavformat/webpdec.c diff --git a/MAINTAINERS b/MAINTAINERS index dcac46003e..f2d8f5eb17 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -505,6 +505,7 @@ Muxers/Demuxers: wav.c Michael Niedermayer wc3movie.cMike Melanson webm dash (matroskaenc.c) Vignesh Venkatasubramanian + webp*.c Martin Reboredo webvtt* Matthew J Heaney westwood.cMike Melanson wtv.c Peter Ross diff --git a/libavformat/Makefile b/libavformat/Makefile index f7e47563da..aec2833c52 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -581,6 +581,7 @@ OBJS-$(CONFIG_WEBM_MUXER)+= matroskaenc.o matroska.o \ OBJS-$(CONFIG_WEBM_DASH_MANIFEST_MUXER) += webmdashenc.o OBJS-$(CONFIG_WEBM_CHUNK_MUXER) += webm_chunk.o OBJS-$(CONFIG_WEBP_MUXER)+= webpenc.o +OBJS-$(CONFIG_WEBP_DEMUXER) += webpdec.o OBJS-$(CONFIG_WEBVTT_DEMUXER)+= webvttdec.o subtitles.o OBJS-$(CONFIG_WEBVTT_MUXER) += webvttenc.o OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood_aud.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 5471f7c16f..55f3c9a956 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -473,6 +473,7 @@ extern const AVOutputFormat ff_webm_muxer; extern const AVInputFormat ff_webm_dash_manifest_demuxer; extern const AVOutputFormat ff_webm_dash_manifest_muxer; extern const AVOutputFormat ff_webm_chunk_muxer; +extern const AVInputFormat ff_webp_demuxer; extern const AVOutputFormat ff_webp_muxer; extern const AVInputFormat ff_webvtt_demuxer; extern const AVOutputFormat ff_webvtt_muxer; diff --git a/libavformat/riff.c b/libavformat/riff.c index 27a9706510..9bd940ba52 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -321,6 +321,7 @@ const AVCodecTag ff_codec_bmp_tags[] = { { AV_CODEC_ID_VP7, MKTAG('V', 'P', '7', '1') }, { AV_CODEC_ID_VP8, MKTAG('V', 'P', '8', '0') }, { AV_CODEC_ID_VP9, MKTAG('V', 'P', '9', '0') }, +{ AV_CODEC_ID_WEBP, MKTAG('W', 'E', 'B', 'P') }, { AV_CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') }, { AV_CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') }, { AV_CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') }, diff --git a/libavformat/webpdec.c b/libavformat/webpdec.c new file mode 100644 index 00..53b0a29a89 --- /dev/null +++ b/libavformat/webpdec.c @@ -0,0 +1,326 @@ +/* + * webp demuxer + * Copyright (c) 2021 Martin Reboredo + * + * 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, + *
[FFmpeg-devel] [PATCH v2 2/2] avformat/webpenc: better detection of anim chunks
Receiving RIFF chunks as `av_packet`s from `webpdec.c` in `webpenc.c` it wasn't doing proper animated frame detection/enumeration. Check for `ANIM`/`ANMF` chunks to see if the package is an animated WebP packet and for the `ANMF`/`ALPH`/`VP8 `/`VP8L` chunks if it's an actual frame. Signed-off-by: Martin Reboredo --- libavformat/webpenc.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index 9599fe7b85..50bee91910 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -55,13 +55,18 @@ static int is_animated_webp_packet(AVPacket *pkt) { int skip = 0; unsigned flags = 0; +int fourcc = AV_RL32(pkt->data); if (pkt->size < 4) return AVERROR_INVALIDDATA; -if (AV_RL32(pkt->data) == AV_RL32("RIFF")) +if (fourcc == AV_RL32("RIFF")) skip = 12; +else if (fourcc == AV_RL32("ANIM")) +return 1; +else if (fourcc == AV_RL32("ANMF")) +return 1; // Safe to do this as a valid WebP bitstream is >=30 bytes. -if (pkt->size < skip + 4) +if (pkt->size < skip + 4 && pkt->size != 12) return AVERROR_INVALIDDATA; if (AV_RL32(pkt->data + skip) == AV_RL32("VP8X")) { flags |= pkt->data[skip + 4 + 4]; @@ -143,6 +148,7 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) static int webp_write_packet(AVFormatContext *s, AVPacket *pkt) { WebpContext *w = s->priv_data; +int fourcc = AV_RL32(pkt->data); int ret; if (!pkt->size) @@ -161,7 +167,9 @@ static int webp_write_packet(AVFormatContext *s, AVPacket *pkt) return ret; av_packet_ref(&w->last_pkt, pkt); } -++w->frame_count; +if (fourcc == AV_RL32("ANMF") || fourcc == AV_RL32("ALPH") || +fourcc == AV_RL32("VP8 ") || fourcc == AV_RL32("VP8L")) +++w->frame_count; return 0; } -- 2.32.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] New format JPEG-XL
Hello, Have your heart about the new format JPEG-XL? https://cloudinary.com/blog/time_for_next_gen_codecs_to_dethrone_jpeg Mr Varun have done a good job to introduce into FFmpeg https://ffaux-bg.ffmpeg.org/project/ffmpeg/patch/20200315184154.28685-2-varun.gupta...@gmail.com/#52069 But i don't see it in the distribution Do you kown why? Thanks Seb ___ 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] avcodec/mlpenc: Fix mixed declarations and code warning
Signed-off-by: Andreas Rheinhardt --- Will apply this soon. libavcodec/mlpenc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index 6d4a12ce3b..ef01c1d282 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -476,6 +476,7 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; MLPEncodeContext *ctx = avctx->priv_data; +RestartHeader *const rh = &ctx->restart_header; unsigned int sum = 0; size_t size; int ret; @@ -674,8 +675,6 @@ static av_cold int mlp_encode_init(AVCodecContext *avctx) if (!ctx->decoding_params) return AVERROR(ENOMEM); -RestartHeader *rh = &ctx->restart_header; - /* TODO see if noisegen_seed is really worth it. */ rh->noisegen_seed = 0; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] Why does this break FATE?
Test seek-lavf-asf failed. Look at tests/data/fate/seek-lavf-asf.err for details. make: *** [/build/ffmpeg-git/tests/Makefile:256: fate-seek-lavf-asf] Error 139 $ cat tests/data/fate/seek-lavf-asf.err /build/ffmpeg-git/tests/fate-run.sh: line 78: 21786 Segmentation fault $target_exec $target_path/"$@" It's the same on both Windows/MSYS2 and Linux. Let's see how patchwork results will be... Signed-off-by: softworkz --- libavcodec/version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/version.h b/libavcodec/version.h index 83db2b242a..d162607f4b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -27,9 +27,9 @@ #include "libavutil/version.h" -#define LIBAVCODEC_VERSION_MAJOR 59 -#define LIBAVCODEC_VERSION_MINOR 7 -#define LIBAVCODEC_VERSION_MICRO 102 +#define LIBAVCODEC_VERSION_MAJOR 60 +#define LIBAVCODEC_VERSION_MINOR 0 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 2.30.2.windows.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] [PATCH] Why does this break FATE?
On 9/8/2021 10:14 PM, Soft Works wrote: Test seek-lavf-asf failed. Look at tests/data/fate/seek-lavf-asf.err for details. make: *** [/build/ffmpeg-git/tests/Makefile:256: fate-seek-lavf-asf] Error 139 $ cat tests/data/fate/seek-lavf-asf.err /build/ffmpeg-git/tests/fate-run.sh: line 78: 21786 Segmentation fault $target_exec $target_path/"$@" It's the same on both Windows/MSYS2 and Linux. Let's see how patchwork results will be... Please, don't send patches just to have patchwork run FATE for you. It litters the mailing list. Do it locally. Signed-off-by: softworkz --- libavcodec/version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/version.h b/libavcodec/version.h index 83db2b242a..d162607f4b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -27,9 +27,9 @@ #include "libavutil/version.h" -#define LIBAVCODEC_VERSION_MAJOR 59 -#define LIBAVCODEC_VERSION_MINOR 7 -#define LIBAVCODEC_VERSION_MICRO 102 +#define LIBAVCODEC_VERSION_MAJOR 60 Bumping major version of any library without the required considerations will more likely than not break many tests and scenarios. If you just want to bump version for a new addition or change, bump minor and/or micro. +#define LIBAVCODEC_VERSION_MINOR 0 +#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ ___ 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] Why does this break FATE?
> -Original Message- > From: ffmpeg-devel On Behalf Of > James Almer > Sent: Thursday, 9 September 2021 03:18 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? > > On 9/8/2021 10:14 PM, Soft Works wrote: > > Test seek-lavf-asf failed. Look at tests/data/fate/seek-lavf- > asf.err for details. > > make: *** [/build/ffmpeg-git/tests/Makefile:256: fate-seek-lavf- > asf] Error 139 > > > > $ cat tests/data/fate/seek-lavf-asf.err > > /build/ffmpeg-git/tests/fate-run.sh: line 78: 21786 Segmentation > fault $target_exec $target_path/"$@" > > > > > > It's the same on both Windows/MSYS2 and Linux. Let's see how > patchwork results will be... > > Please, don't send patches just to have patchwork run FATE for you. > It > litters the mailing list. Do it locally. As written above I _did_ run it locally on both Linux and Windows/MSYS. > > --- > > libavcodec/version.h | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/libavcodec/version.h b/libavcodec/version.h > > index 83db2b242a..d162607f4b 100644 > > --- a/libavcodec/version.h > > +++ b/libavcodec/version.h > > @@ -27,9 +27,9 @@ > > > > #include "libavutil/version.h" > > > > -#define LIBAVCODEC_VERSION_MAJOR 59 > > -#define LIBAVCODEC_VERSION_MINOR 7 > > -#define LIBAVCODEC_VERSION_MICRO 102 > > +#define LIBAVCODEC_VERSION_MAJOR 60 > > Bumping major version of any library without the required > considerations > will more likely than not break many tests and scenarios. > If you just want to bump version for a new addition or change, bump > minor and/or micro. The patch I'm working on requires a major version bump, that's why I had it included in the commit where it belongs to. Needless to say that it was the very last thing I suspected for causing this. So how can this be that a version change without anything else can cause a test to fail?` softworkz PS: Patchwork shows the same error ___ 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] Why does this break FATE?
On 9/8/2021 10:29 PM, Soft Works wrote: -Original Message- From: ffmpeg-devel On Behalf Of James Almer Sent: Thursday, 9 September 2021 03:18 To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? On 9/8/2021 10:14 PM, Soft Works wrote: Test seek-lavf-asf failed. Look at tests/data/fate/seek-lavf- asf.err for details. make: *** [/build/ffmpeg-git/tests/Makefile:256: fate-seek-lavf- asf] Error 139 $ cat tests/data/fate/seek-lavf-asf.err /build/ffmpeg-git/tests/fate-run.sh: line 78: 21786 Segmentation fault $target_exec $target_path/"$@" It's the same on both Windows/MSYS2 and Linux. Let's see how patchwork results will be... Please, don't send patches just to have patchwork run FATE for you. It litters the mailing list. Do it locally. As written above I _did_ run it locally on both Linux and Windows/MSYS. That was more than enough to know that the failure you saw was not a fluke. --- libavcodec/version.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/version.h b/libavcodec/version.h index 83db2b242a..d162607f4b 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -27,9 +27,9 @@ #include "libavutil/version.h" -#define LIBAVCODEC_VERSION_MAJOR 59 -#define LIBAVCODEC_VERSION_MINOR 7 -#define LIBAVCODEC_VERSION_MICRO 102 +#define LIBAVCODEC_VERSION_MAJOR 60 Bumping major version of any library without the required considerations will more likely than not break many tests and scenarios. If you just want to bump version for a new addition or change, bump minor and/or micro. The patch I'm working on requires a major version bump, that's why I had it included in the commit where it belongs to. Since we haven't had a release since the last major bump, we can still apply ABI (not API) breaking changes, if needed. So send your patch for consideration, without bumping major. Needless to say that it was the very last thing I suspected for causing this. So how can this be that a version change without anything else can cause a test to fail?` softworkz PS: Patchwork shows the same error ___ 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] webp: fix transforms after a palette with pixel packing.
On Mon, Aug 30, 2021 at 5:11 AM Maryla wrote: > > When a color indexing transform with 16 or fewer colors is used, > WebP uses "pixel packing", i.e. storing several pixels in one byte, > which virtually reduces the width of the image (see WebPContext's > reduced_width field). This reduced_width should always be used when > reading and applying subsequent transforms. > > Updated patch with added fate test. > The source image dual_transform.webp can be downloaded by cloning > https://chromium.googlesource.com/webm/libwebp-test-data/ > > Fixes: 9368 > --- > libavcodec/webp.c | 34 ++- > tests/fate/image.mak | 3 ++ > .../fate/webp-rgb-lossless-palette-predictor | 6 > 3 files changed, 27 insertions(+), 16 deletions(-) > create mode 100644 tests/ref/fate/webp-rgb-lossless-palette-predictor > This works locally and matches the output from libwebp. I sent a request to samples-request@ to add the file. This should have a micro version bump for libavcodec/version.h; I've added that locally. > diff --git a/libavcodec/webp.c b/libavcodec/webp.c > index 3efd4438d9..e4c67adc3a 100644 > --- a/libavcodec/webp.c > +++ b/libavcodec/webp.c > @@ -181,7 +181,10 @@ typedef struct ImageContext { > uint32_t *color_cache; /* color cache data */ > int nb_huffman_groups; /* number of huffman groups */ > HuffReader *huffman_groups; /* reader for each huffman group */ > -int size_reduction; /* relative size compared to primary > image, log2 */ > +/* relative size compared to primary image, log2. > + * for IMAGE_ROLE_COLOR_INDEXING with <= 16 colors, this is log2 of the > + * number of pixels per byte in the primary image (pixel packing) */ > +int size_reduction; > int is_alpha_primary; > } ImageContext; > > @@ -205,7 +208,9 @@ typedef struct WebPContext { > > int nb_transforms; /* number of transforms */ > enum TransformType transforms[4]; /* transformations used in the > image, in order */ > -int reduced_width; /* reduced width for index image, if > applicable */ > +/* reduced width when using a color indexing transform with <= 16 colors > (pixel packing) > + * before pixels are unpacked, or same as width otherwise. */ > +int reduced_width; > int nb_huffman_groups; /* number of huffman groups in the > primary image */ > ImageContext image[IMAGE_ROLE_NB]; /* image context for each role */ > } WebPContext; > @@ -425,13 +430,9 @@ static int decode_entropy_coded_image(WebPContext *s, > enum ImageRole role, > static int decode_entropy_image(WebPContext *s) > { > ImageContext *img; > -int ret, block_bits, width, blocks_w, blocks_h, x, y, max; > +int ret, block_bits, blocks_w, blocks_h, x, y, max; > > -width = s->width; > -if (s->reduced_width > 0) > -width = s->reduced_width; > - > -PARSE_BLOCK_SIZE(width, s->height); > +PARSE_BLOCK_SIZE(s->reduced_width, s->height); > > ret = decode_entropy_coded_image(s, IMAGE_ROLE_ENTROPY, blocks_w, > blocks_h); > if (ret < 0) > @@ -460,7 +461,7 @@ static int parse_transform_predictor(WebPContext *s) > { > int block_bits, blocks_w, blocks_h, ret; > > -PARSE_BLOCK_SIZE(s->width, s->height); > +PARSE_BLOCK_SIZE(s->reduced_width, s->height); > > ret = decode_entropy_coded_image(s, IMAGE_ROLE_PREDICTOR, blocks_w, > blocks_h); > @@ -476,7 +477,7 @@ static int parse_transform_color(WebPContext *s) > { > int block_bits, blocks_w, blocks_h, ret; > > -PARSE_BLOCK_SIZE(s->width, s->height); > +PARSE_BLOCK_SIZE(s->reduced_width, s->height); > > ret = decode_entropy_coded_image(s, IMAGE_ROLE_COLOR_TRANSFORM, blocks_w, > blocks_h); > @@ -620,7 +621,7 @@ static int decode_entropy_coded_image(WebPContext *s, > enum ImageRole role, > } > > width = img->frame->width; > -if (role == IMAGE_ROLE_ARGB && s->reduced_width > 0) > +if (role == IMAGE_ROLE_ARGB) > width = s->reduced_width; > > x = 0; y = 0; > @@ -925,7 +926,7 @@ static int apply_predictor_transform(WebPContext *s) > int x, y; > > for (y = 0; y < img->frame->height; y++) { > -for (x = 0; x < img->frame->width; x++) { > +for (x = 0; x < s->reduced_width; x++) { > int tx = x >> pimg->size_reduction; > int ty = y >> pimg->size_reduction; > enum PredictionMode m = GET_PIXEL_COMP(pimg->frame, tx, ty, 2); > @@ -965,7 +966,7 @@ static int apply_color_transform(WebPContext *s) > cimg = &s->image[IMAGE_ROLE_COLOR_TRANSFORM]; > > for (y = 0; y < img->frame->height; y++) { > -for (x = 0; x < img->frame->width; x++) { > +for (x = 0; x < s->reduced_width; x++) { > cx = x >> cimg->size_reduction; > cy = y
Re: [FFmpeg-devel] [PATCH] Why does this break FATE?
> -Original Message- > From: ffmpeg-devel On Behalf Of > James Almer > Sent: Thursday, 9 September 2021 03:34 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? > > On 9/8/2021 10:29 PM, Soft Works wrote: > > > > > >> -Original Message- > >> From: ffmpeg-devel On Behalf Of > >> James Almer > >> Sent: Thursday, 9 September 2021 03:18 > >> To: ffmpeg-devel@ffmpeg.org > >> Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? > >> > >> On 9/8/2021 10:14 PM, Soft Works wrote: > >>> Test seek-lavf-asf failed. Look at tests/data/fate/seek-lavf- > >> asf.err for details. > >>> make: *** [/build/ffmpeg-git/tests/Makefile:256: fate-seek-lavf- > >> asf] Error 139 > >>> > >>> $ cat tests/data/fate/seek-lavf-asf.err > >>> /build/ffmpeg-git/tests/fate-run.sh: line 78: 21786 Segmentation > >> fault $target_exec $target_path/"$@" > >>> > >>> > >>> It's the same on both Windows/MSYS2 and Linux. Let's see how > >> patchwork results will be... > >> > >> Please, don't send patches just to have patchwork run FATE for > you. > >> It > >> litters the mailing list. Do it locally. > > > > As written above I _did_ run it locally on both Linux and > Windows/MSYS. > > That was more than enough to know that the failure you saw was not a > fluke. Might be true, but it doesn't seem right to me that this is happening and submitting a patch for demonstration seemed to be an adequate measure to present the issue. > Since we haven't had a release since the last major bump, we can > still > apply ABI (not API) breaking changes, if needed. Based on the fact that requirements are strict about MINOR bumps and mandating them to be included in the very commit that is requiring the bump, I didn't expect that there's a different strategy for MAJOR bumps. Anyway - will use minor bumps, then. Thanks, softworkz ___ 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] Why does this break FATE?
On 9/8/2021 10:49 PM, Soft Works wrote: -Original Message- From: ffmpeg-devel On Behalf Of James Almer Sent: Thursday, 9 September 2021 03:34 To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? On 9/8/2021 10:29 PM, Soft Works wrote: -Original Message- From: ffmpeg-devel On Behalf Of James Almer Sent: Thursday, 9 September 2021 03:18 To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? On 9/8/2021 10:14 PM, Soft Works wrote: Test seek-lavf-asf failed. Look at tests/data/fate/seek-lavf- asf.err for details. make: *** [/build/ffmpeg-git/tests/Makefile:256: fate-seek-lavf- asf] Error 139 $ cat tests/data/fate/seek-lavf-asf.err /build/ffmpeg-git/tests/fate-run.sh: line 78: 21786 Segmentation fault $target_exec $target_path/"$@" It's the same on both Windows/MSYS2 and Linux. Let's see how patchwork results will be... Please, don't send patches just to have patchwork run FATE for you. It litters the mailing list. Do it locally. As written above I _did_ run it locally on both Linux and Windows/MSYS. That was more than enough to know that the failure you saw was not a fluke. Might be true, but it doesn't seem right to me that this is happening and submitting a patch for demonstration seemed to be an adequate measure to present the issue. Since we haven't had a release since the last major bump, we can still apply ABI (not API) breaking changes, if needed. Based on the fact that requirements are strict about MINOR bumps and mandating them to be included in the very commit that is requiring the bump, I didn't expect that there's a different strategy for MAJOR bumps. A major bump is done once every few years to remove deprecated APIs and open the ABI for changes. After a major bump takes place, there's an "Unstable ABI" period where one can make such breaking changes (Altering field offsets in public structs, adding new fields or changing their types on structs that have their size tied to the ABI, changing public enum and #define values, etc). A single major bump should encompass every breaking change during this short "unstable" period. In contrast, every new API addition requires its own minor or micro bump. Anyway - will use minor bumps, then. Thanks, softworkz ___ 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 v2] avcodec/libvpxenc: Apply codec options to alpha codec context
On Fri, Sep 3, 2021 at 5:02 PM James Zern wrote: > > On Fri, Sep 3, 2021 at 1:33 AM Adam Chelminski > wrote: > > > > When encoding yuva420 (alpha) frames, the vpx encoder uses a second > > vpx_codec_ctx to encode the alpha stream. However, codec options were > > only being applied to the primary encoder. This patch updates > > codecctl_int and codecctl_intp to also apply codec options to the alpha > > codec context when encoding frames with alpha. > > > > This is necessary to take advantage of libvpx speed optimizations > > such as 'row-mt' and 'cpu-used' when encoding videos with alpha. > > Without this patch, the speed optimizations are only applied to the > > primary stream encoding, and the overall encoding is just as slow > > as it would be without the options specified. > > > > Signed-off-by: Adam Chelminski > > --- > > doc/APIchanges | 4 > > libavcodec/libvpxenc.c | 26 -- > > libavcodec/version.h | 2 +- > > 3 files changed, 29 insertions(+), 3 deletions(-) > > > > lgtm. One could argue that the alpha encoder should have its own set > of options to allow for a higher quality alpha plane, but I think > aligning the configurations makes sense given the current state of the > code. I'll submit this next week if there aren't any comments. > Applied. Thanks for the 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] [PATCH v2] libavfilter: add a gblur_vulkan filter
Andreas Rheinhardt Wrote: > Wu Jianhua: > > +static av_cold void init_gaussian_params(GBlurVulkanContext *s) { > > +if (!(s->size & 1)) { > > +av_log(s, AV_LOG_WARNING, "kernel size should be even\n"); > > +s->size++; > > +} > > +if (s->sigmaV <= 0) > > +s->sigmaV = s->sigma; > > + > > +s->kernel_size = (s->size >> 1) + 1; > > +s->kernel = av_mallocz(sizeof(float) * s->kernel_size); > > Unchecked allocation. But it seems that it is also an unneeded > allocation: You only use this buffer with init_gaussian_kernel() and > immediately afterwards you copy the result to a buffer provided by > ff_vk_map_buffers(). Can't you use this buffer directly in > init_gaussion_kernel()? (The only potential issue I see with this is > alignment.) > > > +kernel_def = av_asprintf("float kernel[%i];", s->kernel_size); > > Unchecked allocation. > > > +buf_desc.buf_content = kernel_def; > > + > > +if (!sampler) > > +return AVERROR_EXTERNAL; > > kernel_def leaks here; move this check before its allocation. > > > +s->pl_hor = ff_vk_create_pipeline(ctx); > > + > > +if (!s->pl_hor) > > +return AVERROR(ENOMEM); > > kernel_def leaks here. > > > +s->pl_ver = ff_vk_create_pipeline(ctx); > > +if (!s->pl_ver) > > +return AVERROR(ENOMEM); > > kernel_def leaks here. > > > +RET(ff_vk_create_exec_ctx(ctx, &s->exec)); > > + > > +s->initialized = 1; > > This variable is write-only. I am sorry I am confused with the write-only variable here. Could you elaborate it further? > > > +ff_vk_free_buf(avctx, &s->params_buf_hor); > > +ff_vk_free_buf(avctx, &s->params_buf_ver); > > +ff_vk_filter_uninit(avctx); > > Is it really safe to call this if initializing failed? > > > +tmp = ff_get_video_buffer(outlink, outlink->w, outlink->h); > > +if (!tmp) { > > +err = AVERROR(ENOMEM); > > +goto fail; > > +} > > Can't you allocate the tmp frame once and just keep it? Thanks for the careful review. Very helpful. I'll fix and resubmit the patches. Regards, Jianhua ___ 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] Why does this break FATE?
> -Original Message- > From: ffmpeg-devel On Behalf Of > James Almer > Sent: Thursday, 9 September 2021 03:57 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? > [..] > > > > Based on the fact that requirements are strict about MINOR bumps > and > > mandating them to be included in the very commit that is requiring > > the bump, I didn't expect that there's a different strategy for > > MAJOR bumps. > > A major bump is done once every few years to remove deprecated APIs > and > open the ABI for changes. After a major bump takes place, there's an > "Unstable ABI" period where one can make such breaking changes > (Altering > field offsets in public structs, adding new fields or changing their > types on structs that have their size tied to the ABI, changing > public > enum and #define values, etc). > > A single major bump should encompass every breaking change during > this > short "unstable" period. Why does there have to be an "unstable" period instead of making the MAJOR bumps directly in those commits that are breaking ABI compatibility, Is it about "saving" numbers? softworkz ___ 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] Why does this break FATE?
On 9/8/2021 11:24 PM, Soft Works wrote: -Original Message- From: ffmpeg-devel On Behalf Of James Almer Sent: Thursday, 9 September 2021 03:57 To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? [..] Based on the fact that requirements are strict about MINOR bumps and mandating them to be included in the very commit that is requiring the bump, I didn't expect that there's a different strategy for MAJOR bumps. A major bump is done once every few years to remove deprecated APIs and open the ABI for changes. After a major bump takes place, there's an "Unstable ABI" period where one can make such breaking changes (Altering field offsets in public structs, adding new fields or changing their types on structs that have their size tied to the ABI, changing public enum and #define values, etc). A single major bump should encompass every breaking change during this short "unstable" period. Why does there have to be an "unstable" period instead of making the MAJOR bumps directly in those commits that are breaking ABI compatibility, Is it about "saving" numbers? To keep the bumping of major revision to a single number every few years, yes. We decided to go the opposite way of x264. Also, the FF_API defines would need to be updated way too often otherwise. softworkz ___ 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] Why does this break FATE?
> -Original Message- > From: ffmpeg-devel On Behalf Of > James Almer > Sent: Thursday, 9 September 2021 04:31 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? > > On 9/8/2021 11:24 PM, Soft Works wrote: > > > > > >> -Original Message- > >> From: ffmpeg-devel On Behalf Of > >> James Almer > >> Sent: Thursday, 9 September 2021 03:57 > >> To: ffmpeg-devel@ffmpeg.org > >> Subject: Re: [FFmpeg-devel] [PATCH] Why does this break FATE? > >> > > > > [..] > > > >>> > >>> Based on the fact that requirements are strict about MINOR bumps > >> and > >>> mandating them to be included in the very commit that is > requiring > >>> the bump, I didn't expect that there's a different strategy for > >>> MAJOR bumps. > >> > >> A major bump is done once every few years to remove deprecated > APIs > >> and > >> open the ABI for changes. After a major bump takes place, there's > an > >> "Unstable ABI" period where one can make such breaking changes > >> (Altering > >> field offsets in public structs, adding new fields or changing > their > >> types on structs that have their size tied to the ABI, changing > >> public > >> enum and #define values, etc). > >> > >> A single major bump should encompass every breaking change during > >> this > >> short "unstable" period. > > > > Why does there have to be an "unstable" period instead of making > the > > MAJOR bumps directly in those commits that are breaking ABI > compatibility, > > Is it about "saving" numbers? > > To keep the bumping of major revision to a single number every few > years, yes. We decided to go the opposite way of x264. > Also, the FF_API defines would need to be updated way too often > otherwise. OK understood. Thanks a lot for explaining! sw ___ 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] Running FATE
Hi, I have a few questions regarding FATE: - Is it possible to run FATE in a way that it doesn't stop on error? - Is there a better way to exclude certain tests other than commenting them in the mak files? - Is it possible to run just a specific test via command line? Thanks, softworkz ___ 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] libavfilter: add a gblur_vulkan filter
This commit adds a powerful and customizable gblur Vulkan filter, which provides a maximum 127x127 kernel size of Gaussian Filter. The size could be adjusted by requirements on quality or performance. The following command is on how to apply gblur_vulkan filter: ffmpeg -init_hw_device vulkan=vul:0 -filter_hw_device vul -i input.264 -vf hwupload=extra_hw_frames=16,gblur_vulkan,hwdownload,format=yuv420p output.264 Signed-off-by: Wu Jianhua --- configure | 1 + libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_gblur_vulkan.c | 511 ++ 4 files changed, 514 insertions(+) create mode 100644 libavfilter/vf_gblur_vulkan.c diff --git a/configure b/configure index af410a9d11..4b9a0d8e07 100755 --- a/configure +++ b/configure @@ -3601,6 +3601,7 @@ freezedetect_filter_select="scene_sad" frei0r_filter_deps="frei0r libdl" frei0r_src_filter_deps="frei0r libdl" fspp_filter_deps="gpl" +gblur_vulkan_filter_deps="vulkan_lib libglslang" histeq_filter_deps="gpl" hqdn3d_filter_deps="gpl" interlace_filter_deps="gpl" diff --git a/libavfilter/Makefile b/libavfilter/Makefile index af957a5ac0..5f74e33599 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -286,6 +286,7 @@ OBJS-$(CONFIG_FREEZEFRAMES_FILTER) += vf_freezeframes.o OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o OBJS-$(CONFIG_FSPP_FILTER) += vf_fspp.o qp_table.o OBJS-$(CONFIG_GBLUR_FILTER) += vf_gblur.o +OBJS-$(CONFIG_GBLUR_VULKAN_FILTER) += vf_gblur_vulkan.o vulkan.o OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o OBJS-$(CONFIG_GRAPHMONITOR_FILTER) += f_graphmonitor.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 0c6b2347c8..b5576de3af 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -271,6 +271,7 @@ extern const AVFilter ff_vf_freezeframes; extern const AVFilter ff_vf_frei0r; extern const AVFilter ff_vf_fspp; extern const AVFilter ff_vf_gblur; +extern const AVFilter ff_vf_gblur_vulkan; extern const AVFilter ff_vf_geq; extern const AVFilter ff_vf_gradfun; extern const AVFilter ff_vf_graphmonitor; diff --git a/libavfilter/vf_gblur_vulkan.c b/libavfilter/vf_gblur_vulkan.c new file mode 100644 index 00..5c072f8971 --- /dev/null +++ b/libavfilter/vf_gblur_vulkan.c @@ -0,0 +1,511 @@ +/* + * copyright (c) 2021 Wu Jianhua + * 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 "libavutil/random_seed.h" +#include "libavutil/opt.h" +#include "vulkan.h" +#include "internal.h" + +#define CGS 32 +#define GBLUR_MAX_KERNEL_SIZE 127 + +typedef struct GBlurVulkanContext { +VulkanFilterContext vkctx; +FFVkExecContext *exec; +VulkanPipeline *pl_hor; +VulkanPipeline *pl_ver; +FFVkBuffer params_buf_hor; +FFVkBuffer params_buf_ver; + +VkDescriptorImageInfo input_images[3]; +VkDescriptorImageInfo tmp_images[3]; +VkDescriptorImageInfo output_images[3]; +VkDescriptorBufferInfo params_desc_hor; +VkDescriptorBufferInfo params_desc_ver; + +int initialized; +int size; +int planes; +int kernel_size; +float sigma; +float sigmaV; +AVFrame *tmpframe; +} GBlurVulkanContext; + +static const char gblur_horizontal[] = { +C(0, void gblur(const ivec2 pos, const int index) ) +C(0, { ) +C(1, vec4 sum = texture(input_image[index], pos) * kernel[0]; ) +C(0, ) +C(1, for(int i = 1; i < kernel.length(); i++) { ) +C(2, sum += texture(input_image[index], pos + vec2(i, 0.0)) * kernel[i]; ) +C(2, sum += texture(input_image[index], pos - vec2(i, 0.0)) * kernel[i]; ) +C(1, } ) +C(0, ) +C(1, imageStore(output_image[index], pos, sum);