Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vsrc_testsrc: fix a preprocessor check

2018-05-21 Thread Tobias Rapp

On 18.05.2018 22:43, James Almer wrote:

ffmpeg | branch: master | James Almer  | Fri May 18 17:42:57 
2018 -0300| [79126ce80e21f2bc986fef7b8f0d6335136538da] | committer: James Almer

avfilter/vsrc_testsrc: fix a preprocessor check

Signed-off-by: James Almer 


http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79126ce80e21f2bc986fef7b8f0d6335136538da

---

  libavfilter/vsrc_testsrc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 8d76ae9271..f06714807f 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -1252,7 +1252,7 @@ AVFilter ff_vsrc_yuvtestsrc = {
  
  #endif /* CONFIG_YUVTESTSRC_FILTER */
  
-#if CONFIG_PAL75_FILTER || CONFIG_PAL100_FILTER || CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER

+#if CONFIG_PAL75BARS_FILTER || CONFIG_PAL100BARS_FILTER || 
CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER
  
  static const uint8_t rainbow[7][4] = {

  { 180, 128, 128, 255 }, /* 75% white */



I'm sorry for the oversight. Thanks for fixing it!

Regards,
Tobias

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avformat/mpegts: set AV_DISPOSITION_DESCRIPTIONS for OIPF cases

2018-05-21 Thread Łukasz Krzciuk
That is great - thank you.

Regards,

*Łukasz Krzciuk*
Developer

Vewd
ul. Grabarska 2, Pegaz 2A, 50-079 Wrocław, Polska


On Mon, May 21, 2018 at 10:06 PM, Aman Gupta  wrote:

> On Sun, May 20, 2018 at 11:09 PM, Łukasz Krzciuk 
> wrote:
>
> > Any updates on this issue?
> >
>
> I believe that this patch was already merged:
> https://github.com/FFmpeg/FFmpeg/commit/48330500efd636b1540002b600257d
> 8802badc69
>
>
> >
> > Regards,
> >
> > *Łukasz Krzciuk*
> > Developer
> >
> > Vewd
> > ul. Grabarska 2, Pegaz 2A, 50-079 Wrocław, Polska
> >
> >
> > On Tue, May 15, 2018 at 12:51 PM, Łukasz Krzciuk 
> > wrote:
> >
> > > I have prepared a testcase. PMT data comes from org.hbbtv_HTML50420 - I
> > > have squashed them and there is one file attached now. Please review.
> > >
> > > Regards,
> > >
> > > *Łukasz Krzciuk*
> > > Developer
> > >
> > > Vewd
> > > ul. Grabarska 2, Pegaz 2A, 50-079 Wrocław, Polska
> > >
> > >
> > > On Mon, May 14, 2018 at 10:23 AM, Łukasz Krzciuk 
> > > wrote:
> > >
> > >> I have prepared a testcase. PMT data comes from org.hbbtv_HTML50420.
> > Please
> > >> review.
> > >>
> > >> Regards,
> > >>
> > >> *Łukasz Krzciuk*
> > >> Developer
> > >>
> > >> Vewd
> > >> ul. Grabarska 2, Pegaz 2A, 50-079 Wrocław, Polska
> > >>
> > >>
> > >> On Thu, May 10, 2018 at 8:54 PM, Aman Gupta  wrote:
> > >>
> > >>> On Thu, May 10, 2018 at 1:46 AM Łukasz Krzciuk 
> > >>> wrote:
> > >>>
> > >>> > Lets skip a testcase. It will be not easy to me to prepare it.
> > >>>
> > >>>
> > >>> It should be simple to extract a small sample containing the PMT. If
> > you
> > >>> link some larger samples I can help extract the relevant bytes for
> test
> > >>> case.
> > >>>
> > >>> Aman
> > >>>
> > >>>
> > >>> >
> > >>> > Regards,
> > >>> >
> > >>> > *Łukasz Krzciuk*
> > >>> > Developer
> > >>> >
> > >>> > Vewd
> > >>> > ul. Grabarska 2
> > >>> > ,
> Pegaz
> > >>> 2A,
> > >>> > 50-079 Wrocław, Polska
> > >>> >
> > >>> >
> > >>> > On Thu, May 10, 2018 at 3:09 AM, Michael Niedermayer
> > >>> >  > >>> > > wrote:
> > >>> >
> > >>> > > On Wed, May 09, 2018 at 10:19:26AM +0200, Łukasz Krzciuk wrote:
> > >>> > > > Any updates on this issue?
> > >>> > >
> > >>> > > about adding a testcase ?
> > >>> > > adding a huge sample file is not possible.
> > >>> > > It either has to be made smaller or generated by a muxer
> > >>> > > or last resort, no test
> > >>> > >
> > >>> > > [...]
> > >>> > > --
> > >>> > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC7
> > >>> 87040B0FAB
> > >>> > >
> > >>> > > The worst form of inequality is to try to make unequal things
> > equal.
> > >>> > > -- Aristotle
> > >>> > >
> > >>> > > ___
> > >>> > > ffmpeg-devel mailing list
> > >>> > > ffmpeg-devel@ffmpeg.org
> > >>> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >>> > >
> > >>> > >
> > >>> > ___
> > >>> > ffmpeg-devel mailing list
> > >>> > ffmpeg-devel@ffmpeg.org
> > >>> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >>> >
> > >>> ___
> > >>> ffmpeg-devel mailing list
> > >>> ffmpeg-devel@ffmpeg.org
> > >>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >>>
> > >>
> > >>
> > >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v4 4/8] lavfi: add common Vulkan filtering code

2018-05-21 Thread Rostislav Pehlivanov
This commit adds a common code for use in Vulkan filters. It attempts
to ease the burden of writing Vulkan image filtering to a minimum,
which is pretty much a requirement considering how verbose the API is.

It supports both compute and graphic pipelines and manages to abstract
the API to such a level there's no need to call any Vulkan functions
inside the init path of the code. Handling shader descriptors is probably
the bulk of the code, and despite the abstraction, it loses none of the
features for describing shader IO.

In order to produce linkable shaders, it depends on the libshaderc
library (and depends on the latest stable version of it). This allows
for greater performance and flexibility than static built-in shaders
and also eliminates the cumbersome process of interfacing with glslang
to compile GLSL to SPIR-V.

It's based off of the common opencl and provides similar interfaces for
filter pad init and config, with the addition that it also supports
in-place filtering.

Signed-off-by: Rostislav Pehlivanov 
---
 configure|   12 +-
 libavfilter/vulkan.c | 1190 ++
 libavfilter/vulkan.h |  223 
 3 files changed, 1423 insertions(+), 2 deletions(-)
 create mode 100644 libavfilter/vulkan.c
 create mode 100644 libavfilter/vulkan.h

diff --git a/configure b/configure
index 5f4407b753..abcfe32625 100755
--- a/configure
+++ b/configure
@@ -252,6 +252,7 @@ External library support:
   --enable-librsvg enable SVG rasterization via librsvg [no]
   --enable-librubberband   enable rubberband needed for rubberband filter [no]
   --enable-librtmp enable RTMP[E] support via librtmp [no]
+  --enable-libshaderc  enable GLSL->SPIRV compilation via libshaderc [no]
   --enable-libshineenable fixed-point MP3 encoding via libshine [no]
   --enable-libsmbclientenable Samba protocol via libsmbclient [no]
   --enable-libsnappy   enable Snappy compression, needed for hap encoding 
[no]
@@ -1707,6 +1708,7 @@ EXTERNAL_LIBRARY_LIST="
 libpulse
 librsvg
 librtmp
+libshaderc
 libshine
 libsmbclient
 libsnappy
@@ -2225,6 +2227,7 @@ HAVE_LIST="
 opencl_dxva2
 opencl_vaapi_beignet
 opencl_vaapi_intel_media
+shaderc_opt_perf
 vulkan_drm_mod
 perl
 pod2man
@@ -3456,12 +3459,12 @@ avcodec_select="null_bsf"
 avdevice_deps="avformat avcodec avutil"
 avdevice_suggest="libm"
 avfilter_deps="avutil"
-avfilter_suggest="libm"
+avfilter_suggest="libm libshaderc"
 avformat_deps="avcodec avutil"
 avformat_suggest="libm network zlib"
 avresample_deps="avutil"
 avresample_suggest="libm"
-avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi 
videotoolbox corefoundation corevideo coremedia bcrypt"
+avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl vulkan 
user32 vaapi videotoolbox corefoundation corevideo coremedia bcrypt"
 postproc_deps="avutil gpl"
 postproc_suggest="libm"
 swresample_deps="avutil"
@@ -6050,6 +6053,7 @@ enabled libpulse  && require_pkg_config libpulse 
libpulse pulse/pulseaud
 enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
 enabled librtmp   && require_pkg_config librtmp librtmp librtmp/rtmp.h 
RTMP_Socket
 enabled librubberband && require_pkg_config librubberband "rubberband >= 
1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append 
librubberband_extralibs "-lstdc++"
+enabled libshaderc&& require libshaderc shaderc/shaderc.h 
shaderc_compiler_initialize -lshaderc_shared
 enabled libshine  && require_pkg_config libshine shine shine/layer3.h 
shine_encode_buffer
 enabled libsmbclient  && { check_pkg_config libsmbclient smbclient 
libsmbclient.h smbc_init ||
require libsmbclient libsmbclient.h smbc_init 
-lsmbclient; }
@@ -6355,6 +6359,10 @@ enabled crystalhd && check_lib crystalhd "stdint.h 
libcrystalhd/libcrystalhd_if.
 enabled vulkan &&
 require_pkg_config vulkan "vulkan >= 1.1.73" "vulkan/vulkan.h" 
vkCreateInstance
 
+if enabled_all vulkan libshaderc ; then
+check_cc shaderc_opt_perf shaderc/shaderc.h "int t = 
shaderc_optimization_level_performance"
+fi
+
 if enabled_all vulkan libdrm ; then
 check_cpp_condition vulkan_drm_mod vulkan/vulkan.h "defined 
VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME"
 fi
diff --git a/libavfilter/vulkan.c b/libavfilter/vulkan.c
new file mode 100644
index 00..7954c6f665
--- /dev/null
+++ b/libavfilter/vulkan.c
@@ -0,0 +1,1190 @@
+/*
+ * Vulkan utilities
+ * Copyright (c) 2018 Rostislav Pehlivanov 
+ *
+ * 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

Re: [FFmpeg-devel] [PATCH v3 4/8] lavfi: add common Vulkan filtering code

2018-05-21 Thread James Almer
On 5/21/2018 11:46 PM, Rostislav Pehlivanov wrote:
> This commit adds a common code for use in Vulkan filters. It attempts
> to ease the burden of writing Vulkan image filtering to a minimum,
> which is pretty much a requirement considering how verbose the API is.
> 
> It supports both compute and graphic pipelines and manages to abstract
> the API to such a level there's no need to call any Vulkan functions
> inside the init path of the code. Handling shader descriptors is probably
> the bulk of the code, and despite the abstraction, it loses none of the
> features for describing shader IO.
> 
> In order to produce linkable shaders, it depends on the libshaderc
> library (and depends on the latest stable version of it). This allows
> for greater performance and flexibility than static built-in shaders
> and also eliminates the cumbersome process of interfacing with glslang
> to compile GLSL to SPIR-V.
> 
> It's based off of the common opencl and provides similar interfaces for
> filter pad init and config, with the addition that it also supports
> in-place filtering.
> 
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  configure|   10 +-
>  libavfilter/vulkan.c | 1186 ++
>  libavfilter/vulkan.h |  223 
>  3 files changed, 1418 insertions(+), 1 deletion(-)
>  create mode 100644 libavfilter/vulkan.c
>  create mode 100644 libavfilter/vulkan.h
> 
> diff --git a/configure b/configure
> index 5f4407b753..52c1e7a6e8 100755
> --- a/configure
> +++ b/configure
> @@ -252,6 +252,7 @@ External library support:
>--enable-librsvg enable SVG rasterization via librsvg [no]
>--enable-librubberband   enable rubberband needed for rubberband filter 
> [no]
>--enable-librtmp enable RTMP[E] support via librtmp [no]
> +  --enable-libshaderc  enable GLSL->SPIRV compilation via libshaderc [no]
>--enable-libshineenable fixed-point MP3 encoding via libshine [no]
>--enable-libsmbclientenable Samba protocol via libsmbclient [no]
>--enable-libsnappy   enable Snappy compression, needed for hap 
> encoding [no]
> @@ -1707,6 +1708,7 @@ EXTERNAL_LIBRARY_LIST="
>  libpulse
>  librsvg
>  librtmp
> +libshaderc
>  libshine
>  libsmbclient
>  libsnappy
> @@ -2225,6 +2227,7 @@ HAVE_LIST="
>  opencl_dxva2
>  opencl_vaapi_beignet
>  opencl_vaapi_intel_media
> +shaderc_opt_perf
>  vulkan_drm_mod
>  perl
>  pod2man
> @@ -3461,7 +3464,7 @@ avformat_deps="avcodec avutil"
>  avformat_suggest="libm network zlib"
>  avresample_deps="avutil"
>  avresample_suggest="libm"
> -avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 
> vaapi videotoolbox corefoundation corevideo coremedia bcrypt"
> +avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl vulkan 
> libshaderc user32 vaapi videotoolbox corefoundation corevideo coremedia 
> bcrypt"

libshaderc is not being used by avutil. You should add it to avfilter
instead.

>  postproc_deps="avutil gpl"
>  postproc_suggest="libm"
>  swresample_deps="avutil"
> @@ -6050,6 +6053,7 @@ enabled libpulse  && require_pkg_config 
> libpulse libpulse pulse/pulseaud
>  enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
> librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
>  enabled librtmp   && require_pkg_config librtmp librtmp 
> librtmp/rtmp.h RTMP_Socket
>  enabled librubberband && require_pkg_config librubberband "rubberband >= 
> 1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append 
> librubberband_extralibs "-lstdc++"
> +enabled libshaderc&& require libshaderc shaderc/shaderc.h 
> shaderc_compiler_initialize -lshaderc_shared
>  enabled libshine  && require_pkg_config libshine shine 
> shine/layer3.h shine_encode_buffer
>  enabled libsmbclient  && { check_pkg_config libsmbclient smbclient 
> libsmbclient.h smbc_init ||
> require libsmbclient libsmbclient.h smbc_init 
> -lsmbclient; }
> @@ -6355,6 +6359,10 @@ enabled crystalhd && check_lib crystalhd "stdint.h 
> libcrystalhd/libcrystalhd_if.
>  enabled vulkan &&
>  require_pkg_config vulkan "vulkan >= 1.1.73" "vulkan/vulkan.h" 
> vkCreateInstance
>  
> +if enabled_all vulkan libshaderc ; then
> +check_cc shaderc_opt_perf shaderc/shaderc.h "int t = 
> shaderc_optimization_level_performance"

You don't seem to be using shaderc_opt_perf anywhere, be it this patch
or the following ones.

> +fi
> +
>  if enabled_all vulkan libdrm ; then
>  check_cpp_condition vulkan_drm_mod vulkan/vulkan.h "defined 
> VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME"
>  fi
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3 7/8] lavfi: add a Vulkan scale filter

2018-05-21 Thread Rostislav Pehlivanov
Can convert to RGB using very fast fixed-function conversions.

Signed-off-by: Rostislav Pehlivanov 
---
 configure |   1 +
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/vf_scale_vulkan.c | 395 ++
 4 files changed, 398 insertions(+)
 create mode 100644 libavfilter/vf_scale_vulkan.c

diff --git a/configure b/configure
index eb81cc1ed5..3b29cd123a 100755
--- a/configure
+++ b/configure
@@ -3422,6 +3422,7 @@ zmq_filter_deps="libzmq"
 zoompan_filter_deps="swscale"
 zscale_filter_deps="libzimg const_nan"
 scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
+scale_vulkan_filter_deps="vulkan libshaderc"
 vpp_qsv_filter_deps="libmfx"
 vpp_qsv_filter_select="qsvvpp"
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 976955959c..e8c5438c78 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -313,6 +313,7 @@ OBJS-$(CONFIG_SCALE_CUDA_FILTER) += 
vf_scale_cuda.o vf_scale_cuda.pt
 OBJS-$(CONFIG_SCALE_NPP_FILTER)  += vf_scale_npp.o scale.o
 OBJS-$(CONFIG_SCALE_QSV_FILTER)  += vf_scale_qsv.o
 OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale.o 
vaapi_vpp.o
+OBJS-$(CONFIG_SCALE_VULKAN_FILTER)   += vf_scale_vulkan.o scale.o 
vulkan.o
 OBJS-$(CONFIG_SCALE2REF_FILTER)  += vf_scale.o scale.o
 OBJS-$(CONFIG_SELECT_FILTER) += f_select.o
 OBJS-$(CONFIG_SELECTIVECOLOR_FILTER) += vf_selectivecolor.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 7be81e4706..f9dce32f4d 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -304,6 +304,7 @@ extern AVFilter ff_vf_scale_cuda;
 extern AVFilter ff_vf_scale_npp;
 extern AVFilter ff_vf_scale_qsv;
 extern AVFilter ff_vf_scale_vaapi;
+extern AVFilter ff_vf_scale_vulkan;
 extern AVFilter ff_vf_scale2ref;
 extern AVFilter ff_vf_select;
 extern AVFilter ff_vf_selectivecolor;
diff --git a/libavfilter/vf_scale_vulkan.c b/libavfilter/vf_scale_vulkan.c
new file mode 100644
index 00..4a5647072d
--- /dev/null
+++ b/libavfilter/vf_scale_vulkan.c
@@ -0,0 +1,395 @@
+/*
+ * 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 "vulkan.h"
+#include "scale.h"
+#include "internal.h"
+
+enum ScalerFunc {
+F_BILINEAR = 0,
+F_NEAREST,
+
+F_NB,
+};
+
+typedef struct ScaleVulkanContext {
+VulkanFilterContext vkctx;
+
+int conv;
+int initialized;
+FFVkExecContext exec;
+const VulkanSampler *sampler;
+
+/* Shader updators, must be in the main filter struct */
+VkDescriptorImageInfo input_images[3];
+VkDescriptorImageInfo output_images[3];
+
+enum ScalerFunc scaler;
+char *output_format_string;
+char *w_expr;
+char *h_expr;
+} ScaleVulkanContext;
+
+static const char scale_bilinear[] = {
+C(0, void scale_bilinear(int idx, ivec2 pos)   
)
+C(0, { 
)
+C(1, const vec2 npos = (vec2(pos) + 0.5f) / 
imageSize(output_img[idx]);)
+C(1, imageStore(output_img[idx], pos, texture(input_img[idx], npos));  
)
+C(0, } 
)
+};
+
+static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
+{
+int err;
+VkFilter sampler_mode;
+ScaleVulkanContext *s = ctx->priv;
+
+switch (s->scaler) {
+case F_NEAREST:
+sampler_mode = VK_FILTER_NEAREST;
+break;
+case F_BILINEAR:
+sampler_mode = VK_FILTER_LINEAR;
+break;
+};
+
+/* Create a sampler */
+s->sampler = ff_vk_init_sampler(ctx, s->conv ? in : NULL, 0, sampler_mode);
+if (!s->sampler)
+return AVERROR_EXTERNAL;
+
+{ /* Create the shader */
+SPIRVShader *shd = ff_vk_init_shader(ctx, "scale_compute",
+ VK_SHADER_STAGE_COMPUTE_BIT);
+ff_vk_set_compute_shader_sizes(ctx, shd, (int [3]){ 16, 16, 1 });
+
+VulkanDescriptorSetBinding desc_i[2] = {
+{
+.name   = "input_img",
+.type   = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
+

[FFmpeg-devel] [PATCH v3 8/8] lavfi: add a Vulkan overlay filter

2018-05-21 Thread Rostislav Pehlivanov
Could be done in-plane with the main image but framesync segfaults.

Signed-off-by: Rostislav Pehlivanov 
---
 configure   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_overlay_vulkan.c | 461 
 4 files changed, 464 insertions(+)
 create mode 100644 libavfilter/vf_overlay_vulkan.c

diff --git a/configure b/configure
index 3b29cd123a..8806a8 100755
--- a/configure
+++ b/configure
@@ -3365,6 +3365,7 @@ ocr_filter_deps="libtesseract"
 ocv_filter_deps="libopencv"
 openclsrc_filter_deps="opencl"
 overlay_opencl_filter_deps="opencl"
+overlay_vulkan_filter_deps="vulkan libshaderc"
 overlay_qsv_filter_deps="libmfx"
 overlay_qsv_filter_select="qsvvpp"
 owdenoise_filter_deps="gpl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index e8c5438c78..bfbd679a44 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -276,6 +276,7 @@ OBJS-$(CONFIG_OSCILLOSCOPE_FILTER)   += 
vf_datascope.o
 OBJS-$(CONFIG_OVERLAY_FILTER)+= vf_overlay.o framesync.o
 OBJS-$(CONFIG_OVERLAY_OPENCL_FILTER) += vf_overlay_opencl.o opencl.o \
 opencl/overlay.o framesync.o
+OBJS-$(CONFIG_OVERLAY_VULKAN_FILTER) += vf_overlay_vulkan.o
 OBJS-$(CONFIG_OVERLAY_QSV_FILTER)+= vf_overlay_qsv.o framesync.o
 OBJS-$(CONFIG_OWDENOISE_FILTER)  += vf_owdenoise.o
 OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index f9dce32f4d..85383f234a 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -267,6 +267,7 @@ extern AVFilter ff_vf_ocv;
 extern AVFilter ff_vf_oscilloscope;
 extern AVFilter ff_vf_overlay;
 extern AVFilter ff_vf_overlay_opencl;
+extern AVFilter ff_vf_overlay_vulkan;
 extern AVFilter ff_vf_overlay_qsv;
 extern AVFilter ff_vf_owdenoise;
 extern AVFilter ff_vf_pad;
diff --git a/libavfilter/vf_overlay_vulkan.c b/libavfilter/vf_overlay_vulkan.c
new file mode 100644
index 00..a7d8cc3cf2
--- /dev/null
+++ b/libavfilter/vf_overlay_vulkan.c
@@ -0,0 +1,461 @@
+/*
+ * 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 "vulkan.h"
+#include "internal.h"
+#include "framesync.h"
+
+typedef struct OverlayVulkanContext {
+VulkanFilterContext vkctx;
+
+int initialized;
+FFVkExecContext exec;
+FFFrameSync fs;
+FFVkBuffer params_buf;
+
+/* Shader updators, must be in the main filter struct */
+VkDescriptorImageInfo main_images[3];
+VkDescriptorImageInfo overlay_images[3];
+VkDescriptorImageInfo output_images[3];
+VkDescriptorBufferInfo params_desc;
+
+int overlay_x;
+int overlay_y;
+} OverlayVulkanContext;
+
+static const char overlay_noalpha[] = {
+C(0, void overlay_noalpha(int i, ivec2 pos)
)
+C(0, { 
)
+C(1, ivec2 overlay_size = imageSize(overlay_img[i]);   
)
+C(1, if ((o_offset[i].x <= pos.x) && (o_offset[i].y <= pos.y) &&
+ (pos.x < (o_offset[i].x + overlay_size.x)) &&
+ (pos.y < (o_offset[i].y + overlay_size.y))) { 
)
+C(2, vec4 res = imageLoad(overlay_img[i], pos - o_offset[i]);  
)
+C(2, imageStore(output_img[i], pos, res);  
)
+C(1, } else {  
)
+C(2, vec4 res = imageLoad(main_img[i], pos);   
)
+C(2, imageStore(output_img[i], pos, res);  
)
+C(1, } 
)
+C(0, } 
)
+};
+
+static av_cold int init_filter(AVFilterContext *ctx)
+{
+int err;
+OverlayVulkanContext *s = ctx->priv;
+
+{ /* Create the shader */
+const int planes = av_pix_fmt_count_planes(s->vkctx.output_format);
+
+SPIRVShader *shd = ff_vk_init_shader(ctx, "overlay_compute",
+ VK_SHADER_STAGE_COMP

[FFmpeg-devel] [PATCH v3 4/8] lavfi: add common Vulkan filtering code

2018-05-21 Thread Rostislav Pehlivanov
This commit adds a common code for use in Vulkan filters. It attempts
to ease the burden of writing Vulkan image filtering to a minimum,
which is pretty much a requirement considering how verbose the API is.

It supports both compute and graphic pipelines and manages to abstract
the API to such a level there's no need to call any Vulkan functions
inside the init path of the code. Handling shader descriptors is probably
the bulk of the code, and despite the abstraction, it loses none of the
features for describing shader IO.

In order to produce linkable shaders, it depends on the libshaderc
library (and depends on the latest stable version of it). This allows
for greater performance and flexibility than static built-in shaders
and also eliminates the cumbersome process of interfacing with glslang
to compile GLSL to SPIR-V.

It's based off of the common opencl and provides similar interfaces for
filter pad init and config, with the addition that it also supports
in-place filtering.

Signed-off-by: Rostislav Pehlivanov 
---
 configure|   10 +-
 libavfilter/vulkan.c | 1186 ++
 libavfilter/vulkan.h |  223 
 3 files changed, 1418 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/vulkan.c
 create mode 100644 libavfilter/vulkan.h

diff --git a/configure b/configure
index 5f4407b753..52c1e7a6e8 100755
--- a/configure
+++ b/configure
@@ -252,6 +252,7 @@ External library support:
   --enable-librsvg enable SVG rasterization via librsvg [no]
   --enable-librubberband   enable rubberband needed for rubberband filter [no]
   --enable-librtmp enable RTMP[E] support via librtmp [no]
+  --enable-libshaderc  enable GLSL->SPIRV compilation via libshaderc [no]
   --enable-libshineenable fixed-point MP3 encoding via libshine [no]
   --enable-libsmbclientenable Samba protocol via libsmbclient [no]
   --enable-libsnappy   enable Snappy compression, needed for hap encoding 
[no]
@@ -1707,6 +1708,7 @@ EXTERNAL_LIBRARY_LIST="
 libpulse
 librsvg
 librtmp
+libshaderc
 libshine
 libsmbclient
 libsnappy
@@ -2225,6 +2227,7 @@ HAVE_LIST="
 opencl_dxva2
 opencl_vaapi_beignet
 opencl_vaapi_intel_media
+shaderc_opt_perf
 vulkan_drm_mod
 perl
 pod2man
@@ -3461,7 +3464,7 @@ avformat_deps="avcodec avutil"
 avformat_suggest="libm network zlib"
 avresample_deps="avutil"
 avresample_suggest="libm"
-avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl user32 vaapi 
videotoolbox corefoundation corevideo coremedia bcrypt"
+avutil_suggest="clock_gettime ffnvcodec libm libdrm libmfx opencl vulkan 
libshaderc user32 vaapi videotoolbox corefoundation corevideo coremedia bcrypt"
 postproc_deps="avutil gpl"
 postproc_suggest="libm"
 swresample_deps="avutil"
@@ -6050,6 +6053,7 @@ enabled libpulse  && require_pkg_config libpulse 
libpulse pulse/pulseaud
 enabled librsvg   && require_pkg_config librsvg librsvg-2.0 
librsvg-2.0/librsvg/rsvg.h rsvg_handle_render_cairo
 enabled librtmp   && require_pkg_config librtmp librtmp librtmp/rtmp.h 
RTMP_Socket
 enabled librubberband && require_pkg_config librubberband "rubberband >= 
1.8.1" rubberband/rubberband-c.h rubberband_new -lstdc++ && append 
librubberband_extralibs "-lstdc++"
+enabled libshaderc&& require libshaderc shaderc/shaderc.h 
shaderc_compiler_initialize -lshaderc_shared
 enabled libshine  && require_pkg_config libshine shine shine/layer3.h 
shine_encode_buffer
 enabled libsmbclient  && { check_pkg_config libsmbclient smbclient 
libsmbclient.h smbc_init ||
require libsmbclient libsmbclient.h smbc_init 
-lsmbclient; }
@@ -6355,6 +6359,10 @@ enabled crystalhd && check_lib crystalhd "stdint.h 
libcrystalhd/libcrystalhd_if.
 enabled vulkan &&
 require_pkg_config vulkan "vulkan >= 1.1.73" "vulkan/vulkan.h" 
vkCreateInstance
 
+if enabled_all vulkan libshaderc ; then
+check_cc shaderc_opt_perf shaderc/shaderc.h "int t = 
shaderc_optimization_level_performance"
+fi
+
 if enabled_all vulkan libdrm ; then
 check_cpp_condition vulkan_drm_mod vulkan/vulkan.h "defined 
VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME"
 fi
diff --git a/libavfilter/vulkan.c b/libavfilter/vulkan.c
new file mode 100644
index 00..1df3b7a1f2
--- /dev/null
+++ b/libavfilter/vulkan.c
@@ -0,0 +1,1186 @@
+/*
+ * Vulkan utilities
+ * Copyright (c) 2018 Rostislav Pehlivanov 
+ *
+ * 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
+ *

[FFmpeg-devel] [PATCH v3 6/8] lavfi: add a Vulkan chromatic aberration filter

2018-05-21 Thread Rostislav Pehlivanov
It tries to do something similar to it with YUV images, but RGB images
are done properly.

Signed-off-by: Rostislav Pehlivanov 
---
 configure   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_chromaticaberration_vulkan.c | 342 
 4 files changed, 345 insertions(+)
 create mode 100644 libavfilter/vf_chromaticaberration_vulkan.c

diff --git a/configure b/configure
index c34a48b2bc..eb81cc1ed5 100755
--- a/configure
+++ b/configure
@@ -3313,6 +3313,7 @@ azmq_filter_deps="libzmq"
 blackframe_filter_deps="gpl"
 boxblur_filter_deps="gpl"
 bs2b_filter_deps="libbs2b"
+chromaticaberration_vulkan_filter_deps="vulkan libshaderc"
 colormatrix_filter_deps="gpl"
 convolution_opencl_filter_deps="opencl"
 convolve_filter_deps="avcodec"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index fd8cf8c13c..976955959c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -156,6 +156,7 @@ OBJS-$(CONFIG_BLEND_FILTER)  += vf_blend.o 
framesync.o
 OBJS-$(CONFIG_BOXBLUR_FILTER)+= vf_boxblur.o
 OBJS-$(CONFIG_BWDIF_FILTER)  += vf_bwdif.o
 OBJS-$(CONFIG_CHROMAKEY_FILTER)  += vf_chromakey.o
+OBJS-$(CONFIG_CHROMATICABERRATION_VULKAN_FILTER) += 
vf_chromaticaberration_vulkan.o vulkan.o
 OBJS-$(CONFIG_CIESCOPE_FILTER)   += vf_ciescope.o
 OBJS-$(CONFIG_CODECVIEW_FILTER)  += vf_codecview.o
 OBJS-$(CONFIG_COLORBALANCE_FILTER)   += vf_colorbalance.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index c53cb2154e..7be81e4706 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -149,6 +149,7 @@ extern AVFilter ff_vf_blend;
 extern AVFilter ff_vf_boxblur;
 extern AVFilter ff_vf_bwdif;
 extern AVFilter ff_vf_chromakey;
+extern AVFilter ff_vf_chromaticaberration_vulkan;
 extern AVFilter ff_vf_ciescope;
 extern AVFilter ff_vf_codecview;
 extern AVFilter ff_vf_colorbalance;
diff --git a/libavfilter/vf_chromaticaberration_vulkan.c 
b/libavfilter/vf_chromaticaberration_vulkan.c
new file mode 100644
index 00..1d1aeb95a0
--- /dev/null
+++ b/libavfilter/vf_chromaticaberration_vulkan.c
@@ -0,0 +1,342 @@
+/*
+ * 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 "vulkan.h"
+#include "internal.h"
+
+typedef struct ChromaticAberrationVulkanContext {
+VulkanFilterContext vkctx;
+
+int initialized;
+FFVkExecContext exec;
+
+/* Shader updators, must be in the main filter struct */
+VkDescriptorImageInfo input_images[3];
+VkDescriptorImageInfo output_images[3];
+
+float dist_x;
+float dist_y;
+} ChromaticAberrationVulkanContext;
+
+static const char distort_chroma_kernel[] = {
+C(0, void distort_rgb(ivec2 size, ivec2 pos)   
)
+C(0, { 
)
+C(1, const vec2 p = ((vec2(pos)/vec2(size)) - 0.5f)*2.0f;  
)
+C(1, const vec2 o = p * (FILTER_DIST - 1.0f);  
)
+C(0,   
)
+C(1, vec4 res; 
)
+C(1, res.r = texture(input_img[0], ((p - o)/2.0f) + 0.5f).r;   
)
+C(1, res.g = texture(input_img[0], ((p)/2.0f) + 0.5f).g;   
)
+C(1, res.b = texture(input_img[0], ((p + o)/2.0f) + 0.5f).b;   
)
+C(1, res.a = texture(input_img[0], ((p)/2.0f) + 0.5f).a;   
)
+C(1, imageStore(output_img[0], pos, res);  
)
+C(0, } 
)
+C(0,   
)
+C(0, void distort_chroma(int idx, ivec2 size, ivec2 pos)   
)
+C(0, { 
)
+C(1, vec2 p = ((vec2(pos)/vec2(size)) - 0.5f)*2.0f;
)
+C(1, float d = sqrt(p.x*p.x + p.y*p.y);
)
+C(1, p *= d / (d*FILTER_DIST);   

[FFmpeg-devel] [PATCH v3 5/8] lavfi: add a Vulkan avgblur filter

2018-05-21 Thread Rostislav Pehlivanov
Signed-off-by: Rostislav Pehlivanov 
---
 configure   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_avgblur_vulkan.c | 343 
 4 files changed, 346 insertions(+)
 create mode 100644 libavfilter/vf_avgblur_vulkan.c

diff --git a/configure b/configure
index 52c1e7a6e8..c34a48b2bc 100755
--- a/configure
+++ b/configure
@@ -3308,6 +3308,7 @@ ass_filter_deps="libass"
 atempo_filter_deps="avcodec"
 atempo_filter_select="rdft"
 avgblur_opencl_filter_deps="opencl"
+avgblur_vulkan_filter_deps="vulkan libshaderc"
 azmq_filter_deps="libzmq"
 blackframe_filter_deps="gpl"
 boxblur_filter_deps="gpl"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index c68ef05fdc..fd8cf8c13c 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -146,6 +146,7 @@ OBJS-$(CONFIG_ATADENOISE_FILTER) += 
vf_atadenoise.o
 OBJS-$(CONFIG_AVGBLUR_FILTER)+= vf_avgblur.o
 OBJS-$(CONFIG_AVGBLUR_OPENCL_FILTER) += vf_avgblur_opencl.o opencl.o \
 opencl/avgblur.o
+OBJS-$(CONFIG_AVGBLUR_VULKAN_FILTER) += vf_avgblur_vulkan.o vulkan.o
 OBJS-$(CONFIG_BBOX_FILTER)   += bbox.o vf_bbox.o
 OBJS-$(CONFIG_BENCH_FILTER)  += f_bench.o
 OBJS-$(CONFIG_BITPLANENOISE_FILTER)  += vf_bitplanenoise.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index b44093d21b..c53cb2154e 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -139,6 +139,7 @@ extern AVFilter ff_vf_ass;
 extern AVFilter ff_vf_atadenoise;
 extern AVFilter ff_vf_avgblur;
 extern AVFilter ff_vf_avgblur_opencl;
+extern AVFilter ff_vf_avgblur_vulkan;
 extern AVFilter ff_vf_bbox;
 extern AVFilter ff_vf_bench;
 extern AVFilter ff_vf_bitplanenoise;
diff --git a/libavfilter/vf_avgblur_vulkan.c b/libavfilter/vf_avgblur_vulkan.c
new file mode 100644
index 00..5b89ae0718
--- /dev/null
+++ b/libavfilter/vf_avgblur_vulkan.c
@@ -0,0 +1,343 @@
+/*
+ * 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 "vulkan.h"
+#include "internal.h"
+
+typedef struct AvgBlurVulkanContext {
+VulkanFilterContext vkctx;
+
+int initialized;
+FFVkExecContext exec;
+
+/* Shader updators, must be in the main filter struct */
+VkDescriptorImageInfo input_images[3];
+VkDescriptorImageInfo output_images[3];
+
+int size_x;
+int size_y;
+int planes;
+} AvgBlurVulkanContext;
+
+static const char blur_kernel[] = {
+C(0, #define CACHE_SIZE (ivec2(gl_WorkGroupSize) + FILTER_RADIUS*2)
)
+C(0, shared vec4 cache[AREA(CACHE_SIZE)];  
)
+C(0,   
)
+C(0, void blur_kernel(int idx, ivec2 pos)  
)
+C(0, { 
)
+C(1, ivec2 d;  
)
+C(1, const ivec2 s = CACHE_SIZE;   
)
+C(1, const ivec2 w = ivec2(gl_WorkGroupSize);  
)
+C(1, const ivec2 l = ivec2(gl_LocalInvocationID.xy);   
)
+C(1,   
)
+C(1, for (d.y = l.y; d.y < s.y; d.y += w.y) {  
)
+C(2, for (d.x = l.x; d.x < s.x; d.x += w.x) {  
)
+C(3, const ivec2 np = pos + d - l - FILTER_RADIUS; 
)
+C(3, cache[d.y*s.x + d.x] = imageLoad(input_img[idx], np); 
)
+C(2, } 
)
+C(1, } 
)
+C(0,   
)
+C(1, barrier();
)
+C(0,   
)
+C(1, vec4 avg = vec4(0.0f);
)
+C(1, ivec2 start 

[FFmpeg-devel] [PATCH v3 1/8] hwcontext_internal: add ff_hwframe_map_replace

2018-05-21 Thread Rostislav Pehlivanov
Used to fix unmapping when no direct interop exists between APIs.

Signed-off-by: Rostislav Pehlivanov 
---
 libavutil/hwcontext.c  | 7 +++
 libavutil/hwcontext_internal.h | 5 +
 2 files changed, 12 insertions(+)

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 745016ed7e..f1e404ab20 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -870,3 +870,10 @@ fail:
 av_buffer_unref(&dst_ref);
 return ret;
 }
+
+int ff_hwframe_map_replace(AVFrame *dst, const AVFrame *src)
+{
+HWMapDescriptor *hwmap = (HWMapDescriptor*)dst->buf[0]->data;
+av_frame_unref(hwmap->source);
+return av_frame_ref(hwmap->source, src);
+}
diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h
index 332062ddaa..77dc47ddd6 100644
--- a/libavutil/hwcontext_internal.h
+++ b/libavutil/hwcontext_internal.h
@@ -156,6 +156,11 @@ int ff_hwframe_map_create(AVBufferRef *hwframe_ref,
 HWMapDescriptor *hwmap),
   void *priv);
 
+/**
+ * Replace the current hwmap of dst with the one from src, used for indirect
+ * mappings like VAAPI->(DRM)->OpenCL/Vulkan where a direct interop is missing
+ */
+int ff_hwframe_map_replace(AVFrame *dst, const AVFrame *src);
 
 extern const HWContextType ff_hwcontext_type_cuda;
 extern const HWContextType ff_hwcontext_type_d3d11va;
-- 
2.17.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3 2/8] hwcontext_opencl: use ff_hwframe_map_replace()

2018-05-21 Thread Rostislav Pehlivanov
Signed-off-by: Rostislav Pehlivanov 
---
 libavutil/hwcontext_opencl.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index 43b5c5ae0c..1d18da37bf 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -2171,10 +2171,7 @@ static int opencl_map_from_vaapi(AVHWFramesContext 
*dst_fc,
 if (err < 0)
 goto fail;
 
-// Adjust the map descriptor so that unmap works correctly.
-hwmap = (HWMapDescriptor*)dst->buf[0]->data;
-av_frame_unref(hwmap->source);
-err = av_frame_ref(hwmap->source, src);
+err = ff_hwframe_map_replace(dst, src);
 
 fail:
 av_frame_free(&tmp);
-- 
2.17.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3 3/8] lavu: add a Vulkan hwcontext

2018-05-21 Thread Rostislav Pehlivanov
This commit adds a Vulkan hwcontext, currently capable of mapping DRM and
VAAPI frames but additional functionality can be added later to support
importing of D3D11 surfaces as well as exporting to various other APIs.

This context requires the newest stable version of the Vulkan API,
and once the new extension for DRM surfaces makes it in will also require
it (in order to properly and fully import them).

It makes use of every part of the Vulkan spec in order to ensure fastest
possible uploading, downloading and mapping of frames. On AMD, it will
also make use of mapping host memory frames in order to upload
very efficiently and with minimal CPU to hardware.

To be useful for non-RGB images an implementation with the YUV images
extension is needed. All current implementations support that with the
exception of AMD, though support is coming soon for Mesa.

Signed-off-by: Rostislav Pehlivanov 
---
 configure  |   10 +
 doc/APIchanges |3 +
 libavutil/Makefile |3 +
 libavutil/hwcontext.c  |4 +
 libavutil/hwcontext.h  |1 +
 libavutil/hwcontext_internal.h |1 +
 libavutil/hwcontext_vulkan.c   | 2013 
 libavutil/hwcontext_vulkan.h   |  133 +++
 libavutil/pixdesc.c|4 +
 libavutil/pixfmt.h |4 +
 libavutil/version.h|4 +-
 11 files changed, 2178 insertions(+), 2 deletions(-)
 create mode 100644 libavutil/hwcontext_vulkan.c
 create mode 100644 libavutil/hwcontext_vulkan.h

diff --git a/configure b/configure
index 09ff0c55e2..5f4407b753 100755
--- a/configure
+++ b/configure
@@ -300,6 +300,7 @@ External library support:
   --enable-opengl  enable OpenGL rendering [no]
   --enable-openssl enable openssl, needed for https support
if gnutls, libtls or mbedtls is not used [no]
+  --enable-vulkan  enable Vulkan code [no]
   --disable-sndio  disable sndio support [autodetect]
   --disable-schannel   disable SChannel SSP, needed for TLS support on
Windows if openssl and gnutls are not used 
[autodetect]
@@ -1767,6 +1768,7 @@ HWACCEL_LIBRARY_LIST="
 mmal
 omx
 opencl
+vulkan
 "
 
 DOCUMENT_LIST="
@@ -2223,6 +2225,7 @@ HAVE_LIST="
 opencl_dxva2
 opencl_vaapi_beignet
 opencl_vaapi_intel_media
+vulkan_drm_mod
 perl
 pod2man
 texi2html
@@ -6349,6 +6352,13 @@ enabled vdpau &&
 
 enabled crystalhd && check_lib crystalhd "stdint.h 
libcrystalhd/libcrystalhd_if.h" DtsCrystalHDVersion -lcrystalhd
 
+enabled vulkan &&
+require_pkg_config vulkan "vulkan >= 1.1.73" "vulkan/vulkan.h" 
vkCreateInstance
+
+if enabled_all vulkan libdrm ; then
+check_cpp_condition vulkan_drm_mod vulkan/vulkan.h "defined 
VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME"
+fi
+
 if enabled x86; then
 case $target_os in
 mingw32*|mingw64*|win32|win64|linux|cygwin*)
diff --git a/doc/APIchanges b/doc/APIchanges
index efe15ba4e0..1b37f58ca7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2018-04-xx - xx - lavu 56.19.100 - hwcontext.h
+  Add AV_HWDEVICE_TYPE_VULKAN and implementation.
+
 2018-05-xx - xx - lavf 58.15.100 - avformat.h
   Add pmt_version field to AVProgram
 
diff --git a/libavutil/Makefile b/libavutil/Makefile
index d0632f16a6..9fb32bc5e2 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -42,6 +42,7 @@ HEADERS = adler32.h   
  \
   hwcontext_vaapi.h \
   hwcontext_videotoolbox.h  \
   hwcontext_vdpau.h \
+  hwcontext_vulkan.h\
   imgutils.h\
   intfloat.h\
   intreadwrite.h\
@@ -168,6 +169,7 @@ OBJS-$(CONFIG_QSV)  += hwcontext_qsv.o
 OBJS-$(CONFIG_VAAPI)+= hwcontext_vaapi.o
 OBJS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.o
 OBJS-$(CONFIG_VDPAU)+= hwcontext_vdpau.o
+OBJS-$(CONFIG_VULKAN)   += hwcontext_vulkan.o
 
 OBJS += $(COMPAT_OBJS:%=../compat/%)
 
@@ -183,6 +185,7 @@ SKIPHEADERS-$(CONFIG_OPENCL)   += hwcontext_opencl.h
 SKIPHEADERS-$(CONFIG_VAAPI)+= hwcontext_vaapi.h
 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += hwcontext_videotoolbox.h
 SKIPHEADERS-$(CONFIG_VDPAU)+= hwcontext_vdpau.h
+SKIPHEADERS-$(CONFIG_VULKAN)   += hwcontext_vulkan.h
 
 TESTPROGS = adler32 \
 aes

[FFmpeg-devel] [PATCH v3 0/8] Vulkan hwcontext and filtering

2018-05-21 Thread Rostislav Pehlivanov
This is pretty much finished.

Rostislav Pehlivanov (8):
  hwcontext_internal: add ff_hwframe_map_replace
  hwcontext_opencl: use ff_hwframe_map_replace()
  lavu: add a Vulkan hwcontext
  lavfi: add common Vulkan filtering code
  lavfi: add a Vulkan avgblur filter
  lavfi: add a Vulkan chromatic aberration filter
  lavfi: add a Vulkan scale filter
  lavfi: add a Vulkan overlay filter

 configure   |   24 +-
 doc/APIchanges  |3 +
 libavfilter/Makefile|4 +
 libavfilter/allfilters.c|4 +
 libavfilter/vf_avgblur_vulkan.c |  343 
 libavfilter/vf_chromaticaberration_vulkan.c |  342 
 libavfilter/vf_overlay_vulkan.c |  461 +
 libavfilter/vf_scale_vulkan.c   |  395 
 libavfilter/vulkan.c| 1186 +++
 libavfilter/vulkan.h|  223 ++
 libavutil/Makefile  |3 +
 libavutil/hwcontext.c   |   11 +
 libavutil/hwcontext.h   |1 +
 libavutil/hwcontext_internal.h  |6 +
 libavutil/hwcontext_opencl.c|5 +-
 libavutil/hwcontext_vulkan.c| 2013 +++
 libavutil/hwcontext_vulkan.h|  133 ++
 libavutil/pixdesc.c |4 +
 libavutil/pixfmt.h  |4 +
 libavutil/version.h |4 +-
 20 files changed, 5162 insertions(+), 7 deletions(-)
 create mode 100644 libavfilter/vf_avgblur_vulkan.c
 create mode 100644 libavfilter/vf_chromaticaberration_vulkan.c
 create mode 100644 libavfilter/vf_overlay_vulkan.c
 create mode 100644 libavfilter/vf_scale_vulkan.c
 create mode 100644 libavfilter/vulkan.c
 create mode 100644 libavfilter/vulkan.h
 create mode 100644 libavutil/hwcontext_vulkan.c
 create mode 100644 libavutil/hwcontext_vulkan.h

-- 
2.17.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.

2018-05-21 Thread Niklas Haas
On Tue, 22 May 2018 01:18:30 +0100, Mark Thompson  wrote:
> On 21/05/18 07:50, Ruiling Song wrote:
> > This filter does HDR(HDR10/HLG) to SDR conversion with tone-mapping.
> > 
> > An example command to use this filter with vaapi codecs:
> > FFMPEG -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device \
> > opencl=ocl@va -hwaccel vaapi -hwaccel_device va -hwaccel_output_format \
> > vaapi -i INPUT -filter_hw_device ocl -filter_complex \
> > '[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1]; \
> > [x1]hwmap=derive_device=vaapi:reverse=1' -c:v hevc_vaapi -profile 2 OUTPUT
> > 
> > Signed-off-by: Ruiling Song 
> > ---
> 
> I assume you're testing with Beignet for this sort of mapping to work?  I 
> tried it with Beignet on Coffee Lake with 10-bit videos and it looks 
> sensible, though it is rather hard to tell whether it is in some sense 
> "correct".

It's also rather hard to define whether it is in some sense "correct".
The methodology employed here is generally based on ITU-R
recommendations, however the ITU-R advises multiple possible ways of
doing tone-mapping. They also highlight their own curve function, which
we don't use (for performance/simplicity reasons - iirc I gave it a try
and the result was not visually dissimilar enough from the hable
function, but my memory could be wrong). There's nothing resembling an
official "standard" way to tone-map defined by the ITU-R.

This algorithm is also generally based on the results obtained from the
"official" ACES implementation of HDR->SDR tone mapping (obtainable
here: https://github.com/ampas/aces-dev), with the key difference that
we do chroma-invariant tone mapping whereas hollywood tends to use
channel-independent tone mapping. I think the latter distorts the colors
too much for taste and generally results in a worse looking image. The
only important bit to make chroma-invariant tone mapping work well,
however, is the need for a good desaturation algorithm. This one is
based on original research and experimentation. The desaturation
strength with a parameter of 1.0 is comparable to the one achieved by
the ACES algorithm, although I pick a lower strength by default (0.5),
because I found it too damaging for some types of sources (particularly
bright skies) as a result of the chroma-invariant nature.

In addition to the desaturation step, the other key innovation which I
cannot find mentioned in ITU-R literature is the importance of adjusting
the overall average brightness before tone mapping. I suspect the reason
this isn't considered by the ITU-R is because the ITU-R assumes that HDR
sources actually follow their standards, which in practice none seem to
do. In theory, HDR material isn't supposed to have a significantly
higher average brightness than SDR material. Apart from the addition of
isolated super-highlights, nothing should have changed about the image
appearance. In practice, HDR directors like to point their expensive
cameras at very bright objects (e.g. the sun) and blind viewers' eyes by
failing to adjust the brightness during the mastering step. Our
algorithm compensates for this by essentially "correcting" the bad
mastering in real-time. [1] Of course, the result here is not as good as
doing it ahead of time by a human, but unfortunately we don't have a say
in this matter.

As long as the implementation is correct, I'd be confident in assuming
that this produces pleasurable results for all the sources I've thrown
at it, often even exceeding in quality the "official" SDR-mapped blu-ray
versions of the same sources on the same scenes. (Partially due to the
preserved higher color gamut)

In order to ascertain whether or not the implementation is correct, you
could compare it to results obtained by latest `mpv` (might need git
master) or `libplacebo`, both of which implement the same algorithm.


[1] The algorithm I use in mpv and libplacebo does this with one frame
of latency, because I don't want to round-trip through an intermediate
buffer in my processing chain, and there's no other way to communicate
back the measured frame statistics to the rest of the kernels in
OpenGL/Vulkan land. I do this because of my realtime requirements as
well as the structure of my processing chain.

Since you are implementing an offline filter and neither of these
restrictions apply to you, I would recommend changing the implementation
to separate the peak measurement step from the tone mapping step, so
that the former completes first and then the second runs from scratch
and can use the results computed by the former in the same frame.

If you don't do this, you run the risk of failing to tone map single
frame data (e.g. screenshots), because no data about the previous frame
is available at the time.

> > +// detect peak/average signal of a frame, the algorithm was ported from:
> > +// libplacebo (https://github.com/haasn/libplacebo)
> > +struct detection_result
> > +detect_peak_avg(global uint *util_buf, __local uint *sum_wg,
> > + 

Re: [FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.

2018-05-21 Thread Song, Ruiling


> -Original Message-
> From: myp...@gmail.com [mailto:myp...@gmail.com]
> Sent: Monday, May 21, 2018 3:23 PM
> To: FFmpeg development discussions and patches 
> Cc: s...@jkqxz.net; ffm...@haasn.xyz; Song, Ruiling 
> Subject: Re: [FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.
> 
> 2018-05-21 14:50 GMT+08:00 Ruiling Song :
> > This filter does HDR(HDR10/HLG) to SDR conversion with tone-mapping.
> >
> > An example command to use this filter with vaapi codecs:
> > FFMPEG -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device \
> > opencl=ocl@va -hwaccel vaapi -hwaccel_device va -hwaccel_output_format \
> > vaapi -i INPUT -filter_hw_device ocl -filter_complex \
> > '[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1]; \
> > [x1]hwmap=derive_device=vaapi:reverse=1' -c:v hevc_vaapi -profile 2
> OUTPUT
> >
> > Signed-off-by: Ruiling Song 
> > ---
> >  configure  |   1 +
> >  libavfilter/Makefile   |   2 +
> >  libavfilter/allfilters.c   |   1 +
> >  libavfilter/colorspace_basic.c |  89 ++
> >  libavfilter/colorspace_basic.h |  40 +++
> >  libavfilter/opencl/colorspace_basic.cl | 179 +++
> >  libavfilter/opencl/tonemap.cl  | 258 +++
> >  libavfilter/opencl_source.h|   2 +
> >  libavfilter/vf_tonemap_opencl.c| 560
> +
> >  9 files changed, 1132 insertions(+)
> >  create mode 100644 libavfilter/colorspace_basic.c
> >  create mode 100644 libavfilter/colorspace_basic.h
> >  create mode 100644 libavfilter/opencl/colorspace_basic.cl
> >  create mode 100644 libavfilter/opencl/tonemap.cl
> >  create mode 100644 libavfilter/vf_tonemap_opencl.c
> >
> > diff --git a/libavfilter/opencl/colorspace_basic.cl
> b/libavfilter/opencl/colorspace_basic.cl
> > new file mode 100644
> > index 000..ffd98c2
> > --- /dev/null
> > +++ b/libavfilter/opencl/colorspace_basic.cl
> > @@ -0,0 +1,179 @@
> > +/*
> > + * 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
> > + */
> > +
> > +#define ST2084_MAX_LUMINANCE 1.0f
> > +#define REFERENCE_WHITE 100.0f
> > +constant const float ST2084_M1 = 0.1593017578125f;
> > +constant const float ST2084_M2 = 78.84375f;
> > +constant const float ST2084_C1 = 0.8359375f;
> > +constant const float ST2084_C2 = 18.8515625f;
> > +constant const float ST2084_C3 = 18.6875f;
> > +
> > +// TODO Move these colorspace matrix to .cpp files
> what's .cpp files? is it porting from some cpp file?
Sorry, this is a typo. It should be '.c'. It's better to move this matrix 
generation into .c file, so that it is easy to support more color spaces.
But currently, it is not so urgent as the tonemap only cares about bt709/bt2020 
now.

Thanks!
Ruiling

> > +__constant float yuv2rgb_bt2020[] = {
> > +1.0f, 0.0f, 1.4746f,
> > +1.0f, -0.16455f, -0.57135f,
> > +1.0f, 1.8814f, 0.0f
> > +};
> > +
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> 
> 
> --
> ===
> Pixelworks
> Room 301-303 No. 88,Lane 887 Zuchongzhi Road, Zhangjiang Hi-tech Park,
> Shanghai 201203, China
> Best Regards,
> Jun zhao/赵军
> +++
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.

2018-05-21 Thread Mark Thompson
On 21/05/18 07:50, Ruiling Song wrote:
> This filter does HDR(HDR10/HLG) to SDR conversion with tone-mapping.
> 
> An example command to use this filter with vaapi codecs:
> FFMPEG -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device \
> opencl=ocl@va -hwaccel vaapi -hwaccel_device va -hwaccel_output_format \
> vaapi -i INPUT -filter_hw_device ocl -filter_complex \
> '[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1]; \
> [x1]hwmap=derive_device=vaapi:reverse=1' -c:v hevc_vaapi -profile 2 OUTPUT
> 
> Signed-off-by: Ruiling Song 
> ---

I assume you're testing with Beignet for this sort of mapping to work?  I tried 
it with Beignet on Coffee Lake with 10-bit videos and it looks sensible, though 
it is rather hard to tell whether it is in some sense "correct".

Given a non-P010 input video it fails with build errors when compling the 
kernels:

[Parsed_tonemap_opencl_1 @ 0x55b700e51540] Failed to build program: -11.
[Parsed_tonemap_opencl_1 @ 0x55b700e51540] Build log:
/home/mrt/video/ffmpeg/opencl/libavfilter/opencl/colorspace_basic.cl:125:19: 
error: use of undeclared identifier 'null'; did you mean 'all'?
stringInput.cl:7:21: note: expanded from macro 'rgb_matrix'

That case should probably be caught earlier and rejected with a clear message.


On Mali:

$ ./ffmpeg_g -v 55 -y -i ~/test/The\ World\ in\ HDR.mkv -init_hw_device opencl 
-filter_hw_device opencl0 -an -vf 
'format=p010,hwupload,tonemap_opencl=t=bt2020:tonemap=linear:format=p010,hwdownload,format=p010'
 -c:v libx264 out.mp4
...
[tonemap_opencl @ 0x8201d7c0] Filter input: opencl, 3840x2160 (0).
[Parsed_tonemap_opencl_2 @ 0x8201d760] Failed to enqueue kernel: -5.

That's an RK3288 with a Mali T760, clinfo: , full log: 
.

(The Rockchip hardware decoder can do H.265 Main 10, but the output format 
isn't P010 so it's easier to use VP9 here.)


Some more thoughts below, I haven't read through all of it carefully.

Thanks,

- Mark


>  configure  |   1 +
>  libavfilter/Makefile   |   2 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/colorspace_basic.c |  89 ++
>  libavfilter/colorspace_basic.h |  40 +++
>  libavfilter/opencl/colorspace_basic.cl | 179 +++
>  libavfilter/opencl/tonemap.cl  | 258 +++
>  libavfilter/opencl_source.h|   2 +
>  libavfilter/vf_tonemap_opencl.c| 560 
> +
>  9 files changed, 1132 insertions(+)
>  create mode 100644 libavfilter/colorspace_basic.c
>  create mode 100644 libavfilter/colorspace_basic.h
>  create mode 100644 libavfilter/opencl/colorspace_basic.cl
>  create mode 100644 libavfilter/opencl/tonemap.cl
>  create mode 100644 libavfilter/vf_tonemap_opencl.c
> 
> ...
> diff --git a/libavfilter/opencl/tonemap.cl b/libavfilter/opencl/tonemap.cl
> new file mode 100644
> index 000..03cf3e2
> --- /dev/null
> +++ b/libavfilter/opencl/tonemap.cl
> @@ -0,0 +1,258 @@
> +/*
> + * 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
> + */
> +
> +#define REFERENCE_WHITE 100.0f
> +extern float3 lrgb2yuv(float3);
> +extern float3 yuv2lrgb(float3);
> +extern float3 lrgb2lrgb(float3);
> +extern float get_luma_src(float3);
> +extern float get_luma_dst(float3);
> +extern float3 ootf(float3);
> +extern float3 inverse_ootf(float3);
> +struct detection_result {
> +float peak;
> +float average;
> +};
> +
> +float hable_f(float in) {
> +float a = 0.15f, b = 0.50f, c = 0.10f, d = 0.20f, e = 0.02f, f = 0.30f;
> +return (in * (in * a + b * c) + d * e) / (in * (in * a + b) + d * f) - e 
> / f;
> +}
> +
> +float direct(float s, float peak) {
> +return s;
> +}
> +
> +float linear(float s, float peak) {
> +return s * tone_param / peak;
> +}
> +
> +float gamma(float s, float peak) {
> +float p = s > 0.05f ? s /peak : 0.05f / peak;
> +float v = pow(p, 1.0f / tone_param);
> +return s > 0.05f ? v : (s * v /0.05f);
> +}
> +
> +float clip(float s, float peak) {
> +return clamp(s * tone_param, 0.0f, 1.0f);
> +}
> +
> +float reinhard(float s, float peak) {
> +return s / (s + tone_param) * (peak + tone_param) / peak;
> +}
> +
> +float hable(float s, fl

Re: [FFmpeg-devel] [PATCH 1/2] libavformat/mov: treat udta atoms within trak atoms as stream metadata

2018-05-21 Thread Nik Johnson
For lack of a better option here's a dropbox link. The 
ftp://upload.ffmpeg.org server doesn't appear to respond. This is a tiny 
clip unmodified from NVidia Shadowplay.


(5.4MB) 
https://www.dropbox.com/s/6izrx87gfsgjodq/mov-trak-name-shadowplay.mp4?dl=0


-- Original Message --
From: "Carl Eugen Hoyos" 
To: "FFmpeg development discussions and patches" 


Sent: 5/21/2018 4:36:09 PM
Subject: Re: [FFmpeg-devel] [PATCH 1/2] libavformat/mov: treat udta 
atoms within trak atoms as stream metadata



2018-05-21 16:18 GMT+02:00, Nik Johnson :

Some muxers produce mp4s with a udta (user data) atom nested within a
trak atom. The nested udta atoms typically contain stream information
such as the title. ffmpeg should treat nested udta atoms as applicable
to the stream instead of globally.


Please also provide a sample.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH]lavc/j2kenc: Support AV_PIX_FMT_PAL8

2018-05-21 Thread Carl Eugen Hoyos
Hi!

Attached patch allows pal8 encoding into j2k, tested with libopenjpeg,
kakadu and jasper.

Please comment, Carl Eugen
From ffc9968279ecbf8b0b6659e9a07539edb9787e44 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Tue, 22 May 2018 02:21:04 +0200
Subject: [PATCH] lavc/j2kenc: Support AV_PIX_FMT_PAL8.

---
 libavcodec/j2kenc.c  |   40 
 libavcodec/version.h |2 +-
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/libavcodec/j2kenc.c b/libavcodec/j2kenc.c
index 3e542af..e91d932 100644
--- a/libavcodec/j2kenc.c
+++ b/libavcodec/j2kenc.c
@@ -71,6 +71,7 @@
 #include "libavutil/common.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/opt.h"
+#include "libavutil/intreadwrite.h"
 
 #define NMSEDEC_BITS 7
 #define NMSEDEC_FRACBITS (NMSEDEC_BITS-1)
@@ -1054,14 +1055,38 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 bytestream_put_byte(&s->buf, 1);
 bytestream_put_byte(&s->buf, 0);
 bytestream_put_byte(&s->buf, 0);
-if (s->ncomponents == 1) {
-bytestream_put_be32(&s->buf, 17);
-} else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
+if (avctx->pix_fmt == AV_PIX_FMT_RGB24 || avctx->pix_fmt == AV_PIX_FMT_PAL8) {
 bytestream_put_be32(&s->buf, 16);
+} else if (s->ncomponents == 1) {
+bytestream_put_be32(&s->buf, 17);
 } else {
 bytestream_put_be32(&s->buf, 18);
 }
 update_size(chunkstart, s->buf);
+if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
+int i;
+uint8_t *palette = pict->data[1];
+chunkstart = s->buf;
+bytestream_put_be32(&s->buf, 0);
+bytestream_put_buffer(&s->buf, "pclr", 4);
+bytestream_put_be16(&s->buf, AVPALETTE_COUNT);
+bytestream_put_byte(&s->buf, 3); // colour channels
+bytestream_put_be24(&s->buf, 0x070707); //colour depths
+for (i = 0; i < AVPALETTE_COUNT; i++) {
+bytestream_put_be24(&s->buf, HAVE_BIGENDIAN ? AV_RB24(palette + 1) : AV_RL24(palette));
+palette += 4;
+}
+update_size(chunkstart, s->buf);
+chunkstart = s->buf;
+bytestream_put_be32(&s->buf, 0);
+bytestream_put_buffer(&s->buf, "cmap", 4);
+for (i = 0; i < 3; i++) {
+bytestream_put_be16(&s->buf, 0); // component
+bytestream_put_byte(&s->buf, 1); // palette mapping
+bytestream_put_byte(&s->buf, i); // index
+}
+update_size(chunkstart, s->buf);
+}
 update_size(jp2hstart, s->buf);
 
 jp2cstart = s->buf;
@@ -1124,6 +1149,12 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
+if (avctx->pix_fmt == AV_PIX_FMT_PAL8 && (s->pred != FF_DWT97_INT || s->format != CODEC_JP2)) {
+av_log(s->avctx, AV_LOG_WARNING, "Forcing lossless jp2 for pal8\n");
+s->pred = FF_DWT97_INT;
+s->format = CODEC_JP2;
+}
+
 // defaults:
 // TODO: implement setting non-standard precinct size
 memset(codsty->log2_prec_widths , 15, sizeof(codsty->log2_prec_widths ));
@@ -1154,7 +1185,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 if (avctx->pix_fmt == AV_PIX_FMT_RGB24){
 s->ncomponents = 3;
-} else if (avctx->pix_fmt == AV_PIX_FMT_GRAY8){
+} else if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 || avctx->pix_fmt == AV_PIX_FMT_PAL8){
 s->ncomponents = 1;
 } else{ // planar YUV
 s->planar = 1;
@@ -1223,6 +1254,7 @@ AVCodec ff_jpeg2000_encoder = {
 AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV444P, AV_PIX_FMT_GRAY8,
 AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P,
 AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P,
+AV_PIX_FMT_PAL8,
 AV_PIX_FMT_NONE
 },
 .priv_class = &j2k_class,
diff --git a/libavcodec/version.h b/libavcodec/version.h
index da893da..2e45d39 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR  19
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MICRO 103
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
1.7.10.4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] libavformat/mov: treat udta atoms within trak atoms as stream metadata

2018-05-21 Thread Carl Eugen Hoyos
2018-05-21 16:18 GMT+02:00, Nik Johnson :
> Some muxers produce mp4s with a udta (user data) atom nested within a
> trak atom. The nested udta atoms typically contain stream information
> such as the title. ffmpeg should treat nested udta atoms as applicable
> to the stream instead of globally.

Please also provide a sample.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc/cfhd: deinterlacing introduced in cfhd

2018-05-21 Thread James Almer
On 5/21/2018 3:16 PM, Gagandeep Singh wrote:
> ---
>  libavcodec/cfhd.c | 177 
> +-
>  libavcodec/cfhd.h |   9 +++
>  2 files changed, 158 insertions(+), 28 deletions(-)
> 
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index 7ceb803595..d70c13592c 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -49,12 +49,15 @@ enum CFHDParam {
>  SubbandNumber=  48,
>  Quantization =  53,
>  ChannelNumber=  62,
> +SampleFlags  =  68,
>  BitsPerComponent = 101,
>  ChannelWidth = 104,
>  ChannelHeight= 105,
>  PrescaleShift= 109,
>  };
>  
> +
> +
>  static av_cold int cfhd_init(AVCodecContext *avctx)
>  {
>  CFHDContext *s = avctx->priv_data;
> @@ -72,6 +75,13 @@ static void init_plane_defaults(CFHDContext *s)
>  s->subband_num_actual = 0;
>  }
>  
> +static void init_peak_table_defaults(CFHDContext *s)
> +{
> +s->peak.level  = 0;
> +s->peak.offset = 0;
> +s->peak.base   = NULL;
> +}
> +
>  static void init_frame_defaults(CFHDContext *s)
>  {
>  s->coded_width   = 0;
> @@ -86,15 +96,45 @@ static void init_frame_defaults(CFHDContext *s)
>  s->wavelet_depth = 3;
>  s->pshift= 1;
>  s->codebook  = 0;
> +s->difference_coding = 0;
> +s->progressive   = 0;
>  init_plane_defaults(s);
> +init_peak_table_defaults(s);
>  }
>  
>  /* TODO: merge with VLC tables or use LUT */
> -static inline int dequant_and_decompand(int level, int quantisation)
> +static inline int dequant_and_decompand(int level, int quantisation, int 
> codebook)
>  {
> -int64_t abslevel = abs(level);
> -return (abslevel + ((768 * abslevel * abslevel * abslevel) / (255 * 255 
> * 255))) *
> -   FFSIGN(level) * quantisation;
> +if (codebook == 0 || codebook == 1) {
> +int64_t abslevel = abs(level);
> +if (level < 264)
> +return (abslevel + ((768 * abslevel * abslevel * abslevel) / 
> (255 * 255 * 255))) *
> +   FFSIGN(level) * quantisation;
> +else
> +return level * quantisation;
> +  }

Wrong indentation for this bracket.

> +else
> +return level * quantisation;
> +}
> +
> +static inline void difference_coding(int16_t *band, int width, int height)
> +{
> +
> +int i,j;
> +for (i = 0; i < height; i++) {
> +  for (j = 1; j < width; j++) {
> +band[j] += band[j-1];
> +  }
> +  band += width;
> +}

Same for this entire function.

> +}
> +
> +static inline void peak_table(int16_t *band, Peak *peak, int length)
> +{
> +int i;
> +for (i = 0; i < length; i++)
> +if (abs(band[i]) > peak->level)
> +band[i] = *(++peak->base);
>  }
>  
>  static inline void process_alpha(int16_t *alpha, int width)
> @@ -154,6 +194,26 @@ static inline void filter(int16_t *output, ptrdiff_t 
> out_stride,
>  }
>  }
>  
> +static inline void interlaced_vertical_filter(int16_t *output, int16_t *low, 
> int16_t *high,
> + int width, int linesize, int plane)
> +{
> +int i;
> +int16_t even, odd;
> +for (i = 0; i < width; i++) {
> +  even = (*low - *high)/2;
> +  odd  = (*low + *high)/2;
> +

Same.

> +  even = FFMIN(1023, even);
> +  even = FFMAX(0, even);
> +  odd  = FFMIN(1023, odd);
> +  odd  = FFMAX(0, odd);
> +
> +  output[i] = even;
> +  output[i + linesize] = odd;

This can be simplified as

output[i]= av_clip_uintp2(even, 10);
output[i + linesize] = av_clip_uintp2(odd, 10);


> +  low++;
> +  high++;
> +}
> +}
>  static void horiz_filter(int16_t *output, int16_t *low, int16_t *high,
>   int width)
>  {
> @@ -295,6 +355,9 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
> int *got_frame,
>  uint16_t data   = bytestream2_get_be16(&gb);
>  if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
>  av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 
> 16) | data);
> +} else if (tag == SampleFlags) {
> +av_log(avctx, AV_LOG_DEBUG, "Progressive?%"PRIu16"\n", data);
> +s->progressive = data & 0x0001;

Just write data & 1, or !!data if it's a matter of making sure this is
not zero.

>  } else if (tag == ImageWidth) {
>  av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data);
>  s->coded_width = data;
> @@ -393,6 +456,8 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
> int *got_frame,
>  }
>  av_log(avctx, AV_LOG_DEBUG, "Transform-type? %"PRIu16"\n", data);
>  } else if (abstag >= 0x4000 && abstag <= 0x40ff) {
> +if (abstag == 0x4001)
> +s->peak.level = 0;
>  av_log(avctx, AV_LOG_DEBUG, "Small chunk length %d %s\n", data * 
> 4, tag < 0 ? "optional" : "required");
>  bytestream2_skipu(&gb, data * 4);
>  } e

Re: [FFmpeg-devel] [PATCH] lavc/cfhd: deinterlacing introduced in cfhd

2018-05-21 Thread Carl Eugen Hoyos
2018-05-21 20:16 GMT+02:00, Gagandeep Singh :
> ---
>  libavcodec/cfhd.c | 177
> +-
>  libavcodec/cfhd.h |   9 +++
>  2 files changed, 158 insertions(+), 28 deletions(-)

Please mention ticket #5522 in the commit message.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/libvpxenc: fix setting amount of threads used for encoding

2018-05-21 Thread James Almer
On 5/21/2018 4:16 PM, James Zern wrote:
> On Sat, May 19, 2018 at 11:16 AM James Almer  wrote:
> 
>> The libvpx doxy says that a value of 0 for the g_threads field is
>> equivalent to a value of 1, whereas for avctx->thread_count it means
>> the maximum amount of threads possible for the host system.
> 
>> Use av_cpu_count() to get the correct thread count when auto threads
>> is requested.
> 
>> Signed-off-by: James Almer 
>> ---
>>   libavcodec/libvpxenc.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 
> lgtm, thanks.

Pushed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavformat: add mbedTLS based TLS

2018-05-21 Thread James Almer
On 5/21/2018 11:15 AM, James Almer wrote:
> On 5/21/2018 8:27 AM, Thomas Volkert wrote:
>> Hi,
>>
>> On 14.05.2018 19:04, Dave Gregory wrote:
>>> Hi all,
>>>
>>> [..comparison with alternative TLS implementations..]
>>
>> Ping.
>>
>> I still suggest to support mbedTLS in FFmpeg because it is especially
>> interesting for embedded devices.
>>
>> Best regards,
>> Thomas.
> 
> I'll apply it later today. Thank you for the benchmarks.

Pushed after removing the hls muxer configure "suggestion" as you did
not add support for a buffer randomizer to it using mbedtls like it's
done with OpenSSL and gcrypt.

If mbedtls has a similar function, can you look into adding it to hlsenc.c?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/4] hwcontext_opencl: Don't try to free an invalid queue in frames_uninit

2018-05-21 Thread Mark Thompson
This can happen if frames_init fails.
---
 libavutil/hwcontext_opencl.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index c29a521f07..0d255e54e7 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -1739,10 +1739,12 @@ static void opencl_frames_uninit(AVHWFramesContext 
*hwfc)
 av_freep(&priv->mapped_frames);
 #endif
 
-cle = clReleaseCommandQueue(priv->command_queue);
-if (cle != CL_SUCCESS) {
-av_log(hwfc, AV_LOG_ERROR, "Failed to release frame "
-   "command queue: %d.\n", cle);
+if (priv->command_queue) {
+cle = clReleaseCommandQueue(priv->command_queue);
+if (cle != CL_SUCCESS) {
+av_log(hwfc, AV_LOG_ERROR, "Failed to release frame "
+   "command queue: %d.\n", cle);
+}
 }
 }
 
-- 
2.16.3

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/4] hwcontext_opencl: Allocate a test image in frames_init

