[FFmpeg-devel] [PATCH 2/2] lavf: Add coreimage filter for GPU based image filtering on OSX.

Thilo Borgmann thilo.borgmann at mail.de
Sat Mar 12 15:14:06 CET 2016


Add coreimage filter for OSX.

-Thilo
-------------- next part --------------
From 82c98fc9e27655e3e9b32adbf4122f94649359c5 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann <thilo.borgmann at mail.de>
Date: Sat, 12 Mar 2016 14:54:49 +0100
Subject: [PATCH 2/2] lavf: Add coreimage filter for GPU based image filtering
 on OSX.

---
 Changelog                |  1 +
 MAINTAINERS              |  1 +
 configure                |  3 +++
 doc/filters.texi         | 67 ++++++++++++++++++++++++++++++++++++++++++++++++
 libavfilter/Makefile     |  1 +
 libavfilter/allfilters.c |  1 +
 6 files changed, 74 insertions(+)

diff --git a/Changelog b/Changelog
index 1f57f5e..5053a86 100644
--- a/Changelog
+++ b/Changelog
@@ -12,6 +12,7 @@ version <next>:
 - ciescope filter
 - protocol blacklisting API
 - MediaCodec H264 decoding
+- coreimage filter (GPU based image filtering on OSX)
 
 
 version 3.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index 531c21d..a993a67 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -370,6 +370,7 @@ Filters:
   vf_colorbalance.c                     Paul B Mahol
   vf_colorkey.c                         Timo Rothenpieler
   vf_colorlevels.c                      Paul B Mahol
+  vf_coreimage.m                        Thilo Borgmann
   vf_deband.c                           Paul B Mahol
   vf_dejudder.c                         Nicholas Robbins
   vf_delogo.c                           Jean Delvare (CC <jdelvare at suse.com>)
diff --git a/configure b/configure
index 1b189328..fe96215 100755
--- a/configure
+++ b/configure
@@ -5255,6 +5255,7 @@ frei0r_filter_extralibs='$ldl'
 frei0r_src_filter_extralibs='$ldl'
 ladspa_filter_extralibs='$ldl'
 nvenc_encoder_extralibs='$ldl'
+coreimage_filter_extralibs="-framework QuartzCore -framework AppKit -framework OpenGL"
 
 if ! disabled network; then
     check_func getaddrinfo $network_extralibs
@@ -5483,6 +5484,8 @@ enabled avisynth          && { { check_lib2 "windows.h" LoadLibrary; } ||
                                die "ERROR: LoadLibrary/dlopen not found for avisynth"; }
 enabled cuda              && check_lib cuda.h cuInit -lcuda
 enabled chromaprint       && require chromaprint chromaprint.h chromaprint_get_version -lchromaprint
+enabled coreimage         && { check_header_oc CoreImage/CoreImage.h || die "ERROR: CoreImage.h header not found"; }
+#enabled coreimage         && { check_lib2 CoreImage/CoreImage.h CGGetActiveDisplayList -framework CoreImage; }
 enabled decklink          && { check_header DeckLinkAPI.h || die "ERROR: DeckLinkAPI.h header not found"; }
 enabled frei0r            && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
 enabled gmp               && require2 gmp gmp.h mpz_export -lgmp
diff --git a/doc/filters.texi b/doc/filters.texi
index d5d619e..7fdbe61 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -4955,6 +4955,73 @@ convolution="-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -
 Copy the input source unchanged to the output. This is mainly useful for
 testing purposes.
 
