summaryrefslogtreecommitdiff
path: root/ext/vpx
diff options
context:
space:
mode:
Diffstat (limited to 'ext/vpx')
-rw-r--r--ext/vpx/GstVP8Enc.prs8
-rw-r--r--ext/vpx/Makefile.am34
-rwxr-xr-xext/vpx/Makefile.in985
-rwxr-xr-xext/vpx/gstvp8dec.c623
-rw-r--r--ext/vpx/gstvp8dec.h92
-rwxr-xr-xext/vpx/gstvp8enc.c2122
-rw-r--r--ext/vpx/gstvp8enc.h122
-rw-r--r--ext/vpx/gstvp8utils.c64
-rwxr-xr-xext/vpx/gstvp8utils.h30
-rwxr-xr-xext/vpx/gstvp9dec.c628
-rw-r--r--ext/vpx/gstvp9dec.h92
-rwxr-xr-xext/vpx/gstvp9enc.c1954
-rw-r--r--ext/vpx/gstvp9enc.h121
-rw-r--r--ext/vpx/plugin.c63
14 files changed, 6938 insertions, 0 deletions
diff --git a/ext/vpx/GstVP8Enc.prs b/ext/vpx/GstVP8Enc.prs
new file mode 100644
index 0000000..a013959
--- /dev/null
+++ b/ext/vpx/GstVP8Enc.prs
@@ -0,0 +1,8 @@
+[_presets_]
+version=0.10
+element-name=GstVP8Enc
+
+[Profile Realtime]
+deadline=1
+cpu-used=4
+lag-in-frames=0
diff --git a/ext/vpx/Makefile.am b/ext/vpx/Makefile.am
new file mode 100644
index 0000000..1763638
--- /dev/null
+++ b/ext/vpx/Makefile.am
@@ -0,0 +1,34 @@
+plugin_LTLIBRARIES = \
+ libgstvpx.la
+
+libgstvpx_la_SOURCES = \
+ gstvp8dec.c \
+ gstvp8enc.c \
+ gstvp8utils.c \
+ gstvp9dec.c \
+ gstvp9enc.c \
+ plugin.c
+
+libgstvpx_la_CFLAGS = \
+ $(GST_PLUGINS_BASE_CFLAGS) \
+ $(GST_BASE_CFLAGS) \
+ $(GST_CFLAGS) \
+ $(VPX_CFLAGS) \
+ -DGST_USE_UNSTABLE_API
+libgstvpx_la_LIBADD = \
+ $(GST_PLUGINS_BASE_LIBS) -lgsttag-@GST_API_VERSION@ -lgstvideo-@GST_API_VERSION@ \
+ $(GST_BASE_LIBS) $(GST_LIBS) $(VPX_LIBS)
+libgstvpx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstvpx_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
+
+noinst_HEADERS = \
+ gstvp8dec.h \
+ gstvp8enc.h \
+ gstvp9dec.h \
+ gstvp9enc.h \
+ gstvp8utils.h
+
+presetdir = $(datadir)/gstreamer-$(GST_API_VERSION)/presets
+preset_DATA = GstVP8Enc.prs
+
+EXTRA_DIST = $(preset_DATA)
diff --git a/ext/vpx/Makefile.in b/ext/vpx/Makefile.in
new file mode 100755
index 0000000..7902d06
--- /dev/null
+++ b/ext/vpx/Makefile.in
@@ -0,0 +1,985 @@
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = ext/vpx
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/depcomp $(noinst_HEADERS)
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \
+ $(top_srcdir)/common/m4/as-auto-alt.m4 \
+ $(top_srcdir)/common/m4/as-compiler-flag.m4 \
+ $(top_srcdir)/common/m4/as-gcc-inline-assembly.m4 \
+ $(top_srcdir)/common/m4/as-libtool.m4 \
+ $(top_srcdir)/common/m4/as-version.m4 \
+ $(top_srcdir)/common/m4/ax_create_stdint_h.m4 \
+ $(top_srcdir)/common/m4/gst-arch.m4 \
+ $(top_srcdir)/common/m4/gst-args.m4 \
+ $(top_srcdir)/common/m4/gst-check.m4 \
+ $(top_srcdir)/common/m4/gst-default.m4 \
+ $(top_srcdir)/common/m4/gst-dowhile.m4 \
+ $(top_srcdir)/common/m4/gst-error.m4 \
+ $(top_srcdir)/common/m4/gst-feature.m4 \
+ $(top_srcdir)/common/m4/gst-gettext.m4 \
+ $(top_srcdir)/common/m4/gst-glib2.m4 \
+ $(top_srcdir)/common/m4/gst-package-release-datetime.m4 \
+ $(top_srcdir)/common/m4/gst-platform.m4 \
+ $(top_srcdir)/common/m4/gst-plugin-docs.m4 \
+ $(top_srcdir)/common/m4/gst-plugindir.m4 \
+ $(top_srcdir)/common/m4/gst-x11.m4 \
+ $(top_srcdir)/common/m4/gst.m4 \
+ $(top_srcdir)/common/m4/gtk-doc.m4 \
+ $(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \
+ $(top_srcdir)/m4/aalib.m4 $(top_srcdir)/m4/gettext.m4 \
+ $(top_srcdir)/m4/gst-fionread.m4 $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \
+ $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
+ $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(presetdir)"
+LTLIBRARIES = $(plugin_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libgstvpx_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_libgstvpx_la_OBJECTS = libgstvpx_la-gstvp8dec.lo \
+ libgstvpx_la-gstvp8enc.lo libgstvpx_la-gstvp8utils.lo \
+ libgstvpx_la-gstvp9dec.lo libgstvpx_la-gstvp9enc.lo \
+ libgstvpx_la-plugin.lo
+libgstvpx_la_OBJECTS = $(am_libgstvpx_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+libgstvpx_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+ $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+ $(CCLD) $(libgstvpx_la_CFLAGS) $(CFLAGS) \
+ $(libgstvpx_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(libgstvpx_la_SOURCES)
+DIST_SOURCES = $(libgstvpx_la_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+DATA = $(preset_DATA)
+HEADERS = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+AALIB_CFLAGS = @AALIB_CFLAGS@
+AALIB_CONFIG = @AALIB_CONFIG@
+AALIB_LIBS = @AALIB_LIBS@
+ACLOCAL = @ACLOCAL@
+ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BZ2_LIBS = @BZ2_LIBS@
+CAIRO_CFLAGS = @CAIRO_CFLAGS@
+CAIRO_LIBS = @CAIRO_LIBS@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@
+DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@
+DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@
+DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@
+DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@
+DIRECTSOUND_CFLAGS = @DIRECTSOUND_CFLAGS@
+DIRECTSOUND_LDFLAGS = @DIRECTSOUND_LDFLAGS@
+DIRECTSOUND_LIBS = @DIRECTSOUND_LIBS@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+DV1394_CFLAGS = @DV1394_CFLAGS@
+DV1394_LIBS = @DV1394_LIBS@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ERROR_CFLAGS = @ERROR_CFLAGS@
+ERROR_CXXFLAGS = @ERROR_CXXFLAGS@
+ERROR_OBJCFLAGS = @ERROR_OBJCFLAGS@
+EXEEXT = @EXEEXT@
+FFLAGS = @FFLAGS@
+FGREP = @FGREP@
+FLAC_CFLAGS = @FLAC_CFLAGS@
+FLAC_LIBS = @FLAC_LIBS@
+GCOV = @GCOV@
+GCOV_CFLAGS = @GCOV_CFLAGS@
+GCOV_LIBS = @GCOV_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
+GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
+GIO_CFLAGS = @GIO_CFLAGS@
+GIO_LDFLAGS = @GIO_LDFLAGS@
+GIO_LIBS = @GIO_LIBS@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_EXTRA_CFLAGS = @GLIB_EXTRA_CFLAGS@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_MKENUMS = @GLIB_MKENUMS@
+GLIB_PREFIX = @GLIB_PREFIX@
+GLIB_REQ = @GLIB_REQ@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@
+GSTPB_PREFIX = @GSTPB_PREFIX@
+GST_AGE = @GST_AGE@
+GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@
+GST_API_VERSION = @GST_API_VERSION@
+GST_BASE_CFLAGS = @GST_BASE_CFLAGS@
+GST_BASE_LIBS = @GST_BASE_LIBS@
+GST_CFLAGS = @GST_CFLAGS@
+GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@
+GST_CHECK_LIBS = @GST_CHECK_LIBS@
+GST_CONTROLLER_CFLAGS = @GST_CONTROLLER_CFLAGS@
+GST_CONTROLLER_LIBS = @GST_CONTROLLER_LIBS@
+GST_CURRENT = @GST_CURRENT@
+GST_CXXFLAGS = @GST_CXXFLAGS@
+GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@
+GST_LIBS = @GST_LIBS@
+GST_LIBVERSION = @GST_LIBVERSION@
+GST_LICENSE = @GST_LICENSE@
+GST_LT_LDFLAGS = @GST_LT_LDFLAGS@
+GST_NET_CFLAGS = @GST_NET_CFLAGS@
+GST_NET_LIBS = @GST_NET_LIBS@
+GST_OBJCFLAGS = @GST_OBJCFLAGS@
+GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@
+GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@
+GST_OPTION_OBJCFLAGS = @GST_OPTION_OBJCFLAGS@
+GST_PACKAGE_NAME = @GST_PACKAGE_NAME@
+GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@
+GST_PLUGINS_ALL = @GST_PLUGINS_ALL@
+GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@
+GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@
+GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@
+GST_PLUGINS_DIR = @GST_PLUGINS_DIR@
+GST_PLUGINS_NONPORTED = @GST_PLUGINS_NONPORTED@
+GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@
+GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@
+GST_PLUGIN_LIBTOOLFLAGS = @GST_PLUGIN_LIBTOOLFLAGS@
+GST_PREFIX = @GST_PREFIX@
+GST_REVISION = @GST_REVISION@
+GST_TOOLS_DIR = @GST_TOOLS_DIR@
+GTKDOC_CHECK = @GTKDOC_CHECK@
+GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@
+GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@
+GTKDOC_MKPDF = @GTKDOC_MKPDF@
+GTKDOC_REBASE = @GTKDOC_REBASE@
+GTK_CFLAGS = @GTK_CFLAGS@
+GTK_LIBS = @GTK_LIBS@
+GTK_X11_CFLAGS = @GTK_X11_CFLAGS@
+GTK_X11_LIBS = @GTK_X11_LIBS@
+GUDEV_CFLAGS = @GUDEV_CFLAGS@
+GUDEV_LIBS = @GUDEV_LIBS@
+HAVE_AVC1394 = @HAVE_AVC1394@
+HAVE_CXX = @HAVE_CXX@
+HAVE_DIRECTSOUND = @HAVE_DIRECTSOUND@
+HAVE_ROM1394 = @HAVE_ROM1394@
+HAVE_SPEEX = @HAVE_SPEEX@
+HAVE_X = @HAVE_X@
+HAVE_XSHM = @HAVE_XSHM@
+HAVE_ZLIB = @HAVE_ZLIB@
+HTML_DIR = @HTML_DIR@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+JACK_0_120_1_CFLAGS = @JACK_0_120_1_CFLAGS@
+JACK_0_120_1_LIBS = @JACK_0_120_1_LIBS@
+JACK_1_9_7_CFLAGS = @JACK_1_9_7_CFLAGS@
+JACK_1_9_7_LIBS = @JACK_1_9_7_LIBS@
+JACK_CFLAGS = @JACK_CFLAGS@
+JACK_LIBS = @JACK_LIBS@
+JPEG_LIBS = @JPEG_LIBS@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBCACA_CFLAGS = @LIBCACA_CFLAGS@
+LIBCACA_LIBS = @LIBCACA_LIBS@
+LIBDV_CFLAGS = @LIBDV_CFLAGS@
+LIBDV_LIBS = @LIBDV_LIBS@
+LIBICONV = @LIBICONV@
+LIBIEC61883_CFLAGS = @LIBIEC61883_CFLAGS@
+LIBIEC61883_LIBS = @LIBIEC61883_LIBS@
+LIBINTL = @LIBINTL@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBPNG_CFLAGS = @LIBPNG_CFLAGS@
+LIBPNG_LIBS = @LIBPNG_LIBS@
+LIBRT = @LIBRT@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBV4L2_CFLAGS = @LIBV4L2_CFLAGS@
+LIBV4L2_LIBS = @LIBV4L2_LIBS@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOCALEDIR = @LOCALEDIR@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+ORCC = @ORCC@
+ORCC_FLAGS = @ORCC_FLAGS@
+ORC_CFLAGS = @ORC_CFLAGS@
+ORC_LIBS = @ORC_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
+PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@
+PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
+PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@
+PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PLUGINDIR = @PLUGINDIR@
+POSUB = @POSUB@
+PROFILE_CFLAGS = @PROFILE_CFLAGS@
+PULSE_CFLAGS = @PULSE_CFLAGS@
+PULSE_LIBS = @PULSE_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+RAW1394_CFLAGS = @RAW1394_CFLAGS@
+RAW1394_LIBS = @RAW1394_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SHOUT2_CFLAGS = @SHOUT2_CFLAGS@
+SHOUT2_LIBS = @SHOUT2_LIBS@
+SOUP_CFLAGS = @SOUP_CFLAGS@
+SOUP_LIBS = @SOUP_LIBS@
+SPEEX_CFLAGS = @SPEEX_CFLAGS@
+SPEEX_LIBS = @SPEEX_LIBS@
+STRIP = @STRIP@
+TAGLIB_CFLAGS = @TAGLIB_CFLAGS@
+TAGLIB_CXXFLAGS = @TAGLIB_CXXFLAGS@
+TAGLIB_LIBS = @TAGLIB_LIBS@
+USE_NLS = @USE_NLS@
+VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
+VALGRIND_LIBS = @VALGRIND_LIBS@
+VALGRIND_PATH = @VALGRIND_PATH@
+VERSION = @VERSION@
+VPX_130_CFLAGS = @VPX_130_CFLAGS@
+VPX_130_LIBS = @VPX_130_LIBS@
+VPX_CFLAGS = @VPX_CFLAGS@
+VPX_LIBS = @VPX_LIBS@
+WARNING_CFLAGS = @WARNING_CFLAGS@
+WARNING_CXXFLAGS = @WARNING_CXXFLAGS@
+WARNING_OBJCFLAGS = @WARNING_OBJCFLAGS@
+WAVPACK_CFLAGS = @WAVPACK_CFLAGS@
+WAVPACK_LIBS = @WAVPACK_LIBS@
+XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@
+XDAMAGE_LIBS = @XDAMAGE_LIBS@
+XFIXES_CFLAGS = @XFIXES_CFLAGS@
+XFIXES_LIBS = @XFIXES_LIBS@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
+XMKMF = @XMKMF@
+XSHM_LIBS = @XSHM_LIBS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ZLIB_LIBS = @ZLIB_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_ct_OBJC = @ac_ct_OBJC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+plugindir = @plugindir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+plugin_LTLIBRARIES = \
+ libgstvpx.la
+
+libgstvpx_la_SOURCES = \
+ gstvp8dec.c \
+ gstvp8enc.c \
+ gstvp8utils.c \
+ gstvp9dec.c \
+ gstvp9enc.c \
+ plugin.c
+
+libgstvpx_la_CFLAGS = \
+ $(GST_PLUGINS_BASE_CFLAGS) \
+ $(GST_BASE_CFLAGS) \
+ $(GST_CFLAGS) \
+ $(VPX_CFLAGS) \
+ -DGST_USE_UNSTABLE_API
+
+libgstvpx_la_LIBADD = \
+ $(GST_PLUGINS_BASE_LIBS) -lgsttag-@GST_API_VERSION@ -lgstvideo-@GST_API_VERSION@ \
+ $(GST_BASE_LIBS) $(GST_LIBS) $(VPX_LIBS)
+
+libgstvpx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstvpx_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS)
+noinst_HEADERS = \
+ gstvp8dec.h \
+ gstvp8enc.h \
+ gstvp9dec.h \
+ gstvp9enc.h \
+ gstvp8utils.h
+
+presetdir = $(datadir)/gstreamer-$(GST_API_VERSION)/presets
+preset_DATA = GstVP8Enc.prs
+EXTRA_DIST = $(preset_DATA)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/vpx/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu ext/vpx/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(plugindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(plugindir)" || exit 1; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \
+ }
+
+uninstall-pluginLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \
+ done
+
+clean-pluginLTLIBRARIES:
+ -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES)
+ @list='$(plugin_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+libgstvpx.la: $(libgstvpx_la_OBJECTS) $(libgstvpx_la_DEPENDENCIES) $(EXTRA_libgstvpx_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(libgstvpx_la_LINK) -rpath $(plugindir) $(libgstvpx_la_OBJECTS) $(libgstvpx_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvpx_la-gstvp8dec.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvpx_la-gstvp8enc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvpx_la-gstvp8utils.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvpx_la-gstvp9dec.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvpx_la-gstvp9enc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstvpx_la-plugin.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+libgstvpx_la-gstvp8dec.lo: gstvp8dec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -MT libgstvpx_la-gstvp8dec.lo -MD -MP -MF $(DEPDIR)/libgstvpx_la-gstvp8dec.Tpo -c -o libgstvpx_la-gstvp8dec.lo `test -f 'gstvp8dec.c' || echo '$(srcdir)/'`gstvp8dec.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvpx_la-gstvp8dec.Tpo $(DEPDIR)/libgstvpx_la-gstvp8dec.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstvp8dec.c' object='libgstvpx_la-gstvp8dec.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -c -o libgstvpx_la-gstvp8dec.lo `test -f 'gstvp8dec.c' || echo '$(srcdir)/'`gstvp8dec.c
+
+libgstvpx_la-gstvp8enc.lo: gstvp8enc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -MT libgstvpx_la-gstvp8enc.lo -MD -MP -MF $(DEPDIR)/libgstvpx_la-gstvp8enc.Tpo -c -o libgstvpx_la-gstvp8enc.lo `test -f 'gstvp8enc.c' || echo '$(srcdir)/'`gstvp8enc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvpx_la-gstvp8enc.Tpo $(DEPDIR)/libgstvpx_la-gstvp8enc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstvp8enc.c' object='libgstvpx_la-gstvp8enc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -c -o libgstvpx_la-gstvp8enc.lo `test -f 'gstvp8enc.c' || echo '$(srcdir)/'`gstvp8enc.c
+
+libgstvpx_la-gstvp8utils.lo: gstvp8utils.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -MT libgstvpx_la-gstvp8utils.lo -MD -MP -MF $(DEPDIR)/libgstvpx_la-gstvp8utils.Tpo -c -o libgstvpx_la-gstvp8utils.lo `test -f 'gstvp8utils.c' || echo '$(srcdir)/'`gstvp8utils.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvpx_la-gstvp8utils.Tpo $(DEPDIR)/libgstvpx_la-gstvp8utils.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstvp8utils.c' object='libgstvpx_la-gstvp8utils.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -c -o libgstvpx_la-gstvp8utils.lo `test -f 'gstvp8utils.c' || echo '$(srcdir)/'`gstvp8utils.c
+
+libgstvpx_la-gstvp9dec.lo: gstvp9dec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -MT libgstvpx_la-gstvp9dec.lo -MD -MP -MF $(DEPDIR)/libgstvpx_la-gstvp9dec.Tpo -c -o libgstvpx_la-gstvp9dec.lo `test -f 'gstvp9dec.c' || echo '$(srcdir)/'`gstvp9dec.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvpx_la-gstvp9dec.Tpo $(DEPDIR)/libgstvpx_la-gstvp9dec.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstvp9dec.c' object='libgstvpx_la-gstvp9dec.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -c -o libgstvpx_la-gstvp9dec.lo `test -f 'gstvp9dec.c' || echo '$(srcdir)/'`gstvp9dec.c
+
+libgstvpx_la-gstvp9enc.lo: gstvp9enc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -MT libgstvpx_la-gstvp9enc.lo -MD -MP -MF $(DEPDIR)/libgstvpx_la-gstvp9enc.Tpo -c -o libgstvpx_la-gstvp9enc.lo `test -f 'gstvp9enc.c' || echo '$(srcdir)/'`gstvp9enc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvpx_la-gstvp9enc.Tpo $(DEPDIR)/libgstvpx_la-gstvp9enc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstvp9enc.c' object='libgstvpx_la-gstvp9enc.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -c -o libgstvpx_la-gstvp9enc.lo `test -f 'gstvp9enc.c' || echo '$(srcdir)/'`gstvp9enc.c
+
+libgstvpx_la-plugin.lo: plugin.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -MT libgstvpx_la-plugin.lo -MD -MP -MF $(DEPDIR)/libgstvpx_la-plugin.Tpo -c -o libgstvpx_la-plugin.lo `test -f 'plugin.c' || echo '$(srcdir)/'`plugin.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstvpx_la-plugin.Tpo $(DEPDIR)/libgstvpx_la-plugin.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='plugin.c' object='libgstvpx_la-plugin.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstvpx_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstvpx_la_CFLAGS) $(CFLAGS) -c -o libgstvpx_la-plugin.lo `test -f 'plugin.c' || echo '$(srcdir)/'`plugin.c
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-presetDATA: $(preset_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(preset_DATA)'; test -n "$(presetdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(presetdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(presetdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(presetdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(presetdir)" || exit $$?; \
+ done
+
+uninstall-presetDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(preset_DATA)'; test -n "$(presetdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(presetdir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(DATA) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(presetdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pluginLTLIBRARIES install-presetDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pluginLTLIBRARIES uninstall-presetDATA
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pluginLTLIBRARIES cscopelist-am ctags \
+ ctags-am distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-pluginLTLIBRARIES install-presetDATA install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
+ uninstall-am uninstall-pluginLTLIBRARIES uninstall-presetDATA
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/ext/vpx/gstvp8dec.c b/ext/vpx/gstvp8dec.c
new file mode 100755
index 0000000..fc022c7
--- /dev/null
+++ b/ext/vpx/gstvp8dec.c
@@ -0,0 +1,623 @@
+/* VP8
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2008,2009,2010 Entropy Wave Inc
+ * Copyright (C) 2010-2012 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+/**
+ * SECTION:element-vp8dec
+ * @see_also: vp8enc, matroskademux
+ *
+ * This element decodes VP8 streams into raw video.
+ * <ulink url="http://www.webmproject.org">VP8</ulink> is a royalty-free
+ * video codec maintained by <ulink url="http://www.google.com/">Google
+ * </ulink>. It's the successor of On2 VP3, which was the base of the
+ * Theora video codec.
+ *
+ * <refsect2>
+ * <title>Example pipeline</title>
+ * |[
+ * gst-launch -v filesrc location=videotestsrc.webm ! matroskademux ! vp8dec ! xvimagesink
+ * ]| This example pipeline will decode a WebM stream and decodes the VP8 video.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_VP8_DECODER
+
+#include <string.h>
+
+#include "gstvp8dec.h"
+#include "gstvp8utils.h"
+
+#include <gst/video/gstvideometa.h>
+#include <gst/video/gstvideopool.h>
+
+GST_DEBUG_CATEGORY_STATIC (gst_vp8dec_debug);
+#define GST_CAT_DEFAULT gst_vp8dec_debug
+
+#define DEFAULT_POST_PROCESSING FALSE
+#define DEFAULT_POST_PROCESSING_FLAGS (VP8_DEBLOCK | VP8_DEMACROBLOCK | VP8_MFQE)
+#define DEFAULT_DEBLOCKING_LEVEL 4
+#define DEFAULT_NOISE_LEVEL 0
+#define DEFAULT_THREADS 1
+
+enum
+{
+ PROP_0,
+ PROP_POST_PROCESSING,
+ PROP_POST_PROCESSING_FLAGS,
+ PROP_DEBLOCKING_LEVEL,
+ PROP_NOISE_LEVEL,
+ PROP_THREADS
+};
+
+#define C_FLAGS(v) ((guint) v)
+#define GST_VP8_DEC_TYPE_POST_PROCESSING_FLAGS (gst_vp8_dec_post_processing_flags_get_type())
+static GType
+gst_vp8_dec_post_processing_flags_get_type (void)
+{
+ static const GFlagsValue values[] = {
+ {C_FLAGS (VP8_DEBLOCK), "Deblock", "deblock"},
+ {C_FLAGS (VP8_DEMACROBLOCK), "Demacroblock", "demacroblock"},
+ {C_FLAGS (VP8_ADDNOISE), "Add noise", "addnoise"},
+ {C_FLAGS (VP8_MFQE), "Multi-frame quality enhancement", "mfqe"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_flags_register_static ("GstVP8DecPostProcessingFlags", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#undef C_FLAGS
+
+static void gst_vp8_dec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_vp8_dec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_vp8_dec_start (GstVideoDecoder * decoder);
+static gboolean gst_vp8_dec_stop (GstVideoDecoder * decoder);
+static gboolean gst_vp8_dec_set_format (GstVideoDecoder * decoder,
+ GstVideoCodecState * state);
+static gboolean gst_vp8_dec_flush (GstVideoDecoder * decoder);
+static GstFlowReturn gst_vp8_dec_handle_frame (GstVideoDecoder * decoder,
+ GstVideoCodecFrame * frame);
+static gboolean gst_vp8_dec_decide_allocation (GstVideoDecoder * decoder,
+ GstQuery * query);
+
+static GstStaticPadTemplate gst_vp8_dec_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-vp8")
+ );
+
+static GstStaticPadTemplate gst_vp8_dec_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420"))
+ );
+
+#define parent_class gst_vp8_dec_parent_class
+G_DEFINE_TYPE (GstVP8Dec, gst_vp8_dec, GST_TYPE_VIDEO_DECODER);
+
+static void
+gst_vp8_dec_class_init (GstVP8DecClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *element_class;
+ GstVideoDecoderClass *base_video_decoder_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ element_class = GST_ELEMENT_CLASS (klass);
+ base_video_decoder_class = GST_VIDEO_DECODER_CLASS (klass);
+
+ gobject_class->set_property = gst_vp8_dec_set_property;
+ gobject_class->get_property = gst_vp8_dec_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_POST_PROCESSING,
+ g_param_spec_boolean ("post-processing", "Post Processing",
+ "Enable post processing", DEFAULT_POST_PROCESSING,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_POST_PROCESSING_FLAGS,
+ g_param_spec_flags ("post-processing-flags", "Post Processing Flags",
+ "Flags to control post processing",
+ GST_VP8_DEC_TYPE_POST_PROCESSING_FLAGS, DEFAULT_POST_PROCESSING_FLAGS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_DEBLOCKING_LEVEL,
+ g_param_spec_uint ("deblocking-level", "Deblocking Level",
+ "Deblocking level",
+ 0, 16, DEFAULT_DEBLOCKING_LEVEL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_NOISE_LEVEL,
+ g_param_spec_uint ("noise-level", "Noise Level",
+ "Noise level",
+ 0, 16, DEFAULT_NOISE_LEVEL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_THREADS,
+ g_param_spec_uint ("threads", "Max Threads",
+ "Maximum number of decoding threads",
+ 1, 16, DEFAULT_THREADS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vp8_dec_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vp8_dec_sink_template));
+
+ gst_element_class_set_static_metadata (element_class,
+ "On2 VP8 Decoder",
+ "Codec/Decoder/Video",
+ "Decode VP8 video streams", "David Schleef <ds@entropywave.com>, "
+ "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+ base_video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_vp8_dec_start);
+ base_video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_vp8_dec_stop);
+ base_video_decoder_class->flush = GST_DEBUG_FUNCPTR (gst_vp8_dec_flush);
+ base_video_decoder_class->set_format =
+ GST_DEBUG_FUNCPTR (gst_vp8_dec_set_format);
+ base_video_decoder_class->handle_frame =
+ GST_DEBUG_FUNCPTR (gst_vp8_dec_handle_frame);
+ base_video_decoder_class->decide_allocation = gst_vp8_dec_decide_allocation;
+
+ GST_DEBUG_CATEGORY_INIT (gst_vp8dec_debug, "vp8dec", 0, "VP8 Decoder");
+}
+
+static void
+gst_vp8_dec_init (GstVP8Dec * gst_vp8_dec)
+{
+ GstVideoDecoder *decoder = (GstVideoDecoder *) gst_vp8_dec;
+
+ GST_DEBUG_OBJECT (gst_vp8_dec, "gst_vp8_dec_init");
+ gst_video_decoder_set_packetized (decoder, TRUE);
+ gst_vp8_dec->post_processing = DEFAULT_POST_PROCESSING;
+ gst_vp8_dec->post_processing_flags = DEFAULT_POST_PROCESSING_FLAGS;
+ gst_vp8_dec->deblocking_level = DEFAULT_DEBLOCKING_LEVEL;
+ gst_vp8_dec->noise_level = DEFAULT_NOISE_LEVEL;
+
+ gst_video_decoder_set_needs_format (decoder, TRUE);
+}
+
+static void
+gst_vp8_dec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstVP8Dec *dec;
+
+ g_return_if_fail (GST_IS_VP8_DEC (object));
+ dec = GST_VP8_DEC (object);
+
+ GST_DEBUG_OBJECT (object, "gst_vp8_dec_set_property");
+ switch (prop_id) {
+ case PROP_POST_PROCESSING:
+ dec->post_processing = g_value_get_boolean (value);
+ break;
+ case PROP_POST_PROCESSING_FLAGS:
+ dec->post_processing_flags = g_value_get_flags (value);
+ break;
+ case PROP_DEBLOCKING_LEVEL:
+ dec->deblocking_level = g_value_get_uint (value);
+ break;
+ case PROP_NOISE_LEVEL:
+ dec->noise_level = g_value_get_uint (value);
+ break;
+ case PROP_THREADS:
+ dec->threads = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_vp8_dec_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
+ GstVP8Dec *dec;
+
+ g_return_if_fail (GST_IS_VP8_DEC (object));
+ dec = GST_VP8_DEC (object);
+
+ switch (prop_id) {
+ case PROP_POST_PROCESSING:
+ g_value_set_boolean (value, dec->post_processing);
+ break;
+ case PROP_POST_PROCESSING_FLAGS:
+ g_value_set_flags (value, dec->post_processing_flags);
+ break;
+ case PROP_DEBLOCKING_LEVEL:
+ g_value_set_uint (value, dec->deblocking_level);
+ break;
+ case PROP_NOISE_LEVEL:
+ g_value_set_uint (value, dec->noise_level);
+ break;
+ case PROP_THREADS:
+ g_value_set_uint (value, dec->threads);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+gst_vp8_dec_start (GstVideoDecoder * decoder)
+{
+ GstVP8Dec *gst_vp8_dec = GST_VP8_DEC (decoder);
+
+ GST_DEBUG_OBJECT (gst_vp8_dec, "start");
+ gst_vp8_dec->decoder_inited = FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+gst_vp8_dec_stop (GstVideoDecoder * base_video_decoder)
+{
+ GstVP8Dec *gst_vp8_dec = GST_VP8_DEC (base_video_decoder);
+
+ GST_DEBUG_OBJECT (gst_vp8_dec, "stop");
+
+ if (gst_vp8_dec->output_state) {
+ gst_video_codec_state_unref (gst_vp8_dec->output_state);
+ gst_vp8_dec->output_state = NULL;
+ }
+
+ if (gst_vp8_dec->input_state) {
+ gst_video_codec_state_unref (gst_vp8_dec->input_state);
+ gst_vp8_dec->input_state = NULL;
+ }
+
+ if (gst_vp8_dec->decoder_inited)
+ vpx_codec_destroy (&gst_vp8_dec->decoder);
+ gst_vp8_dec->decoder_inited = FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+gst_vp8_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
+{
+ GstVP8Dec *gst_vp8_dec = GST_VP8_DEC (decoder);
+
+ GST_DEBUG_OBJECT (gst_vp8_dec, "set_format");
+
+ if (gst_vp8_dec->decoder_inited)
+ vpx_codec_destroy (&gst_vp8_dec->decoder);
+ gst_vp8_dec->decoder_inited = FALSE;
+
+ if (gst_vp8_dec->output_state) {
+ gst_video_codec_state_unref (gst_vp8_dec->output_state);
+ gst_vp8_dec->output_state = NULL;
+ }
+
+ if (gst_vp8_dec->input_state) {
+ gst_video_codec_state_unref (gst_vp8_dec->input_state);
+ gst_vp8_dec->input_state = NULL;
+ }
+
+ gst_vp8_dec->input_state = gst_video_codec_state_ref (state);
+
+ return TRUE;
+}
+
+static gboolean
+gst_vp8_dec_flush (GstVideoDecoder * base_video_decoder)
+{
+ GstVP8Dec *decoder;
+
+ GST_DEBUG_OBJECT (base_video_decoder, "flush");
+
+ decoder = GST_VP8_DEC (base_video_decoder);
+
+ if (decoder->output_state) {
+ gst_video_codec_state_unref (decoder->output_state);
+ decoder->output_state = NULL;
+ }
+
+ if (decoder->decoder_inited)
+ vpx_codec_destroy (&decoder->decoder);
+ decoder->decoder_inited = FALSE;
+
+ return TRUE;
+}
+
+static void
+gst_vp8_dec_send_tags (GstVP8Dec * dec)
+{
+ GstTagList *list;
+
+ list = gst_tag_list_new_empty ();
+ gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+ GST_TAG_VIDEO_CODEC, "VP8 video", NULL);
+
+ gst_pad_push_event (GST_VIDEO_DECODER_SRC_PAD (dec),
+ gst_event_new_tag (list));
+}
+
+static void
+gst_vp8_dec_image_to_buffer (GstVP8Dec * dec, const vpx_image_t * img,
+ GstBuffer * buffer)
+{
+ int deststride, srcstride, height, width, line, comp;
+ guint8 *dest, *src;
+ GstVideoFrame frame;
+ GstVideoInfo *info = &dec->output_state->info;
+
+ if (!gst_video_frame_map (&frame, info, buffer, GST_MAP_WRITE)) {
+ GST_ERROR_OBJECT (dec, "Could not map video buffer");
+ }
+
+ for (comp = 0; comp < 3; comp++) {
+ dest = GST_VIDEO_FRAME_COMP_DATA (&frame, comp);
+ src = img->planes[comp];
+ width = GST_VIDEO_FRAME_COMP_WIDTH (&frame, comp);
+ height = GST_VIDEO_FRAME_COMP_HEIGHT (&frame, comp);
+ deststride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, comp);
+ srcstride = img->stride[comp];
+
+ /* FIXME (Edward) : Do a plane memcpy is srcstride == deststride instead
+ * of copying line by line */
+ for (line = 0; line < height; line++) {
+ memcpy (dest, src, width);
+ dest += deststride;
+ src += srcstride;
+ }
+ }
+
+ gst_video_frame_unmap (&frame);
+}
+
+static GstFlowReturn
+open_codec (GstVP8Dec * dec, GstVideoCodecFrame * frame)
+{
+ int flags = 0;
+ vpx_codec_stream_info_t stream_info;
+ vpx_codec_caps_t caps;
+ vpx_codec_dec_cfg_t cfg;
+ GstVideoCodecState *state = dec->input_state;
+ vpx_codec_err_t status;
+ GstMapInfo minfo;
+
+ memset (&stream_info, 0, sizeof (stream_info));
+ memset (&cfg, 0, sizeof (cfg));
+ stream_info.sz = sizeof (stream_info);
+
+ if (!gst_buffer_map (frame->input_buffer, &minfo, GST_MAP_READ)) {
+ GST_ERROR_OBJECT (dec, "Failed to map input buffer");
+ return GST_FLOW_ERROR;
+ }
+
+ status = vpx_codec_peek_stream_info (&vpx_codec_vp8_dx_algo,
+ minfo.data, minfo.size, &stream_info);
+
+ gst_buffer_unmap (frame->input_buffer, &minfo);
+
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (dec, "VPX preprocessing error: %s",
+ gst_vpx_error_name (status));
+ gst_video_decoder_finish_frame (GST_VIDEO_DECODER (dec), frame);
+ return GST_FLOW_CUSTOM_SUCCESS_1;
+ }
+ if (!stream_info.is_kf) {
+ GST_WARNING_OBJECT (dec, "No keyframe, skipping");
+ gst_video_decoder_finish_frame (GST_VIDEO_DECODER (dec), frame);
+ return GST_FLOW_CUSTOM_SUCCESS_1;
+ }
+
+ g_assert (dec->output_state == NULL);
+ dec->output_state =
+ gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec),
+ GST_VIDEO_FORMAT_I420, stream_info.w, stream_info.h, state);
+ gst_video_decoder_negotiate (GST_VIDEO_DECODER (dec));
+ gst_vp8_dec_send_tags (dec);
+
+ cfg.w = stream_info.w;
+ cfg.h = stream_info.h;
+ cfg.threads = dec->threads;
+
+ caps = vpx_codec_get_caps (&vpx_codec_vp8_dx_algo);
+
+ if (dec->post_processing) {
+ if (!(caps & VPX_CODEC_CAP_POSTPROC)) {
+ GST_WARNING_OBJECT (dec, "Decoder does not support post processing");
+ } else {
+ flags |= VPX_CODEC_USE_POSTPROC;
+ }
+ }
+
+ status =
+ vpx_codec_dec_init (&dec->decoder, &vpx_codec_vp8_dx_algo, &cfg, flags);
+ if (status != VPX_CODEC_OK) {
+ GST_ELEMENT_ERROR (dec, LIBRARY, INIT,
+ ("Failed to initialize VP8 decoder"), ("%s",
+ gst_vpx_error_name (status)));
+ return GST_FLOW_ERROR;
+ }
+
+ if ((caps & VPX_CODEC_CAP_POSTPROC) && dec->post_processing) {
+ vp8_postproc_cfg_t pp_cfg = { 0, };
+
+ pp_cfg.post_proc_flag = dec->post_processing_flags;
+ pp_cfg.deblocking_level = dec->deblocking_level;
+ pp_cfg.noise_level = dec->noise_level;
+
+ status = vpx_codec_control (&dec->decoder, VP8_SET_POSTPROC, &pp_cfg);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (dec, "Couldn't set postprocessing settings: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+
+ dec->decoder_inited = TRUE;
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_vp8_dec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
+{
+ GstVP8Dec *dec;
+ GstFlowReturn ret = GST_FLOW_OK;
+ vpx_codec_err_t status;
+ vpx_codec_iter_t iter = NULL;
+ vpx_image_t *img;
+ long decoder_deadline = 0;
+ GstClockTimeDiff deadline;
+ GstMapInfo minfo;
+ GstVideoInfo *info;
+ GstVideoCodecState *new_output_state;
+
+ GST_LOG_OBJECT (decoder, "handle_frame");
+
+ dec = GST_VP8_DEC (decoder);
+
+ if (!dec->decoder_inited) {
+ ret = open_codec (dec, frame);
+ if (ret == GST_FLOW_CUSTOM_SUCCESS_1)
+ return GST_FLOW_OK;
+ else if (ret != GST_FLOW_OK)
+ return ret;
+ }
+
+ deadline = gst_video_decoder_get_max_decode_time (decoder, frame);
+ if (deadline < 0) {
+ decoder_deadline = 1;
+ } else if (deadline == G_MAXINT64) {
+ decoder_deadline = 0;
+ } else {
+ decoder_deadline = MAX (1, deadline / GST_MSECOND);
+ }
+
+ if (!gst_buffer_map (frame->input_buffer, &minfo, GST_MAP_READ)) {
+ GST_ERROR_OBJECT (dec, "Failed to map input buffer");
+ return GST_FLOW_ERROR;
+ }
+
+ status = vpx_codec_decode (&dec->decoder,
+ minfo.data, minfo.size, NULL, decoder_deadline);
+
+ gst_buffer_unmap (frame->input_buffer, &minfo);
+
+ if (status) {
+ GST_VIDEO_DECODER_ERROR (decoder, 1, LIBRARY, ENCODE,
+ ("Failed to decode frame"), ("%s", gst_vpx_error_name (status)), ret);
+ return ret;
+ }
+
+ img = vpx_codec_get_frame (&dec->decoder, &iter);
+ if (img) {
+ if (img->fmt != VPX_IMG_FMT_I420) {
+ vpx_img_free (img);
+ GST_ELEMENT_ERROR (decoder, LIBRARY, ENCODE,
+ ("Failed to decode frame"), ("Unsupported color format %d",
+ img->fmt));
+ return GST_FLOW_ERROR;
+ }
+
+ if (deadline < 0) {
+ GST_LOG_OBJECT (dec, "Skipping late frame (%f s past deadline)",
+ (double) -deadline / GST_SECOND);
+ gst_video_decoder_drop_frame (decoder, frame);
+ } else {
+ info = &dec->output_state->info;
+ if (GST_VIDEO_INFO_WIDTH (info) != img->d_w
+ || GST_VIDEO_INFO_HEIGHT (info) != img->d_h) {
+ GST_DEBUG_OBJECT (dec,
+ "Changed output resolution was %d x %d now is got %u x %u (display %u x %u)",
+ GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info), img->w,
+ img->h, img->d_w, img->d_h);
+
+ new_output_state =
+ gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec),
+ GST_VIDEO_FORMAT_I420, img->d_w, img->d_h, dec->output_state);
+ if (dec->output_state) {
+ gst_video_codec_state_unref (dec->output_state);
+ }
+ dec->output_state = new_output_state;
+ /* No need to call negotiate() here, it will be automatically called
+ * by allocate_output_frame() below */
+ }
+
+ ret = gst_video_decoder_allocate_output_frame (decoder, frame);
+
+ if (ret == GST_FLOW_OK) {
+ gst_vp8_dec_image_to_buffer (dec, img, frame->output_buffer);
+ ret = gst_video_decoder_finish_frame (decoder, frame);
+ } else {
+ gst_video_decoder_finish_frame (decoder, frame);
+ }
+ }
+
+ vpx_img_free (img);
+
+ while ((img = vpx_codec_get_frame (&dec->decoder, &iter))) {
+ GST_WARNING_OBJECT (decoder, "Multiple decoded frames... dropping");
+ vpx_img_free (img);
+ }
+ } else {
+ /* Invisible frame */
+ GST_VIDEO_CODEC_FRAME_SET_DECODE_ONLY (frame);
+ gst_video_decoder_finish_frame (decoder, frame);
+ }
+
+ return ret;
+}
+
+static gboolean
+gst_vp8_dec_decide_allocation (GstVideoDecoder * bdec, GstQuery * query)
+{
+ GstBufferPool *pool;
+ GstStructure *config;
+
+ if (!GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (bdec, query))
+ return FALSE;
+
+ g_assert (gst_query_get_n_allocation_pools (query) > 0);
+ gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
+ g_assert (pool != NULL);
+
+ config = gst_buffer_pool_get_config (pool);
+ if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
+ gst_buffer_pool_config_add_option (config,
+ GST_BUFFER_POOL_OPTION_VIDEO_META);
+ }
+ gst_buffer_pool_set_config (pool, config);
+ gst_object_unref (pool);
+
+ return TRUE;
+}
+
+#endif /* HAVE_VP8_DECODER */
diff --git a/ext/vpx/gstvp8dec.h b/ext/vpx/gstvp8dec.h
new file mode 100644
index 0000000..8692f01
--- /dev/null
+++ b/ext/vpx/gstvp8dec.h
@@ -0,0 +1,92 @@
+/* VP8
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2008,2009,2010 Entropy Wave Inc
+ * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __GST_VP8_DEC_H__
+#define __GST_VP8_DEC_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_VP8_DECODER
+
+#include <gst/gst.h>
+#include <gst/video/gstvideodecoder.h>
+
+/* FIXME: Undef HAVE_CONFIG_H because vpx_codec.h uses it,
+ * which causes compilation failures */
+#ifdef HAVE_CONFIG_H
+#undef HAVE_CONFIG_H
+#endif
+
+#include <vpx/vpx_decoder.h>
+#include <vpx/vp8dx.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_VP8_DEC \
+ (gst_vp8_dec_get_type())
+#define GST_VP8_DEC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VP8_DEC,GstVP8Dec))
+#define GST_VP8_DEC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VP8_DEC,GstVP8DecClass))
+#define GST_IS_VP8_DEC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VP8_DEC))
+#define GST_IS_VP8_DEC_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VP8_DEC))
+
+typedef struct _GstVP8Dec GstVP8Dec;
+typedef struct _GstVP8DecClass GstVP8DecClass;
+
+struct _GstVP8Dec
+{
+ GstVideoDecoder base_video_decoder;
+
+ /* < private > */
+ vpx_codec_ctx_t decoder;
+
+ /* state */
+ gboolean decoder_inited;
+
+ /* properties */
+ gboolean post_processing;
+ enum vp8_postproc_level post_processing_flags;
+ gint deblocking_level;
+ gint noise_level;
+ gint threads;
+
+ GstVideoCodecState *input_state;
+ GstVideoCodecState *output_state;
+};
+
+struct _GstVP8DecClass
+{
+ GstVideoDecoderClass base_video_decoder_class;
+};
+
+GType gst_vp8_dec_get_type (void);
+
+G_END_DECLS
+
+#endif
+
+#endif /* __GST_VP8_DEC_H__ */
diff --git a/ext/vpx/gstvp8enc.c b/ext/vpx/gstvp8enc.c
new file mode 100755
index 0000000..5fca8f6
--- /dev/null
+++ b/ext/vpx/gstvp8enc.c
@@ -0,0 +1,2122 @@
+/* VP8
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2010 Entropy Wave Inc
+ * Copyright (C) 2010-2012 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+/**
+ * SECTION:element-vp8enc
+ * @see_also: vp8dec, webmmux, oggmux
+ *
+ * This element encodes raw video into a VP8 stream.
+ * <ulink url="http://www.webmproject.org">VP8</ulink> is a royalty-free
+ * video codec maintained by <ulink url="http://www.google.com/">Google
+ * </ulink>. It's the successor of On2 VP3, which was the base of the
+ * Theora video codec.
+ *
+ * To control the quality of the encoding, the #GstVP8Enc::target-bitrate,
+ * #GstVP8Enc::min-quantizer, #GstVP8Enc::max-quantizer or #GstVP8Enc::cq-level
+ * properties can be used. Which one is used depends on the mode selected by
+ * the #GstVP8Enc::end-usage property.
+ * See <ulink url="http://www.webmproject.org/docs/encoder-parameters/">Encoder Parameters</ulink>
+ * for explanation, examples for useful encoding parameters and more details
+ * on the encoding parameters.
+ *
+ * <refsect2>
+ * <title>Example pipeline</title>
+ * |[
+ * gst-launch -v videotestsrc num-buffers=1000 ! vp8enc ! webmmux ! filesink location=videotestsrc.webm
+ * ]| This example pipeline will encode a test video source to VP8 muxed in an
+ * WebM container.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_VP8_ENCODER
+
+/* glib decided in 2.32 it would be a great idea to deprecated GValueArray without
+ * providing an alternative
+ *
+ * See https://bugzilla.gnome.org/show_bug.cgi?id=667228
+ * */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
+#include <gst/tag/tag.h>
+#include <gst/video/video.h>
+#include <string.h>
+
+#include "gstvp8utils.h"
+#include "gstvp8enc.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_vp8enc_debug);
+#define GST_CAT_DEFAULT gst_vp8enc_debug
+
+typedef struct
+{
+ vpx_image_t *image;
+ GList *invisible;
+} GstVP8EncUserData;
+
+static void
+_gst_mini_object_unref0 (GstMiniObject * obj)
+{
+ if (obj)
+ gst_mini_object_unref (obj);
+}
+
+static void
+gst_vp8_enc_user_data_free (GstVP8EncUserData * user_data)
+{
+ if (user_data->image)
+ g_slice_free (vpx_image_t, user_data->image);
+
+ g_list_foreach (user_data->invisible, (GFunc) _gst_mini_object_unref0, NULL);
+ g_list_free (user_data->invisible);
+ g_slice_free (GstVP8EncUserData, user_data);
+}
+
+/* From vp8/vp8_cx_iface.c */
+#define DEFAULT_PROFILE 0
+
+#define DEFAULT_RC_END_USAGE VPX_VBR
+#define DEFAULT_RC_TARGET_BITRATE 256000
+#define DEFAULT_RC_MIN_QUANTIZER 4
+#define DEFAULT_RC_MAX_QUANTIZER 63
+
+#define DEFAULT_RC_DROPFRAME_THRESH 0
+#define DEFAULT_RC_RESIZE_ALLOWED 0
+#define DEFAULT_RC_RESIZE_UP_THRESH 30
+#define DEFAULT_RC_RESIZE_DOWN_THRESH 60
+#define DEFAULT_RC_UNDERSHOOT_PCT 100
+#define DEFAULT_RC_OVERSHOOT_PCT 100
+#define DEFAULT_RC_BUF_SZ 6000
+#define DEFAULT_RC_BUF_INITIAL_SZ 4000
+#define DEFAULT_RC_BUF_OPTIMAL_SZ 5000
+#define DEFAULT_RC_2PASS_VBR_BIAS_PCT 50
+#define DEFAULT_RC_2PASS_VBR_MINSECTION_PCT 0
+#define DEFAULT_RC_2PASS_VBR_MAXSECTION_PCT 400
+
+#define DEFAULT_KF_MODE VPX_KF_AUTO
+#define DEFAULT_KF_MAX_DIST 128
+
+#define DEFAULT_MULTIPASS_MODE VPX_RC_ONE_PASS
+#define DEFAULT_MULTIPASS_CACHE_FILE "multipass.cache"
+
+#define DEFAULT_TS_NUMBER_LAYERS 1
+#define DEFAULT_TS_TARGET_BITRATE NULL
+#define DEFAULT_TS_RATE_DECIMATOR NULL
+#define DEFAULT_TS_PERIODICITY 0
+#define DEFAULT_TS_LAYER_ID NULL
+
+#define DEFAULT_ERROR_RESILIENT 0
+#define DEFAULT_LAG_IN_FRAMES 0
+
+#define DEFAULT_THREADS 0
+
+#define DEFAULT_H_SCALING_MODE VP8E_NORMAL
+#define DEFAULT_V_SCALING_MODE VP8E_NORMAL
+#define DEFAULT_CPU_USED 0
+#define DEFAULT_ENABLE_AUTO_ALT_REF FALSE
+#define DEFAULT_DEADLINE VPX_DL_BEST_QUALITY
+#define DEFAULT_NOISE_SENSITIVITY 0
+#define DEFAULT_SHARPNESS 0
+#define DEFAULT_STATIC_THRESHOLD 0
+#define DEFAULT_TOKEN_PARTITIONS 0
+#define DEFAULT_ARNR_MAXFRAMES 0
+#define DEFAULT_ARNR_STRENGTH 3
+#define DEFAULT_ARNR_TYPE 3
+#define DEFAULT_TUNING VP8_TUNE_PSNR
+#define DEFAULT_CQ_LEVEL 10
+#define DEFAULT_MAX_INTRA_BITRATE_PCT 0
+#define DEFAULT_TIMEBASE_N 0
+#define DEFAULT_TIMEBASE_D 1
+
+enum
+{
+ PROP_0,
+ PROP_RC_END_USAGE,
+ PROP_RC_TARGET_BITRATE,
+ PROP_RC_MIN_QUANTIZER,
+ PROP_RC_MAX_QUANTIZER,
+ PROP_RC_DROPFRAME_THRESH,
+ PROP_RC_RESIZE_ALLOWED,
+ PROP_RC_RESIZE_UP_THRESH,
+ PROP_RC_RESIZE_DOWN_THRESH,
+ PROP_RC_UNDERSHOOT_PCT,
+ PROP_RC_OVERSHOOT_PCT,
+ PROP_RC_BUF_SZ,
+ PROP_RC_BUF_INITIAL_SZ,
+ PROP_RC_BUF_OPTIMAL_SZ,
+ PROP_RC_2PASS_VBR_BIAS_PCT,
+ PROP_RC_2PASS_VBR_MINSECTION_PCT,
+ PROP_RC_2PASS_VBR_MAXSECTION_PCT,
+ PROP_KF_MODE,
+ PROP_KF_MAX_DIST,
+ PROP_TS_NUMBER_LAYERS,
+ PROP_TS_TARGET_BITRATE,
+ PROP_TS_RATE_DECIMATOR,
+ PROP_TS_PERIODICITY,
+ PROP_TS_LAYER_ID,
+ PROP_MULTIPASS_MODE,
+ PROP_MULTIPASS_CACHE_FILE,
+ PROP_ERROR_RESILIENT,
+ PROP_LAG_IN_FRAMES,
+ PROP_THREADS,
+ PROP_DEADLINE,
+ PROP_H_SCALING_MODE,
+ PROP_V_SCALING_MODE,
+ PROP_CPU_USED,
+ PROP_ENABLE_AUTO_ALT_REF,
+ PROP_NOISE_SENSITIVITY,
+ PROP_SHARPNESS,
+ PROP_STATIC_THRESHOLD,
+ PROP_TOKEN_PARTITIONS,
+ PROP_ARNR_MAXFRAMES,
+ PROP_ARNR_STRENGTH,
+ PROP_ARNR_TYPE,
+ PROP_TUNING,
+ PROP_CQ_LEVEL,
+ PROP_MAX_INTRA_BITRATE_PCT,
+ PROP_TIMEBASE
+};
+
+#define GST_VP8_ENC_END_USAGE_TYPE (gst_vp8_enc_end_usage_get_type())
+static GType
+gst_vp8_enc_end_usage_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VPX_VBR, "Variable Bit Rate (VBR) mode", "vbr"},
+ {VPX_CBR, "Constant Bit Rate (CBR) mode", "cbr"},
+ {VPX_CQ, "Constant Quality Mode (CQ) mode", "cq"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP8EncEndUsage", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP8_ENC_MULTIPASS_MODE_TYPE (gst_vp8_enc_multipass_mode_get_type())
+static GType
+gst_vp8_enc_multipass_mode_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VPX_RC_ONE_PASS, "One pass encoding (default)", "one-pass"},
+ {VPX_RC_FIRST_PASS, "First pass of multipass encoding", "first-pass"},
+ {VPX_RC_LAST_PASS, "Last pass of multipass encoding", "last-pass"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP8EncMultipassMode", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP8_ENC_KF_MODE_TYPE (gst_vp8_enc_kf_mode_get_type())
+static GType
+gst_vp8_enc_kf_mode_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VPX_KF_AUTO, "Determine optimal placement automatically", "auto"},
+ {VPX_KF_DISABLED, "Don't automatically place keyframes", "disabled"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP8EncKfMode", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP8_ENC_TUNING_TYPE (gst_vp8_enc_tuning_get_type())
+static GType
+gst_vp8_enc_tuning_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VP8_TUNE_PSNR, "Tune for PSNR", "psnr"},
+ {VP8_TUNE_SSIM, "Tune for SSIM", "ssim"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP8EncTuning", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP8_ENC_SCALING_MODE_TYPE (gst_vp8_enc_scaling_mode_get_type())
+static GType
+gst_vp8_enc_scaling_mode_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VP8E_NORMAL, "Normal", "normal"},
+ {VP8E_FOURFIVE, "4:5", "4:5"},
+ {VP8E_THREEFIVE, "3:5", "3:5"},
+ {VP8E_ONETWO, "1:2", "1:2"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP8EncScalingMode", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP8_ENC_TOKEN_PARTITIONS_TYPE (gst_vp8_enc_token_partitions_get_type())
+static GType
+gst_vp8_enc_token_partitions_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VP8_ONE_TOKENPARTITION, "One token partition", "1"},
+ {VP8_TWO_TOKENPARTITION, "Two token partitions", "2"},
+ {VP8_FOUR_TOKENPARTITION, "Four token partitions", "4"},
+ {VP8_EIGHT_TOKENPARTITION, "Eight token partitions", "8"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP8EncTokenPartitions", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP8_ENC_ER_FLAGS_TYPE (gst_vp8_enc_er_flags_get_type())
+static GType
+gst_vp8_enc_er_flags_get_type (void)
+{
+ static const GFlagsValue values[] = {
+ {VPX_ERROR_RESILIENT_DEFAULT, "Default error resilience", "default"},
+ {VPX_ERROR_RESILIENT_PARTITIONS,
+ "Allow partitions to be decoded independently", "partitions"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_flags_register_static ("GstVP8EncErFlags", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+static void gst_vp8_enc_finalize (GObject * object);
+static void gst_vp8_enc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_vp8_enc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_vp8_enc_start (GstVideoEncoder * encoder);
+static gboolean gst_vp8_enc_stop (GstVideoEncoder * encoder);
+static gboolean gst_vp8_enc_set_format (GstVideoEncoder *
+ video_encoder, GstVideoCodecState * state);
+static GstFlowReturn gst_vp8_enc_finish (GstVideoEncoder * video_encoder);
+static GstFlowReturn gst_vp8_enc_drain (GstVideoEncoder * video_encoder);
+static GstFlowReturn gst_vp8_enc_handle_frame (GstVideoEncoder *
+ video_encoder, GstVideoCodecFrame * frame);
+static GstFlowReturn gst_vp8_enc_pre_push (GstVideoEncoder * encoder,
+ GstVideoCodecFrame * frame);
+static gboolean gst_vp8_enc_sink_event (GstVideoEncoder *
+ video_encoder, GstEvent * event);
+static gboolean gst_vp8_enc_propose_allocation (GstVideoEncoder * encoder,
+ GstQuery * query);
+
+static GstStaticPadTemplate gst_vp8_enc_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("I420"))
+ );
+
+static GstStaticPadTemplate gst_vp8_enc_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-vp8, " "profile = (string) {0, 1, 2, 3}")
+ );
+
+#define parent_class gst_vp8_enc_parent_class
+G_DEFINE_TYPE_WITH_CODE (GstVP8Enc, gst_vp8_enc, GST_TYPE_VIDEO_ENCODER,
+ G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL);
+ G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL););
+
+static void
+gst_vp8_enc_class_init (GstVP8EncClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *element_class;
+ GstVideoEncoderClass *video_encoder_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ element_class = GST_ELEMENT_CLASS (klass);
+ video_encoder_class = GST_VIDEO_ENCODER_CLASS (klass);
+
+ gobject_class->set_property = gst_vp8_enc_set_property;
+ gobject_class->get_property = gst_vp8_enc_get_property;
+ gobject_class->finalize = gst_vp8_enc_finalize;
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vp8_enc_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vp8_enc_sink_template));
+
+ gst_element_class_set_static_metadata (element_class,
+ "On2 VP8 Encoder",
+ "Codec/Encoder/Video",
+ "Encode VP8 video streams", "David Schleef <ds@entropywave.com>, "
+ "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+ video_encoder_class->start = gst_vp8_enc_start;
+ video_encoder_class->stop = gst_vp8_enc_stop;
+ video_encoder_class->handle_frame = gst_vp8_enc_handle_frame;
+ video_encoder_class->set_format = gst_vp8_enc_set_format;
+ video_encoder_class->finish = gst_vp8_enc_finish;
+ video_encoder_class->pre_push = gst_vp8_enc_pre_push;
+ video_encoder_class->sink_event = gst_vp8_enc_sink_event;
+ video_encoder_class->propose_allocation = gst_vp8_enc_propose_allocation;
+
+ g_object_class_install_property (gobject_class, PROP_RC_END_USAGE,
+ g_param_spec_enum ("end-usage", "Rate control mode",
+ "Rate control mode",
+ GST_VP8_ENC_END_USAGE_TYPE, DEFAULT_RC_END_USAGE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_TARGET_BITRATE,
+ g_param_spec_int ("target-bitrate", "Target bitrate",
+ "Target bitrate (in bits/sec)",
+ 0, G_MAXINT, DEFAULT_RC_TARGET_BITRATE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_MIN_QUANTIZER,
+ g_param_spec_int ("min-quantizer", "Minimum Quantizer",
+ "Minimum Quantizer (best)",
+ 0, 63, DEFAULT_RC_MIN_QUANTIZER,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_MAX_QUANTIZER,
+ g_param_spec_int ("max-quantizer", "Maximum Quantizer",
+ "Maximum Quantizer (worst)",
+ 0, 63, DEFAULT_RC_MAX_QUANTIZER,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_DROPFRAME_THRESH,
+ g_param_spec_int ("dropframe-threshold", "Drop Frame Threshold",
+ "Temporal resampling threshold (buf %)",
+ 0, 100, DEFAULT_RC_DROPFRAME_THRESH,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_RESIZE_ALLOWED,
+ g_param_spec_boolean ("resize-allowed", "Resize Allowed",
+ "Allow spatial resampling",
+ DEFAULT_RC_RESIZE_ALLOWED,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_RESIZE_UP_THRESH,
+ g_param_spec_int ("resize-up-threshold", "Resize Up Threshold",
+ "Upscale threshold (buf %)",
+ 0, 100, DEFAULT_RC_RESIZE_UP_THRESH,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_RESIZE_DOWN_THRESH,
+ g_param_spec_int ("resize-down-threshold", "Resize Down Threshold",
+ "Downscale threshold (buf %)",
+ 0, 100, DEFAULT_RC_RESIZE_DOWN_THRESH,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_UNDERSHOOT_PCT,
+ g_param_spec_int ("undershoot", "Undershoot PCT",
+ "Datarate undershoot (min) target (%)",
+ 0, 1000, DEFAULT_RC_UNDERSHOOT_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_OVERSHOOT_PCT,
+ g_param_spec_int ("overshoot", "Overshoot PCT",
+ "Datarate overshoot (max) target (%)",
+ 0, 1000, DEFAULT_RC_OVERSHOOT_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_BUF_SZ,
+ g_param_spec_int ("buffer-size", "Buffer size",
+ "Client buffer size (ms)",
+ 0, G_MAXINT, DEFAULT_RC_BUF_SZ,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_BUF_INITIAL_SZ,
+ g_param_spec_int ("buffer-initial-size", "Buffer initial size",
+ "Initial client buffer size (ms)",
+ 0, G_MAXINT, DEFAULT_RC_BUF_INITIAL_SZ,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_BUF_OPTIMAL_SZ,
+ g_param_spec_int ("buffer-optimal-size", "Buffer optimal size",
+ "Optimal client buffer size (ms)",
+ 0, G_MAXINT, DEFAULT_RC_BUF_OPTIMAL_SZ,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_2PASS_VBR_BIAS_PCT,
+ g_param_spec_int ("twopass-vbr-bias", "2-pass VBR bias",
+ "CBR/VBR bias (0=CBR, 100=VBR)",
+ 0, 100, DEFAULT_RC_2PASS_VBR_BIAS_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class,
+ PROP_RC_2PASS_VBR_MINSECTION_PCT,
+ g_param_spec_int ("twopass-vbr-minsection", "2-pass GOP min bitrate",
+ "GOP minimum bitrate (% target)", 0, G_MAXINT,
+ DEFAULT_RC_2PASS_VBR_MINSECTION_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class,
+ PROP_RC_2PASS_VBR_MAXSECTION_PCT,
+ g_param_spec_int ("twopass-vbr-maxsection", "2-pass GOP max bitrate",
+ "GOP maximum bitrate (% target)", 0, G_MAXINT,
+ DEFAULT_RC_2PASS_VBR_MINSECTION_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_KF_MODE,
+ g_param_spec_enum ("keyframe-mode", "Keyframe Mode",
+ "Keyframe placement",
+ GST_VP8_ENC_KF_MODE_TYPE, DEFAULT_KF_MODE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_KF_MAX_DIST,
+ g_param_spec_int ("keyframe-max-dist", "Keyframe max distance",
+ "Maximum distance between keyframes (number of frames)",
+ 0, G_MAXINT, DEFAULT_KF_MAX_DIST,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_MULTIPASS_MODE,
+ g_param_spec_enum ("multipass-mode", "Multipass Mode",
+ "Multipass encode mode",
+ GST_VP8_ENC_MULTIPASS_MODE_TYPE, DEFAULT_MULTIPASS_MODE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_MULTIPASS_CACHE_FILE,
+ g_param_spec_string ("multipass-cache-file", "Multipass Cache File",
+ "Multipass cache file",
+ DEFAULT_MULTIPASS_CACHE_FILE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TS_NUMBER_LAYERS,
+ g_param_spec_int ("temporal-scalability-number-layers",
+ "Number of coding layers", "Number of coding layers to use", 1, 5,
+ DEFAULT_TS_NUMBER_LAYERS,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TS_TARGET_BITRATE,
+ g_param_spec_value_array ("temporal-scalability-target-bitrate",
+ "Coding layer target bitrates",
+ "Target bitrates for coding layers (one per layer, decreasing)",
+ g_param_spec_int ("target-bitrate", "Target bitrate",
+ "Target bitrate", 0, G_MAXINT, DEFAULT_RC_TARGET_BITRATE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_TS_RATE_DECIMATOR,
+ g_param_spec_value_array ("temporal-scalability-rate-decimator",
+ "Coding layer rate decimator",
+ "Rate decimation factors for each layer",
+ g_param_spec_int ("rate-decimator", "Rate decimator",
+ "Rate decimator", 0, 1000000000, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_TS_PERIODICITY,
+ g_param_spec_int ("temporal-scalability-periodicity",
+ "Coding layer periodicity",
+ "Length of sequence that defines layer membership periodicity", 0, 16,
+ DEFAULT_TS_PERIODICITY,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TS_LAYER_ID,
+ g_param_spec_value_array ("temporal-scalability-layer-id",
+ "Coding layer identification",
+ "Sequence defining coding layer membership",
+ g_param_spec_int ("layer-id", "Layer ID", "Layer ID", 0, 4, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_LAG_IN_FRAMES,
+ g_param_spec_int ("lag-in-frames", "Lag in frames",
+ "Maximum number of frames to lag",
+ 0, 25, DEFAULT_LAG_IN_FRAMES,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ERROR_RESILIENT,
+ g_param_spec_flags ("error-resilient", "Error resilient",
+ "Error resilience flags",
+ GST_VP8_ENC_ER_FLAGS_TYPE, DEFAULT_ERROR_RESILIENT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_THREADS,
+ g_param_spec_int ("threads", "Threads",
+ "Number of threads to use",
+ 0, 64, DEFAULT_THREADS,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_DEADLINE,
+ g_param_spec_int64 ("deadline", "Deadline",
+ "Deadline per frame (usec, 0=disabled)",
+ 0, G_MAXINT64, DEFAULT_DEADLINE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_H_SCALING_MODE,
+ g_param_spec_enum ("horizontal-scaling-mode", "Horizontal scaling mode",
+ "Horizontal scaling mode",
+ GST_VP8_ENC_SCALING_MODE_TYPE, DEFAULT_H_SCALING_MODE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_V_SCALING_MODE,
+ g_param_spec_enum ("vertical-scaling-mode", "Vertical scaling mode",
+ "Vertical scaling mode",
+ GST_VP8_ENC_SCALING_MODE_TYPE, DEFAULT_V_SCALING_MODE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_CPU_USED,
+ g_param_spec_int ("cpu-used", "CPU used",
+ "CPU used",
+ -16, 16, DEFAULT_CPU_USED,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ENABLE_AUTO_ALT_REF,
+ g_param_spec_boolean ("auto-alt-ref", "Auto alt reference frames",
+ "Automatically generate AltRef frames",
+ DEFAULT_ENABLE_AUTO_ALT_REF,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_NOISE_SENSITIVITY,
+ g_param_spec_int ("noise-sensitivity", "Noise sensitivity",
+ "Noise sensisivity (frames to blur)",
+ 0, 6, DEFAULT_NOISE_SENSITIVITY,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_SHARPNESS,
+ g_param_spec_int ("sharpness", "Sharpness",
+ "Filter sharpness",
+ 0, 7, DEFAULT_SHARPNESS,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_STATIC_THRESHOLD,
+ g_param_spec_int ("static-threshold", "Static Threshold",
+ "Motion detection threshold",
+ 0, G_MAXINT, DEFAULT_STATIC_THRESHOLD,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TOKEN_PARTITIONS,
+ g_param_spec_enum ("token-partitions", "Token partitions",
+ "Number of token partitions",
+ GST_VP8_ENC_TOKEN_PARTITIONS_TYPE, DEFAULT_TOKEN_PARTITIONS,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ARNR_MAXFRAMES,
+ g_param_spec_int ("arnr-maxframes", "AltRef max frames",
+ "AltRef maximum number of frames",
+ 0, 15, DEFAULT_ARNR_MAXFRAMES,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ARNR_STRENGTH,
+ g_param_spec_int ("arnr-strength", "AltRef strength",
+ "AltRef strength",
+ 0, 6, DEFAULT_ARNR_STRENGTH,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ARNR_TYPE,
+ g_param_spec_int ("arnr-type", "AltRef type",
+ "AltRef type",
+ 1, 3, DEFAULT_ARNR_TYPE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+ G_PARAM_DEPRECATED)));
+
+ g_object_class_install_property (gobject_class, PROP_TUNING,
+ g_param_spec_enum ("tuning", "Tuning",
+ "Tuning",
+ GST_VP8_ENC_TUNING_TYPE, DEFAULT_TUNING,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_CQ_LEVEL,
+ g_param_spec_int ("cq-level", "Constrained quality level",
+ "Constrained quality level",
+ 0, 63, DEFAULT_CQ_LEVEL,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_MAX_INTRA_BITRATE_PCT,
+ g_param_spec_int ("max-intra-bitrate", "Max Intra bitrate",
+ "Maximum Intra frame bitrate",
+ 0, G_MAXINT, DEFAULT_MAX_INTRA_BITRATE_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TIMEBASE,
+ gst_param_spec_fraction ("timebase", "Shortest interframe time",
+ "Fraction of one second that is the shortest interframe time - normally left as zero which will default to the framerate",
+ 0, 1, G_MAXINT, 1, DEFAULT_TIMEBASE_N, DEFAULT_TIMEBASE_D,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ GST_DEBUG_CATEGORY_INIT (gst_vp8enc_debug, "vp8enc", 0, "VP8 Encoder");
+}
+
+static void
+gst_vp8_enc_init (GstVP8Enc * gst_vp8_enc)
+{
+ vpx_codec_err_t status;
+
+ GST_DEBUG_OBJECT (gst_vp8_enc, "init");
+
+ status =
+ vpx_codec_enc_config_default (&vpx_codec_vp8_cx_algo, &gst_vp8_enc->cfg,
+ 0);
+ if (status != VPX_CODEC_OK) {
+ GST_ERROR_OBJECT (gst_vp8_enc,
+ "Failed to get default encoder configuration: %s",
+ gst_vpx_error_name (status));
+ gst_vp8_enc->have_default_config = FALSE;
+ } else {
+ gst_vp8_enc->have_default_config = TRUE;
+ }
+
+ gst_vp8_enc->cfg.rc_end_usage = DEFAULT_RC_END_USAGE;
+ gst_vp8_enc->cfg.rc_target_bitrate = DEFAULT_RC_TARGET_BITRATE / 1000;
+ gst_vp8_enc->rc_target_bitrate_set = FALSE;
+ gst_vp8_enc->cfg.rc_min_quantizer = DEFAULT_RC_MIN_QUANTIZER;
+ gst_vp8_enc->cfg.rc_max_quantizer = DEFAULT_RC_MAX_QUANTIZER;
+ gst_vp8_enc->cfg.rc_dropframe_thresh = DEFAULT_RC_DROPFRAME_THRESH;
+ gst_vp8_enc->cfg.rc_resize_allowed = DEFAULT_RC_RESIZE_ALLOWED;
+ gst_vp8_enc->cfg.rc_resize_up_thresh = DEFAULT_RC_RESIZE_UP_THRESH;
+ gst_vp8_enc->cfg.rc_resize_down_thresh = DEFAULT_RC_RESIZE_DOWN_THRESH;
+ gst_vp8_enc->cfg.rc_undershoot_pct = DEFAULT_RC_UNDERSHOOT_PCT;
+ gst_vp8_enc->cfg.rc_overshoot_pct = DEFAULT_RC_OVERSHOOT_PCT;
+ gst_vp8_enc->cfg.rc_buf_sz = DEFAULT_RC_BUF_SZ;
+ gst_vp8_enc->cfg.rc_buf_initial_sz = DEFAULT_RC_BUF_INITIAL_SZ;
+ gst_vp8_enc->cfg.rc_buf_optimal_sz = DEFAULT_RC_BUF_OPTIMAL_SZ;
+ gst_vp8_enc->cfg.rc_2pass_vbr_bias_pct = DEFAULT_RC_2PASS_VBR_BIAS_PCT;
+ gst_vp8_enc->cfg.rc_2pass_vbr_minsection_pct =
+ DEFAULT_RC_2PASS_VBR_MINSECTION_PCT;
+ gst_vp8_enc->cfg.rc_2pass_vbr_maxsection_pct =
+ DEFAULT_RC_2PASS_VBR_MAXSECTION_PCT;
+ gst_vp8_enc->cfg.kf_mode = DEFAULT_KF_MODE;
+ gst_vp8_enc->cfg.kf_max_dist = DEFAULT_KF_MAX_DIST;
+ gst_vp8_enc->cfg.g_pass = DEFAULT_MULTIPASS_MODE;
+ gst_vp8_enc->multipass_cache_file = g_strdup (DEFAULT_MULTIPASS_CACHE_FILE);
+ gst_vp8_enc->cfg.ts_number_layers = DEFAULT_TS_NUMBER_LAYERS;
+ gst_vp8_enc->n_ts_target_bitrate = 0;
+ gst_vp8_enc->n_ts_rate_decimator = 0;
+ gst_vp8_enc->cfg.ts_periodicity = DEFAULT_TS_PERIODICITY;
+ gst_vp8_enc->n_ts_layer_id = 0;
+ gst_vp8_enc->cfg.g_error_resilient = DEFAULT_ERROR_RESILIENT;
+ gst_vp8_enc->cfg.g_lag_in_frames = DEFAULT_LAG_IN_FRAMES;
+ gst_vp8_enc->cfg.g_threads = DEFAULT_THREADS;
+ gst_vp8_enc->deadline = DEFAULT_DEADLINE;
+ gst_vp8_enc->h_scaling_mode = DEFAULT_H_SCALING_MODE;
+ gst_vp8_enc->v_scaling_mode = DEFAULT_V_SCALING_MODE;
+ gst_vp8_enc->cpu_used = DEFAULT_CPU_USED;
+ gst_vp8_enc->enable_auto_alt_ref = DEFAULT_ENABLE_AUTO_ALT_REF;
+ gst_vp8_enc->noise_sensitivity = DEFAULT_NOISE_SENSITIVITY;
+ gst_vp8_enc->sharpness = DEFAULT_SHARPNESS;
+ gst_vp8_enc->static_threshold = DEFAULT_STATIC_THRESHOLD;
+ gst_vp8_enc->token_partitions = DEFAULT_TOKEN_PARTITIONS;
+ gst_vp8_enc->arnr_maxframes = DEFAULT_ARNR_MAXFRAMES;
+ gst_vp8_enc->arnr_strength = DEFAULT_ARNR_STRENGTH;
+ gst_vp8_enc->arnr_type = DEFAULT_ARNR_TYPE;
+ gst_vp8_enc->tuning = DEFAULT_TUNING;
+ gst_vp8_enc->cq_level = DEFAULT_CQ_LEVEL;
+ gst_vp8_enc->max_intra_bitrate_pct = DEFAULT_MAX_INTRA_BITRATE_PCT;
+ gst_vp8_enc->timebase_n = DEFAULT_TIMEBASE_N;
+ gst_vp8_enc->timebase_d = DEFAULT_TIMEBASE_D;
+
+ gst_vp8_enc->cfg.g_profile = DEFAULT_PROFILE;
+
+ g_mutex_init (&gst_vp8_enc->encoder_lock);
+}
+
+static void
+gst_vp8_enc_finalize (GObject * object)
+{
+ GstVP8Enc *gst_vp8_enc;
+
+ GST_DEBUG_OBJECT (object, "finalize");
+
+ g_return_if_fail (GST_IS_VP8_ENC (object));
+ gst_vp8_enc = GST_VP8_ENC (object);
+
+ g_free (gst_vp8_enc->multipass_cache_file);
+ gst_vp8_enc->multipass_cache_file = NULL;
+
+ if (gst_vp8_enc->input_state)
+ gst_video_codec_state_unref (gst_vp8_enc->input_state);
+
+ g_mutex_clear (&gst_vp8_enc->encoder_lock);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+
+}
+
+static void
+gst_vp8_enc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstVP8Enc *gst_vp8_enc;
+ gboolean global = FALSE;
+ vpx_codec_err_t status;
+
+ g_return_if_fail (GST_IS_VP8_ENC (object));
+ gst_vp8_enc = GST_VP8_ENC (object);
+
+ GST_DEBUG_OBJECT (object, "gst_vp8_enc_set_property");
+ g_mutex_lock (&gst_vp8_enc->encoder_lock);
+ switch (prop_id) {
+ case PROP_RC_END_USAGE:
+ gst_vp8_enc->cfg.rc_end_usage = g_value_get_enum (value);
+ global = TRUE;
+ break;
+ case PROP_RC_TARGET_BITRATE:
+ gst_vp8_enc->cfg.rc_target_bitrate = g_value_get_int (value) / 1000;
+ gst_vp8_enc->rc_target_bitrate_set = TRUE;
+ global = TRUE;
+ break;
+ case PROP_RC_MIN_QUANTIZER:
+ gst_vp8_enc->cfg.rc_min_quantizer = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_MAX_QUANTIZER:
+ gst_vp8_enc->cfg.rc_max_quantizer = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_DROPFRAME_THRESH:
+ gst_vp8_enc->cfg.rc_dropframe_thresh = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_RESIZE_ALLOWED:
+ gst_vp8_enc->cfg.rc_resize_allowed = g_value_get_boolean (value);
+ global = TRUE;
+ break;
+ case PROP_RC_RESIZE_UP_THRESH:
+ gst_vp8_enc->cfg.rc_resize_up_thresh = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_RESIZE_DOWN_THRESH:
+ gst_vp8_enc->cfg.rc_resize_down_thresh = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_UNDERSHOOT_PCT:
+ gst_vp8_enc->cfg.rc_undershoot_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_OVERSHOOT_PCT:
+ gst_vp8_enc->cfg.rc_overshoot_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_BUF_SZ:
+ gst_vp8_enc->cfg.rc_buf_sz = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_BUF_INITIAL_SZ:
+ gst_vp8_enc->cfg.rc_buf_initial_sz = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_BUF_OPTIMAL_SZ:
+ gst_vp8_enc->cfg.rc_buf_optimal_sz = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_2PASS_VBR_BIAS_PCT:
+ gst_vp8_enc->cfg.rc_2pass_vbr_bias_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_2PASS_VBR_MINSECTION_PCT:
+ gst_vp8_enc->cfg.rc_2pass_vbr_minsection_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_2PASS_VBR_MAXSECTION_PCT:
+ gst_vp8_enc->cfg.rc_2pass_vbr_maxsection_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_KF_MODE:
+ gst_vp8_enc->cfg.kf_mode = g_value_get_enum (value);
+ global = TRUE;
+ break;
+ case PROP_KF_MAX_DIST:
+ gst_vp8_enc->cfg.kf_max_dist = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_MULTIPASS_MODE:
+ gst_vp8_enc->cfg.g_pass = g_value_get_enum (value);
+ global = TRUE;
+ break;
+ case PROP_MULTIPASS_CACHE_FILE:
+ if (gst_vp8_enc->multipass_cache_file)
+ g_free (gst_vp8_enc->multipass_cache_file);
+ gst_vp8_enc->multipass_cache_file = g_value_dup_string (value);
+ break;
+ case PROP_TS_NUMBER_LAYERS:
+ gst_vp8_enc->cfg.ts_number_layers = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_TS_TARGET_BITRATE:{
+ GValueArray *va = g_value_get_boxed (value);
+
+ memset (&gst_vp8_enc->cfg.ts_target_bitrate, 0,
+ sizeof (gst_vp8_enc->cfg.ts_target_bitrate));
+ if (va == NULL) {
+ gst_vp8_enc->n_ts_target_bitrate = 0;
+ } else if (va->n_values > VPX_TS_MAX_LAYERS) {
+ g_warning ("%s: Only %d layers allowed at maximum",
+ GST_ELEMENT_NAME (gst_vp8_enc), VPX_TS_MAX_LAYERS);
+ } else {
+ gint i;
+
+ for (i = 0; i < va->n_values; i++)
+ gst_vp8_enc->cfg.ts_target_bitrate[i] =
+ g_value_get_int (g_value_array_get_nth (va, i));
+ gst_vp8_enc->n_ts_target_bitrate = va->n_values;
+ }
+ global = TRUE;
+ break;
+ }
+ case PROP_TS_RATE_DECIMATOR:{
+ GValueArray *va = g_value_get_boxed (value);
+
+ memset (&gst_vp8_enc->cfg.ts_rate_decimator, 0,
+ sizeof (gst_vp8_enc->cfg.ts_rate_decimator));
+ if (va == NULL) {
+ gst_vp8_enc->n_ts_rate_decimator = 0;
+ } else if (va->n_values > VPX_TS_MAX_LAYERS) {
+ g_warning ("%s: Only %d layers allowed at maximum",
+ GST_ELEMENT_NAME (gst_vp8_enc), VPX_TS_MAX_LAYERS);
+ } else {
+ gint i;
+
+ for (i = 0; i < va->n_values; i++)
+ gst_vp8_enc->cfg.ts_rate_decimator[i] =
+ g_value_get_int (g_value_array_get_nth (va, i));
+ gst_vp8_enc->n_ts_rate_decimator = va->n_values;
+ }
+ global = TRUE;
+ break;
+ }
+ case PROP_TS_PERIODICITY:
+ gst_vp8_enc->cfg.ts_periodicity = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_TS_LAYER_ID:{
+ GValueArray *va = g_value_get_boxed (value);
+
+ memset (&gst_vp8_enc->cfg.ts_layer_id, 0,
+ sizeof (gst_vp8_enc->cfg.ts_layer_id));
+ if (va && va->n_values > VPX_TS_MAX_PERIODICITY) {
+ g_warning ("%s: Only %d sized layer sequences allowed at maximum",
+ GST_ELEMENT_NAME (gst_vp8_enc), VPX_TS_MAX_PERIODICITY);
+ } else if (va) {
+ gint i;
+
+ for (i = 0; i < va->n_values; i++)
+ gst_vp8_enc->cfg.ts_layer_id[i] =
+ g_value_get_int (g_value_array_get_nth (va, i));
+ gst_vp8_enc->n_ts_layer_id = va->n_values;
+ } else {
+ gst_vp8_enc->n_ts_layer_id = 0;
+ }
+ global = TRUE;
+ break;
+ }
+ case PROP_ERROR_RESILIENT:
+ gst_vp8_enc->cfg.g_error_resilient = g_value_get_flags (value);
+ global = TRUE;
+ break;
+ case PROP_LAG_IN_FRAMES:
+ gst_vp8_enc->cfg.g_lag_in_frames = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_THREADS:
+ gst_vp8_enc->cfg.g_threads = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_DEADLINE:
+ gst_vp8_enc->deadline = g_value_get_int64 (value);
+ break;
+ case PROP_H_SCALING_MODE:
+ gst_vp8_enc->h_scaling_mode = g_value_get_enum (value);
+ if (gst_vp8_enc->inited) {
+ vpx_scaling_mode_t sm;
+
+ sm.h_scaling_mode = gst_vp8_enc->h_scaling_mode;
+ sm.v_scaling_mode = gst_vp8_enc->v_scaling_mode;
+
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_SCALEMODE, &sm);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_SCALEMODE: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_V_SCALING_MODE:
+ gst_vp8_enc->v_scaling_mode = g_value_get_enum (value);
+ if (gst_vp8_enc->inited) {
+ vpx_scaling_mode_t sm;
+
+ sm.h_scaling_mode = gst_vp8_enc->h_scaling_mode;
+ sm.v_scaling_mode = gst_vp8_enc->v_scaling_mode;
+
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_SCALEMODE, &sm);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_SCALEMODE: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_CPU_USED:
+ gst_vp8_enc->cpu_used = g_value_get_int (value);
+ if (gst_vp8_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_CPUUSED,
+ gst_vp8_enc->cpu_used);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc, "Failed to set VP8E_SET_CPUUSED: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_ENABLE_AUTO_ALT_REF:
+ gst_vp8_enc->enable_auto_alt_ref = g_value_get_boolean (value);
+ if (gst_vp8_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_ENABLEAUTOALTREF,
+ (gst_vp8_enc->enable_auto_alt_ref ? 1 : 0));
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_ENABLEAUTOALTREF: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_NOISE_SENSITIVITY:
+ gst_vp8_enc->noise_sensitivity = g_value_get_int (value);
+ if (gst_vp8_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder,
+ VP8E_SET_NOISE_SENSITIVITY, gst_vp8_enc->noise_sensitivity);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_NOISE_SENSITIVITY: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_SHARPNESS:
+ gst_vp8_enc->sharpness = g_value_get_int (value);
+ if (gst_vp8_enc->inited) {
+ status = vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_SHARPNESS,
+ gst_vp8_enc->sharpness);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_SHARPNESS: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_STATIC_THRESHOLD:
+ gst_vp8_enc->static_threshold = g_value_get_int (value);
+ if (gst_vp8_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_STATIC_THRESHOLD,
+ gst_vp8_enc->static_threshold);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_STATIC_THRESHOLD: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_TOKEN_PARTITIONS:
+ gst_vp8_enc->token_partitions = g_value_get_enum (value);
+ if (gst_vp8_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_TOKEN_PARTITIONS,
+ gst_vp8_enc->token_partitions);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_TOKEN_PARTIONS: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_ARNR_MAXFRAMES:
+ gst_vp8_enc->arnr_maxframes = g_value_get_int (value);
+ if (gst_vp8_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_ARNR_MAXFRAMES,
+ gst_vp8_enc->arnr_maxframes);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_ARNR_MAXFRAMES: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_ARNR_STRENGTH:
+ gst_vp8_enc->arnr_strength = g_value_get_int (value);
+ if (gst_vp8_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_ARNR_STRENGTH,
+ gst_vp8_enc->arnr_strength);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_ARNR_STRENGTH: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_ARNR_TYPE:
+ gst_vp8_enc->arnr_type = g_value_get_int (value);
+ g_warning ("arnr-type is a no-op since control has been deprecated "
+ "in libvpx");
+ break;
+ case PROP_TUNING:
+ gst_vp8_enc->tuning = g_value_get_enum (value);
+ if (gst_vp8_enc->inited) {
+ status = vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_TUNING,
+ gst_vp8_enc->tuning);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_TUNING: %s", gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_CQ_LEVEL:
+ gst_vp8_enc->cq_level = g_value_get_int (value);
+ if (gst_vp8_enc->inited) {
+ status = vpx_codec_control (&gst_vp8_enc->encoder, VP8E_SET_CQ_LEVEL,
+ gst_vp8_enc->cq_level);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_CQ_LEVEL: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_MAX_INTRA_BITRATE_PCT:
+ gst_vp8_enc->max_intra_bitrate_pct = g_value_get_int (value);
+ if (gst_vp8_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp8_enc->encoder,
+ VP8E_SET_MAX_INTRA_BITRATE_PCT, gst_vp8_enc->max_intra_bitrate_pct);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp8_enc,
+ "Failed to set VP8E_SET_MAX_INTRA_BITRATE_PCT: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_TIMEBASE:
+ gst_vp8_enc->timebase_n = gst_value_get_fraction_numerator (value);
+ gst_vp8_enc->timebase_d = gst_value_get_fraction_denominator (value);
+ break;
+ default:
+ break;
+ }
+
+ if (global &&gst_vp8_enc->inited) {
+ status =
+ vpx_codec_enc_config_set (&gst_vp8_enc->encoder, &gst_vp8_enc->cfg);
+ if (status != VPX_CODEC_OK) {
+ g_mutex_unlock (&gst_vp8_enc->encoder_lock);
+ GST_ELEMENT_ERROR (gst_vp8_enc, LIBRARY, INIT,
+ ("Failed to set encoder configuration"), ("%s",
+ gst_vpx_error_name (status)));
+ } else {
+ g_mutex_unlock (&gst_vp8_enc->encoder_lock);
+ }
+ } else {
+ g_mutex_unlock (&gst_vp8_enc->encoder_lock);
+ }
+}
+
+static void
+gst_vp8_enc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
+ GstVP8Enc *gst_vp8_enc;
+
+ g_return_if_fail (GST_IS_VP8_ENC (object));
+ gst_vp8_enc = GST_VP8_ENC (object);
+
+ g_mutex_lock (&gst_vp8_enc->encoder_lock);
+ switch (prop_id) {
+ case PROP_RC_END_USAGE:
+ g_value_set_enum (value, gst_vp8_enc->cfg.rc_end_usage);
+ break;
+ case PROP_RC_TARGET_BITRATE:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_target_bitrate * 1000);
+ break;
+ case PROP_RC_MIN_QUANTIZER:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_min_quantizer);
+ break;
+ case PROP_RC_MAX_QUANTIZER:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_max_quantizer);
+ break;
+ case PROP_RC_DROPFRAME_THRESH:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_dropframe_thresh);
+ break;
+ case PROP_RC_RESIZE_ALLOWED:
+ g_value_set_boolean (value, gst_vp8_enc->cfg.rc_resize_allowed);
+ break;
+ case PROP_RC_RESIZE_UP_THRESH:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_resize_up_thresh);
+ break;
+ case PROP_RC_RESIZE_DOWN_THRESH:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_resize_down_thresh);
+ break;
+ case PROP_RC_UNDERSHOOT_PCT:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_undershoot_pct);
+ break;
+ case PROP_RC_OVERSHOOT_PCT:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_overshoot_pct);
+ break;
+ case PROP_RC_BUF_SZ:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_buf_sz);
+ break;
+ case PROP_RC_BUF_INITIAL_SZ:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_buf_initial_sz);
+ break;
+ case PROP_RC_BUF_OPTIMAL_SZ:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_buf_optimal_sz);
+ break;
+ case PROP_RC_2PASS_VBR_BIAS_PCT:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_2pass_vbr_bias_pct);
+ break;
+ case PROP_RC_2PASS_VBR_MINSECTION_PCT:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_2pass_vbr_minsection_pct);
+ break;
+ case PROP_RC_2PASS_VBR_MAXSECTION_PCT:
+ g_value_set_int (value, gst_vp8_enc->cfg.rc_2pass_vbr_maxsection_pct);
+ break;
+ case PROP_KF_MODE:
+ g_value_set_enum (value, gst_vp8_enc->cfg.kf_mode);
+ break;
+ case PROP_KF_MAX_DIST:
+ g_value_set_int (value, gst_vp8_enc->cfg.kf_max_dist);
+ break;
+ case PROP_MULTIPASS_MODE:
+ g_value_set_enum (value, gst_vp8_enc->cfg.g_pass);
+ break;
+ case PROP_MULTIPASS_CACHE_FILE:
+ g_value_set_string (value, gst_vp8_enc->multipass_cache_file);
+ break;
+ case PROP_TS_NUMBER_LAYERS:
+ g_value_set_int (value, gst_vp8_enc->cfg.ts_number_layers);
+ break;
+ case PROP_TS_TARGET_BITRATE:{
+ GValueArray *va;
+
+ if (gst_vp8_enc->n_ts_target_bitrate == 0) {
+ g_value_set_boxed (value, NULL);
+ } else {
+ gint i;
+
+ va = g_value_array_new (gst_vp8_enc->n_ts_target_bitrate);
+ for (i = 0; i < gst_vp8_enc->n_ts_target_bitrate; i++) {
+ GValue v = { 0, };
+
+ g_value_init (&v, G_TYPE_INT);
+ g_value_set_int (&v, gst_vp8_enc->cfg.ts_target_bitrate[i]);
+ g_value_array_append (va, &v);
+ g_value_unset (&v);
+ }
+ g_value_set_boxed (value, va);
+ g_value_array_free (va);
+ }
+ break;
+ }
+ case PROP_TS_RATE_DECIMATOR:{
+ GValueArray *va;
+
+ if (gst_vp8_enc->n_ts_rate_decimator == 0) {
+ g_value_set_boxed (value, NULL);
+ } else {
+ gint i;
+
+ va = g_value_array_new (gst_vp8_enc->n_ts_rate_decimator);
+ for (i = 0; i < gst_vp8_enc->n_ts_rate_decimator; i++) {
+ GValue v = { 0, };
+
+ g_value_init (&v, G_TYPE_INT);
+ g_value_set_int (&v, gst_vp8_enc->cfg.ts_rate_decimator[i]);
+ g_value_array_append (va, &v);
+ g_value_unset (&v);
+ }
+ g_value_set_boxed (value, va);
+ g_value_array_free (va);
+ }
+ break;
+ }
+ case PROP_TS_PERIODICITY:
+ g_value_set_int (value, gst_vp8_enc->cfg.ts_periodicity);
+ break;
+ case PROP_TS_LAYER_ID:{
+ GValueArray *va;
+
+ if (gst_vp8_enc->n_ts_layer_id == 0) {
+ g_value_set_boxed (value, NULL);
+ } else {
+ gint i;
+
+ va = g_value_array_new (gst_vp8_enc->n_ts_layer_id);
+ for (i = 0; i < gst_vp8_enc->n_ts_layer_id; i++) {
+ GValue v = { 0, };
+
+ g_value_init (&v, G_TYPE_INT);
+ g_value_set_int (&v, gst_vp8_enc->cfg.ts_layer_id[i]);
+ g_value_array_append (va, &v);
+ g_value_unset (&v);
+ }
+ g_value_set_boxed (value, va);
+ g_value_array_free (va);
+ }
+ break;
+ }
+ case PROP_ERROR_RESILIENT:
+ g_value_set_flags (value, gst_vp8_enc->cfg.g_error_resilient);
+ break;
+ case PROP_LAG_IN_FRAMES:
+ g_value_set_int (value, gst_vp8_enc->cfg.g_lag_in_frames);
+ break;
+ case PROP_THREADS:
+ g_value_set_int (value, gst_vp8_enc->cfg.g_threads);
+ break;
+ case PROP_DEADLINE:
+ g_value_set_int64 (value, gst_vp8_enc->deadline);
+ break;
+ case PROP_H_SCALING_MODE:
+ g_value_set_enum (value, gst_vp8_enc->h_scaling_mode);
+ break;
+ case PROP_V_SCALING_MODE:
+ g_value_set_enum (value, gst_vp8_enc->v_scaling_mode);
+ break;
+ case PROP_CPU_USED:
+ g_value_set_int (value, gst_vp8_enc->cpu_used);
+ break;
+ case PROP_ENABLE_AUTO_ALT_REF:
+ g_value_set_boolean (value, gst_vp8_enc->enable_auto_alt_ref);
+ break;
+ case PROP_NOISE_SENSITIVITY:
+ g_value_set_int (value, gst_vp8_enc->noise_sensitivity);
+ break;
+ case PROP_SHARPNESS:
+ g_value_set_int (value, gst_vp8_enc->sharpness);
+ break;
+ case PROP_STATIC_THRESHOLD:
+ g_value_set_int (value, gst_vp8_enc->static_threshold);
+ break;
+ case PROP_TOKEN_PARTITIONS:
+ g_value_set_enum (value, gst_vp8_enc->token_partitions);
+ break;
+ case PROP_ARNR_MAXFRAMES:
+ g_value_set_int (value, gst_vp8_enc->arnr_maxframes);
+ break;
+ case PROP_ARNR_STRENGTH:
+ g_value_set_int (value, gst_vp8_enc->arnr_strength);
+ break;
+ case PROP_ARNR_TYPE:
+ g_value_set_int (value, gst_vp8_enc->arnr_type);
+ break;
+ case PROP_TUNING:
+ g_value_set_enum (value, gst_vp8_enc->tuning);
+ break;
+ case PROP_CQ_LEVEL:
+ g_value_set_int (value, gst_vp8_enc->cq_level);
+ break;
+ case PROP_MAX_INTRA_BITRATE_PCT:
+ g_value_set_int (value, gst_vp8_enc->max_intra_bitrate_pct);
+ break;
+ case PROP_TIMEBASE:
+ gst_value_set_fraction (value, gst_vp8_enc->timebase_n,
+ gst_vp8_enc->timebase_d);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+
+ g_mutex_unlock (&gst_vp8_enc->encoder_lock);
+}
+
+static gboolean
+gst_vp8_enc_start (GstVideoEncoder * video_encoder)
+{
+ GstVP8Enc *encoder = GST_VP8_ENC (video_encoder);
+
+ GST_DEBUG_OBJECT (video_encoder, "start");
+
+ if (!encoder->have_default_config) {
+ GST_ELEMENT_ERROR (encoder, LIBRARY, INIT,
+ ("Failed to get default encoder configuration"), (NULL));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+gst_vp8_enc_stop (GstVideoEncoder * video_encoder)
+{
+ GstVP8Enc *encoder;
+
+ GST_DEBUG_OBJECT (video_encoder, "stop");
+
+ encoder = GST_VP8_ENC (video_encoder);
+
+ g_mutex_lock (&encoder->encoder_lock);
+ if (encoder->inited) {
+ vpx_codec_destroy (&encoder->encoder);
+ encoder->inited = FALSE;
+ }
+
+ if (encoder->first_pass_cache_content) {
+ g_byte_array_free (encoder->first_pass_cache_content, TRUE);
+ encoder->first_pass_cache_content = NULL;
+ }
+
+ if (encoder->cfg.rc_twopass_stats_in.buf) {
+ g_free (encoder->cfg.rc_twopass_stats_in.buf);
+ encoder->cfg.rc_twopass_stats_in.buf = NULL;
+ encoder->cfg.rc_twopass_stats_in.sz = 0;
+ }
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ gst_tag_setter_reset_tags (GST_TAG_SETTER (encoder));
+
+ return TRUE;
+}
+
+static gint
+gst_vp8_enc_get_downstream_profile (GstVP8Enc * encoder)
+{
+ GstCaps *allowed;
+ GstStructure *s;
+ gint profile = DEFAULT_PROFILE;
+
+ allowed = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder));
+ if (allowed) {
+ allowed = gst_caps_truncate (allowed);
+ s = gst_caps_get_structure (allowed, 0);
+ if (gst_structure_has_field (s, "profile")) {
+ const GValue *v = gst_structure_get_value (s, "profile");
+ const gchar *profile_str = NULL;
+
+ if (GST_VALUE_HOLDS_LIST (v) && gst_value_list_get_size (v) > 0) {
+ profile_str = g_value_get_string (gst_value_list_get_value (v, 0));
+ } else if (G_VALUE_HOLDS_STRING (v)) {
+ profile_str = g_value_get_string (v);
+ }
+
+ if (profile_str) {
+ gchar *endptr = NULL;
+
+ profile = g_ascii_strtoull (profile_str, &endptr, 10);
+ if (*endptr != '\0' || profile < 0 || profile > 3) {
+ GST_ERROR_OBJECT (encoder, "Invalid profile '%s'", profile_str);
+ profile = DEFAULT_PROFILE;
+ }
+ }
+ }
+ gst_caps_unref (allowed);
+ }
+
+ GST_DEBUG_OBJECT (encoder, "Using profile %d", profile);
+
+ return profile;
+}
+
+static gboolean
+gst_vp8_enc_set_format (GstVideoEncoder * video_encoder,
+ GstVideoCodecState * state)
+{
+ GstVP8Enc *encoder;
+ vpx_codec_err_t status;
+ vpx_image_t *image;
+ guint8 *data = NULL;
+ GstCaps *caps;
+ gboolean ret = TRUE;
+ GstVideoInfo *info = &state->info;
+ GstVideoCodecState *output_state;
+ gchar *profile_str;
+
+ encoder = GST_VP8_ENC (video_encoder);
+ GST_DEBUG_OBJECT (video_encoder, "set_format");
+
+ if (encoder->inited) {
+ gst_vp8_enc_drain (video_encoder);
+ g_mutex_lock (&encoder->encoder_lock);
+ vpx_codec_destroy (&encoder->encoder);
+ encoder->inited = FALSE;
+ } else {
+ g_mutex_lock (&encoder->encoder_lock);
+ }
+
+ encoder->cfg.g_profile = gst_vp8_enc_get_downstream_profile (encoder);
+
+ /* Scale default bitrate to our size */
+ if (!encoder->rc_target_bitrate_set)
+ encoder->cfg.rc_target_bitrate =
+ gst_util_uint64_scale (DEFAULT_RC_TARGET_BITRATE,
+ GST_VIDEO_INFO_WIDTH (info) * GST_VIDEO_INFO_HEIGHT (info),
+ 320 * 240 * 1000);
+
+ encoder->cfg.g_w = GST_VIDEO_INFO_WIDTH (info);
+ encoder->cfg.g_h = GST_VIDEO_INFO_HEIGHT (info);
+
+ if (encoder->timebase_n != 0 && encoder->timebase_d != 0) {
+ GST_DEBUG_OBJECT (video_encoder, "Using timebase configuration");
+ encoder->cfg.g_timebase.num = encoder->timebase_n;
+ encoder->cfg.g_timebase.den = encoder->timebase_d;
+ } else if (GST_VIDEO_INFO_FPS_D (info) != 0
+ && GST_VIDEO_INFO_FPS_N (info) != 0) {
+ /* GstVideoInfo holds either the framerate or max-framerate (if framerate
+ * is 0) in FPS so this will be used if max-framerate or framerate
+ * is set */
+ GST_DEBUG_OBJECT (video_encoder, "Setting timebase from framerate");
+ encoder->cfg.g_timebase.num = GST_VIDEO_INFO_FPS_D (info);
+ encoder->cfg.g_timebase.den = GST_VIDEO_INFO_FPS_N (info);
+ } else {
+ /* Zero framerate and max-framerate but still need to setup the timebase to avoid
+ * a divide by zero error. Presuming the lowest common denominator will be RTP -
+ * VP8 payload draft states clock rate of 90000 which should work for anyone where
+ * FPS < 90000 (shouldn't be too many cases where it's higher) though wouldn't be optimal. RTP specification
+ * http://tools.ietf.org/html/draft-ietf-payload-vp8-01 section 6.3.1 */
+ GST_WARNING_OBJECT (encoder,
+ "No timebase and zero framerate setting timebase to 1/90000");
+ encoder->cfg.g_timebase.num = 1;
+ encoder->cfg.g_timebase.den = 90000;
+ }
+
+ if (encoder->cfg.g_pass == VPX_RC_FIRST_PASS) {
+ if (encoder->first_pass_cache_content == NULL) {
+ encoder->first_pass_cache_content = g_byte_array_sized_new (4096);
+ }
+ } else if (encoder->cfg.g_pass == VPX_RC_LAST_PASS) {
+ GError *err = NULL;
+
+ if (!encoder->multipass_cache_file) {
+ GST_ELEMENT_ERROR (encoder, RESOURCE, OPEN_READ,
+ ("No multipass cache file provided"), (NULL));
+ g_mutex_unlock (&encoder->encoder_lock);
+ return FALSE;
+ }
+
+ if (encoder->cfg.rc_twopass_stats_in.buf != NULL) {
+ g_free (encoder->cfg.rc_twopass_stats_in.buf);
+ encoder->cfg.rc_twopass_stats_in.buf = NULL;
+ encoder->cfg.rc_twopass_stats_in.sz = 0;
+ }
+
+ if (!g_file_get_contents (encoder->multipass_cache_file,
+ (gchar **) & encoder->cfg.rc_twopass_stats_in.buf,
+ &encoder->cfg.rc_twopass_stats_in.sz, &err)) {
+ GST_ELEMENT_ERROR (encoder, RESOURCE, OPEN_READ,
+ ("Failed to read multipass cache file provided"), ("%s",
+ err->message));
+ g_error_free (err);
+ g_mutex_unlock (&encoder->encoder_lock);
+ return FALSE;
+ }
+ }
+
+ status = vpx_codec_enc_init (&encoder->encoder, &vpx_codec_vp8_cx_algo,
+ &encoder->cfg, 0);
+ if (status != VPX_CODEC_OK) {
+ GST_ELEMENT_ERROR (encoder, LIBRARY, INIT,
+ ("Failed to initialize encoder"), ("%s", gst_vpx_error_name (status)));
+ g_mutex_unlock (&encoder->encoder_lock);
+ return FALSE;
+ }
+
+ {
+ vpx_scaling_mode_t sm;
+
+ sm.h_scaling_mode = encoder->h_scaling_mode;
+ sm.v_scaling_mode = encoder->v_scaling_mode;
+
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_SCALEMODE, &sm);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder, "Failed to set VP8E_SET_SCALEMODE: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+
+ status =
+ vpx_codec_control (&encoder->encoder, VP8E_SET_CPUUSED,
+ encoder->cpu_used);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder, "Failed to set VP8E_SET_CPUUSED: %s",
+ gst_vpx_error_name (status));
+ }
+
+ status =
+ vpx_codec_control (&encoder->encoder, VP8E_SET_ENABLEAUTOALTREF,
+ (encoder->enable_auto_alt_ref ? 1 : 0));
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_ENABLEAUTOALTREF: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_NOISE_SENSITIVITY,
+ encoder->noise_sensitivity);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_NOISE_SENSITIVITY: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_SHARPNESS,
+ encoder->sharpness);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_SHARPNESS: %s", gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_STATIC_THRESHOLD,
+ encoder->static_threshold);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_STATIC_THRESHOLD: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_TOKEN_PARTITIONS,
+ encoder->token_partitions);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_TOKEN_PARTIONS: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_ARNR_MAXFRAMES,
+ encoder->arnr_maxframes);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_ARNR_MAXFRAMES: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_ARNR_STRENGTH,
+ encoder->arnr_strength);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_ARNR_STRENGTH: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_TUNING,
+ encoder->tuning);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_TUNING: %s", gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_CQ_LEVEL,
+ encoder->cq_level);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_CQ_LEVEL: %s", gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_MAX_INTRA_BITRATE_PCT,
+ encoder->max_intra_bitrate_pct);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_MAX_INTRA_BITRATE_PCT: %s",
+ gst_vpx_error_name (status));
+ }
+
+ if (GST_VIDEO_INFO_FPS_D (info) == 0 || GST_VIDEO_INFO_FPS_N (info) == 0) {
+ gst_video_encoder_set_latency (video_encoder, 0, GST_CLOCK_TIME_NONE);
+ } else {
+ gst_video_encoder_set_latency (video_encoder, 0,
+ gst_util_uint64_scale (encoder->cfg.g_lag_in_frames,
+ GST_VIDEO_INFO_FPS_D (info) * GST_SECOND,
+ GST_VIDEO_INFO_FPS_N (info)));
+ }
+ encoder->inited = TRUE;
+
+ /* Store input state */
+ if (encoder->input_state)
+ gst_video_codec_state_unref (encoder->input_state);
+ encoder->input_state = gst_video_codec_state_ref (state);
+
+ /* prepare cached image buffer setup */
+ image = &encoder->image;
+ memset (image, 0, sizeof (*image));
+
+ image->fmt = VPX_IMG_FMT_I420;
+ image->bps = 12;
+ image->x_chroma_shift = image->y_chroma_shift = 1;
+ image->w = image->d_w = GST_VIDEO_INFO_WIDTH (info);
+ image->h = image->d_h = GST_VIDEO_INFO_HEIGHT (info);
+
+ image->stride[VPX_PLANE_Y] = GST_VIDEO_INFO_COMP_STRIDE (info, 0);
+ image->stride[VPX_PLANE_U] = GST_VIDEO_INFO_COMP_STRIDE (info, 1);
+ image->stride[VPX_PLANE_V] = GST_VIDEO_INFO_COMP_STRIDE (info, 2);
+
+ profile_str = g_strdup_printf ("%d", encoder->cfg.g_profile);
+ caps = gst_caps_new_simple ("video/x-vp8",
+ "profile", G_TYPE_STRING, profile_str, NULL);
+ g_free (profile_str);
+
+ {
+ GstStructure *s;
+ GstBuffer *stream_hdr, *vorbiscomment;
+ const GstTagList *iface_tags;
+ GValue array = { 0, };
+ GValue value = { 0, };
+ GstMapInfo map;
+
+ s = gst_caps_get_structure (caps, 0);
+
+ /* put buffers in a fixed list */
+ g_value_init (&array, GST_TYPE_ARRAY);
+ g_value_init (&value, GST_TYPE_BUFFER);
+
+ /* Create Ogg stream-info */
+ stream_hdr = gst_buffer_new_and_alloc (26);
+ gst_buffer_map (stream_hdr, &map, GST_MAP_WRITE);
+ data = map.data;
+
+ GST_WRITE_UINT8 (data, 0x4F);
+ GST_WRITE_UINT32_BE (data + 1, 0x56503830); /* "VP80" */
+ GST_WRITE_UINT8 (data + 5, 0x01); /* stream info header */
+ GST_WRITE_UINT8 (data + 6, 1); /* Major version 1 */
+ GST_WRITE_UINT8 (data + 7, 0); /* Minor version 0 */
+ GST_WRITE_UINT16_BE (data + 8, GST_VIDEO_INFO_WIDTH (info));
+ GST_WRITE_UINT16_BE (data + 10, GST_VIDEO_INFO_HEIGHT (info));
+ GST_WRITE_UINT24_BE (data + 12, GST_VIDEO_INFO_PAR_N (info));
+ GST_WRITE_UINT24_BE (data + 15, GST_VIDEO_INFO_PAR_D (info));
+ GST_WRITE_UINT32_BE (data + 18, GST_VIDEO_INFO_FPS_N (info));
+ GST_WRITE_UINT32_BE (data + 22, GST_VIDEO_INFO_FPS_D (info));
+
+ gst_buffer_unmap (stream_hdr, &map);
+
+ GST_BUFFER_FLAG_SET (stream_hdr, GST_BUFFER_FLAG_HEADER);
+ gst_value_set_buffer (&value, stream_hdr);
+ gst_value_array_append_value (&array, &value);
+ g_value_unset (&value);
+ gst_buffer_unref (stream_hdr);
+
+ iface_tags = gst_tag_setter_get_tag_list (GST_TAG_SETTER (video_encoder));
+ if (iface_tags) {
+ vorbiscomment =
+ gst_tag_list_to_vorbiscomment_buffer (iface_tags,
+ (const guint8 *) "OVP80\2 ", 7,
+ "Encoded with GStreamer vp8enc " PACKAGE_VERSION);
+
+ GST_BUFFER_FLAG_SET (vorbiscomment, GST_BUFFER_FLAG_HEADER);
+
+ g_value_init (&value, GST_TYPE_BUFFER);
+ gst_value_set_buffer (&value, vorbiscomment);
+ gst_value_array_append_value (&array, &value);
+ g_value_unset (&value);
+ gst_buffer_unref (vorbiscomment);
+ }
+
+ gst_structure_set_value (s, "streamheader", &array);
+ g_value_unset (&array);
+ }
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ output_state =
+ gst_video_encoder_set_output_state (video_encoder, caps, state);
+ gst_video_codec_state_unref (output_state);
+
+ gst_video_encoder_negotiate (GST_VIDEO_ENCODER (encoder));
+
+ return ret;
+}
+
+static GstFlowReturn
+gst_vp8_enc_process (GstVP8Enc * encoder)
+{
+ vpx_codec_iter_t iter = NULL;
+ const vpx_codec_cx_pkt_t *pkt;
+ GstVideoEncoder *video_encoder;
+ GstVP8EncUserData *user_data;
+ GstVideoCodecFrame *frame;
+ GstFlowReturn ret = GST_FLOW_OK;
+
+ video_encoder = GST_VIDEO_ENCODER (encoder);
+
+ g_mutex_lock (&encoder->encoder_lock);
+ pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter);
+ while (pkt != NULL) {
+ GstBuffer *buffer;
+ gboolean invisible;
+
+ GST_DEBUG_OBJECT (encoder, "packet %u type %d", (guint) pkt->data.frame.sz,
+ pkt->kind);
+
+ if (pkt->kind == VPX_CODEC_STATS_PKT
+ && encoder->cfg.g_pass == VPX_RC_FIRST_PASS) {
+ GST_LOG_OBJECT (encoder, "handling STATS packet");
+
+ g_byte_array_append (encoder->first_pass_cache_content,
+ pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz);
+
+ frame = gst_video_encoder_get_oldest_frame (video_encoder);
+ if (frame != NULL) {
+ buffer = gst_buffer_new ();
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_LIVE);
+ frame->output_buffer = buffer;
+ g_mutex_unlock (&encoder->encoder_lock);
+ ret = gst_video_encoder_finish_frame (video_encoder, frame);
+ g_mutex_lock (&encoder->encoder_lock);
+ }
+
+ pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter);
+ continue;
+ } else if (pkt->kind != VPX_CODEC_CX_FRAME_PKT) {
+ GST_LOG_OBJECT (encoder, "non frame pkt: %d", pkt->kind);
+ pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter);
+ continue;
+ }
+
+ invisible = (pkt->data.frame.flags & VPX_FRAME_IS_INVISIBLE) != 0;
+ frame = gst_video_encoder_get_oldest_frame (video_encoder);
+ g_assert (frame != NULL);
+ if ((pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0)
+ GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
+ else
+ GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT (frame);
+
+ user_data = gst_video_codec_frame_get_user_data (frame);
+
+ /* FIXME : It would be nice to avoid the memory copy ... */
+ buffer =
+ gst_buffer_new_wrapped (g_memdup (pkt->data.frame.buf,
+ pkt->data.frame.sz), pkt->data.frame.sz);
+
+ if (user_data->image)
+ g_slice_free (vpx_image_t, user_data->image);
+ user_data->image = NULL;
+
+ if (invisible) {
+ user_data->invisible = g_list_append (user_data->invisible, buffer);
+ gst_video_codec_frame_unref (frame);
+ } else {
+ frame->output_buffer = buffer;
+ g_mutex_unlock (&encoder->encoder_lock);
+ ret = gst_video_encoder_finish_frame (video_encoder, frame);
+ g_mutex_lock (&encoder->encoder_lock);
+ }
+
+ pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter);
+ }
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ return ret;
+}
+
+/* This function should be called holding then stream lock*/
+static GstFlowReturn
+gst_vp8_enc_drain (GstVideoEncoder * video_encoder)
+{
+ GstVP8Enc *encoder;
+ int flags = 0;
+ vpx_codec_err_t status;
+ gint64 deadline;
+
+ encoder = GST_VP8_ENC (video_encoder);
+
+ g_mutex_lock (&encoder->encoder_lock);
+ deadline = encoder->deadline;
+
+ status =
+ vpx_codec_encode (&encoder->encoder, NULL, encoder->n_frames, 1, flags,
+ deadline);
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ if (status != 0) {
+ GST_ERROR_OBJECT (encoder, "encode returned %d %s", status,
+ gst_vpx_error_name (status));
+ return GST_FLOW_ERROR;
+ }
+
+ /* dispatch remaining frames */
+ gst_vp8_enc_process (encoder);
+
+ g_mutex_lock (&encoder->encoder_lock);
+ if (encoder->cfg.g_pass == VPX_RC_FIRST_PASS && encoder->multipass_cache_file) {
+ GError *err = NULL;
+
+ if (!g_file_set_contents (encoder->multipass_cache_file,
+ (const gchar *) encoder->first_pass_cache_content->data,
+ encoder->first_pass_cache_content->len, &err)) {
+ GST_ELEMENT_ERROR (encoder, RESOURCE, WRITE, (NULL),
+ ("Failed to write multipass cache file: %s", err->message));
+ g_error_free (err);
+ }
+ }
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_vp8_enc_finish (GstVideoEncoder * video_encoder)
+{
+ GstFlowReturn ret;
+
+ GST_DEBUG_OBJECT (video_encoder, "finish");
+
+ ret = gst_vp8_enc_drain (video_encoder);
+
+ return ret;
+}
+
+static vpx_image_t *
+gst_vp8_enc_buffer_to_image (GstVP8Enc * enc, GstVideoFrame * frame)
+{
+ vpx_image_t *image = g_slice_new (vpx_image_t);
+
+ memcpy (image, &enc->image, sizeof (*image));
+
+ image->planes[VPX_PLANE_Y] = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
+ image->planes[VPX_PLANE_U] = GST_VIDEO_FRAME_COMP_DATA (frame, 1);
+ image->planes[VPX_PLANE_V] = GST_VIDEO_FRAME_COMP_DATA (frame, 2);
+
+ image->stride[VPX_PLANE_Y] = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
+ image->stride[VPX_PLANE_U] = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1);
+ image->stride[VPX_PLANE_V] = GST_VIDEO_FRAME_COMP_STRIDE (frame, 2);
+
+ return image;
+}
+
+static GstFlowReturn
+gst_vp8_enc_handle_frame (GstVideoEncoder * video_encoder,
+ GstVideoCodecFrame * frame)
+{
+ GstVP8Enc *encoder;
+ vpx_codec_err_t status;
+ int flags = 0;
+ vpx_image_t *image;
+ GstVP8EncUserData *user_data;
+ GstVideoFrame vframe;
+
+ GST_DEBUG_OBJECT (video_encoder, "handle_frame");
+
+ encoder = GST_VP8_ENC (video_encoder);
+
+ encoder->n_frames++;
+
+ GST_DEBUG_OBJECT (video_encoder, "size %d %d",
+ GST_VIDEO_INFO_WIDTH (&encoder->input_state->info),
+ GST_VIDEO_INFO_HEIGHT (&encoder->input_state->info));
+
+ gst_video_frame_map (&vframe, &encoder->input_state->info,
+ frame->input_buffer, GST_MAP_READ);
+ image = gst_vp8_enc_buffer_to_image (encoder, &vframe);
+
+ user_data = g_slice_new0 (GstVP8EncUserData);
+ user_data->image = image;
+ gst_video_codec_frame_set_user_data (frame, user_data,
+ (GDestroyNotify) gst_vp8_enc_user_data_free);
+
+ if (GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME (frame)) {
+ flags |= VPX_EFLAG_FORCE_KF;
+ }
+
+ g_mutex_lock (&encoder->encoder_lock);
+ status = vpx_codec_encode (&encoder->encoder, image,
+ encoder->n_frames, 1, flags, encoder->deadline);
+ g_mutex_unlock (&encoder->encoder_lock);
+ gst_video_frame_unmap (&vframe);
+
+ if (status != 0) {
+ GST_ELEMENT_ERROR (encoder, LIBRARY, ENCODE,
+ ("Failed to encode frame"), ("%s", gst_vpx_error_name (status)));
+ gst_video_codec_frame_set_user_data (frame, NULL, NULL);
+ return FALSE;
+ }
+ gst_video_codec_frame_unref (frame);
+ return gst_vp8_enc_process (encoder);
+}
+
+static guint64
+_to_granulepos (guint64 frame_end_number, guint inv_count, guint keyframe_dist)
+{
+ guint64 granulepos;
+ guint inv;
+
+ inv = (inv_count == 0) ? 0x3 : inv_count - 1;
+
+ granulepos = (frame_end_number << 32) | (inv << 30) | (keyframe_dist << 3);
+ return granulepos;
+}
+
+static GstFlowReturn
+gst_vp8_enc_pre_push (GstVideoEncoder * video_encoder,
+ GstVideoCodecFrame * frame)
+{
+ GstVP8Enc *encoder;
+ GstBuffer *buf;
+ GstFlowReturn ret = GST_FLOW_OK;
+ GstVP8EncUserData *user_data = gst_video_codec_frame_get_user_data (frame);
+ GList *l;
+ gint inv_count;
+ GstVideoInfo *info;
+
+ GST_DEBUG_OBJECT (video_encoder, "pre_push");
+
+ encoder = GST_VP8_ENC (video_encoder);
+
+ info = &encoder->input_state->info;
+
+ g_assert (user_data != NULL);
+
+ for (inv_count = 0, l = user_data->invisible; l; inv_count++, l = l->next) {
+ buf = l->data;
+ l->data = NULL;
+
+ /* FIXME : All of this should have already been handled by base classes, no ? */
+ if (l == user_data->invisible
+ && GST_VIDEO_CODEC_FRAME_IS_SYNC_POINT (frame)) {
+ GST_BUFFER_FLAG_UNSET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
+ encoder->keyframe_distance = 0;
+ } else {
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
+ encoder->keyframe_distance++;
+ }
+
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DECODE_ONLY);
+ GST_BUFFER_TIMESTAMP (buf) = GST_BUFFER_TIMESTAMP (frame->output_buffer);
+ GST_BUFFER_DURATION (buf) = 0;
+ if (GST_VIDEO_INFO_FPS_D (info) == 0 || GST_VIDEO_INFO_FPS_N (info) == 0) {
+ GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_OFFSET_NONE;
+ GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET_NONE;
+ } else {
+ GST_BUFFER_OFFSET_END (buf) =
+ _to_granulepos (frame->presentation_frame_number + 1,
+ inv_count, encoder->keyframe_distance);
+ GST_BUFFER_OFFSET (buf) =
+ gst_util_uint64_scale (frame->presentation_frame_number + 1,
+ GST_SECOND * GST_VIDEO_INFO_FPS_D (info),
+ GST_VIDEO_INFO_FPS_N (info));
+ }
+
+ ret = gst_pad_push (GST_VIDEO_ENCODER_SRC_PAD (video_encoder), buf);
+
+ if (ret != GST_FLOW_OK) {
+ GST_WARNING_OBJECT (encoder, "flow error %d", ret);
+ goto done;
+ }
+ }
+
+ buf = frame->output_buffer;
+
+ /* FIXME : All of this should have already been handled by base classes, no ? */
+ if (!user_data->invisible && GST_VIDEO_CODEC_FRAME_IS_SYNC_POINT (frame)) {
+ GST_BUFFER_FLAG_UNSET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
+ encoder->keyframe_distance = 0;
+ } else {
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
+ encoder->keyframe_distance++;
+ }
+
+ if (GST_VIDEO_INFO_FPS_D (info) == 0 || GST_VIDEO_INFO_FPS_N (info) == 0) {
+ GST_BUFFER_OFFSET_END (buf) = GST_BUFFER_OFFSET_NONE;
+ GST_BUFFER_OFFSET (buf) = GST_BUFFER_OFFSET_NONE;
+ } else {
+ GST_BUFFER_OFFSET_END (buf) =
+ _to_granulepos (frame->presentation_frame_number + 1, 0,
+ encoder->keyframe_distance);
+ GST_BUFFER_OFFSET (buf) =
+ gst_util_uint64_scale (frame->presentation_frame_number + 1,
+ GST_SECOND * GST_VIDEO_INFO_FPS_D (info), GST_VIDEO_INFO_FPS_N (info));
+ }
+
+ GST_LOG_OBJECT (video_encoder, "src ts: %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
+
+done:
+ return ret;
+}
+
+static gboolean
+gst_vp8_enc_sink_event (GstVideoEncoder * benc, GstEvent * event)
+{
+ GstVP8Enc *enc = GST_VP8_ENC (benc);
+
+ /* FIXME : Move this to base encoder class */
+
+ if (GST_EVENT_TYPE (event) == GST_EVENT_TAG) {
+ GstTagList *list;
+ GstTagSetter *setter = GST_TAG_SETTER (enc);
+ const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
+
+ gst_event_parse_tag (event, &list);
+ gst_tag_setter_merge_tags (setter, list, mode);
+ }
+
+ /* just peeked, baseclass handles the rest */
+ return GST_VIDEO_ENCODER_CLASS (parent_class)->sink_event (benc, event);
+}
+
+static gboolean
+gst_vp8_enc_propose_allocation (GstVideoEncoder * encoder, GstQuery * query)
+{
+ gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
+
+ return GST_VIDEO_ENCODER_CLASS (parent_class)->propose_allocation (encoder,
+ query);
+}
+
+#endif /* HAVE_VP8_ENCODER */
diff --git a/ext/vpx/gstvp8enc.h b/ext/vpx/gstvp8enc.h
new file mode 100644
index 0000000..206ac02
--- /dev/null
+++ b/ext/vpx/gstvp8enc.h
@@ -0,0 +1,122 @@
+/* VP8
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2010 Entropy Wave Inc
+ * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef __GST_VP8_ENC_H__
+#define __GST_VP8_ENC_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_VP8_ENCODER
+
+#include <gst/gst.h>
+#include <gst/video/gstvideoencoder.h>
+
+/* FIXME: Undef HAVE_CONFIG_H because vpx_codec.h uses it,
+ * which causes compilation failures */
+#ifdef HAVE_CONFIG_H
+#undef HAVE_CONFIG_H
+#endif
+
+#include <vpx/vpx_encoder.h>
+#include <vpx/vp8cx.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_VP8_ENC \
+ (gst_vp8_enc_get_type())
+#define GST_VP8_ENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VP8_ENC,GstVP8Enc))
+#define GST_VP8_ENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VP8_ENC,GstVP8EncClass))
+#define GST_IS_VP8_ENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VP8_ENC))
+#define GST_IS_VP8_ENC_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VP8_ENC))
+
+typedef struct _GstVP8Enc GstVP8Enc;
+typedef struct _GstVP8EncClass GstVP8EncClass;
+
+struct _GstVP8Enc
+{
+ GstVideoEncoder base_video_encoder;
+
+ /* < private > */
+ vpx_codec_ctx_t encoder;
+ GMutex encoder_lock;
+
+ /* properties */
+ vpx_codec_enc_cfg_t cfg;
+ gboolean have_default_config;
+ gboolean rc_target_bitrate_set;
+ gint n_ts_target_bitrate;
+ gint n_ts_rate_decimator;
+ gint n_ts_layer_id;
+ /* Global two-pass options */
+ gchar *multipass_cache_file;
+ GByteArray *first_pass_cache_content;
+
+ /* Encode parameter */
+ gint64 deadline;
+
+ /* Controls */
+ VPX_SCALING_MODE h_scaling_mode;
+ VPX_SCALING_MODE v_scaling_mode;
+ int cpu_used;
+ gboolean enable_auto_alt_ref;
+ unsigned int noise_sensitivity;
+ unsigned int sharpness;
+ unsigned int static_threshold;
+ vp8e_token_partitions token_partitions;
+ unsigned int arnr_maxframes;
+ unsigned int arnr_strength;
+ unsigned int arnr_type;
+ vp8e_tuning tuning;
+ unsigned int cq_level;
+ unsigned int max_intra_bitrate_pct;
+ /* Timebase - a value of 0 will use the framerate */
+ unsigned int timebase_n;
+ unsigned int timebase_d;
+
+ /* state */
+ gboolean inited;
+
+ vpx_image_t image;
+
+ int n_frames;
+ int keyframe_distance;
+
+ GstVideoCodecState *input_state;
+};
+
+struct _GstVP8EncClass
+{
+ GstVideoEncoderClass base_video_encoder_class;
+};
+
+GType gst_vp8_enc_get_type (void);
+
+G_END_DECLS
+
+#endif
+
+#endif /* __GST_VP8_ENC_H__ */
diff --git a/ext/vpx/gstvp8utils.c b/ext/vpx/gstvp8utils.c
new file mode 100644
index 0000000..1721945
--- /dev/null
+++ b/ext/vpx/gstvp8utils.c
@@ -0,0 +1,64 @@
+/* VP8
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2010 Entropy Wave Inc
+ * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+
+/* FIXME: Undef HAVE_CONFIG_H because vpx_codec.h uses it,
+ * which causes compilation failures */
+#ifdef HAVE_CONFIG_H
+#undef HAVE_CONFIG_H
+#endif
+
+#include <vpx/vpx_codec.h>
+
+#include "gstvp8utils.h"
+
+const char *
+gst_vpx_error_name (vpx_codec_err_t status)
+{
+ switch (status) {
+ case VPX_CODEC_OK:
+ return "OK";
+ case VPX_CODEC_ERROR:
+ return "error";
+ case VPX_CODEC_MEM_ERROR:
+ return "mem error";
+ case VPX_CODEC_ABI_MISMATCH:
+ return "abi mismatch";
+ case VPX_CODEC_INCAPABLE:
+ return "incapable";
+ case VPX_CODEC_UNSUP_BITSTREAM:
+ return "unsupported bitstream";
+ case VPX_CODEC_UNSUP_FEATURE:
+ return "unsupported feature";
+ case VPX_CODEC_CORRUPT_FRAME:
+ return "corrupt frame";
+ case VPX_CODEC_INVALID_PARAM:
+ return "invalid parameter";
+ default:
+ return "unknown";
+ }
+}
diff --git a/ext/vpx/gstvp8utils.h b/ext/vpx/gstvp8utils.h
new file mode 100755
index 0000000..ea45df1
--- /dev/null
+++ b/ext/vpx/gstvp8utils.h
@@ -0,0 +1,30 @@
+/* VP8
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2010 Entropy Wave Inc
+ * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <gst/gst.h>
+#include <vpx/vpx_codec.h>
+
+G_BEGIN_DECLS
+
+const char * gst_vpx_error_name (vpx_codec_err_t status);
+
+G_END_DECLS
diff --git a/ext/vpx/gstvp9dec.c b/ext/vpx/gstvp9dec.c
new file mode 100755
index 0000000..ff075bb
--- /dev/null
+++ b/ext/vpx/gstvp9dec.c
@@ -0,0 +1,628 @@
+/* VP9
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2008,2009,2010 Entropy Wave Inc
+ * Copyright (C) 2010-2013 Sebastian Dröge <slomo@circular-chaos.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+/**
+ * SECTION:element-vp9dec
+ * @see_also: vp9enc, matroskademux
+ *
+ * This element decodes VP9 streams into raw video.
+ * <ulink url="http://www.webmproject.org">VP9</ulink> is a royalty-free
+ * video codec maintained by <ulink url="http://www.google.com/">Google
+ * </ulink>. It's the successor of On2 VP3, which was the base of the
+ * Theora video codec.
+ *
+ * <refsect2>
+ * <title>Example pipeline</title>
+ * |[
+ * gst-launch -v filesrc location=videotestsrc.webm ! matroskademux ! vp9dec ! xvimagesink
+ * ]| This example pipeline will decode a WebM stream and decodes the VP9 video.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_VP9_DECODER
+
+#include <string.h>
+
+#include "gstvp8utils.h"
+#include "gstvp9dec.h"
+
+#include <gst/video/gstvideometa.h>
+#include <gst/video/gstvideopool.h>
+
+GST_DEBUG_CATEGORY_STATIC (gst_vp9dec_debug);
+#define GST_CAT_DEFAULT gst_vp9dec_debug
+
+#define DEFAULT_POST_PROCESSING FALSE
+#define DEFAULT_POST_PROCESSING_FLAGS (VP8_DEBLOCK | VP8_DEMACROBLOCK)
+#define DEFAULT_DEBLOCKING_LEVEL 4
+#define DEFAULT_NOISE_LEVEL 0
+#define DEFAULT_THREADS 1
+
+enum
+{
+ PROP_0,
+ PROP_POST_PROCESSING,
+ PROP_POST_PROCESSING_FLAGS,
+ PROP_DEBLOCKING_LEVEL,
+ PROP_NOISE_LEVEL,
+ PROP_THREADS
+};
+
+#define C_FLAGS(v) ((guint) v)
+#define GST_VP9_DEC_TYPE_POST_PROCESSING_FLAGS (gst_vp9_dec_post_processing_flags_get_type())
+static GType
+gst_vp9_dec_post_processing_flags_get_type (void)
+{
+ static const GFlagsValue values[] = {
+ {C_FLAGS (VP8_DEBLOCK), "Deblock", "deblock"},
+ {C_FLAGS (VP8_DEMACROBLOCK), "Demacroblock", "demacroblock"},
+ {C_FLAGS (VP8_ADDNOISE), "Add noise", "addnoise"},
+ {C_FLAGS (VP8_MFQE), "Multi-frame quality enhancement", "mfqe"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_flags_register_static ("GstVP9DecPostProcessingFlags", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#undef C_FLAGS
+
+static void gst_vp9_dec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_vp9_dec_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_vp9_dec_start (GstVideoDecoder * decoder);
+static gboolean gst_vp9_dec_stop (GstVideoDecoder * decoder);
+static gboolean gst_vp9_dec_set_format (GstVideoDecoder * decoder,
+ GstVideoCodecState * state);
+static gboolean gst_vp9_dec_flush (GstVideoDecoder * decoder);
+static GstFlowReturn gst_vp9_dec_handle_frame (GstVideoDecoder * decoder,
+ GstVideoCodecFrame * frame);
+static gboolean gst_vp9_dec_decide_allocation (GstVideoDecoder * decoder,
+ GstQuery * query);
+
+static GstStaticPadTemplate gst_vp9_dec_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-vp9")
+ );
+
+static GstStaticPadTemplate gst_vp9_dec_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ I420, YV12, Y42B, Y444 }"))
+ );
+
+#define parent_class gst_vp9_dec_parent_class
+G_DEFINE_TYPE (GstVP9Dec, gst_vp9_dec, GST_TYPE_VIDEO_DECODER);
+
+static void
+gst_vp9_dec_class_init (GstVP9DecClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *element_class;
+ GstVideoDecoderClass *base_video_decoder_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ element_class = GST_ELEMENT_CLASS (klass);
+ base_video_decoder_class = GST_VIDEO_DECODER_CLASS (klass);
+
+ gobject_class->set_property = gst_vp9_dec_set_property;
+ gobject_class->get_property = gst_vp9_dec_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_POST_PROCESSING,
+ g_param_spec_boolean ("post-processing", "Post Processing",
+ "Enable post processing", DEFAULT_POST_PROCESSING,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_POST_PROCESSING_FLAGS,
+ g_param_spec_flags ("post-processing-flags", "Post Processing Flags",
+ "Flags to control post processing",
+ GST_VP9_DEC_TYPE_POST_PROCESSING_FLAGS, DEFAULT_POST_PROCESSING_FLAGS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_DEBLOCKING_LEVEL,
+ g_param_spec_uint ("deblocking-level", "Deblocking Level",
+ "Deblocking level",
+ 0, 16, DEFAULT_DEBLOCKING_LEVEL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_NOISE_LEVEL,
+ g_param_spec_uint ("noise-level", "Noise Level",
+ "Noise level",
+ 0, 16, DEFAULT_NOISE_LEVEL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_THREADS,
+ g_param_spec_uint ("threads", "Max Threads",
+ "Maximum number of decoding threads",
+ 1, 16, DEFAULT_THREADS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vp9_dec_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vp9_dec_sink_template));
+
+ gst_element_class_set_static_metadata (element_class,
+ "On2 VP9 Decoder",
+ "Codec/Decoder/Video",
+ "Decode VP9 video streams", "David Schleef <ds@entropywave.com>, "
+ "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+ base_video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_vp9_dec_start);
+ base_video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_vp9_dec_stop);
+ base_video_decoder_class->flush = GST_DEBUG_FUNCPTR (gst_vp9_dec_flush);
+ base_video_decoder_class->set_format =
+ GST_DEBUG_FUNCPTR (gst_vp9_dec_set_format);
+ base_video_decoder_class->handle_frame =
+ GST_DEBUG_FUNCPTR (gst_vp9_dec_handle_frame);
+ base_video_decoder_class->decide_allocation = gst_vp9_dec_decide_allocation;
+
+ GST_DEBUG_CATEGORY_INIT (gst_vp9dec_debug, "vp9dec", 0, "VP9 Decoder");
+}
+
+static void
+gst_vp9_dec_init (GstVP9Dec * gst_vp9_dec)
+{
+ GstVideoDecoder *decoder = (GstVideoDecoder *) gst_vp9_dec;
+
+ GST_DEBUG_OBJECT (gst_vp9_dec, "gst_vp9_dec_init");
+ gst_video_decoder_set_packetized (decoder, TRUE);
+ gst_vp9_dec->post_processing = DEFAULT_POST_PROCESSING;
+ gst_vp9_dec->post_processing_flags = DEFAULT_POST_PROCESSING_FLAGS;
+ gst_vp9_dec->deblocking_level = DEFAULT_DEBLOCKING_LEVEL;
+ gst_vp9_dec->noise_level = DEFAULT_NOISE_LEVEL;
+
+ gst_video_decoder_set_needs_format (decoder, TRUE);
+}
+
+static void
+gst_vp9_dec_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstVP9Dec *dec;
+
+ g_return_if_fail (GST_IS_VP9_DEC (object));
+ dec = GST_VP9_DEC (object);
+
+ GST_DEBUG_OBJECT (object, "gst_vp9_dec_set_property");
+ switch (prop_id) {
+ case PROP_POST_PROCESSING:
+ dec->post_processing = g_value_get_boolean (value);
+ break;
+ case PROP_POST_PROCESSING_FLAGS:
+ dec->post_processing_flags = g_value_get_flags (value);
+ break;
+ case PROP_DEBLOCKING_LEVEL:
+ dec->deblocking_level = g_value_get_uint (value);
+ break;
+ case PROP_NOISE_LEVEL:
+ dec->noise_level = g_value_get_uint (value);
+ break;
+ case PROP_THREADS:
+ dec->threads = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_vp9_dec_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
+ GstVP9Dec *dec;
+
+ g_return_if_fail (GST_IS_VP9_DEC (object));
+ dec = GST_VP9_DEC (object);
+
+ switch (prop_id) {
+ case PROP_POST_PROCESSING:
+ g_value_set_boolean (value, dec->post_processing);
+ break;
+ case PROP_POST_PROCESSING_FLAGS:
+ g_value_set_flags (value, dec->post_processing_flags);
+ break;
+ case PROP_DEBLOCKING_LEVEL:
+ g_value_set_uint (value, dec->deblocking_level);
+ break;
+ case PROP_NOISE_LEVEL:
+ g_value_set_uint (value, dec->noise_level);
+ break;
+ case PROP_THREADS:
+ g_value_set_uint (value, dec->threads);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+gst_vp9_dec_start (GstVideoDecoder * decoder)
+{
+ GstVP9Dec *gst_vp9_dec = GST_VP9_DEC (decoder);
+
+ GST_DEBUG_OBJECT (gst_vp9_dec, "start");
+ gst_vp9_dec->decoder_inited = FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+gst_vp9_dec_stop (GstVideoDecoder * base_video_decoder)
+{
+ GstVP9Dec *gst_vp9_dec = GST_VP9_DEC (base_video_decoder);
+
+ GST_DEBUG_OBJECT (gst_vp9_dec, "stop");
+
+ if (gst_vp9_dec->output_state) {
+ gst_video_codec_state_unref (gst_vp9_dec->output_state);
+ gst_vp9_dec->output_state = NULL;
+ }
+
+ if (gst_vp9_dec->input_state) {
+ gst_video_codec_state_unref (gst_vp9_dec->input_state);
+ gst_vp9_dec->input_state = NULL;
+ }
+
+ if (gst_vp9_dec->decoder_inited)
+ vpx_codec_destroy (&gst_vp9_dec->decoder);
+ gst_vp9_dec->decoder_inited = FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+gst_vp9_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
+{
+ GstVP9Dec *gst_vp9_dec = GST_VP9_DEC (decoder);
+
+ GST_DEBUG_OBJECT (gst_vp9_dec, "set_format");
+
+ if (gst_vp9_dec->decoder_inited)
+ vpx_codec_destroy (&gst_vp9_dec->decoder);
+ gst_vp9_dec->decoder_inited = FALSE;
+
+ if (gst_vp9_dec->output_state) {
+ gst_video_codec_state_unref (gst_vp9_dec->output_state);
+ gst_vp9_dec->output_state = NULL;
+ }
+
+ if (gst_vp9_dec->input_state)
+ gst_video_codec_state_unref (gst_vp9_dec->input_state);
+ gst_vp9_dec->input_state = gst_video_codec_state_ref (state);
+
+ return TRUE;
+}
+
+static gboolean
+gst_vp9_dec_flush (GstVideoDecoder * base_video_decoder)
+{
+ GstVP9Dec *decoder;
+
+ GST_DEBUG_OBJECT (base_video_decoder, "flush");
+
+ decoder = GST_VP9_DEC (base_video_decoder);
+
+ if (decoder->output_state) {
+ gst_video_codec_state_unref (decoder->output_state);
+ decoder->output_state = NULL;
+ }
+
+ if (decoder->decoder_inited)
+ vpx_codec_destroy (&decoder->decoder);
+ decoder->decoder_inited = FALSE;
+
+ return TRUE;
+}
+
+static void
+gst_vp9_dec_send_tags (GstVP9Dec * dec)
+{
+ GstTagList *list;
+
+ list = gst_tag_list_new_empty ();
+ gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+ GST_TAG_VIDEO_CODEC, "VP9 video", NULL);
+
+ gst_pad_push_event (GST_VIDEO_DECODER_SRC_PAD (dec),
+ gst_event_new_tag (list));
+}
+
+static void
+gst_vp9_dec_image_to_buffer (GstVP9Dec * dec, const vpx_image_t * img,
+ GstBuffer * buffer)
+{
+ int deststride, srcstride, height, width, line, comp;
+ guint8 *dest, *src;
+ GstVideoFrame frame;
+ GstVideoInfo *info = &dec->output_state->info;
+
+ if (!gst_video_frame_map (&frame, info, buffer, GST_MAP_WRITE)) {
+ GST_ERROR_OBJECT (dec, "Could not map video buffer");
+ }
+
+ for (comp = 0; comp < 3; comp++) {
+ dest = GST_VIDEO_FRAME_COMP_DATA (&frame, comp);
+ src = img->planes[comp];
+ width = GST_VIDEO_FRAME_COMP_WIDTH (&frame, comp);
+ height = GST_VIDEO_FRAME_COMP_HEIGHT (&frame, comp);
+ deststride = GST_VIDEO_FRAME_COMP_STRIDE (&frame, comp);
+ srcstride = img->stride[comp];
+
+ /* FIXME (Edward) : Do a plane memcpy is srcstride == deststride instead
+ * of copying line by line */
+ for (line = 0; line < height; line++) {
+ memcpy (dest, src, width);
+ dest += deststride;
+ src += srcstride;
+ }
+ }
+
+ gst_video_frame_unmap (&frame);
+}
+
+static GstFlowReturn
+open_codec (GstVP9Dec * dec, GstVideoCodecFrame * frame)
+{
+ int flags = 0;
+ vpx_codec_stream_info_t stream_info;
+ vpx_codec_caps_t caps;
+ vpx_codec_dec_cfg_t cfg;
+ vpx_codec_err_t status;
+ GstMapInfo minfo;
+
+ memset (&stream_info, 0, sizeof (stream_info));
+ memset (&cfg, 0, sizeof (cfg));
+ stream_info.sz = sizeof (stream_info);
+
+ if (!gst_buffer_map (frame->input_buffer, &minfo, GST_MAP_READ)) {
+ GST_ERROR_OBJECT (dec, "Failed to map input buffer");
+ return GST_FLOW_ERROR;
+ }
+
+ status = vpx_codec_peek_stream_info (&vpx_codec_vp9_dx_algo,
+ minfo.data, minfo.size, &stream_info);
+
+ gst_buffer_unmap (frame->input_buffer, &minfo);
+
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (dec, "VPX preprocessing error: %s",
+ gst_vpx_error_name (status));
+ gst_video_decoder_finish_frame (GST_VIDEO_DECODER (dec), frame);
+ return GST_FLOW_CUSTOM_SUCCESS_1;
+ }
+ if (!stream_info.is_kf) {
+ GST_WARNING_OBJECT (dec, "No keyframe, skipping");
+ gst_video_decoder_finish_frame (GST_VIDEO_DECODER (dec), frame);
+ return GST_FLOW_CUSTOM_SUCCESS_1;
+ }
+
+ /* FIXME: peek_stream_info() does not return valid values, take input caps */
+ stream_info.w = dec->input_state->info.width;
+ stream_info.h = dec->input_state->info.height;
+
+ cfg.w = stream_info.w;
+ cfg.h = stream_info.h;
+ cfg.threads = dec->threads;
+
+ caps = vpx_codec_get_caps (&vpx_codec_vp9_dx_algo);
+
+ if (dec->post_processing) {
+ if (!(caps & VPX_CODEC_CAP_POSTPROC)) {
+ GST_WARNING_OBJECT (dec, "Decoder does not support post processing");
+ } else {
+ flags |= VPX_CODEC_USE_POSTPROC;
+ }
+ }
+
+ status =
+ vpx_codec_dec_init (&dec->decoder, &vpx_codec_vp9_dx_algo, &cfg, flags);
+ if (status != VPX_CODEC_OK) {
+ GST_ELEMENT_ERROR (dec, LIBRARY, INIT,
+ ("Failed to initialize VP9 decoder"), ("%s",
+ gst_vpx_error_name (status)));
+ return GST_FLOW_ERROR;
+ }
+
+ if ((caps & VPX_CODEC_CAP_POSTPROC) && dec->post_processing) {
+ vp8_postproc_cfg_t pp_cfg = { 0, };
+
+ pp_cfg.post_proc_flag = dec->post_processing_flags;
+ pp_cfg.deblocking_level = dec->deblocking_level;
+ pp_cfg.noise_level = dec->noise_level;
+
+ status = vpx_codec_control (&dec->decoder, VP8_SET_POSTPROC, &pp_cfg);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (dec, "Couldn't set postprocessing settings: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+
+ dec->decoder_inited = TRUE;
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_vp9_dec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
+{
+ GstVP9Dec *dec;
+ GstFlowReturn ret = GST_FLOW_OK;
+ vpx_codec_err_t status;
+ vpx_codec_iter_t iter = NULL;
+ vpx_image_t *img;
+ long decoder_deadline = 0;
+ GstClockTimeDiff deadline;
+ GstMapInfo minfo;
+
+ GST_DEBUG_OBJECT (decoder, "handle_frame");
+
+ dec = GST_VP9_DEC (decoder);
+
+ if (!dec->decoder_inited) {
+ ret = open_codec (dec, frame);
+ if (ret == GST_FLOW_CUSTOM_SUCCESS_1)
+ return GST_FLOW_OK;
+ else if (ret != GST_FLOW_OK)
+ return ret;
+ }
+
+ deadline = gst_video_decoder_get_max_decode_time (decoder, frame);
+ if (deadline < 0) {
+ decoder_deadline = 1;
+ } else if (deadline == G_MAXINT64) {
+ decoder_deadline = 0;
+ } else {
+ decoder_deadline = MAX (1, deadline / GST_MSECOND);
+ }
+
+ if (!gst_buffer_map (frame->input_buffer, &minfo, GST_MAP_READ)) {
+ GST_ERROR_OBJECT (dec, "Failed to map input buffer");
+ return GST_FLOW_ERROR;
+ }
+
+ status = vpx_codec_decode (&dec->decoder,
+ minfo.data, minfo.size, NULL, decoder_deadline);
+
+ gst_buffer_unmap (frame->input_buffer, &minfo);
+
+ if (status) {
+ GST_VIDEO_DECODER_ERROR (decoder, 1, LIBRARY, ENCODE,
+ ("Failed to decode frame"), ("%s", gst_vpx_error_name (status)), ret);
+ return ret;
+ }
+
+ img = vpx_codec_get_frame (&dec->decoder, &iter);
+ if (img) {
+ GstVideoFormat fmt;
+
+ switch (img->fmt) {
+ case VPX_IMG_FMT_I420:
+ fmt = GST_VIDEO_FORMAT_I420;
+ break;
+ case VPX_IMG_FMT_YV12:
+ fmt = GST_VIDEO_FORMAT_YV12;
+ break;
+ case VPX_IMG_FMT_I422:
+ fmt = GST_VIDEO_FORMAT_Y42B;
+ break;
+ case VPX_IMG_FMT_I444:
+ fmt = GST_VIDEO_FORMAT_Y444;
+ break;
+ default:
+ vpx_img_free (img);
+ GST_ELEMENT_ERROR (decoder, LIBRARY, ENCODE,
+ ("Failed to decode frame"), ("Unsupported color format %d",
+ img->fmt));
+ return GST_FLOW_ERROR;
+ break;
+ }
+
+ if (!dec->output_state || dec->output_state->info.finfo->format != fmt ||
+ dec->output_state->info.width != img->d_w ||
+ dec->output_state->info.height != img->d_h) {
+ gboolean send_tags = !dec->output_state;
+
+ if (dec->output_state)
+ gst_video_codec_state_unref (dec->output_state);
+
+ dec->output_state =
+ gst_video_decoder_set_output_state (GST_VIDEO_DECODER (dec),
+ fmt, img->d_w, img->d_h, dec->input_state);
+ gst_video_decoder_negotiate (GST_VIDEO_DECODER (dec));
+
+ if (send_tags)
+ gst_vp9_dec_send_tags (dec);
+ }
+
+ if (deadline < 0) {
+ GST_LOG_OBJECT (dec, "Skipping late frame (%f s past deadline)",
+ (double) -deadline / GST_SECOND);
+ gst_video_decoder_drop_frame (decoder, frame);
+ } else {
+ ret = gst_video_decoder_allocate_output_frame (decoder, frame);
+
+ if (ret == GST_FLOW_OK) {
+ gst_vp9_dec_image_to_buffer (dec, img, frame->output_buffer);
+ ret = gst_video_decoder_finish_frame (decoder, frame);
+ } else {
+ gst_video_decoder_finish_frame (decoder, frame);
+ }
+ }
+
+ vpx_img_free (img);
+
+ while ((img = vpx_codec_get_frame (&dec->decoder, &iter))) {
+ GST_WARNING_OBJECT (decoder, "Multiple decoded frames... dropping");
+ vpx_img_free (img);
+ }
+ } else {
+ /* Invisible frame */
+ GST_VIDEO_CODEC_FRAME_SET_DECODE_ONLY (frame);
+ gst_video_decoder_finish_frame (decoder, frame);
+ }
+
+ return ret;
+}
+
+static gboolean
+gst_vp9_dec_decide_allocation (GstVideoDecoder * bdec, GstQuery * query)
+{
+ GstBufferPool *pool;
+ GstStructure *config;
+
+ if (!GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (bdec, query))
+ return FALSE;
+
+ g_assert (gst_query_get_n_allocation_pools (query) > 0);
+ gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
+ g_assert (pool != NULL);
+
+ config = gst_buffer_pool_get_config (pool);
+ if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
+ gst_buffer_pool_config_add_option (config,
+ GST_BUFFER_POOL_OPTION_VIDEO_META);
+ }
+ gst_buffer_pool_set_config (pool, config);
+ gst_object_unref (pool);
+
+ return TRUE;
+}
+
+#endif /* HAVE_VP9_DECODER */
diff --git a/ext/vpx/gstvp9dec.h b/ext/vpx/gstvp9dec.h
new file mode 100644
index 0000000..8cd69ba
--- /dev/null
+++ b/ext/vpx/gstvp9dec.h
@@ -0,0 +1,92 @@
+/* VP9
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2008,2009,2010 Entropy Wave Inc
+ * Copyright (C) 2010-2013 Sebastian Dröge <slomo@circular-chaos.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef __GST_VP9_DEC_H__
+#define __GST_VP9_DEC_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_VP9_DECODER
+
+#include <gst/gst.h>
+#include <gst/video/gstvideodecoder.h>
+
+/* FIXME: Undef HAVE_CONFIG_H because vpx_codec.h uses it,
+ * which causes compilation failures */
+#ifdef HAVE_CONFIG_H
+#undef HAVE_CONFIG_H
+#endif
+
+#include <vpx/vpx_decoder.h>
+#include <vpx/vp8dx.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_VP9_DEC \
+ (gst_vp9_dec_get_type())
+#define GST_VP9_DEC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VP9_DEC,GstVP9Dec))
+#define GST_VP9_DEC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VP9_DEC,GstVP9DecClass))
+#define GST_IS_VP9_DEC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VP9_DEC))
+#define GST_IS_VP9_DEC_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VP9_DEC))
+
+typedef struct _GstVP9Dec GstVP9Dec;
+typedef struct _GstVP9DecClass GstVP9DecClass;
+
+struct _GstVP9Dec
+{
+ GstVideoDecoder base_video_decoder;
+
+ /* < private > */
+ vpx_codec_ctx_t decoder;
+
+ /* state */
+ gboolean decoder_inited;
+
+ /* properties */
+ gboolean post_processing;
+ enum vp8_postproc_level post_processing_flags;
+ gint deblocking_level;
+ gint noise_level;
+ gint threads;
+
+ GstVideoCodecState *input_state;
+ GstVideoCodecState *output_state;
+};
+
+struct _GstVP9DecClass
+{
+ GstVideoDecoderClass base_video_decoder_class;
+};
+
+GType gst_vp9_dec_get_type (void);
+
+G_END_DECLS
+
+#endif
+
+#endif /* __GST_VP9_DEC_H__ */
diff --git a/ext/vpx/gstvp9enc.c b/ext/vpx/gstvp9enc.c
new file mode 100755
index 0000000..84b4b22
--- /dev/null
+++ b/ext/vpx/gstvp9enc.c
@@ -0,0 +1,1954 @@
+/* VP9
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2010 Entropy Wave Inc
+ * Copyright (C) 2010-2013 Sebastian Dröge <slomo@circular-chaos.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+/**
+ * SECTION:element-vp9enc
+ * @see_also: vp9dec, webmmux, oggmux
+ *
+ * This element encodes raw video into a VP9 stream.
+ * <ulink url="http://www.webmproject.org">VP9</ulink> is a royalty-free
+ * video codec maintained by <ulink url="http://www.google.com/">Google
+ * </ulink>. It's the successor of On2 VP3, which was the base of the
+ * Theora video codec.
+ *
+ * To control the quality of the encoding, the #GstVP9Enc::target-bitrate,
+ * #GstVP9Enc::min-quantizer, #GstVP9Enc::max-quantizer or #GstVP9Enc::cq-level
+ * properties can be used. Which one is used depends on the mode selected by
+ * the #GstVP9Enc::end-usage property.
+ * See <ulink url="http://www.webmproject.org/docs/encoder-parameters/">Encoder Parameters</ulink>
+ * for explanation, examples for useful encoding parameters and more details
+ * on the encoding parameters.
+ *
+ * <refsect2>
+ * <title>Example pipeline</title>
+ * |[
+ * gst-launch -v videotestsrc num-buffers=1000 ! vp9enc ! webmmux ! filesink location=videotestsrc.webm
+ * ]| This example pipeline will encode a test video source to VP9 muxed in an
+ * WebM container.
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_VP9_ENCODER
+
+/* glib decided in 2.32 it would be a great idea to deprecated GValueArray without
+ * providing an alternative
+ *
+ * See https://bugzilla.gnome.org/show_bug.cgi?id=667228
+ * */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
+#include <gst/tag/tag.h>
+#include <gst/video/video.h>
+#include <string.h>
+
+#include "gstvp8utils.h"
+#include "gstvp9enc.h"
+
+GST_DEBUG_CATEGORY_STATIC (gst_vp9enc_debug);
+#define GST_CAT_DEFAULT gst_vp9enc_debug
+
+/* From vp9/vp9_cx_iface.c */
+#define DEFAULT_PROFILE 0
+
+#define DEFAULT_RC_END_USAGE VPX_VBR
+#define DEFAULT_RC_TARGET_BITRATE 256000
+#define DEFAULT_RC_MIN_QUANTIZER 4
+#define DEFAULT_RC_MAX_QUANTIZER 63
+
+#define DEFAULT_RC_DROPFRAME_THRESH 0
+#define DEFAULT_RC_RESIZE_ALLOWED 0
+#define DEFAULT_RC_RESIZE_UP_THRESH 30
+#define DEFAULT_RC_RESIZE_DOWN_THRESH 60
+#define DEFAULT_RC_UNDERSHOOT_PCT 100
+#define DEFAULT_RC_OVERSHOOT_PCT 100
+#define DEFAULT_RC_BUF_SZ 6000
+#define DEFAULT_RC_BUF_INITIAL_SZ 4000
+#define DEFAULT_RC_BUF_OPTIMAL_SZ 5000
+#define DEFAULT_RC_2PASS_VBR_BIAS_PCT 50
+#define DEFAULT_RC_2PASS_VBR_MINSECTION_PCT 0
+#define DEFAULT_RC_2PASS_VBR_MAXSECTION_PCT 400
+
+#define DEFAULT_KF_MODE VPX_KF_AUTO
+#define DEFAULT_KF_MAX_DIST 128
+
+#define DEFAULT_MULTIPASS_MODE VPX_RC_ONE_PASS
+#define DEFAULT_MULTIPASS_CACHE_FILE "multipass.cache"
+
+#define DEFAULT_TS_NUMBER_LAYERS 1
+#define DEFAULT_TS_TARGET_BITRATE NULL
+#define DEFAULT_TS_RATE_DECIMATOR NULL
+#define DEFAULT_TS_PERIODICITY 0
+#define DEFAULT_TS_LAYER_ID NULL
+
+#define DEFAULT_ERROR_RESILIENT 0
+#define DEFAULT_LAG_IN_FRAMES 0
+
+#define DEFAULT_THREADS 0
+
+#define DEFAULT_H_SCALING_MODE VP8E_NORMAL
+#define DEFAULT_V_SCALING_MODE VP8E_NORMAL
+#define DEFAULT_CPU_USED 0
+#define DEFAULT_ENABLE_AUTO_ALT_REF FALSE
+#define DEFAULT_DEADLINE VPX_DL_BEST_QUALITY
+#define DEFAULT_NOISE_SENSITIVITY 0
+#define DEFAULT_SHARPNESS 0
+#define DEFAULT_STATIC_THRESHOLD 0
+#define DEFAULT_TOKEN_PARTITIONS 0
+#define DEFAULT_ARNR_MAXFRAMES 0
+#define DEFAULT_ARNR_STRENGTH 3
+#define DEFAULT_ARNR_TYPE 3
+#define DEFAULT_TUNING VP8_TUNE_PSNR
+#define DEFAULT_CQ_LEVEL 10
+#define DEFAULT_MAX_INTRA_BITRATE_PCT 0
+#define DEFAULT_TIMEBASE_N 0
+#define DEFAULT_TIMEBASE_D 1
+
+enum
+{
+ PROP_0,
+ PROP_RC_END_USAGE,
+ PROP_RC_TARGET_BITRATE,
+ PROP_RC_MIN_QUANTIZER,
+ PROP_RC_MAX_QUANTIZER,
+ PROP_RC_DROPFRAME_THRESH,
+ PROP_RC_RESIZE_ALLOWED,
+ PROP_RC_RESIZE_UP_THRESH,
+ PROP_RC_RESIZE_DOWN_THRESH,
+ PROP_RC_UNDERSHOOT_PCT,
+ PROP_RC_OVERSHOOT_PCT,
+ PROP_RC_BUF_SZ,
+ PROP_RC_BUF_INITIAL_SZ,
+ PROP_RC_BUF_OPTIMAL_SZ,
+ PROP_RC_2PASS_VBR_BIAS_PCT,
+ PROP_RC_2PASS_VBR_MINSECTION_PCT,
+ PROP_RC_2PASS_VBR_MAXSECTION_PCT,
+ PROP_KF_MODE,
+ PROP_KF_MAX_DIST,
+ PROP_TS_NUMBER_LAYERS,
+ PROP_TS_TARGET_BITRATE,
+ PROP_TS_RATE_DECIMATOR,
+ PROP_TS_PERIODICITY,
+ PROP_TS_LAYER_ID,
+ PROP_MULTIPASS_MODE,
+ PROP_MULTIPASS_CACHE_FILE,
+ PROP_ERROR_RESILIENT,
+ PROP_LAG_IN_FRAMES,
+ PROP_THREADS,
+ PROP_DEADLINE,
+ PROP_H_SCALING_MODE,
+ PROP_V_SCALING_MODE,
+ PROP_CPU_USED,
+ PROP_ENABLE_AUTO_ALT_REF,
+ PROP_NOISE_SENSITIVITY,
+ PROP_SHARPNESS,
+ PROP_STATIC_THRESHOLD,
+ PROP_TOKEN_PARTITIONS,
+ PROP_ARNR_MAXFRAMES,
+ PROP_ARNR_STRENGTH,
+ PROP_ARNR_TYPE,
+ PROP_TUNING,
+ PROP_CQ_LEVEL,
+ PROP_MAX_INTRA_BITRATE_PCT,
+ PROP_TIMEBASE
+};
+
+#define GST_VP9_ENC_END_USAGE_TYPE (gst_vp9_enc_end_usage_get_type())
+static GType
+gst_vp9_enc_end_usage_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VPX_VBR, "Variable Bit Rate (VBR) mode", "vbr"},
+ {VPX_CBR, "Constant Bit Rate (CBR) mode", "cbr"},
+ {VPX_CQ, "Constant Quality Mode (CQ) mode", "cq"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP9EncEndUsage", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP9_ENC_MULTIPASS_MODE_TYPE (gst_vp9_enc_multipass_mode_get_type())
+static GType
+gst_vp9_enc_multipass_mode_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VPX_RC_ONE_PASS, "One pass encoding (default)", "one-pass"},
+ {VPX_RC_FIRST_PASS, "First pass of multipass encoding", "first-pass"},
+ {VPX_RC_LAST_PASS, "Last pass of multipass encoding", "last-pass"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP9EncMultipassMode", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP9_ENC_KF_MODE_TYPE (gst_vp9_enc_kf_mode_get_type())
+static GType
+gst_vp9_enc_kf_mode_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VPX_KF_AUTO, "Determine optimal placement automatically", "auto"},
+ {VPX_KF_DISABLED, "Don't automatically place keyframes", "disabled"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP9EncKfMode", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP9_ENC_TUNING_TYPE (gst_vp9_enc_tuning_get_type())
+static GType
+gst_vp9_enc_tuning_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VP8_TUNE_PSNR, "Tune for PSNR", "psnr"},
+ {VP8_TUNE_SSIM, "Tune for SSIM", "ssim"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP9EncTuning", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP9_ENC_SCALING_MODE_TYPE (gst_vp9_enc_scaling_mode_get_type())
+static GType
+gst_vp9_enc_scaling_mode_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VP8E_NORMAL, "Normal", "normal"},
+ {VP8E_FOURFIVE, "4:5", "4:5"},
+ {VP8E_THREEFIVE, "3:5", "3:5"},
+ {VP8E_ONETWO, "1:2", "1:2"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP9EncScalingMode", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP9_ENC_TOKEN_PARTITIONS_TYPE (gst_vp9_enc_token_partitions_get_type())
+static GType
+gst_vp9_enc_token_partitions_get_type (void)
+{
+ static const GEnumValue values[] = {
+ {VP8_ONE_TOKENPARTITION, "One token partition", "1"},
+ {VP8_TWO_TOKENPARTITION, "Two token partitions", "2"},
+ {VP8_FOUR_TOKENPARTITION, "Four token partitions", "4"},
+ {VP8_EIGHT_TOKENPARTITION, "Eight token partitions", "8"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_enum_register_static ("GstVP9EncTokenPartitions", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+#define GST_VP9_ENC_ER_FLAGS_TYPE (gst_vp9_enc_er_flags_get_type())
+static GType
+gst_vp9_enc_er_flags_get_type (void)
+{
+ static const GFlagsValue values[] = {
+ {VPX_ERROR_RESILIENT_DEFAULT, "Default error resilience", "default"},
+ {VPX_ERROR_RESILIENT_PARTITIONS,
+ "Allow partitions to be decoded independently", "partitions"},
+ {0, NULL, NULL}
+ };
+ static volatile GType id = 0;
+
+ if (g_once_init_enter ((gsize *) & id)) {
+ GType _id;
+
+ _id = g_flags_register_static ("GstVP9EncErFlags", values);
+
+ g_once_init_leave ((gsize *) & id, _id);
+ }
+
+ return id;
+}
+
+static void gst_vp9_enc_finalize (GObject * object);
+static void gst_vp9_enc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_vp9_enc_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+static gboolean gst_vp9_enc_start (GstVideoEncoder * encoder);
+static gboolean gst_vp9_enc_stop (GstVideoEncoder * encoder);
+static gboolean gst_vp9_enc_set_format (GstVideoEncoder *
+ video_encoder, GstVideoCodecState * state);
+static GstFlowReturn gst_vp9_enc_finish (GstVideoEncoder * video_encoder);
+static GstFlowReturn gst_vp9_enc_handle_frame (GstVideoEncoder *
+ video_encoder, GstVideoCodecFrame * frame);
+static GstFlowReturn gst_vp9_enc_drain (GstVideoEncoder * video_encoder);
+static gboolean gst_vp9_enc_sink_event (GstVideoEncoder *
+ video_encoder, GstEvent * event);
+static gboolean gst_vp9_enc_propose_allocation (GstVideoEncoder * encoder,
+ GstQuery * query);
+
+/* FIXME: Y42B and Y444 do not work yet it seems */
+static GstStaticPadTemplate gst_vp9_enc_sink_template =
+GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ /*GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ I420, YV12, Y42B, Y444 }")) */
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ I420, YV12 }"))
+ );
+
+static GstStaticPadTemplate gst_vp9_enc_src_template =
+GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-vp9, " "profile = (string) {0, 1, 2, 3}")
+ );
+
+#define parent_class gst_vp9_enc_parent_class
+G_DEFINE_TYPE_WITH_CODE (GstVP9Enc, gst_vp9_enc, GST_TYPE_VIDEO_ENCODER,
+ G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL);
+ G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL););
+
+static void
+gst_vp9_enc_class_init (GstVP9EncClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstElementClass *element_class;
+ GstVideoEncoderClass *video_encoder_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ element_class = GST_ELEMENT_CLASS (klass);
+ video_encoder_class = GST_VIDEO_ENCODER_CLASS (klass);
+
+ gobject_class->set_property = gst_vp9_enc_set_property;
+ gobject_class->get_property = gst_vp9_enc_get_property;
+ gobject_class->finalize = gst_vp9_enc_finalize;
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vp9_enc_src_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_vp9_enc_sink_template));
+
+ gst_element_class_set_static_metadata (element_class,
+ "On2 VP9 Encoder",
+ "Codec/Encoder/Video",
+ "Encode VP9 video streams", "David Schleef <ds@entropywave.com>, "
+ "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
+
+ video_encoder_class->start = gst_vp9_enc_start;
+ video_encoder_class->stop = gst_vp9_enc_stop;
+ video_encoder_class->handle_frame = gst_vp9_enc_handle_frame;
+ video_encoder_class->set_format = gst_vp9_enc_set_format;
+ video_encoder_class->finish = gst_vp9_enc_finish;
+ video_encoder_class->sink_event = gst_vp9_enc_sink_event;
+ video_encoder_class->propose_allocation = gst_vp9_enc_propose_allocation;
+
+ g_object_class_install_property (gobject_class, PROP_RC_END_USAGE,
+ g_param_spec_enum ("end-usage", "Rate control mode",
+ "Rate control mode",
+ GST_VP9_ENC_END_USAGE_TYPE, DEFAULT_RC_END_USAGE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_TARGET_BITRATE,
+ g_param_spec_int ("target-bitrate", "Target bitrate",
+ "Target bitrate (in bits/sec)",
+ 0, G_MAXINT, DEFAULT_RC_TARGET_BITRATE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_MIN_QUANTIZER,
+ g_param_spec_int ("min-quantizer", "Minimum Quantizer",
+ "Minimum Quantizer (best)",
+ 0, 63, DEFAULT_RC_MIN_QUANTIZER,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_MAX_QUANTIZER,
+ g_param_spec_int ("max-quantizer", "Maximum Quantizer",
+ "Maximum Quantizer (worst)",
+ 0, 63, DEFAULT_RC_MAX_QUANTIZER,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_DROPFRAME_THRESH,
+ g_param_spec_int ("dropframe-threshold", "Drop Frame Threshold",
+ "Temporal resampling threshold (buf %)",
+ 0, 100, DEFAULT_RC_DROPFRAME_THRESH,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_RESIZE_ALLOWED,
+ g_param_spec_boolean ("resize-allowed", "Resize Allowed",
+ "Allow spatial resampling",
+ DEFAULT_RC_RESIZE_ALLOWED,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_RESIZE_UP_THRESH,
+ g_param_spec_int ("resize-up-threshold", "Resize Up Threshold",
+ "Upscale threshold (buf %)",
+ 0, 100, DEFAULT_RC_RESIZE_UP_THRESH,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_RESIZE_DOWN_THRESH,
+ g_param_spec_int ("resize-down-threshold", "Resize Down Threshold",
+ "Downscale threshold (buf %)",
+ 0, 100, DEFAULT_RC_RESIZE_DOWN_THRESH,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_UNDERSHOOT_PCT,
+ g_param_spec_int ("undershoot", "Undershoot PCT",
+ "Datarate undershoot (min) target (%)",
+ 0, 1000, DEFAULT_RC_UNDERSHOOT_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_OVERSHOOT_PCT,
+ g_param_spec_int ("overshoot", "Overshoot PCT",
+ "Datarate overshoot (max) target (%)",
+ 0, 1000, DEFAULT_RC_OVERSHOOT_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_BUF_SZ,
+ g_param_spec_int ("buffer-size", "Buffer size",
+ "Client buffer size (ms)",
+ 0, G_MAXINT, DEFAULT_RC_BUF_SZ,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_BUF_INITIAL_SZ,
+ g_param_spec_int ("buffer-initial-size", "Buffer initial size",
+ "Initial client buffer size (ms)",
+ 0, G_MAXINT, DEFAULT_RC_BUF_INITIAL_SZ,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_BUF_OPTIMAL_SZ,
+ g_param_spec_int ("buffer-optimal-size", "Buffer optimal size",
+ "Optimal client buffer size (ms)",
+ 0, G_MAXINT, DEFAULT_RC_BUF_OPTIMAL_SZ,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_RC_2PASS_VBR_BIAS_PCT,
+ g_param_spec_int ("twopass-vbr-bias", "2-pass VBR bias",
+ "CBR/VBR bias (0=CBR, 100=VBR)",
+ 0, 100, DEFAULT_RC_2PASS_VBR_BIAS_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class,
+ PROP_RC_2PASS_VBR_MINSECTION_PCT,
+ g_param_spec_int ("twopass-vbr-minsection", "2-pass GOP min bitrate",
+ "GOP minimum bitrate (% target)", 0, G_MAXINT,
+ DEFAULT_RC_2PASS_VBR_MINSECTION_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class,
+ PROP_RC_2PASS_VBR_MAXSECTION_PCT,
+ g_param_spec_int ("twopass-vbr-maxsection", "2-pass GOP max bitrate",
+ "GOP maximum bitrate (% target)", 0, G_MAXINT,
+ DEFAULT_RC_2PASS_VBR_MINSECTION_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_KF_MODE,
+ g_param_spec_enum ("keyframe-mode", "Keyframe Mode",
+ "Keyframe placement",
+ GST_VP9_ENC_KF_MODE_TYPE, DEFAULT_KF_MODE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_KF_MAX_DIST,
+ g_param_spec_int ("keyframe-max-dist", "Keyframe max distance",
+ "Maximum distance between keyframes (number of frames)",
+ 0, G_MAXINT, DEFAULT_KF_MAX_DIST,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_MULTIPASS_MODE,
+ g_param_spec_enum ("multipass-mode", "Multipass Mode",
+ "Multipass encode mode",
+ GST_VP9_ENC_MULTIPASS_MODE_TYPE, DEFAULT_MULTIPASS_MODE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_MULTIPASS_CACHE_FILE,
+ g_param_spec_string ("multipass-cache-file", "Multipass Cache File",
+ "Multipass cache file",
+ DEFAULT_MULTIPASS_CACHE_FILE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TS_NUMBER_LAYERS,
+ g_param_spec_int ("temporal-scalability-number-layers",
+ "Number of coding layers", "Number of coding layers to use", 1, 5,
+ DEFAULT_TS_NUMBER_LAYERS,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TS_TARGET_BITRATE,
+ g_param_spec_value_array ("temporal-scalability-target-bitrate",
+ "Coding layer target bitrates",
+ "Target bitrates for coding layers (one per layer, decreasing)",
+ g_param_spec_int ("target-bitrate", "Target bitrate",
+ "Target bitrate", 0, G_MAXINT, DEFAULT_RC_TARGET_BITRATE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_TS_RATE_DECIMATOR,
+ g_param_spec_value_array ("temporal-scalability-rate-decimator",
+ "Coding layer rate decimator",
+ "Rate decimation factors for each layer",
+ g_param_spec_int ("rate-decimator", "Rate decimator",
+ "Rate decimator", 0, 1000000000, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_TS_PERIODICITY,
+ g_param_spec_int ("temporal-scalability-periodicity",
+ "Coding layer periodicity",
+ "Length of sequence that defines layer membership periodicity", 0, 16,
+ DEFAULT_TS_PERIODICITY,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TS_LAYER_ID,
+ g_param_spec_value_array ("temporal-scalability-layer-id",
+ "Coding layer identification",
+ "Sequence defining coding layer membership",
+ g_param_spec_int ("layer-id", "Layer ID", "Layer ID", 0, 4, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS),
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_LAG_IN_FRAMES,
+ g_param_spec_int ("lag-in-frames", "Lag in frames",
+ "Maximum number of frames to lag",
+ 0, 25, DEFAULT_LAG_IN_FRAMES,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ERROR_RESILIENT,
+ g_param_spec_flags ("error-resilient", "Error resilient",
+ "Error resilience flags",
+ GST_VP9_ENC_ER_FLAGS_TYPE, DEFAULT_ERROR_RESILIENT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_THREADS,
+ g_param_spec_int ("threads", "Threads",
+ "Number of threads to use",
+ 0, 64, DEFAULT_THREADS,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_DEADLINE,
+ g_param_spec_int64 ("deadline", "Deadline",
+ "Deadline per frame (usec, 0=disabled)",
+ 0, G_MAXINT64, DEFAULT_DEADLINE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_H_SCALING_MODE,
+ g_param_spec_enum ("horizontal-scaling-mode", "Horizontal scaling mode",
+ "Horizontal scaling mode",
+ GST_VP9_ENC_SCALING_MODE_TYPE, DEFAULT_H_SCALING_MODE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_V_SCALING_MODE,
+ g_param_spec_enum ("vertical-scaling-mode", "Vertical scaling mode",
+ "Vertical scaling mode",
+ GST_VP9_ENC_SCALING_MODE_TYPE, DEFAULT_V_SCALING_MODE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_CPU_USED,
+ g_param_spec_int ("cpu-used", "CPU used",
+ "CPU used",
+ -16, 16, DEFAULT_CPU_USED,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ENABLE_AUTO_ALT_REF,
+ g_param_spec_boolean ("auto-alt-ref", "Auto alt reference frames",
+ "Automatically generate AltRef frames",
+ DEFAULT_ENABLE_AUTO_ALT_REF,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_NOISE_SENSITIVITY,
+ g_param_spec_int ("noise-sensitivity", "Noise sensitivity",
+ "Noise sensisivity (frames to blur)",
+ 0, 6, DEFAULT_NOISE_SENSITIVITY,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_SHARPNESS,
+ g_param_spec_int ("sharpness", "Sharpness",
+ "Filter sharpness",
+ 0, 7, DEFAULT_SHARPNESS,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_STATIC_THRESHOLD,
+ g_param_spec_int ("static-threshold", "Static Threshold",
+ "Motion detection threshold",
+ 0, G_MAXINT, DEFAULT_STATIC_THRESHOLD,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TOKEN_PARTITIONS,
+ g_param_spec_enum ("token-partitions", "Token partitions",
+ "Number of token partitions",
+ GST_VP9_ENC_TOKEN_PARTITIONS_TYPE, DEFAULT_TOKEN_PARTITIONS,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ARNR_MAXFRAMES,
+ g_param_spec_int ("arnr-maxframes", "AltRef max frames",
+ "AltRef maximum number of frames",
+ 0, 15, DEFAULT_ARNR_MAXFRAMES,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ARNR_STRENGTH,
+ g_param_spec_int ("arnr-strength", "AltRef strength",
+ "AltRef strength",
+ 0, 6, DEFAULT_ARNR_STRENGTH,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_ARNR_TYPE,
+ g_param_spec_int ("arnr-type", "AltRef type",
+ "AltRef type",
+ 1, 3, DEFAULT_ARNR_TYPE,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+ G_PARAM_DEPRECATED)));
+
+ g_object_class_install_property (gobject_class, PROP_TUNING,
+ g_param_spec_enum ("tuning", "Tuning",
+ "Tuning",
+ GST_VP9_ENC_TUNING_TYPE, DEFAULT_TUNING,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_CQ_LEVEL,
+ g_param_spec_int ("cq-level", "Constrained quality level",
+ "Constrained quality level",
+ 0, 63, DEFAULT_CQ_LEVEL,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_MAX_INTRA_BITRATE_PCT,
+ g_param_spec_int ("max-intra-bitrate", "Max Intra bitrate",
+ "Maximum Intra frame bitrate",
+ 0, G_MAXINT, DEFAULT_MAX_INTRA_BITRATE_PCT,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
+
+ g_object_class_install_property (gobject_class, PROP_TIMEBASE,
+ gst_param_spec_fraction ("timebase", "Shortest interframe time",
+ "Fraction of one second that is the shortest interframe time - normally left as zero which will default to the framerate",
+ 0, 1, G_MAXINT, 1, DEFAULT_TIMEBASE_N, DEFAULT_TIMEBASE_D,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ GST_DEBUG_CATEGORY_INIT (gst_vp9enc_debug, "vp9enc", 0, "VP9 Encoder");
+}
+
+static void
+gst_vp9_enc_init (GstVP9Enc * gst_vp9_enc)
+{
+ vpx_codec_err_t status;
+
+ GST_DEBUG_OBJECT (gst_vp9_enc, "init");
+
+ status =
+ vpx_codec_enc_config_default (&vpx_codec_vp9_cx_algo, &gst_vp9_enc->cfg,
+ 0);
+ if (status != VPX_CODEC_OK) {
+ GST_ERROR_OBJECT (gst_vp9_enc,
+ "Failed to get default encoder configuration: %s",
+ gst_vpx_error_name (status));
+ gst_vp9_enc->have_default_config = FALSE;
+ } else {
+ gst_vp9_enc->have_default_config = TRUE;
+ }
+
+ gst_vp9_enc->cfg.rc_end_usage = DEFAULT_RC_END_USAGE;
+ gst_vp9_enc->cfg.rc_target_bitrate = DEFAULT_RC_TARGET_BITRATE / 1000;
+ gst_vp9_enc->rc_target_bitrate_set = FALSE;
+ gst_vp9_enc->cfg.rc_min_quantizer = DEFAULT_RC_MIN_QUANTIZER;
+ gst_vp9_enc->cfg.rc_max_quantizer = DEFAULT_RC_MAX_QUANTIZER;
+ gst_vp9_enc->cfg.rc_dropframe_thresh = DEFAULT_RC_DROPFRAME_THRESH;
+ gst_vp9_enc->cfg.rc_resize_allowed = DEFAULT_RC_RESIZE_ALLOWED;
+ gst_vp9_enc->cfg.rc_resize_up_thresh = DEFAULT_RC_RESIZE_UP_THRESH;
+ gst_vp9_enc->cfg.rc_resize_down_thresh = DEFAULT_RC_RESIZE_DOWN_THRESH;
+ gst_vp9_enc->cfg.rc_undershoot_pct = DEFAULT_RC_UNDERSHOOT_PCT;
+ gst_vp9_enc->cfg.rc_overshoot_pct = DEFAULT_RC_OVERSHOOT_PCT;
+ gst_vp9_enc->cfg.rc_buf_sz = DEFAULT_RC_BUF_SZ;
+ gst_vp9_enc->cfg.rc_buf_initial_sz = DEFAULT_RC_BUF_INITIAL_SZ;
+ gst_vp9_enc->cfg.rc_buf_optimal_sz = DEFAULT_RC_BUF_OPTIMAL_SZ;
+ gst_vp9_enc->cfg.rc_2pass_vbr_bias_pct = DEFAULT_RC_2PASS_VBR_BIAS_PCT;
+ gst_vp9_enc->cfg.rc_2pass_vbr_minsection_pct =
+ DEFAULT_RC_2PASS_VBR_MINSECTION_PCT;
+ gst_vp9_enc->cfg.rc_2pass_vbr_maxsection_pct =
+ DEFAULT_RC_2PASS_VBR_MAXSECTION_PCT;
+ gst_vp9_enc->cfg.kf_mode = DEFAULT_KF_MODE;
+ gst_vp9_enc->cfg.kf_max_dist = DEFAULT_KF_MAX_DIST;
+ gst_vp9_enc->cfg.g_pass = DEFAULT_MULTIPASS_MODE;
+ gst_vp9_enc->multipass_cache_file = g_strdup (DEFAULT_MULTIPASS_CACHE_FILE);
+ gst_vp9_enc->cfg.ts_number_layers = DEFAULT_TS_NUMBER_LAYERS;
+ gst_vp9_enc->n_ts_target_bitrate = 0;
+ gst_vp9_enc->n_ts_rate_decimator = 0;
+ gst_vp9_enc->cfg.ts_periodicity = DEFAULT_TS_PERIODICITY;
+ gst_vp9_enc->n_ts_layer_id = 0;
+ gst_vp9_enc->cfg.g_error_resilient = DEFAULT_ERROR_RESILIENT;
+ gst_vp9_enc->cfg.g_lag_in_frames = DEFAULT_LAG_IN_FRAMES;
+ gst_vp9_enc->cfg.g_threads = DEFAULT_THREADS;
+ gst_vp9_enc->deadline = DEFAULT_DEADLINE;
+ gst_vp9_enc->h_scaling_mode = DEFAULT_H_SCALING_MODE;
+ gst_vp9_enc->v_scaling_mode = DEFAULT_V_SCALING_MODE;
+ gst_vp9_enc->cpu_used = DEFAULT_CPU_USED;
+ gst_vp9_enc->enable_auto_alt_ref = DEFAULT_ENABLE_AUTO_ALT_REF;
+ gst_vp9_enc->noise_sensitivity = DEFAULT_NOISE_SENSITIVITY;
+ gst_vp9_enc->sharpness = DEFAULT_SHARPNESS;
+ gst_vp9_enc->static_threshold = DEFAULT_STATIC_THRESHOLD;
+ gst_vp9_enc->token_partitions = DEFAULT_TOKEN_PARTITIONS;
+ gst_vp9_enc->arnr_maxframes = DEFAULT_ARNR_MAXFRAMES;
+ gst_vp9_enc->arnr_strength = DEFAULT_ARNR_STRENGTH;
+ gst_vp9_enc->arnr_type = DEFAULT_ARNR_TYPE;
+ gst_vp9_enc->tuning = DEFAULT_TUNING;
+ gst_vp9_enc->cq_level = DEFAULT_CQ_LEVEL;
+ gst_vp9_enc->max_intra_bitrate_pct = DEFAULT_MAX_INTRA_BITRATE_PCT;
+ gst_vp9_enc->timebase_n = DEFAULT_TIMEBASE_N;
+ gst_vp9_enc->timebase_d = DEFAULT_TIMEBASE_D;
+
+ gst_vp9_enc->cfg.g_profile = DEFAULT_PROFILE;
+
+ g_mutex_init (&gst_vp9_enc->encoder_lock);
+}
+
+static void
+gst_vp9_enc_finalize (GObject * object)
+{
+ GstVP9Enc *gst_vp9_enc;
+
+ GST_DEBUG_OBJECT (object, "finalize");
+
+ g_return_if_fail (GST_IS_VP9_ENC (object));
+ gst_vp9_enc = GST_VP9_ENC (object);
+
+ g_free (gst_vp9_enc->multipass_cache_file);
+ gst_vp9_enc->multipass_cache_file = NULL;
+
+ if (gst_vp9_enc->input_state)
+ gst_video_codec_state_unref (gst_vp9_enc->input_state);
+
+ g_mutex_clear (&gst_vp9_enc->encoder_lock);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+
+}
+
+static void
+gst_vp9_enc_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstVP9Enc *gst_vp9_enc;
+ gboolean global = FALSE;
+ vpx_codec_err_t status;
+
+ g_return_if_fail (GST_IS_VP9_ENC (object));
+ gst_vp9_enc = GST_VP9_ENC (object);
+
+ GST_DEBUG_OBJECT (object, "gst_vp9_enc_set_property");
+ g_mutex_lock (&gst_vp9_enc->encoder_lock);
+ switch (prop_id) {
+ case PROP_RC_END_USAGE:
+ gst_vp9_enc->cfg.rc_end_usage = g_value_get_enum (value);
+ global = TRUE;
+ break;
+ case PROP_RC_TARGET_BITRATE:
+ gst_vp9_enc->cfg.rc_target_bitrate = g_value_get_int (value) / 1000;
+ gst_vp9_enc->rc_target_bitrate_set = TRUE;
+ global = TRUE;
+ break;
+ case PROP_RC_MIN_QUANTIZER:
+ gst_vp9_enc->cfg.rc_min_quantizer = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_MAX_QUANTIZER:
+ gst_vp9_enc->cfg.rc_max_quantizer = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_DROPFRAME_THRESH:
+ gst_vp9_enc->cfg.rc_dropframe_thresh = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_RESIZE_ALLOWED:
+ gst_vp9_enc->cfg.rc_resize_allowed = g_value_get_boolean (value);
+ global = TRUE;
+ break;
+ case PROP_RC_RESIZE_UP_THRESH:
+ gst_vp9_enc->cfg.rc_resize_up_thresh = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_RESIZE_DOWN_THRESH:
+ gst_vp9_enc->cfg.rc_resize_down_thresh = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_UNDERSHOOT_PCT:
+ gst_vp9_enc->cfg.rc_undershoot_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_OVERSHOOT_PCT:
+ gst_vp9_enc->cfg.rc_overshoot_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_BUF_SZ:
+ gst_vp9_enc->cfg.rc_buf_sz = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_BUF_INITIAL_SZ:
+ gst_vp9_enc->cfg.rc_buf_initial_sz = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_BUF_OPTIMAL_SZ:
+ gst_vp9_enc->cfg.rc_buf_optimal_sz = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_2PASS_VBR_BIAS_PCT:
+ gst_vp9_enc->cfg.rc_2pass_vbr_bias_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_2PASS_VBR_MINSECTION_PCT:
+ gst_vp9_enc->cfg.rc_2pass_vbr_minsection_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_RC_2PASS_VBR_MAXSECTION_PCT:
+ gst_vp9_enc->cfg.rc_2pass_vbr_maxsection_pct = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_KF_MODE:
+ gst_vp9_enc->cfg.kf_mode = g_value_get_enum (value);
+ global = TRUE;
+ break;
+ case PROP_KF_MAX_DIST:
+ gst_vp9_enc->cfg.kf_max_dist = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_MULTIPASS_MODE:
+ gst_vp9_enc->cfg.g_pass = g_value_get_enum (value);
+ global = TRUE;
+ break;
+ case PROP_MULTIPASS_CACHE_FILE:
+ if (gst_vp9_enc->multipass_cache_file)
+ g_free (gst_vp9_enc->multipass_cache_file);
+ gst_vp9_enc->multipass_cache_file = g_value_dup_string (value);
+ break;
+ case PROP_TS_NUMBER_LAYERS:
+ gst_vp9_enc->cfg.ts_number_layers = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_TS_TARGET_BITRATE:{
+ GValueArray *va = g_value_get_boxed (value);
+
+ memset (&gst_vp9_enc->cfg.ts_target_bitrate, 0,
+ sizeof (gst_vp9_enc->cfg.ts_target_bitrate));
+ if (va == NULL) {
+ gst_vp9_enc->n_ts_target_bitrate = 0;
+ } else {
+ if (va->n_values > VPX_TS_MAX_LAYERS) {
+ g_warning ("%s: Only %d layers allowed at maximum",
+ GST_ELEMENT_NAME (gst_vp9_enc), VPX_TS_MAX_LAYERS);
+ } else {
+ gint i;
+
+ for (i = 0; i < va->n_values; i++)
+ gst_vp9_enc->cfg.ts_target_bitrate[i] =
+ g_value_get_int (g_value_array_get_nth (va, i));
+ gst_vp9_enc->n_ts_target_bitrate = va->n_values;
+ }
+ }
+ global = TRUE;
+ break;
+ }
+ case PROP_TS_RATE_DECIMATOR:{
+ GValueArray *va = g_value_get_boxed (value);
+
+ memset (&gst_vp9_enc->cfg.ts_rate_decimator, 0,
+ sizeof (gst_vp9_enc->cfg.ts_rate_decimator));
+ if (va == NULL) {
+ gst_vp9_enc->n_ts_rate_decimator = 0;
+ } else if (va->n_values > VPX_TS_MAX_LAYERS) {
+ g_warning ("%s: Only %d layers allowed at maximum",
+ GST_ELEMENT_NAME (gst_vp9_enc), VPX_TS_MAX_LAYERS);
+ } else {
+ gint i;
+
+ for (i = 0; i < va->n_values; i++)
+ gst_vp9_enc->cfg.ts_rate_decimator[i] =
+ g_value_get_int (g_value_array_get_nth (va, i));
+ gst_vp9_enc->n_ts_rate_decimator = va->n_values;
+ }
+ global = TRUE;
+ break;
+ }
+ case PROP_TS_PERIODICITY:
+ gst_vp9_enc->cfg.ts_periodicity = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_TS_LAYER_ID:{
+ GValueArray *va = g_value_get_boxed (value);
+
+ memset (&gst_vp9_enc->cfg.ts_layer_id, 0,
+ sizeof (gst_vp9_enc->cfg.ts_layer_id));
+ if (va && va->n_values > VPX_TS_MAX_PERIODICITY) {
+ g_warning ("%s: Only %d sized layer sequences allowed at maximum",
+ GST_ELEMENT_NAME (gst_vp9_enc), VPX_TS_MAX_PERIODICITY);
+ } else if (va) {
+ gint i;
+
+ for (i = 0; i < va->n_values; i++)
+ gst_vp9_enc->cfg.ts_layer_id[i] =
+ g_value_get_int (g_value_array_get_nth (va, i));
+ gst_vp9_enc->n_ts_layer_id = va->n_values;
+ } else {
+ gst_vp9_enc->n_ts_layer_id = 0;
+ }
+ global = TRUE;
+ break;
+ }
+ case PROP_ERROR_RESILIENT:
+ gst_vp9_enc->cfg.g_error_resilient = g_value_get_flags (value);
+ global = TRUE;
+ break;
+ case PROP_LAG_IN_FRAMES:
+ gst_vp9_enc->cfg.g_lag_in_frames = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_THREADS:
+ gst_vp9_enc->cfg.g_threads = g_value_get_int (value);
+ global = TRUE;
+ break;
+ case PROP_DEADLINE:
+ gst_vp9_enc->deadline = g_value_get_int64 (value);
+ break;
+ case PROP_H_SCALING_MODE:
+ gst_vp9_enc->h_scaling_mode = g_value_get_enum (value);
+ if (gst_vp9_enc->inited) {
+ vpx_scaling_mode_t sm;
+
+ sm.h_scaling_mode = gst_vp9_enc->h_scaling_mode;
+ sm.v_scaling_mode = gst_vp9_enc->v_scaling_mode;
+
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_SCALEMODE, &sm);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_SCALEMODE: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_V_SCALING_MODE:
+ gst_vp9_enc->v_scaling_mode = g_value_get_enum (value);
+ if (gst_vp9_enc->inited) {
+ vpx_scaling_mode_t sm;
+
+ sm.h_scaling_mode = gst_vp9_enc->h_scaling_mode;
+ sm.v_scaling_mode = gst_vp9_enc->v_scaling_mode;
+
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_SCALEMODE, &sm);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_SCALEMODE: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_CPU_USED:
+ gst_vp9_enc->cpu_used = g_value_get_int (value);
+ if (gst_vp9_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_CPUUSED,
+ gst_vp9_enc->cpu_used);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc, "Failed to set VP8E_SET_CPUUSED: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_ENABLE_AUTO_ALT_REF:
+ gst_vp9_enc->enable_auto_alt_ref = g_value_get_boolean (value);
+ if (gst_vp9_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_ENABLEAUTOALTREF,
+ (gst_vp9_enc->enable_auto_alt_ref ? 1 : 0));
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_ENABLEAUTOALTREF: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_NOISE_SENSITIVITY:
+ gst_vp9_enc->noise_sensitivity = g_value_get_int (value);
+ if (gst_vp9_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder,
+ VP8E_SET_NOISE_SENSITIVITY, gst_vp9_enc->noise_sensitivity);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_NOISE_SENSITIVITY: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_SHARPNESS:
+ gst_vp9_enc->sharpness = g_value_get_int (value);
+ if (gst_vp9_enc->inited) {
+ status = vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_SHARPNESS,
+ gst_vp9_enc->sharpness);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_SHARPNESS: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_STATIC_THRESHOLD:
+ gst_vp9_enc->static_threshold = g_value_get_int (value);
+ if (gst_vp9_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_STATIC_THRESHOLD,
+ gst_vp9_enc->static_threshold);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_STATIC_THRESHOLD: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_TOKEN_PARTITIONS:
+ gst_vp9_enc->token_partitions = g_value_get_enum (value);
+ if (gst_vp9_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_TOKEN_PARTITIONS,
+ gst_vp9_enc->token_partitions);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_TOKEN_PARTIONS: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_ARNR_MAXFRAMES:
+ gst_vp9_enc->arnr_maxframes = g_value_get_int (value);
+ if (gst_vp9_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_ARNR_MAXFRAMES,
+ gst_vp9_enc->arnr_maxframes);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_ARNR_MAXFRAMES: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_ARNR_STRENGTH:
+ gst_vp9_enc->arnr_strength = g_value_get_int (value);
+ if (gst_vp9_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_ARNR_STRENGTH,
+ gst_vp9_enc->arnr_strength);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_ARNR_STRENGTH: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_ARNR_TYPE:
+ gst_vp9_enc->arnr_type = g_value_get_int (value);
+ g_warning ("arnr-type is a no-op since control has been deprecated "
+ "in libvpx");
+ break;
+ case PROP_TUNING:
+ gst_vp9_enc->tuning = g_value_get_enum (value);
+ if (gst_vp9_enc->inited) {
+ status = vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_TUNING,
+ gst_vp9_enc->tuning);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_TUNING: %s", gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_CQ_LEVEL:
+ gst_vp9_enc->cq_level = g_value_get_int (value);
+ if (gst_vp9_enc->inited) {
+ status = vpx_codec_control (&gst_vp9_enc->encoder, VP8E_SET_CQ_LEVEL,
+ gst_vp9_enc->cq_level);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_CQ_LEVEL: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_MAX_INTRA_BITRATE_PCT:
+ gst_vp9_enc->max_intra_bitrate_pct = g_value_get_int (value);
+ if (gst_vp9_enc->inited) {
+ status =
+ vpx_codec_control (&gst_vp9_enc->encoder,
+ VP8E_SET_MAX_INTRA_BITRATE_PCT, gst_vp9_enc->max_intra_bitrate_pct);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (gst_vp9_enc,
+ "Failed to set VP8E_SET_MAX_INTRA_BITRATE_PCT: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+ break;
+ case PROP_TIMEBASE:
+ gst_vp9_enc->timebase_n = gst_value_get_fraction_numerator (value);
+ gst_vp9_enc->timebase_d = gst_value_get_fraction_denominator (value);
+ break;
+ default:
+ break;
+ }
+
+ if (global &&gst_vp9_enc->inited) {
+ status =
+ vpx_codec_enc_config_set (&gst_vp9_enc->encoder, &gst_vp9_enc->cfg);
+ if (status != VPX_CODEC_OK) {
+ g_mutex_unlock (&gst_vp9_enc->encoder_lock);
+ GST_ELEMENT_ERROR (gst_vp9_enc, LIBRARY, INIT,
+ ("Failed to set encoder configuration"), ("%s",
+ gst_vpx_error_name (status)));
+ } else {
+ g_mutex_unlock (&gst_vp9_enc->encoder_lock);
+ }
+ } else {
+ g_mutex_unlock (&gst_vp9_enc->encoder_lock);
+ }
+}
+
+static void
+gst_vp9_enc_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
+ GstVP9Enc *gst_vp9_enc;
+
+ g_return_if_fail (GST_IS_VP9_ENC (object));
+ gst_vp9_enc = GST_VP9_ENC (object);
+
+ g_mutex_lock (&gst_vp9_enc->encoder_lock);
+ switch (prop_id) {
+ case PROP_RC_END_USAGE:
+ g_value_set_enum (value, gst_vp9_enc->cfg.rc_end_usage);
+ break;
+ case PROP_RC_TARGET_BITRATE:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_target_bitrate * 1000);
+ break;
+ case PROP_RC_MIN_QUANTIZER:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_min_quantizer);
+ break;
+ case PROP_RC_MAX_QUANTIZER:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_max_quantizer);
+ break;
+ case PROP_RC_DROPFRAME_THRESH:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_dropframe_thresh);
+ break;
+ case PROP_RC_RESIZE_ALLOWED:
+ g_value_set_boolean (value, gst_vp9_enc->cfg.rc_resize_allowed);
+ break;
+ case PROP_RC_RESIZE_UP_THRESH:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_resize_up_thresh);
+ break;
+ case PROP_RC_RESIZE_DOWN_THRESH:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_resize_down_thresh);
+ break;
+ case PROP_RC_UNDERSHOOT_PCT:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_undershoot_pct);
+ break;
+ case PROP_RC_OVERSHOOT_PCT:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_overshoot_pct);
+ break;
+ case PROP_RC_BUF_SZ:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_buf_sz);
+ break;
+ case PROP_RC_BUF_INITIAL_SZ:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_buf_initial_sz);
+ break;
+ case PROP_RC_BUF_OPTIMAL_SZ:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_buf_optimal_sz);
+ break;
+ case PROP_RC_2PASS_VBR_BIAS_PCT:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_2pass_vbr_bias_pct);
+ break;
+ case PROP_RC_2PASS_VBR_MINSECTION_PCT:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_2pass_vbr_minsection_pct);
+ break;
+ case PROP_RC_2PASS_VBR_MAXSECTION_PCT:
+ g_value_set_int (value, gst_vp9_enc->cfg.rc_2pass_vbr_maxsection_pct);
+ break;
+ case PROP_KF_MODE:
+ g_value_set_enum (value, gst_vp9_enc->cfg.kf_mode);
+ break;
+ case PROP_KF_MAX_DIST:
+ g_value_set_int (value, gst_vp9_enc->cfg.kf_max_dist);
+ break;
+ case PROP_MULTIPASS_MODE:
+ g_value_set_enum (value, gst_vp9_enc->cfg.g_pass);
+ break;
+ case PROP_MULTIPASS_CACHE_FILE:
+ g_value_set_string (value, gst_vp9_enc->multipass_cache_file);
+ break;
+ case PROP_TS_NUMBER_LAYERS:
+ g_value_set_int (value, gst_vp9_enc->cfg.ts_number_layers);
+ break;
+ case PROP_TS_TARGET_BITRATE:{
+ GValueArray *va;
+
+ if (gst_vp9_enc->n_ts_target_bitrate == 0) {
+ g_value_set_boxed (value, NULL);
+ } else {
+ gint i;
+
+ va = g_value_array_new (gst_vp9_enc->n_ts_target_bitrate);
+ for (i = 0; i < gst_vp9_enc->n_ts_target_bitrate; i++) {
+ GValue v = { 0, };
+
+ g_value_init (&v, G_TYPE_INT);
+ g_value_set_int (&v, gst_vp9_enc->cfg.ts_target_bitrate[i]);
+ g_value_array_append (va, &v);
+ g_value_unset (&v);
+ }
+ g_value_set_boxed (value, va);
+ g_value_array_free (va);
+ }
+ break;
+ }
+ case PROP_TS_RATE_DECIMATOR:{
+ GValueArray *va;
+
+ if (gst_vp9_enc->n_ts_rate_decimator == 0) {
+ g_value_set_boxed (value, NULL);
+ } else {
+ gint i;
+
+ va = g_value_array_new (gst_vp9_enc->n_ts_rate_decimator);
+ for (i = 0; i < gst_vp9_enc->n_ts_rate_decimator; i++) {
+ GValue v = { 0, };
+
+ g_value_init (&v, G_TYPE_INT);
+ g_value_set_int (&v, gst_vp9_enc->cfg.ts_rate_decimator[i]);
+ g_value_array_append (va, &v);
+ g_value_unset (&v);
+ }
+ g_value_set_boxed (value, va);
+ g_value_array_free (va);
+ }
+ break;
+ }
+ case PROP_TS_PERIODICITY:
+ g_value_set_int (value, gst_vp9_enc->cfg.ts_periodicity);
+ break;
+ case PROP_TS_LAYER_ID:{
+ GValueArray *va;
+
+ if (gst_vp9_enc->n_ts_layer_id == 0) {
+ g_value_set_boxed (value, NULL);
+ } else {
+ gint i;
+
+ va = g_value_array_new (gst_vp9_enc->n_ts_layer_id);
+ for (i = 0; i < gst_vp9_enc->n_ts_layer_id; i++) {
+ GValue v = { 0, };
+
+ g_value_init (&v, G_TYPE_INT);
+ g_value_set_int (&v, gst_vp9_enc->cfg.ts_layer_id[i]);
+ g_value_array_append (va, &v);
+ g_value_unset (&v);
+ }
+ g_value_set_boxed (value, va);
+ g_value_array_free (va);
+ }
+ break;
+ }
+ case PROP_ERROR_RESILIENT:
+ g_value_set_flags (value, gst_vp9_enc->cfg.g_error_resilient);
+ break;
+ case PROP_LAG_IN_FRAMES:
+ g_value_set_int (value, gst_vp9_enc->cfg.g_lag_in_frames);
+ break;
+ case PROP_THREADS:
+ g_value_set_int (value, gst_vp9_enc->cfg.g_threads);
+ break;
+ case PROP_DEADLINE:
+ g_value_set_int64 (value, gst_vp9_enc->deadline);
+ break;
+ case PROP_H_SCALING_MODE:
+ g_value_set_enum (value, gst_vp9_enc->h_scaling_mode);
+ break;
+ case PROP_V_SCALING_MODE:
+ g_value_set_enum (value, gst_vp9_enc->v_scaling_mode);
+ break;
+ case PROP_CPU_USED:
+ g_value_set_int (value, gst_vp9_enc->cpu_used);
+ break;
+ case PROP_ENABLE_AUTO_ALT_REF:
+ g_value_set_boolean (value, gst_vp9_enc->enable_auto_alt_ref);
+ break;
+ case PROP_NOISE_SENSITIVITY:
+ g_value_set_int (value, gst_vp9_enc->noise_sensitivity);
+ break;
+ case PROP_SHARPNESS:
+ g_value_set_int (value, gst_vp9_enc->sharpness);
+ break;
+ case PROP_STATIC_THRESHOLD:
+ g_value_set_int (value, gst_vp9_enc->static_threshold);
+ break;
+ case PROP_TOKEN_PARTITIONS:
+ g_value_set_enum (value, gst_vp9_enc->token_partitions);
+ break;
+ case PROP_ARNR_MAXFRAMES:
+ g_value_set_int (value, gst_vp9_enc->arnr_maxframes);
+ break;
+ case PROP_ARNR_STRENGTH:
+ g_value_set_int (value, gst_vp9_enc->arnr_strength);
+ break;
+ case PROP_ARNR_TYPE:
+ g_value_set_int (value, gst_vp9_enc->arnr_type);
+ break;
+ case PROP_TUNING:
+ g_value_set_enum (value, gst_vp9_enc->tuning);
+ break;
+ case PROP_CQ_LEVEL:
+ g_value_set_int (value, gst_vp9_enc->cq_level);
+ break;
+ case PROP_MAX_INTRA_BITRATE_PCT:
+ g_value_set_int (value, gst_vp9_enc->max_intra_bitrate_pct);
+ break;
+ case PROP_TIMEBASE:
+ gst_value_set_fraction (value, gst_vp9_enc->timebase_n,
+ gst_vp9_enc->timebase_d);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+
+ g_mutex_unlock (&gst_vp9_enc->encoder_lock);
+}
+
+static gboolean
+gst_vp9_enc_start (GstVideoEncoder * video_encoder)
+{
+ GstVP9Enc *encoder = GST_VP9_ENC (video_encoder);
+
+ GST_DEBUG_OBJECT (video_encoder, "start");
+
+ if (!encoder->have_default_config) {
+ GST_ELEMENT_ERROR (encoder, LIBRARY, INIT,
+ ("Failed to get default encoder configuration"), (NULL));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+gst_vp9_enc_stop (GstVideoEncoder * video_encoder)
+{
+ GstVP9Enc *encoder;
+
+ GST_DEBUG_OBJECT (video_encoder, "stop");
+
+ encoder = GST_VP9_ENC (video_encoder);
+
+ g_mutex_lock (&encoder->encoder_lock);
+ if (encoder->inited) {
+ vpx_codec_destroy (&encoder->encoder);
+ encoder->inited = FALSE;
+ }
+
+ if (encoder->first_pass_cache_content) {
+ g_byte_array_free (encoder->first_pass_cache_content, TRUE);
+ encoder->first_pass_cache_content = NULL;
+ }
+
+ if (encoder->cfg.rc_twopass_stats_in.buf) {
+ g_free (encoder->cfg.rc_twopass_stats_in.buf);
+ encoder->cfg.rc_twopass_stats_in.buf = NULL;
+ encoder->cfg.rc_twopass_stats_in.sz = 0;
+ }
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ gst_tag_setter_reset_tags (GST_TAG_SETTER (encoder));
+
+ return TRUE;
+}
+
+static gint
+gst_vp9_enc_get_downstream_profile (GstVP9Enc * encoder)
+{
+ GstCaps *allowed;
+ GstStructure *s;
+ gint profile = DEFAULT_PROFILE;
+
+ allowed = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder));
+ if (allowed) {
+ allowed = gst_caps_truncate (allowed);
+ s = gst_caps_get_structure (allowed, 0);
+ if (gst_structure_has_field (s, "profile")) {
+ const GValue *v = gst_structure_get_value (s, "profile");
+ const gchar *profile_str = NULL;
+
+ if (GST_VALUE_HOLDS_LIST (v) && gst_value_list_get_size (v) > 0) {
+ profile_str = g_value_get_string (gst_value_list_get_value (v, 0));
+ } else if (G_VALUE_HOLDS_STRING (v)) {
+ profile_str = g_value_get_string (v);
+ }
+
+ if (profile_str) {
+ gchar *endptr = NULL;
+
+ profile = g_ascii_strtoull (profile_str, &endptr, 10);
+ if (*endptr != '\0' || profile < 0 || profile > 3) {
+ GST_ERROR_OBJECT (encoder, "Invalid profile '%s'", profile_str);
+ profile = DEFAULT_PROFILE;
+ }
+ }
+ }
+ gst_caps_unref (allowed);
+ }
+
+ GST_DEBUG_OBJECT (encoder, "Using profile %d", profile);
+
+ return profile;
+}
+
+static gboolean
+gst_vp9_enc_set_format (GstVideoEncoder * video_encoder,
+ GstVideoCodecState * state)
+{
+ GstVP9Enc *encoder;
+ vpx_codec_err_t status;
+ vpx_image_t *image;
+ GstCaps *caps;
+ gboolean ret = TRUE;
+ GstVideoInfo *info = &state->info;
+ GstVideoCodecState *output_state;
+ gchar *profile_str;
+
+ encoder = GST_VP9_ENC (video_encoder);
+ GST_DEBUG_OBJECT (video_encoder, "set_format");
+
+ if (encoder->inited) {
+ gst_vp9_enc_drain (video_encoder);
+ g_mutex_lock (&encoder->encoder_lock);
+ vpx_codec_destroy (&encoder->encoder);
+ encoder->inited = FALSE;
+ } else {
+ g_mutex_lock (&encoder->encoder_lock);
+ }
+
+ encoder->cfg.g_profile = gst_vp9_enc_get_downstream_profile (encoder);
+
+ /* Scale default bitrate to our size */
+ if (!encoder->rc_target_bitrate_set)
+ encoder->cfg.rc_target_bitrate =
+ gst_util_uint64_scale (DEFAULT_RC_TARGET_BITRATE,
+ GST_VIDEO_INFO_WIDTH (info) * GST_VIDEO_INFO_HEIGHT (info),
+ 320 * 240 * 1000);
+
+ encoder->cfg.g_w = GST_VIDEO_INFO_WIDTH (info);
+ encoder->cfg.g_h = GST_VIDEO_INFO_HEIGHT (info);
+
+ if (encoder->timebase_n != 0 && encoder->timebase_d != 0) {
+ GST_DEBUG_OBJECT (video_encoder, "Using timebase configuration");
+ encoder->cfg.g_timebase.num = encoder->timebase_n;
+ encoder->cfg.g_timebase.den = encoder->timebase_d;
+ } else if (GST_VIDEO_INFO_FPS_D (info) != 0
+ && GST_VIDEO_INFO_FPS_N (info) != 0) {
+ /* GstVideoInfo holds either the framerate or max-framerate (if framerate
+ * is 0) in FPS so this will be used if max-framerate or framerate
+ * is set */
+ GST_DEBUG_OBJECT (video_encoder, "Setting timebase from framerate");
+ encoder->cfg.g_timebase.num = GST_VIDEO_INFO_FPS_D (info);
+ encoder->cfg.g_timebase.den = GST_VIDEO_INFO_FPS_N (info);
+ } else {
+ /* Zero framerate and max-framerate but still need to setup the timebase to avoid
+ * a divide by zero error. Presuming the lowest common denominator will be RTP -
+ * VP9 payload draft states clock rate of 90000 which should work for anyone where
+ * FPS < 90000 (shouldn't be too many cases where it's higher) though wouldn't be optimal. RTP specification
+ * http://tools.ietf.org/html/draft-ietf-payload-vp9-01 section 6.3.1 */
+ GST_WARNING_OBJECT (encoder,
+ "No timebase and zero framerate setting timebase to 1/90000");
+ encoder->cfg.g_timebase.num = 1;
+ encoder->cfg.g_timebase.den = 90000;
+ }
+
+ if (encoder->cfg.g_pass == VPX_RC_FIRST_PASS) {
+ if (encoder->first_pass_cache_content == NULL) {
+ encoder->first_pass_cache_content = g_byte_array_sized_new (4096);
+ }
+ } else if (encoder->cfg.g_pass == VPX_RC_LAST_PASS) {
+ GError *err = NULL;
+
+ if (!encoder->multipass_cache_file) {
+ GST_ELEMENT_ERROR (encoder, RESOURCE, OPEN_READ,
+ ("No multipass cache file provided"), (NULL));
+ g_mutex_unlock (&encoder->encoder_lock);
+ return FALSE;
+ }
+
+ if (encoder->cfg.rc_twopass_stats_in.buf != NULL) {
+ g_free (encoder->cfg.rc_twopass_stats_in.buf);
+ encoder->cfg.rc_twopass_stats_in.buf = NULL;
+ encoder->cfg.rc_twopass_stats_in.sz = 0;
+ }
+
+ if (!g_file_get_contents (encoder->multipass_cache_file,
+ (gchar **) & encoder->cfg.rc_twopass_stats_in.buf,
+ &encoder->cfg.rc_twopass_stats_in.sz, &err)) {
+ GST_ELEMENT_ERROR (encoder, RESOURCE, OPEN_READ,
+ ("Failed to read multipass cache file provided"), ("%s",
+ err->message));
+ g_error_free (err);
+ g_mutex_unlock (&encoder->encoder_lock);
+ return FALSE;
+ }
+ }
+
+ status = vpx_codec_enc_init (&encoder->encoder, &vpx_codec_vp9_cx_algo,
+ &encoder->cfg, 0);
+ if (status != VPX_CODEC_OK) {
+ GST_ELEMENT_ERROR (encoder, LIBRARY, INIT,
+ ("Failed to initialize encoder"), ("%s", gst_vpx_error_name (status)));
+ g_mutex_unlock (&encoder->encoder_lock);
+ return FALSE;
+ }
+
+ /* FIXME: Disabled for now, does not work with VP9 */
+#if 0
+ {
+ vpx_scaling_mode_t sm;
+
+ sm.h_scaling_mode = encoder->h_scaling_mode;
+ sm.v_scaling_mode = encoder->v_scaling_mode;
+
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_SCALEMODE, &sm);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder, "Failed to set VP8E_SET_SCALEMODE: %s",
+ gst_vpx_error_name (status));
+ }
+ }
+#endif
+
+ status =
+ vpx_codec_control (&encoder->encoder, VP8E_SET_CPUUSED,
+ encoder->cpu_used);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder, "Failed to set VP8E_SET_CPUUSED: %s",
+ gst_vpx_error_name (status));
+ }
+
+ status =
+ vpx_codec_control (&encoder->encoder, VP8E_SET_ENABLEAUTOALTREF,
+ (encoder->enable_auto_alt_ref ? 1 : 0));
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_ENABLEAUTOALTREF: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_NOISE_SENSITIVITY,
+ encoder->noise_sensitivity);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_NOISE_SENSITIVITY: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_SHARPNESS,
+ encoder->sharpness);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_SHARPNESS: %s", gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_STATIC_THRESHOLD,
+ encoder->static_threshold);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_STATIC_THRESHOLD: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_TOKEN_PARTITIONS,
+ encoder->token_partitions);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_TOKEN_PARTIONS: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_ARNR_MAXFRAMES,
+ encoder->arnr_maxframes);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_ARNR_MAXFRAMES: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_ARNR_STRENGTH,
+ encoder->arnr_strength);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_ARNR_STRENGTH: %s",
+ gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_TUNING,
+ encoder->tuning);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_TUNING: %s", gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_CQ_LEVEL,
+ encoder->cq_level);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_CQ_LEVEL: %s", gst_vpx_error_name (status));
+ }
+ status = vpx_codec_control (&encoder->encoder, VP8E_SET_MAX_INTRA_BITRATE_PCT,
+ encoder->max_intra_bitrate_pct);
+ if (status != VPX_CODEC_OK) {
+ GST_WARNING_OBJECT (encoder,
+ "Failed to set VP8E_SET_MAX_INTRA_BITRATE_PCT: %s",
+ gst_vpx_error_name (status));
+ }
+
+ if (GST_VIDEO_INFO_FPS_D (info) == 0 || GST_VIDEO_INFO_FPS_N (info) == 0) {
+ gst_video_encoder_set_latency (video_encoder, 0, GST_CLOCK_TIME_NONE);
+ } else {
+ gst_video_encoder_set_latency (video_encoder, 0,
+ gst_util_uint64_scale (encoder->cfg.g_lag_in_frames,
+ GST_VIDEO_INFO_FPS_D (info) * GST_SECOND,
+ GST_VIDEO_INFO_FPS_N (info)));
+ }
+ encoder->inited = TRUE;
+
+ /* Store input state */
+ if (encoder->input_state)
+ gst_video_codec_state_unref (encoder->input_state);
+ encoder->input_state = gst_video_codec_state_ref (state);
+
+ /* prepare cached image buffer setup */
+ image = &encoder->image;
+ memset (image, 0, sizeof (*image));
+
+ switch (encoder->input_state->info.finfo->format) {
+ case GST_VIDEO_FORMAT_I420:
+ image->fmt = VPX_IMG_FMT_I420;
+ image->bps = 12;
+ image->x_chroma_shift = image->y_chroma_shift = 1;
+ break;
+ case GST_VIDEO_FORMAT_YV12:
+ image->fmt = VPX_IMG_FMT_YV12;
+ image->bps = 12;
+ image->x_chroma_shift = image->y_chroma_shift = 1;
+ break;
+ case GST_VIDEO_FORMAT_Y42B:
+ image->fmt = VPX_IMG_FMT_I422;
+ image->bps = 16;
+ image->x_chroma_shift = 1;
+ image->y_chroma_shift = 0;
+ break;
+ case GST_VIDEO_FORMAT_Y444:
+ image->fmt = VPX_IMG_FMT_I444;
+ image->bps = 24;
+ image->x_chroma_shift = image->y_chroma_shift = 0;
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ image->w = image->d_w = GST_VIDEO_INFO_WIDTH (info);
+ image->h = image->d_h = GST_VIDEO_INFO_HEIGHT (info);
+
+ image->stride[VPX_PLANE_Y] = GST_VIDEO_INFO_COMP_STRIDE (info, 0);
+ image->stride[VPX_PLANE_U] = GST_VIDEO_INFO_COMP_STRIDE (info, 1);
+ image->stride[VPX_PLANE_V] = GST_VIDEO_INFO_COMP_STRIDE (info, 2);
+
+ profile_str = g_strdup_printf ("%d", encoder->cfg.g_profile);
+ caps = gst_caps_new_simple ("video/x-vp9",
+ "profile", G_TYPE_STRING, profile_str, NULL);
+ g_free (profile_str);
+
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ output_state =
+ gst_video_encoder_set_output_state (video_encoder, caps, state);
+ gst_video_codec_state_unref (output_state);
+
+ gst_video_encoder_negotiate (GST_VIDEO_ENCODER (encoder));
+
+ return ret;
+}
+
+static GstFlowReturn
+gst_vp9_enc_process (GstVP9Enc * encoder)
+{
+ vpx_codec_iter_t iter = NULL;
+ const vpx_codec_cx_pkt_t *pkt;
+ GstVideoEncoder *video_encoder;
+ GstVideoCodecFrame *frame;
+ GstFlowReturn ret = GST_FLOW_OK;
+
+ video_encoder = GST_VIDEO_ENCODER (encoder);
+
+ g_mutex_lock (&encoder->encoder_lock);
+ pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter);
+ while (pkt != NULL) {
+ GstBuffer *buffer;
+ gboolean invisible;
+
+ GST_DEBUG_OBJECT (encoder, "packet %u type %d", (guint) pkt->data.frame.sz,
+ pkt->kind);
+
+ if (pkt->kind == VPX_CODEC_STATS_PKT
+ && encoder->cfg.g_pass == VPX_RC_FIRST_PASS) {
+ GST_LOG_OBJECT (encoder, "handling STATS packet");
+
+ g_byte_array_append (encoder->first_pass_cache_content,
+ pkt->data.twopass_stats.buf, pkt->data.twopass_stats.sz);
+
+ frame = gst_video_encoder_get_oldest_frame (video_encoder);
+ if (frame != NULL) {
+ buffer = gst_buffer_new ();
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_LIVE);
+ frame->output_buffer = buffer;
+ g_mutex_unlock (&encoder->encoder_lock);
+ ret = gst_video_encoder_finish_frame (video_encoder, frame);
+ g_mutex_lock (&encoder->encoder_lock);
+ }
+
+ pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter);
+ continue;
+ } else if (pkt->kind != VPX_CODEC_CX_FRAME_PKT) {
+ GST_LOG_OBJECT (encoder, "non frame pkt: %d", pkt->kind);
+ pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter);
+ continue;
+ }
+
+ invisible = (pkt->data.frame.flags & VPX_FRAME_IS_INVISIBLE) != 0;
+ frame = gst_video_encoder_get_oldest_frame (video_encoder);
+ g_assert (frame != NULL);
+ if ((pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0)
+ GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
+ else
+ GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT (frame);
+
+ /* FIXME : It would be nice to avoid the memory copy ... */
+ buffer =
+ gst_buffer_new_wrapped (g_memdup (pkt->data.frame.buf,
+ pkt->data.frame.sz), pkt->data.frame.sz);
+
+ if (invisible) {
+ g_mutex_unlock (&encoder->encoder_lock);
+ ret = gst_pad_push (GST_VIDEO_ENCODER_SRC_PAD (encoder), buffer);
+ g_mutex_lock (&encoder->encoder_lock);
+ gst_video_codec_frame_unref (frame);
+ } else {
+ frame->output_buffer = buffer;
+ g_mutex_unlock (&encoder->encoder_lock);
+ ret = gst_video_encoder_finish_frame (video_encoder, frame);
+ g_mutex_lock (&encoder->encoder_lock);
+ }
+
+ pkt = vpx_codec_get_cx_data (&encoder->encoder, &iter);
+ }
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ return ret;
+}
+
+/* This function should be called holding then stream lock*/
+static GstFlowReturn
+gst_vp9_enc_drain (GstVideoEncoder * video_encoder)
+{
+ GstVP9Enc *encoder;
+ int flags = 0;
+ vpx_codec_err_t status;
+ gint64 deadline;
+
+ encoder = GST_VP9_ENC (video_encoder);
+
+ g_mutex_lock (&encoder->encoder_lock);
+ deadline = encoder->deadline;
+
+ status =
+ vpx_codec_encode (&encoder->encoder, NULL, encoder->n_frames, 1, flags,
+ deadline);
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ if (status != 0) {
+ GST_ERROR_OBJECT (encoder, "encode returned %d %s", status,
+ gst_vpx_error_name (status));
+ return GST_FLOW_ERROR;
+ }
+
+ /* dispatch remaining frames */
+ gst_vp9_enc_process (encoder);
+
+ g_mutex_lock (&encoder->encoder_lock);
+ if (encoder->cfg.g_pass == VPX_RC_FIRST_PASS && encoder->multipass_cache_file) {
+ GError *err = NULL;
+
+ if (!g_file_set_contents (encoder->multipass_cache_file,
+ (const gchar *) encoder->first_pass_cache_content->data,
+ encoder->first_pass_cache_content->len, &err)) {
+ GST_ELEMENT_ERROR (encoder, RESOURCE, WRITE, (NULL),
+ ("Failed to write multipass cache file: %s", err->message));
+ g_error_free (err);
+ }
+ }
+ g_mutex_unlock (&encoder->encoder_lock);
+
+ return GST_FLOW_OK;
+}
+
+static GstFlowReturn
+gst_vp9_enc_finish (GstVideoEncoder * video_encoder)
+{
+ GstFlowReturn ret;
+
+ GST_DEBUG_OBJECT (video_encoder, "finish");
+
+ ret = gst_vp9_enc_drain (video_encoder);
+
+ return ret;
+}
+
+static vpx_image_t *
+gst_vp9_enc_buffer_to_image (GstVP9Enc * enc, GstVideoFrame * frame)
+{
+ vpx_image_t *image = g_slice_new (vpx_image_t);
+
+ memcpy (image, &enc->image, sizeof (*image));
+
+ image->planes[VPX_PLANE_Y] = GST_VIDEO_FRAME_COMP_DATA (frame, 0);
+ image->planes[VPX_PLANE_U] = GST_VIDEO_FRAME_COMP_DATA (frame, 1);
+ image->planes[VPX_PLANE_V] = GST_VIDEO_FRAME_COMP_DATA (frame, 2);
+
+ image->stride[VPX_PLANE_Y] = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0);
+ image->stride[VPX_PLANE_U] = GST_VIDEO_FRAME_COMP_STRIDE (frame, 1);
+ image->stride[VPX_PLANE_V] = GST_VIDEO_FRAME_COMP_STRIDE (frame, 2);
+
+ return image;
+}
+
+static GstFlowReturn
+gst_vp9_enc_handle_frame (GstVideoEncoder * video_encoder,
+ GstVideoCodecFrame * frame)
+{
+ GstVP9Enc *encoder;
+ vpx_codec_err_t status;
+ int flags = 0;
+ vpx_image_t *image;
+ GstVideoFrame vframe;
+
+ GST_DEBUG_OBJECT (video_encoder, "handle_frame");
+
+ encoder = GST_VP9_ENC (video_encoder);
+
+ encoder->n_frames++;
+
+ GST_DEBUG_OBJECT (video_encoder, "size %d %d",
+ GST_VIDEO_INFO_WIDTH (&encoder->input_state->info),
+ GST_VIDEO_INFO_HEIGHT (&encoder->input_state->info));
+
+ gst_video_frame_map (&vframe, &encoder->input_state->info,
+ frame->input_buffer, GST_MAP_READ);
+ image = gst_vp9_enc_buffer_to_image (encoder, &vframe);
+
+ if (GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME (frame)) {
+ flags |= VPX_EFLAG_FORCE_KF;
+ }
+
+ g_mutex_lock (&encoder->encoder_lock);
+ status = vpx_codec_encode (&encoder->encoder, image,
+ encoder->n_frames, 1, flags, encoder->deadline);
+ g_mutex_unlock (&encoder->encoder_lock);
+ gst_video_frame_unmap (&vframe);
+
+ if (status != 0) {
+ GST_ELEMENT_ERROR (encoder, LIBRARY, ENCODE,
+ ("Failed to encode frame"), ("%s", gst_vpx_error_name (status)));
+ return FALSE;
+ }
+ gst_video_codec_frame_unref (frame);
+ return gst_vp9_enc_process (encoder);
+}
+
+static gboolean
+gst_vp9_enc_sink_event (GstVideoEncoder * benc, GstEvent * event)
+{
+ GstVP9Enc *enc = GST_VP9_ENC (benc);
+
+ /* FIXME : Move this to base encoder class */
+
+ if (GST_EVENT_TYPE (event) == GST_EVENT_TAG) {
+ GstTagList *list;
+ GstTagSetter *setter = GST_TAG_SETTER (enc);
+ const GstTagMergeMode mode = gst_tag_setter_get_tag_merge_mode (setter);
+
+ gst_event_parse_tag (event, &list);
+ gst_tag_setter_merge_tags (setter, list, mode);
+ }
+
+ /* just peeked, baseclass handles the rest */
+ return GST_VIDEO_ENCODER_CLASS (parent_class)->sink_event (benc, event);
+}
+
+static gboolean
+gst_vp9_enc_propose_allocation (GstVideoEncoder * encoder, GstQuery * query)
+{
+ gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
+
+ return GST_VIDEO_ENCODER_CLASS (parent_class)->propose_allocation (encoder,
+ query);
+}
+
+#endif /* HAVE_VP9_ENCODER */
diff --git a/ext/vpx/gstvp9enc.h b/ext/vpx/gstvp9enc.h
new file mode 100644
index 0000000..b991905
--- /dev/null
+++ b/ext/vpx/gstvp9enc.h
@@ -0,0 +1,121 @@
+/* VP9
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2010 Entropy Wave Inc
+ * Copyright (C) 2010-2013 Sebastian Dröge <slomo@circular-chaos.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+#ifndef __GST_VP9_ENC_H__
+#define __GST_VP9_ENC_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_VP9_ENCODER
+
+#include <gst/gst.h>
+#include <gst/video/gstvideoencoder.h>
+
+/* FIXME: Undef HAVE_CONFIG_H because vpx_codec.h uses it,
+ * which causes compilation failures */
+#ifdef HAVE_CONFIG_H
+#undef HAVE_CONFIG_H
+#endif
+
+#include <vpx/vpx_encoder.h>
+#include <vpx/vp8cx.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_VP9_ENC \
+ (gst_vp9_enc_get_type())
+#define GST_VP9_ENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VP9_ENC,GstVP9Enc))
+#define GST_VP9_ENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VP9_ENC,GstVP9EncClass))
+#define GST_IS_VP9_ENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VP9_ENC))
+#define GST_IS_VP9_ENC_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VP9_ENC))
+
+typedef struct _GstVP9Enc GstVP9Enc;
+typedef struct _GstVP9EncClass GstVP9EncClass;
+
+struct _GstVP9Enc
+{
+ GstVideoEncoder base_video_encoder;
+
+ /* < private > */
+ vpx_codec_ctx_t encoder;
+ GMutex encoder_lock;
+
+ /* properties */
+ vpx_codec_enc_cfg_t cfg;
+ gboolean have_default_config;
+ gboolean rc_target_bitrate_set;
+ gint n_ts_target_bitrate;
+ gint n_ts_rate_decimator;
+ gint n_ts_layer_id;
+ /* Global two-pass options */
+ gchar *multipass_cache_file;
+ GByteArray *first_pass_cache_content;
+
+ /* Encode parameter */
+ gint64 deadline;
+
+ /* Controls */
+ VPX_SCALING_MODE h_scaling_mode;
+ VPX_SCALING_MODE v_scaling_mode;
+ int cpu_used;
+ gboolean enable_auto_alt_ref;
+ unsigned int noise_sensitivity;
+ unsigned int sharpness;
+ unsigned int static_threshold;
+ vp8e_token_partitions token_partitions;
+ unsigned int arnr_maxframes;
+ unsigned int arnr_strength;
+ unsigned int arnr_type;
+ vp8e_tuning tuning;
+ unsigned int cq_level;
+ unsigned int max_intra_bitrate_pct;
+ /* Timebase - a value of 0 will use the framerate */
+ unsigned int timebase_n;
+ unsigned int timebase_d;
+
+ /* state */
+ gboolean inited;
+
+ vpx_image_t image;
+
+ int n_frames;
+
+ GstVideoCodecState *input_state;
+};
+
+struct _GstVP9EncClass
+{
+ GstVideoEncoderClass base_video_encoder_class;
+};
+
+GType gst_vp9_enc_get_type (void);
+
+G_END_DECLS
+
+#endif
+
+#endif /* __GST_VP9_ENC_H__ */
diff --git a/ext/vpx/plugin.c b/ext/vpx/plugin.c
new file mode 100644
index 0000000..4f04efa
--- /dev/null
+++ b/ext/vpx/plugin.c
@@ -0,0 +1,63 @@
+/* VP8
+ * Copyright (C) 2006 David Schleef <ds@schleef.org>
+ * Copyright (C) 2010 Entropy Wave Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+
+#include "gstvp8dec.h"
+#include "gstvp8enc.h"
+#include "gstvp9dec.h"
+#include "gstvp9enc.h"
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+#ifdef HAVE_VP8_DECODER
+ gst_element_register (plugin, "vp8dec", GST_RANK_PRIMARY,
+ gst_vp8_dec_get_type ());
+#endif
+
+#ifdef HAVE_VP8_ENCODER
+ gst_element_register (plugin, "vp8enc", GST_RANK_PRIMARY,
+ gst_vp8_enc_get_type ());
+#endif
+
+#ifdef HAVE_VP9_DECODER
+ gst_element_register (plugin, "vp9dec", GST_RANK_PRIMARY,
+ gst_vp9_dec_get_type ());
+#endif
+
+#ifdef HAVE_VP9_ENCODER
+ gst_element_register (plugin, "vp9enc", GST_RANK_PRIMARY,
+ gst_vp9_enc_get_type ());
+#endif
+
+ return TRUE;
+}
+
+GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ vpx,
+ "VP8 plugin",
+ plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)