2018-05-21 Thread Mark Thompson
This ensures that the format and dimensions are actually valid -
previously this wasn't checked, so we would only fail when the user
actually attempted to allocate an image.
---
 libavutil/hwcontext_opencl.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index 43b5c5ae0c..c29a521f07 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -1696,11 +1696,23 @@ static int 
opencl_frames_init_command_queue(AVHWFramesContext *hwfc)
 static int opencl_frames_init(AVHWFramesContext *hwfc)
 {
 if (!hwfc->pool) {
+AVBufferRef *test_ref;
+
 hwfc->internal->pool_internal =
 av_buffer_pool_init2(sizeof(cl_mem), hwfc,
  &opencl_pool_alloc, NULL);
 if (!hwfc->internal->pool_internal)
 return AVERROR(ENOMEM);
+
+test_ref = av_buffer_pool_get(hwfc->internal->pool_internal);
+if (!test_ref) {
+av_log(hwfc, AV_LOG_ERROR, "Unable to create %dx%d images "
+   "with format %s.\n", hwfc->width, hwfc->height,
+   av_get_pix_fmt_name(hwfc->sw_format));
+return AVERROR(EINVAL);
+}
+
+av_buffer_unref(&test_ref);
 }
 
 return opencl_frames_init_command_queue(hwfc);
-- 
2.16.3

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 4/4] hwcontext: Add test for frames context creation and transfer