+ at anchor{coreimage}
+ at section coreimage
+
+Video filtering on GPU using Apple's CoreImage API on OSX.
+
+Hardware acceleration is based on an OpenGL context. Usually, this means it is processed by video hardware. However, software-based OpenGL implementations exist which means there is no guarantee for hardware processing. It depends on the respective OSX.
+
+There are many filters and image generators provided by Apple that come with a large variety of options. The filter has to be referenced by its name along with its options.
+
+The coreimage filter accepts the following options:
+ at table @option
+ at item list_filters
+List all available filters along with all their respective options as well as possible minimum and maximum values along with the default values.
+ at example
+    coreimage=list_filters=true
+ at end example
+
+ at item filter
+Specifiy all filters by their respective name and options.
+Use @option{list_filters} to determine all valid filter names and options.
+Numerical options are specified by a float value and are automatically clamped to their respective value range.
+Vector and color options have to be specified by a list of space separated float values. Character escaping has to be done.
+A special option name @code{default} is available to use default options for a filter.
+It is required to specify either @code{default} or at least one of the filter options.
+All omitted options are used with their default values.
+The syntax of the filter string is as follows:
+ at example
+filter=<NAME>@<OPTION>=<VALUE>[@<OPTION>=<VALUE>][@...][#<NAME>@<OPTION>=<VALUE>[@<OPTION>=<VALUE>][@...]]
+ at end example
+ at end table
+
+Several filters can be chained for successive processing without GPU-HOST transfers allowing for fast processing of complex filter chains.
+Currently, only filters with zero (generators) or exactly one (filters) input image and one output image are supported.
+Also, transition filters are not yet usable as intended.
+
+Some filters generate output images with additional padding depending on the respective filter kernel. The padding is automatically removed to ensure the filter output has the same size as the input image.
+For image generators, the size of the output image is determined by the given input image. The generators do not use the pixel information of the input image to generate their output. However, the generated output is blended onto the input image, resulting in partial or complete coverage of the output image.
+
+ at subsection Examples
+
+ at itemize
+
+ at item
+List all filters available:
+ at example
+coreimage=list_filters=true
+ at end example
+
+ at item
+Use the CIBoxBlur filter with default options to blur an image:
+ at example
+coreimage=filter=CIBoxBlur at default
+ at end example
+
+ at item
+Use a filter chain with CISepiaTone at default values and CIVignetteEffect with its center at 100x100 and a radius of 50 pixels:
+ at example
+coreimage=filter=CIBoxBlur at default#CIVignetteEffect at inputCenter=100\ 100 at inputRadius=50
+ at end example
+
+ at item
+Use nullsrc and CIQRCodeGenerator to create a QR code for the FFmpeg homepage, given as complete and escaped command-line for Apple's standard bash shell:
+ at example
+./ffmpeg -f lavfi -i nullsrc=s=100x100,coreimage=filter=CIQRCodeGenerator at inputMessage=https\\\\\://FFmpeg.org/@inputCorrectionLevel=H -frames:v 1 QRCode.png
+ at end example
+ at end itemize
+
 @section crop
 
 Crop the input video to given dimensions.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 956a077..9ce6559 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -133,6 +133,7 @@ OBJS-$(CONFIG_COLORLEVELS_FILTER)            += vf_colorlevels.o
 OBJS-$(CONFIG_COLORMATRIX_FILTER)            += vf_colormatrix.o
 OBJS-$(CONFIG_CONVOLUTION_FILTER)            += vf_convolution.o
 OBJS-$(CONFIG_COPY_FILTER)                   += vf_copy.o
+OBJS-$(CONFIG_COREIMAGE_FILTER)              += vf_coreimage.o
 OBJS-$(CONFIG_COVER_RECT_FILTER)             += vf_cover_rect.o lavfutils.o
 OBJS-$(CONFIG_CROP_FILTER)                   += vf_crop.o
 OBJS-$(CONFIG_CROPDETECT_FILTER)             += vf_cropdetect.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index e5080b5..91b0dde 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -154,6 +154,7 @@ void avfilter_register_all(void)
     REGISTER_FILTER(COLORMATRIX,    colormatrix,    vf);
     REGISTER_FILTER(CONVOLUTION,    convolution,    vf);
     REGISTER_FILTER(COPY,           copy,           vf);
+    REGISTER_FILTER(COREIMAGE,      coreimage,      vf);
     REGISTER_FILTER(COVER_RECT,     cover_rect,     vf);
     REGISTER_FILTER(CROP,           crop,           vf);
     REGISTER_FILTER(CROPDETECT,     cropdetect,     vf);
-- 
2.4.9 (Apple Git-60)



More information about the ffmpeg-devel mailing list