2018-05-21 Thread Mark Thompson
Creates a frames context of every available type and attempts to
upload/download frame data to each, checking that the output is the same
as the input in each case.
---
This test passes with VDPAU and OpenCL, but may fail for others.

For VAAPI the main issue is that there isn't really a consistent way to 
determine what formats are supported as surfaces, as images and for 
upload/download.
With the i965 driver:
* YUV 4:2:2 planar works as surfaces and images but can't be downloaded.
* Greyscale images can't be created.
* Uploading RGB and then downloading it again gives different results.  It 
looks like it might have gone via 4:2:0 somewhere?
* With older hardware (Haswell), P010 appears to be supported but always fails.
With the Mesa driver:
* Uploading UYVY and then downloading it doesn't match halfway through the 
image.  Halfway suggests another consequence of the separated fields madness, I 
didn't look very carefully.
* It aborts when asked to make a YUYV (YUY2) surface.  This should be easily 
fixable in the driver.

DXVA2 can fail because format support is not checked at init time (see patch 
1/4 here for OpenCL).  Should that be changed?

D3D11 and libmfx require fixed-size pools to create, which I don't attempt to 
deal with here.

Any thoughts invited.

- Mark


 libavutil/Makefile |   1 +
 libavutil/tests/hwframes.c | 404 +
 tests/fate/hw.mak  |   5 +
 3 files changed, 410 insertions(+)
 create mode 100644 libavutil/tests/hwframes.c

diff --git a/libavutil/Makefile b/libavutil/Makefile
index d0632f16a6..59b8d52e04 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -207,6 +207,7 @@ TESTPROGS = adler32 
\
 hash\
 hmac\
 hwdevice\
+hwframes\
 integer \
 imgutils\
 lfg \
diff --git a/libavutil/tests/hwframes.c b/libavutil/tests/hwframes.c
new file mode 100644
index 00..32e3cdbdf9
--- /dev/null
+++ b/libavutil/tests/hwframes.c
@@ -0,0 +1,404 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavutil/hwcontext.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/pixdesc.h"
+
+static int test_frames_transfer(AVBufferRef *frames_ref)
+{
+AVHWFramesContext *frames = (AVHWFramesContext*)frames_ref->data;
+const AVPixFmtDescriptor *desc;
+AVFrame *src, *hw, *dst;
+int planes, line_width[4], plane_height[4];
+int c, p, x, y, err;
+uint8_t val;
+
+desc = av_pix_fmt_desc_get(frames->sw_format);
+if (!desc)
+return -1;
+
+err = av_image_fill_linesizes(line_width,
+  frames->sw_format, frames->width);
+if (err < 0) {
+fprintf(stderr, "Failed to determine line widths for format %s.\n",
+desc->name);
+return -1;
+}
+planes = 0;
+for (c = 0; c < desc->nb_components; c++)
+planes = FFMAX(planes, desc->comp[c].plane + 1);
+for (p = 0; p < planes; p++) {
+plane_height[p] = AV_CEIL_RSHIFT(frames->height,
+ desc->log2_chroma_h);
+}
+
+src = av_frame_alloc();
+hw  = av_frame_alloc();
+dst = av_frame_alloc();
+if (!src || !hw || !dst) {
+fprintf(stderr, "Failed to allocate frames.\n");
+err = -1;
+goto fail;
+}
+
+src->format = dst->format = frames->sw_format;
+src->width  = dst->width  = frames->width;
+src->height = dst->height = frames->height;
+
+err = av_frame_get_buffer(src, 0);
+if (err < 0) {
+fprintf(stderr, "Failed to allocate source frame data.\n");
+err = -1;
+goto fail;
+}
+err = av_hwframe_get_buffer(frames_ref, hw, 0);
+if (err < 0) {
+fprintf(stderr, "Failed to allocate hardware frame.

[FFmpeg-devel] [PATCH 3/4] hwcontext: Don't segfault on invalid arguments to transfer

2018-05-21 Thread Mark Thompson
The code previously assumed that src->hw_frames_ctx was necessarily set
if dst->buf wasn't.  Using non-refcounted hardware frames is not allowed
here, but we can return an error in that case.
---
 libavutil/hwcontext.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index 745016ed7e..5859443cf6 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -441,8 +441,12 @@ int av_hwframe_transfer_data(AVFrame *dst, const AVFrame 
*src, int flags)
 AVHWFramesContext *ctx;
 int ret;
 
-if (!dst->buf[0])
-return transfer_data_alloc(dst, src, flags);
+if (!dst->buf[0]) {
+if (src->hw_frames_ctx)
+return transfer_data_alloc(dst, src, flags);
+else
+return AVERROR(EINVAL);
+}
 
 if (src->hw_frames_ctx) {
 ctx = (AVHWFramesContext*)src->hw_frames_ctx->data;
-- 
2.16.3

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-05-21 Thread Michael Niedermayer
On Mon, May 21, 2018 at 02:36:28PM -0700, Wang Cao wrote:
> Sorry the ticket doesn't contain alaw_2.aif as in
> https://trac.ffmpeg.org/ticket/1660

the issue is reproduceable with alaw.aif from the ticket

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] ffmpeg: Use the colour properties from the input stream when doing transcode

2018-05-21 Thread Mark Thompson
On 16/05/18 08:19, Haihao Xiang wrote:
> In lavc/hevec_vaapi, colour properties in AVCodecContext are needed to
> write the sequence header
> 
> Tested by the command below:
> ffmpeg -hwaccel vaapi -hwaccel_device /dev/dri/renderD128
> -hwaccel_output_format vaapi -i input-with-hdr.mkv -c:v hevc_vaapi
> -profile:v main10 output.h265
> 
> Signed-off-by: Haihao Xiang 
> ---
>  fftools/ffmpeg.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 5a19a09d9a..80b5441f8f 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -3298,6 +3298,10 @@ static int init_output_stream_encode(OutputStream *ost)
>  dec_ctx = ist->dec_ctx;
>  
>  enc_ctx->chroma_sample_location = dec_ctx->chroma_sample_location;
> +enc_ctx->color_range= dec_ctx->color_range;
> +enc_ctx->color_primaries= dec_ctx->color_primaries;
> +enc_ctx->color_trc  = dec_ctx->color_trc;
> +enc_ctx->colorspace = dec_ctx->colorspace;
>  } else {
>  for (j = 0; j < oc->nb_streams; j++) {
>  AVStream *st = oc->streams[j];
> 

There are outstanding patches passing color_range through the filter chain (see 
), and 
that would be the right solution for the rest of these properties as well, but 
it would require significantly more work.

I think hacking it like this is ok for now?  It's not worse than before since a 
change during filtering wasn't visible anyway, and the manual options do still 
work to override it.  I think the commit message could be a little clearer 
about the problem (really, that this colour information doesn't pass through 
filtering) and its limitations (requires a single input matched to the output; 
will write the wrong thing if filtering changes anything) though, or maybe that 
could be explained in a comment.

Does anyone else have any thoughts on this?  If there are no objections then I 
would apply it updated with a clearer explanation.

Thanks,

- Mark
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] hwcontext: Add test for device creation and derivation

2018-05-21 Thread Mark Thompson
On 16/05/18 02:14, Xiang, Haihao wrote:
> On Tue, 2018-05-15 at 23:15 +0100, Mark Thompson wrote:
>> This uses any devices it can find on the host system - on a system with no
>> hardware device support or in builds with no support included it will do
>> nothing and pass.
>> ---
>>
>> It now comes under a new target "fate-hw", which is not run as part of 
>> "fate".
>>
>> I found the CMP option, so it no longer has a reference file.  All output is
>> therefore now on stderr.
>>
>> Thanks,
>>
>> - Mark
>>
>> (In terms of further tests under fate-hw, I'm intending to add a hwframes 
>> test
>> which tries to make frames contexts and do upload/download.  There should
>> probably be something with frames context mapping too, but I'm unsure exactly
>> what.  I'd also like to have some tests for the complex header construction
>> code in VAAPI encode, but how to actually run that needs a bit more thought.)
>>
>>
>>  libavutil/Makefile |   1 +
>>  libavutil/tests/.gitignore |   1 +
>>  libavutil/tests/hwdevice.c | 226
>> +
>>  tests/Makefile |   5 +
>>  tests/fate/hw.mak  |   6 ++
>>  5 files changed, 239 insertions(+)
>>  create mode 100644 libavutil/tests/hwdevice.c
>>  create mode 100644 tests/fate/hw.mak
>>
>> diff --git a/libavutil/Makefile b/libavutil/Makefile
>> index 4fe470748c..d0632f16a6 100644
>> --- a/libavutil/Makefile
>> +++ b/libavutil/Makefile
>> @@ -206,6 +206,7 @@ TESTPROGS =
>> adler32 \
>>  fifo\
>>  hash\
>>  hmac\
>> +hwdevice\
>>  integer \
>>  imgutils\
>>  lfg \
>> diff --git a/libavutil/tests/.gitignore b/libavutil/tests/.gitignore
>> index 8ede070887..71f75a8ee9 100644
>> --- a/libavutil/tests/.gitignore
>> +++ b/libavutil/tests/.gitignore
>> @@ -22,6 +22,7 @@
>>  /file
>>  /hash
>>  /hmac
>> +/hwdevice
>>  /imgutils
>>  /lfg
>>  /lls
>> diff --git a/libavutil/tests/hwdevice.c b/libavutil/tests/hwdevice.c
>> new file mode 100644
>> index 00..7eb355c988
>> --- /dev/null
>> +++ b/libavutil/tests/hwdevice.c
>> @@ -0,0 +1,226 @@
>> +/*
>> + * This file is part of FFmpeg.
>> + *
>> + * FFmpeg is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * FFmpeg is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with FFmpeg; if not, write to the Free Software
>> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
>> USA
>> + */
>> +
>> +#include 
>> +
>> +#include "libavutil/hwcontext.h"
>> +
>> +static int test_derivation(AVBufferRef *src_ref, const char *src_name)
>> +{
>> +enum AVHWDeviceType derived_type;
>> +const char *derived_name;
>> +AVBufferRef *derived_ref = NULL, *back_ref = NULL;
>> +AVHWDeviceContext *src_dev, *derived_dev;
>> +int err;
>> +
>> +src_dev = (AVHWDeviceContext*)src_ref->data;
>> +
>> +derived_type = AV_HWDEVICE_TYPE_NONE;
>> +while (1) {
>> +derived_type = av_hwdevice_iterate_types(derived_type);
>> +if (derived_type == AV_HWDEVICE_TYPE_NONE)
>> +break;
>> +
>> +derived_name = av_hwdevice_get_type_name(derived_type);
>> +
>> +err = av_hwdevice_ctx_create_derived(&derived_ref, derived_type,
>> + src_ref, 0);
>> +if (err < 0) {
>> +fprintf(stderr, "Unable to derive %s -> %s: %d.\n",
>> +src_name, derived_name, err);
>> +continue;
>> +}
>> +
>> +derived_dev = (AVHWDeviceContext*)derived_ref->data;
>> +if (derived_dev->type != derived_type) {
>> +fprintf(stderr, "Device derived as type %d has type %d.\n",
>> +derived_type, derived_dev->type);
>> +goto fail;
>> +}
>> +
>> +if (derived_type == src_dev->type) {
>> +if (derived_dev != src_dev) {
>> +fprintf(stderr, "Derivation of %s from itself succeeded "
>> +"but did not return the same device.\n", src_name);
>> +

Re: [FFmpeg-devel] [PATCH] avcodec/avformat: Add Camera Motion Metadata support

2018-05-21 Thread Erik Ackermann
Could you elaborate a bit on what you mean?

This patch mostly follows the pattern of the existing 'gmpd' track, however
it seems without adding logic to mov.c::mov_parse_stsd_data() the track is
not correctly identified. I just tested -c copy on a file with gpmd track
and it is lost during the copy (but tmcd track is not).

On Mon, May 21, 2018 at 12:58 PM, Rostislav Pehlivanov 
wrote:

> On 21 May 2018 at 19:52, Erik Ackermann 
> wrote:
>
> > Spec: https://developers.google.com/streetview/publish/camm-spec
> >
> > The Lenovo Mirage camera launched recently and outputs this metadata
> track
> > in its videos.
> >
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> >
> This should be outputted as side data rather than as a separate stream, if
> possible, even if the demuxer needs hacks.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-05-21 Thread Wang Cao
Sorry the ticket doesn't contain alaw_2.aif as in
https://trac.ffmpeg.org/ticket/1660

On Fri, May 18, 2018 at 8:13 PM, Michael Niedermayer  wrote:

> On Fri, May 18, 2018 at 04:54:25PM -0700, Wang Cao wrote:
> > - Make ffmpeg to output stats for each video streams and each ouptut
> file ffmpeg output log in print_report.
> > - The report of video/audio sizes is clear as previously all output
> > video/audio sizes were combined to report and it is unclear such stats
> > is for one output files or aggregates for all output files.
> >
> > Signed-off-by: Wang Cao 
> > ---
> >  fftools/ffmpeg.c | 182 ++-
> >  1 file changed, 101 insertions(+), 81 deletions(-)
>
> This causes the report to disappear for
> ./ffmpeg -i ~/tickets/1660/alaw_2.aif -f null -
>
> file should be in the ticket on trac, if not, say so and ill figure out
> where
> the file is
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Those who are best at talking, realize last or never when they are wrong.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>


-- 
Wang Cao
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/mpeg4videoenc: Use 64 bit for times in mpeg4_encode_gop_header()

2018-05-21 Thread Michael Niedermayer
Fixes truncation
Fixes Assertion n <= 31 && value < (1U << n) failed at libavcodec/put_bits.h:169
Fixes: ffmpeg_crash_2.avi

Found-by: Thuan Pham , Marcel Böhme, Andrew Santosa 
and Alexandru RazvanCaciulescu with AFLSmart

Signed-off-by: Michael Niedermayer 
---
 libavcodec/mpeg4videoenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 494452c938..f6a5992df7 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -882,7 +882,7 @@ void ff_set_mpeg4_time(MpegEncContext *s)
 
 static void mpeg4_encode_gop_header(MpegEncContext *s)
 {
-int hours, minutes, seconds;
+int64_t hours, minutes, seconds;
 int64_t time;
 
 put_bits(&s->pb, 16, 0);
-- 
2.17.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/8] ffserver: Implement lua config file reader

2018-05-21 Thread Stephan Holljes
On Mon, May 21, 2018 at 3:04 PM, James Darnley  wrote:
> On 2018-05-20 20:53, Stephan Holljes wrote:
>> +#include 
>> +#include 
>> +#include 
>
> That's not portable.  Lua headers are not in a subdirectory.

Yes, artifact from early testing, changed and tested, pkg-config adds
the appropriate include directories.

>
>> +int configs_read(struct HTTPDConfig **configs, const char *filename)
>> +{
>> +int ret = 0;
>> +int nb_configs = 0;
>> +int nb_streams = 0;
>> +int nb_formats = 0;
>> +int i;
>> +int index = 0;
>> +const char *key, *error;
>> +struct HTTPDConfig *parsed_configs = NULL;
>> +struct HTTPDConfig *config;
>> +struct StreamConfig *stream;
>> +lua_State *L = luaL_newstate();
>> +ret = luaL_loadfile(L, filename);
>> +if (ret != 0) {
>> +fprintf(stderr, "Unable to open config file: %s\n", lua_tostring(L, 
>> -1));
>> +lua_close(L);
>> +return -1;
>> +}
>> +
>> +ret = lua_pcall(L, 0, 0, 0);
>> +
>> +if (ret != 0) {
>> +fprintf(stderr, "Unable to read config file: %s\n", lua_tostring(L, 
>> -1));
>> +lua_close(L);
>> +return -1;
>> +}
>> +lua_getglobal(L, "settings");
>> +if (lua_type(L, -1) != LUA_TTABLE) {
>> +lua_pushstring(L, "Error \"settings\" is not a table");
>> +goto fail;
>> +}
>> +lua_pushnil(L);
>> +
>> +// iterate servers
>> +while (lua_next(L, -2) != 0) {
>> +nb_configs++;
>> +parsed_configs = av_realloc(parsed_configs, nb_configs * 
>> sizeof(struct HTTPDConfig));
>> +config = &parsed_configs[nb_configs - 1];
>> +config->server_name = NULL;
>> +config->bind_address = NULL;
>> +config->port = 0;
>> +config->accept_timeout = 1000;
>> +config->streams = NULL;
>> +config->nb_streams = 0;
>> +if (lua_type(L, -2) != LUA_TSTRING) {
>> +lua_pushstring(L, "Error server name is not a string.");
>> +goto fail;
>> +}
>> +if (lua_type(L, -1) != LUA_TTABLE) {
>> +lua_pushstring(L, "Error server settings is not a table.");
>> +goto fail;
>> +}
>> +config->server_name = av_strdup(lua_tostring(L, -2));
>> +lua_pushnil(L);
>> +// iterate server properties
>> +nb_streams = 0;
>> +while(lua_next(L, -2) != 0) {
>> +if (lua_type(L, -2) != LUA_TSTRING) {
>> +lua_pushstring(L, "Error server property is not a string.");
>> +goto fail;
>> +}
>> +key = lua_tostring(L, -2);
>> +if (!strncmp("bind_address", key, 12)) {
>> +config->bind_address = av_strdup(lua_tostring(L, -1));
>> +} else if (!strncmp("port", key, 4)) {
>> +config->port = (int) lua_tonumber(L, -1);
>> +} else {
>> +// keys that are not "bind_address" or "port" are streams
>> +if (lua_type(L, -1) != LUA_TTABLE) {
>> +lua_pushstring(L, "Error Stream configuration is not a 
>> table.");
>> +goto fail;
>> +}
>> +
>> +nb_streams++;
>> +config->streams = av_realloc(config->streams, nb_streams * 
>> sizeof(struct StreamConfig));
>> +stream = &config->streams[nb_streams - 1];
>> +stream->input_uri = NULL;
>> +stream->formats = NULL;
>> +stream->stream_name = av_strdup(lua_tostring(L, -2));
>> +lua_pushnil(L);
>> +while(lua_next(L, -2) != 0) {
>> +if (lua_type(L, -2) != LUA_TSTRING) {
>> +lua_pushstring(L, "Error stream property is not a 
>> string.");
>> +goto fail;
>> +}
>> +key = lua_tostring(L, -2);
>> +if (!strncmp("input", key, 5)) {
>> +stream->input_uri = av_strdup(lua_tostring(L, -1));
>> +} else if (!strncmp("formats", key, 7)) {
>> +index = 1;
>> +nb_formats = 0;
>> +lua_pushnumber(L, index);
>> +while(1) {
>> +lua_gettable(L, -2);
>> +if (lua_isnil(L, -1))
>> +break;
>> +if (lua_type(L, -1) != LUA_TSTRING) {
>> +lua_pushstring(L, "Error format name is not 
>> a string.");
>> +goto fail;
>> +}
>> +stream->formats = av_realloc(stream->formats,
>> + (nb_formats + 1) * 
>> sizeof(enum StreamFormat));
>> +key = lua_tostring(L, -1);
>> +if (!strncmp("mkv", key,

Re: [FFmpeg-devel] [PATCH] lavc/cfhd: deinterlacing introduced in cfhd

2018-05-21 Thread Kieran Kunhya
>
> +static inline void interlaced_vertical_filter(int16_t *output, int16_t
> *low, int16_t *high,
> + int width, int linesize, int plane)
> +{
> +int i;
> +int16_t even, odd;
> +for (i = 0; i < width; i++) {
> +  even = (*low - *high)/2;
> +  odd  = (*low + *high)/2;
> +
> +  even = FFMIN(1023, even);
> +  even = FFMAX(0, even);
> +  odd  = FFMIN(1023, odd);
> +  odd  = FFMAX(0, odd);
> +
> +  output[i] = even;
> +  output[i + linesize] = odd;
> +  low++;
> +  high++;
> +}
> +}
>

low[i] and high[i] instead of doing this pointer addition stuff.

Kieran
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc/cfhd: deinterlacing introduced in cfhd

2018-05-21 Thread Kieran Kunhya
Not really "deinterlacing", it would be "add interlaced file support" or
similar.


On Mon, 21 May 2018 at 20:17 Gagandeep Singh 
wrote:

> +static inline void peak_table(int16_t *band, Peak *peak, int length)
> +{
> +int i;
> +for (i = 0; i < length; i++)
> +if (abs(band[i]) > peak->level)
> +band[i] = *(++peak->base);
>  }
>

Pretty sure you need to start from the first base entry, not the sencond
so, peak->base++;

 static inline void process_alpha(int16_t *alpha, int width)
> @@ -154,6 +194,26 @@ static inline void filter(int16_t *output, ptrdiff_t
> out_stride,
>  }
>  }
>
> +static inline void interlaced_vertical_filter(int16_t *output, int16_t
> *low, int16_t *high,
> + int width, int linesize, int plane)
> +{
> +int i;
> +int16_t even, odd;
> +for (i = 0; i < width; i++) {
> +  even = (*low - *high)/2;
> +  odd  = (*low + *high)/2;
> +
> +  even = FFMIN(1023, even);
> +  even = FFMAX(0, even);
> +  odd  = FFMIN(1023, odd);
> +  odd  = FFMAX(0, odd);
>

av_clip functions to do this.


> +  output[i] = even;
> +  output[i + linesize] = odd;
> +  low++;
> +  high++;
> +}
> +}
>

Probably need to validate you haven't overread buffer with peak detection.

Kieran
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v4 1/3] avformat: add fields to AVProgram/AVStream for PMT change tracking

2018-05-21 Thread Aman Gupta
On Sun, May 20, 2018 at 12:55 PM, Michael Niedermayer <
mich...@niedermayer.cc> wrote:

> On Sun, May 20, 2018 at 11:37:22AM -0700, Aman Gupta wrote:
> > On Sat, May 19, 2018 at 2:56 PM James Almer  wrote:
> >
> > > On 5/19/2018 6:31 PM, Michael Niedermayer wrote:
> > > > On Fri, May 18, 2018 at 11:15:04AM -0700, Aman Gupta wrote:
> > > >> From: Aman Gupta 
> > > >>
> > > >> These fields will allow the mpegts demuxer to expose details about
> > > >> the PMT/program which created the AVProgram and its AVStreams.
> > > >>
> > > >> In mpegts, a PMT which advertises streams has a version number
> > > >> which can be incremented at any time. When the version changes,
> > > >> the pids which correspond to each of it's streams can also change.
> > > >>
> > > >> Since ffmpeg creates a new AVStream per pid by default, an API user
> > > >> needs the ability to (a) detect when the PMT changed, and (b) tell
> > > >> which AVStream were added to replace earlier streams.
> > > >>
> > > >> This has been a long-standing issue with ffmpeg's handling of mpegts
> > > >> streams with PMT changes, and I found two related patches in the
> wild
> > > >> that attempt to solve the same problem.
> > > >>
> > > >> The first is in MythTV's ffmpeg fork, where they added a
> > > >> void (*streams_changed)(void*); to AVFormatContext and call it from
> > > >> their fork of the mpegts demuxer whenever the PMT changes.
> > > >>
> > > >> The second was proposed by XBMC in
> > > >> https://ffmpeg.org/pipermail/ffmpeg-devel/2012-December/135036.html
> ,
> > > >> where they created a new AVMEDIA_TYPE_DATA stream with id=0 and
> > > >> attempted to send packets to it whenever the PMT changed.
> > > >>
> > > >> Signed-off-by: Aman Gupta 
> > > >> ---
> > > >>  doc/APIchanges | 4 
> > > >>  libavformat/avformat.h | 8 
> > > >>  libavformat/utils.c| 1 +
> > > >>  libavformat/version.h  | 2 +-
> > > >>  4 files changed, 14 insertions(+), 1 deletion(-)
> > > >>
> > > >> diff --git a/doc/APIchanges b/doc/APIchanges
> > > >> index befa58c84a..a592073ca5 100644
> > > >> --- a/doc/APIchanges
> > > >> +++ b/doc/APIchanges
> > > >> @@ -15,6 +15,10 @@ libavutil: 2017-10-21
> > > >>
> > > >>  API changes, most recent first:
> > > >>
> > > >> +2018-05-xx - xx - lavf 58.15.100 - avformat.h
> > > >> +  Add pmt_version field to AVProgram
> > > >> +  Add program_num, pmt_version, pmt_stream_idx to AVStream
> > > >> +
> > > >>  2018-05-xx - xx - lavf 58.14.100 - avformat.h
> > > >>Add AV_DISPOSITION_STILL_IMAGE
> > > >>
> > > >> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> > > >> index 6dce88fad5..ade918f99c 100644
> > > >> --- a/libavformat/avformat.h
> > > >> +++ b/libavformat/avformat.h
> > > >> @@ -1103,6 +1103,13 @@ typedef struct AVStream {
> > > >>   */
> > > >>  int stream_identifier;
> > > >>
> > > >> +/**
> > > >> + * Details of the MPEG-TS program which created this stream.
> > > >> + */
> > > >> +int program_num;
> > > >> +int pmt_version;
> > > >> +int pmt_stream_idx;
> > > >> +
> > > >>  int64_t interleaver_chunk_size;
> > > >>  int64_t interleaver_chunk_duration;
> > > >>
> > > >
> > > > These are added below the "All fields below this line are not part of
> > > the public API."
> > > > This contradicts the addition to APIChanges
> > >
> > > If these don't need to be accessed by the API user then I'd rather keep
> > > them here than moving them to the public section. Just remove the
> > > APIChanges entry.
> > > Same thing with the AVStream pmt_version field. If direct access is not
> > > needed for it, then it should be moved below the public notice.
> > >
> > > These fields seem pretty specific to one demuxer so ideally they
> > > shouldn't be public in case changes to them and the implementation are
> > > ever needed.
> >
> >
> > Yes they are specific to mpegts, and also may need to change in the
> future.
> >
> > These were intended to be used in conjunction with the existing
> > AVStream.stream_identifier, which is also mpegts-specific. It appears in
> > the private section, even though the field is only written to from
> mpegts.c
> > and never used anywhere else in avformat. Clearly it was added to be used
> > by API users, but it too lives in the private section.
> >
>
> > It seems like the best course forward is to remove APIchanges entries.
> The
> > fields are there if a user really needs to access them, but they are
> > considered private which means we can change them later if need be to
> > evolve support. In this case, should I revert the version bump as well?
> Or
> > is that still required since the ABI changed (even though it was in the
> > private section).
>
> Iam not sure i understand what you suggest but if a field is added in the
> private section then a user app cannot reliably access it. (It would move
> in memory the next time a public field is added)
>
> Also if the ABI changes in the future then any users using the AP

Re: [FFmpeg-devel] [PATCH] avcodec/avformat: Add Camera Motion Metadata support

2018-05-21 Thread Rostislav Pehlivanov
On 21 May 2018 at 19:52, Erik Ackermann  wrote:

> Spec: https://developers.google.com/streetview/publish/camm-spec
>
> The Lenovo Mirage camera launched recently and outputs this metadata track
> in its videos.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
This should be outputted as side data rather than as a separate stream, if
possible, even if the demuxer needs hacks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avformat/mpegts: set AV_DISPOSITION_DESCRIPTIONS for OIPF cases

2018-05-21 Thread Aman Gupta
On Sun, May 20, 2018 at 11:09 PM, Łukasz Krzciuk  wrote:

> Any updates on this issue?
>

I believe that this patch was already merged:
https://github.com/FFmpeg/FFmpeg/commit/48330500efd636b1540002b600257d8802badc69


>
> Regards,
>
> *Łukasz Krzciuk*
> Developer
>
> Vewd
> ul. Grabarska 2, Pegaz 2A, 50-079 Wrocław, Polska
>
>
> On Tue, May 15, 2018 at 12:51 PM, Łukasz Krzciuk 
> wrote:
>
> > I have prepared a testcase. PMT data comes from org.hbbtv_HTML50420 - I
> > have squashed them and there is one file attached now. Please review.
> >
> > Regards,
> >
> > *Łukasz Krzciuk*
> > Developer
> >
> > Vewd
> > ul. Grabarska 2, Pegaz 2A, 50-079 Wrocław, Polska
> >
> >
> > On Mon, May 14, 2018 at 10:23 AM, Łukasz Krzciuk 
> > wrote:
> >
> >> I have prepared a testcase. PMT data comes from org.hbbtv_HTML50420.
> Please
> >> review.
> >>
> >> Regards,
> >>
> >> *Łukasz Krzciuk*
> >> Developer
> >>
> >> Vewd
> >> ul. Grabarska 2, Pegaz 2A, 50-079 Wrocław, Polska
> >>
> >>
> >> On Thu, May 10, 2018 at 8:54 PM, Aman Gupta  wrote:
> >>
> >>> On Thu, May 10, 2018 at 1:46 AM Łukasz Krzciuk 
> >>> wrote:
> >>>
> >>> > Lets skip a testcase. It will be not easy to me to prepare it.
> >>>
> >>>
> >>> It should be simple to extract a small sample containing the PMT. If
> you
> >>> link some larger samples I can help extract the relevant bytes for test
> >>> case.
> >>>
> >>> Aman
> >>>
> >>>
> >>> >
> >>> > Regards,
> >>> >
> >>> > *Łukasz Krzciuk*
> >>> > Developer
> >>> >
> >>> > Vewd
> >>> > ul. Grabarska 2
> >>> > , Pegaz
> >>> 2A,
> >>> > 50-079 Wrocław, Polska
> >>> >
> >>> >
> >>> > On Thu, May 10, 2018 at 3:09 AM, Michael Niedermayer
> >>> >  >>> > > wrote:
> >>> >
> >>> > > On Wed, May 09, 2018 at 10:19:26AM +0200, Łukasz Krzciuk wrote:
> >>> > > > Any updates on this issue?
> >>> > >
> >>> > > about adding a testcase ?
> >>> > > adding a huge sample file is not possible.
> >>> > > It either has to be made smaller or generated by a muxer
> >>> > > or last resort, no test
> >>> > >
> >>> > > [...]
> >>> > > --
> >>> > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC7
> >>> 87040B0FAB
> >>> > >
> >>> > > The worst form of inequality is to try to make unequal things
> equal.
> >>> > > -- Aristotle
> >>> > >
> >>> > > ___
> >>> > > ffmpeg-devel mailing list
> >>> > > ffmpeg-devel@ffmpeg.org
> >>> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>> > >
> >>> > >
> >>> > ___
> >>> > ffmpeg-devel mailing list
> >>> > ffmpeg-devel@ffmpeg.org
> >>> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>> >
> >>> ___
> >>> ffmpeg-devel mailing list
> >>> ffmpeg-devel@ffmpeg.org
> >>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>>
> >>
> >>
> >
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/libvpxenc: fix setting amount of threads used for encoding

2018-05-21 Thread James Zern
On Sat, May 19, 2018 at 11:16 AM James Almer  wrote:

> The libvpx doxy says that a value of 0 for the g_threads field is
> equivalent to a value of 1, whereas for avctx->thread_count it means
> the maximum amount of threads possible for the host system.

> Use av_cpu_count() to get the correct thread count when auto threads
> is requested.

> Signed-off-by: James Almer 
> ---
>   libavcodec/libvpxenc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)


lgtm, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavfi: a minor fix to tonemap peak detection.

2018-05-21 Thread Vittorio Giovara
On Mon, May 21, 2018 at 2:58 AM, Ruiling Song 
wrote:

> If the transfer was SMPTE2084, use the peak of 1 even if not tagged.
> Otherwise, we would assume it is HLG with a peak of 1200.
> Based on suggestion by Niklas Haas.
>
> Signed-off-by: Ruiling Song 
> ---
>  libavfilter/vf_tonemap.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
> index 10308bd..ab45f2e 100644
> --- a/libavfilter/vf_tonemap.c
> +++ b/libavfilter/vf_tonemap.c
> @@ -131,10 +131,9 @@ static double determine_signal_peak(AVFrame *in)
>  peak = av_q2d(metadata->max_luminance) / REFERENCE_WHITE;
>  }
>
> -/* smpte2084 needs the side data above to work correctly
> - * if missing, assume that the original transfer was arib-std-b67 */
> +/* if not SMPTE2084, we would assume HLG */
>  if (!peak)
> -peak = 12;
> +peak = in->color_trc == AVCOL_TRC_SMPTE2084 ? 100 : 12;
>
>  return peak;
>  }
> --
> 2.7.4
>
>
seems reasonable
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 2/2] libavformat/mov: recognize udta name tag as the stream title

2018-05-21 Thread Nik Johnson
Some muxers write the stream title in a udta atom with the tag 'name'.
Recognize 'name' tags as the stream title instead of an unknown tag.

Signed-off-by: Nik Johnson 
---
[v2: Add raw = 1]

 libavformat/mov.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5332d48eb1..09e3096a06 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -340,6 +340,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return mov_metadata_loci(c, pb, atom.size);
 case MKTAG( 'm','a','n','u'): key = "make"; break;
 case MKTAG( 'm','o','d','l'): key = "model"; break;
+case MKTAG( 'n','a','m','e'): key = "title"; raw = 1; break;
 case MKTAG( 'p','c','s','t'): key = "podcast";
 parse = mov_metadata_int8_no_padding; break;
 case MKTAG( 'p','g','a','p'): key = "gapless_playback";
-- 
2.17.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 1/2] libavformat/mov: treat udta atoms within trak atoms as stream metadata

2018-05-21 Thread Nik Johnson
Some muxers produce mp4s with a udta (user data) atom nested within a
trak atom. The nested udta atoms typically contain stream information
such as the title. ffmpeg should treat nested udta atoms as applicable
to the stream instead of globally.

Signed-off-by: Nik Johnson 
---
[v2: No changes]

 libavformat/mov.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1975011741..5332d48eb1 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -306,6 +306,8 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL;
 int raw = 0;
 int num = 0;
+AVStream *st;
+AVDictionary **metadata;
 
 switch (atom.type) {
 case MKTAG( '@','P','R','M'): key = "premiere_version"; raw = 1; break;
@@ -514,12 +516,23 @@ retry:
 }
 str[str_size] = 0;
 }
-c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
-av_dict_set(&c->fc->metadata, key, str, 0);
+
+// A udta atom may occur inside a trak atom when specifying trak
+// specific user data. For example, some muxers define a trak name.
+if (c->fc->nb_streams > 0 && c->trak_index != -1) {
+st = c->fc->streams[c->fc->nb_streams-1];
+st->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
+metadata = &st->metadata;
+} else {
+c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
+metadata = &c->fc->metadata;
+}
+av_dict_set(metadata, key, str, 0);
 if (*language && strcmp(language, "und")) {
 snprintf(key2, sizeof(key2), "%s-%s", key, language);
-av_dict_set(&c->fc->metadata, key2, str, 0);
+av_dict_set(metadata, key2, str, 0);
 }
+
 if (!strcmp(key, "encoder")) {
 int major, minor, micro;
 if (sscanf(str, "HandBrake %d.%d.%d", &major, &minor, µ) == 
3) {
-- 
2.17.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/avformat: Add Camera Motion Metadata support

2018-05-21 Thread Erik Ackermann
Spec: https://developers.google.com/streetview/publish/camm-spec

The Lenovo Mirage camera launched recently and outputs this metadata track
in its videos.
From 937a49d00139edfc8cc5eda9234c2b8afbaa4773 Mon Sep 17 00:00:00 2001
From: Erik Ackermann 
Date: Mon, 21 May 2018 11:42:04 -0700
Subject: [PATCH] Add support for Camera Motion Metadata ('camm') track.

https://developers.google.com/streetview/publish/camm-spec
---
 libavcodec/avcodec.h| 1 +
 libavcodec/codec_desc.c | 6 ++
 libavformat/isom.c  | 1 +
 libavformat/mov.c   | 2 ++
 libavformat/movenc.c| 9 +
 5 files changed, 19 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fb0c6fae70..920b2b519a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -689,6 +689,7 @@ enum AVCodecID {
 * stream (only used by libavformat) */
 AV_CODEC_ID_FFMETADATA = 0x21000,   ///< Dummy codec for streams containing only metadata information.
 AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket
+AV_CODEC_ID_CAMERA_MOTION_METADATA = 0x63616d6d,
 };
 
 /**
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 79552a910d..31d0d82a53 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3047,6 +3047,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("HDMV Text subtitle"),
 .props = AV_CODEC_PROP_TEXT_SUB,
 },
+{
+.id= AV_CODEC_ID_CAMERA_MOTION_METADATA,
+.type  = AVMEDIA_TYPE_DATA,
+.name  = "camm",
+.long_name = NULL_IF_CONFIG_SMALL("camera motion metadata"),
+},
 
 /* other kind of codecs and pseudo-codecs */
 {
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 2792371c25..44b303f687 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -69,6 +69,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
 { AV_CODEC_ID_QCELP   , 0xE1 },
 { AV_CODEC_ID_MPEG4SYSTEMS, 0x01 },
 { AV_CODEC_ID_MPEG4SYSTEMS, 0x02 },
+{ AV_CODEC_ID_CAMERA_MOTION_METADATA, MKTAG('c', 'a', 'm', 'm') },
 { AV_CODEC_ID_NONE,0 },
 };
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1340bf3913..080b152c73 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2327,6 +2327,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 }
 }
 }
+} else if (st->codecpar->codec_tag == MKTAG('c','a','m','m')) {
+  st->codecpar->codec_id = AV_CODEC_ID_CAMERA_MOTION_METADATA;
 } else {
 /* other codec type, just skip (rtp, mp4s ...) */
 avio_skip(pb, size);
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index d03d7906a1..8828efd898 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2177,6 +2177,12 @@ static int mov_write_stsd_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext
 mov_write_tmcd_tag(pb, track);
 else if (track->par->codec_tag == MKTAG('g','p','m','d'))
 mov_write_gpmd_tag(pb, track);
+else if (track->par->codec_tag == MKTAG('c', 'a', 'm', 'm')) {
+avio_wb32(pb, 16); /* size */
+avio_wl32(pb, track->par->codec_tag); /* tag */
+avio_wb32(pb, 0); /* reserved */
+avio_wb32(pb, 0); /* data reference index*/
+}
 return update_size(pb, pos);
 }
 
@@ -2567,6 +2573,9 @@ static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra
 } else if (track->par->codec_tag == MKTAG('g','p','m','d')) {
 hdlr_type = "meta";
 descr = "GoPro MET"; // GoPro Metadata
+} else if (track->par->codec_tag == MKTAG('c','a','m','m')) {
+hdlr_type = "meta";
+descr = "MetadataHandler";
 } else {
 av_log(s, AV_LOG_WARNING,
"Unknown hldr_type for %s, writing dummy values\n",
-- 
2.17.0.441.gb46fe60e1d-goog

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavc/cfhd: deinterlacing introduced in cfhd

2018-05-21 Thread Gagandeep Singh
---
 libavcodec/cfhd.c | 177 +-
 libavcodec/cfhd.h |   9 +++
 2 files changed, 158 insertions(+), 28 deletions(-)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 7ceb803595..d70c13592c 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -49,12 +49,15 @@ enum CFHDParam {
 SubbandNumber=  48,
 Quantization =  53,
 ChannelNumber=  62,
+SampleFlags  =  68,
 BitsPerComponent = 101,
 ChannelWidth = 104,
 ChannelHeight= 105,
 PrescaleShift= 109,
 };
 
+
+
 static av_cold int cfhd_init(AVCodecContext *avctx)
 {
 CFHDContext *s = avctx->priv_data;
@@ -72,6 +75,13 @@ static void init_plane_defaults(CFHDContext *s)
 s->subband_num_actual = 0;
 }
 
+static void init_peak_table_defaults(CFHDContext *s)
+{
+s->peak.level  = 0;
+s->peak.offset = 0;
+s->peak.base   = NULL;
+}
+
 static void init_frame_defaults(CFHDContext *s)
 {
 s->coded_width   = 0;
@@ -86,15 +96,45 @@ static void init_frame_defaults(CFHDContext *s)
 s->wavelet_depth = 3;
 s->pshift= 1;
 s->codebook  = 0;
+s->difference_coding = 0;
+s->progressive   = 0;
 init_plane_defaults(s);
+init_peak_table_defaults(s);
 }
 
 /* TODO: merge with VLC tables or use LUT */
-static inline int dequant_and_decompand(int level, int quantisation)
+static inline int dequant_and_decompand(int level, int quantisation, int 
codebook)
 {
-int64_t abslevel = abs(level);
-return (abslevel + ((768 * abslevel * abslevel * abslevel) / (255 * 255 * 
255))) *
-   FFSIGN(level) * quantisation;
+if (codebook == 0 || codebook == 1) {
+int64_t abslevel = abs(level);
+if (level < 264)
+return (abslevel + ((768 * abslevel * abslevel * abslevel) / (255 
* 255 * 255))) *
+   FFSIGN(level) * quantisation;
+else
+return level * quantisation;
+  }
+else
+return level * quantisation;
+}
+
+static inline void difference_coding(int16_t *band, int width, int height)
+{
+
+int i,j;
+for (i = 0; i < height; i++) {
+  for (j = 1; j < width; j++) {
+band[j] += band[j-1];
+  }
+  band += width;
+}
+}
+
+static inline void peak_table(int16_t *band, Peak *peak, int length)
+{
+int i;
+for (i = 0; i < length; i++)
+if (abs(band[i]) > peak->level)
+band[i] = *(++peak->base);
 }
 
 static inline void process_alpha(int16_t *alpha, int width)
@@ -154,6 +194,26 @@ static inline void filter(int16_t *output, ptrdiff_t 
out_stride,
 }
 }
 
+static inline void interlaced_vertical_filter(int16_t *output, int16_t *low, 
int16_t *high,
+ int width, int linesize, int plane)
+{
+int i;
+int16_t even, odd;
+for (i = 0; i < width; i++) {
+  even = (*low - *high)/2;
+  odd  = (*low + *high)/2;
+
+  even = FFMIN(1023, even);
+  even = FFMAX(0, even);
+  odd  = FFMIN(1023, odd);
+  odd  = FFMAX(0, odd);
+
+  output[i] = even;
+  output[i + linesize] = odd;
+  low++;
+  high++;
+}
+}
 static void horiz_filter(int16_t *output, int16_t *low, int16_t *high,
  int width)
 {
@@ -295,6 +355,9 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 uint16_t data   = bytestream2_get_be16(&gb);
 if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) {
 av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 
16) | data);
+} else if (tag == SampleFlags) {
+av_log(avctx, AV_LOG_DEBUG, "Progressive?%"PRIu16"\n", data);
+s->progressive = data & 0x0001;
 } else if (tag == ImageWidth) {
 av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data);
 s->coded_width = data;
@@ -393,6 +456,8 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 }
 av_log(avctx, AV_LOG_DEBUG, "Transform-type? %"PRIu16"\n", data);
 } else if (abstag >= 0x4000 && abstag <= 0x40ff) {
+if (abstag == 0x4001)
+s->peak.level = 0;
 av_log(avctx, AV_LOG_DEBUG, "Small chunk length %d %s\n", data * 
4, tag < 0 ? "optional" : "required");
 bytestream2_skipu(&gb, data * 4);
 } else if (tag == 23) {
@@ -450,7 +515,8 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 s->codebook = data;
 av_log(avctx, AV_LOG_DEBUG, "Codebook %i\n", s->codebook);
 } else if (tag == 72) {
-s->codebook = data;
+s->codebook = data & 0xf;
+s->difference_coding = (data >> 4) & 1;
 av_log(avctx, AV_LOG_DEBUG, "Other codebook? %i\n", s->codebook);
 } else if (tag == 70) {
 av_log(avctx, AV_LOG_DEBUG, "Subsampling or bit-depth flag? %i\n", 
data);
@@ -477,6 +543,19 @@ static int cfhd_decode(AV

Re: [FFmpeg-devel] null metadata for the first decoded video frame

2018-05-21 Thread Aman Gupta
On Mon, May 21, 2018 at 10:29 AM Alexander Ivash  wrote:

> I'm not injecting metadata, but reading it! Here:
>
> https://github.com/ElderOrb/qctools/blob/master/Source/Core/VideoStats.cpp#L287
> This function is being called for every frame. The issue is that the
> first frame returns null.


If you're talking about cropdetect metadata then it's because of this:
https://github.com/FFmpeg/FFmpeg/blob/master/libavfilter/vf_cropdetect.c#L170


>
> 2018-05-21 19:35 GMT+03:00 Paul B Mahol :
> > On 5/21/18, Alexander Ivash  wrote:
> >> What could be the reason for such a behavior besides using deprecated
> >> 'avcodec_decode_video2' ? I've also tried to experiment a bit with new
> >> API (avcodec_send_packet/avcodec_receive_frame) but this time got no
> >> metadata even for second frame (the code is here:
> >>
> https://github.com/ElderOrb/qctools/commit/aa521aac9d147f380f5d7e2716fb3410e7c5613c
> ).
> >> What I'm doing wrong?
> >
> > You are injecting metadata where exactly?
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] null metadata for the first decoded video frame

2018-05-21 Thread Alexander Ivash
I'm not injecting metadata, but reading it! Here:
https://github.com/ElderOrb/qctools/blob/master/Source/Core/VideoStats.cpp#L287
This function is being called for every frame. The issue is that the
first frame returns null.

2018-05-21 19:35 GMT+03:00 Paul B Mahol :
> On 5/21/18, Alexander Ivash  wrote:
>> What could be the reason for such a behavior besides using deprecated
>> 'avcodec_decode_video2' ? I've also tried to experiment a bit with new
>> API (avcodec_send_packet/avcodec_receive_frame) but this time got no
>> metadata even for second frame (the code is here:
>> https://github.com/ElderOrb/qctools/commit/aa521aac9d147f380f5d7e2716fb3410e7c5613c).
>> What I'm doing wrong?
>
> You are injecting metadata where exactly?
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] null metadata for the first decoded video frame

2018-05-21 Thread Paul B Mahol
On 5/21/18, Alexander Ivash  wrote:
> What could be the reason for such a behavior besides using deprecated
> 'avcodec_decode_video2' ? I've also tried to experiment a bit with new
> API (avcodec_send_packet/avcodec_receive_frame) but this time got no
> metadata even for second frame (the code is here:
> https://github.com/ElderOrb/qctools/commit/aa521aac9d147f380f5d7e2716fb3410e7c5613c).
> What I'm doing wrong?

You are injecting metadata where exactly?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] libavutil/encryption_info: Allow multiple init info.

2018-05-21 Thread Jacob Trimble
On Mon, May 14, 2018 at 4:49 PM, Jacob Trimble  wrote:
> On Tue, May 8, 2018 at 3:47 PM, Michael Niedermayer
>  wrote:
>> On Mon, May 07, 2018 at 04:59:33PM -0700, Jacob Trimble wrote:
>>> On Mon, May 7, 2018 at 3:18 PM, Michael Niedermayer
>>>  wrote:
>>> > On Mon, Apr 23, 2018 at 11:03:57AM -0700, Jacob Trimble wrote:
>>> >> While integrating my encryption info changes, I noticed a problem with
>>> >> the init info structs.  I implemented them as side-data on the Stream.
>>> >> But this means there can only be one per stream.  However, there can
>>> >> be multiple 'pssh' atoms in a single stream (e.g. for key rotation or
>>> >> multiple key systems). (sorry for not noticing sooner)
>>> >>
>>> >> Attached is a patch to fix this by making the init info a
>>> >> singly-linked-list.  It is ABI compatible and is still easy to use and
>>> >> understand.  The alternative would be to break ABI and have the
>>> >> side-data methods return an array of pointers.  I could do that
>>> >> instead if that is preferable.
>>> >
>>> >>  encryption_info.c |  154 
>>> >> +++---
>>> >>  encryption_info.h |5 +
>>> >>  2 files changed, 106 insertions(+), 53 deletions(-)
>>> >> e5eecc73a6997bbd11541771372d38ea9c3972a7  
>>> >> 0001-libavutil-encryption_info-Allow-multiple-init-info.patch
>>> >> From bb941a77e882e93629d63d63059d0063b9519e29 Mon Sep 17 00:00:00 2001
>>> >> From: Jacob Trimble 
>>> >> Date: Mon, 23 Apr 2018 10:33:58 -0700
>>> >> Subject: [PATCH] libavutil/encryption_info: Allow multiple init info.
>>> >>
>>> >> It is possible for there to be multiple encryption init info structure.
>>> >> For example, to support multiple key systems or in key rotation.  This
>>> >> changes the AVEncryptionInitInfo struct to be a linked list so there
>>> >> can be multiple structs without breaking ABI.
>>> >>
>>> >> Signed-off-by: Jacob Trimble 
>>> >> ---
>>> >>  libavutil/encryption_info.c | 154 +++-
>>> >>  libavutil/encryption_info.h |   5 ++
>>> >>  2 files changed, 106 insertions(+), 53 deletions(-)
>>> >>
>>> >> diff --git a/libavutil/encryption_info.c b/libavutil/encryption_info.c
>>> >> index 20a752d6b4..9935c10d74 100644
>>> >> --- a/libavutil/encryption_info.c
>>> >> +++ b/libavutil/encryption_info.c
>>> >> @@ -160,13 +160,16 @@ uint8_t *av_encryption_info_add_side_data(const 
>>> >> AVEncryptionInfo *info, size_t *
>>> >>  }
>>> >>
>>> >>  // The format of the AVEncryptionInitInfo side data:
>>> >> -// u32be system_id_size
>>> >> -// u32be num_key_ids
>>> >> -// u32be key_id_size
>>> >> -// u32be data_size
>>> >> -// u8[system_id_size] system_id
>>> >> -// u8[key_id_size][num_key_id] key_ids
>>> >> -// u8[data_size] data
>>> >> +// u32be init_info_count
>>> >> +// {
>>> >> +//   u32be system_id_size
>>> >> +//   u32be num_key_ids
>>> >> +//   u32be key_id_size
>>> >> +//   u32be data_size
>>> >> +//   u8[system_id_size] system_id
>>> >> +//   u8[key_id_size][num_key_id] key_ids
>>> >> +//   u8[data_size] data
>>> >> +// }[init_info_count]
>>> >>
>>> >>  #define FF_ENCRYPTION_INIT_INFO_EXTRA 16
>>> >>
>>> >> @@ -215,6 +218,7 @@ void 
>>> >> av_encryption_init_info_free(AVEncryptionInitInfo *info)
>>> >>  for (i = 0; i < info->num_key_ids; i++) {
>>> >>  av_free(info->key_ids[i]);
>>> >>  }
>>> >> +av_encryption_init_info_free(info->next);
>>> >>  av_free(info->system_id);
>>> >>  av_free(info->key_ids);
>>> >>  av_free(info->data);
>>> >> @@ -225,71 +229,115 @@ void 
>>> >> av_encryption_init_info_free(AVEncryptionInitInfo *info)
>>> >>  AVEncryptionInitInfo *av_encryption_init_info_get_side_data(
>>> >>  const uint8_t *side_data, size_t side_data_size)
>>> >>  {
>>> >> -AVEncryptionInitInfo *info;
>>> >> +AVEncryptionInitInfo *ret = NULL, *info;
>>> >>  uint64_t system_id_size, num_key_ids, key_id_size, data_size, i;
>>> >> +uint64_t init_info_count;
>>> >>
>>> >> -if (!side_data || side_data_size < FF_ENCRYPTION_INIT_INFO_EXTRA)
>>> >> -return NULL;
>>> >> -
>>> >> -system_id_size = AV_RB32(side_data);
>>> > [...]
>>> >> +init_info_count = AV_RB32(side_data);
>>> >
>>> > i may be missing something but this looks like the meaning of the first
>>> > field changes, this thus doesnt look compatible to me
>>>
>>> It changes the binary format of the side-data, but that was explicitly
>>> not part of ABI.  The fields in the structs are unchanged.  This would
>>> only cause a problem if the side data bytes were stored out-of-band
>>> from a different version of FFmpeg.
>>
>> yes, right.
>> its side data that is neighter a C struct nor a well defined byte stream
>> its a opaque block that can only be passed to libavutil which then translates
>> it into a C struct.
>> its not new but it still feels clumsy to use this as means to pass data 
>> around
>>
>
> I know it's weird, but this was the design that was decided on when
> this was added.  Are th

[FFmpeg-devel] null metadata for the first decoded video frame

2018-05-21 Thread Alexander Ivash
What could be the reason for such a behavior besides using deprecated
'avcodec_decode_video2' ? I've also tried to experiment a bit with new
API (avcodec_send_packet/avcodec_receive_frame) but this time got no
metadata even for second frame (the code is here:
https://github.com/ElderOrb/qctools/commit/aa521aac9d147f380f5d7e2716fb3410e7c5613c).
What I'm doing wrong?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] libavformat/mov: recognize udta name tag as the stream title

2018-05-21 Thread Nik Johnson
Some muxers write the stream title in a udta atom with the tag 'name'.
Recognize 'name' tags as the stream title instead of an unknown tag.

Signed-off-by: Nik Johnson 
---
 libavformat/mov.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 5332d48eb1..d0856665b6 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -340,6 +340,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return mov_metadata_loci(c, pb, atom.size);
 case MKTAG( 'm','a','n','u'): key = "make"; break;
 case MKTAG( 'm','o','d','l'): key = "model"; break;
+case MKTAG( 'n','a','m','e'): key = "title"; break;
 case MKTAG( 'p','c','s','t'): key = "podcast";
 parse = mov_metadata_int8_no_padding; break;
 case MKTAG( 'p','g','a','p'): key = "gapless_playback";
-- 
2.17.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] libavformat/mov: treat udta atoms within trak atoms as stream metadata

2018-05-21 Thread Nik Johnson
Some muxers produce mp4s with a udta (user data) atom nested within a
trak atom. The nested udta atoms typically contain stream information
such as the title. ffmpeg should treat nested udta atoms as applicable
to the stream instead of globally.

Signed-off-by: Nik Johnson 
---
 libavformat/mov.c | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1975011741..5332d48eb1 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -306,6 +306,8 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL;
 int raw = 0;
 int num = 0;
+AVStream *st;
+AVDictionary **metadata;
 
 switch (atom.type) {
 case MKTAG( '@','P','R','M'): key = "premiere_version"; raw = 1; break;
@@ -514,12 +516,23 @@ retry:
 }
 str[str_size] = 0;
 }
-c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
-av_dict_set(&c->fc->metadata, key, str, 0);
+
+// A udta atom may occur inside a trak atom when specifying trak
+// specific user data. For example, some muxers define a trak name.
+if (c->fc->nb_streams > 0 && c->trak_index != -1) {
+st = c->fc->streams[c->fc->nb_streams-1];
+st->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
+metadata = &st->metadata;
+} else {
+c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
+metadata = &c->fc->metadata;
+}
+av_dict_set(metadata, key, str, 0);
 if (*language && strcmp(language, "und")) {
 snprintf(key2, sizeof(key2), "%s-%s", key, language);
-av_dict_set(&c->fc->metadata, key2, str, 0);
+av_dict_set(metadata, key2, str, 0);
 }
+
 if (!strcmp(key, "encoder")) {
 int major, minor, micro;
 if (sscanf(str, "HandBrake %d.%d.%d", &major, &minor, µ) == 
3) {
-- 
2.17.0.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libavformat: add mbedTLS based TLS

2018-05-21 Thread James Almer
On 5/21/2018 8:27 AM, Thomas Volkert wrote:
> Hi,
> 
> On 14.05.2018 19:04, Dave Gregory wrote:
>> Hi all,
>>
>> [..comparison with alternative TLS implementations..]
> 
> Ping.
> 
> I still suggest to support mbedTLS in FFmpeg because it is especially
> interesting for embedded devices.
> 
> Best regards,
> Thomas.

I'll apply it later today. Thank you for the benchmarks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/8] ffserver: Implement lua config file reader

2018-05-21 Thread James Darnley
On 2018-05-20 20:53, Stephan Holljes wrote:
> +#include 
> +#include 
> +#include 

That's not portable.  Lua headers are not in a subdirectory.

> +int configs_read(struct HTTPDConfig **configs, const char *filename)
> +{
> +int ret = 0;
> +int nb_configs = 0;
> +int nb_streams = 0;
> +int nb_formats = 0;
> +int i;
> +int index = 0;
> +const char *key, *error;
> +struct HTTPDConfig *parsed_configs = NULL;
> +struct HTTPDConfig *config;
> +struct StreamConfig *stream;
> +lua_State *L = luaL_newstate();
> +ret = luaL_loadfile(L, filename);
> +if (ret != 0) {
> +fprintf(stderr, "Unable to open config file: %s\n", lua_tostring(L, 
> -1));
> +lua_close(L);
> +return -1;
> +}
> +
> +ret = lua_pcall(L, 0, 0, 0);
> +
> +if (ret != 0) {
> +fprintf(stderr, "Unable to read config file: %s\n", lua_tostring(L, 
> -1));
> +lua_close(L);
> +return -1;
> +}
> +lua_getglobal(L, "settings");
> +if (lua_type(L, -1) != LUA_TTABLE) {
> +lua_pushstring(L, "Error \"settings\" is not a table");
> +goto fail;
> +}
> +lua_pushnil(L);
> +
> +// iterate servers
> +while (lua_next(L, -2) != 0) {
> +nb_configs++;
> +parsed_configs = av_realloc(parsed_configs, nb_configs * 
> sizeof(struct HTTPDConfig));
> +config = &parsed_configs[nb_configs - 1];
> +config->server_name = NULL;
> +config->bind_address = NULL;
> +config->port = 0;
> +config->accept_timeout = 1000;
> +config->streams = NULL;
> +config->nb_streams = 0;
> +if (lua_type(L, -2) != LUA_TSTRING) {
> +lua_pushstring(L, "Error server name is not a string.");
> +goto fail;
> +}
> +if (lua_type(L, -1) != LUA_TTABLE) {
> +lua_pushstring(L, "Error server settings is not a table.");
> +goto fail;
> +}
> +config->server_name = av_strdup(lua_tostring(L, -2));
> +lua_pushnil(L);
> +// iterate server properties
> +nb_streams = 0;
> +while(lua_next(L, -2) != 0) {
> +if (lua_type(L, -2) != LUA_TSTRING) {
> +lua_pushstring(L, "Error server property is not a string.");
> +goto fail;
> +}
> +key = lua_tostring(L, -2);
> +if (!strncmp("bind_address", key, 12)) {
> +config->bind_address = av_strdup(lua_tostring(L, -1));
> +} else if (!strncmp("port", key, 4)) {
> +config->port = (int) lua_tonumber(L, -1);
> +} else {
> +// keys that are not "bind_address" or "port" are streams
> +if (lua_type(L, -1) != LUA_TTABLE) {
> +lua_pushstring(L, "Error Stream configuration is not a 
> table.");
> +goto fail;
> +}
> +
> +nb_streams++;
> +config->streams = av_realloc(config->streams, nb_streams * 
> sizeof(struct StreamConfig));
> +stream = &config->streams[nb_streams - 1];
> +stream->input_uri = NULL;
> +stream->formats = NULL;
> +stream->stream_name = av_strdup(lua_tostring(L, -2));
> +lua_pushnil(L);
> +while(lua_next(L, -2) != 0) {
> +if (lua_type(L, -2) != LUA_TSTRING) {
> +lua_pushstring(L, "Error stream property is not a 
> string.");
> +goto fail;
> +}
> +key = lua_tostring(L, -2);
> +if (!strncmp("input", key, 5)) {
> +stream->input_uri = av_strdup(lua_tostring(L, -1));
> +} else if (!strncmp("formats", key, 7)) {
> +index = 1;
> +nb_formats = 0;
> +lua_pushnumber(L, index);
> +while(1) {
> +lua_gettable(L, -2);
> +if (lua_isnil(L, -1))
> +break;
> +if (lua_type(L, -1) != LUA_TSTRING) {
> +lua_pushstring(L, "Error format name is not 
> a string.");
> +goto fail;
> +}
> +stream->formats = av_realloc(stream->formats,
> + (nb_formats + 1) * 
> sizeof(enum StreamFormat));
> +key = lua_tostring(L, -1);
> +if (!strncmp("mkv", key, 3)) {
> +stream->formats[nb_formats++] = FMT_MATROSKA;
> +} else {
> +fprintf(stderr, "Warning unknown format (%s) 
> in stream format configuration.\n",
> +

Re: [FFmpeg-devel] [PATCH] libavformat: add mbedTLS based TLS

2018-05-21 Thread Thomas Volkert
Hi,

On 14.05.2018 19:04, Dave Gregory wrote:
> Hi all,
>
> [..comparison with alternative TLS implementations..]

Ping.

I still suggest to support mbedTLS in FFmpeg because it is especially
interesting for embedded devices.

Best regards,
Thomas.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: Add support for AV_PIX_FMT_BGRA.

2018-05-21 Thread Zhong Li
RGB32(AV_PIX_FMT_BGRA on intel platforms) format may be used as overlay with 
alpha blending.
So add AV_PIX_FMT_BGRA format support.

Rename RGB32 to be BGRA to make it clearer as Mark Thompson's suggestion.

Signed-off-by: Zhong Li 
---
 libavfilter/qsvvpp.c  |  2 +-
 libavutil/hwcontext_qsv.c | 43 +--
 2 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 2c01295..88c74d8 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -142,7 +142,7 @@ static int pix_fmt_to_mfx_fourcc(int format)
 return MFX_FOURCC_NV12;
 case AV_PIX_FMT_YUYV422:
 return MFX_FOURCC_YUY2;
-case AV_PIX_FMT_RGB32:
+case AV_PIX_FMT_BGRA:
 return MFX_FOURCC_RGB4;
 }
 
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 250091c..2a979cb 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -90,6 +90,7 @@ static const struct {
 uint32_t   fourcc;
 } supported_pixel_formats[] = {
 { AV_PIX_FMT_NV12, MFX_FOURCC_NV12 },
+{ AV_PIX_FMT_BGRA, MFX_FOURCC_RGB4 },
 { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
 { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
 };
@@ -731,6 +732,36 @@ static int qsv_transfer_data_child(AVHWFramesContext *ctx, 
AVFrame *dst,
 return ret;
 }
 
+static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 
*surface)
+{
+switch (frame->format) {
+case AV_PIX_FMT_NV12:
+surface->Data.Y  = frame->data[0];
+surface->Data.UV = frame->data[1];
+break;
+
+case AV_PIX_FMT_YUV420P:
+surface->Data.Y = frame->data[0];
+surface->Data.U = frame->data[1];
+surface->Data.V = frame->data[2];
+break;
+
+case AV_PIX_FMT_BGRA:
+surface->Data.B = frame->data[0];
+surface->Data.G = frame->data[0] + 1;
+surface->Data.R = frame->data[0] + 2;
+surface->Data.A = frame->data[0] + 3;
+break;
+
+default:
+return MFX_ERR_UNSUPPORTED;
+}
+surface->Data.Pitch = frame->linesize[0];
+surface->Data.TimeStamp = frame->pts;
+
+return 0;
+}
+
 static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
   const AVFrame *src)
 {
@@ -750,11 +781,7 @@ static int qsv_transfer_data_from(AVHWFramesContext *ctx, 
AVFrame *dst,
 }
 
 out.Info = in->Info;
-out.Data.PitchLow = dst->linesize[0];
-out.Data.Y= dst->data[0];
-out.Data.U= dst->data[1];
-out.Data.V= dst->data[2];
-out.Data.A= dst->data[3];
+map_frame_to_surface(dst, &out);
 
 do {
 err = MFXVideoVPP_RunFrameVPPAsync(s->session_download, in, &out, 
NULL, &sync);
@@ -797,11 +824,7 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, 
AVFrame *dst,
 }
 
 in.Info = out->Info;
-in.Data.PitchLow = src->linesize[0];
-in.Data.Y= src->data[0];
-in.Data.U= src->data[1];
-in.Data.V= src->data[2];
-in.Data.A= src->data[3];
+map_frame_to_surface(src, &in);
 
 do {
 err = MFXVideoVPP_RunFrameVPPAsync(s->session_upload, &in, out, NULL, 
&sync);
-- 
1.8.3.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.

2018-05-21 Thread myp...@gmail.com
2018-05-21 14:50 GMT+08:00 Ruiling Song :
> This filter does HDR(HDR10/HLG) to SDR conversion with tone-mapping.
>
> An example command to use this filter with vaapi codecs:
> FFMPEG -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device \
> opencl=ocl@va -hwaccel vaapi -hwaccel_device va -hwaccel_output_format \
> vaapi -i INPUT -filter_hw_device ocl -filter_complex \
> '[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1]; \
> [x1]hwmap=derive_device=vaapi:reverse=1' -c:v hevc_vaapi -profile 2 OUTPUT
>
> Signed-off-by: Ruiling Song 
> ---
>  configure  |   1 +
>  libavfilter/Makefile   |   2 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/colorspace_basic.c |  89 ++
>  libavfilter/colorspace_basic.h |  40 +++
>  libavfilter/opencl/colorspace_basic.cl | 179 +++
>  libavfilter/opencl/tonemap.cl  | 258 +++
>  libavfilter/opencl_source.h|   2 +
>  libavfilter/vf_tonemap_opencl.c| 560 
> +
>  9 files changed, 1132 insertions(+)
>  create mode 100644 libavfilter/colorspace_basic.c
>  create mode 100644 libavfilter/colorspace_basic.h
>  create mode 100644 libavfilter/opencl/colorspace_basic.cl
>  create mode 100644 libavfilter/opencl/tonemap.cl
>  create mode 100644 libavfilter/vf_tonemap_opencl.c
>
> diff --git a/configure b/configure
> index e52f8f8..ee3586b 100755
> --- a/configure
> +++ b/configure
> @@ -3401,6 +3401,7 @@ tinterlace_filter_deps="gpl"
>  tinterlace_merge_test_deps="tinterlace_filter"
>  tinterlace_pad_test_deps="tinterlace_filter"
>  tonemap_filter_deps="const_nan"
> +tonemap_opencl_filter_deps="opencl"
>  unsharp_opencl_filter_deps="opencl"
>  uspp_filter_deps="gpl avcodec"
>  vaguedenoiser_filter_deps="gpl"
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index c68ef05..0915656 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -352,6 +352,8 @@ OBJS-$(CONFIG_TINTERLACE_FILTER) += 
> vf_tinterlace.o
>  OBJS-$(CONFIG_TLUT2_FILTER)  += vf_lut2.o framesync.o
>  OBJS-$(CONFIG_TMIX_FILTER)   += vf_mix.o framesync.o
>  OBJS-$(CONFIG_TONEMAP_FILTER)+= vf_tonemap.o
> +OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) += vf_tonemap_opencl.o 
> colorspace_basic.o opencl.o \
> +opencl/tonemap.o 
> opencl/colorspace_basic.o
>  OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
>  OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
>  OBJS-$(CONFIG_UNPREMULTIPLY_FILTER)  += vf_premultiply.o framesync.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index b44093d..6873bab 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -343,6 +343,7 @@ extern AVFilter ff_vf_tinterlace;
>  extern AVFilter ff_vf_tlut2;
>  extern AVFilter ff_vf_tmix;
>  extern AVFilter ff_vf_tonemap;
> +extern AVFilter ff_vf_tonemap_opencl;
>  extern AVFilter ff_vf_transpose;
>  extern AVFilter ff_vf_trim;
>  extern AVFilter ff_vf_unpremultiply;
> diff --git a/libavfilter/colorspace_basic.c b/libavfilter/colorspace_basic.c
> new file mode 100644
> index 000..93f9f08
> --- /dev/null
> +++ b/libavfilter/colorspace_basic.c
> @@ -0,0 +1,89 @@
> +/*
> + * 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 "colorspace_basic.h"
> +
> +
> +void invert_matrix3x3(const double in[3][3], double out[3][3])
> +{
> +double m00 = in[0][0], m01 = in[0][1], m02 = in[0][2],
> +   m10 = in[1][0], m11 = in[1][1], m12 = in[1][2],
> +   m20 = in[2][0], m21 = in[2][1], m22 = in[2][2];
> +int i, j;
> +double det;
> +
> +out[0][0] =  (m11 * m22 - m21 * m12);
> +out[0][1] = -(m01 * m22 - m21 * m02);
> +out[0][2] =  (m01 * m12 - m11 * m02);
> +out[1][0] = -(m10 * m22 - m20 * m12);
> +out[1][1] =  (m00 * m22 - m20 * m02);
> +out[1][2] = -(m00 * m12 - m10 * m02);
> +out[2][0] =  (m10 * m21 - m20 * m11);
> +out[2][1] = -(m00 * m21 - m20 * m01);
> +out[2][2] =  (m00 * m11 - m10 * m01);
> +
> +det = m00 * out[0][0] + m10 * out[0][1] + m20 * out[0][2];
> +det =