aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-08-09 11:57:49 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-08-09 11:57:49 +0200
commitbf67b6b3be6adab19d7354e0f8a1b81b873c09dd (patch)
tree8781aed7dae9376c5f73fa57efea0d0fb993b03f
parent20860c094a820bd9276f1fc83792ee9d9aa54ad3 (diff)
Imported Upstream version 0.11.93upstream/0.11.93
-rw-r--r--Makefile.in4
-rw-r--r--aclocal.m46
-rwxr-xr-xautogen.sh2
-rw-r--r--common/Makefile.in2
-rw-r--r--common/m4/Makefile.in2
-rw-r--r--common/m4/gst-arch.m43
-rw-r--r--common/m4/gst-glib2.m438
-rw-r--r--common/m4/gst-parser.m42
-rw-r--r--common/m4/gst.m45
-rwxr-xr-xcompile91
-rwxr-xr-xconfig.sub11
-rwxr-xr-xconfigure309
-rw-r--r--configure.ac6
-rwxr-xr-xdepcomp124
-rw-r--r--docs/Makefile.in2
-rw-r--r--ext/Makefile.in2
-rw-r--r--ext/ffmpeg/Makefile.am3
-rw-r--r--ext/ffmpeg/Makefile.in26
-rw-r--r--ext/ffmpeg/gstffmpeg.c6
-rw-r--r--ext/ffmpeg/gstffmpeg.h6
-rw-r--r--ext/ffmpeg/gstffmpegcfg.c59
-rw-r--r--ext/ffmpeg/gstffmpegcfg.h8
-rw-r--r--ext/ffmpeg/gstffmpegcodecmap.c520
-rw-r--r--ext/ffmpeg/gstffmpegcodecmap.h7
-rw-r--r--ext/ffmpeg/gstffmpegdec.c2157
-rw-r--r--ext/ffmpeg/gstffmpegdeinterlace.c11
-rw-r--r--ext/ffmpeg/gstffmpegdemux.c28
-rw-r--r--ext/ffmpeg/gstffmpegenc.c1083
-rw-r--r--ext/ffmpeg/gstffmpegenc.h63
-rw-r--r--ext/ffmpeg/gstffmpegmux.c3
-rw-r--r--ext/ffmpeg/gstffmpegviddec.c1756
-rw-r--r--ext/ffmpeg/gstffmpegvidenc.c1030
-rw-r--r--ext/ffmpeg/gstffmpegvidenc.h95
-rw-r--r--ext/libpostproc/Makefile.in2
-rw-r--r--ext/libswscale/Makefile.in2
-rw-r--r--gst-libav.doap10
-rw-r--r--gst-libav.spec31
-rw-r--r--gst-libav.spec.in29
-rw-r--r--gst-libs/Makefile.in2
-rw-r--r--gst-libs/ext/Makefile.am2
-rw-r--r--gst-libs/ext/Makefile.in4
-rw-r--r--ltmain.sh4
-rw-r--r--m4/libtool.m428
-rw-r--r--tests/Makefile.in2
-rw-r--r--tests/check/Makefile.in2
-rw-r--r--tests/check/elements/avdec_adpcm.c2
-rw-r--r--tests/check/elements/avdemux_ape.c4
-rw-r--r--tests/files/Makefile.in2
48 files changed, 4149 insertions, 3447 deletions
diff --git a/Makefile.in b/Makefile.in
index 921a957..38c84bf 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -735,7 +735,7 @@ distcheck: dist
*.zip*) \
unzip $(distdir).zip ;;\
esac
- chmod -R a-w $(distdir); chmod a+w $(distdir)
+ chmod -R a-w $(distdir); chmod u+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
diff --git a/aclocal.m4 b/aclocal.m4
index 8e86028..8e7fd7d 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.11.5 -*- Autoconf -*-
+# generated automatically by aclocal 1.11.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
@@ -38,7 +38,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.11'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
-m4_if([$1], [1.11.5], [],
+m4_if([$1], [1.11.6], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@@ -54,7 +54,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.11.5])dnl
+[AM_AUTOMAKE_VERSION([1.11.6])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
diff --git a/autogen.sh b/autogen.sh
index 188a2db..1b560ac 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -2,7 +2,7 @@
# Run this to generate all the initial makefiles, etc.
DIE=0
-package=gst-ffmpeg
+package=gst-libav
srcfile=configure.ac
# make sure we have common
diff --git a/common/Makefile.in b/common/Makefile.in
index 4202282..07fbb3c 100644
--- a/common/Makefile.in
+++ b/common/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/common/m4/Makefile.in b/common/m4/Makefile.in
index 20a3e9f..a1820c1 100644
--- a/common/m4/Makefile.in
+++ b/common/m4/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/common/m4/gst-arch.m4 b/common/m4/gst-arch.m4
index ff0954a..077a20b 100644
--- a/common/m4/gst-arch.m4
+++ b/common/m4/gst-arch.m4
@@ -5,9 +5,6 @@ dnl defines HOST_CPU
AC_DEFUN([AG_GST_ARCH],
[
- AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use host_ variables
- AC_REQUIRE([AC_CANONICAL_TARGET]) dnl we use target_ variables
-
dnl Determine CPU
case "x${target_cpu}" in
xi?86 | xk? | xi?86_64)
diff --git a/common/m4/gst-glib2.m4 b/common/m4/gst-glib2.m4
index b141bee..3f3d565 100644
--- a/common/m4/gst-glib2.m4
+++ b/common/m4/gst-glib2.m4
@@ -68,6 +68,44 @@ AC_DEFUN([AG_GST_GLIB_CHECK],
GLIB_EXTRA_CFLAGS="$GLIB_EXTRA_CFLAGS -DG_DISABLE_ASSERT"
fi
+ dnl Find location of glib utils. People may want to or have to override these,
+ dnl e.g. in a cross-compile situation where PATH is a bit messed up. We need
+ dnl for these tools to work on the host, so can't just use the one from the
+ dnl GLib installation that pkg-config picks up, as that might be for a
+ dnl different target architecture.
+ dnl
+ dnl glib-genmarshal:
+ AC_MSG_CHECKING(for glib-genmarshal)
+ if test "x$GLIB_GENMARSHAL" != "x"; then
+ AC_MSG_RESULT([$GLIB_GENMARSHAL (from environment)])
+ else
+ GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
+ if $GLIB_GENMARSHAL --version 2>/dev/null >/dev/null; then
+ AC_MSG_RESULT([$GLIB_GENMARSHAL (from pkg-config path)])
+ else
+ AC_PATH_PROG(GLIB_GENMARSHAL, [glib-genmarshal], [glib-genmarshal])
+ AC_MSG_RESULT([$GLIB_GENMARSHAL])
+ fi
+ fi
+ if ! $GLIB_GENMARSHAL --version 2>/dev/null >/dev/null; then
+ AC_MSG_WARN([$GLIB_GENMARSHAL does not seem to work!])
+ fi
+ AC_SUBST(GLIB_GENMARSHAL)
+
+ dnl glib-mkenums:
+ AC_MSG_CHECKING(for glib-mkenums)
+ if test "x$GLIB_MKENUMS" != "x"; then
+ AC_MSG_RESULT([$GLIB_MKENUMS (from environment)])
+ else
+ dnl glib-mkenums is written in perl so should always work really
+ GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
+ AC_MSG_RESULT([$GLIB_MKENUMS])
+ fi
+ if ! $GLIB_MKENUMS --version 2>/dev/null >/dev/null; then
+ AC_MSG_WARN([$GLIB_MKENUMS does not seem to work!])
+ fi
+ AC_SUBST(GLIB_MKENUMS)
+
dnl for the poor souls who for example have glib in /usr/local
AS_SCRUB_INCLUDE(GLIB_CFLAGS)
diff --git a/common/m4/gst-parser.m4 b/common/m4/gst-parser.m4
index 2cae45d..710da89 100644
--- a/common/m4/gst-parser.m4
+++ b/common/m4/gst-parser.m4
@@ -34,7 +34,7 @@ AC_DEFUN([AG_GST_FLEX_CHECK],
dnl we need version >= 2.5.31 for the reentrancy support
dnl in the parser.
flex_min_version=2.5.31
- flex_version=`$FLEX_PATH --version | head -n 1 | sed 's/^.* //' | sed 's/[[a-zA-Z]]*$//' | cut -d' ' -f1`
+ flex_version=`$FLEX_PATH --version | head -n 1 | awk '{print $2}'`
AC_MSG_CHECKING([flex version $flex_version >= $flex_min_version])
if perl -w <<EOF
(\$min_version_major, \$min_version_minor, \$min_version_micro ) = "$flex_min_version" =~ /(\d+)\.(\d+)\.(\d+)/;
diff --git a/common/m4/gst.m4 b/common/m4/gst.m4
index ddfde51..d4c53cb 100644
--- a/common/m4/gst.m4
+++ b/common/m4/gst.m4
@@ -3,10 +3,15 @@ dnl sets up use of GStreamer configure.ac macros
dnl all GStreamer autoconf macros are prefixed
dnl with AG_GST_ for public macros
dnl with _AG_GST_ for private macros
+dnl
+dnl We call AC_CANONICAL_TARGET and AC_CANONICAL_HOST so that
+dnl it is valid before AC_ARG_PROGRAM is called
AC_DEFUN([AG_GST_INIT],
[
m4_pattern_forbid(^_?AG_GST_)
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use host_ variables
+ AC_REQUIRE([AC_CANONICAL_TARGET]) dnl we use target_ variables
])
dnl AG_GST_PKG_CONFIG_PATH
diff --git a/compile b/compile
index b1f4749..862a14e 100755
--- a/compile
+++ b/compile
@@ -1,7 +1,7 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
-scriptversion=2012-01-04.17; # UTC
+scriptversion=2012-03-05.13; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free
# Software Foundation, Inc.
@@ -79,6 +79,48 @@ func_file_conv ()
esac
}
+# func_cl_dashL linkdir
+# Make cl look for libraries in LINKDIR
+func_cl_dashL ()
+{
+ func_file_conv "$1"
+ if test -z "$lib_path"; then
+ lib_path=$file
+ else
+ lib_path="$lib_path;$file"
+ fi
+ linker_opts="$linker_opts -LIBPATH:$file"
+}
+
+# func_cl_dashl library
+# Do a library search-path lookup for cl
+func_cl_dashl ()
+{
+ lib=$1
+ found=no
+ save_IFS=$IFS
+ IFS=';'
+ for dir in $lib_path $LIB
+ do
+ IFS=$save_IFS
+ if $shared && test -f "$dir/$lib.dll.lib"; then
+ found=yes
+ lib=$dir/$lib.dll.lib
+ break
+ fi
+ if test -f "$dir/$lib.lib"; then
+ found=yes
+ lib=$dir/$lib.lib
+ break
+ fi
+ done
+ IFS=$save_IFS
+
+ if test "$found" != yes; then
+ lib=$lib.lib
+ fi
+}
+
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
@@ -109,43 +151,34 @@ func_cl_wrapper ()
;;
esac
;;
+ -I)
+ eat=1
+ func_file_conv "$2" mingw
+ set x "$@" -I"$file"
+ shift
+ ;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
+ -l)
+ eat=1
+ func_cl_dashl "$2"
+ set x "$@" "$lib"
+ shift
+ ;;
-l*)
- lib=${1#-l}
- found=no
- save_IFS=$IFS
- IFS=';'
- for dir in $lib_path $LIB
- do
- IFS=$save_IFS
- if $shared && test -f "$dir/$lib.dll.lib"; then
- found=yes
- set x "$@" "$dir/$lib.dll.lib"
- break
- fi
- if test -f "$dir/$lib.lib"; then
- found=yes
- set x "$@" "$dir/$lib.lib"
- break
- fi
- done
- IFS=$save_IFS
-
- test "$found" != yes && set x "$@" "$lib.lib"
+ func_cl_dashl "${1#-l}"
+ set x "$@" "$lib"
shift
;;
+ -L)
+ eat=1
+ func_cl_dashL "$2"
+ ;;
-L*)
- func_file_conv "${1#-L}"
- if test -z "$lib_path"; then
- lib_path=$file
- else
- lib_path="$lib_path;$file"
- fi
- linker_opts="$linker_opts -LIBPATH:$file"
+ func_cl_dashL "${1#-L}"
;;
-static)
shared=false
diff --git a/config.sub b/config.sub
index c894da4..6205f84 100755
--- a/config.sub
+++ b/config.sub
@@ -4,7 +4,7 @@
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.
-timestamp='2012-02-10'
+timestamp='2012-04-18'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@@ -225,6 +225,12 @@ case $os in
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
+ -lynx*178)
+ os=-lynxos178
+ ;;
+ -lynx*5)
+ os=-lynxos5
+ ;;
-lynx*)
os=-lynxos
;;
@@ -1537,6 +1543,9 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
+ hexagon-*)
+ os=-elf
+ ;;
tic54x-*)
os=-coff
;;
diff --git a/configure b/configure
index 1503497..3cccf24 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for GStreamer libav 0.11.92.
+# Generated by GNU Autoconf 2.69 for GStreamer libav 0.11.93.
#
# Report bugs to <http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer>.
#
@@ -591,8 +591,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='GStreamer libav'
PACKAGE_TARNAME='gst-libav'
-PACKAGE_VERSION='0.11.92'
-PACKAGE_STRING='GStreamer libav 0.11.92'
+PACKAGE_VERSION='0.11.93'
+PACKAGE_STRING='GStreamer libav 0.11.93'
PACKAGE_BUGREPORT='http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer'
PACKAGE_URL=''
@@ -772,10 +772,6 @@ HAVE_CPU_PPC_FALSE
HAVE_CPU_PPC_TRUE
HAVE_CPU_I386_FALSE
HAVE_CPU_I386_TRUE
-target_os
-target_vendor
-target_cpu
-target
VALGRIND_LIBS
VALGRIND_CFLAGS
PKG_CONFIG
@@ -832,14 +828,6 @@ AM_BACKSLASH
AM_DEFAULT_VERBOSITY
AM_DEFAULT_V
AM_V
-host_os
-host_vendor
-host_cpu
-host
-build_os
-build_vendor
-build_cpu
-build
MAINT
MAINTAINER_MODE_FALSE
MAINTAINER_MODE_TRUE
@@ -871,6 +859,18 @@ am__isrc
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
+target_os
+target_vendor
+target_cpu
+target
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
target_alias
host_alias
build_alias
@@ -1511,7 +1511,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures GStreamer libav 0.11.92 to adapt to many kinds of systems.
+\`configure' configures GStreamer libav 0.11.93 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1582,7 +1582,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of GStreamer libav 0.11.92:";;
+ short | recursive ) echo "Configuration of GStreamer libav 0.11.93:";;
esac
cat <<\_ACEOF
@@ -1748,7 +1748,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-GStreamer libav configure 0.11.92
+GStreamer libav configure 0.11.93
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2163,7 +2163,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by GStreamer libav $as_me 0.11.92, which was
+It was created by GStreamer libav $as_me 0.11.93, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2512,12 +2512,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-am__api_version='1.11'
-
ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
if test -f "$ac_dir/install-sh"; then
@@ -2547,6 +2541,122 @@ ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
+$as_echo_n "checking target system type... " >&6; }
+if ${ac_cv_target+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$target_alias" = x; then
+ ac_cv_target=$ac_cv_host
+else
+ ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
+$as_echo "$ac_cv_target" >&6; }
+case $ac_cv_target in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
+esac
+target=$ac_cv_target
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_target
+shift
+target_cpu=$1
+target_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+target_os=$*
+IFS=$ac_save_IFS
+case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
+
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+test -n "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+
+
+
+am__api_version='1.11'
+
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
@@ -2983,7 +3093,7 @@ fi
# Define the identity of the package.
PACKAGE='gst-libav'
- VERSION='0.11.92'
+ VERSION='0.11.93'
cat >>confdefs.h <<_ACEOF
@@ -3106,9 +3216,9 @@ $as_echo "$am_cv_prog_tar_ustar" >&6; }
- PACKAGE_VERSION_MAJOR=$(echo 0.11.92 | cut -d'.' -f1)
- PACKAGE_VERSION_MINOR=$(echo 0.11.92 | cut -d'.' -f2)
- PACKAGE_VERSION_MICRO=$(echo 0.11.92 | cut -d'.' -f3)
+ PACKAGE_VERSION_MAJOR=$(echo 0.11.93 | cut -d'.' -f1)
+ PACKAGE_VERSION_MINOR=$(echo 0.11.93 | cut -d'.' -f2)
+ PACKAGE_VERSION_MICRO=$(echo 0.11.93 | cut -d'.' -f3)
@@ -3119,7 +3229,7 @@ $as_echo "$am_cv_prog_tar_ustar" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking nano version" >&5
$as_echo_n "checking nano version... " >&6; }
- NANO=$(echo 0.11.92 | cut -d'.' -f4)
+ NANO=$(echo 0.11.93 | cut -d'.' -f4)
if test x"$NANO" = x || test "x$NANO" = "x0" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 0 (release)" >&5
@@ -3171,76 +3281,6 @@ fi
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
- as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-$as_echo_n "checking build system type... " >&6; }
-if ${ac_cv_build+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_build_alias=$build_alias
-test "x$ac_build_alias" = x &&
- ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-test "x$ac_build_alias" = x &&
- as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
- as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-$as_echo "$ac_cv_build" >&6; }
-case $ac_cv_build in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
-esac
-build=$ac_cv_build
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_build
-shift
-build_cpu=$1
-build_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-build_os=$*
-IFS=$ac_save_IFS
-case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-$as_echo_n "checking host system type... " >&6; }
-if ${ac_cv_host+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test "x$host_alias" = x; then
- ac_cv_host=$ac_cv_build
-else
- ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
- as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
-$as_echo "$ac_cv_host" >&6; }
-case $ac_cv_host in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
-esac
-host=$ac_cv_host
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_host
-shift
-host_cpu=$1
-host_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-host_os=$*
-IFS=$ac_save_IFS
-case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-
# Check whether --enable-silent-rules was given.
@@ -5486,10 +5526,6 @@ freebsd* | dragonfly*)
fi
;;
-gnu*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
haiku*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -5528,7 +5564,7 @@ irix5* | irix6* | nonstopux*)
;;
# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -8766,7 +8802,7 @@ lt_prog_compiler_static=
lt_prog_compiler_static='-non_shared'
;;
- linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
# old Intel for x86_64 which still supported -KPIC.
ecc*)
@@ -10936,17 +10972,6 @@ freebsd* | dragonfly*)
esac
;;
-gnu*)
- version_type=linux # correct to gnu/linux during the next big refactor
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
haiku*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
@@ -11063,7 +11088,7 @@ linux*oldld* | linux*aout* | linux*coff*)
;;
# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
@@ -12111,8 +12136,8 @@ CC="$lt_save_CC"
-GST_REQ=0.11.91
-ORC_REQ=0.4.6
+GST_REQ=0.11.93
+ORC_REQ=0.4.16
@@ -12485,46 +12510,6 @@ $as_echo "$as_me: Using extra code paths for valgrind" >&6;}
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
-$as_echo_n "checking target system type... " >&6; }
-if ${ac_cv_target+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test "x$target_alias" = x; then
- ac_cv_target=$ac_cv_host
-else
- ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
- as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
-$as_echo "$ac_cv_target" >&6; }
-case $ac_cv_target in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
-esac
-target=$ac_cv_target
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_target
-shift
-target_cpu=$1
-target_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-target_os=$*
-IFS=$ac_save_IFS
-case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
-
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-test -n "$target_alias" &&
- test "$program_prefix$program_suffix$program_transform_name" = \
- NONENONEs,x,x, &&
- program_prefix=${target_alias}-
-
case "x${target_cpu}" in
xi?86 | xk? | xi?86_64)
@@ -17948,7 +17933,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by GStreamer libav $as_me 0.11.92, which was
+This file was extended by GStreamer libav $as_me 0.11.93, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -18014,7 +17999,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-GStreamer libav config.status 0.11.92
+GStreamer libav config.status 0.11.93
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 01ff757..e6c3cee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,7 +3,7 @@ AC_PREREQ(2.62)
dnl initialize autoconf
dnl when going to/from release please set the nano (fourth number) right !
dnl releases only do Wall, cvs and prerelease does Werror too
-AC_INIT(GStreamer libav, 0.11.92,
+AC_INIT(GStreamer libav, 0.11.93,
http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
gst-libav)
@@ -45,8 +45,8 @@ AG_GST_LIBTOOL_PREPARE
AS_LIBTOOL(GST, 0, 0, 0)
dnl *** required versions of GStreamer stuff ***
-GST_REQ=0.11.91
-ORC_REQ=0.4.6
+GST_REQ=0.11.93
+ORC_REQ=0.4.16
dnl *** autotools stuff ****
diff --git a/depcomp b/depcomp
index bd0ac08..25a39e6 100755
--- a/depcomp
+++ b/depcomp
@@ -1,10 +1,10 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
-scriptversion=2011-12-04.11; # UTC
+scriptversion=2012-03-27.16; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
-# 2011 Free Software Foundation, Inc.
+# 2011, 2012 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -28,7 +28,7 @@ scriptversion=2011-12-04.11; # UTC
case $1 in
'')
- echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
@@ -40,8 +40,8 @@ as side-effects.
Environment variables:
depmode Dependency tracking mode.
- source Source file read by `PROGRAMS ARGS'.
- object Object file output by `PROGRAMS ARGS'.
+ source Source file read by 'PROGRAMS ARGS'.
+ object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
@@ -57,6 +57,12 @@ EOF
;;
esac
+# A tabulation character.
+tab=' '
+# A newline character.
+nl='
+'
+
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
@@ -102,6 +108,12 @@ if test "$depmode" = msvc7msys; then
depmode=msvc7
fi
+if test "$depmode" = xlc; then
+ # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
+ gccflag=-qmakedep=gcc,-MF
+ depmode=gcc
+fi
+
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
@@ -156,15 +168,14 @@ gcc)
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
-## This next piece of magic avoids the `deleted header file' problem.
+## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
- tr ' ' '
-' < "$tmpdepfile" |
-## Some versions of gcc put a space before the `:'. On the theory
+ tr ' ' "$nl" < "$tmpdepfile" |
+## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
@@ -203,18 +214,15 @@ sgi)
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
- # the IRIX cc adds comments like `#:fec' to the end of the
+ # the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
- tr ' ' '
-' < "$tmpdepfile" \
+ tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
- tr '
-' ' ' >> "$depfile"
+ tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
- tr ' ' '
-' < "$tmpdepfile" \
+ tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
@@ -226,10 +234,17 @@ sgi)
rm -f "$tmpdepfile"
;;
+xlc)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
- # current directory. Also, the AIX compiler puts `$object:' at the
+ # current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
@@ -259,12 +274,11 @@ aix)
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
- # Each line is of the form `foo.o: dependent.h'.
+ # Each line is of the form 'foo.o: dependent.h'.
# Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
+ # '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a tab and a space in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
@@ -275,23 +289,26 @@ aix)
;;
icc)
- # Intel's C compiler understands `-MD -MF file'. However on
- # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
+ # However on
+ # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
- # which is wrong. We want:
+ # which is wrong. We want
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
- # and will wrap long lines using \ :
+ # and will wrap long lines using '\':
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
-
+ # tcc 0.9.26 (FIXME still under development at the moment of writing)
+ # will emit a similar output, but also prepend the continuation lines
+ # with horizontal tabulation characters.
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
@@ -300,15 +317,21 @@ icc)
exit $stat
fi
rm -f "$depfile"
- # Each line is of the form `foo.o: dependent.h',
- # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Each line is of the form 'foo.o: dependent.h',
+ # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
# Do two passes, one to just change these to
- # `$object: dependent.h' and one to simply `dependent.h:'.
- sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
- # Some versions of the HPUX 10.20 sed can't process this invocation
- # correctly. Breaking it into two sed invocations is a workaround.
- sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
- sed -e 's/$/ :/' >> "$depfile"
+ # '$object: dependent.h' and one to simply 'dependent.h:'.
+ sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
+ < "$tmpdepfile" > "$depfile"
+ sed '
+ s/[ '"$tab"'][ '"$tab"']*/ /g
+ s/^ *//
+ s/ *\\*$//
+ s/^[^:]*: *//
+ /^$/d
+ /:$/d
+ s/$/ :/
+ ' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
@@ -344,7 +367,7 @@ hp2)
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
- # Add `dependent.h:' lines.
+ # Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
@@ -359,9 +382,9 @@ hp2)
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
- # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+ # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
- # dependencies in `foo.d' instead, so we check for that too.
+ # dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
@@ -407,8 +430,7 @@ tru64)
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
- # That's a tab and a space in the [].
- sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
@@ -443,11 +465,11 @@ msvc7)
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
-s/\(.*\)/ \1 \\/p
+s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
- s/.*/ /
+ s/.*/'"$tab"'/
G
p
}' >> "$depfile"
@@ -478,7 +500,7 @@ dashmstdout)
shift
fi
- # Remove `-o $object'.
+ # Remove '-o $object'.
IFS=" "
for arg
do
@@ -498,15 +520,14 @@ dashmstdout)
done
test -z "$dashmflag" && dashmflag=-M
- # Require at least two characters before searching for `:'
+ # Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
- # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+ # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
- sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
+ sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
- tr ' ' '
-' < "$tmpdepfile" | \
+ tr ' ' "$nl" < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
@@ -562,8 +583,7 @@ makedepend)
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
- sed '1,2d' "$tmpdepfile" | tr ' ' '
-' | \
+ sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
@@ -583,7 +603,7 @@ cpp)
shift
fi
- # Remove `-o $object'.
+ # Remove '-o $object'.
IFS=" "
for arg
do
@@ -652,8 +672,8 @@ msvisualcpp)
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
- sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
- echo " " >> "$depfile"
+ sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
+ echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
diff --git a/docs/Makefile.in b/docs/Makefile.in
index c475dc9..13272cc 100644
--- a/docs/Makefile.in
+++ b/docs/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/ext/Makefile.in b/ext/Makefile.in
index 0b650c7..673d7f5 100644
--- a/ext/Makefile.in
+++ b/ext/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/ext/ffmpeg/Makefile.am b/ext/ffmpeg/Makefile.am
index bae2a6d..ac4a7e8 100644
--- a/ext/ffmpeg/Makefile.am
+++ b/ext/ffmpeg/Makefile.am
@@ -11,7 +11,9 @@ libgstlibav_la_SOURCES = gstffmpeg.c \
gstffmpegcodecmap.c \
gstffmpegutils.c \
gstffmpegenc.c \
+ gstffmpegvidenc.c \
gstffmpegdec.c \
+ gstffmpegviddec.c \
gstffmpegcfg.c \
gstffmpegdemux.c \
gstffmpegmux.c \
@@ -39,5 +41,6 @@ noinst_HEADERS = \
gstffmpegcodecmap.h \
gstffmpegutils.h \
gstffmpegenc.h \
+ gstffmpegvidenc.h \
gstffmpegcfg.h \
gstffmpegpipe.h
diff --git a/ext/ffmpeg/Makefile.in b/ext/ffmpeg/Makefile.in
index f25d5f6..3918dcc 100644
--- a/ext/ffmpeg/Makefile.in
+++ b/ext/ffmpeg/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -126,7 +126,10 @@ am_libgstlibav_la_OBJECTS = libgstlibav_la-gstffmpeg.lo \
libgstlibav_la-gstffmpegprotocol.lo \
libgstlibav_la-gstffmpegcodecmap.lo \
libgstlibav_la-gstffmpegutils.lo \
- libgstlibav_la-gstffmpegenc.lo libgstlibav_la-gstffmpegdec.lo \
+ libgstlibav_la-gstffmpegenc.lo \
+ libgstlibav_la-gstffmpegvidenc.lo \
+ libgstlibav_la-gstffmpegdec.lo \
+ libgstlibav_la-gstffmpegviddec.lo \
libgstlibav_la-gstffmpegcfg.lo \
libgstlibav_la-gstffmpegdemux.lo \
libgstlibav_la-gstffmpegmux.lo \
@@ -394,7 +397,9 @@ libgstlibav_la_SOURCES = gstffmpeg.c \
gstffmpegcodecmap.c \
gstffmpegutils.c \
gstffmpegenc.c \
+ gstffmpegvidenc.c \
gstffmpegdec.c \
+ gstffmpegviddec.c \
gstffmpegcfg.c \
gstffmpegdemux.c \
gstffmpegmux.c \
@@ -418,6 +423,7 @@ noinst_HEADERS = \
gstffmpegcodecmap.h \
gstffmpegutils.h \
gstffmpegenc.h \
+ gstffmpegvidenc.h \
gstffmpegcfg.h \
gstffmpegpipe.h
@@ -506,6 +512,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstlibav_la-gstffmpegmux.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstlibav_la-gstffmpegprotocol.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstlibav_la-gstffmpegutils.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstlibav_la-gstffmpegviddec.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstlibav_la-gstffmpegvidenc.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -563,6 +571,13 @@ libgstlibav_la-gstffmpegenc.lo: gstffmpegenc.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlibav_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlibav_la_CFLAGS) $(CFLAGS) -c -o libgstlibav_la-gstffmpegenc.lo `test -f 'gstffmpegenc.c' || echo '$(srcdir)/'`gstffmpegenc.c
+libgstlibav_la-gstffmpegvidenc.lo: gstffmpegvidenc.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlibav_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlibav_la_CFLAGS) $(CFLAGS) -MT libgstlibav_la-gstffmpegvidenc.lo -MD -MP -MF $(DEPDIR)/libgstlibav_la-gstffmpegvidenc.Tpo -c -o libgstlibav_la-gstffmpegvidenc.lo `test -f 'gstffmpegvidenc.c' || echo '$(srcdir)/'`gstffmpegvidenc.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstlibav_la-gstffmpegvidenc.Tpo $(DEPDIR)/libgstlibav_la-gstffmpegvidenc.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstffmpegvidenc.c' object='libgstlibav_la-gstffmpegvidenc.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 $(libgstlibav_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlibav_la_CFLAGS) $(CFLAGS) -c -o libgstlibav_la-gstffmpegvidenc.lo `test -f 'gstffmpegvidenc.c' || echo '$(srcdir)/'`gstffmpegvidenc.c
+
libgstlibav_la-gstffmpegdec.lo: gstffmpegdec.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlibav_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlibav_la_CFLAGS) $(CFLAGS) -MT libgstlibav_la-gstffmpegdec.lo -MD -MP -MF $(DEPDIR)/libgstlibav_la-gstffmpegdec.Tpo -c -o libgstlibav_la-gstffmpegdec.lo `test -f 'gstffmpegdec.c' || echo '$(srcdir)/'`gstffmpegdec.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstlibav_la-gstffmpegdec.Tpo $(DEPDIR)/libgstlibav_la-gstffmpegdec.Plo
@@ -570,6 +585,13 @@ libgstlibav_la-gstffmpegdec.lo: gstffmpegdec.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlibav_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlibav_la_CFLAGS) $(CFLAGS) -c -o libgstlibav_la-gstffmpegdec.lo `test -f 'gstffmpegdec.c' || echo '$(srcdir)/'`gstffmpegdec.c
+libgstlibav_la-gstffmpegviddec.lo: gstffmpegviddec.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlibav_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlibav_la_CFLAGS) $(CFLAGS) -MT libgstlibav_la-gstffmpegviddec.lo -MD -MP -MF $(DEPDIR)/libgstlibav_la-gstffmpegviddec.Tpo -c -o libgstlibav_la-gstffmpegviddec.lo `test -f 'gstffmpegviddec.c' || echo '$(srcdir)/'`gstffmpegviddec.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstlibav_la-gstffmpegviddec.Tpo $(DEPDIR)/libgstlibav_la-gstffmpegviddec.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='gstffmpegviddec.c' object='libgstlibav_la-gstffmpegviddec.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 $(libgstlibav_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlibav_la_CFLAGS) $(CFLAGS) -c -o libgstlibav_la-gstffmpegviddec.lo `test -f 'gstffmpegviddec.c' || echo '$(srcdir)/'`gstffmpegviddec.c
+
libgstlibav_la-gstffmpegcfg.lo: gstffmpegcfg.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstlibav_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstlibav_la_CFLAGS) $(CFLAGS) -MT libgstlibav_la-gstffmpegcfg.lo -MD -MP -MF $(DEPDIR)/libgstlibav_la-gstffmpegcfg.Tpo -c -o libgstlibav_la-gstffmpegcfg.lo `test -f 'gstffmpegcfg.c' || echo '$(srcdir)/'`gstffmpegcfg.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstlibav_la-gstffmpegcfg.Tpo $(DEPDIR)/libgstlibav_la-gstffmpegcfg.Plo
diff --git a/ext/ffmpeg/gstffmpeg.c b/ext/ffmpeg/gstffmpeg.c
index 899d4be..a0e79d0 100644
--- a/ext/ffmpeg/gstffmpeg.c
+++ b/ext/ffmpeg/gstffmpeg.c
@@ -138,8 +138,10 @@ plugin_init (GstPlugin * plugin)
av_register_all ();
- gst_ffmpegenc_register (plugin);
- gst_ffmpegdec_register (plugin);
+ gst_ffmpegaudenc_register (plugin);
+ gst_ffmpegvidenc_register (plugin);
+ gst_ffmpegauddec_register (plugin);
+ gst_ffmpegviddec_register (plugin);
gst_ffmpegdemux_register (plugin);
gst_ffmpegmux_register (plugin);
gst_ffmpegdeinterlace_register (plugin);
diff --git a/ext/ffmpeg/gstffmpeg.h b/ext/ffmpeg/gstffmpeg.h
index 602e1f1..22ebc07 100644
--- a/ext/ffmpeg/gstffmpeg.h
+++ b/ext/ffmpeg/gstffmpeg.h
@@ -44,8 +44,10 @@ extern gboolean _shut_up_I_am_probing;
#endif
extern gboolean gst_ffmpegdemux_register (GstPlugin * plugin);
-extern gboolean gst_ffmpegdec_register (GstPlugin * plugin);
-extern gboolean gst_ffmpegenc_register (GstPlugin * plugin);
+extern gboolean gst_ffmpegauddec_register (GstPlugin * plugin);
+extern gboolean gst_ffmpegviddec_register (GstPlugin * plugin);
+extern gboolean gst_ffmpegaudenc_register (GstPlugin * plugin);
+extern gboolean gst_ffmpegvidenc_register (GstPlugin * plugin);
extern gboolean gst_ffmpegmux_register (GstPlugin * plugin);
extern gboolean gst_ffmpegcsp_register (GstPlugin * plugin);
#if 0
diff --git a/ext/ffmpeg/gstffmpegcfg.c b/ext/ffmpeg/gstffmpegcfg.c
index cd3b589..99390be 100644
--- a/ext/ffmpeg/gstffmpegcfg.c
+++ b/ext/ffmpeg/gstffmpegcfg.c
@@ -26,7 +26,7 @@
#endif
#include "gstffmpeg.h"
-#include "gstffmpegenc.h"
+#include "gstffmpegvidenc.h"
#include "gstffmpegcfg.h"
#include <string.h>
@@ -324,7 +324,7 @@ struct _GParamSpecData
/* properties whose member offset is higher than the config base
* can be copied directly at context configuration time;
* and can also retrieve a default value from lavc */
-#define CONTEXT_CONFIG_OFFSET G_STRUCT_OFFSET (GstFFMpegEnc, config)
+#define CONTEXT_CONFIG_OFFSET G_STRUCT_OFFSET (GstFFMpegVidEnc, config)
/* additional info is named pointer specified by the quark */
static GQuark quark;
@@ -339,7 +339,7 @@ static GList *property_list;
default, include, exclude) \
G_STMT_START { \
GParamSpecData *_qdata = g_new0 (GParamSpecData, 1); \
- GstFFMpegEnc _enc; \
+ GstFFMpegVidEnc _enc; \
_qdata->offset = G_STRUCT_OFFSET (struct_type, member); \
_qdata->size = sizeof (_enc.member); \
_qdata->lavc_default = default; \
@@ -350,7 +350,7 @@ G_STMT_START { \
} G_STMT_END
#define gst_ffmpeg_add_pspec(pspec, member, default, include, exclude) \
- gst_ffmpeg_add_pspec_full (pspec, property_list, GstFFMpegEnc, member, \
+ gst_ffmpeg_add_pspec_full (pspec, property_list, GstFFMpegVidEnc, member, \
default, include, exclude)
/* ==== BEGIN CONFIGURATION SECTION ==== */
@@ -401,11 +401,6 @@ gst_ffmpeg_cfg_init (void)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
gst_ffmpeg_add_pspec (pspec, quantizer, FALSE, mpeg, NULL);
- pspec = g_param_spec_string ("statsfile", "Statistics Filename",
- "Filename to store data for 2-pass encoding (deprecated, use multipass-cache-file)",
- "stats.log", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- gst_ffmpeg_add_pspec (pspec, filename, FALSE, mpeg, NULL);
-
pspec = g_param_spec_string ("multipass-cache-file", "Multipass Cache File",
"Filename for multipass cache file", "stats.log",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
@@ -487,16 +482,6 @@ gst_ffmpeg_cfg_init (void)
1, 31, 3, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
gst_ffmpeg_add_pspec (pspec, config.max_qdiff, FALSE, mpeg, NULL);
- pspec = g_param_spec_int ("mb-qmin", "Minimum MB Quantizer (DEPRECATED)",
- "Minimum MB Quantizer (DEPRECATED, use qmin instead)", 0, 31, 2,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- gst_ffmpeg_add_pspec (pspec, config.qmin, FALSE, mpeg, NULL);
-
- pspec = g_param_spec_int ("mb-qmax", "Maximum MB Quantizer (DEPRECATED)",
- "Maximum MB Quantizer (DEPRECATED, use qmax instead)", 0, 31, 31,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
- gst_ffmpeg_add_pspec (pspec, config.qmax, FALSE, mpeg, NULL);
-
pspec = g_param_spec_int ("lmin", "Minimum Lagrange Multiplier",
"Minimum Lagrange Multiplier", 1, 31, 2,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
@@ -755,7 +740,7 @@ gst_ffmpeg_cfg_codec_has_pspec (enum CodecID codec_id, GParamSpec * pspec)
/* install all properties for klass that have been registered in property_list */
void
-gst_ffmpeg_cfg_install_property (GstFFMpegEncClass * klass, guint base)
+gst_ffmpeg_cfg_install_property (GstFFMpegVidEncClass * klass, guint base)
{
GParamSpec *pspec;
GList *list;
@@ -823,15 +808,6 @@ gst_ffmpeg_cfg_install_property (GstFFMpegEncClass * klass, guint base)
: puint->default_value, pspec->flags);
break;
}
- case G_TYPE_ULONG:{
- GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (pspec);
-
- pspec = g_param_spec_ulong (name, nick, blurb,
- pulong->minimum, pulong->maximum,
- lavc_default ? G_STRUCT_MEMBER (gulong, ctx, ctx_offset)
- : pulong->default_value, pspec->flags);
- break;
- }
case G_TYPE_FLOAT:{
GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (pspec);
@@ -887,7 +863,7 @@ gboolean
gst_ffmpeg_cfg_set_property (GObject * object,
const GValue * value, GParamSpec * pspec)
{
- GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (object);
+ GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) (object);
GParamSpecData *qdata;
qdata = g_param_spec_get_qdata (pspec, quark);
@@ -913,11 +889,6 @@ gst_ffmpeg_cfg_set_property (GObject * object,
G_STRUCT_MEMBER (gint, ffmpegenc, qdata->offset) =
g_value_get_int (value);
break;
- case G_TYPE_ULONG:
- g_return_val_if_fail (qdata->size == sizeof (gulong), TRUE);
- G_STRUCT_MEMBER (glong, ffmpegenc, qdata->offset) =
- g_value_get_ulong (value);
- break;
case G_TYPE_FLOAT:
g_return_val_if_fail (qdata->size == sizeof (gfloat), TRUE);
G_STRUCT_MEMBER (gfloat, ffmpegenc, qdata->offset) =
@@ -955,7 +926,7 @@ gboolean
gst_ffmpeg_cfg_get_property (GObject * object,
GValue * value, GParamSpec * pspec)
{
- GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) (object);
+ GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) (object);
GParamSpecData *qdata;
qdata = g_param_spec_get_qdata (pspec, quark);
@@ -980,11 +951,6 @@ gst_ffmpeg_cfg_get_property (GObject * object,
g_return_val_if_fail (qdata->size == sizeof (gint), TRUE);
g_value_set_int (value, G_STRUCT_MEMBER (gint, ffmpegenc, qdata->offset));
break;
- case G_TYPE_ULONG:
- g_return_val_if_fail (qdata->size == sizeof (gulong), TRUE);
- g_value_set_ulong (value,
- G_STRUCT_MEMBER (glong, ffmpegenc, qdata->offset));
- break;
case G_TYPE_FLOAT:
g_return_val_if_fail (qdata->size == sizeof (gfloat), TRUE);
g_value_set_float (value,
@@ -1015,7 +981,7 @@ gst_ffmpeg_cfg_get_property (GObject * object,
}
void
-gst_ffmpeg_cfg_set_defaults (GstFFMpegEnc * ffmpegenc)
+gst_ffmpeg_cfg_set_defaults (GstFFMpegVidEnc * ffmpegenc)
{
GParamSpec **pspecs;
guint num_props, i;
@@ -1043,10 +1009,11 @@ gst_ffmpeg_cfg_set_defaults (GstFFMpegEnc * ffmpegenc)
void
-gst_ffmpeg_cfg_fill_context (GstFFMpegEnc * ffmpegenc, AVCodecContext * context)
+gst_ffmpeg_cfg_fill_context (GstFFMpegVidEnc * ffmpegenc,
+ AVCodecContext * context)
{
- GstFFMpegEncClass *klass
- = (GstFFMpegEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
+ GstFFMpegVidEncClass *klass
+ = (GstFFMpegVidEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
GParamSpec *pspec;
GParamSpecData *qdata;
GList *list;
@@ -1078,7 +1045,7 @@ gst_ffmpeg_cfg_fill_context (GstFFMpegEnc * ffmpegenc, AVCodecContext * context)
}
void
-gst_ffmpeg_cfg_finalize (GstFFMpegEnc * ffmpegenc)
+gst_ffmpeg_cfg_finalize (GstFFMpegVidEnc * ffmpegenc)
{
GParamSpec **pspecs;
guint num_props, i;
diff --git a/ext/ffmpeg/gstffmpegcfg.h b/ext/ffmpeg/gstffmpegcfg.h
index 1dcaade..5251eb2 100644
--- a/ext/ffmpeg/gstffmpegcfg.h
+++ b/ext/ffmpeg/gstffmpegcfg.h
@@ -25,7 +25,7 @@ G_BEGIN_DECLS
void gst_ffmpeg_cfg_init (void);
-void gst_ffmpeg_cfg_install_property (GstFFMpegEncClass * klass, guint base);
+void gst_ffmpeg_cfg_install_property (GstFFMpegVidEncClass * klass, guint base);
gboolean gst_ffmpeg_cfg_set_property (GObject * object,
const GValue * value, GParamSpec * pspec);
@@ -33,9 +33,9 @@ gboolean gst_ffmpeg_cfg_set_property (GObject * object,
gboolean gst_ffmpeg_cfg_get_property (GObject * object,
GValue * value, GParamSpec * pspec);
-void gst_ffmpeg_cfg_fill_context (GstFFMpegEnc * ffmpegenc, AVCodecContext * context);
-void gst_ffmpeg_cfg_set_defaults (GstFFMpegEnc * ffmpegenc);
-void gst_ffmpeg_cfg_finalize (GstFFMpegEnc * ffmpegenc);
+void gst_ffmpeg_cfg_fill_context (GstFFMpegVidEnc * ffmpegenc, AVCodecContext * context);
+void gst_ffmpeg_cfg_set_defaults (GstFFMpegVidEnc * ffmpegenc);
+void gst_ffmpeg_cfg_finalize (GstFFMpegVidEnc * ffmpegenc);
G_END_DECLS
diff --git a/ext/ffmpeg/gstffmpegcodecmap.c b/ext/ffmpeg/gstffmpegcodecmap.c
index 4c2727a..0df3c2d 100644
--- a/ext/ffmpeg/gstffmpegcodecmap.c
+++ b/ext/ffmpeg/gstffmpegcodecmap.c
@@ -182,7 +182,7 @@ gst_ffmpeg_channel_layout_to_gst (AVCodecContext * context,
*/
static GstCaps *
gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
- const char *mimetype, const char *fieldname, ...)
+ gboolean encode, const char *mimetype, const char *fieldname, ...)
{
GstStructure *structure = NULL;
GstCaps *caps = NULL;
@@ -214,7 +214,7 @@ gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
GST_LOG ("setting framerate: %d/%d", num, denom);
gst_caps_set_simple (caps,
"framerate", GST_TYPE_FRACTION, num, denom, NULL);
- } else {
+ } else if (encode) {
/* so we are after restricted caps in this case */
switch (codec_id) {
case CODEC_ID_H261:
@@ -321,7 +321,7 @@ gst_ff_vid_caps_new (AVCodecContext * context, enum CodecID codec_id,
*/
static GstCaps *
gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id,
- const char *mimetype, const char *fieldname, ...)
+ gboolean encode, const char *mimetype, const char *fieldname, ...)
{
GstCaps *caps = NULL;
GstStructure *structure = NULL;
@@ -339,12 +339,13 @@ gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id,
if (gst_ffmpeg_channel_layout_to_gst (context, pos)) {
guint64 mask;
- if (gst_audio_channel_positions_to_mask (pos, context->channels, &mask)) {
+ if (gst_audio_channel_positions_to_mask (pos, context->channels, FALSE,
+ &mask)) {
gst_caps_set_simple (caps, "channel-mask", GST_TYPE_BITMASK, mask,
NULL);
}
}
- } else {
+ } else if (encode) {
gint maxchannels = 2;
const gint *rates = NULL;
gint n_rates = 0;
@@ -463,6 +464,8 @@ gst_ff_aud_caps_new (AVCodecContext * context, enum CodecID codec_id,
g_value_unset (&list);
} else
gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL);
+ } else {
+ caps = gst_caps_new_empty_simple (mimetype);
}
for (i = 0; i < gst_caps_get_size (caps); i++) {
@@ -503,7 +506,7 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
switch (codec_id) {
case CODEC_ID_MPEG1VIDEO:
/* FIXME: bitrate */
- caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/mpeg",
"mpegversion", G_TYPE_INT, 1,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
break;
@@ -511,7 +514,7 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
case CODEC_ID_MPEG2VIDEO:
if (encode) {
/* FIXME: bitrate */
- caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/mpeg",
"mpegversion", G_TYPE_INT, 2,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
} else {
@@ -529,20 +532,21 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
case CODEC_ID_H263:
if (encode) {
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-h263",
"variant", G_TYPE_STRING, "itu",
"h263version", G_TYPE_STRING, "h263", NULL);
} else {
/* don't pass codec_id, we can decode other variants with the H263
* decoder that don't have specific size requirements
*/
- caps = gst_ff_vid_caps_new (context, CODEC_ID_NONE, "video/x-h263",
+ caps =
+ gst_ff_vid_caps_new (context, CODEC_ID_NONE, encode, "video/x-h263",
"variant", G_TYPE_STRING, "itu", NULL);
}
break;
case CODEC_ID_H263P:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h263",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-h263",
"variant", G_TYPE_STRING, "itu",
"h263version", G_TYPE_STRING, "h263p", NULL);
if (encode && context) {
@@ -557,12 +561,14 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_H263I:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-intel-h263",
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-intel-h263",
"variant", G_TYPE_STRING, "intel", NULL);
break;
case CODEC_ID_H261:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h261", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-h261", NULL);
break;
case CODEC_ID_RV10:
@@ -588,8 +594,9 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
}
/* FIXME: context->sub_id must be filled in during decoding */
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-pn-realvideo",
- "systemstream", G_TYPE_BOOLEAN, FALSE,
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode,
+ "video/x-pn-realvideo", "systemstream", G_TYPE_BOOLEAN, FALSE,
"rmversion", G_TYPE_INT, version, NULL);
if (context) {
gst_caps_set_simple (caps, "format", G_TYPE_INT, context->sub_id, NULL);
@@ -604,20 +611,20 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
case CODEC_ID_MP1:
/* FIXME: bitrate */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/mpeg",
"mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 1, NULL);
break;
case CODEC_ID_MP2:
/* FIXME: bitrate */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/mpeg",
"mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 2, NULL);
break;
case CODEC_ID_MP3:
if (encode) {
/* FIXME: bitrate */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/mpeg",
"mpegversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3, NULL);
} else {
/* Decodes MPEG-1 layer 1/2/3. Samplerate, channels et al are
@@ -630,52 +637,57 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
case CODEC_ID_MUSEPACK7:
caps =
- gst_ff_aud_caps_new (context, codec_id,
+ gst_ff_aud_caps_new (context, codec_id, encode,
"audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 7,
NULL);
break;
case CODEC_ID_MUSEPACK8:
caps =
- gst_ff_aud_caps_new (context, codec_id,
+ gst_ff_aud_caps_new (context, codec_id, encode,
"audio/x-ffmpeg-parsed-musepack", "streamversion", G_TYPE_INT, 8,
NULL);
break;
case CODEC_ID_AC3:
/* FIXME: bitrate */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-ac3", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-ac3", NULL);
break;
case CODEC_ID_EAC3:
/* FIXME: bitrate */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-eac3", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-eac3", NULL);
break;
case CODEC_ID_TRUEHD:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-true-hd", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-true-hd",
+ NULL);
break;
case CODEC_ID_ATRAC1:
caps =
- gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac1",
- NULL);
+ gst_ff_aud_caps_new (context, codec_id, encode,
+ "audio/x-vnd.sony.atrac1", NULL);
break;
case CODEC_ID_ATRAC3:
caps =
- gst_ff_aud_caps_new (context, codec_id, "audio/x-vnd.sony.atrac3",
- NULL);
+ gst_ff_aud_caps_new (context, codec_id, encode,
+ "audio/x-vnd.sony.atrac3", NULL);
break;
case CODEC_ID_DTS:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dts", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-dts", NULL);
break;
case CODEC_ID_APE:
caps =
- gst_ff_aud_caps_new (context, codec_id, "audio/x-ffmpeg-parsed-ape",
- NULL);
+ gst_ff_aud_caps_new (context, codec_id, encode,
+ "audio/x-ffmpeg-parsed-ape", NULL);
if (context) {
gst_caps_set_simple (caps,
"depth", G_TYPE_INT, context->bits_per_coded_sample, NULL);
@@ -683,11 +695,13 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_MLP:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mlp", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-mlp", NULL);
break;
case CODEC_ID_IMC:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-imc", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-imc", NULL);
break;
/* MJPEG is normal JPEG, Motion-JPEG and Quicktime MJPEG-A. MJPEGB
@@ -697,15 +711,19 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
* MJPEG-B and sp5x decoding...)? */
case CODEC_ID_MJPEG:
case CODEC_ID_LJPEG:
- caps = gst_ff_vid_caps_new (context, codec_id, "image/jpeg", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "image/jpeg", NULL);
break;
case CODEC_ID_SP5X:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/sp5x", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/sp5x", NULL);
break;
case CODEC_ID_MJPEGB:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mjpeg-b", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-mjpeg-b",
+ NULL);
break;
case CODEC_ID_MPEG4:
@@ -714,32 +732,33 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
* the AVI fourcc 'DIVX', but 'mp4v' for Quicktime... */
switch (context->codec_tag) {
case GST_MAKE_FOURCC ('D', 'I', 'V', 'X'):
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-divx",
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-divx",
"divxversion", G_TYPE_INT, 5, NULL);
break;
case GST_MAKE_FOURCC ('m', 'p', '4', 'v'):
default:
/* FIXME: bitrate */
- caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/mpeg",
"systemstream", G_TYPE_BOOLEAN, FALSE,
"mpegversion", G_TYPE_INT, 4, NULL);
break;
}
} else {
/* The trick here is to separate xvid, divx, mpeg4, 3ivx et al */
- caps = gst_ff_vid_caps_new (context, codec_id, "video/mpeg",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/mpeg",
"mpegversion", G_TYPE_INT, 4,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
if (encode) {
- gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id, encode,
"video/x-divx", "divxversion", G_TYPE_INT, 5, NULL));
} else {
- gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id, encode,
"video/x-divx", "divxversion", GST_TYPE_INT_RANGE, 4, 5,
NULL));
- gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id, encode,
"video/x-xvid", NULL));
- gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id, encode,
"video/x-3ivx", NULL));
}
}
@@ -758,10 +777,10 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
gint version = 41 + codec_id - CODEC_ID_MSMPEG4V1;
/* encode-FIXME: bitrate */
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msmpeg",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-msmpeg",
"msmpegversion", G_TYPE_INT, version, NULL);
if (!encode && codec_id == CODEC_ID_MSMPEG4V3) {
- gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id,
+ gst_caps_append (caps, gst_ff_vid_caps_new (context, codec_id, encode,
"video/x-divx", "divxversion", G_TYPE_INT, 3, NULL));
}
}
@@ -772,28 +791,30 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
{
gint version = (codec_id == CODEC_ID_WMV1) ? 1 : 2;
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-wmv",
"wmvversion", G_TYPE_INT, version, NULL);
}
break;
case CODEC_ID_FLV1:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-flash-video",
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-flash-video",
"flvversion", G_TYPE_INT, 1, NULL);
break;
case CODEC_ID_SVQ1:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-svq",
"svqversion", G_TYPE_INT, 1, NULL);
break;
case CODEC_ID_SVQ3:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-svq",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-svq",
"svqversion", G_TYPE_INT, 3, NULL);
break;
case CODEC_ID_DVAUDIO:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dv", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-dv", NULL);
break;
case CODEC_ID_DVVIDEO:
@@ -827,11 +848,11 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
format = "I420";
break;
}
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-dv",
"systemstream", G_TYPE_BOOLEAN, FALSE,
"format", G_TYPE_STRING, format, NULL);
} else {
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dv",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-dv",
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
}
}
@@ -843,12 +864,12 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
gint version = (codec_id == CODEC_ID_WMAV1) ? 1 : 2;
if (context) {
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-wma",
"wmaversion", G_TYPE_INT, version,
"block_align", G_TYPE_INT, context->block_align,
"bitrate", G_TYPE_INT, context->bit_rate, NULL);
} else {
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-wma",
"wmaversion", G_TYPE_INT, version,
"block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
"bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT, NULL);
@@ -857,14 +878,15 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_WMAPRO:
{
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wma",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-wma",
"wmaversion", G_TYPE_INT, 3, NULL);
break;
}
case CODEC_ID_WMAVOICE:
{
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-wms", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-wms", NULL);
break;
}
@@ -873,13 +895,15 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
{
gint version = (codec_id == CODEC_ID_MACE3) ? 3 : 6;
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mace",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-mace",
"maceversion", G_TYPE_INT, version, NULL);
}
break;
case CODEC_ID_HUFFYUV:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-huffyuv", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-huffyuv",
+ NULL);
if (context) {
gst_caps_set_simple (caps,
"bpp", G_TYPE_INT, context->bits_per_coded_sample, NULL);
@@ -888,70 +912,84 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
case CODEC_ID_CYUV:
caps =
- gst_ff_vid_caps_new (context, codec_id, "video/x-compressed-yuv",
- NULL);
+ gst_ff_vid_caps_new (context, codec_id, encode,
+ "video/x-compressed-yuv", NULL);
break;
case CODEC_ID_H264:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-h264", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-h264",
+ "alignment", G_TYPE_STRING, "au", NULL);
break;
case CODEC_ID_INDEO5:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-indeo",
"indeoversion", G_TYPE_INT, 5, NULL);
break;
case CODEC_ID_INDEO4:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-indeo",
"indeoversion", G_TYPE_INT, 4, NULL);
break;
case CODEC_ID_INDEO3:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-indeo",
"indeoversion", G_TYPE_INT, 3, NULL);
break;
case CODEC_ID_INDEO2:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-indeo",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-indeo",
"indeoversion", G_TYPE_INT, 2, NULL);
break;
case CODEC_ID_FLASHSV:
caps =
- gst_ff_vid_caps_new (context, codec_id, "video/x-flash-screen", NULL);
+ gst_ff_vid_caps_new (context, codec_id, encode,
+ "video/x-flash-screen", NULL);
break;
case CODEC_ID_VP3:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp3", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-vp3", NULL);
break;
case CODEC_ID_VP5:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp5", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-vp5", NULL);
break;
case CODEC_ID_VP6:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-vp6", NULL);
break;
case CODEC_ID_VP6F:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-flash", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-vp6-flash",
+ NULL);
break;
case CODEC_ID_VP6A:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp6-alpha", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-vp6-alpha",
+ NULL);
break;
case CODEC_ID_VP8:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vp8", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-vp8", NULL);
break;
case CODEC_ID_THEORA:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-theora", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-theora",
+ NULL);
break;
case CODEC_ID_AAC:
{
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/mpeg", NULL);
if (!encode) {
GValue arr = { 0, };
@@ -993,43 +1031,46 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
}
case CODEC_ID_AAC_LATM: /* LATM/LOAS AAC syntax */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/mpeg",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/mpeg",
"mpegversion", G_TYPE_INT, 4, "stream-format", G_TYPE_STRING, "loas",
NULL);
break;
case CODEC_ID_ASV1:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-asus",
"asusversion", G_TYPE_INT, 1, NULL);
break;
case CODEC_ID_ASV2:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-asus",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-asus",
"asusversion", G_TYPE_INT, 2, NULL);
break;
case CODEC_ID_FFV1:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ffv",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-ffv",
"ffvversion", G_TYPE_INT, 1, NULL);
break;
case CODEC_ID_4XM:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-4xm", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-4xm", NULL);
break;
case CODEC_ID_XAN_WC3:
case CODEC_ID_XAN_WC4:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-xan",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-xan",
"wcversion", G_TYPE_INT, 3 - CODEC_ID_XAN_WC3 + codec_id, NULL);
break;
case CODEC_ID_CLJR:
caps =
- gst_ff_vid_caps_new (context, codec_id,
+ gst_ff_vid_caps_new (context, codec_id, encode,
"video/x-cirrus-logic-accupak", NULL);
break;
case CODEC_ID_FRAPS:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-fraps", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-fraps",
+ NULL);
break;
case CODEC_ID_MDEC:
@@ -1039,23 +1080,26 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_VCR1:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ati-vcr",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-ati-vcr",
"vcrversion", G_TYPE_INT, 1, NULL);
break;
case CODEC_ID_RPZA:
caps =
- gst_ff_vid_caps_new (context, codec_id, "video/x-apple-video", NULL);
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-apple-video",
+ NULL);
break;
case CODEC_ID_CINEPAK:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-cinepak", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-cinepak",
+ NULL);
break;
/* WS_VQA belogns here (order) */
case CODEC_ID_MSRLE:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-rle",
"layout", G_TYPE_STRING, "microsoft", NULL);
if (context) {
gst_caps_set_simple (caps,
@@ -1066,7 +1110,7 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_QTRLE:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-rle",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-rle",
"layout", G_TYPE_STRING, "quicktime", NULL);
if (context) {
gst_caps_set_simple (caps,
@@ -1077,46 +1121,55 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_MSVIDEO1:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-msvideocodec",
- "msvideoversion", G_TYPE_INT, 1, NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode,
+ "video/x-msvideocodec", "msvideoversion", G_TYPE_INT, 1, NULL);
break;
case CODEC_ID_WMV3:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-wmv",
"wmvversion", G_TYPE_INT, 3, NULL);
break;
case CODEC_ID_VC1:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv",
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "video/x-wmv",
"wmvversion", G_TYPE_INT, 3, "format", G_TYPE_STRING, "WVC1", NULL);
break;
case CODEC_ID_QDM2:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-qdm2", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-qdm2", NULL);
break;
case CODEC_ID_MSZH:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mszh", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-mszh", NULL);
break;
case CODEC_ID_ZLIB:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zlib", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-zlib", NULL);
break;
case CODEC_ID_TRUEMOTION1:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-truemotion",
"trueversion", G_TYPE_INT, 1, NULL);
break;
case CODEC_ID_TRUEMOTION2:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-truemotion",
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-truemotion",
"trueversion", G_TYPE_INT, 2, NULL);
break;
case CODEC_ID_ULTI:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-ultimotion",
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-ultimotion",
NULL);
break;
case CODEC_ID_TSCC:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camtasia", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-camtasia",
+ NULL);
if (context) {
gst_caps_set_simple (caps,
"depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
@@ -1126,113 +1179,137 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_KMVC:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-kmvc", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-kmvc", NULL);
break;
case CODEC_ID_NUV:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-nuv", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-nuv", NULL);
break;
case CODEC_ID_GIF:
- caps = gst_ff_vid_caps_new (context, codec_id, "image/gif", NULL);
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "image/gif", NULL);
break;
case CODEC_ID_PNG:
- caps = gst_ff_vid_caps_new (context, codec_id, "image/png", NULL);
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "image/png", NULL);
break;
case CODEC_ID_PPM:
- caps = gst_ff_vid_caps_new (context, codec_id, "image/ppm", NULL);
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "image/ppm", NULL);
break;
case CODEC_ID_PBM:
- caps = gst_ff_vid_caps_new (context, codec_id, "image/pbm", NULL);
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, "image/pbm", NULL);
break;
case CODEC_ID_PAM:
caps =
- gst_ff_vid_caps_new (context, codec_id, "image/x-portable-anymap",
- NULL);
+ gst_ff_vid_caps_new (context, codec_id, encode,
+ "image/x-portable-anymap", NULL);
break;
case CODEC_ID_PGM:
caps =
- gst_ff_vid_caps_new (context, codec_id, "image/x-portable-graymap",
- NULL);
+ gst_ff_vid_caps_new (context, codec_id, encode,
+ "image/x-portable-graymap", NULL);
break;
case CODEC_ID_PCX:
- caps = gst_ff_vid_caps_new (context, codec_id, "image/x-pcx", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "image/x-pcx", NULL);
break;
case CODEC_ID_SGI:
- caps = gst_ff_vid_caps_new (context, codec_id, "image/x-sgi", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "image/x-sgi", NULL);
break;
case CODEC_ID_TARGA:
- caps = gst_ff_vid_caps_new (context, codec_id, "image/x-tga", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "image/x-tga", NULL);
break;
case CODEC_ID_TIFF:
- caps = gst_ff_vid_caps_new (context, codec_id, "image/tiff", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "image/tiff", NULL);
break;
case CODEC_ID_SUNRAST:
caps =
- gst_ff_vid_caps_new (context, codec_id, "image/x-sun-raster", NULL);
+ gst_ff_vid_caps_new (context, codec_id, encode, "image/x-sun-raster",
+ NULL);
break;
case CODEC_ID_SMC:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-smc", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-smc", NULL);
break;
case CODEC_ID_QDRAW:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-qdrw", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-qdrw", NULL);
break;
case CODEC_ID_DNXHD:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-dnxhd", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-dnxhd",
+ NULL);
break;
case CODEC_ID_MIMIC:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-mimic", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-mimic",
+ NULL);
break;
case CODEC_ID_VMNC:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-vmnc", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-vmnc", NULL);
break;
case CODEC_ID_TRUESPEECH:
caps =
- gst_ff_aud_caps_new (context, codec_id, "audio/x-truespeech", NULL);
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-truespeech",
+ NULL);
break;
case CODEC_ID_QCELP:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/qcelp", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/qcelp", NULL);
break;
case CODEC_ID_AMV:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-amv", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-amv", NULL);
break;
case CODEC_ID_AASC:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-aasc", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-aasc", NULL);
break;
case CODEC_ID_LOCO:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-loco", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-loco", NULL);
break;
case CODEC_ID_ZMBV:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-zmbv", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-zmbv", NULL);
break;
case CODEC_ID_LAGARITH:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-lagarith", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-lagarith",
+ NULL);
break;
case CODEC_ID_CSCD:
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-camstudio", NULL);
+ caps =
+ gst_ff_vid_caps_new (context, codec_id, encode, "video/x-camstudio",
+ NULL);
if (context) {
gst_caps_set_simple (caps,
"depth", G_TYPE_INT, (gint) context->bits_per_coded_sample, NULL);
@@ -1298,22 +1375,26 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
}
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-raw",
"format", G_TYPE_STRING, gst_audio_format_to_string (format),
"layout", G_TYPE_STRING, "interleaved", NULL);
}
break;
case CODEC_ID_PCM_MULAW:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-mulaw", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-mulaw",
+ NULL);
break;
case CODEC_ID_PCM_ALAW:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alaw", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-alaw", NULL);
break;
case CODEC_ID_ADPCM_G722:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/G722", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/G722", NULL);
if (context)
gst_caps_set_simple (caps,
"block_align", G_TYPE_INT, context->block_align,
@@ -1323,7 +1404,7 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
case CODEC_ID_ADPCM_G726:
{
/* the G726 decoder can also handle G721 */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-adpcm",
"layout", G_TYPE_STRING, "g726", NULL);
if (context)
gst_caps_set_simple (caps,
@@ -1456,7 +1537,7 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
/* FIXME: someone please check whether we need additional properties
* in this caps definition. */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-adpcm",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-adpcm",
"layout", G_TYPE_STRING, layout, NULL);
if (context)
gst_caps_set_simple (caps,
@@ -1466,29 +1547,35 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_AMR_NB:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR", NULL);
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/AMR", NULL);
break;
case CODEC_ID_AMR_WB:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/AMR-WB", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/AMR-WB", NULL);
break;
case CODEC_ID_GSM:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-gsm", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-gsm", NULL);
break;
case CODEC_ID_GSM_MS:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/ms-gsm", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/ms-gsm", NULL);
break;
case CODEC_ID_NELLYMOSER:
caps =
- gst_ff_aud_caps_new (context, codec_id, "audio/x-nellymoser", NULL);
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-nellymoser",
+ NULL);
break;
case CODEC_ID_SIPR:
{
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-sipro", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-sipro",
+ NULL);
if (context) {
gst_caps_set_simple (caps,
"leaf_size", G_TYPE_INT, context->block_align,
@@ -1518,8 +1605,9 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
}
/* FIXME: properties? */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-pn-realaudio",
- "raversion", G_TYPE_INT, version, NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode,
+ "audio/x-pn-realaudio", "raversion", G_TYPE_INT, version, NULL);
if (context) {
gst_caps_set_simple (caps,
"leaf_size", G_TYPE_INT, context->block_align,
@@ -1555,7 +1643,7 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
/* FIXME: someone please check whether we need additional properties
* in this caps definition. */
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-dpcm",
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-dpcm",
"layout", G_TYPE_STRING, layout, NULL);
if (context)
gst_caps_set_simple (caps,
@@ -1569,7 +1657,8 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_ALAC:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-alac", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-alac", NULL);
if (context) {
gst_caps_set_simple (caps,
"samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
@@ -1592,14 +1681,17 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
caps = gst_caps_new_empty_simple ("image/bmp");
break;
case CODEC_ID_TTA:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-tta", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-tta", NULL);
if (context) {
gst_caps_set_simple (caps,
"samplesize", G_TYPE_INT, context->bits_per_coded_sample, NULL);
}
break;
case CODEC_ID_TWINVQ:
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-twin-vq", NULL);
+ caps =
+ gst_ff_aud_caps_new (context, codec_id, encode, "audio/x-twin-vq",
+ NULL);
break;
default:
GST_DEBUG ("Unknown codec ID %d, please add mapping here", codec_id);
@@ -1617,13 +1709,13 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
switch (codec->type) {
case AVMEDIA_TYPE_VIDEO:
- mime = g_strdup_printf ("video/x-gst_ff-%s", codec->name);
- caps = gst_ff_vid_caps_new (context, codec_id, mime, NULL);
+ mime = g_strdup_printf ("video/x-gst-av-%s", codec->name);
+ caps = gst_ff_vid_caps_new (context, codec_id, encode, mime, NULL);
g_free (mime);
break;
case AVMEDIA_TYPE_AUDIO:
- mime = g_strdup_printf ("audio/x-gst_ff-%s", codec->name);
- caps = gst_ff_aud_caps_new (context, codec_id, mime, NULL);
+ mime = g_strdup_printf ("audio/x-gst-av-%s", codec->name);
+ caps = gst_ff_aud_caps_new (context, codec_id, encode, mime, NULL);
if (context)
gst_caps_set_simple (caps,
"block_align", G_TYPE_INT, context->block_align,
@@ -1748,7 +1840,7 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context,
format = gst_ffmpeg_pixfmt_to_video_format (pix_fmt);
if (format != GST_VIDEO_FORMAT_UNKNOWN) {
- caps = gst_ff_vid_caps_new (context, codec_id, "video/x-raw",
+ caps = gst_ff_vid_caps_new (context, codec_id, TRUE, "video/x-raw",
"format", G_TYPE_STRING, gst_video_format_to_string (format), NULL);
}
@@ -1795,7 +1887,7 @@ gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
}
if (format != GST_AUDIO_FORMAT_UNKNOWN) {
- caps = gst_ff_aud_caps_new (context, codec_id, "audio/x-raw",
+ caps = gst_ff_aud_caps_new (context, codec_id, TRUE, "audio/x-raw",
"format", G_TYPE_STRING, gst_audio_format_to_string (format),
"layout", G_TYPE_STRING, "interleaved", NULL);
GST_LOG ("caps for sample_fmt=%d: %" GST_PTR_FORMAT, sample_fmt, caps);
@@ -2075,6 +2167,128 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps,
}
}
+typedef struct
+{
+ GstVideoFormat format;
+ enum PixelFormat pixfmt;
+} PixToFmt;
+
+/* FIXME : FILLME */
+static const PixToFmt pixtofmttable[] = {
+ /* GST_VIDEO_FORMAT_I420, */
+ {GST_VIDEO_FORMAT_I420, PIX_FMT_YUV420P},
+ /* Note : this should use a different chroma placement */
+ {GST_VIDEO_FORMAT_I420, PIX_FMT_YUVJ420P},
+
+ /* GST_VIDEO_FORMAT_YV12, */
+ /* GST_VIDEO_FORMAT_YUY2, */
+ {GST_VIDEO_FORMAT_YUY2, PIX_FMT_YUYV422},
+ /* GST_VIDEO_FORMAT_UYVY, */
+ {GST_VIDEO_FORMAT_UYVY, PIX_FMT_UYVY422},
+ /* GST_VIDEO_FORMAT_AYUV, */
+ /* GST_VIDEO_FORMAT_RGBx, */
+ /* GST_VIDEO_FORMAT_BGRx, */
+ /* GST_VIDEO_FORMAT_xRGB, */
+ /* GST_VIDEO_FORMAT_xBGR, */
+ /* GST_VIDEO_FORMAT_RGBA, */
+ {GST_VIDEO_FORMAT_RGBA, PIX_FMT_RGB32},
+ /* GST_VIDEO_FORMAT_BGRA, */
+ {GST_VIDEO_FORMAT_BGRA, PIX_FMT_BGR32},
+ /* GST_VIDEO_FORMAT_ARGB, */
+ /* GST_VIDEO_FORMAT_ABGR, */
+ /* GST_VIDEO_FORMAT_RGB, */
+ {GST_VIDEO_FORMAT_RGB, PIX_FMT_RGB24},
+ /* GST_VIDEO_FORMAT_BGR, */
+ {GST_VIDEO_FORMAT_BGR, PIX_FMT_BGR24},
+ /* GST_VIDEO_FORMAT_Y41B, */
+ {GST_VIDEO_FORMAT_Y41B, PIX_FMT_YUV410P},
+ /* GST_VIDEO_FORMAT_Y42B, */
+ {GST_VIDEO_FORMAT_Y42B, PIX_FMT_YUV422P},
+ {GST_VIDEO_FORMAT_Y42B, PIX_FMT_YUVJ422P},
+ /* GST_VIDEO_FORMAT_YVYU, */
+ /* GST_VIDEO_FORMAT_Y444, */
+ {GST_VIDEO_FORMAT_Y444, PIX_FMT_YUV444P},
+ {GST_VIDEO_FORMAT_Y444, PIX_FMT_YUVJ444P},
+ /* GST_VIDEO_FORMAT_v210, */
+ /* GST_VIDEO_FORMAT_v216, */
+ /* GST_VIDEO_FORMAT_NV12, */
+ {GST_VIDEO_FORMAT_NV12, PIX_FMT_NV12},
+ /* GST_VIDEO_FORMAT_NV21, */
+ {GST_VIDEO_FORMAT_NV21, PIX_FMT_NV21},
+ /* GST_VIDEO_FORMAT_GRAY8, */
+ {GST_VIDEO_FORMAT_GRAY8, PIX_FMT_GRAY8},
+ /* GST_VIDEO_FORMAT_GRAY16_BE, */
+ {GST_VIDEO_FORMAT_GRAY16_BE, PIX_FMT_GRAY16BE},
+ /* GST_VIDEO_FORMAT_GRAY16_LE, */
+ {GST_VIDEO_FORMAT_GRAY16_LE, PIX_FMT_GRAY16LE},
+ /* GST_VIDEO_FORMAT_v308, */
+ /* GST_VIDEO_FORMAT_Y800, */
+ /* GST_VIDEO_FORMAT_Y16, */
+ /* GST_VIDEO_FORMAT_RGB16, */
+ {GST_VIDEO_FORMAT_RGB16, PIX_FMT_RGB565},
+ /* GST_VIDEO_FORMAT_BGR16, */
+ /* GST_VIDEO_FORMAT_RGB15, */
+ {GST_VIDEO_FORMAT_RGB15, PIX_FMT_RGB555},
+ /* GST_VIDEO_FORMAT_BGR15, */
+ /* GST_VIDEO_FORMAT_UYVP, */
+ /* GST_VIDEO_FORMAT_A420, */
+ {GST_VIDEO_FORMAT_A420, PIX_FMT_YUVA420P},
+ /* GST_VIDEO_FORMAT_RGB8_PALETTED, */
+ {GST_VIDEO_FORMAT_RGB8P, PIX_FMT_PAL8},
+ /* GST_VIDEO_FORMAT_YUV9, */
+ /* GST_VIDEO_FORMAT_YVU9, */
+ /* GST_VIDEO_FORMAT_IYU1, */
+ /* GST_VIDEO_FORMAT_ARGB64, */
+ /* GST_VIDEO_FORMAT_AYUV64, */
+ /* GST_VIDEO_FORMAT_r210, */
+};
+
+GstVideoFormat
+gst_ffmpeg_pixfmt_to_videoformat (enum PixelFormat pixfmt)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (pixtofmttable); i++)
+ if (pixtofmttable[i].pixfmt == pixfmt)
+ return pixtofmttable[i].format;
+
+ GST_WARNING ("Unknown pixel format %d", pixfmt);
+ return GST_VIDEO_FORMAT_UNKNOWN;
+}
+
+enum PixelFormat
+gst_ffmpeg_videoformat_to_pixfmt (GstVideoFormat format)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (pixtofmttable); i++)
+ if (pixtofmttable[i].format == format)
+ return pixtofmttable[i].pixfmt;
+ return PIX_FMT_NONE;
+}
+
+void
+gst_ffmpeg_videoinfo_to_context (GstVideoInfo * info, AVCodecContext * context)
+{
+ gint i, bpp = 0;
+
+ context->width = GST_VIDEO_INFO_WIDTH (info);
+ context->height = GST_VIDEO_INFO_HEIGHT (info);
+ for (i = 0; i < GST_VIDEO_INFO_N_COMPONENTS (info); i++)
+ bpp += GST_VIDEO_INFO_COMP_DEPTH (info, i);
+ context->bits_per_coded_sample = bpp;
+
+ context->ticks_per_frame = 1;
+ context->time_base.den = GST_VIDEO_INFO_FPS_N (info);
+ context->time_base.num = GST_VIDEO_INFO_FPS_D (info);
+
+ context->sample_aspect_ratio.num = GST_VIDEO_INFO_PAR_N (info);
+ context->sample_aspect_ratio.den = GST_VIDEO_INFO_PAR_D (info);
+
+ context->pix_fmt =
+ gst_ffmpeg_videoformat_to_pixfmt (GST_VIDEO_INFO_FORMAT (info));
+}
+
/* Convert a GstCaps and a FFMPEG codec Type to a
* AVCodecContext. If the context is ommitted, no fixed values
* for video/audio size will be included in the context
@@ -2557,7 +2771,7 @@ gst_ffmpeg_formatid_to_caps (const gchar * format_name)
gchar *name;
GST_LOG ("Could not create stream format caps for %s", format_name);
- name = g_strdup_printf ("application/x-gst_ff-%s", format_name);
+ name = g_strdup_printf ("application/x-gst-av-%s", format_name);
caps = gst_caps_new_empty_simple (name);
g_free (name);
}
@@ -3254,24 +3468,24 @@ gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context)
} else if (!strcmp (mimetype, "audio/x-nellymoser")) {
id = CODEC_ID_NELLYMOSER;
audio = TRUE;
- } else if (!strncmp (mimetype, "audio/x-gst_ff-", 15)) {
+ } else if (!strncmp (mimetype, "audio/x-gst-av-", 15)) {
gchar ext[16];
AVCodec *codec;
if (strlen (mimetype) <= 30 &&
- sscanf (mimetype, "audio/x-gst_ff-%s", ext) == 1) {
+ sscanf (mimetype, "audio/x-gst-av-%s", ext) == 1) {
if ((codec = avcodec_find_decoder_by_name (ext)) ||
(codec = avcodec_find_encoder_by_name (ext))) {
id = codec->id;
audio = TRUE;
}
}
- } else if (!strncmp (mimetype, "video/x-gst_ff-", 15)) {
+ } else if (!strncmp (mimetype, "video/x-gst-av-", 15)) {
gchar ext[16];
AVCodec *codec;
if (strlen (mimetype) <= 30 &&
- sscanf (mimetype, "video/x-gst_ff-%s", ext) == 1) {
+ sscanf (mimetype, "video/x-gst-av-%s", ext) == 1) {
if ((codec = avcodec_find_decoder_by_name (ext)) ||
(codec = avcodec_find_encoder_by_name (ext))) {
id = codec->id;
diff --git a/ext/ffmpeg/gstffmpegcodecmap.h b/ext/ffmpeg/gstffmpegcodecmap.h
index 2c49afa..2039631 100644
--- a/ext/ffmpeg/gstffmpegcodecmap.h
+++ b/ext/ffmpeg/gstffmpegcodecmap.h
@@ -91,6 +91,13 @@ gst_ffmpeg_caps_with_codectype (enum AVMediaType type,
const GstCaps *caps,
AVCodecContext *context);
+void
+gst_ffmpeg_videoinfo_to_context (GstVideoInfo *info,
+ AVCodecContext *context);
+
+GstVideoFormat gst_ffmpeg_pixfmt_to_videoformat (enum PixelFormat pixfmt);
+enum PixelFormat gst_ffmpeg_videoformat_to_pixfmt (GstVideoFormat format);
+
/*
* _formatid_to_caps () is meant for muxers/demuxers, it
* transforms a name (ffmpeg way of ID'ing these, why don't
diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c
index a15507b..c9c8281 100644
--- a/ext/ffmpeg/gstffmpegdec.c
+++ b/ext/ffmpeg/gstffmpegdec.c
@@ -31,9 +31,6 @@
#endif
#include <gst/gst.h>
-#include <gst/video/video.h>
-#include <gst/video/gstvideometa.h>
-#include <gst/video/gstvideopool.h>
#include "gstffmpeg.h"
#include "gstffmpegcodecmap.h"
@@ -41,7 +38,7 @@
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
-typedef struct _GstFFMpegDec GstFFMpegDec;
+typedef struct _GstFFMpegAudDec GstFFMpegAudDec;
#define MAX_TS_MASK 0xff
@@ -58,7 +55,7 @@ typedef struct
gint64 offset;
} GstTSInfo;
-struct _GstFFMpegDec
+struct _GstFFMpegAudDec
{
GstElement element;
@@ -68,55 +65,16 @@ struct _GstFFMpegDec
/* decoding */
AVCodecContext *context;
- AVFrame *picture;
gboolean opened;
- GstBufferPool *pool;
-
- /* from incoming caps */
- gint in_width;
- gint in_height;
- gint in_par_n;
- gint in_par_d;
- gint in_fps_n;
- gint in_fps_d;
-
- /* current context */
- enum PixelFormat ctx_pix_fmt;
- gint ctx_width;
- gint ctx_height;
- gint ctx_par_n;
- gint ctx_par_d;
- gint ctx_ticks;
- gint ctx_time_d;
- gint ctx_time_n;
- gint ctx_interlaced;
/* current output format */
- GstVideoInfo out_info;
+ gint channels, samplerate, depth;
+ GstAudioChannelPosition ffmpeg_layout[64], gst_layout[64];
- union
- {
- struct
- {
- gint channels;
- gint samplerate;
- gint depth;
-
- GstAudioChannelPosition ffmpeg_layout[64], gst_layout[64];
- } audio;
- } format;
-
-
- gboolean waiting_for_key;
gboolean discont;
gboolean clear_ts;
/* for tracking DTS/PTS */
- gboolean has_b_frames;
- GstClockTime last_dts;
- GstClockTime last_diff;
- guint last_frames;
- GstClockTime last_out;
GstClockTime next_out;
/* parsing */
@@ -124,29 +82,10 @@ struct _GstFFMpegDec
* See bug #566250 */
AVCodecParserContext *pctx;
GstBuffer *pcache;
- guint8 *padded;
- guint padded_size;
-
- gboolean current_dr; /* if direct rendering is enabled */
-
- /* some properties */
- enum AVDiscard skip_frame;
- gint lowres;
- gboolean direct_rendering;
- gboolean debug_mv;
- int max_threads;
-
- /* QoS stuff *//* with LOCK */
- gdouble proportion;
- GstClockTime earliest_time;
- gint64 processed;
- gint64 dropped;
/* clipping segment */
GstSegment segment;
- gboolean is_realvideo;
-
GstTSInfo ts_info[MAX_TS_MASK + 1];
gint ts_idx;
@@ -157,9 +96,9 @@ struct _GstFFMpegDec
GstCaps *last_caps;
};
-typedef struct _GstFFMpegDecClass GstFFMpegDecClass;
+typedef struct _GstFFMpegAudDecClass GstFFMpegAudDecClass;
-struct _GstFFMpegDecClass
+struct _GstFFMpegAudDecClass
{
GstElementClass parent_class;
@@ -171,7 +110,7 @@ struct _GstFFMpegDecClass
static const GstTSInfo ts_info_none = { -1, -1, -1, -1 };
static const GstTSInfo *
-gst_ts_info_store (GstFFMpegDec * dec, GstClockTime dts, GstClockTime pts,
+gst_ts_info_store (GstFFMpegAudDec * dec, GstClockTime dts, GstClockTime pts,
GstClockTime duration, gint64 offset)
{
gint idx = dec->ts_idx;
@@ -186,7 +125,7 @@ gst_ts_info_store (GstFFMpegDec * dec, GstClockTime dts, GstClockTime pts,
}
static const GstTSInfo *
-gst_ts_info_get (GstFFMpegDec * dec, gint idx)
+gst_ts_info_get (GstFFMpegAudDec * dec, gint idx)
{
if (G_UNLIKELY (idx < 0 || idx > MAX_TS_MASK))
return GST_TS_INFO_NONE;
@@ -195,127 +134,51 @@ gst_ts_info_get (GstFFMpegDec * dec, gint idx)
}
#define GST_TYPE_FFMPEGDEC \
- (gst_ffmpegdec_get_type())
+ (gst_ffmpegauddec_get_type())
#define GST_FFMPEGDEC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegDec))
-#define GST_FFMPEGDEC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegDecClass))
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegAudDec))
+#define GST_FFMPEGAUDDEC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegAudDecClass))
#define GST_IS_FFMPEGDEC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
-#define GST_IS_FFMPEGDEC_CLASS(klass) \
+#define GST_IS_FFMPEGAUDDEC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
-#define DEFAULT_LOWRES 0
-#define DEFAULT_SKIPFRAME 0
-#define DEFAULT_DIRECT_RENDERING TRUE
-#define DEFAULT_DEBUG_MV FALSE
-#define DEFAULT_MAX_THREADS 1
-
-enum
-{
- PROP_0,
- PROP_LOWRES,
- PROP_SKIPFRAME,
- PROP_DIRECT_RENDERING,
- PROP_DEBUG_MV,
- PROP_MAX_THREADS,
- PROP_LAST
-};
-
/* A number of function prototypes are given so we can refer to them later. */
-static void gst_ffmpegdec_base_init (GstFFMpegDecClass * klass);
-static void gst_ffmpegdec_class_init (GstFFMpegDecClass * klass);
-static void gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec);
-static void gst_ffmpegdec_finalize (GObject * object);
-
-static gboolean gst_ffmpegdec_src_query (GstPad * pad, GstObject * parent,
- GstQuery * query);
-static gboolean gst_ffmpegdec_src_event (GstPad * pad, GstObject * parent,
+static void gst_ffmpegauddec_base_init (GstFFMpegAudDecClass * klass);
+static void gst_ffmpegauddec_class_init (GstFFMpegAudDecClass * klass);
+static void gst_ffmpegauddec_init (GstFFMpegAudDec * ffmpegdec);
+static void gst_ffmpegauddec_finalize (GObject * object);
+
+static gboolean gst_ffmpegauddec_setcaps (GstFFMpegAudDec * ffmpegdec,
+ GstCaps * caps);
+static gboolean gst_ffmpegauddec_sink_event (GstPad * pad, GstObject * parent,
GstEvent * event);
-
-static gboolean gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent,
- GstEvent * event);
-static gboolean gst_ffmpegdec_sink_query (GstPad * pad, GstObject * parent,
+static gboolean gst_ffmpegauddec_sink_query (GstPad * pad, GstObject * parent,
GstQuery * query);
-static GstFlowReturn gst_ffmpegdec_chain (GstPad * pad, GstObject * parent,
+static GstFlowReturn gst_ffmpegauddec_chain (GstPad * pad, GstObject * parent,
GstBuffer * buf);
-static GstStateChangeReturn gst_ffmpegdec_change_state (GstElement * element,
+static GstStateChangeReturn gst_ffmpegauddec_change_state (GstElement * element,
GstStateChange transition);
-static void gst_ffmpegdec_set_property (GObject * object,
- guint prop_id, const GValue * value, GParamSpec * pspec);
-static void gst_ffmpegdec_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * pspec);
-
-static gboolean gst_ffmpegdec_video_negotiate (GstFFMpegDec * ffmpegdec,
- gboolean force);
-static gboolean gst_ffmpegdec_audio_negotiate (GstFFMpegDec * ffmpegdec,
+static gboolean gst_ffmpegauddec_negotiate (GstFFMpegAudDec * ffmpegdec,
gboolean force);
-/* some sort of bufferpool handling, but different */
-static int gst_ffmpegdec_get_buffer (AVCodecContext * context,
- AVFrame * picture);
-static void gst_ffmpegdec_release_buffer (AVCodecContext * context,
- AVFrame * picture);
-
-static void gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec);
+static void gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec);
#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("avdec-params")
static GstElementClass *parent_class = NULL;
-#define GST_FFMPEGDEC_TYPE_LOWRES (gst_ffmpegdec_lowres_get_type())
-static GType
-gst_ffmpegdec_lowres_get_type (void)
-{
- static GType ffmpegdec_lowres_type = 0;
-
- if (!ffmpegdec_lowres_type) {
- static const GEnumValue ffmpegdec_lowres[] = {
- {0, "0", "full"},
- {1, "1", "1/2-size"},
- {2, "2", "1/4-size"},
- {0, NULL, NULL},
- };
-
- ffmpegdec_lowres_type =
- g_enum_register_static ("GstLibAVDecLowres", ffmpegdec_lowres);
- }
-
- return ffmpegdec_lowres_type;
-}
-
-#define GST_FFMPEGDEC_TYPE_SKIPFRAME (gst_ffmpegdec_skipframe_get_type())
-static GType
-gst_ffmpegdec_skipframe_get_type (void)
-{
- static GType ffmpegdec_skipframe_type = 0;
-
- if (!ffmpegdec_skipframe_type) {
- static const GEnumValue ffmpegdec_skipframe[] = {
- {0, "0", "Skip nothing"},
- {1, "1", "Skip B-frames"},
- {2, "2", "Skip IDCT/Dequantization"},
- {5, "5", "Skip everything"},
- {0, NULL, NULL},
- };
-
- ffmpegdec_skipframe_type =
- g_enum_register_static ("GstLibAVDecSkipFrame", ffmpegdec_skipframe);
- }
-
- return ffmpegdec_skipframe_type;
-}
-
static void
-gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
+gst_ffmpegauddec_base_init (GstFFMpegAudDecClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstPadTemplate *sinktempl, *srctempl;
GstCaps *sinkcaps, *srccaps;
AVCodec *in_plugin;
- gchar *longname, *classification, *description;
+ gchar *longname, *description;
in_plugin =
(AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
@@ -324,16 +187,13 @@ gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
/* construct the element details struct */
longname = g_strdup_printf ("libav %s decoder", in_plugin->long_name);
- classification = g_strdup_printf ("Codec/Decoder/%s",
- (in_plugin->type == AVMEDIA_TYPE_VIDEO) ? "Video" : "Audio");
description = g_strdup_printf ("libav %s decoder", in_plugin->name);
gst_element_class_set_metadata (element_class, longname,
- classification, description,
+ "Codec/Decoder/Audio", description,
"Wim Taymans <wim.taymans@gmail.com>, "
"Ronald Bultje <rbultje@ronald.bitfreak.net>, "
"Edward Hervey <bilboed@bilboed.com>");
g_free (longname);
- g_free (classification);
g_free (description);
/* get the caps */
@@ -342,12 +202,8 @@ gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
sinkcaps = gst_caps_from_string ("unknown/unknown");
}
- if (in_plugin->type == AVMEDIA_TYPE_VIDEO) {
- srccaps = gst_caps_from_string ("video/x-raw");
- } else {
- srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
- in_plugin->id, FALSE, in_plugin);
- }
+ srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
+ in_plugin->id, FALSE, in_plugin);
if (!srccaps) {
GST_DEBUG ("Couldn't get source caps for decoder '%s'", in_plugin->name);
srccaps = gst_caps_from_string ("unknown/unknown");
@@ -367,237 +223,73 @@ gst_ffmpegdec_base_init (GstFFMpegDecClass * klass)
}
static void
-gst_ffmpegdec_class_init (GstFFMpegDecClass * klass)
+gst_ffmpegauddec_class_init (GstFFMpegAudDecClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
- gobject_class->finalize = gst_ffmpegdec_finalize;
-
- gobject_class->set_property = gst_ffmpegdec_set_property;
- gobject_class->get_property = gst_ffmpegdec_get_property;
-
- if (klass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
- int caps;
-
- g_object_class_install_property (gobject_class, PROP_SKIPFRAME,
- g_param_spec_enum ("skip-frame", "Skip frames",
- "Which types of frames to skip during decoding",
- GST_FFMPEGDEC_TYPE_SKIPFRAME, 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_LOWRES,
- g_param_spec_enum ("lowres", "Low resolution",
- "At which resolution to decode images", GST_FFMPEGDEC_TYPE_LOWRES,
- 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_DIRECT_RENDERING,
- g_param_spec_boolean ("direct-rendering", "Direct Rendering",
- "Enable direct rendering", DEFAULT_DIRECT_RENDERING,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_DEBUG_MV,
- g_param_spec_boolean ("debug-mv", "Debug motion vectors",
- "Whether ffmpeg should print motion vectors on top of the image",
- DEFAULT_DEBUG_MV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- caps = klass->in_plugin->capabilities;
- if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) {
- g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS,
- g_param_spec_int ("max-threads", "Maximum decode threads",
- "Maximum number of worker threads to spawn. (0 = auto)",
- 0, G_MAXINT, DEFAULT_MAX_THREADS,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
- }
+ gobject_class->finalize = gst_ffmpegauddec_finalize;
- gstelement_class->change_state = gst_ffmpegdec_change_state;
+ gstelement_class->change_state = gst_ffmpegauddec_change_state;
}
static void
-gst_ffmpegdec_init (GstFFMpegDec * ffmpegdec)
+gst_ffmpegauddec_init (GstFFMpegAudDec * ffmpegdec)
{
- GstFFMpegDecClass *oclass;
+ GstFFMpegAudDecClass *oclass;
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+ oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
/* setup pads */
ffmpegdec->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
- gst_pad_set_event_function (ffmpegdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_event));
gst_pad_set_query_function (ffmpegdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_ffmpegdec_sink_query));
+ GST_DEBUG_FUNCPTR (gst_ffmpegauddec_sink_query));
+ gst_pad_set_event_function (ffmpegdec->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_ffmpegauddec_sink_event));
gst_pad_set_chain_function (ffmpegdec->sinkpad,
- GST_DEBUG_FUNCPTR (gst_ffmpegdec_chain));
+ GST_DEBUG_FUNCPTR (gst_ffmpegauddec_chain));
gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->sinkpad);
ffmpegdec->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
gst_pad_use_fixed_caps (ffmpegdec->srcpad);
- gst_pad_set_event_function (ffmpegdec->srcpad,
- GST_DEBUG_FUNCPTR (gst_ffmpegdec_src_event));
- gst_pad_set_query_function (ffmpegdec->srcpad,
- GST_DEBUG_FUNCPTR (gst_ffmpegdec_src_query));
gst_element_add_pad (GST_ELEMENT (ffmpegdec), ffmpegdec->srcpad);
/* some ffmpeg data */
ffmpegdec->context = avcodec_alloc_context ();
- ffmpegdec->picture = avcodec_alloc_frame ();
ffmpegdec->pctx = NULL;
ffmpegdec->pcache = NULL;
ffmpegdec->opened = FALSE;
- ffmpegdec->waiting_for_key = TRUE;
- ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
- ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
- ffmpegdec->debug_mv = DEFAULT_DEBUG_MV;
- ffmpegdec->max_threads = DEFAULT_MAX_THREADS;
gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
}
static void
-gst_ffmpegdec_finalize (GObject * object)
+gst_ffmpegauddec_finalize (GObject * object)
{
- GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
+ GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) object;
if (ffmpegdec->context != NULL)
av_free (ffmpegdec->context);
- if (ffmpegdec->picture != NULL)
- av_free (ffmpegdec->picture);
-
- if (ffmpegdec->pool)
- gst_object_unref (ffmpegdec->pool);
-
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static gboolean
-gst_ffmpegdec_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
-{
- GstFFMpegDec *ffmpegdec;
- gboolean res = FALSE;
-
- ffmpegdec = (GstFFMpegDec *) parent;
-
- switch (GST_QUERY_TYPE (query)) {
- case GST_QUERY_LATENCY:
- {
- GST_DEBUG_OBJECT (ffmpegdec, "latency query %d",
- ffmpegdec->context->has_b_frames);
- if ((res = gst_pad_peer_query (ffmpegdec->sinkpad, query))) {
- if (ffmpegdec->context->has_b_frames) {
- gboolean live;
- GstClockTime min_lat, max_lat, our_lat;
-
- gst_query_parse_latency (query, &live, &min_lat, &max_lat);
- if (ffmpegdec->out_info.fps_n > 0)
- our_lat =
- gst_util_uint64_scale_int (ffmpegdec->context->has_b_frames *
- GST_SECOND, ffmpegdec->out_info.fps_d,
- ffmpegdec->out_info.fps_n);
- else
- our_lat =
- gst_util_uint64_scale_int (ffmpegdec->context->has_b_frames *
- GST_SECOND, 1, 25);
- if (min_lat != -1)
- min_lat += our_lat;
- if (max_lat != -1)
- max_lat += our_lat;
- gst_query_set_latency (query, live, min_lat, max_lat);
- }
- }
- }
- break;
- default:
- res = gst_pad_query_default (pad, parent, query);
- break;
- }
-
- return res;
-}
-
static void
-gst_ffmpegdec_reset_ts (GstFFMpegDec * ffmpegdec)
+gst_ffmpegauddec_reset_ts (GstFFMpegAudDec * ffmpegdec)
{
- ffmpegdec->last_dts = GST_CLOCK_TIME_NONE;
- ffmpegdec->last_diff = GST_CLOCK_TIME_NONE;
- ffmpegdec->last_frames = 0;
- ffmpegdec->last_out = GST_CLOCK_TIME_NONE;
ffmpegdec->next_out = GST_CLOCK_TIME_NONE;
}
-static void
-gst_ffmpegdec_update_qos (GstFFMpegDec * ffmpegdec, gdouble proportion,
- GstClockTime timestamp)
-{
- GST_LOG_OBJECT (ffmpegdec, "update QOS: %f, %" GST_TIME_FORMAT,
- proportion, GST_TIME_ARGS (timestamp));
-
- GST_OBJECT_LOCK (ffmpegdec);
- ffmpegdec->proportion = proportion;
- ffmpegdec->earliest_time = timestamp;
- GST_OBJECT_UNLOCK (ffmpegdec);
-}
-
-static void
-gst_ffmpegdec_reset_qos (GstFFMpegDec * ffmpegdec)
-{
- gst_ffmpegdec_update_qos (ffmpegdec, 0.5, GST_CLOCK_TIME_NONE);
- ffmpegdec->processed = 0;
- ffmpegdec->dropped = 0;
-}
-
-static void
-gst_ffmpegdec_read_qos (GstFFMpegDec * ffmpegdec, gdouble * proportion,
- GstClockTime * timestamp)
-{
- GST_OBJECT_LOCK (ffmpegdec);
- *proportion = ffmpegdec->proportion;
- *timestamp = ffmpegdec->earliest_time;
- GST_OBJECT_UNLOCK (ffmpegdec);
-}
-
-static gboolean
-gst_ffmpegdec_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
-{
- GstFFMpegDec *ffmpegdec;
- gboolean res;
-
- ffmpegdec = (GstFFMpegDec *) parent;
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_QOS:
- {
- GstQOSType type;
- gdouble proportion;
- GstClockTimeDiff diff;
- GstClockTime timestamp;
-
- gst_event_parse_qos (event, &type, &proportion, &diff, &timestamp);
-
- /* update our QoS values */
- gst_ffmpegdec_update_qos (ffmpegdec, proportion, timestamp + diff);
-
- /* forward upstream */
- res = gst_pad_push_event (ffmpegdec->sinkpad, event);
- break;
- }
- default:
- /* forward upstream */
- res = gst_pad_push_event (ffmpegdec->sinkpad, event);
- break;
- }
-
- return res;
-}
-
/* with LOCK */
static void
-gst_ffmpegdec_close (GstFFMpegDec * ffmpegdec)
+gst_ffmpegauddec_close (GstFFMpegAudDec * ffmpegdec)
{
if (!ffmpegdec->opened)
return;
- GST_LOG_OBJECT (ffmpegdec, "closing ffmpeg codec");
+ GST_LOG_OBJECT (ffmpegdec, "closing libav codec");
gst_caps_replace (&ffmpegdec->last_caps, NULL);
@@ -627,187 +319,82 @@ gst_ffmpegdec_close (GstFFMpegDec * ffmpegdec)
/* with LOCK */
static gboolean
-gst_ffmpegdec_open (GstFFMpegDec * ffmpegdec)
+gst_ffmpegauddec_open (GstFFMpegAudDec * ffmpegdec)
{
- GstFFMpegDecClass *oclass;
+ GstFFMpegAudDecClass *oclass;
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+ oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
if (gst_ffmpeg_avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0)
goto could_not_open;
ffmpegdec->opened = TRUE;
- ffmpegdec->is_realvideo = FALSE;
- GST_LOG_OBJECT (ffmpegdec, "Opened ffmpeg codec %s, id %d",
+ GST_LOG_OBJECT (ffmpegdec, "Opened libav codec %s, id %d",
oclass->in_plugin->name, oclass->in_plugin->id);
- /* open a parser if we can */
- switch (oclass->in_plugin->id) {
- case CODEC_ID_MPEG4:
- case CODEC_ID_MJPEG:
- case CODEC_ID_VC1:
- GST_LOG_OBJECT (ffmpegdec, "not using parser, blacklisted codec");
- ffmpegdec->pctx = NULL;
- break;
- case CODEC_ID_H264:
- /* For H264, only use a parser if there is no context data, if there is,
- * we're talking AVC */
- if (ffmpegdec->context->extradata_size == 0) {
- GST_LOG_OBJECT (ffmpegdec, "H264 with no extradata, creating parser");
- ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
- } else {
- GST_LOG_OBJECT (ffmpegdec,
- "H264 with extradata implies framed data - not using parser");
- ffmpegdec->pctx = NULL;
- }
- break;
- case CODEC_ID_RV10:
- case CODEC_ID_RV30:
- case CODEC_ID_RV20:
- case CODEC_ID_RV40:
- ffmpegdec->is_realvideo = TRUE;
- break;
- default:
- if (!ffmpegdec->turnoff_parser) {
- ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
- if (ffmpegdec->pctx)
- GST_LOG_OBJECT (ffmpegdec, "Using parser %p", ffmpegdec->pctx);
- else
- GST_LOG_OBJECT (ffmpegdec, "No parser for codec");
- } else {
- GST_LOG_OBJECT (ffmpegdec, "Parser deactivated for format");
- }
- break;
+ if (!ffmpegdec->turnoff_parser) {
+ ffmpegdec->pctx = av_parser_init (oclass->in_plugin->id);
+ if (ffmpegdec->pctx)
+ GST_LOG_OBJECT (ffmpegdec, "Using parser %p", ffmpegdec->pctx);
+ else
+ GST_LOG_OBJECT (ffmpegdec, "No parser for codec");
+ } else {
+ GST_LOG_OBJECT (ffmpegdec, "Parser deactivated for format");
}
- switch (oclass->in_plugin->type) {
- case AVMEDIA_TYPE_VIDEO:
- /* clear values */
- ffmpegdec->ctx_pix_fmt = PIX_FMT_NB;
- ffmpegdec->ctx_width = 0;
- ffmpegdec->ctx_height = 0;
- ffmpegdec->ctx_ticks = 1;
- ffmpegdec->ctx_time_n = 0;
- ffmpegdec->ctx_time_d = 0;
- ffmpegdec->ctx_par_n = 0;
- ffmpegdec->ctx_par_d = 0;
- break;
- case AVMEDIA_TYPE_AUDIO:
- ffmpegdec->format.audio.samplerate = 0;
- ffmpegdec->format.audio.channels = 0;
- ffmpegdec->format.audio.depth = 0;
- break;
- default:
- break;
- }
+ ffmpegdec->samplerate = 0;
+ ffmpegdec->channels = 0;
+ ffmpegdec->depth = 0;
- gst_ffmpegdec_reset_ts (ffmpegdec);
- /* FIXME, reset_qos will take the LOCK and this function is already called
- * with the LOCK */
- ffmpegdec->proportion = 0.5;
- ffmpegdec->earliest_time = -1;
+ gst_ffmpegauddec_reset_ts (ffmpegdec);
return TRUE;
/* ERRORS */
could_not_open:
{
- gst_ffmpegdec_close (ffmpegdec);
- GST_DEBUG_OBJECT (ffmpegdec, "avdec_%s: Failed to open FFMPEG codec",
+ gst_ffmpegauddec_close (ffmpegdec);
+ GST_DEBUG_OBJECT (ffmpegdec, "avdec_%s: Failed to open libav codec",
oclass->in_plugin->name);
return FALSE;
}
}
static gboolean
-gst_ffmpegdec_setcaps (GstFFMpegDec * ffmpegdec, GstCaps * caps)
+gst_ffmpegauddec_setcaps (GstFFMpegAudDec * ffmpegdec, GstCaps * caps)
{
- GstFFMpegDecClass *oclass;
+ GstFFMpegAudDecClass *oclass;
GstStructure *structure;
- const GValue *par;
- const GValue *fps;
gboolean ret = TRUE;
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+ oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
GST_DEBUG_OBJECT (ffmpegdec, "setcaps called");
GST_OBJECT_LOCK (ffmpegdec);
- /* stupid check for VC1 */
- if ((oclass->in_plugin->id == CODEC_ID_WMV3) ||
- (oclass->in_plugin->id == CODEC_ID_VC1))
- oclass->in_plugin->id = gst_ffmpeg_caps_to_codecid (caps, NULL);
-
/* close old session */
if (ffmpegdec->opened) {
GST_OBJECT_UNLOCK (ffmpegdec);
- gst_ffmpegdec_drain (ffmpegdec);
+ gst_ffmpegauddec_drain (ffmpegdec);
GST_OBJECT_LOCK (ffmpegdec);
- gst_ffmpegdec_close (ffmpegdec);
+ gst_ffmpegauddec_close (ffmpegdec);
/* and reset the defaults that were set when a context is created */
avcodec_get_context_defaults (ffmpegdec->context);
}
- /* set buffer functions */
- if (oclass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
- ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer;
- ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer;
- ffmpegdec->context->draw_horiz_band = NULL;
- }
-
/* default is to let format decide if it needs a parser */
ffmpegdec->turnoff_parser = FALSE;
- ffmpegdec->has_b_frames = FALSE;
-
- GST_LOG_OBJECT (ffmpegdec, "size %dx%d", ffmpegdec->context->width,
- ffmpegdec->context->height);
-
/* get size and so */
gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
oclass->in_plugin->type, caps, ffmpegdec->context);
- GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
- ffmpegdec->context->height);
-
- if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
- GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
- ffmpegdec->context->time_base.num = 1;
- ffmpegdec->context->time_base.den = 25;
- }
-
/* get pixel aspect ratio if it's set */
structure = gst_caps_get_structure (caps, 0);
- par = gst_structure_get_value (structure, "pixel-aspect-ratio");
- if (par != NULL && GST_VALUE_HOLDS_FRACTION (par)) {
- ffmpegdec->in_par_n = gst_value_get_fraction_numerator (par);
- ffmpegdec->in_par_d = gst_value_get_fraction_denominator (par);
- GST_DEBUG_OBJECT (ffmpegdec, "sink caps have pixel-aspect-ratio of %d:%d",
- ffmpegdec->in_par_n, ffmpegdec->in_par_d);
- } else {
- GST_DEBUG_OBJECT (ffmpegdec, "no input pixel-aspect-ratio");
- ffmpegdec->in_par_n = 0;
- ffmpegdec->in_par_d = 0;
- }
-
- /* get the framerate from incoming caps. fps_n is set to 0 when
- * there is no valid framerate */
- fps = gst_structure_get_value (structure, "framerate");
- if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) {
- ffmpegdec->in_fps_n = gst_value_get_fraction_numerator (fps);
- ffmpegdec->in_fps_d = gst_value_get_fraction_denominator (fps);
- GST_DEBUG_OBJECT (ffmpegdec, "sink caps have framerate of %d/%d",
- ffmpegdec->in_fps_n, ffmpegdec->in_fps_d);
- } else {
- GST_DEBUG_OBJECT (ffmpegdec, "no input framerate ");
- ffmpegdec->in_fps_n = 0;
- ffmpegdec->in_fps_d = 0;
- }
-
/* for AAC we only use av_parse if not on stream-format==raw or ==loas */
if (oclass->in_plugin->id == CODEC_ID_AAC
|| oclass->in_plugin->id == CODEC_ID_AAC_LATM) {
@@ -828,44 +415,12 @@ gst_ffmpegdec_setcaps (GstFFMpegDec * ffmpegdec, GstCaps * caps)
ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
ffmpegdec->context->error_recognition = 1;
- /* for slow cpus */
- ffmpegdec->context->lowres = ffmpegdec->lowres;
- ffmpegdec->context->skip_frame = ffmpegdec->skip_frame;
-
- /* ffmpeg can draw motion vectors on top of the image (not every decoder
- * supports it) */
- ffmpegdec->context->debug_mv = ffmpegdec->debug_mv;
-
- if (ffmpegdec->max_threads == 0) {
- if (!(oclass->in_plugin->capabilities & CODEC_CAP_AUTO_THREADS))
- ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
- else
- ffmpegdec->context->thread_count = 0;
- } else
- ffmpegdec->context->thread_count = ffmpegdec->max_threads;
-
- ffmpegdec->context->thread_type = FF_THREAD_SLICE;
-
/* open codec - we don't select an output pix_fmt yet,
* simply because we don't know! We only get it
* during playback... */
- if (!gst_ffmpegdec_open (ffmpegdec))
+ if (!gst_ffmpegauddec_open (ffmpegdec))
goto open_failed;
- /* clipping region. take into account the lowres property */
- if (gst_structure_get_int (structure, "width", &ffmpegdec->in_width))
- ffmpegdec->in_width >>= ffmpegdec->lowres;
- else
- ffmpegdec->in_width = -1;
-
- if (gst_structure_get_int (structure, "height", &ffmpegdec->in_height))
- ffmpegdec->in_height >>= ffmpegdec->lowres;
- else
- ffmpegdec->in_height = -1;
-
- GST_DEBUG_OBJECT (ffmpegdec, "clipping to %dx%d",
- ffmpegdec->in_width, ffmpegdec->in_height);
-
done:
GST_OBJECT_UNLOCK (ffmpegdec);
@@ -880,575 +435,50 @@ open_failed:
}
}
-static void
-gst_ffmpegdec_fill_picture (GstFFMpegDec * ffmpegdec, GstVideoFrame * frame,
- AVFrame * picture)
-{
- guint i;
-
- /* setup data pointers and strides */
- for (i = 0; i < GST_VIDEO_FRAME_N_PLANES (frame); i++) {
- picture->data[i] = GST_VIDEO_FRAME_PLANE_DATA (frame, i);
- picture->linesize[i] = GST_VIDEO_FRAME_PLANE_STRIDE (frame, i);
-
- GST_LOG_OBJECT (ffmpegdec, "plane %d: data %p, linesize %d", i,
- picture->data[i], picture->linesize[i]);
- }
-}
-
-/* called when ffmpeg wants us to allocate a buffer to write the decoded frame
- * into. We try to give it memory from our pool */
-static int
-gst_ffmpegdec_get_buffer (AVCodecContext * context, AVFrame * picture)
-{
- GstBuffer *buf = NULL;
- GstFFMpegDec *ffmpegdec;
- GstFlowReturn ret;
- GstVideoFrame frame;
-
- ffmpegdec = (GstFFMpegDec *) context->opaque;
-
- ffmpegdec->context->pix_fmt = context->pix_fmt;
-
- GST_DEBUG_OBJECT (ffmpegdec, "getting buffer");
-
- /* apply the last info we have seen to this picture, when we get the
- * picture back from ffmpeg we can use this to correctly timestamp the output
- * buffer */
- picture->reordered_opaque = context->reordered_opaque;
- /* make sure we don't free the buffer when it's not ours */
- picture->opaque = NULL;
-
- /* see if we need renegotiation */
- if (G_UNLIKELY (!gst_ffmpegdec_video_negotiate (ffmpegdec, FALSE)))
- goto negotiate_failed;
-
- if (!ffmpegdec->current_dr)
- goto no_dr;
-
- /* alloc with aligned dimensions for ffmpeg */
- GST_LOG_OBJECT (ffmpegdec, "doing alloc from pool");
- ret = gst_buffer_pool_acquire_buffer (ffmpegdec->pool, &buf, NULL);
- if (G_UNLIKELY (ret != GST_FLOW_OK))
- goto alloc_failed;
-
- if (!gst_video_frame_map (&frame, &ffmpegdec->out_info, buf,
- GST_MAP_READWRITE))
- goto invalid_frame;
-
- gst_ffmpegdec_fill_picture (ffmpegdec, &frame, picture);
-
- /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
- * the opaque data. */
- picture->type = FF_BUFFER_TYPE_USER;
- picture->age = 256 * 256 * 256 * 64;
- picture->opaque = g_slice_dup (GstVideoFrame, &frame);
-
- GST_LOG_OBJECT (ffmpegdec, "returned buffer %p in frame %p", buf,
- picture->opaque);
-
- return 0;
-
- /* fallbacks */
-negotiate_failed:
- {
- GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");
- goto fallback;
- }
-no_dr:
- {
- GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
- goto fallback;
- }
-alloc_failed:
- {
- /* alloc default buffer when we can't get one from downstream */
- GST_LOG_OBJECT (ffmpegdec, "alloc failed, fallback alloc");
- goto fallback;
- }
-invalid_frame:
- {
- /* alloc default buffer when we can't get one from downstream */
- GST_LOG_OBJECT (ffmpegdec, "failed to map frame, fallback alloc");
- gst_buffer_unref (buf);
- goto fallback;
- }
-fallback:
- {
- return avcodec_default_get_buffer (context, picture);
- }
-}
-
-/* called when ffmpeg is done with our buffer */
-static void
-gst_ffmpegdec_release_buffer (AVCodecContext * context, AVFrame * picture)
-{
- gint i;
- GstBuffer *buf;
- GstFFMpegDec *ffmpegdec;
- GstVideoFrame *frame;
-
- ffmpegdec = (GstFFMpegDec *) context->opaque;
-
- /* check if it was our buffer */
- if (picture->opaque == NULL) {
- GST_DEBUG_OBJECT (ffmpegdec, "default release buffer");
- avcodec_default_release_buffer (context, picture);
- return;
- }
-
- /* we remove the opaque data now */
- frame = picture->opaque;
- picture->opaque = NULL;
-
- /* unmap buffer data */
- gst_video_frame_unmap (frame);
- buf = frame->buffer;
-
- GST_DEBUG_OBJECT (ffmpegdec, "release buffer %p in frame %p", buf, frame);
-
- g_slice_free (GstVideoFrame, frame);
- gst_buffer_unref (buf);
-
- /* zero out the reference in ffmpeg */
- for (i = 0; i < 4; i++) {
- picture->data[i] = NULL;
- picture->linesize[i] = 0;
- }
-}
-
-static void
-gst_ffmpegdec_update_par (GstFFMpegDec * ffmpegdec, gint * par_n, gint * par_d)
-{
- gboolean demuxer_par_set = FALSE;
- gboolean decoder_par_set = FALSE;
- gint demuxer_num = 1, demuxer_denom = 1;
- gint decoder_num = 1, decoder_denom = 1;
-
- GST_OBJECT_LOCK (ffmpegdec);
-
- if (ffmpegdec->in_par_n && ffmpegdec->in_par_d) {
- demuxer_num = ffmpegdec->in_par_n;
- demuxer_denom = ffmpegdec->in_par_d;
- demuxer_par_set = TRUE;
- GST_DEBUG_OBJECT (ffmpegdec, "Demuxer PAR: %d:%d", demuxer_num,
- demuxer_denom);
- }
-
- if (ffmpegdec->ctx_par_n && ffmpegdec->ctx_par_d) {
- decoder_num = ffmpegdec->ctx_par_n;
- decoder_denom = ffmpegdec->ctx_par_d;
- decoder_par_set = TRUE;
- GST_DEBUG_OBJECT (ffmpegdec, "Decoder PAR: %d:%d", decoder_num,
- decoder_denom);
- }
-
- GST_OBJECT_UNLOCK (ffmpegdec);
-
- if (!demuxer_par_set && !decoder_par_set)
- goto no_par;
-
- if (demuxer_par_set && !decoder_par_set)
- goto use_demuxer_par;
-
- if (decoder_par_set && !demuxer_par_set)
- goto use_decoder_par;
-
- /* Both the demuxer and the decoder provide a PAR. If one of
- * the two PARs is 1:1 and the other one is not, use the one
- * that is not 1:1. */
- if (demuxer_num == demuxer_denom && decoder_num != decoder_denom)
- goto use_decoder_par;
-
- if (decoder_num == decoder_denom && demuxer_num != demuxer_denom)
- goto use_demuxer_par;
-
- /* Both PARs are non-1:1, so use the PAR provided by the demuxer */
- goto use_demuxer_par;
-
-use_decoder_par:
- {
- GST_DEBUG_OBJECT (ffmpegdec,
- "Setting decoder provided pixel-aspect-ratio of %u:%u", decoder_num,
- decoder_denom);
- *par_n = decoder_num;
- *par_d = decoder_denom;
- return;
- }
-
-use_demuxer_par:
- {
- GST_DEBUG_OBJECT (ffmpegdec,
- "Setting demuxer provided pixel-aspect-ratio of %u:%u", demuxer_num,
- demuxer_denom);
- *par_n = demuxer_num;
- *par_d = demuxer_denom;
- return;
- }
-no_par:
- {
- GST_DEBUG_OBJECT (ffmpegdec,
- "Neither demuxer nor codec provide a pixel-aspect-ratio");
- *par_n = 1;
- *par_d = 1;
- return;
- }
-}
-
-static gboolean
-gst_ffmpegdec_bufferpool (GstFFMpegDec * ffmpegdec, GstCaps * caps)
-{
- GstQuery *query;
- GstBufferPool *pool;
- guint size, min, max;
- GstStructure *config;
- guint edge;
- AVCodecContext *context = ffmpegdec->context;
- gboolean have_videometa, have_alignment;
- GstAllocationParams params = { 0, 0, 0, 15, };
-
- GST_DEBUG_OBJECT (ffmpegdec, "setting up bufferpool");
-
- /* find a pool for the negotiated caps now */
- query = gst_query_new_allocation (caps, TRUE);
-
- if (gst_pad_peer_query (ffmpegdec->srcpad, query)) {
- have_videometa =
- gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE);
- } else {
- /* use query defaults */
- GST_DEBUG_OBJECT (ffmpegdec, "peer query failed, using defaults");
- have_videometa = FALSE;
- }
-
- if (gst_query_get_n_allocation_pools (query) > 0) {
- /* we got configuration from our peer, parse them */
- gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
-
- size = MAX (size, ffmpegdec->out_info.size);
- } else {
- pool = NULL;
- size = ffmpegdec->out_info.size;
- min = max = 0;
- }
-
- gst_query_unref (query);
-
- if (pool == NULL) {
- /* we did not get a pool, make one ourselves then */
- pool = gst_video_buffer_pool_new ();
- }
-
- config = gst_buffer_pool_get_config (pool);
- gst_buffer_pool_config_set_params (config, caps, size, min, max);
- /* we are happy with the default allocator but we would like to have 16 bytes
- * aligned memory */
- gst_buffer_pool_config_set_allocator (config, NULL, &params);
-
- have_alignment =
- gst_buffer_pool_has_option (pool, GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
-
- /* we can only enable the alignment if downstream supports the
- * videometa api */
- if (have_alignment && have_videometa) {
- GstVideoAlignment align;
- gint width, height;
- gint linesize_align[4];
- gint i;
-
- width = ffmpegdec->ctx_width;
- height = ffmpegdec->ctx_height;
- /* let ffmpeg find the alignment and padding */
- avcodec_align_dimensions2 (context, &width, &height, linesize_align);
- edge = context->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width ();
- /* increase the size for the padding */
- width += edge << 1;
- height += edge << 1;
-
- align.padding_top = edge;
- align.padding_left = edge;
- align.padding_right = width - ffmpegdec->ctx_width - edge;
- align.padding_bottom = height - ffmpegdec->ctx_height - edge;
- for (i = 0; i < GST_VIDEO_MAX_PLANES; i++)
- align.stride_align[i] =
- (linesize_align[i] > 0 ? linesize_align[i] - 1 : 0);
-
- GST_DEBUG_OBJECT (ffmpegdec, "aligned dimension %dx%d -> %dx%d "
- "padding t:%u l:%u r:%u b:%u, stride_align %d:%d:%d:%d",
- ffmpegdec->ctx_width, ffmpegdec->ctx_height, width, height,
- align.padding_top, align.padding_left, align.padding_right,
- align.padding_bottom, align.stride_align[0], align.stride_align[1],
- align.stride_align[2], align.stride_align[3]);
-
- gst_buffer_pool_config_add_option (config,
- GST_BUFFER_POOL_OPTION_VIDEO_META);
- gst_buffer_pool_config_add_option (config,
- GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
- gst_buffer_pool_config_set_video_alignment (config, &align);
-
- if (ffmpegdec->direct_rendering) {
- GstFFMpegDecClass *oclass;
-
- GST_DEBUG_OBJECT (ffmpegdec, "trying to enable direct rendering");
-
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-
- if (oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
- GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
- ffmpegdec->current_dr = TRUE;
- } else {
- GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
- }
- }
- } else {
- GST_DEBUG_OBJECT (ffmpegdec,
- "alignment or videometa not supported, disable direct rendering");
- /* disable direct rendering. This will make us use the fallback ffmpeg
- * picture allocation code with padding etc. We will then do the final
- * copy (with cropping) into a buffer from our pool */
- ffmpegdec->current_dr = FALSE;
- }
-
- /* and store */
- gst_buffer_pool_set_config (pool, config);
-
- if (ffmpegdec->pool) {
- gst_buffer_pool_set_active (ffmpegdec->pool, FALSE);
- gst_object_unref (ffmpegdec->pool);
- }
- ffmpegdec->pool = pool;
-
- /* and activate */
- gst_buffer_pool_set_active (pool, TRUE);
-
- return TRUE;
-}
-
static gboolean
-update_video_context (GstFFMpegDec * ffmpegdec, gboolean force)
+gst_ffmpegauddec_negotiate (GstFFMpegAudDec * ffmpegdec, gboolean force)
{
- AVCodecContext *context = ffmpegdec->context;
-
- if (!force && ffmpegdec->ctx_width == context->width
- && ffmpegdec->ctx_height == context->height
- && ffmpegdec->ctx_ticks == context->ticks_per_frame
- && ffmpegdec->ctx_time_n == context->time_base.num
- && ffmpegdec->ctx_time_d == context->time_base.den
- && ffmpegdec->ctx_pix_fmt == context->pix_fmt
- && ffmpegdec->ctx_par_n == context->sample_aspect_ratio.num
- && ffmpegdec->ctx_par_d == context->sample_aspect_ratio.den)
- return FALSE;
-
- GST_DEBUG_OBJECT (ffmpegdec,
- "Renegotiating video from %dx%d@ %d:%d PAR %d/%d fps to %dx%d@ %d:%d PAR %d/%d fps pixfmt %d",
- ffmpegdec->ctx_width, ffmpegdec->ctx_height,
- ffmpegdec->ctx_par_n, ffmpegdec->ctx_par_d,
- ffmpegdec->ctx_time_n, ffmpegdec->ctx_time_d,
- context->width, context->height,
- context->sample_aspect_ratio.num,
- context->sample_aspect_ratio.den,
- context->time_base.num, context->time_base.den, context->pix_fmt);
-
- ffmpegdec->ctx_width = context->width;
- ffmpegdec->ctx_height = context->height;
- ffmpegdec->ctx_ticks = context->ticks_per_frame;
- ffmpegdec->ctx_time_n = context->time_base.num;
- ffmpegdec->ctx_time_d = context->time_base.den;
- ffmpegdec->ctx_pix_fmt = context->pix_fmt;
- ffmpegdec->ctx_par_n = context->sample_aspect_ratio.num;
- ffmpegdec->ctx_par_d = context->sample_aspect_ratio.den;
-
- return TRUE;
-}
-
-static gboolean
-gst_ffmpegdec_video_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
-{
- GstFFMpegDecClass *oclass;
+ GstFFMpegAudDecClass *oclass;
GstCaps *caps;
- gint width, height;
- gint fps_n, fps_d;
- GstVideoInfo info;
- GstVideoFormat fmt;
-
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-
- force |= gst_pad_check_reconfigure (ffmpegdec->srcpad);
-
- /* first check if anything changed */
- if (!update_video_context (ffmpegdec, force))
- return TRUE;
-
- /* now we're going to construct the video info for the final output
- * format */
- gst_video_info_init (&info);
-
- fmt = gst_ffmpeg_pixfmt_to_video_format (ffmpegdec->ctx_pix_fmt);
- if (fmt == GST_VIDEO_FORMAT_UNKNOWN)
- goto unknown_format;
-
- /* determine the width and height, start with the dimension of the
- * context */
- width = ffmpegdec->ctx_width;
- height = ffmpegdec->ctx_height;
-
- /* if there is a width/height specified in the input, use that */
- if (ffmpegdec->in_width != -1 && ffmpegdec->in_width < width)
- width = ffmpegdec->in_width;
- if (ffmpegdec->in_height != -1 && ffmpegdec->in_height < height)
- height = ffmpegdec->in_height;
-
- /* now store the values */
- gst_video_info_set_format (&info, fmt, width, height);
-
- /* set the interlaced flag */
- if (ffmpegdec->ctx_interlaced)
- info.interlace_mode = GST_VIDEO_INTERLACE_MODE_MIXED;
- else
- info.interlace_mode = GST_VIDEO_INTERLACE_MODE_PROGRESSIVE;
-
- /* try to find a good framerate */
- if (ffmpegdec->in_fps_d) {
- /* take framerate from input when it was specified (#313970) */
- fps_n = ffmpegdec->in_fps_n;
- fps_d = ffmpegdec->in_fps_d;
- } else {
- fps_n = ffmpegdec->ctx_time_d / ffmpegdec->ctx_ticks;
- fps_d = ffmpegdec->ctx_time_n;
-
- if (!fps_d) {
- GST_LOG_OBJECT (ffmpegdec, "invalid framerate: %d/0, -> %d/1", fps_n,
- fps_n);
- fps_d = 1;
- }
- if (gst_util_fraction_compare (fps_n, fps_d, 1000, 1) > 0) {
- GST_LOG_OBJECT (ffmpegdec, "excessive framerate: %d/%d, -> 0/1", fps_n,
- fps_d);
- fps_n = 0;
- fps_d = 1;
- }
- }
- GST_LOG_OBJECT (ffmpegdec, "setting framerate: %d/%d", fps_n, fps_d);
- info.fps_n = fps_n;
- info.fps_d = fps_d;
-
- /* calculate and update par now */
- gst_ffmpegdec_update_par (ffmpegdec, &info.par_n, &info.par_d);
-
- caps = gst_video_info_to_caps (&info);
-
- if (!gst_pad_set_caps (ffmpegdec->srcpad, caps))
- goto caps_failed;
-
- ffmpegdec->out_info = info;
-
- /* now figure out a bufferpool */
- if (!gst_ffmpegdec_bufferpool (ffmpegdec, caps))
- goto no_bufferpool;
-
- gst_caps_unref (caps);
-
- return TRUE;
-
- /* ERRORS */
-unknown_format:
- {
-#ifdef HAVE_LIBAV_UNINSTALLED
- /* using internal ffmpeg snapshot */
- GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
- ("Could not find GStreamer caps mapping for libav pixfmt %d.",
- ffmpegdec->ctx_pix_fmt), (NULL));
-#else
- /* using external ffmpeg */
- GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION,
- ("Could not find GStreamer caps mapping for libav codec '%s', and "
- "you are using an external libavcodec. This is most likely due to "
- "a packaging problem and/or libavcodec having been upgraded to a "
- "version that is not compatible with this version of "
- "gstreamer-libav. Make sure your gstreamer-libav and libavcodec "
- "packages come from the same source/repository.",
- oclass->in_plugin->name), (NULL));
-#endif
- return FALSE;
- }
-caps_failed:
- {
- GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
- ("Could not set caps for libav decoder (%s), not fixed?",
- oclass->in_plugin->name));
- gst_caps_unref (caps);
-
- return FALSE;
- }
-no_bufferpool:
- {
- GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
- ("Could not create bufferpool for fmpeg decoder (%s)",
- oclass->in_plugin->name));
- gst_caps_unref (caps);
-
- return FALSE;
- }
-}
-
-static gboolean
-update_audio_context (GstFFMpegDec * ffmpegdec, gboolean force)
-{
- AVCodecContext *context = ffmpegdec->context;
gint depth;
GstAudioChannelPosition pos[64] = { 0, };
- depth = av_smp_format_depth (context->sample_fmt);
+ oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
- gst_ffmpeg_channel_layout_to_gst (context, pos);
+ depth = av_smp_format_depth (ffmpegdec->context->sample_fmt);
+ gst_ffmpeg_channel_layout_to_gst (ffmpegdec->context, pos);
- if (!force && ffmpegdec->format.audio.samplerate ==
- context->sample_rate &&
- ffmpegdec->format.audio.channels == context->channels &&
- ffmpegdec->format.audio.depth == depth &&
- memcmp (ffmpegdec->format.audio.ffmpeg_layout, pos,
- sizeof (GstAudioChannelPosition) * context->channels) == 0)
- return FALSE;
+ if (!force && ffmpegdec->samplerate ==
+ ffmpegdec->context->sample_rate &&
+ ffmpegdec->channels == ffmpegdec->context->channels &&
+ ffmpegdec->depth == depth)
+ return TRUE;
GST_DEBUG_OBJECT (ffmpegdec,
"Renegotiating audio from %dHz@%dchannels (%d) to %dHz@%dchannels (%d)",
- ffmpegdec->format.audio.samplerate, ffmpegdec->format.audio.channels,
- ffmpegdec->format.audio.depth,
- context->sample_rate, context->channels, depth);
+ ffmpegdec->samplerate, ffmpegdec->channels,
+ ffmpegdec->depth,
+ ffmpegdec->context->sample_rate, ffmpegdec->context->channels, depth);
- ffmpegdec->format.audio.samplerate = context->sample_rate;
- ffmpegdec->format.audio.channels = context->channels;
- ffmpegdec->format.audio.depth = depth;
- memcpy (ffmpegdec->format.audio.ffmpeg_layout, pos,
- sizeof (GstAudioChannelPosition) * context->channels);
+ ffmpegdec->samplerate = ffmpegdec->context->sample_rate;
+ ffmpegdec->channels = ffmpegdec->context->channels;
+ ffmpegdec->depth = depth;
+ memcpy (ffmpegdec->ffmpeg_layout, pos,
+ sizeof (GstAudioChannelPosition) * ffmpegdec->context->channels);
- return TRUE;
-}
-
-static gboolean
-gst_ffmpegdec_audio_negotiate (GstFFMpegDec * ffmpegdec, gboolean force)
-{
- GstFFMpegDecClass *oclass;
- GstCaps *caps;
-
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-
- if (!update_audio_context (ffmpegdec, force))
- return TRUE;
+ /* Get GStreamer channel layout */
+ memcpy (ffmpegdec->gst_layout,
+ ffmpegdec->ffmpeg_layout,
+ sizeof (GstAudioChannelPosition) * ffmpegdec->channels);
+ gst_audio_channel_positions_to_valid_order (ffmpegdec->gst_layout,
+ ffmpegdec->channels);
- /* convert the raw output format to caps */
caps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type,
ffmpegdec->context, oclass->in_plugin->id, FALSE);
+
if (caps == NULL)
goto no_caps;
- /* Get GStreamer channel layout */
- memcpy (ffmpegdec->format.audio.gst_layout,
- ffmpegdec->format.audio.ffmpeg_layout,
- sizeof (GstAudioChannelPosition) * ffmpegdec->format.audio.channels);
- gst_audio_channel_positions_to_valid_order (ffmpegdec->format.audio.
- gst_layout, ffmpegdec->format.audio.channels);
-
GST_LOG_OBJECT (ffmpegdec, "output caps %" GST_PTR_FORMAT, caps);
if (!gst_pad_set_caps (ffmpegdec->srcpad, caps))
@@ -1490,292 +520,8 @@ caps_failed:
}
}
-/* perform qos calculations before decoding the next frame.
- *
- * Sets the skip_frame flag and if things are really bad, skips to the next
- * keyframe.
- *
- * Returns TRUE if the frame should be decoded, FALSE if the frame can be dropped
- * entirely.
- */
-static gboolean
-gst_ffmpegdec_do_qos (GstFFMpegDec * ffmpegdec, GstClockTime timestamp,
- gboolean * mode_switch)
-{
- GstClockTimeDiff diff;
- gdouble proportion;
- GstClockTime qostime, earliest_time;
- gboolean res = TRUE;
-
- *mode_switch = FALSE;
-
- /* no timestamp, can't do QoS */
- if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (timestamp)))
- goto no_qos;
-
- /* get latest QoS observation values */
- gst_ffmpegdec_read_qos (ffmpegdec, &proportion, &earliest_time);
-
- /* skip qos if we have no observation (yet) */
- if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (earliest_time))) {
- /* no skip_frame initialy */
- ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
- goto no_qos;
- }
-
- /* qos is done on running time of the timestamp */
- qostime = gst_segment_to_running_time (&ffmpegdec->segment, GST_FORMAT_TIME,
- timestamp);
-
- /* timestamp can be out of segment, then we don't do QoS */
- if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (qostime)))
- goto no_qos;
-
- /* see how our next timestamp relates to the latest qos timestamp. negative
- * values mean we are early, positive values mean we are too late. */
- diff = GST_CLOCK_DIFF (qostime, earliest_time);
-
- GST_DEBUG_OBJECT (ffmpegdec, "QOS: qostime %" GST_TIME_FORMAT
- ", earliest %" GST_TIME_FORMAT, GST_TIME_ARGS (qostime),
- GST_TIME_ARGS (earliest_time));
-
- /* if we using less than 40% of the available time, we can try to
- * speed up again when we were slow. */
- if (proportion < 0.4 && diff < 0) {
- goto normal_mode;
- } else {
- if (diff >= 0) {
- /* we're too slow, try to speed up */
- if (ffmpegdec->waiting_for_key) {
- /* we were waiting for a keyframe, that's ok */
- goto skipping;
- }
- /* switch to skip_frame mode */
- goto skip_frame;
- }
- }
-
-no_qos:
- ffmpegdec->processed++;
- return TRUE;
-
-skipping:
- {
- res = FALSE;
- goto drop_qos;
- }
-normal_mode:
- {
- if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
- ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
- *mode_switch = TRUE;
- GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode %g < 0.4", proportion);
- }
- ffmpegdec->processed++;
- return TRUE;
- }
-skip_frame:
- {
- if (ffmpegdec->context->skip_frame != AVDISCARD_NONREF) {
- ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
- *mode_switch = TRUE;
- GST_DEBUG_OBJECT (ffmpegdec,
- "QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
- }
- goto drop_qos;
- }
-drop_qos:
- {
- GstClockTime stream_time, jitter;
- GstMessage *qos_msg;
-
- ffmpegdec->dropped++;
- stream_time =
- gst_segment_to_stream_time (&ffmpegdec->segment, GST_FORMAT_TIME,
- timestamp);
- jitter = GST_CLOCK_DIFF (qostime, earliest_time);
- qos_msg =
- gst_message_new_qos (GST_OBJECT_CAST (ffmpegdec), FALSE, qostime,
- stream_time, timestamp, GST_CLOCK_TIME_NONE);
- gst_message_set_qos_values (qos_msg, jitter, proportion, 1000000);
- gst_message_set_qos_stats (qos_msg, GST_FORMAT_BUFFERS,
- ffmpegdec->processed, ffmpegdec->dropped);
- gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec), qos_msg);
-
- return res;
- }
-}
-
-/* returns TRUE if buffer is within segment, else FALSE.
- * if Buffer is on segment border, it's timestamp and duration will be clipped */
-static gboolean
-clip_video_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
- GstClockTime in_dur)
-{
- gboolean res = TRUE;
- guint64 cstart, cstop;
- GstClockTime stop;
-
- GST_LOG_OBJECT (dec,
- "timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
- GST_TIME_ARGS (in_ts), GST_TIME_ARGS (in_dur));
-
- /* can't clip without TIME segment */
- if (G_UNLIKELY (dec->segment.format != GST_FORMAT_TIME))
- goto beach;
-
- /* we need a start time */
- if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (in_ts)))
- goto beach;
-
- /* generate valid stop, if duration unknown, we have unknown stop */
- stop =
- GST_CLOCK_TIME_IS_VALID (in_dur) ? (in_ts + in_dur) : GST_CLOCK_TIME_NONE;
-
- /* now clip */
- res =
- gst_segment_clip (&dec->segment, GST_FORMAT_TIME, in_ts, stop, &cstart,
- &cstop);
- if (G_UNLIKELY (!res))
- goto beach;
-
- /* we're pretty sure the duration of this buffer is not till the end of this
- * segment (which _clip will assume when the stop is -1) */
- if (stop == GST_CLOCK_TIME_NONE)
- cstop = GST_CLOCK_TIME_NONE;
-
- /* update timestamp and possibly duration if the clipped stop time is
- * valid */
- GST_BUFFER_TIMESTAMP (buf) = cstart;
- if (GST_CLOCK_TIME_IS_VALID (cstop))
- GST_BUFFER_DURATION (buf) = cstop - cstart;
-
- GST_LOG_OBJECT (dec,
- "clipped timestamp:%" GST_TIME_FORMAT " , duration:%" GST_TIME_FORMAT,
- GST_TIME_ARGS (cstart), GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
-
-beach:
- GST_LOG_OBJECT (dec, "%sdropping", (res ? "not " : ""));
- return res;
-}
-
-
-/* figure out if the current picture is a keyframe, return TRUE if that is
- * the case. */
-static gboolean
-check_keyframe (GstFFMpegDec * ffmpegdec)
-{
- GstFFMpegDecClass *oclass;
- gboolean is_itype = FALSE;
- gboolean is_reference = FALSE;
- gboolean iskeyframe;
-
- /* figure out if we are dealing with a keyframe */
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
-
- /* remember that we have B frames, we need this for the DTS -> PTS conversion
- * code */
- if (!ffmpegdec->has_b_frames && ffmpegdec->picture->pict_type == FF_B_TYPE) {
- GST_DEBUG_OBJECT (ffmpegdec, "we have B frames");
- ffmpegdec->has_b_frames = TRUE;
- /* Emit latency message to recalculate it */
- gst_element_post_message (GST_ELEMENT_CAST (ffmpegdec),
- gst_message_new_latency (GST_OBJECT_CAST (ffmpegdec)));
- }
-
- is_itype = (ffmpegdec->picture->pict_type == FF_I_TYPE);
- is_reference = (ffmpegdec->picture->reference == 1);
-
- iskeyframe = (is_itype || is_reference || ffmpegdec->picture->key_frame)
- || (oclass->in_plugin->id == CODEC_ID_INDEO3)
- || (oclass->in_plugin->id == CODEC_ID_MSZH)
- || (oclass->in_plugin->id == CODEC_ID_ZLIB)
- || (oclass->in_plugin->id == CODEC_ID_VP3)
- || (oclass->in_plugin->id == CODEC_ID_HUFFYUV);
-
- GST_LOG_OBJECT (ffmpegdec,
- "current picture: type: %d, is_keyframe:%d, is_itype:%d, is_reference:%d",
- ffmpegdec->picture->pict_type, iskeyframe, is_itype, is_reference);
-
- return iskeyframe;
-}
-
-/* get an outbuf buffer with the current picture */
-static GstFlowReturn
-get_output_buffer (GstFFMpegDec * ffmpegdec, GstBuffer ** outbuf)
-{
- GstFlowReturn ret;
-
- if (ffmpegdec->picture->opaque != NULL) {
- GstVideoFrame *frame;
-
- /* we allocated a picture already for ffmpeg to decode into, let's pick it
- * up and use it now. */
- frame = ffmpegdec->picture->opaque;
- *outbuf = frame->buffer;
- GST_LOG_OBJECT (ffmpegdec, "using opaque buffer %p on frame %p", *outbuf,
- frame);
- gst_buffer_ref (*outbuf);
- } else {
- GstVideoFrame frame;
- AVPicture *src, *dest;
- AVFrame pic;
- gint width, height;
- GstBuffer *buf;
-
- GST_LOG_OBJECT (ffmpegdec, "allocating an output buffer");
-
- if (G_UNLIKELY (!gst_ffmpegdec_video_negotiate (ffmpegdec, FALSE)))
- goto negotiate_failed;
-
- ret = gst_buffer_pool_acquire_buffer (ffmpegdec->pool, &buf, NULL);
- if (G_UNLIKELY (ret != GST_FLOW_OK))
- goto alloc_failed;
-
- if (!gst_video_frame_map (&frame, &ffmpegdec->out_info, buf,
- GST_MAP_READWRITE))
- goto invalid_frame;
-
- gst_ffmpegdec_fill_picture (ffmpegdec, &frame, &pic);
-
- width = ffmpegdec->out_info.width;
- height = ffmpegdec->out_info.height;
-
- src = (AVPicture *) ffmpegdec->picture;
- dest = (AVPicture *) & pic;
-
- GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec,
- "copy picture to output buffer %dx%d", width, height);
- av_picture_copy (dest, src, ffmpegdec->context->pix_fmt, width, height);
-
- gst_video_frame_unmap (&frame);
-
- *outbuf = buf;
- }
- ffmpegdec->picture->reordered_opaque = -1;
-
- return GST_FLOW_OK;
-
- /* special cases */
-negotiate_failed:
- {
- GST_DEBUG_OBJECT (ffmpegdec, "negotiation failed");
- return GST_FLOW_NOT_NEGOTIATED;
- }
-alloc_failed:
- {
- GST_DEBUG_OBJECT (ffmpegdec, "buffer alloc failed");
- return ret;
- }
-invalid_frame:
- {
- GST_DEBUG_OBJECT (ffmpegdec, "could not map frame");
- return GST_FLOW_ERROR;
- }
-}
-
static void
-clear_queued (GstFFMpegDec * ffmpegdec)
+clear_queued (GstFFMpegAudDec * ffmpegdec)
{
g_list_foreach (ffmpegdec->queued, (GFunc) gst_mini_object_unref, NULL);
g_list_free (ffmpegdec->queued);
@@ -1783,7 +529,7 @@ clear_queued (GstFFMpegDec * ffmpegdec)
}
static GstFlowReturn
-flush_queued (GstFFMpegDec * ffmpegdec)
+flush_queued (GstFFMpegAudDec * ffmpegdec)
{
GstFlowReturn res = GST_FLOW_OK;
@@ -1814,369 +560,10 @@ gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
packet->size = size;
}
-/* gst_ffmpegdec_[video|audio]_frame:
- * ffmpegdec:
- * data: pointer to the data to decode
- * size: size of data in bytes
- * dec_info: timestamp info
- * outbuf: outgoing buffer. Different from NULL ONLY if it contains decoded data.
- * ret: Return flow.
- *
- * Returns: number of bytes used in decoding. The check for successful decode is
- * outbuf being non-NULL.
- */
-static gint
-gst_ffmpegdec_video_frame (GstFFMpegDec * ffmpegdec,
- guint8 * data, guint size,
- const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
-{
- gint len = -1;
- gint have_data;
- gboolean iskeyframe;
- gboolean mode_switch;
- gboolean decode;
- gint skip_frame = AVDISCARD_DEFAULT;
- GstClockTime out_dts, out_pts, out_duration;
- gint64 out_offset;
- const GstTSInfo *out_info;
- AVPacket packet;
-
- *ret = GST_FLOW_OK;
- *outbuf = NULL;
-
- ffmpegdec->context->opaque = ffmpegdec;
-
- /* in case we skip frames */
- ffmpegdec->picture->pict_type = -1;
-
- /* run QoS code, we don't stop decoding the frame when we are late because
- * else we might skip a reference frame */
- decode = gst_ffmpegdec_do_qos (ffmpegdec, dec_info->pts, &mode_switch);
-
- if (ffmpegdec->is_realvideo && data != NULL) {
- gint slice_count;
- gint i;
-
- /* setup the slice table for realvideo */
- if (ffmpegdec->context->slice_offset == NULL)
- ffmpegdec->context->slice_offset = g_malloc (sizeof (guint32) * 1000);
-
- slice_count = (*data++) + 1;
- ffmpegdec->context->slice_count = slice_count;
-
- for (i = 0; i < slice_count; i++) {
- data += 4;
- ffmpegdec->context->slice_offset[i] = GST_READ_UINT32_LE (data);
- data += 4;
- }
- }
-
- if (!decode) {
- /* no decoding needed, save previous skip_frame value and brutely skip
- * decoding everything */
- skip_frame = ffmpegdec->context->skip_frame;
- ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
- }
-
- /* save reference to the timing info */
- ffmpegdec->context->reordered_opaque = (gint64) dec_info->idx;
- ffmpegdec->picture->reordered_opaque = (gint64) dec_info->idx;
-
- GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d", dec_info->idx);
-
- /* now decode the frame */
- gst_avpacket_init (&packet, data, size);
-
- if (ffmpegdec->context->palctrl) {
- guint8 *pal;
-
- pal = av_packet_new_side_data (&packet, AV_PKT_DATA_PALETTE,
- AVPALETTE_SIZE);
- memcpy (pal, ffmpegdec->context->palctrl->palette, AVPALETTE_SIZE);
- GST_DEBUG_OBJECT (ffmpegdec, "copy pal %p %p", &packet, pal);
- }
-
- len = avcodec_decode_video2 (ffmpegdec->context,
- ffmpegdec->picture, &have_data, &packet);
-
- /* restore previous state */
- if (!decode)
- ffmpegdec->context->skip_frame = skip_frame;
-
- GST_DEBUG_OBJECT (ffmpegdec, "after decode: len %d, have_data %d",
- len, have_data);
-
- /* when we are in skip_frame mode, don't complain when ffmpeg returned
- * no data because we told it to skip stuff. */
- if (len < 0 && (mode_switch || ffmpegdec->context->skip_frame))
- len = 0;
-
- if (len > 0 && have_data <= 0 && (mode_switch
- || ffmpegdec->context->skip_frame)) {
- /* we consumed some bytes but nothing decoded and we are skipping frames,
- * disable the interpollation of DTS timestamps */
- ffmpegdec->last_out = -1;
- }
-
- /* no data, we're done */
- if (len < 0 || have_data <= 0)
- goto beach;
-
- /* get the output picture timing info again */
- out_info = gst_ts_info_get (ffmpegdec, ffmpegdec->picture->reordered_opaque);
- out_dts = out_info->dts;
- out_pts = out_info->pts;
- out_duration = out_info->duration;
- out_offset = out_info->offset;
-
- GST_DEBUG_OBJECT (ffmpegdec,
- "dts %" G_GUINT64_FORMAT " pts %" G_GUINT64_FORMAT " duration %"
- G_GUINT64_FORMAT " offset %" G_GINT64_FORMAT, out_dts, out_pts,
- out_duration, out_offset);
- GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT,
- (guint64) ffmpegdec->picture->pts);
- GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d",
- ffmpegdec->picture->coded_picture_number);
- GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d",
- ffmpegdec->picture->reference);
- GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d",
- ffmpegdec->picture->display_picture_number);
- GST_DEBUG_OBJECT (ffmpegdec, "picture: opaque %p",
- ffmpegdec->picture->opaque);
- GST_DEBUG_OBJECT (ffmpegdec, "picture: reordered opaque %" G_GUINT64_FORMAT,
- (guint64) ffmpegdec->picture->reordered_opaque);
- GST_DEBUG_OBJECT (ffmpegdec, "repeat_pict:%d",
- ffmpegdec->picture->repeat_pict);
- GST_DEBUG_OBJECT (ffmpegdec, "interlaced_frame:%d",
- ffmpegdec->picture->interlaced_frame);
-
- if (G_UNLIKELY (ffmpegdec->picture->interlaced_frame !=
- ffmpegdec->ctx_interlaced)) {
- GST_WARNING ("Change in interlacing ! picture:%d, recorded:%d",
- ffmpegdec->picture->interlaced_frame, ffmpegdec->ctx_interlaced);
- ffmpegdec->ctx_interlaced = ffmpegdec->picture->interlaced_frame;
- gst_ffmpegdec_video_negotiate (ffmpegdec, TRUE);
- }
-#if 0
- /* Whether a frame is interlaced or not is unknown at the time of
- buffer allocation, so caps on the buffer in opaque will have
- the previous frame's interlaced flag set. So if interlacedness
- has changed since allocation, we update the buffer (if any)
- caps now with the correct interlaced flag. */
- if (ffmpegdec->picture->opaque != NULL) {
- GstBuffer *buffer = ffmpegdec->picture->opaque;
- if (GST_BUFFER_CAPS (buffer) && GST_PAD_CAPS (ffmpegdec->srcpad)) {
- GstStructure *s = gst_caps_get_structure (GST_BUFFER_CAPS (buffer), 0);
- gboolean interlaced;
- gboolean found = gst_structure_get_boolean (s, "interlaced", &interlaced);
- if (!found || (! !interlaced != ! !ffmpegdec->format.video.interlaced)) {
- GST_DEBUG_OBJECT (ffmpegdec,
- "Buffer interlacing does not match pad, updating");
- buffer = gst_buffer_make_metadata_writable (buffer);
- gst_buffer_set_caps (buffer, GST_PAD_CAPS (ffmpegdec->srcpad));
- ffmpegdec->picture->opaque = buffer;
- }
- }
- }
-#endif
-
- /* check if we are dealing with a keyframe here, this will also check if we
- * are dealing with B frames. */
- iskeyframe = check_keyframe (ffmpegdec);
-
- if (out_pts == 0 && out_pts == ffmpegdec->last_out) {
- GST_LOG_OBJECT (ffmpegdec, "ffmpeg returns 0 timestamps, ignoring");
- /* some codecs only output 0 timestamps, when that happens, make us select an
- * output timestamp based on the input timestamp. We do this by making the
- * ffmpeg timestamp and the interpollated next timestamp invalid. */
- out_pts = -1;
- ffmpegdec->next_out = -1;
- } else
- ffmpegdec->last_out = out_pts;
-
-
- if (iskeyframe && out_pts == -1) {
- GST_DEBUG_OBJECT (ffmpegdec, "keyframe, use DTS %" GST_TIME_FORMAT,
- GST_TIME_ARGS (out_dts));
- out_pts = out_dts;
- }
-
- /* when we're waiting for a keyframe, see if we have one or drop the current
- * non-keyframe */
- if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
- if (G_LIKELY (!iskeyframe))
- goto drop_non_keyframe;
-
- /* we have a keyframe, we can stop waiting for one */
- ffmpegdec->waiting_for_key = FALSE;
- }
-
- /* get a handle to the output buffer */
- *ret = get_output_buffer (ffmpegdec, outbuf);
- if (G_UNLIKELY (*ret != GST_FLOW_OK))
- goto no_output;
-
- /*
- * Timestamps:
- *
- * 1) Copy picture timestamp if valid
- * 2) else interpolate from previous output timestamp
- * 3) else copy input timestamp
- */
- if (out_pts != -1) {
- /* Use (interpolated) timestamp from FFMPEG */
- GST_LOG_OBJECT (ffmpegdec, "using timestamp %" GST_TIME_FORMAT
- " returned by ffmpeg", GST_TIME_ARGS (out_pts));
- } else if (ffmpegdec->next_out != -1) {
- out_pts = ffmpegdec->next_out;
- GST_LOG_OBJECT (ffmpegdec, "using next timestamp %" GST_TIME_FORMAT,
- GST_TIME_ARGS (out_pts));
- } else {
- out_pts = dec_info->pts;
- GST_LOG_OBJECT (ffmpegdec, "using in timestamp %" GST_TIME_FORMAT,
- GST_TIME_ARGS (out_pts));
- }
- GST_BUFFER_DTS (*outbuf) = out_pts;
- GST_BUFFER_PTS (*outbuf) = out_pts;
-
- /*
- * Offset:
- * 0) Use stored input offset (from opaque)
- * 1) Use value converted from timestamp if valid
- * 2) Use input offset if valid
- */
- if (out_offset != GST_BUFFER_OFFSET_NONE) {
- /* out_offset already contains the offset from ts_info */
- GST_LOG_OBJECT (ffmpegdec, "Using offset returned by ffmpeg");
- } else if (out_pts != GST_CLOCK_TIME_NONE) {
- GST_LOG_OBJECT (ffmpegdec, "Using offset converted from timestamp");
- /* FIXME, we should really remove this as it's not nice at all to do
- * upstream queries for each frame to get the frame offset. We also can't
- * really remove this because it is the only way of setting frame offsets
- * on outgoing buffers. We should have metadata so that the upstream peer
- * can set a frame number on the encoded data. */
- gst_pad_peer_query_convert (ffmpegdec->sinkpad,
- GST_FORMAT_TIME, out_pts, GST_FORMAT_DEFAULT, &out_offset);
- } else if (dec_info->offset != GST_BUFFER_OFFSET_NONE) {
- /* FIXME, the input offset is input media specific and might not
- * be the same for the output media. (byte offset as input, frame number
- * as output, for example) */
- GST_LOG_OBJECT (ffmpegdec, "using in_offset %" G_GINT64_FORMAT,
- dec_info->offset);
- out_offset = dec_info->offset;
- } else {
- GST_LOG_OBJECT (ffmpegdec, "no valid offset found");
- out_offset = GST_BUFFER_OFFSET_NONE;
- }
- GST_BUFFER_OFFSET (*outbuf) = out_offset;
-
- /*
- * Duration:
- *
- * 1) Use reordered input duration if valid
- * 2) Else use input duration
- * 3) else use input framerate
- * 4) else use ffmpeg framerate
- */
- if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
- /* We have a valid (reordered) duration */
- GST_LOG_OBJECT (ffmpegdec,
- "Using duration returned by ffmpeg %" GST_TIME_FORMAT,
- GST_TIME_ARGS (out_duration));
- } else if (GST_CLOCK_TIME_IS_VALID (dec_info->duration)) {
- out_duration = dec_info->duration;
- GST_LOG_OBJECT (ffmpegdec, "using in_duration %" GST_TIME_FORMAT,
- GST_TIME_ARGS (out_duration));
- } else if (GST_CLOCK_TIME_IS_VALID (ffmpegdec->last_diff)) {
- out_duration = ffmpegdec->last_diff;
- GST_LOG_OBJECT (ffmpegdec, "using last-diff %" GST_TIME_FORMAT,
- GST_TIME_ARGS (out_duration));
- } else {
- /* if we have an input framerate, use that */
- if (ffmpegdec->out_info.fps_n != -1 &&
- (ffmpegdec->out_info.fps_n != 1000 && ffmpegdec->out_info.fps_d != 1)) {
- out_duration = gst_util_uint64_scale_int (GST_SECOND,
- ffmpegdec->out_info.fps_d, ffmpegdec->out_info.fps_n);
- GST_LOG_OBJECT (ffmpegdec,
- "using input framerate for duration %" GST_TIME_FORMAT,
- GST_TIME_ARGS (out_duration));
- } else {
- /* don't try to use the decoder's framerate when it seems a bit abnormal,
- * which we assume when den >= 1000... */
- if (ffmpegdec->context->time_base.num != 0 &&
- (ffmpegdec->context->time_base.den > 0 &&
- ffmpegdec->context->time_base.den < 1000)) {
- out_duration = gst_util_uint64_scale_int (GST_SECOND,
- ffmpegdec->context->time_base.num *
- ffmpegdec->context->ticks_per_frame,
- ffmpegdec->context->time_base.den);
- GST_LOG_OBJECT (ffmpegdec, "using decoder's framerate for duration %"
- GST_TIME_FORMAT, GST_TIME_ARGS (out_duration));
- } else {
- GST_LOG_OBJECT (ffmpegdec, "no valid duration found");
- }
- }
- }
-
- /* Take repeat_pict into account */
- if (GST_CLOCK_TIME_IS_VALID (out_duration)) {
- GST_LOG_OBJECT (ffmpegdec, "repeat pict %d",
- ffmpegdec->picture->repeat_pict);
- out_duration += out_duration * ffmpegdec->picture->repeat_pict / 2;
- }
- GST_BUFFER_DURATION (*outbuf) = out_duration;
-
- if (out_dts != -1 && out_duration != -1 && out_duration != 0)
- ffmpegdec->next_out = out_pts + out_duration;
- else
- ffmpegdec->next_out = -1;
-
- GST_LOG_OBJECT (ffmpegdec, "next out %" GST_TIME_FORMAT,
- GST_TIME_ARGS (ffmpegdec->next_out));
-
- /* now see if we need to clip the buffer against the segment boundaries. */
- if (G_UNLIKELY (!clip_video_buffer (ffmpegdec, *outbuf, out_pts,
- out_duration)))
- goto clipped;
-
- /* mark as keyframe or delta unit */
- if (!iskeyframe)
- GST_BUFFER_FLAG_SET (*outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
-
- if (ffmpegdec->picture->top_field_first)
- GST_BUFFER_FLAG_SET (*outbuf, GST_VIDEO_BUFFER_FLAG_TFF);
-
-
-beach:
- GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
- *ret, *outbuf, len);
- return len;
-
- /* special cases */
-drop_non_keyframe:
- {
- GST_WARNING_OBJECT (ffmpegdec, "Dropping non-keyframe (seek/init)");
- goto beach;
- }
-no_output:
- {
- GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
- len = -1;
- goto beach;
- }
-clipped:
- {
- GST_DEBUG_OBJECT (ffmpegdec, "buffer clipped");
- gst_buffer_unref (*outbuf);
- *outbuf = NULL;
- goto beach;
- }
-}
-
/* returns TRUE if buffer is within segment, else FALSE.
* if Buffer is on segment border, it's timestamp and duration will be clipped */
static gboolean
-clip_audio_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
+clip_audio_buffer (GstFFMpegAudDec * dec, GstBuffer * buf, GstClockTime in_ts,
GstClockTime in_dur)
{
GstClockTime stop;
@@ -2213,8 +600,8 @@ clip_audio_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
if (G_UNLIKELY ((diff = ctime - in_ts) > 0)) {
/* bring clipped time to bytes */
diff =
- gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
- GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
+ gst_util_uint64_scale_int (diff, dec->samplerate,
+ GST_SECOND) * (dec->depth * dec->channels);
GST_DEBUG_OBJECT (dec, "clipping start to %" GST_TIME_FORMAT " %"
G_GINT64_FORMAT " bytes", GST_TIME_ARGS (ctime), diff);
@@ -2225,8 +612,8 @@ clip_audio_buffer (GstFFMpegDec * dec, GstBuffer * buf, GstClockTime in_ts,
if (G_UNLIKELY ((diff = stop - cstop) > 0)) {
/* bring clipped time to bytes */
diff =
- gst_util_uint64_scale_int (diff, dec->format.audio.samplerate,
- GST_SECOND) * (dec->format.audio.depth * dec->format.audio.channels);
+ gst_util_uint64_scale_int (diff, dec->samplerate,
+ GST_SECOND) * (dec->depth * dec->channels);
GST_DEBUG_OBJECT (dec, "clipping stop to %" GST_TIME_FORMAT " %"
G_GINT64_FORMAT " bytes", GST_TIME_ARGS (cstop), diff);
@@ -2250,7 +637,7 @@ out_of_segment:
}
static gint
-gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
+gst_ffmpegauddec_audio_frame (GstFFMpegAudDec * ffmpegdec,
AVCodec * in_plugin, guint8 * data, guint size,
const GstTSInfo * dec_info, GstBuffer ** outbuf, GstFlowReturn * ret)
{
@@ -2288,7 +675,7 @@ gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
gst_buffer_resize (*outbuf, 0, have_data);
GST_DEBUG_OBJECT (ffmpegdec, "Creating output buffer");
- if (!gst_ffmpegdec_audio_negotiate (ffmpegdec, FALSE)) {
+ if (!gst_ffmpegauddec_negotiate (ffmpegdec, FALSE)) {
gst_buffer_unref (*outbuf);
*outbuf = NULL;
len = -1;
@@ -2314,8 +701,7 @@ gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
* 1) calculate based on number of samples
*/
out_duration = gst_util_uint64_scale (have_data, GST_SECOND,
- ffmpegdec->format.audio.depth * ffmpegdec->format.audio.channels *
- ffmpegdec->format.audio.samplerate);
+ ffmpegdec->depth * ffmpegdec->channels * ffmpegdec->samplerate);
/* offset:
*
@@ -2346,27 +732,16 @@ gst_ffmpegdec_audio_frame (GstFFMpegDec * ffmpegdec,
/* Only the width really matters here... and it's stored as depth */
fmt =
gst_audio_format_build_integer (TRUE, G_BYTE_ORDER,
- ffmpegdec->format.audio.depth * 8, ffmpegdec->format.audio.depth * 8);
+ ffmpegdec->depth * 8, ffmpegdec->depth * 8);
gst_audio_buffer_reorder_channels (*outbuf, fmt,
- ffmpegdec->format.audio.channels,
- ffmpegdec->format.audio.ffmpeg_layout,
- ffmpegdec->format.audio.gst_layout);
+ ffmpegdec->channels, ffmpegdec->ffmpeg_layout, ffmpegdec->gst_layout);
} else {
gst_buffer_unmap (*outbuf, &map);
gst_buffer_unref (*outbuf);
*outbuf = NULL;
}
- /* If we don't error out after the first failed read with the AAC decoder,
- * we must *not* carry on pushing data, else we'll cause segfaults... */
- if (len == -1 && (in_plugin->id == CODEC_ID_AAC
- || in_plugin->id == CODEC_ID_AAC_LATM)) {
- GST_ELEMENT_ERROR (ffmpegdec, STREAM, DECODE, (NULL),
- ("Decoding of AAC stream by libav failed."));
- *ret = GST_FLOW_ERROR;
- }
-
beach:
GST_DEBUG_OBJECT (ffmpegdec, "return flow %d, out %p, len %d",
*ret, *outbuf, len);
@@ -2382,7 +757,7 @@ clipped:
}
}
-/* gst_ffmpegdec_frame:
+/* gst_ffmpegauddec_frame:
* ffmpegdec:
* data: pointer to the data to decode
* size: size of data in bytes
@@ -2397,11 +772,11 @@ clipped:
*/
static gint
-gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
+gst_ffmpegauddec_frame (GstFFMpegAudDec * ffmpegdec,
guint8 * data, guint size, gint * got_data, const GstTSInfo * dec_info,
GstFlowReturn * ret)
{
- GstFFMpegDecClass *oclass;
+ GstFFMpegAudDecClass *oclass;
GstBuffer *outbuf = NULL;
gint have_data = 0, len = 0;
@@ -2414,31 +789,18 @@ gst_ffmpegdec_frame (GstFFMpegDec * ffmpegdec,
*ret = GST_FLOW_OK;
ffmpegdec->context->frame_number++;
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+ oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
- switch (oclass->in_plugin->type) {
- case AVMEDIA_TYPE_VIDEO:
- len =
- gst_ffmpegdec_video_frame (ffmpegdec, data, size, dec_info, &outbuf,
- ret);
- break;
- case AVMEDIA_TYPE_AUDIO:
- len =
- gst_ffmpegdec_audio_frame (ffmpegdec, oclass->in_plugin, data, size,
- dec_info, &outbuf, ret);
-
- /* if we did not get an output buffer and we have a pending discont, don't
- * clear the input timestamps, we will put them on the next buffer because
- * else we might create the first buffer with a very big timestamp gap. */
- if (outbuf == NULL && ffmpegdec->discont) {
- GST_DEBUG_OBJECT (ffmpegdec, "no buffer but keeping timestamp");
- ffmpegdec->clear_ts = FALSE;
- }
- break;
- default:
- GST_ERROR_OBJECT (ffmpegdec, "Asked to decode non-audio/video frame !");
- g_assert_not_reached ();
- break;
+ len =
+ gst_ffmpegauddec_audio_frame (ffmpegdec, oclass->in_plugin, data, size,
+ dec_info, &outbuf, ret);
+
+ /* if we did not get an output buffer and we have a pending discont, don't
+ * clear the input timestamps, we will put them on the next buffer because
+ * else we might create the first buffer with a very big timestamp gap. */
+ if (outbuf == NULL && ffmpegdec->discont) {
+ GST_DEBUG_OBJECT (ffmpegdec, "no buffer but keeping timestamp");
+ ffmpegdec->clear_ts = FALSE;
}
if (outbuf)
@@ -2496,11 +858,11 @@ no_codec:
}
static void
-gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec)
+gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec)
{
- GstFFMpegDecClass *oclass;
+ GstFFMpegAudDecClass *oclass;
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+ oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
gint have_data, len, try = 0;
@@ -2512,7 +874,7 @@ gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec)
GstFlowReturn ret;
len =
- gst_ffmpegdec_frame (ffmpegdec, NULL, 0, &have_data, &ts_info_none,
+ gst_ffmpegauddec_frame (ffmpegdec, NULL, 0, &have_data, &ts_info_none,
&ret);
if (len < 0 || have_data == 0)
break;
@@ -2525,7 +887,7 @@ gst_ffmpegdec_drain (GstFFMpegDec * ffmpegdec)
}
static void
-gst_ffmpegdec_flush_pcache (GstFFMpegDec * ffmpegdec)
+gst_ffmpegauddec_flush_pcache (GstFFMpegAudDec * ffmpegdec)
{
if (ffmpegdec->pctx) {
gint size, bsize;
@@ -2550,12 +912,12 @@ gst_ffmpegdec_flush_pcache (GstFFMpegDec * ffmpegdec)
}
static gboolean
-gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
+gst_ffmpegauddec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
- GstFFMpegDec *ffmpegdec;
+ GstFFMpegAudDec *ffmpegdec;
gboolean ret = FALSE;
- ffmpegdec = (GstFFMpegDec *) parent;
+ ffmpegdec = (GstFFMpegAudDec *) parent;
GST_DEBUG_OBJECT (ffmpegdec, "Handling %s event",
GST_EVENT_TYPE_NAME (event));
@@ -2563,7 +925,7 @@ gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
{
- gst_ffmpegdec_drain (ffmpegdec);
+ gst_ffmpegauddec_drain (ffmpegdec);
break;
}
case GST_EVENT_FLUSH_STOP:
@@ -2571,10 +933,8 @@ gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
if (ffmpegdec->opened) {
avcodec_flush_buffers (ffmpegdec->context);
}
- gst_ffmpegdec_reset_ts (ffmpegdec);
- gst_ffmpegdec_reset_qos (ffmpegdec);
- gst_ffmpegdec_flush_pcache (ffmpegdec);
- ffmpegdec->waiting_for_key = TRUE;
+ gst_ffmpegauddec_reset_ts (ffmpegdec);
+ gst_ffmpegauddec_flush_pcache (ffmpegdec);
gst_segment_init (&ffmpegdec->segment, GST_FORMAT_TIME);
clear_queued (ffmpegdec);
break;
@@ -2587,7 +947,7 @@ gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
if (!ffmpegdec->last_caps
|| !gst_caps_is_equal (ffmpegdec->last_caps, caps)) {
- ret = gst_ffmpegdec_setcaps (ffmpegdec, caps);
+ ret = gst_ffmpegauddec_setcaps (ffmpegdec, caps);
if (ret) {
gst_caps_replace (&ffmpegdec->last_caps, caps);
}
@@ -2647,11 +1007,6 @@ gst_ffmpegdec_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
goto invalid_format;
}
- /* drain pending frames before trying to use the new segment, queued
- * buffers belonged to the previous segment. */
- if (ffmpegdec->context->codec)
- gst_ffmpegdec_drain (ffmpegdec);
-
GST_DEBUG_OBJECT (ffmpegdec, "SEGMENT in time %" GST_SEGMENT_FORMAT,
&segment);
@@ -2686,12 +1041,12 @@ invalid_format:
}
static gboolean
-gst_ffmpegdec_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
+gst_ffmpegauddec_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
- GstFFMpegDec *ffmpegdec;
+ GstFFMpegAudDec *ffmpegdec;
gboolean ret = FALSE;
- ffmpegdec = (GstFFMpegDec *) parent;
+ ffmpegdec = (GstFFMpegAudDec *) parent;
GST_DEBUG_OBJECT (ffmpegdec, "Handling %s query",
GST_QUERY_TYPE_NAME (query));
@@ -2716,19 +1071,6 @@ gst_ffmpegdec_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
}
break;
}
- case GST_QUERY_ALLOCATION:
- {
- GstAllocationParams params;
-
- gst_allocation_params_init (&params);
- params.flags = GST_MEMORY_FLAG_ZERO_PADDED;
- params.padding = FF_INPUT_BUFFER_PADDING_SIZE;
- /* we would like to have some padding so that we don't have to
- * memcpy. We don't suggest an allocator. */
- gst_query_add_allocation_param (query, NULL, &params);
- ret = TRUE;
- break;
- }
default:
ret = gst_pad_query_default (pad, parent, query);
break;
@@ -2737,21 +1079,21 @@ gst_ffmpegdec_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
}
static GstFlowReturn
-gst_ffmpegdec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
+gst_ffmpegauddec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
{
- GstFFMpegDec *ffmpegdec;
- GstFFMpegDecClass *oclass;
+ GstFFMpegAudDec *ffmpegdec;
+ GstFFMpegAudDecClass *oclass;
guint8 *data, *bdata;
GstMapInfo map;
gint size, bsize, len, have_data;
GstFlowReturn ret = GST_FLOW_OK;
GstClockTime in_pts, in_dts, in_duration;
- gboolean discont, do_padding;
+ gboolean discont;
gint64 in_offset;
const GstTSInfo *in_info;
const GstTSInfo *dec_info;
- ffmpegdec = (GstFFMpegDec *) parent;
+ ffmpegdec = (GstFFMpegAudDec *) parent;
if (G_UNLIKELY (!ffmpegdec->opened))
goto not_negotiated;
@@ -2766,28 +1108,17 @@ gst_ffmpegdec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
if (G_UNLIKELY (discont)) {
GST_DEBUG_OBJECT (ffmpegdec, "received DISCONT");
/* drain what we have queued */
- gst_ffmpegdec_drain (ffmpegdec);
- gst_ffmpegdec_flush_pcache (ffmpegdec);
+ gst_ffmpegauddec_drain (ffmpegdec);
+ gst_ffmpegauddec_flush_pcache (ffmpegdec);
ffmpegdec->discont = TRUE;
- gst_ffmpegdec_reset_ts (ffmpegdec);
+ gst_ffmpegauddec_reset_ts (ffmpegdec);
}
/* by default we clear the input timestamp after decoding each frame so that
* interpollation can work. */
ffmpegdec->clear_ts = TRUE;
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+ oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
- /* do early keyframe check pretty bad to rely on the keyframe flag in the
- * source for this as it might not even be parsed (UDP/file/..). */
- if (G_UNLIKELY (ffmpegdec->waiting_for_key)) {
- GST_DEBUG_OBJECT (ffmpegdec, "waiting for keyframe");
- if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_DELTA_UNIT) &&
- oclass->in_plugin->type != AVMEDIA_TYPE_AUDIO)
- goto skip_keyframe;
-
- GST_DEBUG_OBJECT (ffmpegdec, "got keyframe");
- ffmpegdec->waiting_for_key = FALSE;
- }
/* parse cache joining. If there is cached data */
if (ffmpegdec->pcache) {
/* join with previous data */
@@ -2806,21 +1137,11 @@ gst_ffmpegdec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
in_info =
gst_ts_info_store (ffmpegdec, in_dts, in_pts, in_duration, in_offset);
- if (in_dts != -1) {
- GstClockTime diff;
- /* keep track of timestamp diff to estimate duration */
- diff = in_dts - ffmpegdec->last_dts;
- /* need to scale with amount of frames in the interval */
- if (ffmpegdec->last_frames)
- diff /= ffmpegdec->last_frames;
-
- GST_LOG_OBJECT (ffmpegdec, "estimated duration %" GST_TIME_FORMAT " %u",
- GST_TIME_ARGS (diff), ffmpegdec->last_frames);
-
- ffmpegdec->last_diff = diff;
- ffmpegdec->last_dts = in_dts;
- ffmpegdec->last_frames = 0;
- }
+ GST_LOG_OBJECT (ffmpegdec,
+ "Received new data of size %u, offset:%" G_GUINT64_FORMAT ", ts:%"
+ GST_TIME_FORMAT ", dur:%" GST_TIME_FORMAT ", info %d",
+ gst_buffer_get_size (inbuf), GST_BUFFER_OFFSET (inbuf),
+ GST_TIME_ARGS (in_pts), GST_TIME_ARGS (in_duration), in_info->idx);
/* workarounds, functions write to buffers:
* libavcodec/svq1.c:svq1_decode_frame writes to the given buffer.
@@ -2842,31 +1163,11 @@ gst_ffmpegdec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
", info %d", bsize, in_offset, GST_TIME_ARGS (in_dts),
GST_TIME_ARGS (in_pts), GST_TIME_ARGS (in_duration), in_info->idx);
- if (!GST_MEMORY_IS_ZERO_PADDED (map.memory)
- || (map.maxsize - map.size) < FF_INPUT_BUFFER_PADDING_SIZE) {
- /* add padding */
- if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) {
- ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE;
- ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size);
- GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d",
- ffmpegdec->padded_size);
- }
- GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec,
- "Copy input to add padding");
- memcpy (ffmpegdec->padded, bdata, bsize);
- memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
-
- bdata = ffmpegdec->padded;
- }
-
do {
- guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE];
-
/* parse, if at all possible */
if (ffmpegdec->pctx) {
gint res;
- do_padding = TRUE;
GST_LOG_OBJECT (ffmpegdec,
"Calling av_parser_parse2 with offset %" G_GINT64_FORMAT ", ts:%"
GST_TIME_FORMAT " size %d", in_offset, GST_TIME_ARGS (in_pts), bsize);
@@ -2913,28 +1214,16 @@ gst_ffmpegdec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
break;
}
} else {
- do_padding = FALSE;
data = bdata;
size = bsize;
dec_info = in_info;
}
- if (do_padding) {
- /* add temporary padding */
- GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec,
- "Add temporary input padding");
- memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE);
- memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
- }
-
- /* decode a frame of audio/video now */
+ /* decode a frame of audio now */
len =
- gst_ffmpegdec_frame (ffmpegdec, data, size, &have_data, dec_info, &ret);
-
- if (do_padding) {
- memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE);
- }
+ gst_ffmpegauddec_frame (ffmpegdec, data, size, &have_data, dec_info,
+ &ret);
if (ret != GST_FLOW_OK) {
GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s",
@@ -2985,8 +1274,6 @@ gst_ffmpegdec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
} else {
ffmpegdec->clear_ts = TRUE;
}
- ffmpegdec->last_frames++;
- do_padding = TRUE;
GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0). bsize:%d , bdata:%p",
bsize, bdata);
@@ -3021,25 +1308,19 @@ gst_ffmpegdec_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
/* ERRORS */
not_negotiated:
{
- oclass = (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+ oclass = (GstFFMpegAudDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
GST_ELEMENT_ERROR (ffmpegdec, CORE, NEGOTIATION, (NULL),
("avdec_%s: input format was not set before data start",
oclass->in_plugin->name));
gst_buffer_unref (inbuf);
return GST_FLOW_NOT_NEGOTIATED;
}
-skip_keyframe:
- {
- GST_DEBUG_OBJECT (ffmpegdec, "skipping non keyframe");
- gst_buffer_unref (inbuf);
- return GST_FLOW_OK;
- }
}
static GstStateChangeReturn
-gst_ffmpegdec_change_state (GstElement * element, GstStateChange transition)
+gst_ffmpegauddec_change_state (GstElement * element, GstStateChange transition)
{
- GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) element;
+ GstFFMpegAudDec *ffmpegdec = (GstFFMpegAudDec *) element;
GstStateChangeReturn ret;
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
@@ -3047,17 +1328,9 @@ gst_ffmpegdec_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
GST_OBJECT_LOCK (ffmpegdec);
- gst_ffmpegdec_close (ffmpegdec);
+ gst_ffmpegauddec_close (ffmpegdec);
GST_OBJECT_UNLOCK (ffmpegdec);
clear_queued (ffmpegdec);
- g_free (ffmpegdec->padded);
- ffmpegdec->padded = NULL;
- ffmpegdec->padded_size = 0;
- if (ffmpegdec->pool) {
- gst_buffer_pool_set_active (ffmpegdec->pool, FALSE);
- gst_object_unref (ffmpegdec->pool);
- }
- ffmpegdec->pool = NULL;
break;
default:
break;
@@ -3066,77 +1339,19 @@ gst_ffmpegdec_change_state (GstElement * element, GstStateChange transition)
return ret;
}
-static void
-gst_ffmpegdec_set_property (GObject * object,
- guint prop_id, const GValue * value, GParamSpec * pspec)
-{
- GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
-
- switch (prop_id) {
- case PROP_LOWRES:
- ffmpegdec->lowres = ffmpegdec->context->lowres = g_value_get_enum (value);
- break;
- case PROP_SKIPFRAME:
- ffmpegdec->skip_frame = ffmpegdec->context->skip_frame =
- g_value_get_enum (value);
- break;
- case PROP_DIRECT_RENDERING:
- ffmpegdec->direct_rendering = g_value_get_boolean (value);
- break;
- case PROP_DEBUG_MV:
- ffmpegdec->debug_mv = ffmpegdec->context->debug_mv =
- g_value_get_boolean (value);
- break;
- case PROP_MAX_THREADS:
- ffmpegdec->max_threads = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_ffmpegdec_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * pspec)
-{
- GstFFMpegDec *ffmpegdec = (GstFFMpegDec *) object;
-
- switch (prop_id) {
- case PROP_LOWRES:
- g_value_set_enum (value, ffmpegdec->context->lowres);
- break;
- case PROP_SKIPFRAME:
- g_value_set_enum (value, ffmpegdec->context->skip_frame);
- break;
- case PROP_DIRECT_RENDERING:
- g_value_set_boolean (value, ffmpegdec->direct_rendering);
- break;
- case PROP_DEBUG_MV:
- g_value_set_boolean (value, ffmpegdec->context->debug_mv);
- break;
- case PROP_MAX_THREADS:
- g_value_set_int (value, ffmpegdec->max_threads);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
gboolean
-gst_ffmpegdec_register (GstPlugin * plugin)
+gst_ffmpegauddec_register (GstPlugin * plugin)
{
GTypeInfo typeinfo = {
- sizeof (GstFFMpegDecClass),
- (GBaseInitFunc) gst_ffmpegdec_base_init,
+ sizeof (GstFFMpegAudDecClass),
+ (GBaseInitFunc) gst_ffmpegauddec_base_init,
NULL,
- (GClassInitFunc) gst_ffmpegdec_class_init,
+ (GClassInitFunc) gst_ffmpegauddec_class_init,
NULL,
NULL,
- sizeof (GstFFMpegDec),
+ sizeof (GstFFMpegAudDec),
0,
- (GInstanceInitFunc) gst_ffmpegdec_init,
+ (GInstanceInitFunc) gst_ffmpegauddec_init,
};
GType type;
AVCodec *in_plugin;
@@ -3151,17 +1366,13 @@ gst_ffmpegdec_register (GstPlugin * plugin)
gchar *plugin_name;
/* only decoders */
- if (!in_plugin->decode) {
+ if (!in_plugin->decode || in_plugin->type != AVMEDIA_TYPE_AUDIO) {
goto next;
}
/* no quasi-codecs, please */
- if (in_plugin->id == CODEC_ID_RAWVIDEO ||
- in_plugin->id == CODEC_ID_V210 ||
- in_plugin->id == CODEC_ID_V210X ||
- in_plugin->id == CODEC_ID_R210 ||
- (in_plugin->id >= CODEC_ID_PCM_S16LE &&
- in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
+ if (in_plugin->id >= CODEC_ID_PCM_S16LE &&
+ in_plugin->id <= CODEC_ID_PCM_BLURAY) {
goto next;
}
@@ -3175,33 +1386,13 @@ gst_ffmpegdec_register (GstPlugin * plugin)
goto next;
}
- /* No vdpau plugins until we can figure out how to properly use them
- * outside of ffmpeg. */
- if (g_str_has_suffix (in_plugin->name, "_vdpau")) {
- GST_DEBUG
- ("Ignoring VDPAU decoder %s. We can't handle this outside of libav",
- in_plugin->name);
- goto next;
- }
-
- if (g_str_has_suffix (in_plugin->name, "_xvmc")) {
- GST_DEBUG
- ("Ignoring XVMC decoder %s. We can't handle this outside of libav",
- in_plugin->name);
- goto next;
- }
-
GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
/* no codecs for which we're GUARANTEED to have better alternatives */
- /* MPEG1VIDEO : the mpeg2video decoder is preferred */
/* MP1 : Use MP3 for decoding */
/* MP2 : Use MP3 for decoding */
/* Theora: Use libtheora based theoradec */
- if (!strcmp (in_plugin->name, "gif") ||
- !strcmp (in_plugin->name, "vorbis") ||
- !strcmp (in_plugin->name, "theora") ||
- !strcmp (in_plugin->name, "mpeg1video") ||
+ if (!strcmp (in_plugin->name, "vorbis") ||
!strcmp (in_plugin->name, "wavpack") ||
!strcmp (in_plugin->name, "mp1") ||
!strcmp (in_plugin->name, "mp2") ||
@@ -3235,25 +1426,13 @@ gst_ffmpegdec_register (GstPlugin * plugin)
* msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
* VC1/WMV3 are not working and thus unpreferred for now. */
switch (in_plugin->id) {
- case CODEC_ID_MPEG4:
- case CODEC_ID_MSMPEG4V3:
- case CODEC_ID_H264:
case CODEC_ID_RA_144:
case CODEC_ID_RA_288:
- case CODEC_ID_RV10:
- case CODEC_ID_RV20:
- case CODEC_ID_RV30:
- case CODEC_ID_RV40:
case CODEC_ID_COOK:
rank = GST_RANK_PRIMARY;
break;
- /* DVVIDEO: we have a good dv decoder, fast on both ppc as well as x86.
- * They say libdv's quality is better though. leave as secondary.
- * note: if you change this, see the code in gstdv.c in good/ext/dv.
- *
- * SIPR: decoder should have a higher rank than realaudiodec.
+ /* SIPR: decoder should have a higher rank than realaudiodec.
*/
- case CODEC_ID_DVVIDEO:
case CODEC_ID_SIPR:
rank = GST_RANK_SECONDARY;
break;
diff --git a/ext/ffmpeg/gstffmpegdeinterlace.c b/ext/ffmpeg/gstffmpegdeinterlace.c
index 56aa1aa..69e1724 100644
--- a/ext/ffmpeg/gstffmpegdeinterlace.c
+++ b/ext/ffmpeg/gstffmpegdeinterlace.c
@@ -189,17 +189,22 @@ gst_ffmpegdeinterlace_sink_setcaps (GstPad * pad, GstCaps * caps)
GstFFMpegDeinterlace *deinterlace =
GST_FFMPEGDEINTERLACE (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
+ const gchar *imode;
AVCodecContext *ctx;
GstCaps *src_caps;
gboolean ret;
+ /* FIXME: use GstVideoInfo etc. */
if (!gst_structure_get_int (structure, "width", &deinterlace->width))
return FALSE;
if (!gst_structure_get_int (structure, "height", &deinterlace->height))
return FALSE;
deinterlace->interlaced = FALSE;
- gst_structure_get_boolean (structure, "interlaced", &deinterlace->interlaced);
+ imode = gst_structure_get_string (structure, "interlace-mode");
+ if (imode && (!strcmp (imode, "interleaved") || !strcmp (imode, "mixed"))) {
+ deinterlace->interlaced = TRUE;
+ }
gst_ffmpegdeinterlace_update_passthrough (deinterlace);
ctx = avcodec_alloc_context ();
@@ -221,8 +226,8 @@ gst_ffmpegdeinterlace_sink_setcaps (GstPad * pad, GstCaps * caps)
deinterlace->height);
src_caps = gst_caps_copy (caps);
- gst_caps_set_simple (src_caps, "interlaced", G_TYPE_BOOLEAN,
- deinterlace->interlaced, NULL);
+ gst_caps_set_simple (src_caps, "interlace-mode", G_TYPE_STRING,
+ deinterlace->interlaced ? "progressive" : imode, NULL);
ret = gst_pad_set_caps (deinterlace->srcpad, src_caps);
gst_caps_unref (src_caps);
diff --git a/ext/ffmpeg/gstffmpegdemux.c b/ext/ffmpeg/gstffmpegdemux.c
index 313237a..6ed40bb 100644
--- a/ext/ffmpeg/gstffmpegdemux.c
+++ b/ext/ffmpeg/gstffmpegdemux.c
@@ -267,7 +267,8 @@ gst_ffmpegdemux_init (GstFFMpegDemux * demux)
gst_pad_set_chain_function (demux->sinkpad,
GST_DEBUG_FUNCPTR (gst_ffmpegdemux_chain));
/* task for driving ffmpeg in loop function */
- demux->task = gst_task_new ((GstTaskFunction) gst_ffmpegdemux_loop, demux);
+ demux->task =
+ gst_task_new ((GstTaskFunction) gst_ffmpegdemux_loop, demux, NULL);
g_rec_mutex_init (&demux->task_lock);
gst_task_set_lock (demux->task, &demux->task_lock);
@@ -330,7 +331,7 @@ gst_ffmpegdemux_close (GstFFMpegDemux * demux)
if (stream->pad)
gst_element_remove_pad (GST_ELEMENT (demux), stream->pad);
if (stream->tags)
- gst_tag_list_free (stream->tags);
+ gst_tag_list_unref (stream->tags);
g_free (stream);
}
demux->streams[n] = NULL;
@@ -630,7 +631,7 @@ gst_ffmpegdemux_perform_seek (GstFFMpegDemux * demux, GstEvent * event)
/* and restart the task in case it got paused explicitely or by
* the FLUSH_START event we pushed out. */
gst_pad_start_task (demux->sinkpad, (GstTaskFunction) gst_ffmpegdemux_loop,
- demux->sinkpad);
+ demux->sinkpad, NULL);
/* and release the lock again so we can continue streaming */
GST_PAD_STREAM_UNLOCK (demux->sinkpad);
@@ -925,6 +926,7 @@ gst_ffmpegdemux_get_stream (GstFFMpegDemux * demux, AVStream * avstream)
const gchar *codec;
AVCodecContext *ctx;
GstFFStream *stream;
+ gchar *stream_id;
ctx = avstream->codec;
@@ -975,8 +977,6 @@ gst_ffmpegdemux_get_stream (GstFFMpegDemux * demux, AVStream * avstream)
gst_pad_use_fixed_caps (pad);
gst_pad_set_active (pad, TRUE);
- gst_pad_set_caps (pad, caps);
- gst_caps_unref (caps);
gst_pad_set_query_function (pad, gst_ffmpegdemux_src_query);
gst_pad_set_event_function (pad, gst_ffmpegdemux_src_event);
@@ -1001,6 +1001,16 @@ gst_ffmpegdemux_get_stream (GstFFMpegDemux * demux, AVStream * avstream)
demux->streams[avstream->index] = stream;
+
+ stream_id =
+ gst_pad_create_stream_id_printf (pad, GST_ELEMENT_CAST (demux), "%u",
+ avstream->index);
+ gst_pad_push_event (pad, gst_event_new_stream_start (stream_id));
+ g_free (stream_id);
+
+ gst_pad_set_caps (pad, caps);
+ gst_caps_unref (caps);
+
/* activate and add */
gst_element_add_pad (GST_ELEMENT (demux), pad);
@@ -1102,7 +1112,7 @@ gst_ffmpegdemux_read_tags (GstFFMpegDemux * demux)
}
if (!hastag) {
- gst_tag_list_free (tlist);
+ gst_tag_list_unref (tlist);
tlist = NULL;
}
return tlist;
@@ -1221,7 +1231,7 @@ gst_ffmpegdemux_open (GstFFMpegDemux * demux)
GST_INFO_OBJECT (stream->pad, "stream tags: %" GST_PTR_FORMAT,
stream->tags);
gst_pad_push_event (stream->pad,
- gst_event_new_tag ("GstDemuxer", gst_tag_list_copy (stream->tags)));
+ gst_event_new_tag (gst_tag_list_ref (stream->tags)));
}
}
@@ -1484,6 +1494,8 @@ pause:
gst_element_post_message (GST_ELEMENT (demux),
gst_message_new_segment_done (GST_OBJECT (demux),
demux->segment.format, stop));
+ gst_ffmpegdemux_push_event (demux,
+ gst_event_new_segment_done (demux->segment.format, stop));
} else {
GST_LOG_OBJECT (demux, "pushing eos");
gst_ffmpegdemux_push_event (demux, gst_event_new_eos ());
@@ -1778,7 +1790,7 @@ gst_ffmpegdemux_sink_activate_pull (GstPad * sinkpad, GstObject * parent,
if (active) {
demux->seekable = TRUE;
res = gst_pad_start_task (sinkpad, (GstTaskFunction) gst_ffmpegdemux_loop,
- demux);
+ demux, NULL);
} else {
res = gst_pad_stop_task (sinkpad);
demux->seekable = FALSE;
diff --git a/ext/ffmpeg/gstffmpegenc.c b/ext/ffmpeg/gstffmpegenc.c
index 9bc426e..be7bc41 100644
--- a/ext/ffmpeg/gstffmpegenc.c
+++ b/ext/ffmpeg/gstffmpegenc.c
@@ -40,18 +40,9 @@
#include "gstffmpegcodecmap.h"
#include "gstffmpegutils.h"
#include "gstffmpegenc.h"
-#include "gstffmpegcfg.h"
-#define DEFAULT_VIDEO_BITRATE 300000 /* in bps */
-#define DEFAULT_VIDEO_GOP_SIZE 15
#define DEFAULT_AUDIO_BITRATE 128000
-#define DEFAULT_WIDTH 352
-#define DEFAULT_HEIGHT 288
-
-
-#define VIDEO_BUFFER_SIZE (1024*1024)
-
enum
{
/* FILL ME */
@@ -62,76 +53,49 @@ enum
{
ARG_0,
ARG_BIT_RATE,
- ARG_GOP_SIZE,
- ARG_ME_METHOD,
ARG_BUFSIZE,
ARG_RTP_PAYLOAD_SIZE,
- ARG_CFG_BASE
};
-#define GST_TYPE_ME_METHOD (gst_ffmpegenc_me_method_get_type())
-static GType
-gst_ffmpegenc_me_method_get_type (void)
-{
- static GType ffmpegenc_me_method_type = 0;
- static GEnumValue ffmpegenc_me_methods[] = {
- {ME_ZERO, "None (Very low quality)", "zero"},
- {ME_FULL, "Full (Slow, unmaintained)", "full"},
- {ME_LOG, "Logarithmic (Low quality, unmaintained)", "logarithmic"},
- {ME_PHODS, "phods (Low quality, unmaintained)", "phods"},
- {ME_EPZS, "EPZS (Best quality, Fast)", "epzs"},
- {ME_X1, "X1 (Experimental)", "x1"},
- {0, NULL, NULL},
- };
- if (!ffmpegenc_me_method_type) {
- ffmpegenc_me_method_type =
- g_enum_register_static ("GstLibAVEncMeMethod", ffmpegenc_me_methods);
- }
- return ffmpegenc_me_method_type;
-}
-
/* A number of function prototypes are given so we can refer to them later. */
-static void gst_ffmpegenc_class_init (GstFFMpegEncClass * klass);
-static void gst_ffmpegenc_base_init (GstFFMpegEncClass * klass);
-static void gst_ffmpegenc_init (GstFFMpegEnc * ffmpegenc);
-static void gst_ffmpegenc_finalize (GObject * object);
+static void gst_ffmpegaudenc_class_init (GstFFMpegAudEncClass * klass);
+static void gst_ffmpegaudenc_base_init (GstFFMpegAudEncClass * klass);
+static void gst_ffmpegaudenc_init (GstFFMpegAudEnc * ffmpegaudenc);
+static void gst_ffmpegaudenc_finalize (GObject * object);
-static gboolean gst_ffmpegenc_setcaps (GstFFMpegEnc * ffmpegenc,
+static gboolean gst_ffmpegaudenc_setcaps (GstFFMpegAudEnc * ffmpegenc,
GstCaps * caps);
-static GstCaps *gst_ffmpegenc_getcaps (GstPad * pad, GstCaps * filter);
-static GstFlowReturn gst_ffmpegenc_chain_video (GstPad * pad,
- GstObject * parent, GstBuffer * buffer);
-static GstFlowReturn gst_ffmpegenc_chain_audio (GstPad * pad,
+static GstCaps *gst_ffmpegaudenc_getcaps (GstFFMpegAudEnc * ffmpegenc,
+ GstCaps * filter);
+static GstFlowReturn gst_ffmpegaudenc_chain_audio (GstPad * pad,
GstObject * parent, GstBuffer * buffer);
-static gboolean gst_ffmpegenc_event_sink (GstPad * pad, GstObject * parent,
- GstEvent * event);
-static gboolean gst_ffmpegenc_event_src (GstPad * pad, GstObject * parent,
- GstEvent * event);
-static gboolean gst_ffmpegenc_query_sink (GstPad * pad, GstObject * parent,
+static gboolean gst_ffmpegaudenc_query_sink (GstPad * pad, GstObject * parent,
GstQuery * query);
+static gboolean gst_ffmpegaudenc_event_sink (GstPad * pad, GstObject * parent,
+ GstEvent * event);
-static void gst_ffmpegenc_set_property (GObject * object,
+static void gst_ffmpegaudenc_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
-static void gst_ffmpegenc_get_property (GObject * object,
+static void gst_ffmpegaudenc_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
-static GstStateChangeReturn gst_ffmpegenc_change_state (GstElement * element,
+static GstStateChangeReturn gst_ffmpegaudenc_change_state (GstElement * element,
GstStateChange transition);
#define GST_FFENC_PARAMS_QDATA g_quark_from_static_string("avenc-params")
static GstElementClass *parent_class = NULL;
-/*static guint gst_ffmpegenc_signals[LAST_SIGNAL] = { 0 }; */
+/*static guint gst_ffmpegaudenc_signals[LAST_SIGNAL] = { 0 }; */
static void
-gst_ffmpegenc_base_init (GstFFMpegEncClass * klass)
+gst_ffmpegaudenc_base_init (GstFFMpegAudEncClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
AVCodec *in_plugin;
GstPadTemplate *srctempl = NULL, *sinktempl = NULL;
GstCaps *srccaps = NULL, *sinkcaps = NULL;
- gchar *longname, *classification, *description;
+ gchar *longname, *description;
in_plugin =
(AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
@@ -140,15 +104,12 @@ gst_ffmpegenc_base_init (GstFFMpegEncClass * klass)
/* construct the element details struct */
longname = g_strdup_printf ("libav %s encoder", in_plugin->long_name);
- classification = g_strdup_printf ("Codec/Encoder/%s",
- (in_plugin->type == AVMEDIA_TYPE_VIDEO) ? "Video" : "Audio");
description = g_strdup_printf ("libav %s encoder", in_plugin->name);
gst_element_class_set_metadata (element_class, longname,
- classification, description,
+ "Codec/Encoder/Audio", description,
"Wim Taymans <wim.taymans@gmail.com>, "
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
g_free (longname);
- g_free (classification);
g_free (description);
if (!(srccaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, TRUE))) {
@@ -156,12 +117,8 @@ gst_ffmpegenc_base_init (GstFFMpegEncClass * klass)
srccaps = gst_caps_new_empty_simple ("unknown/unknown");
}
- if (in_plugin->type == AVMEDIA_TYPE_VIDEO) {
- sinkcaps = gst_caps_from_string ("video/x-raw");
- } else {
- sinkcaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
- in_plugin->id, TRUE, in_plugin);
- }
+ sinkcaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
+ in_plugin->id, TRUE, in_plugin);
if (!sinkcaps) {
GST_DEBUG ("Couldn't get sink caps for encoder '%s'", in_plugin->name);
sinkcaps = gst_caps_new_empty_simple ("unknown/unknown");
@@ -184,7 +141,7 @@ gst_ffmpegenc_base_init (GstFFMpegEncClass * klass)
}
static void
-gst_ffmpegenc_class_init (GstFFMpegEncClass * klass)
+gst_ffmpegaudenc_class_init (GstFFMpegAudEncClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@@ -194,534 +151,184 @@ gst_ffmpegenc_class_init (GstFFMpegEncClass * klass)
parent_class = g_type_class_peek_parent (klass);
- gobject_class->set_property = gst_ffmpegenc_set_property;
- gobject_class->get_property = gst_ffmpegenc_get_property;
-
- if (klass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE,
- g_param_spec_ulong ("bitrate", "Bit Rate",
- "Target Video Bitrate", 0, G_MAXULONG, DEFAULT_VIDEO_BITRATE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GOP_SIZE,
- g_param_spec_int ("gop-size", "GOP Size",
- "Number of frames within one GOP", 0, G_MAXINT,
- DEFAULT_VIDEO_GOP_SIZE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ME_METHOD,
- g_param_spec_enum ("me-method", "ME Method", "Motion Estimation Method",
- GST_TYPE_ME_METHOD, ME_EPZS,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /* FIXME 0.11: Make this property read-only */
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
- g_param_spec_ulong ("buffer-size", "Buffer Size",
- "Size of the video buffers. "
- "Note: Setting this property has no effect "
- "and is deprecated!", 0, G_MAXULONG, 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (G_OBJECT_CLASS (klass),
- ARG_RTP_PAYLOAD_SIZE, g_param_spec_ulong ("rtp-payload-size",
- "RTP Payload Size", "Target GOB length", 0, G_MAXULONG, 0,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- /* register additional properties, possibly dependent on the exact CODEC */
- gst_ffmpeg_cfg_install_property (klass, ARG_CFG_BASE);
- } else if (klass->in_plugin->type == AVMEDIA_TYPE_AUDIO) {
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE,
- g_param_spec_ulong ("bitrate", "Bit Rate",
- "Target Audio Bitrate", 0, G_MAXULONG, DEFAULT_AUDIO_BITRATE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- }
+ gobject_class->set_property = gst_ffmpegaudenc_set_property;
+ gobject_class->get_property = gst_ffmpegaudenc_get_property;
- gstelement_class->change_state = gst_ffmpegenc_change_state;
+ /* FIXME: could use -1 for a sensible per-codec defaults */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE,
+ g_param_spec_int ("bitrate", "Bit Rate",
+ "Target Audio Bitrate", 0, G_MAXINT, DEFAULT_AUDIO_BITRATE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gobject_class->finalize = gst_ffmpegenc_finalize;
+ gstelement_class->change_state = gst_ffmpegaudenc_change_state;
+
+ gobject_class->finalize = gst_ffmpegaudenc_finalize;
}
static void
-gst_ffmpegenc_init (GstFFMpegEnc * ffmpegenc)
+gst_ffmpegaudenc_init (GstFFMpegAudEnc * ffmpegaudenc)
{
- GstFFMpegEncClass *oclass =
- (GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
+ GstFFMpegAudEncClass *oclass =
+ (GstFFMpegAudEncClass *) (G_OBJECT_GET_CLASS (ffmpegaudenc));
/* setup pads */
- ffmpegenc->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
- gst_pad_set_query_function (ffmpegenc->sinkpad, gst_ffmpegenc_query_sink);
- ffmpegenc->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
- gst_pad_use_fixed_caps (ffmpegenc->srcpad);
-
- /* ffmpeg objects */
- ffmpegenc->context = avcodec_alloc_context ();
- ffmpegenc->picture = avcodec_alloc_frame ();
- ffmpegenc->opened = FALSE;
-
- ffmpegenc->file = NULL;
- ffmpegenc->delay = g_queue_new ();
-
- gst_pad_set_event_function (ffmpegenc->sinkpad, gst_ffmpegenc_event_sink);
-
- if (oclass->in_plugin->type == AVMEDIA_TYPE_VIDEO) {
- gst_pad_set_chain_function (ffmpegenc->sinkpad, gst_ffmpegenc_chain_video);
- /* so we know when to flush the buffers on EOS */
- gst_pad_set_event_function (ffmpegenc->srcpad, gst_ffmpegenc_event_src);
-
- ffmpegenc->bitrate = DEFAULT_VIDEO_BITRATE;
- ffmpegenc->me_method = ME_EPZS;
- ffmpegenc->buffer_size = 512 * 1024;
- ffmpegenc->gop_size = DEFAULT_VIDEO_GOP_SIZE;
- ffmpegenc->rtp_payload_size = 0;
-
- ffmpegenc->lmin = 2;
- ffmpegenc->lmax = 31;
- ffmpegenc->max_key_interval = 0;
+ ffmpegaudenc->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink");
+ gst_pad_set_event_function (ffmpegaudenc->sinkpad,
+ gst_ffmpegaudenc_event_sink);
+ gst_pad_set_query_function (ffmpegaudenc->sinkpad,
+ gst_ffmpegaudenc_query_sink);
+ gst_pad_set_chain_function (ffmpegaudenc->sinkpad,
+ gst_ffmpegaudenc_chain_audio);
- gst_ffmpeg_cfg_set_defaults (ffmpegenc);
- } else if (oclass->in_plugin->type == AVMEDIA_TYPE_AUDIO) {
- gst_pad_set_chain_function (ffmpegenc->sinkpad, gst_ffmpegenc_chain_audio);
+ ffmpegaudenc->srcpad = gst_pad_new_from_template (oclass->srctempl, "src");
+ gst_pad_use_fixed_caps (ffmpegaudenc->srcpad);
- ffmpegenc->bitrate = DEFAULT_AUDIO_BITRATE;
- }
+ /* ffmpeg objects */
+ ffmpegaudenc->context = avcodec_alloc_context ();
+ ffmpegaudenc->opened = FALSE;
- gst_element_add_pad (GST_ELEMENT (ffmpegenc), ffmpegenc->sinkpad);
- gst_element_add_pad (GST_ELEMENT (ffmpegenc), ffmpegenc->srcpad);
+ gst_element_add_pad (GST_ELEMENT (ffmpegaudenc), ffmpegaudenc->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (ffmpegaudenc), ffmpegaudenc->srcpad);
- ffmpegenc->adapter = gst_adapter_new ();
+ ffmpegaudenc->adapter = gst_adapter_new ();
}
static void
-gst_ffmpegenc_finalize (GObject * object)
+gst_ffmpegaudenc_finalize (GObject * object)
{
- GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) object;
+ GstFFMpegAudEnc *ffmpegaudenc = (GstFFMpegAudEnc *) object;
- gst_ffmpeg_cfg_finalize (ffmpegenc);
/* close old session */
- if (ffmpegenc->opened) {
- gst_ffmpeg_avcodec_close (ffmpegenc->context);
- ffmpegenc->opened = FALSE;
+ if (ffmpegaudenc->opened) {
+ gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
+ ffmpegaudenc->opened = FALSE;
}
/* clean up remaining allocated data */
- av_free (ffmpegenc->context);
- av_free (ffmpegenc->picture);
-
- g_queue_free (ffmpegenc->delay);
- g_free (ffmpegenc->filename);
+ av_free (ffmpegaudenc->context);
- g_object_unref (ffmpegenc->adapter);
+ g_object_unref (ffmpegaudenc->adapter);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GstCaps *
-gst_ffmpegenc_get_possible_sizes (GstFFMpegEnc * ffmpegenc, GstPad * pad,
- GstCaps * caps)
-{
- GstCaps *templ, *othercaps = NULL;
- GstCaps *tmpcaps = NULL;
- GstCaps *intersect = NULL;
- guint i;
-
- othercaps = gst_pad_peer_query_caps (ffmpegenc->srcpad, NULL);
-
- if (!othercaps)
- return gst_caps_ref (caps);
-
- templ = gst_pad_get_pad_template_caps (ffmpegenc->srcpad);
- intersect = gst_caps_intersect (othercaps, templ);
- gst_caps_unref (othercaps);
- gst_caps_unref (templ);
-
- if (gst_caps_is_empty (intersect))
- return intersect;
-
- if (gst_caps_is_any (intersect))
- return gst_caps_ref (caps);
-
- tmpcaps = gst_caps_new_empty ();
-
- for (i = 0; i < gst_caps_get_size (intersect); i++) {
- GstStructure *s = gst_caps_get_structure (intersect, i);
- const GValue *height = NULL;
- const GValue *width = NULL;
- const GValue *framerate = NULL;
- GstStructure *tmps;
-
- height = gst_structure_get_value (s, "height");
- width = gst_structure_get_value (s, "width");
- framerate = gst_structure_get_value (s, "framerate");
-
- tmps = gst_structure_new_empty ("video/x-raw");
- if (width)
- gst_structure_set_value (tmps, "width", width);
- if (height)
- gst_structure_set_value (tmps, "height", height);
- if (framerate)
- gst_structure_set_value (tmps, "framerate", framerate);
-
- tmpcaps = gst_caps_merge_structure (tmpcaps, tmps);
- }
- gst_caps_unref (intersect);
-
- intersect = gst_caps_intersect (caps, tmpcaps);
- gst_caps_unref (tmpcaps);
-
- return intersect;
-}
-
-
-static GstCaps *
-gst_ffmpegenc_getcaps (GstPad * pad, GstCaps * filter)
+gst_ffmpegaudenc_getcaps (GstFFMpegAudEnc * ffmpegaudenc, GstCaps * filter)
{
- GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) GST_PAD_PARENT (pad);
- GstFFMpegEncClass *oclass =
- (GstFFMpegEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
- AVCodecContext *ctx = NULL;
- enum PixelFormat pixfmt;
- GstCaps *templ, *caps = NULL;
- GstCaps *finalcaps = NULL;
- gint i;
+ GstCaps *caps = NULL;
- GST_DEBUG_OBJECT (ffmpegenc, "getting caps, filter %" GST_PTR_FORMAT, filter);
+ GST_DEBUG_OBJECT (ffmpegaudenc, "getting caps");
/* audio needs no special care */
- if (oclass->in_plugin->type == AVMEDIA_TYPE_AUDIO) {
- templ = gst_pad_get_pad_template_caps (pad);
- if (filter) {
- caps = gst_caps_intersect_full (filter, templ, GST_CAPS_INTERSECT_FIRST);
- gst_caps_unref (templ);
- } else
- caps = templ;
-
- GST_DEBUG_OBJECT (ffmpegenc, "audio caps, return intersected template %"
- GST_PTR_FORMAT, caps);
-
- return caps;
- }
-
- /* cached */
- if (oclass->sinkcaps) {
- caps = gst_ffmpegenc_get_possible_sizes (ffmpegenc, pad, oclass->sinkcaps);
- if (filter) {
- finalcaps =
- gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
- gst_caps_unref (caps);
- } else {
- finalcaps = caps;
- }
- GST_DEBUG_OBJECT (ffmpegenc,
- "return intersected cached caps %" GST_PTR_FORMAT, finalcaps);
- return finalcaps;
- }
-
- /* create cache etc. */
-
- /* shut up the logging while we autoprobe; we don't want warnings and
- * errors about unsupported formats */
- /* FIXME: if someone cares about this disabling the logging for other
- * instances/threads/..., one could investigate if there is a way to
- * set this as a struct member on the av context, and check it from the
- * log handler */
-#ifndef GST_DISABLE_GST_DEBUG
- _shut_up_I_am_probing = TRUE;
-#endif
- GST_DEBUG_OBJECT (ffmpegenc, "probing caps");
- i = pixfmt = 0;
- /* check pixfmt until deemed finished */
- for (pixfmt = 0;; pixfmt++) {
- GstCaps *tmpcaps;
-
- /* override looping all pixfmt if codec declares pixfmts;
- * these may not properly check and report supported pixfmt during _init */
- if (oclass->in_plugin->pix_fmts) {
- if ((pixfmt = oclass->in_plugin->pix_fmts[i++]) == PIX_FMT_NONE) {
- GST_DEBUG_OBJECT (ffmpegenc,
- "At the end of official pixfmt for this codec, breaking out");
- break;
- }
- GST_DEBUG_OBJECT (ffmpegenc,
- "Got an official pixfmt [%d], attempting to get caps", pixfmt);
- tmpcaps = gst_ffmpeg_pixfmt_to_caps (pixfmt, NULL, oclass->in_plugin->id);
- if (tmpcaps) {
- GST_DEBUG_OBJECT (ffmpegenc, "Got caps, breaking out");
- if (!caps)
- caps = gst_caps_new_empty ();
- gst_caps_append (caps, tmpcaps);
- continue;
- }
- GST_DEBUG_OBJECT (ffmpegenc,
- "Couldn't figure out caps without context, trying again with a context");
- }
-
- GST_DEBUG_OBJECT (ffmpegenc, "pixfmt :%d", pixfmt);
- if (pixfmt >= PIX_FMT_NB) {
- GST_WARNING ("Invalid pixfmt, breaking out");
- break;
- }
-
- /* need to start with a fresh codec_context each time around, since
- * codec_close may have released stuff causing the next pass to segfault */
- ctx = avcodec_alloc_context ();
- if (!ctx) {
- GST_DEBUG_OBJECT (ffmpegenc, "no context");
- break;
- }
-
- /* set some default properties */
- ctx->width = DEFAULT_WIDTH;
- ctx->height = DEFAULT_HEIGHT;
- ctx->time_base.num = 1;
- ctx->time_base.den = 25;
- ctx->ticks_per_frame = 1;
- ctx->bit_rate = DEFAULT_VIDEO_BITRATE;
- /* makes it silent */
- ctx->strict_std_compliance = -1;
-
- ctx->pix_fmt = pixfmt;
-
- GST_DEBUG ("Attempting to open codec");
- if (gst_ffmpeg_avcodec_open (ctx, oclass->in_plugin) >= 0 &&
- ctx->pix_fmt == pixfmt) {
- ctx->width = -1;
- if (!caps)
- caps = gst_caps_new_empty ();
- tmpcaps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type, ctx,
- oclass->in_plugin->id, TRUE);
- if (tmpcaps)
- gst_caps_append (caps, tmpcaps);
- else
- GST_LOG_OBJECT (ffmpegenc,
- "Couldn't get caps for oclass->in_plugin->name:%s",
- oclass->in_plugin->name);
- gst_ffmpeg_avcodec_close (ctx);
- } else {
- GST_DEBUG_OBJECT (ffmpegenc, "Opening codec failed with pixfmt : %d",
- pixfmt);
- }
- if (ctx->priv_data)
- gst_ffmpeg_avcodec_close (ctx);
- av_free (ctx);
- }
-#ifndef GST_DISABLE_GST_DEBUG
- _shut_up_I_am_probing = FALSE;
-#endif
-
- /* make sure we have something */
- if (!caps) {
- templ = gst_pad_get_pad_template_caps (pad);
- caps = gst_ffmpegenc_get_possible_sizes (ffmpegenc, pad, templ);
- gst_caps_unref (templ);
- if (filter) {
- finalcaps =
- gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
- gst_caps_unref (caps);
- } else {
- finalcaps = caps;
- }
- GST_DEBUG_OBJECT (ffmpegenc, "probing gave nothing, "
- "return intersected template %" GST_PTR_FORMAT, finalcaps);
- return finalcaps;
- }
-
- GST_DEBUG_OBJECT (ffmpegenc, "probed caps gave %" GST_PTR_FORMAT, caps);
- oclass->sinkcaps = caps;
-
- finalcaps =
- gst_ffmpegenc_get_possible_sizes (ffmpegenc, pad, oclass->sinkcaps);
+ caps = gst_pad_get_pad_template_caps (ffmpegaudenc->sinkpad);
if (filter) {
- caps = finalcaps;
- finalcaps =
- gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
+ GstCaps *tmp;
+ tmp = gst_caps_intersect_full (filter, caps, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (caps);
+ caps = tmp;
}
- return finalcaps;
+ GST_DEBUG_OBJECT (ffmpegaudenc,
+ "audio caps, return template %" GST_PTR_FORMAT, caps);
+
+ return caps;
}
static gboolean
-gst_ffmpegenc_setcaps (GstFFMpegEnc * ffmpegenc, GstCaps * caps)
+gst_ffmpegaudenc_setcaps (GstFFMpegAudEnc * ffmpegaudenc, GstCaps * caps)
{
GstCaps *other_caps;
GstCaps *allowed_caps;
GstCaps *icaps;
- enum PixelFormat pix_fmt;
- GstFFMpegEncClass *oclass =
- (GstFFMpegEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
+ GstFFMpegAudEncClass *oclass =
+ (GstFFMpegAudEncClass *) G_OBJECT_GET_CLASS (ffmpegaudenc);
/* close old session */
- if (ffmpegenc->opened) {
- gst_ffmpeg_avcodec_close (ffmpegenc->context);
- ffmpegenc->opened = FALSE;
+ if (ffmpegaudenc->opened) {
+ gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
+ ffmpegaudenc->opened = FALSE;
+ /* fixed src caps;
+ * so clear src caps for proper (re-)negotiation */
+ gst_pad_set_caps (ffmpegaudenc->srcpad, NULL);
}
/* set defaults */
- avcodec_get_context_defaults (ffmpegenc->context);
+ avcodec_get_context_defaults (ffmpegaudenc->context);
/* if we set it in _getcaps we should set it also in _link */
- ffmpegenc->context->strict_std_compliance = -1;
+ ffmpegaudenc->context->strict_std_compliance = -1;
/* user defined properties */
- ffmpegenc->context->bit_rate = ffmpegenc->bitrate;
- ffmpegenc->context->bit_rate_tolerance = ffmpegenc->bitrate;
- ffmpegenc->context->gop_size = ffmpegenc->gop_size;
- ffmpegenc->context->me_method = ffmpegenc->me_method;
- GST_DEBUG_OBJECT (ffmpegenc, "Setting avcontext to bitrate %lu, gop_size %d",
- ffmpegenc->bitrate, ffmpegenc->gop_size);
-
- /* RTP payload used for GOB production (for Asterisk) */
- if (ffmpegenc->rtp_payload_size) {
- ffmpegenc->context->rtp_payload_size = ffmpegenc->rtp_payload_size;
+ if (ffmpegaudenc->bitrate > 0) {
+ GST_INFO_OBJECT (ffmpegaudenc, "Setting avcontext to bitrate %d",
+ ffmpegaudenc->bitrate);
+ ffmpegaudenc->context->bit_rate = ffmpegaudenc->bitrate;
+ ffmpegaudenc->context->bit_rate_tolerance = ffmpegaudenc->bitrate;
+ } else {
+ GST_INFO_OBJECT (ffmpegaudenc, "Using avcontext default bitrate %d",
+ ffmpegaudenc->context->bit_rate);
}
- /* additional avcodec settings */
- /* first fill in the majority by copying over */
- gst_ffmpeg_cfg_fill_context (ffmpegenc, ffmpegenc->context);
-
- /* then handle some special cases */
- ffmpegenc->context->lmin = (ffmpegenc->lmin * FF_QP2LAMBDA + 0.5);
- ffmpegenc->context->lmax = (ffmpegenc->lmax * FF_QP2LAMBDA + 0.5);
-
- if (ffmpegenc->interlaced) {
- ffmpegenc->context->flags |=
- CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME;
- ffmpegenc->picture->interlaced_frame = TRUE;
- /* if this is not the case, a filter element should be used to swap fields */
- ffmpegenc->picture->top_field_first = TRUE;
+ /* RTP payload used for GOB production (for Asterisk) */
+ if (ffmpegaudenc->rtp_payload_size) {
+ ffmpegaudenc->context->rtp_payload_size = ffmpegaudenc->rtp_payload_size;
}
/* some other defaults */
- ffmpegenc->context->rc_strategy = 2;
- ffmpegenc->context->b_frame_strategy = 0;
- ffmpegenc->context->coder_type = 0;
- ffmpegenc->context->context_model = 0;
- ffmpegenc->context->scenechange_threshold = 0;
- ffmpegenc->context->inter_threshold = 0;
-
- /* and last but not least the pass; CBR, 2-pass, etc */
- ffmpegenc->context->flags |= ffmpegenc->pass;
- switch (ffmpegenc->pass) {
- /* some additional action depends on type of pass */
- case CODEC_FLAG_QSCALE:
- ffmpegenc->context->global_quality
- = ffmpegenc->picture->quality = FF_QP2LAMBDA * ffmpegenc->quantizer;
- break;
- case CODEC_FLAG_PASS1: /* need to prepare a stats file */
- /* we don't close when changing caps, fingers crossed */
- if (!ffmpegenc->file)
- ffmpegenc->file = g_fopen (ffmpegenc->filename, "w");
- if (!ffmpegenc->file) {
- GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, OPEN_WRITE,
- (("Could not open file \"%s\" for writing."), ffmpegenc->filename),
- GST_ERROR_SYSTEM);
- return FALSE;
- }
- break;
- case CODEC_FLAG_PASS2:
- { /* need to read the whole stats file ! */
- gsize size;
-
- if (!g_file_get_contents (ffmpegenc->filename,
- &ffmpegenc->context->stats_in, &size, NULL)) {
- GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, READ,
- (("Could not get contents of file \"%s\"."), ffmpegenc->filename),
- GST_ERROR_SYSTEM);
- return FALSE;
- }
+ ffmpegaudenc->context->rc_strategy = 2;
+ ffmpegaudenc->context->b_frame_strategy = 0;
+ ffmpegaudenc->context->coder_type = 0;
+ ffmpegaudenc->context->context_model = 0;
+ ffmpegaudenc->context->scenechange_threshold = 0;
+ ffmpegaudenc->context->inter_threshold = 0;
- break;
- }
- default:
- break;
- }
/* fetch pix_fmt and so on */
gst_ffmpeg_caps_with_codectype (oclass->in_plugin->type,
- caps, ffmpegenc->context);
- if (!ffmpegenc->context->time_base.den) {
- ffmpegenc->context->time_base.den = 25;
- ffmpegenc->context->time_base.num = 1;
- ffmpegenc->context->ticks_per_frame = 1;
- } else if ((oclass->in_plugin->id == CODEC_ID_MPEG4)
- && (ffmpegenc->context->time_base.den > 65535)) {
- /* MPEG4 Standards do not support time_base denominator greater than
- * (1<<16) - 1 . We therefore scale them down.
- * Agreed, it will not be the exact framerate... but the difference
- * shouldn't be that noticeable */
- ffmpegenc->context->time_base.num =
- (gint) gst_util_uint64_scale_int (ffmpegenc->context->time_base.num,
- 65535, ffmpegenc->context->time_base.den);
- ffmpegenc->context->time_base.den = 65535;
- GST_LOG_OBJECT (ffmpegenc, "MPEG4 : scaled down framerate to %d / %d",
- ffmpegenc->context->time_base.den, ffmpegenc->context->time_base.num);
- }
-
- pix_fmt = ffmpegenc->context->pix_fmt;
-
- /* max-key-interval may need the framerate set above */
- if (ffmpegenc->max_key_interval) {
- AVCodecContext *ctx;
-
- /* override gop-size */
- ctx = ffmpegenc->context;
- ctx->gop_size = (ffmpegenc->max_key_interval < 0) ?
- (-ffmpegenc->max_key_interval
- * (ctx->time_base.den * ctx->ticks_per_frame / ctx->time_base.num))
- : ffmpegenc->max_key_interval;
+ caps, ffmpegaudenc->context);
+ if (!ffmpegaudenc->context->time_base.den) {
+ ffmpegaudenc->context->time_base.den = 25;
+ ffmpegaudenc->context->time_base.num = 1;
+ ffmpegaudenc->context->ticks_per_frame = 1;
}
/* open codec */
- if (gst_ffmpeg_avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) {
- if (ffmpegenc->context->priv_data)
- gst_ffmpeg_avcodec_close (ffmpegenc->context);
- if (ffmpegenc->context->stats_in)
- g_free (ffmpegenc->context->stats_in);
- GST_DEBUG_OBJECT (ffmpegenc, "avenc_%s: Failed to open libav codec",
+ if (gst_ffmpeg_avcodec_open (ffmpegaudenc->context, oclass->in_plugin) < 0) {
+ if (ffmpegaudenc->context->priv_data)
+ gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
+ if (ffmpegaudenc->context->stats_in)
+ g_free (ffmpegaudenc->context->stats_in);
+ GST_DEBUG_OBJECT (ffmpegaudenc, "avenc_%s: Failed to open FFMPEG codec",
oclass->in_plugin->name);
return FALSE;
}
/* second pass stats buffer no longer needed */
- if (ffmpegenc->context->stats_in)
- g_free (ffmpegenc->context->stats_in);
-
- /* is the colourspace correct? */
- if (pix_fmt != ffmpegenc->context->pix_fmt) {
- gst_ffmpeg_avcodec_close (ffmpegenc->context);
- GST_DEBUG_OBJECT (ffmpegenc,
- "avenc_%s: AV wants different colourspace (%d given, %d wanted)",
- oclass->in_plugin->name, pix_fmt, ffmpegenc->context->pix_fmt);
- return FALSE;
- }
- /* we may have failed mapping caps to a pixfmt,
- * and quite some codecs do not make up their own mind about that
- * in any case, _NONE can never work out later on */
- if (oclass->in_plugin->type == AVMEDIA_TYPE_VIDEO && pix_fmt == PIX_FMT_NONE) {
- GST_DEBUG_OBJECT (ffmpegenc, "avenc_%s: Failed to determine input format",
- oclass->in_plugin->name);
- return FALSE;
- }
+ if (ffmpegaudenc->context->stats_in)
+ g_free (ffmpegaudenc->context->stats_in);
/* some codecs support more than one format, first auto-choose one */
- GST_DEBUG_OBJECT (ffmpegenc, "picking an output format ...");
- allowed_caps = gst_pad_get_allowed_caps (ffmpegenc->srcpad);
+ GST_DEBUG_OBJECT (ffmpegaudenc, "picking an output format ...");
+ allowed_caps = gst_pad_get_allowed_caps (ffmpegaudenc->srcpad);
if (!allowed_caps) {
- GST_DEBUG_OBJECT (ffmpegenc, "... but no peer, using template caps");
+ GST_DEBUG_OBJECT (ffmpegaudenc, "... but no peer, using template caps");
/* we need to copy because get_allowed_caps returns a ref, and
* get_pad_template_caps doesn't */
- allowed_caps = gst_pad_get_pad_template_caps (ffmpegenc->srcpad);
+ allowed_caps = gst_pad_get_pad_template_caps (ffmpegaudenc->srcpad);
}
- GST_DEBUG_OBJECT (ffmpegenc, "chose caps %" GST_PTR_FORMAT, allowed_caps);
+ GST_DEBUG_OBJECT (ffmpegaudenc, "chose caps %" GST_PTR_FORMAT, allowed_caps);
gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
- oclass->in_plugin->type, allowed_caps, ffmpegenc->context);
+ oclass->in_plugin->type, allowed_caps, ffmpegaudenc->context);
/* try to set this caps on the other side */
other_caps = gst_ffmpeg_codecid_to_caps (oclass->in_plugin->id,
- ffmpegenc->context, TRUE);
+ ffmpegaudenc->context, TRUE);
if (!other_caps) {
gst_caps_unref (allowed_caps);
- gst_ffmpeg_avcodec_close (ffmpegenc->context);
+ gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
GST_DEBUG ("Unsupported codec - no caps found");
return FALSE;
}
@@ -744,146 +351,23 @@ gst_ffmpegenc_setcaps (GstFFMpegEnc * ffmpegenc, GstCaps * caps)
icaps = newcaps;
}
- if (!gst_pad_set_caps (ffmpegenc->srcpad, icaps)) {
- gst_ffmpeg_avcodec_close (ffmpegenc->context);
+ if (!gst_pad_set_caps (ffmpegaudenc->srcpad, icaps)) {
+ gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
gst_caps_unref (icaps);
return FALSE;
}
gst_caps_unref (icaps);
/* success! */
- ffmpegenc->opened = TRUE;
+ ffmpegaudenc->opened = TRUE;
return TRUE;
}
-static void
-ffmpegenc_setup_working_buf (GstFFMpegEnc * ffmpegenc)
-{
- guint wanted_size =
- ffmpegenc->context->width * ffmpegenc->context->height * 6 +
- FF_MIN_BUFFER_SIZE;
-
- /* Above is the buffer size used by ffmpeg/ffmpeg.c */
-
- if (ffmpegenc->working_buf == NULL ||
- ffmpegenc->working_buf_size != wanted_size) {
- if (ffmpegenc->working_buf)
- g_free (ffmpegenc->working_buf);
- ffmpegenc->working_buf_size = wanted_size;
- ffmpegenc->working_buf = g_malloc (ffmpegenc->working_buf_size);
- }
- ffmpegenc->buffer_size = wanted_size;
-}
static GstFlowReturn
-gst_ffmpegenc_chain_video (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
-{
- GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) parent;
- GstBuffer *outbuf;
- GstMapInfo map;
- gint ret_size = 0, frame_size;
- gboolean force_keyframe;
-
- if (G_UNLIKELY (!ffmpegenc->opened))
- goto not_negotiated;
-
- GST_DEBUG_OBJECT (ffmpegenc,
- "Received buffer of time %" GST_TIME_FORMAT,
- GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)));
-
- GST_OBJECT_LOCK (ffmpegenc);
- force_keyframe = ffmpegenc->force_keyframe;
- ffmpegenc->force_keyframe = FALSE;
- GST_OBJECT_UNLOCK (ffmpegenc);
-
- if (force_keyframe)
- ffmpegenc->picture->pict_type = FF_I_TYPE;
-
- gst_buffer_map (inbuf, &map, GST_MAP_READ);
- frame_size = gst_ffmpeg_avpicture_fill ((AVPicture *) ffmpegenc->picture,
- map.data,
- ffmpegenc->context->pix_fmt,
- ffmpegenc->context->width, ffmpegenc->context->height);
- g_return_val_if_fail (frame_size == map.size, GST_FLOW_ERROR);
- ffmpegenc->picture->pts =
- gst_ffmpeg_time_gst_to_ff (GST_BUFFER_TIMESTAMP (inbuf) /
- ffmpegenc->context->ticks_per_frame, ffmpegenc->context->time_base);
-
- ffmpegenc_setup_working_buf (ffmpegenc);
-
- ret_size = avcodec_encode_video (ffmpegenc->context,
- ffmpegenc->working_buf, ffmpegenc->working_buf_size, ffmpegenc->picture);
-
- gst_buffer_unmap (inbuf, &map);
-
- if (ret_size < 0) {
-#ifndef GST_DISABLE_GST_DEBUG
- GstFFMpegEncClass *oclass =
- (GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
- GST_ERROR_OBJECT (ffmpegenc,
- "avenc_%s: failed to encode buffer", oclass->in_plugin->name);
-#endif /* GST_DISABLE_GST_DEBUG */
- gst_buffer_unref (inbuf);
- return GST_FLOW_OK;
- }
-
- /* handle b-frame delay when no output, so we don't output empty frames;
- * timestamps and so can permute a bit between coding and display order
- * but keyframes should still end up with the proper metadata */
- g_queue_push_tail (ffmpegenc->delay, inbuf);
- if (ret_size)
- inbuf = g_queue_pop_head (ffmpegenc->delay);
- else
- return GST_FLOW_OK;
-
- /* save stats info if there is some as well as a stats file */
- if (ffmpegenc->file && ffmpegenc->context->stats_out)
- if (fprintf (ffmpegenc->file, "%s", ffmpegenc->context->stats_out) < 0)
- GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, WRITE,
- (("Could not write to file \"%s\"."), ffmpegenc->filename),
- GST_ERROR_SYSTEM);
-
- outbuf = gst_buffer_new_and_alloc (ret_size);
- gst_buffer_fill (outbuf, 0, ffmpegenc->working_buf, ret_size);
- GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
- GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
- /* buggy codec may not set coded_frame */
- if (ffmpegenc->context->coded_frame) {
- if (!ffmpegenc->context->coded_frame->key_frame)
- GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
- } else
- GST_WARNING_OBJECT (ffmpegenc, "codec did not provide keyframe info");
-
- gst_buffer_unref (inbuf);
-
- /* Reset frame type */
- if (ffmpegenc->picture->pict_type)
- ffmpegenc->picture->pict_type = 0;
-
- if (force_keyframe) {
- gst_pad_push_event (ffmpegenc->srcpad,
- gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM,
- gst_structure_new ("GstForceKeyUnit",
- "timestamp", G_TYPE_UINT64, GST_BUFFER_TIMESTAMP (outbuf),
- NULL)));
- }
-
- return gst_pad_push (ffmpegenc->srcpad, outbuf);
-
- /* ERRORS */
-not_negotiated:
- {
- GST_ELEMENT_ERROR (ffmpegenc, CORE, NEGOTIATION, (NULL),
- ("not configured to input format before data start"));
- gst_buffer_unref (inbuf);
- return GST_FLOW_NOT_NEGOTIATED;
- }
-}
-
-static GstFlowReturn
-gst_ffmpegenc_encode_audio (GstFFMpegEnc * ffmpegenc, guint8 * audio_in,
- guint in_size, guint max_size, GstClockTime timestamp,
+gst_ffmpegaudenc_encode_audio (GstFFMpegAudEnc * ffmpegaudenc,
+ guint8 * audio_in, guint in_size, guint max_size, GstClockTime timestamp,
GstClockTime duration, gboolean discont)
{
GstBuffer *outbuf;
@@ -892,25 +376,25 @@ gst_ffmpegenc_encode_audio (GstFFMpegEnc * ffmpegenc, guint8 * audio_in,
gint res;
GstFlowReturn ret;
- ctx = ffmpegenc->context;
+ ctx = ffmpegaudenc->context;
/* We need to provide at least ffmpegs minimal buffer size */
outbuf = gst_buffer_new_and_alloc (max_size + FF_MIN_BUFFER_SIZE);
gst_buffer_map (outbuf, &map, GST_MAP_WRITE);
- GST_LOG_OBJECT (ffmpegenc, "encoding buffer of max size %d", max_size);
- if (ffmpegenc->buffer_size != max_size)
- ffmpegenc->buffer_size = max_size;
+ GST_LOG_OBJECT (ffmpegaudenc, "encoding buffer of max size %d", max_size);
+ if (ffmpegaudenc->buffer_size != max_size)
+ ffmpegaudenc->buffer_size = max_size;
res = avcodec_encode_audio (ctx, map.data, max_size, (short *) audio_in);
if (res < 0) {
gst_buffer_unmap (outbuf, &map);
- GST_ERROR_OBJECT (ffmpegenc, "Failed to encode buffer: %d", res);
+ GST_ERROR_OBJECT (ffmpegaudenc, "Failed to encode buffer: %d", res);
gst_buffer_unref (outbuf);
return GST_FLOW_OK;
}
- GST_LOG_OBJECT (ffmpegenc, "got output size %d", res);
+ GST_LOG_OBJECT (ffmpegaudenc, "got output size %d", res);
gst_buffer_unmap (outbuf, &map);
gst_buffer_resize (outbuf, 0, res);
@@ -919,19 +403,20 @@ gst_ffmpegenc_encode_audio (GstFFMpegEnc * ffmpegenc, guint8 * audio_in,
if (discont)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
- GST_LOG_OBJECT (ffmpegenc, "pushing size %d, timestamp %" GST_TIME_FORMAT,
+ GST_LOG_OBJECT (ffmpegaudenc, "pushing size %d, timestamp %" GST_TIME_FORMAT,
res, GST_TIME_ARGS (timestamp));
- ret = gst_pad_push (ffmpegenc->srcpad, outbuf);
+ ret = gst_pad_push (ffmpegaudenc->srcpad, outbuf);
return ret;
}
static GstFlowReturn
-gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
+gst_ffmpegaudenc_chain_audio (GstPad * pad, GstObject * parent,
+ GstBuffer * inbuf)
{
- GstFFMpegEnc *ffmpegenc;
- GstFFMpegEncClass *oclass;
+ GstFFMpegAudEnc *ffmpegaudenc;
+ GstFFMpegAudEncClass *oclass;
AVCodecContext *ctx;
GstClockTime timestamp, duration;
gsize size, frame_size;
@@ -941,20 +426,20 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
gboolean discont;
guint8 *in_data;
- ffmpegenc = (GstFFMpegEnc *) parent;
- oclass = (GstFFMpegEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
+ ffmpegaudenc = (GstFFMpegAudEnc *) parent;
+ oclass = (GstFFMpegAudEncClass *) G_OBJECT_GET_CLASS (ffmpegaudenc);
- if (G_UNLIKELY (!ffmpegenc->opened))
+ if (G_UNLIKELY (!ffmpegaudenc->opened))
goto not_negotiated;
- ctx = ffmpegenc->context;
+ ctx = ffmpegaudenc->context;
size = gst_buffer_get_size (inbuf);
timestamp = GST_BUFFER_TIMESTAMP (inbuf);
duration = GST_BUFFER_DURATION (inbuf);
discont = GST_BUFFER_IS_DISCONT (inbuf);
- GST_DEBUG_OBJECT (ffmpegenc,
+ GST_DEBUG_OBJECT (ffmpegaudenc,
"Received time %" GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT
", size %" G_GSIZE_FORMAT, GST_TIME_ARGS (timestamp),
GST_TIME_ARGS (duration), size);
@@ -967,17 +452,17 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
guint avail, frame_bytes;
if (discont) {
- GST_LOG_OBJECT (ffmpegenc, "DISCONT, clear adapter");
- gst_adapter_clear (ffmpegenc->adapter);
- ffmpegenc->discont = TRUE;
+ GST_LOG_OBJECT (ffmpegaudenc, "DISCONT, clear adapter");
+ gst_adapter_clear (ffmpegaudenc->adapter);
+ ffmpegaudenc->discont = TRUE;
}
- if (gst_adapter_available (ffmpegenc->adapter) == 0) {
+ if (gst_adapter_available (ffmpegaudenc->adapter) == 0) {
/* lock on to new timestamp */
- GST_LOG_OBJECT (ffmpegenc, "taking buffer timestamp %" GST_TIME_FORMAT,
+ GST_LOG_OBJECT (ffmpegaudenc, "taking buffer timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (timestamp));
- ffmpegenc->adapter_ts = timestamp;
- ffmpegenc->adapter_consumed = 0;
+ ffmpegaudenc->adapter_ts = timestamp;
+ ffmpegaudenc->adapter_consumed = 0;
} else {
GstClockTime upstream_time;
GstClockTime consumed_time;
@@ -985,18 +470,20 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
/* use timestamp at head of the adapter */
consumed_time =
- gst_util_uint64_scale (ffmpegenc->adapter_consumed, GST_SECOND,
+ gst_util_uint64_scale (ffmpegaudenc->adapter_consumed, GST_SECOND,
ctx->sample_rate);
- timestamp = ffmpegenc->adapter_ts + consumed_time;
- GST_LOG_OBJECT (ffmpegenc, "taking adapter timestamp %" GST_TIME_FORMAT
+ timestamp = ffmpegaudenc->adapter_ts + consumed_time;
+ GST_LOG_OBJECT (ffmpegaudenc, "taking adapter timestamp %" GST_TIME_FORMAT
" and adding consumed time %" GST_TIME_FORMAT,
- GST_TIME_ARGS (ffmpegenc->adapter_ts), GST_TIME_ARGS (consumed_time));
+ GST_TIME_ARGS (ffmpegaudenc->adapter_ts),
+ GST_TIME_ARGS (consumed_time));
/* check with upstream timestamps, if too much deviation,
* forego some timestamp perfection in favour of upstream syncing
* (particularly in case these do not happen to come in multiple
* of frame size) */
- upstream_time = gst_adapter_prev_timestamp (ffmpegenc->adapter, &bytes);
+ upstream_time =
+ gst_adapter_prev_timestamp (ffmpegaudenc->adapter, &bytes);
if (GST_CLOCK_TIME_IS_VALID (upstream_time)) {
GstClockTimeDiff diff;
@@ -1006,32 +493,33 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
diff = upstream_time - timestamp;
/* relaxed difference, rather than half a sample or so ... */
if (diff > GST_SECOND / 10 || diff < -GST_SECOND / 10) {
- GST_DEBUG_OBJECT (ffmpegenc, "adapter timestamp drifting, "
+ GST_DEBUG_OBJECT (ffmpegaudenc, "adapter timestamp drifting, "
"taking upstream timestamp %" GST_TIME_FORMAT,
GST_TIME_ARGS (upstream_time));
timestamp = upstream_time;
/* samples corresponding to bytes */
- ffmpegenc->adapter_consumed = bytes / (osize * ctx->channels);
- ffmpegenc->adapter_ts = upstream_time -
- gst_util_uint64_scale (ffmpegenc->adapter_consumed, GST_SECOND,
+ ffmpegaudenc->adapter_consumed = bytes / (osize * ctx->channels);
+ ffmpegaudenc->adapter_ts = upstream_time -
+ gst_util_uint64_scale (ffmpegaudenc->adapter_consumed, GST_SECOND,
ctx->sample_rate);
- ffmpegenc->discont = TRUE;
+ ffmpegaudenc->discont = TRUE;
}
}
}
- GST_LOG_OBJECT (ffmpegenc, "pushing buffer in adapter");
- gst_adapter_push (ffmpegenc->adapter, inbuf);
+ GST_LOG_OBJECT (ffmpegaudenc, "pushing buffer in adapter");
+ gst_adapter_push (ffmpegaudenc->adapter, inbuf);
/* first see how many bytes we need to feed to the decoder. */
frame_bytes = frame_size * osize * ctx->channels;
- avail = gst_adapter_available (ffmpegenc->adapter);
+ avail = gst_adapter_available (ffmpegaudenc->adapter);
- GST_LOG_OBJECT (ffmpegenc, "frame_bytes %u, avail %u", frame_bytes, avail);
+ GST_LOG_OBJECT (ffmpegaudenc, "frame_bytes %u, avail %u", frame_bytes,
+ avail);
/* while there is more than a frame size in the adapter, consume it */
while (avail >= frame_bytes) {
- GST_LOG_OBJECT (ffmpegenc, "taking %u bytes from the adapter",
+ GST_LOG_OBJECT (ffmpegaudenc, "taking %u bytes from the adapter",
frame_bytes);
/* Note that we take frame_bytes and add frame_size.
@@ -1039,25 +527,25 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
* or samplesize to divide by the samplerate */
/* take an audio buffer out of the adapter */
- in_data = (guint8 *) gst_adapter_map (ffmpegenc->adapter, frame_bytes);
- ffmpegenc->adapter_consumed += frame_size;
+ in_data = (guint8 *) gst_adapter_map (ffmpegaudenc->adapter, frame_bytes);
+ ffmpegaudenc->adapter_consumed += frame_size;
/* calculate timestamp and duration relative to start of adapter and to
* the amount of samples we consumed */
duration =
- gst_util_uint64_scale (ffmpegenc->adapter_consumed, GST_SECOND,
+ gst_util_uint64_scale (ffmpegaudenc->adapter_consumed, GST_SECOND,
ctx->sample_rate);
- duration -= (timestamp - ffmpegenc->adapter_ts);
+ duration -= (timestamp - ffmpegaudenc->adapter_ts);
/* 4 times the input size should be big enough... */
out_size = frame_bytes * 4;
ret =
- gst_ffmpegenc_encode_audio (ffmpegenc, in_data, frame_bytes, out_size,
- timestamp, duration, ffmpegenc->discont);
+ gst_ffmpegaudenc_encode_audio (ffmpegaudenc, in_data, frame_bytes,
+ out_size, timestamp, duration, ffmpegaudenc->discont);
- gst_adapter_unmap (ffmpegenc->adapter);
- gst_adapter_flush (ffmpegenc->adapter, frame_bytes);
+ gst_adapter_unmap (ffmpegaudenc->adapter);
+ gst_adapter_flush (ffmpegaudenc->adapter, frame_bytes);
if (ret != GST_FLOW_OK)
goto push_failed;
@@ -1065,17 +553,17 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
/* advance the adapter timestamp with the duration */
timestamp += duration;
- ffmpegenc->discont = FALSE;
- avail = gst_adapter_available (ffmpegenc->adapter);
+ ffmpegaudenc->discont = FALSE;
+ avail = gst_adapter_available (ffmpegaudenc->adapter);
}
- GST_LOG_OBJECT (ffmpegenc, "%u bytes left in the adapter", avail);
+ GST_LOG_OBJECT (ffmpegaudenc, "%u bytes left in the adapter", avail);
} else {
GstMapInfo map;
/* we have no frame_size, feed the encoder all the data and expect a fixed
* output size */
int coded_bps = av_get_bits_per_sample (oclass->in_plugin->id);
- GST_LOG_OBJECT (ffmpegenc, "coded bps %d, osize %d", coded_bps, osize);
+ GST_LOG_OBJECT (ffmpegaudenc, "coded bps %d, osize %d", coded_bps, osize);
out_size = size / osize;
if (coded_bps)
@@ -1084,7 +572,7 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
gst_buffer_map (inbuf, &map, GST_MAP_READ);
in_data = map.data;
size = map.size;
- ret = gst_ffmpegenc_encode_audio (ffmpegenc, in_data, size, out_size,
+ ret = gst_ffmpegaudenc_encode_audio (ffmpegaudenc, in_data, size, out_size,
timestamp, duration, discont);
gst_buffer_unmap (inbuf, &map);
gst_buffer_unref (inbuf);
@@ -1098,110 +586,32 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstObject * parent, GstBuffer * inbuf)
/* ERRORS */
not_negotiated:
{
- GST_ELEMENT_ERROR (ffmpegenc, CORE, NEGOTIATION, (NULL),
+ GST_ELEMENT_ERROR (ffmpegaudenc, CORE, NEGOTIATION, (NULL),
("not configured to input format before data start"));
gst_buffer_unref (inbuf);
return GST_FLOW_NOT_NEGOTIATED;
}
push_failed:
{
- GST_DEBUG_OBJECT (ffmpegenc, "Failed to push buffer %d (%s)", ret,
+ GST_DEBUG_OBJECT (ffmpegaudenc, "Failed to push buffer %d (%s)", ret,
gst_flow_get_name (ret));
return ret;
}
}
-static void
-gst_ffmpegenc_flush_buffers (GstFFMpegEnc * ffmpegenc, gboolean send)
-{
- GstBuffer *outbuf, *inbuf;
- gint ret_size;
-
- GST_DEBUG_OBJECT (ffmpegenc, "flushing buffers with sending %d", send);
-
- /* no need to empty codec if there is none */
- if (!ffmpegenc->opened)
- goto flush;
-
- while (!g_queue_is_empty (ffmpegenc->delay)) {
-
- ffmpegenc_setup_working_buf (ffmpegenc);
-
- ret_size = avcodec_encode_video (ffmpegenc->context,
- ffmpegenc->working_buf, ffmpegenc->working_buf_size, NULL);
-
- if (ret_size < 0) { /* there should be something, notify and give up */
-#ifndef GST_DISABLE_GST_DEBUG
- GstFFMpegEncClass *oclass =
- (GstFFMpegEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
- GST_WARNING_OBJECT (ffmpegenc,
- "avenc_%s: failed to flush buffer", oclass->in_plugin->name);
-#endif /* GST_DISABLE_GST_DEBUG */
- break;
- }
-
- /* save stats info if there is some as well as a stats file */
- if (ffmpegenc->file && ffmpegenc->context->stats_out)
- if (fprintf (ffmpegenc->file, "%s", ffmpegenc->context->stats_out) < 0)
- GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, WRITE,
- (("Could not write to file \"%s\"."), ffmpegenc->filename),
- GST_ERROR_SYSTEM);
-
- /* handle b-frame delay when no output, so we don't output empty frames */
- inbuf = g_queue_pop_head (ffmpegenc->delay);
-
- outbuf = gst_buffer_new_and_alloc (ret_size);
- gst_buffer_fill (outbuf, 0, ffmpegenc->working_buf, ret_size);
- GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
- GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
-
- if (!ffmpegenc->context->coded_frame->key_frame)
- GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DELTA_UNIT);
-
- gst_buffer_unref (inbuf);
-
- if (send)
- gst_pad_push (ffmpegenc->srcpad, outbuf);
- else
- gst_buffer_unref (outbuf);
- }
-
-flush:
- {
- /* make sure that we empty the queue, is still needed if we had to break */
- while (!g_queue_is_empty (ffmpegenc->delay))
- gst_buffer_unref (g_queue_pop_head (ffmpegenc->delay));
- }
-}
-
static gboolean
-gst_ffmpegenc_event_sink (GstPad * pad, GstObject * parent, GstEvent * event)
+gst_ffmpegaudenc_event_sink (GstPad * pad, GstObject * parent, GstEvent * event)
{
- GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) parent;
+ GstFFMpegAudEnc *ffmpegaudenc = (GstFFMpegAudEnc *) parent;
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_EOS:
- gst_ffmpegenc_flush_buffers (ffmpegenc, TRUE);
- break;
- /* no flushing if flush received,
- * buffers in encoder are considered (in the) past */
- case GST_EVENT_CUSTOM_DOWNSTREAM:
- {
- const GstStructure *s;
-
- s = gst_event_get_structure (event);
- if (gst_structure_has_name (s, "GstForceKeyUnit")) {
- ffmpegenc->picture->pict_type = FF_I_TYPE;
- }
- break;
- }
case GST_EVENT_CAPS:
{
GstCaps *caps;
gboolean ret;
gst_event_parse_caps (event, &caps);
- ret = gst_ffmpegenc_setcaps (ffmpegenc, caps);
+ ret = gst_ffmpegaudenc_setcaps (ffmpegaudenc, caps);
gst_event_unref (event);
return ret;
}
@@ -1209,42 +619,13 @@ gst_ffmpegenc_event_sink (GstPad * pad, GstObject * parent, GstEvent * event)
break;
}
- return gst_pad_push_event (ffmpegenc->srcpad, event);
-}
-
-static gboolean
-gst_ffmpegenc_event_src (GstPad * pad, GstObject * parent, GstEvent * event)
-{
- GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) parent;
- gboolean forward = TRUE;
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_CUSTOM_UPSTREAM:{
- const GstStructure *s;
- s = gst_event_get_structure (event);
- if (gst_structure_has_name (s, "GstForceKeyUnit")) {
- GST_OBJECT_LOCK (ffmpegenc);
- ffmpegenc->force_keyframe = TRUE;
- GST_OBJECT_UNLOCK (ffmpegenc);
- forward = FALSE;
- gst_event_unref (event);
- }
- break;
- }
-
- default:
- break;
- }
-
- if (forward)
- return gst_pad_push_event (ffmpegenc->sinkpad, event);
- else
- return TRUE;
+ return gst_pad_event_default (pad, parent, event);
}
static gboolean
-gst_ffmpegenc_query_sink (GstPad * pad, GstObject * parent, GstQuery * query)
+gst_ffmpegaudenc_query_sink (GstPad * pad, GstObject * parent, GstQuery * query)
{
+ GstFFMpegAudEnc *ffmpegaudenc = (GstFFMpegAudEnc *) parent;
gboolean res = FALSE;
switch (GST_QUERY_TYPE (query)) {
@@ -1253,7 +634,7 @@ gst_ffmpegenc_query_sink (GstPad * pad, GstObject * parent, GstQuery * query)
GstCaps *filter, *caps;
gst_query_parse_caps (query, &filter);
- caps = gst_ffmpegenc_getcaps (pad, filter);
+ caps = gst_ffmpegaudenc_getcaps (ffmpegaudenc, filter);
gst_query_set_caps_result (query, caps);
gst_caps_unref (caps);
res = TRUE;
@@ -1268,16 +649,16 @@ gst_ffmpegenc_query_sink (GstPad * pad, GstObject * parent, GstQuery * query)
}
static void
-gst_ffmpegenc_set_property (GObject * object,
+gst_ffmpegaudenc_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
- GstFFMpegEnc *ffmpegenc;
+ GstFFMpegAudEnc *ffmpegaudenc;
/* Get a pointer of the right type. */
- ffmpegenc = (GstFFMpegEnc *) (object);
+ ffmpegaudenc = (GstFFMpegAudEnc *) (object);
- if (ffmpegenc->opened) {
- GST_WARNING_OBJECT (ffmpegenc,
+ if (ffmpegaudenc->opened) {
+ GST_WARNING_OBJECT (ffmpegaudenc,
"Can't change properties once decoder is setup !");
return;
}
@@ -1285,63 +666,50 @@ gst_ffmpegenc_set_property (GObject * object,
/* Check the argument id to see which argument we're setting. */
switch (prop_id) {
case ARG_BIT_RATE:
- ffmpegenc->bitrate = g_value_get_ulong (value);
- break;
- case ARG_GOP_SIZE:
- ffmpegenc->gop_size = g_value_get_int (value);
- break;
- case ARG_ME_METHOD:
- ffmpegenc->me_method = g_value_get_enum (value);
+ ffmpegaudenc->bitrate = g_value_get_int (value);
break;
case ARG_BUFSIZE:
break;
case ARG_RTP_PAYLOAD_SIZE:
- ffmpegenc->rtp_payload_size = g_value_get_ulong (value);
+ ffmpegaudenc->rtp_payload_size = g_value_get_int (value);
break;
default:
- if (!gst_ffmpeg_cfg_set_property (object, value, pspec))
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/* The set function is simply the inverse of the get fuction. */
static void
-gst_ffmpegenc_get_property (GObject * object,
+gst_ffmpegaudenc_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec)
{
- GstFFMpegEnc *ffmpegenc;
+ GstFFMpegAudEnc *ffmpegaudenc;
/* It's not null if we got it, but it might not be ours */
- ffmpegenc = (GstFFMpegEnc *) (object);
+ ffmpegaudenc = (GstFFMpegAudEnc *) (object);
switch (prop_id) {
case ARG_BIT_RATE:
- g_value_set_ulong (value, ffmpegenc->bitrate);
+ g_value_set_int (value, ffmpegaudenc->bitrate);
break;
- case ARG_GOP_SIZE:
- g_value_set_int (value, ffmpegenc->gop_size);
- break;
- case ARG_ME_METHOD:
- g_value_set_enum (value, ffmpegenc->me_method);
break;
case ARG_BUFSIZE:
- g_value_set_ulong (value, ffmpegenc->buffer_size);
+ g_value_set_int (value, ffmpegaudenc->buffer_size);
break;
case ARG_RTP_PAYLOAD_SIZE:
- g_value_set_ulong (value, ffmpegenc->rtp_payload_size);
+ g_value_set_int (value, ffmpegaudenc->rtp_payload_size);
break;
default:
- if (!gst_ffmpeg_cfg_get_property (object, value, pspec))
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GstStateChangeReturn
-gst_ffmpegenc_change_state (GstElement * element, GstStateChange transition)
+gst_ffmpegaudenc_change_state (GstElement * element, GstStateChange transition)
{
- GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) element;
+ GstFFMpegAudEnc *ffmpegaudenc = (GstFFMpegAudEnc *) element;
GstStateChangeReturn result;
switch (transition) {
@@ -1353,21 +721,11 @@ gst_ffmpegenc_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY:
- gst_ffmpegenc_flush_buffers (ffmpegenc, FALSE);
- if (ffmpegenc->opened) {
- gst_ffmpeg_avcodec_close (ffmpegenc->context);
- ffmpegenc->opened = FALSE;
- }
- gst_adapter_clear (ffmpegenc->adapter);
-
- if (ffmpegenc->file) {
- fclose (ffmpegenc->file);
- ffmpegenc->file = NULL;
- }
- if (ffmpegenc->working_buf) {
- g_free (ffmpegenc->working_buf);
- ffmpegenc->working_buf = NULL;
+ if (ffmpegaudenc->opened) {
+ gst_ffmpeg_avcodec_close (ffmpegaudenc->context);
+ ffmpegaudenc->opened = FALSE;
}
+ gst_adapter_clear (ffmpegaudenc->adapter);
break;
default:
break;
@@ -1376,18 +734,18 @@ gst_ffmpegenc_change_state (GstElement * element, GstStateChange transition)
}
gboolean
-gst_ffmpegenc_register (GstPlugin * plugin)
+gst_ffmpegaudenc_register (GstPlugin * plugin)
{
GTypeInfo typeinfo = {
- sizeof (GstFFMpegEncClass),
- (GBaseInitFunc) gst_ffmpegenc_base_init,
+ sizeof (GstFFMpegAudEncClass),
+ (GBaseInitFunc) gst_ffmpegaudenc_base_init,
NULL,
- (GClassInitFunc) gst_ffmpegenc_class_init,
+ (GClassInitFunc) gst_ffmpegaudenc_class_init,
NULL,
NULL,
- sizeof (GstFFMpegEnc),
+ sizeof (GstFFMpegAudEnc),
0,
- (GInstanceInitFunc) gst_ffmpegenc_init,
+ (GInstanceInitFunc) gst_ffmpegaudenc_init,
};
GType type;
AVCodec *in_plugin;
@@ -1395,25 +753,16 @@ gst_ffmpegenc_register (GstPlugin * plugin)
GST_LOG ("Registering encoders");
- /* build global ffmpeg param/property info */
- gst_ffmpeg_cfg_init ();
-
in_plugin = av_codec_next (NULL);
while (in_plugin) {
gchar *type_name;
/* Skip non-AV codecs */
- if (in_plugin->type != AVMEDIA_TYPE_AUDIO &&
- in_plugin->type != AVMEDIA_TYPE_VIDEO)
+ if (in_plugin->type != AVMEDIA_TYPE_AUDIO)
goto next;
/* no quasi codecs, please */
- if (in_plugin->id == CODEC_ID_RAWVIDEO ||
- in_plugin->id == CODEC_ID_V210 ||
- in_plugin->id == CODEC_ID_V210X ||
- in_plugin->id == CODEC_ID_R210 ||
- in_plugin->id == CODEC_ID_ZLIB ||
- (in_plugin->id >= CODEC_ID_PCM_S16LE &&
+ if ((in_plugin->id >= CODEC_ID_PCM_S16LE &&
in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
goto next;
}
@@ -1439,8 +788,8 @@ gst_ffmpegenc_register (GstPlugin * plugin)
GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
/* no codecs for which we're GUARANTEED to have better alternatives */
- if (!strcmp (in_plugin->name, "vorbis") ||
- !strcmp (in_plugin->name, "gif") || !strcmp (in_plugin->name, "flac")) {
+ if (!strcmp (in_plugin->name, "vorbis")
+ || !strcmp (in_plugin->name, "flac")) {
GST_LOG ("Ignoring encoder %s", in_plugin->name);
goto next;
}
diff --git a/ext/ffmpeg/gstffmpegenc.h b/ext/ffmpeg/gstffmpegenc.h
index c13a0d3..019b168 100644
--- a/ext/ffmpeg/gstffmpegenc.h
+++ b/ext/ffmpeg/gstffmpegenc.h
@@ -21,16 +21,16 @@
* object definition and other useful things.
*/
-#ifndef __GST_FFMPEGENC_H__
-#define __GST_FFMPEGENC_H__
+#ifndef __GST_FFMPEGAUDENC_H__
+#define __GST_FFMPEGAUDENC_H__
G_BEGIN_DECLS
#include <gst/base/gstadapter.h>
-typedef struct _GstFFMpegEnc GstFFMpegEnc;
+typedef struct _GstFFMpegAudEnc GstFFMpegAudEnc;
-struct _GstFFMpegEnc
+struct _GstFFMpegAudEnc
{
GstElement element;
@@ -39,7 +39,6 @@ struct _GstFFMpegEnc
GstPad *sinkpad;
AVCodecContext *context;
- AVFrame *picture;
gboolean opened;
GstClockTime adapter_ts;
guint64 adapter_consumed;
@@ -47,40 +46,18 @@ struct _GstFFMpegEnc
gboolean discont;
/* cache */
- gulong bitrate;
- gint me_method;
- gint gop_size;
- gulong buffer_size;
- gulong rtp_payload_size;
-
- guint8 *working_buf;
- gulong working_buf_size;
-
- /* settings with some special handling */
- guint pass;
- gfloat quantizer;
- gchar *filename;
- guint lmin;
- guint lmax;
- gint max_key_interval;
- gboolean interlaced;
-
- /* statistics file */
- FILE *file;
-
- /* for b-frame delay handling */
- GQueue *delay;
+ gint bitrate;
+ gint buffer_size;
+ gint rtp_payload_size;
/* other settings are copied over straight,
* include a context here, rather than copy-and-past it from avcodec.h */
AVCodecContext config;
-
- gboolean force_keyframe;
};
-typedef struct _GstFFMpegEncClass GstFFMpegEncClass;
+typedef struct _GstFFMpegAudEncClass GstFFMpegAudEncClass;
-struct _GstFFMpegEncClass
+struct _GstFFMpegAudEncClass
{
GstElementClass parent_class;
@@ -89,17 +66,17 @@ struct _GstFFMpegEncClass
GstCaps *sinkcaps;
};
-#define GST_TYPE_FFMPEGENC \
- (gst_ffmpegenc_get_type())
-#define GST_FFMPEGENC(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGENC,GstFFMpegEnc))
-#define GST_FFMPEGENC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGENC,GstFFMpegEncClass))
-#define GST_IS_FFMPEGENC(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGENC))
-#define GST_IS_FFMPEGENC_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGENC))
+#define GST_TYPE_FFMPEGAUDENC \
+ (gst_ffmpegaudenc_get_type())
+#define GST_FFMPEGAUDENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGAUDENC,GstFFMpegAudEnc))
+#define GST_FFMPEGAUDENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGAUDENC,GstFFMpegAudEncClass))
+#define GST_IS_FFMPEGAUDENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGAUDENC))
+#define GST_IS_FFMPEGAUDENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGAUDENC))
G_END_DECLS
-#endif /* __GST_FFMPEGENC_H__ */
+#endif /* __GST_FFMPEGAUDENC_H__ */
diff --git a/ext/ffmpeg/gstffmpegmux.c b/ext/ffmpeg/gstffmpegmux.c
index 001fdcf..41e6e3f 100644
--- a/ext/ffmpeg/gstffmpegmux.c
+++ b/ext/ffmpeg/gstffmpegmux.c
@@ -929,7 +929,8 @@ gst_ffmpegmux_register (GstPlugin * plugin)
(!strncmp (in_plugin->name, "rtp", 3)) ||
(!strncmp (in_plugin->name, "ass", 3)) ||
(!strncmp (in_plugin->name, "ffmetadata", 10)) ||
- (!strncmp (in_plugin->name, "srt", 3))
+ (!strncmp (in_plugin->name, "srt", 3)) ||
+ !strcmp (in_plugin->name, "segment")
) {
GST_LOG ("Ignoring muxer %s", in_plugin->name);
goto next;
diff --git a/ext/ffmpeg/gstffmpegviddec.c b/ext/ffmpeg/gstffmpegviddec.c
new file mode 100644
index 0000000..129fc89
--- /dev/null
+++ b/ext/ffmpeg/gstffmpegviddec.c
@@ -0,0 +1,1756 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <assert.h>
+#include <string.h>
+
+#ifdef HAVE_LIBAV_UNINSTALLED
+#include <avcodec.h>
+#else
+#include <libavcodec/avcodec.h>
+#endif
+
+#include <gst/gst.h>
+#include <gst/video/video.h>
+#include <gst/video/gstvideodecoder.h>
+#include <gst/video/gstvideometa.h>
+#include <gst/video/gstvideopool.h>
+
+#include "gstffmpeg.h"
+#include "gstffmpegcodecmap.h"
+#include "gstffmpegutils.h"
+
+GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
+
+typedef struct _GstFFMpegVidDec GstFFMpegVidDec;
+
+#define MAX_TS_MASK 0xff
+
+struct _GstFFMpegVidDec
+{
+ GstVideoDecoder parent;
+
+ GstVideoCodecState *input_state;
+ GstVideoCodecState *output_state;
+
+ /* decoding */
+ AVCodecContext *context;
+ AVFrame *picture;
+ gboolean opened;
+
+ /* current context */
+ enum PixelFormat ctx_pix_fmt;
+ gint ctx_width;
+ gint ctx_height;
+ gint ctx_par_n;
+ gint ctx_par_d;
+ gint ctx_ticks;
+ gint ctx_time_d;
+ gint ctx_time_n;
+ gint ctx_interlaced;
+
+ /* for tracking DTS/PTS */
+ gboolean has_b_frames;
+
+ guint8 *padded;
+ guint padded_size;
+
+ gboolean current_dr; /* if direct rendering is enabled */
+
+ /* some properties */
+ enum AVDiscard skip_frame;
+ gint lowres;
+ gboolean direct_rendering;
+ gboolean debug_mv;
+ int max_threads;
+
+ gboolean is_realvideo;
+
+ GstCaps *last_caps;
+};
+
+typedef struct _GstFFMpegVidDecClass GstFFMpegVidDecClass;
+
+struct _GstFFMpegVidDecClass
+{
+ GstVideoDecoderClass parent_class;
+
+ AVCodec *in_plugin;
+};
+
+#define GST_TYPE_FFMPEGDEC \
+ (gst_ffmpegviddec_get_type())
+#define GST_FFMPEGDEC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGDEC,GstFFMpegVidDec))
+#define GST_FFMPEGVIDDEC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGDEC,GstFFMpegVidDecClass))
+#define GST_IS_FFMPEGDEC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGDEC))
+#define GST_IS_FFMPEGVIDDEC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGDEC))
+
+#define DEFAULT_LOWRES 0
+#define DEFAULT_SKIPFRAME 0
+#define DEFAULT_DIRECT_RENDERING TRUE
+#define DEFAULT_DEBUG_MV FALSE
+#define DEFAULT_MAX_THREADS 0
+
+enum
+{
+ PROP_0,
+ PROP_LOWRES,
+ PROP_SKIPFRAME,
+ PROP_DIRECT_RENDERING,
+ PROP_DEBUG_MV,
+ PROP_MAX_THREADS,
+ PROP_LAST
+};
+
+/* A number of function prototypes are given so we can refer to them later. */
+static void gst_ffmpegviddec_base_init (GstFFMpegVidDecClass * klass);
+static void gst_ffmpegviddec_class_init (GstFFMpegVidDecClass * klass);
+static void gst_ffmpegviddec_init (GstFFMpegVidDec * ffmpegdec);
+static void gst_ffmpegviddec_finalize (GObject * object);
+
+static gboolean gst_ffmpegviddec_set_format (GstVideoDecoder * decoder,
+ GstVideoCodecState * state);
+static GstFlowReturn gst_ffmpegviddec_handle_frame (GstVideoDecoder * decoder,
+ GstVideoCodecFrame * frame);
+static gboolean gst_ffmpegviddec_stop (GstVideoDecoder * decoder);
+static gboolean gst_ffmpegviddec_reset (GstVideoDecoder * decoder,
+ gboolean hard);
+static gboolean gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder,
+ GstQuery * query);
+static gboolean gst_ffmpegviddec_propose_allocation (GstVideoDecoder * decoder,
+ GstQuery * query);
+
+static void gst_ffmpegviddec_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_ffmpegviddec_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+static gboolean gst_ffmpegviddec_negotiate (GstFFMpegVidDec * ffmpegdec,
+ gboolean force);
+
+/* some sort of bufferpool handling, but different */
+static int gst_ffmpegviddec_get_buffer (AVCodecContext * context,
+ AVFrame * picture);
+static void gst_ffmpegviddec_release_buffer (AVCodecContext * context,
+ AVFrame * picture);
+
+static GstFlowReturn gst_ffmpegviddec_finish (GstVideoDecoder * decoder);
+static void gst_ffmpegviddec_drain (GstFFMpegVidDec * ffmpegdec);
+
+#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("avdec-params")
+
+static GstElementClass *parent_class = NULL;
+
+#define GST_FFMPEGVIDDEC_TYPE_LOWRES (gst_ffmpegviddec_lowres_get_type())
+static GType
+gst_ffmpegviddec_lowres_get_type (void)
+{
+ static GType ffmpegdec_lowres_type = 0;
+
+ if (!ffmpegdec_lowres_type) {
+ static const GEnumValue ffmpegdec_lowres[] = {
+ {0, "0", "full"},
+ {1, "1", "1/2-size"},
+ {2, "2", "1/4-size"},
+ {0, NULL, NULL},
+ };
+
+ ffmpegdec_lowres_type =
+ g_enum_register_static ("GstLibAVVidDecLowres", ffmpegdec_lowres);
+ }
+
+ return ffmpegdec_lowres_type;
+}
+
+#define GST_FFMPEGVIDDEC_TYPE_SKIPFRAME (gst_ffmpegviddec_skipframe_get_type())
+static GType
+gst_ffmpegviddec_skipframe_get_type (void)
+{
+ static GType ffmpegdec_skipframe_type = 0;
+
+ if (!ffmpegdec_skipframe_type) {
+ static const GEnumValue ffmpegdec_skipframe[] = {
+ {0, "0", "Skip nothing"},
+ {1, "1", "Skip B-frames"},
+ {2, "2", "Skip IDCT/Dequantization"},
+ {5, "5", "Skip everything"},
+ {0, NULL, NULL},
+ };
+
+ ffmpegdec_skipframe_type =
+ g_enum_register_static ("GstLibAVVidDecSkipFrame", ffmpegdec_skipframe);
+ }
+
+ return ffmpegdec_skipframe_type;
+}
+
+static void
+gst_ffmpegviddec_base_init (GstFFMpegVidDecClass * klass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstPadTemplate *sinktempl, *srctempl;
+ GstCaps *sinkcaps, *srccaps;
+ AVCodec *in_plugin;
+ gchar *longname, *description;
+
+ in_plugin =
+ (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
+ GST_FFDEC_PARAMS_QDATA);
+ g_assert (in_plugin != NULL);
+
+ /* construct the element details struct */
+ longname = g_strdup_printf ("libav %s decoder", in_plugin->long_name);
+ description = g_strdup_printf ("libav %s decoder", in_plugin->name);
+ gst_element_class_set_metadata (element_class, longname,
+ "Codec/Decoder/Video", description,
+ "Wim Taymans <wim.taymans@gmail.com>, "
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>, "
+ "Edward Hervey <bilboed@bilboed.com>");
+ g_free (longname);
+ g_free (description);
+
+ /* get the caps */
+ sinkcaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, FALSE);
+ if (!sinkcaps) {
+ GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
+ sinkcaps = gst_caps_new_empty_simple ("unknown/unknown");
+ }
+ srccaps = gst_caps_new_empty_simple ("video/x-raw");
+
+ /* pad templates */
+ sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, sinkcaps);
+ srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
+
+ gst_element_class_add_pad_template (element_class, srctempl);
+ gst_element_class_add_pad_template (element_class, sinktempl);
+
+ klass->in_plugin = in_plugin;
+}
+
+static void
+gst_ffmpegviddec_class_init (GstFFMpegVidDecClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GstVideoDecoderClass *viddec_class = GST_VIDEO_DECODER_CLASS (klass);
+ int caps;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->finalize = gst_ffmpegviddec_finalize;
+
+ gobject_class->set_property = gst_ffmpegviddec_set_property;
+ gobject_class->get_property = gst_ffmpegviddec_get_property;
+
+ g_object_class_install_property (gobject_class, PROP_SKIPFRAME,
+ g_param_spec_enum ("skip-frame", "Skip frames",
+ "Which types of frames to skip during decoding",
+ GST_FFMPEGVIDDEC_TYPE_SKIPFRAME, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_LOWRES,
+ g_param_spec_enum ("lowres", "Low resolution",
+ "At which resolution to decode images",
+ GST_FFMPEGVIDDEC_TYPE_LOWRES, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_DIRECT_RENDERING,
+ g_param_spec_boolean ("direct-rendering", "Direct Rendering",
+ "Enable direct rendering", DEFAULT_DIRECT_RENDERING,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_DEBUG_MV,
+ g_param_spec_boolean ("debug-mv", "Debug motion vectors",
+ "Whether libav should print motion vectors on top of the image",
+ DEFAULT_DEBUG_MV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ caps = klass->in_plugin->capabilities;
+ if (caps & (CODEC_CAP_FRAME_THREADS | CODEC_CAP_SLICE_THREADS)) {
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_THREADS,
+ g_param_spec_int ("max-threads", "Maximum decode threads",
+ "Maximum number of worker threads to spawn. (0 = auto)",
+ 0, G_MAXINT, DEFAULT_MAX_THREADS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ }
+
+ viddec_class->set_format = gst_ffmpegviddec_set_format;
+ viddec_class->handle_frame = gst_ffmpegviddec_handle_frame;
+ viddec_class->stop = gst_ffmpegviddec_stop;
+ viddec_class->reset = gst_ffmpegviddec_reset;
+ viddec_class->finish = gst_ffmpegviddec_finish;
+ viddec_class->decide_allocation = gst_ffmpegviddec_decide_allocation;
+ viddec_class->propose_allocation = gst_ffmpegviddec_propose_allocation;
+}
+
+static void
+gst_ffmpegviddec_init (GstFFMpegVidDec * ffmpegdec)
+{
+ /* some ffmpeg data */
+ ffmpegdec->context = avcodec_alloc_context ();
+ ffmpegdec->picture = avcodec_alloc_frame ();
+ ffmpegdec->opened = FALSE;
+ ffmpegdec->skip_frame = ffmpegdec->lowres = 0;
+ ffmpegdec->direct_rendering = DEFAULT_DIRECT_RENDERING;
+ ffmpegdec->debug_mv = DEFAULT_DEBUG_MV;
+ ffmpegdec->max_threads = DEFAULT_MAX_THREADS;
+}
+
+static void
+gst_ffmpegviddec_finalize (GObject * object)
+{
+ GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) object;
+
+ if (ffmpegdec->context != NULL) {
+ av_free (ffmpegdec->context);
+ ffmpegdec->context = NULL;
+ }
+
+ if (ffmpegdec->picture != NULL) {
+ av_free (ffmpegdec->picture);
+ ffmpegdec->picture = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+/* with LOCK */
+static void
+gst_ffmpegviddec_close (GstFFMpegVidDec * ffmpegdec)
+{
+ if (!ffmpegdec->opened)
+ return;
+
+ GST_LOG_OBJECT (ffmpegdec, "closing ffmpeg codec");
+
+ gst_caps_replace (&ffmpegdec->last_caps, NULL);
+
+ if (ffmpegdec->context->priv_data)
+ gst_ffmpeg_avcodec_close (ffmpegdec->context);
+ ffmpegdec->opened = FALSE;
+
+ if (ffmpegdec->context->palctrl) {
+ av_free (ffmpegdec->context->palctrl);
+ ffmpegdec->context->palctrl = NULL;
+ }
+
+ if (ffmpegdec->context->extradata) {
+ av_free (ffmpegdec->context->extradata);
+ ffmpegdec->context->extradata = NULL;
+ }
+}
+
+/* with LOCK */
+static gboolean
+gst_ffmpegviddec_open (GstFFMpegVidDec * ffmpegdec)
+{
+ GstFFMpegVidDecClass *oclass;
+
+ oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+
+ if (gst_ffmpeg_avcodec_open (ffmpegdec->context, oclass->in_plugin) < 0)
+ goto could_not_open;
+
+ ffmpegdec->opened = TRUE;
+ ffmpegdec->is_realvideo = FALSE;
+
+ GST_LOG_OBJECT (ffmpegdec, "Opened libav codec %s, id %d",
+ oclass->in_plugin->name, oclass->in_plugin->id);
+
+ switch (oclass->in_plugin->id) {
+ case CODEC_ID_RV10:
+ case CODEC_ID_RV30:
+ case CODEC_ID_RV20:
+ case CODEC_ID_RV40:
+ ffmpegdec->is_realvideo = TRUE;
+ break;
+ default:
+ GST_LOG_OBJECT (ffmpegdec, "Parser deactivated for format");
+ break;
+ }
+
+ return TRUE;
+
+ /* ERRORS */
+could_not_open:
+ {
+ gst_ffmpegviddec_close (ffmpegdec);
+ GST_DEBUG_OBJECT (ffmpegdec, "avdec_%s: Failed to open libav codec",
+ oclass->in_plugin->name);
+ return FALSE;
+ }
+}
+
+static gboolean
+gst_ffmpegviddec_set_format (GstVideoDecoder * decoder,
+ GstVideoCodecState * state)
+{
+ GstFFMpegVidDec *ffmpegdec;
+ GstFFMpegVidDecClass *oclass;
+ gboolean ret = FALSE;
+
+ ffmpegdec = (GstFFMpegVidDec *) decoder;
+ oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+
+ if (ffmpegdec->last_caps != NULL &&
+ gst_caps_is_equal (ffmpegdec->last_caps, state->caps)) {
+ return TRUE;
+ }
+
+ gst_caps_replace (&ffmpegdec->last_caps, state->caps);
+
+ GST_DEBUG_OBJECT (ffmpegdec, "setcaps called");
+
+ GST_OBJECT_LOCK (ffmpegdec);
+ /* stupid check for VC1 */
+ if ((oclass->in_plugin->id == CODEC_ID_WMV3) ||
+ (oclass->in_plugin->id == CODEC_ID_VC1))
+ oclass->in_plugin->id = gst_ffmpeg_caps_to_codecid (state->caps, NULL);
+
+ /* close old session */
+ if (ffmpegdec->opened) {
+ GST_OBJECT_UNLOCK (ffmpegdec);
+ gst_ffmpegviddec_drain (ffmpegdec);
+ GST_OBJECT_LOCK (ffmpegdec);
+ gst_ffmpegviddec_close (ffmpegdec);
+
+ /* and reset the defaults that were set when a context is created */
+ avcodec_get_context_defaults (ffmpegdec->context);
+ }
+
+ /* set buffer functions */
+ ffmpegdec->context->get_buffer = gst_ffmpegviddec_get_buffer;
+ ffmpegdec->context->release_buffer = gst_ffmpegviddec_release_buffer;
+ ffmpegdec->context->draw_horiz_band = NULL;
+
+ ffmpegdec->has_b_frames = FALSE;
+
+ GST_LOG_OBJECT (ffmpegdec, "size %dx%d", ffmpegdec->context->width,
+ ffmpegdec->context->height);
+
+ /* FIXME : Create a method that takes GstVideoCodecState instead */
+ /* get size and so */
+ gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
+ oclass->in_plugin->type, state->caps, ffmpegdec->context);
+
+ GST_LOG_OBJECT (ffmpegdec, "size after %dx%d", ffmpegdec->context->width,
+ ffmpegdec->context->height);
+
+ if (!ffmpegdec->context->time_base.den || !ffmpegdec->context->time_base.num) {
+ GST_DEBUG_OBJECT (ffmpegdec, "forcing 25/1 framerate");
+ ffmpegdec->context->time_base.num = 1;
+ ffmpegdec->context->time_base.den = 25;
+ }
+
+ /* workaround encoder bugs */
+ ffmpegdec->context->workaround_bugs |= FF_BUG_AUTODETECT;
+ ffmpegdec->context->error_recognition = 1;
+
+ /* for slow cpus */
+ ffmpegdec->context->lowres = ffmpegdec->lowres;
+ ffmpegdec->context->skip_frame = ffmpegdec->skip_frame;
+
+ /* ffmpeg can draw motion vectors on top of the image (not every decoder
+ * supports it) */
+ ffmpegdec->context->debug_mv = ffmpegdec->debug_mv;
+
+ if (ffmpegdec->max_threads == 0) {
+ if (!(oclass->in_plugin->capabilities & CODEC_CAP_AUTO_THREADS))
+ ffmpegdec->context->thread_count = gst_ffmpeg_auto_max_threads ();
+ else
+ ffmpegdec->context->thread_count = 0;
+ } else
+ ffmpegdec->context->thread_count = ffmpegdec->max_threads;
+
+ ffmpegdec->context->thread_type = FF_THREAD_SLICE;
+
+ /* open codec - we don't select an output pix_fmt yet,
+ * simply because we don't know! We only get it
+ * during playback... */
+ if (!gst_ffmpegviddec_open (ffmpegdec))
+ goto open_failed;
+
+ if (ffmpegdec->input_state)
+ gst_video_codec_state_unref (ffmpegdec->input_state);
+ ffmpegdec->input_state = gst_video_codec_state_ref (state);
+
+ ret = TRUE;
+
+done:
+ GST_OBJECT_UNLOCK (ffmpegdec);
+
+ return ret;
+
+ /* ERRORS */
+open_failed:
+ {
+ GST_DEBUG_OBJECT (ffmpegdec, "Failed to open");
+ goto done;
+ }
+}
+
+typedef struct
+{
+ GstVideoCodecFrame *frame;
+ gboolean mapped;
+ GstVideoFrame vframe;
+} GstFFMpegVidDecVideoFrame;
+
+static GstFFMpegVidDecVideoFrame *
+gst_ffmpegviddec_video_frame_new (GstVideoCodecFrame * frame)
+{
+ GstFFMpegVidDecVideoFrame *dframe;
+
+ dframe = g_slice_new0 (GstFFMpegVidDecVideoFrame);
+ dframe->frame = frame;
+
+ return dframe;
+}
+
+static void
+gst_ffmpegviddec_video_frame_free (GstFFMpegVidDecVideoFrame * frame)
+{
+ if (frame->mapped)
+ gst_video_frame_unmap (&frame->vframe);
+ gst_video_codec_frame_unref (frame->frame);
+ g_slice_free (GstFFMpegVidDecVideoFrame, frame);
+}
+
+/* called when ffmpeg wants us to allocate a buffer to write the decoded frame
+ * into. We try to give it memory from our pool */
+static int
+gst_ffmpegviddec_get_buffer (AVCodecContext * context, AVFrame * picture)
+{
+ GstVideoCodecFrame *frame;
+ GstFFMpegVidDecVideoFrame *dframe;
+ GstFFMpegVidDec *ffmpegdec;
+ gint c;
+ GstVideoInfo *info;
+ GstFlowReturn ret;
+
+ ffmpegdec = (GstFFMpegVidDec *) context->opaque;
+
+ GST_DEBUG_OBJECT (ffmpegdec, "getting buffer");
+
+ /* apply the last info we have seen to this picture, when we get the
+ * picture back from ffmpeg we can use this to correctly timestamp the output
+ * buffer */
+ picture->reordered_opaque = context->reordered_opaque;
+
+ frame =
+ gst_video_decoder_get_frame (GST_VIDEO_DECODER (ffmpegdec),
+ picture->reordered_opaque);
+ if (G_UNLIKELY (frame == NULL))
+ goto no_frame;
+
+ if (G_UNLIKELY (frame->output_buffer != NULL))
+ goto duplicate_frame;
+
+ /* GstFFMpegVidDecVideoFrame receives the frame ref */
+ picture->opaque = dframe = gst_ffmpegviddec_video_frame_new (frame);
+
+ ffmpegdec->context->pix_fmt = context->pix_fmt;
+
+ /* see if we need renegotiation */
+ if (G_UNLIKELY (!gst_ffmpegviddec_negotiate (ffmpegdec, FALSE)))
+ goto negotiate_failed;
+
+ if (!ffmpegdec->current_dr)
+ goto no_dr;
+
+ ret =
+ gst_video_decoder_allocate_output_frame (GST_VIDEO_DECODER (ffmpegdec),
+ frame);
+ if (ret != GST_FLOW_OK)
+ goto alloc_failed;
+
+ /* Fill avpicture */
+ info = &ffmpegdec->output_state->info;
+ if (!gst_video_frame_map (&dframe->vframe, info, dframe->frame->output_buffer,
+ GST_MAP_READWRITE))
+ goto invalid_frame;
+ dframe->mapped = TRUE;
+
+ for (c = 0; c < AV_NUM_DATA_POINTERS; c++) {
+ if (c < GST_VIDEO_INFO_N_PLANES (info)) {
+ picture->data[c] = GST_VIDEO_FRAME_PLANE_DATA (&dframe->vframe, c);
+ picture->linesize[c] = GST_VIDEO_FRAME_COMP_STRIDE (&dframe->vframe, c);
+ } else {
+ picture->data[c] = NULL;
+ picture->linesize[c] = 0;
+ }
+ }
+ GST_DEBUG_OBJECT (ffmpegdec, "from GstVideoInfo data %p %p %p",
+ picture->data[0], picture->data[1], picture->data[2]);
+ GST_DEBUG_OBJECT (ffmpegdec, "from GstVideoInfo linesize %d %d %d",
+ picture->linesize[0], picture->linesize[1], picture->linesize[2]);
+
+ /* tell ffmpeg we own this buffer, tranfer the ref we have on the buffer to
+ * the opaque data. */
+ picture->type = FF_BUFFER_TYPE_USER;
+ picture->age = 256 * 256 * 256 * 64;
+
+ GST_LOG_OBJECT (ffmpegdec, "returned frame %p", frame->output_buffer);
+
+ return 0;
+
+ /* fallbacks */
+negotiate_failed:
+ {
+ GST_DEBUG_OBJECT (ffmpegdec, "negotiate failed");
+ goto fallback;
+ }
+no_dr:
+ {
+ GST_LOG_OBJECT (ffmpegdec, "direct rendering disabled, fallback alloc");
+ goto fallback;
+ }
+alloc_failed:
+ {
+ /* alloc default buffer when we can't get one from downstream */
+ GST_LOG_OBJECT (ffmpegdec, "alloc failed, fallback alloc");
+ goto fallback;
+ }
+invalid_frame:
+ {
+ /* alloc default buffer when we can't get one from downstream */
+ GST_LOG_OBJECT (ffmpegdec, "failed to map frame, fallback alloc");
+ gst_buffer_unref (frame->output_buffer);
+ frame->output_buffer = NULL;
+ goto fallback;
+ }
+fallback:
+ {
+ return avcodec_default_get_buffer (context, picture);
+ }
+duplicate_frame:
+ {
+ GST_WARNING_OBJECT (ffmpegdec, "already alloc'ed output buffer for frame");
+ return -1;
+ }
+no_frame:
+ GST_WARNING_OBJECT (ffmpegdec, "Couldn't get codec frame !");
+ return -1;
+}
+
+/* called when ffmpeg is done with our buffer */
+static void
+gst_ffmpegviddec_release_buffer (AVCodecContext * context, AVFrame * picture)
+{
+ gint i;
+ GstFFMpegVidDecVideoFrame *frame;
+ GstFFMpegVidDec *ffmpegdec;
+
+ ffmpegdec = (GstFFMpegVidDec *) context->opaque;
+ frame = (GstFFMpegVidDecVideoFrame *) picture->opaque;
+ GST_DEBUG_OBJECT (ffmpegdec, "release frame %d",
+ frame->frame->system_frame_number);
+
+ /* check if it was our buffer */
+ if (picture->type != FF_BUFFER_TYPE_USER) {
+ GST_DEBUG_OBJECT (ffmpegdec, "default release buffer");
+ avcodec_default_release_buffer (context, picture);
+ }
+
+ /* we remove the opaque data now */
+ picture->opaque = NULL;
+
+ gst_ffmpegviddec_video_frame_free (frame);
+
+ /* zero out the reference in ffmpeg */
+ for (i = 0; i < 4; i++) {
+ picture->data[i] = NULL;
+ picture->linesize[i] = 0;
+ }
+}
+
+static gboolean
+update_video_context (GstFFMpegVidDec * ffmpegdec, gboolean force)
+{
+ AVCodecContext *context = ffmpegdec->context;
+
+ if (!force && ffmpegdec->ctx_width == context->width
+ && ffmpegdec->ctx_height == context->height
+ && ffmpegdec->ctx_ticks == context->ticks_per_frame
+ && ffmpegdec->ctx_time_n == context->time_base.num
+ && ffmpegdec->ctx_time_d == context->time_base.den
+ && ffmpegdec->ctx_pix_fmt == context->pix_fmt
+ && ffmpegdec->ctx_par_n == context->sample_aspect_ratio.num
+ && ffmpegdec->ctx_par_d == context->sample_aspect_ratio.den)
+ return FALSE;
+
+ GST_DEBUG_OBJECT (ffmpegdec,
+ "Renegotiating video from %dx%d@ %d:%d PAR %d/%d fps to %dx%d@ %d:%d PAR %d/%d fps pixfmt %d",
+ ffmpegdec->ctx_width, ffmpegdec->ctx_height,
+ ffmpegdec->ctx_par_n, ffmpegdec->ctx_par_d,
+ ffmpegdec->ctx_time_n, ffmpegdec->ctx_time_d,
+ context->width, context->height,
+ context->sample_aspect_ratio.num,
+ context->sample_aspect_ratio.den,
+ context->time_base.num, context->time_base.den, context->pix_fmt);
+
+ ffmpegdec->ctx_width = context->width;
+ ffmpegdec->ctx_height = context->height;
+ ffmpegdec->ctx_ticks = context->ticks_per_frame;
+ ffmpegdec->ctx_time_n = context->time_base.num;
+ ffmpegdec->ctx_time_d = context->time_base.den;
+ ffmpegdec->ctx_pix_fmt = context->pix_fmt;
+ ffmpegdec->ctx_par_n = context->sample_aspect_ratio.num;
+ ffmpegdec->ctx_par_d = context->sample_aspect_ratio.den;
+
+ return TRUE;
+}
+
+static void
+gst_ffmpegviddec_update_par (GstFFMpegVidDec * ffmpegdec,
+ GstVideoInfo * in_info, GstVideoInfo * out_info)
+{
+ gboolean demuxer_par_set = FALSE;
+ gboolean decoder_par_set = FALSE;
+ gint demuxer_num = 1, demuxer_denom = 1;
+ gint decoder_num = 1, decoder_denom = 1;
+
+ if (in_info->par_n && in_info->par_d) {
+ demuxer_num = in_info->par_n;
+ demuxer_denom = in_info->par_d;
+ demuxer_par_set = TRUE;
+ GST_DEBUG_OBJECT (ffmpegdec, "Demuxer PAR: %d:%d", demuxer_num,
+ demuxer_denom);
+ }
+
+ if (ffmpegdec->ctx_par_n && ffmpegdec->ctx_par_d) {
+ decoder_num = ffmpegdec->ctx_par_n;
+ decoder_denom = ffmpegdec->ctx_par_d;
+ decoder_par_set = TRUE;
+ GST_DEBUG_OBJECT (ffmpegdec, "Decoder PAR: %d:%d", decoder_num,
+ decoder_denom);
+ }
+
+ if (!demuxer_par_set && !decoder_par_set)
+ goto no_par;
+
+ if (demuxer_par_set && !decoder_par_set)
+ goto use_demuxer_par;
+
+ if (decoder_par_set && !demuxer_par_set)
+ goto use_decoder_par;
+
+ /* Both the demuxer and the decoder provide a PAR. If one of
+ * the two PARs is 1:1 and the other one is not, use the one
+ * that is not 1:1. */
+ if (demuxer_num == demuxer_denom && decoder_num != decoder_denom)
+ goto use_decoder_par;
+
+ if (decoder_num == decoder_denom && demuxer_num != demuxer_denom)
+ goto use_demuxer_par;
+
+ /* Both PARs are non-1:1, so use the PAR provided by the demuxer */
+ goto use_demuxer_par;
+
+use_decoder_par:
+ {
+ GST_DEBUG_OBJECT (ffmpegdec,
+ "Setting decoder provided pixel-aspect-ratio of %u:%u", decoder_num,
+ decoder_denom);
+ out_info->par_n = decoder_num;
+ out_info->par_d = decoder_denom;
+ return;
+ }
+use_demuxer_par:
+ {
+ GST_DEBUG_OBJECT (ffmpegdec,
+ "Setting demuxer provided pixel-aspect-ratio of %u:%u", demuxer_num,
+ demuxer_denom);
+ out_info->par_n = demuxer_num;
+ out_info->par_d = demuxer_denom;
+ return;
+ }
+no_par:
+ {
+ GST_DEBUG_OBJECT (ffmpegdec,
+ "Neither demuxer nor codec provide a pixel-aspect-ratio");
+ out_info->par_n = 1;
+ out_info->par_d = 1;
+ return;
+ }
+}
+
+static gboolean
+gst_ffmpegviddec_negotiate (GstFFMpegVidDec * ffmpegdec, gboolean force)
+{
+ GstVideoFormat fmt;
+ GstVideoInfo *in_info, *out_info;
+ GstVideoCodecState *output_state;
+ gint fps_n, fps_d;
+
+ if (!update_video_context (ffmpegdec, force))
+ return TRUE;
+
+ fmt = gst_ffmpeg_pixfmt_to_videoformat (ffmpegdec->ctx_pix_fmt);
+ if (G_UNLIKELY (fmt == GST_VIDEO_FORMAT_UNKNOWN))
+ goto unknown_format;
+
+ output_state =
+ gst_video_decoder_set_output_state (GST_VIDEO_DECODER (ffmpegdec), fmt,
+ ffmpegdec->ctx_width, ffmpegdec->ctx_height, ffmpegdec->input_state);
+ if (ffmpegdec->output_state)
+ gst_video_codec_state_unref (ffmpegdec->output_state);
+ ffmpegdec->output_state = output_state;
+
+ in_info = &ffmpegdec->input_state->info;
+ out_info = &ffmpegdec->output_state->info;
+
+ /* set the interlaced flag */
+ if (ffmpegdec->ctx_interlaced)
+ out_info->interlace_mode = GST_VIDEO_INTERLACE_MODE_MIXED;
+ else
+ out_info->interlace_mode = GST_VIDEO_INTERLACE_MODE_PROGRESSIVE;
+
+ /* try to find a good framerate */
+ if (in_info->fps_d) {
+ /* take framerate from input when it was specified (#313970) */
+ fps_n = in_info->fps_n;
+ fps_d = in_info->fps_d;
+ } else {
+ fps_n = ffmpegdec->ctx_time_d / ffmpegdec->ctx_ticks;
+ fps_d = ffmpegdec->ctx_time_n;
+
+ if (!fps_d) {
+ GST_LOG_OBJECT (ffmpegdec, "invalid framerate: %d/0, -> %d/1", fps_n,
+ fps_n);
+ fps_d = 1;
+ }
+ if (gst_util_fraction_compare (fps_n, fps_d, 1000, 1) > 0) {
+ GST_LOG_OBJECT (ffmpegdec, "excessive framerate: %d/%d, -> 0/1", fps_n,
+ fps_d);
+ fps_n = 0;
+ fps_d = 1;
+ }
+ }
+ GST_LOG_OBJECT (ffmpegdec, "setting framerate: %d/%d", fps_n, fps_d);
+ out_info->fps_n = fps_n;
+ out_info->fps_d = fps_d;
+
+ /* calculate and update par now */
+ gst_ffmpegviddec_update_par (ffmpegdec, in_info, out_info);
+
+ gst_video_decoder_negotiate (GST_VIDEO_DECODER (ffmpegdec));
+
+ return TRUE;
+
+ /* ERRORS */
+unknown_format:
+ {
+ GST_ERROR_OBJECT (ffmpegdec,
+ "decoder requires a video format unsupported by GStreamer");
+ return FALSE;
+ }
+}
+
+/* perform qos calculations before decoding the next frame.
+ *
+ * Sets the skip_frame flag and if things are really bad, skips to the next
+ * keyframe.
+ *
+ * Returns TRUE if the frame should be decoded, FALSE if the frame can be dropped
+ * entirely.
+ */
+static gboolean
+gst_ffmpegviddec_do_qos (GstFFMpegVidDec * ffmpegdec,
+ GstVideoCodecFrame * frame, gboolean * mode_switch)
+{
+ GstClockTimeDiff diff;
+
+ *mode_switch = FALSE;
+
+ if (frame == NULL)
+ goto no_qos;
+
+ diff =
+ gst_video_decoder_get_max_decode_time (GST_VIDEO_DECODER (ffmpegdec),
+ frame);
+
+ /* if we don't have timing info, then we don't do QoS */
+ if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (diff)))
+ goto no_qos;
+
+ GST_DEBUG_OBJECT (ffmpegdec, "decoding time %" GST_TIME_FORMAT,
+ GST_TIME_ARGS (diff));
+
+ if (diff > 0)
+ goto normal_mode;
+
+ if (diff <= 0) {
+ goto skip_frame;
+ }
+
+no_qos:
+ return TRUE;
+
+normal_mode:
+ {
+ if (ffmpegdec->context->skip_frame != AVDISCARD_DEFAULT) {
+ ffmpegdec->context->skip_frame = AVDISCARD_DEFAULT;
+ *mode_switch = TRUE;
+ GST_DEBUG_OBJECT (ffmpegdec, "QOS: normal mode");
+ }
+ return TRUE;
+ }
+skip_frame:
+ {
+ if (ffmpegdec->context->skip_frame != AVDISCARD_NONREF) {
+ ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
+ *mode_switch = TRUE;
+ GST_DEBUG_OBJECT (ffmpegdec,
+ "QOS: hurry up, diff %" G_GINT64_FORMAT " >= 0", diff);
+ }
+ return FALSE;
+ }
+}
+
+/* get an outbuf buffer with the current picture */
+static GstFlowReturn
+get_output_buffer (GstFFMpegVidDec * ffmpegdec, GstVideoCodecFrame * frame)
+{
+ GstFlowReturn ret = GST_FLOW_OK;
+ AVPicture pic, *outpic;
+ GstVideoFrame vframe;
+ GstVideoInfo *info;
+ gint c;
+
+ GST_LOG_OBJECT (ffmpegdec, "get output buffer");
+
+ ret =
+ gst_video_decoder_allocate_output_frame (GST_VIDEO_DECODER (ffmpegdec),
+ frame);
+ if (G_UNLIKELY (ret != GST_FLOW_OK))
+ goto alloc_failed;
+
+ /* original ffmpeg code does not handle odd sizes correctly.
+ * This patched up version does */
+ /* Fill avpicture */
+ info = &ffmpegdec->output_state->info;
+ if (!gst_video_frame_map (&vframe, info, frame->output_buffer,
+ GST_MAP_READ | GST_MAP_WRITE))
+ goto alloc_failed;
+
+ for (c = 0; c < AV_NUM_DATA_POINTERS; c++) {
+ if (c < GST_VIDEO_INFO_N_COMPONENTS (info)) {
+ pic.data[c] = GST_VIDEO_FRAME_PLANE_DATA (&vframe, c);
+ pic.linesize[c] = GST_VIDEO_FRAME_COMP_STRIDE (&vframe, c);
+ } else {
+ pic.data[c] = NULL;
+ pic.linesize[c] = 0;
+ }
+ }
+
+ outpic = (AVPicture *) ffmpegdec->picture;
+
+ GST_LOG_OBJECT (ffmpegdec, "linsize %d %d %d", outpic->linesize[0],
+ outpic->linesize[1], outpic->linesize[2]);
+ GST_LOG_OBJECT (ffmpegdec, "data %u %u %u", 0,
+ (guint) (outpic->data[1] - outpic->data[0]),
+ (guint) (outpic->data[2] - outpic->data[0]));
+
+ av_picture_copy (&pic, outpic, ffmpegdec->context->pix_fmt,
+ GST_VIDEO_INFO_WIDTH (info), GST_VIDEO_INFO_HEIGHT (info));
+
+ gst_video_frame_unmap (&vframe);
+
+ ffmpegdec->picture->reordered_opaque = -1;
+
+ return ret;
+
+ /* special cases */
+alloc_failed:
+ {
+ GST_DEBUG_OBJECT (ffmpegdec, "pad_alloc failed");
+ return ret;
+ }
+}
+
+static void
+gst_avpacket_init (AVPacket * packet, guint8 * data, guint size)
+{
+ memset (packet, 0, sizeof (AVPacket));
+ packet->data = data;
+ packet->size = size;
+}
+
+/* gst_ffmpegviddec_[video|audio]_frame:
+ * ffmpegdec:
+ * data: pointer to the data to decode
+ * size: size of data in bytes
+ * in_timestamp: incoming timestamp.
+ * in_duration: incoming duration.
+ * in_offset: incoming offset (frame number).
+ * ret: Return flow.
+ *
+ * Returns: number of bytes used in decoding. The check for successful decode is
+ * outbuf being non-NULL.
+ */
+static gint
+gst_ffmpegviddec_video_frame (GstFFMpegVidDec * ffmpegdec,
+ guint8 * data, guint size, GstVideoCodecFrame * frame, GstFlowReturn * ret)
+{
+ gint len = -1;
+ gint have_data;
+ gboolean mode_switch;
+ gboolean decode;
+ gint skip_frame = AVDISCARD_DEFAULT;
+ GstVideoCodecFrame *out_frame;
+ GstFFMpegVidDecVideoFrame *out_dframe;
+ AVPacket packet;
+
+ *ret = GST_FLOW_OK;
+
+ ffmpegdec->context->opaque = ffmpegdec;
+
+ /* in case we skip frames */
+ ffmpegdec->picture->pict_type = -1;
+
+ /* run QoS code, we don't stop decoding the frame when we are late because
+ * else we might skip a reference frame */
+ decode = gst_ffmpegviddec_do_qos (ffmpegdec, frame, &mode_switch);
+
+ if (ffmpegdec->is_realvideo && data != NULL) {
+ gint slice_count;
+ gint i;
+
+ /* setup the slice table for realvideo */
+ if (ffmpegdec->context->slice_offset == NULL)
+ ffmpegdec->context->slice_offset = g_malloc (sizeof (guint32) * 1000);
+
+ slice_count = (*data++) + 1;
+ ffmpegdec->context->slice_count = slice_count;
+
+ for (i = 0; i < slice_count; i++) {
+ data += 4;
+ ffmpegdec->context->slice_offset[i] = GST_READ_UINT32_LE (data);
+ data += 4;
+ }
+ }
+
+ if (!decode) {
+ /* no decoding needed, save previous skip_frame value and brutely skip
+ * decoding everything */
+ skip_frame = ffmpegdec->context->skip_frame;
+ ffmpegdec->context->skip_frame = AVDISCARD_NONREF;
+ }
+
+ if (frame) {
+ /* save reference to the timing info */
+ ffmpegdec->context->reordered_opaque = (gint64) frame->system_frame_number;
+ ffmpegdec->picture->reordered_opaque = (gint64) frame->system_frame_number;
+
+ GST_DEBUG_OBJECT (ffmpegdec, "stored opaque values idx %d",
+ frame->system_frame_number);
+ }
+
+ /* now decode the frame */
+ gst_avpacket_init (&packet, data, size);
+
+ if (ffmpegdec->context->palctrl) {
+ guint8 *pal;
+
+ pal = av_packet_new_side_data (&packet, AV_PKT_DATA_PALETTE,
+ AVPALETTE_SIZE);
+ memcpy (pal, ffmpegdec->context->palctrl->palette, AVPALETTE_SIZE);
+ GST_DEBUG_OBJECT (ffmpegdec, "copy pal %p %p", &packet, pal);
+ }
+
+ len = avcodec_decode_video2 (ffmpegdec->context,
+ ffmpegdec->picture, &have_data, &packet);
+
+ /* restore previous state */
+ if (!decode)
+ ffmpegdec->context->skip_frame = skip_frame;
+
+ GST_DEBUG_OBJECT (ffmpegdec, "after decode: len %d, have_data %d",
+ len, have_data);
+
+ /* when we are in skip_frame mode, don't complain when ffmpeg returned
+ * no data because we told it to skip stuff. */
+ if (len < 0 && (mode_switch || ffmpegdec->context->skip_frame))
+ len = 0;
+
+ /* no data, we're done */
+ if (len < 0 || have_data <= 0)
+ goto beach;
+
+ /* get the output picture timing info again */
+ out_dframe = ffmpegdec->picture->opaque;
+ out_frame = gst_video_codec_frame_ref (out_dframe->frame);
+
+ GST_DEBUG_OBJECT (ffmpegdec,
+ "pts %" G_GUINT64_FORMAT " duration %" G_GUINT64_FORMAT,
+ out_frame->pts, out_frame->duration);
+ GST_DEBUG_OBJECT (ffmpegdec, "picture: pts %" G_GUINT64_FORMAT,
+ (guint64) ffmpegdec->picture->pts);
+ GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d",
+ ffmpegdec->picture->coded_picture_number);
+ GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d",
+ ffmpegdec->picture->reference);
+ GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d",
+ ffmpegdec->picture->display_picture_number);
+ GST_DEBUG_OBJECT (ffmpegdec, "picture: opaque %p",
+ ffmpegdec->picture->opaque);
+ GST_DEBUG_OBJECT (ffmpegdec, "picture: reordered opaque %" G_GUINT64_FORMAT,
+ (guint64) ffmpegdec->picture->reordered_opaque);
+ GST_DEBUG_OBJECT (ffmpegdec, "repeat_pict:%d",
+ ffmpegdec->picture->repeat_pict);
+ GST_DEBUG_OBJECT (ffmpegdec, "interlaced_frame:%d (current:%d)",
+ ffmpegdec->picture->interlaced_frame, ffmpegdec->ctx_interlaced);
+
+ if (G_UNLIKELY (ffmpegdec->picture->interlaced_frame !=
+ ffmpegdec->ctx_interlaced)) {
+ GST_WARNING ("Change in interlacing ! picture:%d, recorded:%d",
+ ffmpegdec->picture->interlaced_frame, ffmpegdec->ctx_interlaced);
+ ffmpegdec->ctx_interlaced = ffmpegdec->picture->interlaced_frame;
+ if (!gst_ffmpegviddec_negotiate (ffmpegdec, TRUE))
+ goto negotiation_error;
+ }
+
+ if (G_UNLIKELY (out_frame->output_buffer == NULL))
+ *ret = get_output_buffer (ffmpegdec, out_frame);
+
+ if (G_UNLIKELY (*ret != GST_FLOW_OK))
+ goto no_output;
+
+ if (ffmpegdec->ctx_interlaced) {
+ /* set interlaced flags */
+ if (ffmpegdec->picture->repeat_pict)
+ GST_BUFFER_FLAG_SET (out_frame->output_buffer, GST_VIDEO_BUFFER_FLAG_RFF);
+ if (ffmpegdec->picture->top_field_first)
+ GST_BUFFER_FLAG_SET (out_frame->output_buffer, GST_VIDEO_BUFFER_FLAG_TFF);
+ if (ffmpegdec->picture->interlaced_frame)
+ GST_BUFFER_FLAG_SET (out_frame->output_buffer,
+ GST_VIDEO_BUFFER_FLAG_INTERLACED);
+ }
+
+ *ret =
+ gst_video_decoder_finish_frame (GST_VIDEO_DECODER (ffmpegdec), out_frame);
+
+beach:
+ GST_DEBUG_OBJECT (ffmpegdec, "return flow %s, len %d",
+ gst_flow_get_name (*ret), len);
+ return len;
+
+ /* special cases */
+no_output:
+ {
+ GST_DEBUG_OBJECT (ffmpegdec, "no output buffer");
+ gst_video_decoder_drop_frame (GST_VIDEO_DECODER (ffmpegdec), out_frame);
+ len = -1;
+ goto beach;
+ }
+
+negotiation_error:
+ {
+ GST_WARNING_OBJECT (ffmpegdec, "Error negotiating format");
+ *ret = GST_FLOW_NOT_NEGOTIATED;
+ goto beach;
+ }
+}
+
+
+/* gst_ffmpegviddec_frame:
+ * ffmpegdec:
+ * data: pointer to the data to decode
+ * size: size of data in bytes
+ * got_data: 0 if no data was decoded, != 0 otherwise.
+ * in_time: timestamp of data
+ * in_duration: duration of data
+ * ret: GstFlowReturn to return in the chain function
+ *
+ * Decode the given frame and pushes it downstream.
+ *
+ * Returns: Number of bytes used in decoding, -1 on error/failure.
+ */
+
+static gint
+gst_ffmpegviddec_frame (GstFFMpegVidDec * ffmpegdec,
+ guint8 * data, guint size, gint * got_data, GstVideoCodecFrame * frame,
+ GstFlowReturn * ret)
+{
+ GstFFMpegVidDecClass *oclass;
+ gint have_data = 0, len = 0;
+
+ if (G_UNLIKELY (ffmpegdec->context->codec == NULL))
+ goto no_codec;
+
+ GST_LOG_OBJECT (ffmpegdec, "data:%p, size:%d", data, size);
+
+ *ret = GST_FLOW_OK;
+ ffmpegdec->context->frame_number++;
+
+ oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+
+ len = gst_ffmpegviddec_video_frame (ffmpegdec, data, size, frame, ret);
+
+ if (frame && frame->output_buffer)
+ have_data = 1;
+
+ if (len < 0 || have_data < 0) {
+ GST_WARNING_OBJECT (ffmpegdec,
+ "avdec_%s: decoding error (len: %d, have_data: %d)",
+ oclass->in_plugin->name, len, have_data);
+ *got_data = 0;
+ goto beach;
+ }
+ if (len == 0 && have_data == 0) {
+ *got_data = 0;
+ goto beach;
+ }
+
+ /* this is where I lost my last clue on ffmpeg... */
+ *got_data = 1;
+
+beach:
+ return len;
+
+ /* ERRORS */
+no_codec:
+ {
+ GST_ERROR_OBJECT (ffmpegdec, "no codec context");
+ *ret = GST_FLOW_NOT_NEGOTIATED;
+ return -1;
+ }
+}
+
+static void
+gst_ffmpegviddec_drain (GstFFMpegVidDec * ffmpegdec)
+{
+ GstFFMpegVidDecClass *oclass;
+
+ oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+
+ if (oclass->in_plugin->capabilities & CODEC_CAP_DELAY) {
+ gint have_data, len, try = 0;
+
+ GST_LOG_OBJECT (ffmpegdec,
+ "codec has delay capabilities, calling until ffmpeg has drained everything");
+
+ do {
+ GstFlowReturn ret;
+
+ len = gst_ffmpegviddec_frame (ffmpegdec, NULL, 0, &have_data, NULL, &ret);
+ if (len < 0 || have_data == 0)
+ break;
+ } while (try++ < 10);
+ }
+}
+
+static GstFlowReturn
+gst_ffmpegviddec_handle_frame (GstVideoDecoder * decoder,
+ GstVideoCodecFrame * frame)
+{
+ GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) decoder;
+ guint8 *data, *bdata;
+ gint size, len, have_data, bsize;
+ GstMapInfo minfo;
+ GstFlowReturn ret = GST_FLOW_OK;
+ gboolean do_padding;
+
+ GST_LOG_OBJECT (ffmpegdec,
+ "Received new data of size %u, pts:%"
+ GST_TIME_FORMAT ", dur:%" GST_TIME_FORMAT,
+ gst_buffer_get_size (frame->input_buffer),
+ GST_TIME_ARGS (frame->pts), GST_TIME_ARGS (frame->duration));
+
+ if (!gst_buffer_map (frame->input_buffer, &minfo, GST_MAP_READ)) {
+ GST_ERROR_OBJECT (ffmpegdec, "Failed to map buffer");
+ return GST_FLOW_ERROR;
+ }
+
+ bdata = minfo.data;
+ bsize = minfo.size;
+
+ if (!GST_MEMORY_IS_ZERO_PADDED (minfo.memory)
+ || (minfo.maxsize - minfo.size) < FF_INPUT_BUFFER_PADDING_SIZE) {
+ /* add padding */
+ if (ffmpegdec->padded_size < bsize + FF_INPUT_BUFFER_PADDING_SIZE) {
+ ffmpegdec->padded_size = bsize + FF_INPUT_BUFFER_PADDING_SIZE;
+ ffmpegdec->padded = g_realloc (ffmpegdec->padded, ffmpegdec->padded_size);
+ GST_LOG_OBJECT (ffmpegdec, "resized padding buffer to %d",
+ ffmpegdec->padded_size);
+ }
+ GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec,
+ "Copy input to add padding");
+ memcpy (ffmpegdec->padded, bdata, bsize);
+ memset (ffmpegdec->padded + bsize, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+
+ bdata = ffmpegdec->padded;
+ do_padding = TRUE;
+ } else {
+ do_padding = FALSE;
+ }
+
+ do {
+ guint8 tmp_padding[FF_INPUT_BUFFER_PADDING_SIZE];
+
+ /* parse, if at all possible */
+ data = bdata;
+ size = bsize;
+
+ if (do_padding) {
+ /* add temporary padding */
+ GST_CAT_TRACE_OBJECT (GST_CAT_PERFORMANCE, ffmpegdec,
+ "Add temporary input padding");
+ memcpy (tmp_padding, data + size, FF_INPUT_BUFFER_PADDING_SIZE);
+ memset (data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ }
+
+ /* decode a frame of audio/video now */
+ len =
+ gst_ffmpegviddec_frame (ffmpegdec, data, size, &have_data, frame, &ret);
+
+ if (do_padding) {
+ memcpy (data + size, tmp_padding, FF_INPUT_BUFFER_PADDING_SIZE);
+ }
+
+ if (ret != GST_FLOW_OK) {
+ GST_LOG_OBJECT (ffmpegdec, "breaking because of flow ret %s",
+ gst_flow_get_name (ret));
+ /* bad flow retun, make sure we discard all data and exit */
+ bsize = 0;
+ break;
+ }
+
+ if (len == 0 && !have_data) {
+ /* nothing was decoded, this could be because no data was available or
+ * because we were skipping frames.
+ * If we have no context we must exit and wait for more data, we keep the
+ * data we tried. */
+ GST_LOG_OBJECT (ffmpegdec, "Decoding didn't return any data, breaking");
+ break;
+ }
+
+ if (len < 0) {
+ /* a decoding error happened, we must break and try again with next data. */
+ GST_LOG_OBJECT (ffmpegdec, "Decoding error, breaking");
+ bsize = 0;
+ break;
+ }
+
+ /* prepare for the next round, for codecs with a context we did this
+ * already when using the parser. */
+ bsize -= len;
+ bdata += len;
+
+ do_padding = TRUE;
+
+ GST_LOG_OBJECT (ffmpegdec, "Before (while bsize>0). bsize:%d , bdata:%p",
+ bsize, bdata);
+ } while (bsize > 0);
+
+ if (bsize > 0)
+ GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize);
+
+ gst_buffer_unmap (frame->input_buffer, &minfo);
+ gst_video_codec_frame_unref (frame);
+
+ return ret;
+}
+
+static gboolean
+gst_ffmpegviddec_stop (GstVideoDecoder * decoder)
+{
+ GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) decoder;
+
+ GST_OBJECT_LOCK (ffmpegdec);
+ gst_ffmpegviddec_close (ffmpegdec);
+ GST_OBJECT_UNLOCK (ffmpegdec);
+ g_free (ffmpegdec->padded);
+ ffmpegdec->padded = NULL;
+ ffmpegdec->padded_size = 0;
+ if (ffmpegdec->input_state)
+ gst_video_codec_state_unref (ffmpegdec->input_state);
+ ffmpegdec->input_state = NULL;
+ if (ffmpegdec->output_state)
+ gst_video_codec_state_unref (ffmpegdec->output_state);
+ ffmpegdec->output_state = NULL;
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_ffmpegviddec_finish (GstVideoDecoder * decoder)
+{
+ GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) decoder;
+
+ gst_ffmpegviddec_drain (ffmpegdec);
+
+ return GST_FLOW_OK;
+}
+
+static gboolean
+gst_ffmpegviddec_reset (GstVideoDecoder * decoder, gboolean hard)
+{
+ GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) decoder;
+
+ if (ffmpegdec->opened) {
+ avcodec_flush_buffers (ffmpegdec->context);
+ }
+
+ return TRUE;
+}
+
+static gboolean
+gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
+{
+ GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) decoder;
+ GstVideoCodecState *state;
+ GstBufferPool *pool;
+ guint size, min, max;
+ GstStructure *config;
+ gboolean have_videometa, have_alignment;
+ GstAllocator *allocator = NULL;
+ GstAllocationParams params = { 0, 15, 0, 0, };
+
+ if (!GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (decoder,
+ query))
+ return FALSE;
+
+ state = gst_video_decoder_get_output_state (decoder);
+
+ if (gst_query_get_n_allocation_params (query) > 0) {
+ gst_query_parse_nth_allocation_param (query, 0, &allocator, &params);
+ params.align = MAX (params.align, 15);
+ } else {
+ gst_query_add_allocation_param (query, allocator, &params);
+ }
+
+ gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
+
+ config = gst_buffer_pool_get_config (pool);
+ gst_buffer_pool_config_set_params (config, state->caps, size, min, max);
+ /* we are happy with the default allocator but we would like to have 16 bytes
+ * aligned and padded memory */
+ gst_buffer_pool_config_set_allocator (config, allocator, &params);
+
+ have_videometa =
+ gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
+ if (have_videometa)
+ gst_buffer_pool_config_add_option (config,
+ GST_BUFFER_POOL_OPTION_VIDEO_META);
+
+ have_alignment =
+ gst_buffer_pool_has_option (pool, GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
+
+ /* we can only enable the alignment if downstream supports the
+ * videometa api */
+ if (have_alignment && have_videometa) {
+ GstVideoAlignment align;
+ gint width, height;
+ gint linesize_align[4];
+ gint i;
+ guint edge;
+
+ width = GST_VIDEO_INFO_WIDTH (&state->info);
+ height = GST_VIDEO_INFO_HEIGHT (&state->info);
+ /* let ffmpeg find the alignment and padding */
+ avcodec_align_dimensions2 (ffmpegdec->context, &width, &height,
+ linesize_align);
+ edge =
+ ffmpegdec->
+ context->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width ();
+ /* increase the size for the padding */
+ width += edge << 1;
+ height += edge << 1;
+
+ align.padding_top = edge;
+ align.padding_left = edge;
+ align.padding_right = width - GST_VIDEO_INFO_WIDTH (&state->info) - edge;
+ align.padding_bottom = height - GST_VIDEO_INFO_HEIGHT (&state->info) - edge;
+ for (i = 0; i < GST_VIDEO_MAX_PLANES; i++)
+ align.stride_align[i] =
+ (linesize_align[i] > 0 ? linesize_align[i] - 1 : 0);
+
+ GST_DEBUG_OBJECT (ffmpegdec, "aligned dimension %dx%d -> %dx%d "
+ "padding t:%u l:%u r:%u b:%u, stride_align %d:%d:%d:%d",
+ GST_VIDEO_INFO_WIDTH (&state->info),
+ GST_VIDEO_INFO_HEIGHT (&state->info), width, height, align.padding_top,
+ align.padding_left, align.padding_right, align.padding_bottom,
+ align.stride_align[0], align.stride_align[1], align.stride_align[2],
+ align.stride_align[3]);
+
+ gst_buffer_pool_config_add_option (config,
+ GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
+ gst_buffer_pool_config_set_video_alignment (config, &align);
+
+ if (ffmpegdec->direct_rendering) {
+ GstFFMpegVidDecClass *oclass;
+
+ GST_DEBUG_OBJECT (ffmpegdec, "trying to enable direct rendering");
+
+ oclass = (GstFFMpegVidDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec));
+
+ if (oclass->in_plugin->capabilities & CODEC_CAP_DR1) {
+ GST_DEBUG_OBJECT (ffmpegdec, "enabled direct rendering");
+ ffmpegdec->current_dr = TRUE;
+ } else {
+ GST_DEBUG_OBJECT (ffmpegdec, "direct rendering not supported");
+ }
+ }
+ } else {
+ GST_DEBUG_OBJECT (ffmpegdec,
+ "alignment or videometa not supported, disable direct rendering");
+
+ /* disable direct rendering. This will make us use the fallback ffmpeg
+ * picture allocation code with padding etc. We will then do the final
+ * copy (with cropping) into a buffer from our pool */
+ ffmpegdec->current_dr = FALSE;
+ }
+
+ /* and store */
+ gst_buffer_pool_set_config (pool, config);
+
+ gst_object_unref (pool);
+ if (allocator)
+ gst_object_unref (allocator);
+ gst_video_codec_state_unref (state);
+
+ return TRUE;
+}
+
+static gboolean
+gst_ffmpegviddec_propose_allocation (GstVideoDecoder * decoder,
+ GstQuery * query)
+{
+ GstAllocationParams params;
+
+ gst_allocation_params_init (&params);
+ params.flags = GST_MEMORY_FLAG_ZERO_PADDED;
+ params.align = 15;
+ params.padding = FF_INPUT_BUFFER_PADDING_SIZE;
+ /* we would like to have some padding so that we don't have to
+ * memcpy. We don't suggest an allocator. */
+ gst_query_add_allocation_param (query, NULL, &params);
+
+ return GST_VIDEO_DECODER_CLASS (parent_class)->propose_allocation (decoder,
+ query);
+}
+
+static void
+gst_ffmpegviddec_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
+{
+ GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) object;
+
+ switch (prop_id) {
+ case PROP_LOWRES:
+ ffmpegdec->lowres = ffmpegdec->context->lowres = g_value_get_enum (value);
+ break;
+ case PROP_SKIPFRAME:
+ ffmpegdec->skip_frame = ffmpegdec->context->skip_frame =
+ g_value_get_enum (value);
+ break;
+ case PROP_DIRECT_RENDERING:
+ ffmpegdec->direct_rendering = g_value_get_boolean (value);
+ break;
+ case PROP_DEBUG_MV:
+ ffmpegdec->debug_mv = ffmpegdec->context->debug_mv =
+ g_value_get_boolean (value);
+ break;
+ case PROP_MAX_THREADS:
+ ffmpegdec->max_threads = g_value_get_int (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_ffmpegviddec_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
+{
+ GstFFMpegVidDec *ffmpegdec = (GstFFMpegVidDec *) object;
+
+ switch (prop_id) {
+ case PROP_LOWRES:
+ g_value_set_enum (value, ffmpegdec->context->lowres);
+ break;
+ case PROP_SKIPFRAME:
+ g_value_set_enum (value, ffmpegdec->context->skip_frame);
+ break;
+ case PROP_DIRECT_RENDERING:
+ g_value_set_boolean (value, ffmpegdec->direct_rendering);
+ break;
+ case PROP_DEBUG_MV:
+ g_value_set_boolean (value, ffmpegdec->context->debug_mv);
+ break;
+ case PROP_MAX_THREADS:
+ g_value_set_int (value, ffmpegdec->max_threads);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+gboolean
+gst_ffmpegviddec_register (GstPlugin * plugin)
+{
+ GTypeInfo typeinfo = {
+ sizeof (GstFFMpegVidDecClass),
+ (GBaseInitFunc) gst_ffmpegviddec_base_init,
+ NULL,
+ (GClassInitFunc) gst_ffmpegviddec_class_init,
+ NULL,
+ NULL,
+ sizeof (GstFFMpegVidDec),
+ 0,
+ (GInstanceInitFunc) gst_ffmpegviddec_init,
+ };
+ GType type;
+ AVCodec *in_plugin;
+ gint rank;
+
+ in_plugin = av_codec_next (NULL);
+
+ GST_LOG ("Registering decoders");
+
+ while (in_plugin) {
+ gchar *type_name;
+ gchar *plugin_name;
+
+ /* only decoders */
+ if (!in_plugin->decode) {
+ goto next;
+ }
+
+ /* no quasi-codecs, please */
+ if (in_plugin->id == CODEC_ID_RAWVIDEO ||
+ in_plugin->id == CODEC_ID_V210 ||
+ in_plugin->id == CODEC_ID_V210X ||
+ in_plugin->id == CODEC_ID_R210 ||
+ (in_plugin->id >= CODEC_ID_PCM_S16LE &&
+ in_plugin->id <= CODEC_ID_PCM_BLURAY)) {
+ goto next;
+ }
+
+ /* No decoders depending on external libraries (we don't build them, but
+ * people who build against an external ffmpeg might have them.
+ * We have native gstreamer plugins for all of those libraries anyway. */
+ if (!strncmp (in_plugin->name, "lib", 3)) {
+ GST_DEBUG
+ ("Not using external library decoder %s. Use the gstreamer-native ones instead.",
+ in_plugin->name);
+ goto next;
+ }
+
+ /* No vdpau plugins until we can figure out how to properly use them
+ * outside of ffmpeg. */
+ if (g_str_has_suffix (in_plugin->name, "_vdpau")) {
+ GST_DEBUG
+ ("Ignoring VDPAU decoder %s. We can't handle this outside of ffmpeg",
+ in_plugin->name);
+ goto next;
+ }
+
+ if (g_str_has_suffix (in_plugin->name, "_xvmc")) {
+ GST_DEBUG
+ ("Ignoring XVMC decoder %s. We can't handle this outside of ffmpeg",
+ in_plugin->name);
+ goto next;
+ }
+
+ GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
+
+ /* no codecs for which we're GUARANTEED to have better alternatives */
+ /* MPEG1VIDEO : the mpeg2video decoder is preferred */
+ /* MP1 : Use MP3 for decoding */
+ /* MP2 : Use MP3 for decoding */
+ /* Theora: Use libtheora based theoradec */
+ if (!strcmp (in_plugin->name, "gif") ||
+ !strcmp (in_plugin->name, "theora") ||
+ !strcmp (in_plugin->name, "mpeg1video") ||
+ !strcmp (in_plugin->name, "ass") ||
+ !strcmp (in_plugin->name, "srt") ||
+ !strcmp (in_plugin->name, "pgssub") ||
+ !strcmp (in_plugin->name, "dvdsub") ||
+ !strcmp (in_plugin->name, "dvbsub")) {
+ GST_LOG ("Ignoring decoder %s", in_plugin->name);
+ goto next;
+ }
+
+ /* construct the type */
+ plugin_name = g_strdup ((gchar *) in_plugin->name);
+ g_strdelimit (plugin_name, NULL, '_');
+ type_name = g_strdup_printf ("avdec_%s", plugin_name);
+ g_free (plugin_name);
+
+ type = g_type_from_name (type_name);
+
+ if (!type) {
+ /* create the gtype now */
+ type =
+ g_type_register_static (GST_TYPE_VIDEO_DECODER, type_name, &typeinfo,
+ 0);
+ g_type_set_qdata (type, GST_FFDEC_PARAMS_QDATA, (gpointer) in_plugin);
+ }
+
+ /* (Ronald) MPEG-4 gets a higher priority because it has been well-
+ * tested and by far outperforms divxdec/xviddec - so we prefer it.
+ * msmpeg4v3 same, as it outperforms divxdec for divx3 playback.
+ * VC1/WMV3 are not working and thus unpreferred for now. */
+ switch (in_plugin->id) {
+ case CODEC_ID_MPEG4:
+ case CODEC_ID_MSMPEG4V3:
+ case CODEC_ID_H264:
+ case CODEC_ID_RV10:
+ case CODEC_ID_RV20:
+ case CODEC_ID_RV30:
+ case CODEC_ID_RV40:
+ rank = GST_RANK_PRIMARY;
+ break;
+ /* DVVIDEO: we have a good dv decoder, fast on both ppc as well as x86.
+ * They say libdv's quality is better though. leave as secondary.
+ * note: if you change this, see the code in gstdv.c in good/ext/dv.
+ */
+ case CODEC_ID_DVVIDEO:
+ rank = GST_RANK_SECONDARY;
+ break;
+ default:
+ rank = GST_RANK_MARGINAL;
+ break;
+ }
+ if (!gst_element_register (plugin, type_name, rank, type)) {
+ g_warning ("Failed to register %s", type_name);
+ g_free (type_name);
+ return FALSE;
+ }
+
+ g_free (type_name);
+
+ next:
+ in_plugin = av_codec_next (in_plugin);
+ }
+
+ GST_LOG ("Finished Registering decoders");
+
+ return TRUE;
+}
diff --git a/ext/ffmpeg/gstffmpegvidenc.c b/ext/ffmpeg/gstffmpegvidenc.c
new file mode 100644
index 0000000..4204e08
--- /dev/null
+++ b/ext/ffmpeg/gstffmpegvidenc.c
@@ -0,0 +1,1030 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <assert.h>
+#include <string.h>
+/* for stats file handling */
+#include <stdio.h>
+#include <glib/gstdio.h>
+#include <errno.h>
+
+#ifdef HAVE_LIBAV_UNINSTALLED
+#include <avcodec.h>
+#else
+#include <libavcodec/avcodec.h>
+#endif
+
+#include <gst/gst.h>
+#include <gst/video/gstvideometa.h>
+
+#include "gstffmpeg.h"
+#include "gstffmpegcodecmap.h"
+#include "gstffmpegutils.h"
+#include "gstffmpegvidenc.h"
+#include "gstffmpegcfg.h"
+
+#define DEFAULT_VIDEO_BITRATE 300000 /* in bps */
+#define DEFAULT_VIDEO_GOP_SIZE 15
+
+#define DEFAULT_WIDTH 352
+#define DEFAULT_HEIGHT 288
+
+
+#define VIDEO_BUFFER_SIZE (1024*1024)
+
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum
+{
+ ARG_0,
+ ARG_BIT_RATE,
+ ARG_GOP_SIZE,
+ ARG_ME_METHOD,
+ ARG_BUFSIZE,
+ ARG_RTP_PAYLOAD_SIZE,
+ ARG_CFG_BASE
+};
+
+#define GST_TYPE_ME_METHOD (gst_ffmpegvidenc_me_method_get_type())
+static GType
+gst_ffmpegvidenc_me_method_get_type (void)
+{
+ static GType ffmpegenc_me_method_type = 0;
+ static GEnumValue ffmpegenc_me_methods[] = {
+ {ME_ZERO, "None (Very low quality)", "zero"},
+ {ME_FULL, "Full (Slow, unmaintained)", "full"},
+ {ME_LOG, "Logarithmic (Low quality, unmaintained)", "logarithmic"},
+ {ME_PHODS, "phods (Low quality, unmaintained)", "phods"},
+ {ME_EPZS, "EPZS (Best quality, Fast)", "epzs"},
+ {ME_X1, "X1 (Experimental)", "x1"},
+ {0, NULL, NULL},
+ };
+ if (!ffmpegenc_me_method_type) {
+ ffmpegenc_me_method_type =
+ g_enum_register_static ("GstLibAVVidEncMeMethod", ffmpegenc_me_methods);
+ }
+ return ffmpegenc_me_method_type;
+}
+
+/* A number of function prototypes are given so we can refer to them later. */
+static void gst_ffmpegvidenc_class_init (GstFFMpegVidEncClass * klass);
+static void gst_ffmpegvidenc_base_init (GstFFMpegVidEncClass * klass);
+static void gst_ffmpegvidenc_init (GstFFMpegVidEnc * ffmpegenc);
+static void gst_ffmpegvidenc_finalize (GObject * object);
+
+static gboolean gst_ffmpegvidenc_stop (GstVideoEncoder * encoder);
+static GstFlowReturn gst_ffmpegvidenc_finish (GstVideoEncoder * encoder);
+static gboolean gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder,
+ GstVideoCodecState * state);
+static gboolean gst_ffmpegvidenc_propose_allocation (GstVideoEncoder * encoder,
+ GstQuery * query);
+
+static GstCaps *gst_ffmpegvidenc_getcaps (GstVideoEncoder * encoder,
+ GstCaps * filter);
+static GstFlowReturn gst_ffmpegvidenc_handle_frame (GstVideoEncoder * encoder,
+ GstVideoCodecFrame * frame);
+
+static void gst_ffmpegvidenc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec);
+static void gst_ffmpegvidenc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec);
+
+#define GST_FFENC_PARAMS_QDATA g_quark_from_static_string("avenc-params")
+
+static GstElementClass *parent_class = NULL;
+
+/*static guint gst_ffmpegvidenc_signals[LAST_SIGNAL] = { 0 }; */
+
+static void
+gst_ffmpegvidenc_base_init (GstFFMpegVidEncClass * klass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ AVCodec *in_plugin;
+ GstPadTemplate *srctempl = NULL, *sinktempl = NULL;
+ GstCaps *srccaps = NULL, *sinkcaps = NULL;
+ gchar *longname, *description;
+
+ in_plugin =
+ (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
+ GST_FFENC_PARAMS_QDATA);
+ g_assert (in_plugin != NULL);
+
+ /* construct the element details struct */
+ longname = g_strdup_printf ("libav %s encoder", in_plugin->long_name);
+ description = g_strdup_printf ("libav %s encoder", in_plugin->name);
+ gst_element_class_set_metadata (element_class, longname,
+ "Codec/Encoder/Video", description,
+ "Wim Taymans <wim.taymans@gmail.com>, "
+ "Ronald Bultje <rbultje@ronald.bitfreak.net>");
+ g_free (longname);
+ g_free (description);
+
+ if (!(srccaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, TRUE))) {
+ GST_DEBUG ("Couldn't get source caps for encoder '%s'", in_plugin->name);
+ srccaps = gst_caps_new_empty_simple ("unknown/unknown");
+ }
+
+ sinkcaps = gst_caps_new_empty_simple ("video/x-raw");
+
+ /* pad templates */
+ sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
+ GST_PAD_ALWAYS, sinkcaps);
+ srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);
+
+ gst_element_class_add_pad_template (element_class, srctempl);
+ gst_element_class_add_pad_template (element_class, sinktempl);
+
+ klass->in_plugin = in_plugin;
+ klass->srctempl = srctempl;
+ klass->sinktempl = sinktempl;
+ klass->sinkcaps = NULL;
+
+ return;
+}
+
+static void
+gst_ffmpegvidenc_class_init (GstFFMpegVidEncClass * klass)
+{
+ GObjectClass *gobject_class;
+ GstVideoEncoderClass *venc_class;
+
+ gobject_class = (GObjectClass *) klass;
+ venc_class = (GstVideoEncoderClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->set_property = gst_ffmpegvidenc_set_property;
+ gobject_class->get_property = gst_ffmpegvidenc_get_property;
+
+ /* FIXME: could use -1 for a sensible per-codec default based on
+ * e.g. input resolution and framerate */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BIT_RATE,
+ g_param_spec_int ("bitrate", "Bit Rate",
+ "Target Video Bitrate", 0, G_MAXINT, DEFAULT_VIDEO_BITRATE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_GOP_SIZE,
+ g_param_spec_int ("gop-size", "GOP Size",
+ "Number of frames within one GOP", 0, G_MAXINT,
+ DEFAULT_VIDEO_GOP_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ME_METHOD,
+ g_param_spec_enum ("me-method", "ME Method", "Motion Estimation Method",
+ GST_TYPE_ME_METHOD, ME_EPZS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFSIZE,
+ g_param_spec_int ("buffer-size", "Buffer Size",
+ "Size of the video buffers", 0, G_MAXINT, 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (G_OBJECT_CLASS (klass),
+ ARG_RTP_PAYLOAD_SIZE, g_param_spec_int ("rtp-payload-size",
+ "RTP Payload Size", "Target GOB length", 0, G_MAXINT, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /* register additional properties, possibly dependent on the exact CODEC */
+ gst_ffmpeg_cfg_install_property (klass, ARG_CFG_BASE);
+
+ venc_class->stop = gst_ffmpegvidenc_stop;
+ venc_class->finish = gst_ffmpegvidenc_finish;
+ venc_class->handle_frame = gst_ffmpegvidenc_handle_frame;
+ venc_class->getcaps = gst_ffmpegvidenc_getcaps;
+ venc_class->set_format = gst_ffmpegvidenc_set_format;
+ venc_class->propose_allocation = gst_ffmpegvidenc_propose_allocation;
+
+ gobject_class->finalize = gst_ffmpegvidenc_finalize;
+}
+
+static void
+gst_ffmpegvidenc_init (GstFFMpegVidEnc * ffmpegenc)
+{
+ /* ffmpeg objects */
+ ffmpegenc->context = avcodec_alloc_context ();
+ ffmpegenc->picture = avcodec_alloc_frame ();
+ ffmpegenc->opened = FALSE;
+
+ ffmpegenc->file = NULL;
+
+ ffmpegenc->bitrate = DEFAULT_VIDEO_BITRATE;
+ ffmpegenc->me_method = ME_EPZS;
+ ffmpegenc->buffer_size = 512 * 1024;
+ ffmpegenc->gop_size = DEFAULT_VIDEO_GOP_SIZE;
+ ffmpegenc->rtp_payload_size = 0;
+
+ ffmpegenc->lmin = 2;
+ ffmpegenc->lmax = 31;
+ ffmpegenc->max_key_interval = 0;
+
+ gst_ffmpeg_cfg_set_defaults (ffmpegenc);
+}
+
+static void
+gst_ffmpegvidenc_finalize (GObject * object)
+{
+ GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) object;
+
+ gst_ffmpeg_cfg_finalize (ffmpegenc);
+
+ /* close old session */
+ if (ffmpegenc->opened) {
+ gst_ffmpeg_avcodec_close (ffmpegenc->context);
+ ffmpegenc->opened = FALSE;
+ }
+
+ /* clean up remaining allocated data */
+ av_free (ffmpegenc->context);
+ av_free (ffmpegenc->picture);
+
+ g_free (ffmpegenc->filename);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static GstCaps *
+gst_ffmpegvidenc_getcaps (GstVideoEncoder * encoder, GstCaps * filter)
+{
+ GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) encoder;
+ GstFFMpegVidEncClass *oclass =
+ (GstFFMpegVidEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
+ AVCodecContext *ctx = NULL;
+ enum PixelFormat pixfmt;
+ GstCaps *caps = NULL;
+ gint i;
+
+ GST_DEBUG_OBJECT (ffmpegenc, "getting caps");
+
+ /* cached */
+ if (oclass->sinkcaps) {
+ caps = gst_video_encoder_proxy_getcaps (encoder, oclass->sinkcaps, filter);
+ GST_DEBUG_OBJECT (ffmpegenc, "return cached caps %" GST_PTR_FORMAT, caps);
+ return caps;
+ }
+
+ /* create cache etc. */
+
+ /* shut up the logging while we autoprobe; we don't want warnings and
+ * errors about unsupported formats */
+ /* FIXME: if someone cares about this disabling the logging for other
+ * instances/threads/..., one could investigate if there is a way to
+ * set this as a struct member on the av context, and check it from the
+ * log handler */
+#ifndef GST_DISABLE_GST_DEBUG
+ _shut_up_I_am_probing = TRUE;
+#endif
+ GST_DEBUG_OBJECT (ffmpegenc, "probing caps");
+ i = pixfmt = 0;
+ /* check pixfmt until deemed finished */
+ for (pixfmt = 0;; pixfmt++) {
+ GstCaps *tmpcaps;
+
+ /* override looping all pixfmt if codec declares pixfmts;
+ * these may not properly check and report supported pixfmt during _init */
+ if (oclass->in_plugin->pix_fmts) {
+ if ((pixfmt = oclass->in_plugin->pix_fmts[i++]) == PIX_FMT_NONE) {
+ GST_DEBUG_OBJECT (ffmpegenc,
+ "At the end of official pixfmt for this codec, breaking out");
+ break;
+ }
+ GST_DEBUG_OBJECT (ffmpegenc,
+ "Got an official pixfmt [%d], attempting to get caps", pixfmt);
+ tmpcaps = gst_ffmpeg_pixfmt_to_caps (pixfmt, NULL, oclass->in_plugin->id);
+ if (tmpcaps) {
+ GST_DEBUG_OBJECT (ffmpegenc, "Got caps, breaking out");
+ if (!caps)
+ caps = gst_caps_new_empty ();
+ gst_caps_append (caps, tmpcaps);
+ continue;
+ }
+ GST_DEBUG_OBJECT (ffmpegenc,
+ "Couldn't figure out caps without context, trying again with a context");
+ }
+
+ GST_DEBUG_OBJECT (ffmpegenc, "pixfmt :%d", pixfmt);
+ if (pixfmt >= PIX_FMT_NB) {
+ GST_WARNING ("Invalid pixfmt, breaking out");
+ break;
+ }
+
+ /* need to start with a fresh codec_context each time around, since
+ * codec_close may have released stuff causing the next pass to segfault */
+ ctx = avcodec_alloc_context ();
+ if (!ctx) {
+ GST_DEBUG_OBJECT (ffmpegenc, "no context");
+ break;
+ }
+
+ /* set some default properties */
+ ctx->width = DEFAULT_WIDTH;
+ ctx->height = DEFAULT_HEIGHT;
+ ctx->time_base.num = 1;
+ ctx->time_base.den = 25;
+ ctx->ticks_per_frame = 1;
+ ctx->bit_rate = DEFAULT_VIDEO_BITRATE;
+ /* makes it silent */
+ ctx->strict_std_compliance = -1;
+
+ ctx->pix_fmt = pixfmt;
+
+ GST_DEBUG ("Attempting to open codec");
+ if (gst_ffmpeg_avcodec_open (ctx, oclass->in_plugin) >= 0 &&
+ ctx->pix_fmt == pixfmt) {
+ ctx->width = -1;
+ if (!caps)
+ caps = gst_caps_new_empty ();
+ tmpcaps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type, ctx,
+ oclass->in_plugin->id, TRUE);
+ if (tmpcaps)
+ gst_caps_append (caps, tmpcaps);
+ else
+ GST_LOG_OBJECT (ffmpegenc,
+ "Couldn't get caps for oclass->in_plugin->name:%s",
+ oclass->in_plugin->name);
+ gst_ffmpeg_avcodec_close (ctx);
+ } else {
+ GST_DEBUG_OBJECT (ffmpegenc, "Opening codec failed with pixfmt : %d",
+ pixfmt);
+ }
+ if (ctx->priv_data)
+ gst_ffmpeg_avcodec_close (ctx);
+ av_free (ctx);
+ }
+#ifndef GST_DISABLE_GST_DEBUG
+ _shut_up_I_am_probing = FALSE;
+#endif
+
+ oclass->sinkcaps = caps;
+
+ return gst_video_encoder_proxy_getcaps (encoder, caps, filter);
+}
+
+static gboolean
+gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder,
+ GstVideoCodecState * state)
+{
+ GstCaps *other_caps;
+ GstCaps *allowed_caps;
+ GstCaps *icaps;
+ GstVideoCodecState *output_format;
+ enum PixelFormat pix_fmt;
+ GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) encoder;
+ GstFFMpegVidEncClass *oclass =
+ (GstFFMpegVidEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
+
+ /* close old session */
+ if (ffmpegenc->opened) {
+ gst_ffmpeg_avcodec_close (ffmpegenc->context);
+ ffmpegenc->opened = FALSE;
+ }
+
+ /* set defaults */
+ avcodec_get_context_defaults (ffmpegenc->context);
+
+ /* if we set it in _getcaps we should set it also in _link */
+ ffmpegenc->context->strict_std_compliance = -1;
+
+ /* user defined properties */
+ ffmpegenc->context->bit_rate = ffmpegenc->bitrate;
+ ffmpegenc->context->bit_rate_tolerance = ffmpegenc->bitrate;
+ ffmpegenc->context->gop_size = ffmpegenc->gop_size;
+ ffmpegenc->context->me_method = ffmpegenc->me_method;
+ GST_DEBUG_OBJECT (ffmpegenc, "Setting avcontext to bitrate %d, gop_size %d",
+ ffmpegenc->bitrate, ffmpegenc->gop_size);
+
+ /* RTP payload used for GOB production (for Asterisk) */
+ if (ffmpegenc->rtp_payload_size) {
+ ffmpegenc->context->rtp_payload_size = ffmpegenc->rtp_payload_size;
+ }
+
+ /* additional avcodec settings */
+ /* first fill in the majority by copying over */
+ gst_ffmpeg_cfg_fill_context (ffmpegenc, ffmpegenc->context);
+
+ /* then handle some special cases */
+ ffmpegenc->context->lmin = (ffmpegenc->lmin * FF_QP2LAMBDA + 0.5);
+ ffmpegenc->context->lmax = (ffmpegenc->lmax * FF_QP2LAMBDA + 0.5);
+
+ if (ffmpegenc->interlaced) {
+ ffmpegenc->context->flags |=
+ CODEC_FLAG_INTERLACED_DCT | CODEC_FLAG_INTERLACED_ME;
+ ffmpegenc->picture->interlaced_frame = TRUE;
+ /* if this is not the case, a filter element should be used to swap fields */
+ ffmpegenc->picture->top_field_first = TRUE;
+ }
+
+ /* some other defaults */
+ ffmpegenc->context->rc_strategy = 2;
+ ffmpegenc->context->b_frame_strategy = 0;
+ ffmpegenc->context->coder_type = 0;
+ ffmpegenc->context->context_model = 0;
+ ffmpegenc->context->scenechange_threshold = 0;
+ ffmpegenc->context->inter_threshold = 0;
+
+ /* and last but not least the pass; CBR, 2-pass, etc */
+ ffmpegenc->context->flags |= ffmpegenc->pass;
+ switch (ffmpegenc->pass) {
+ /* some additional action depends on type of pass */
+ case CODEC_FLAG_QSCALE:
+ ffmpegenc->context->global_quality
+ = ffmpegenc->picture->quality = FF_QP2LAMBDA * ffmpegenc->quantizer;
+ break;
+ case CODEC_FLAG_PASS1: /* need to prepare a stats file */
+ /* we don't close when changing caps, fingers crossed */
+ if (!ffmpegenc->file)
+ ffmpegenc->file = g_fopen (ffmpegenc->filename, "w");
+ if (!ffmpegenc->file)
+ goto open_file_err;
+ break;
+ case CODEC_FLAG_PASS2:
+ { /* need to read the whole stats file ! */
+ gsize size;
+
+ if (!g_file_get_contents (ffmpegenc->filename,
+ &ffmpegenc->context->stats_in, &size, NULL))
+ goto file_read_err;
+
+ break;
+ }
+ default:
+ break;
+ }
+
+ GST_DEBUG_OBJECT (ffmpegenc, "Extracting common video information");
+ /* fetch pix_fmt, fps, par, width, height... */
+ gst_ffmpeg_videoinfo_to_context (&state->info, ffmpegenc->context);
+
+ if ((oclass->in_plugin->id == CODEC_ID_MPEG4)
+ && (ffmpegenc->context->time_base.den > 65535)) {
+ /* MPEG4 Standards do not support time_base denominator greater than
+ * (1<<16) - 1 . We therefore scale them down.
+ * Agreed, it will not be the exact framerate... but the difference
+ * shouldn't be that noticeable */
+ ffmpegenc->context->time_base.num =
+ (gint) gst_util_uint64_scale_int (ffmpegenc->context->time_base.num,
+ 65535, ffmpegenc->context->time_base.den);
+ ffmpegenc->context->time_base.den = 65535;
+ GST_LOG_OBJECT (ffmpegenc, "MPEG4 : scaled down framerate to %d / %d",
+ ffmpegenc->context->time_base.den, ffmpegenc->context->time_base.num);
+ }
+
+ pix_fmt = ffmpegenc->context->pix_fmt;
+
+ /* max-key-interval may need the framerate set above */
+ if (ffmpegenc->max_key_interval) {
+ AVCodecContext *ctx;
+
+ /* override gop-size */
+ ctx = ffmpegenc->context;
+ ctx->gop_size = (ffmpegenc->max_key_interval < 0) ?
+ (-ffmpegenc->max_key_interval
+ * (ctx->time_base.den * ctx->ticks_per_frame / ctx->time_base.num))
+ : ffmpegenc->max_key_interval;
+ }
+
+ /* open codec */
+ if (gst_ffmpeg_avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0)
+ goto open_codec_fail;
+
+ /* second pass stats buffer no longer needed */
+ if (ffmpegenc->context->stats_in)
+ g_free (ffmpegenc->context->stats_in);
+
+ /* is the colourspace correct? */
+ if (pix_fmt != ffmpegenc->context->pix_fmt)
+ goto pix_fmt_err;
+
+ /* we may have failed mapping caps to a pixfmt,
+ * and quite some codecs do not make up their own mind about that
+ * in any case, _NONE can never work out later on */
+ if (pix_fmt == PIX_FMT_NONE)
+ goto bad_input_fmt;
+
+ /* some codecs support more than one format, first auto-choose one */
+ GST_DEBUG_OBJECT (ffmpegenc, "picking an output format ...");
+ allowed_caps = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder));
+ if (!allowed_caps) {
+ GST_DEBUG_OBJECT (ffmpegenc, "... but no peer, using template caps");
+ /* we need to copy because get_allowed_caps returns a ref, and
+ * get_pad_template_caps doesn't */
+ allowed_caps =
+ gst_pad_get_pad_template_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder));
+ }
+ GST_DEBUG_OBJECT (ffmpegenc, "chose caps %" GST_PTR_FORMAT, allowed_caps);
+ gst_ffmpeg_caps_with_codecid (oclass->in_plugin->id,
+ oclass->in_plugin->type, allowed_caps, ffmpegenc->context);
+
+ /* try to set this caps on the other side */
+ other_caps = gst_ffmpeg_codecid_to_caps (oclass->in_plugin->id,
+ ffmpegenc->context, TRUE);
+
+ if (!other_caps) {
+ gst_caps_unref (allowed_caps);
+ goto unsupported_codec;
+ }
+
+ icaps = gst_caps_intersect (allowed_caps, other_caps);
+ gst_caps_unref (allowed_caps);
+ gst_caps_unref (other_caps);
+ if (gst_caps_is_empty (icaps)) {
+ gst_caps_unref (icaps);
+ return FALSE;
+ }
+
+ if (gst_caps_get_size (icaps) > 1) {
+ GstCaps *newcaps;
+
+ newcaps =
+ gst_caps_new_full (gst_structure_copy (gst_caps_get_structure (icaps,
+ 0)), NULL);
+ gst_caps_unref (icaps);
+ icaps = newcaps;
+ }
+
+ /* Store input state and set output state */
+ if (ffmpegenc->input_state)
+ gst_video_codec_state_unref (ffmpegenc->input_state);
+ ffmpegenc->input_state = gst_video_codec_state_ref (state);
+
+ output_format = gst_video_encoder_set_output_state (encoder, icaps, state);
+ gst_video_codec_state_unref (output_format);
+
+ /* success! */
+ ffmpegenc->opened = TRUE;
+
+ return TRUE;
+
+ /* ERRORS */
+open_file_err:
+ {
+ GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, OPEN_WRITE,
+ (("Could not open file \"%s\" for writing."), ffmpegenc->filename),
+ GST_ERROR_SYSTEM);
+ return FALSE;
+ }
+file_read_err:
+ {
+ GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, READ,
+ (("Could not get contents of file \"%s\"."), ffmpegenc->filename),
+ GST_ERROR_SYSTEM);
+ return FALSE;
+ }
+
+open_codec_fail:
+ {
+ if (ffmpegenc->context->priv_data)
+ gst_ffmpeg_avcodec_close (ffmpegenc->context);
+ if (ffmpegenc->context->stats_in)
+ g_free (ffmpegenc->context->stats_in);
+ GST_DEBUG_OBJECT (ffmpegenc, "avenc_%s: Failed to open libav codec",
+ oclass->in_plugin->name);
+ return FALSE;
+ }
+
+pix_fmt_err:
+ {
+ gst_ffmpeg_avcodec_close (ffmpegenc->context);
+ GST_DEBUG_OBJECT (ffmpegenc,
+ "avenc_%s: AV wants different colourspace (%d given, %d wanted)",
+ oclass->in_plugin->name, pix_fmt, ffmpegenc->context->pix_fmt);
+ return FALSE;
+ }
+
+bad_input_fmt:
+ {
+ GST_DEBUG_OBJECT (ffmpegenc, "avenc_%s: Failed to determine input format",
+ oclass->in_plugin->name);
+ return FALSE;
+ }
+
+unsupported_codec:
+ {
+ gst_ffmpeg_avcodec_close (ffmpegenc->context);
+ GST_DEBUG ("Unsupported codec - no caps found");
+ return FALSE;
+ }
+}
+
+
+static gboolean
+gst_ffmpegvidenc_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);
+}
+
+static void
+ffmpegenc_setup_working_buf (GstFFMpegVidEnc * ffmpegenc)
+{
+ guint wanted_size =
+ ffmpegenc->context->width * ffmpegenc->context->height * 6 +
+ FF_MIN_BUFFER_SIZE;
+
+ /* Above is the buffer size used by ffmpeg/ffmpeg.c */
+
+ if (ffmpegenc->working_buf == NULL ||
+ ffmpegenc->working_buf_size != wanted_size) {
+ if (ffmpegenc->working_buf)
+ g_free (ffmpegenc->working_buf);
+ ffmpegenc->working_buf_size = wanted_size;
+ ffmpegenc->working_buf = g_malloc (ffmpegenc->working_buf_size);
+ }
+ ffmpegenc->buffer_size = wanted_size;
+}
+
+static GstFlowReturn
+gst_ffmpegvidenc_handle_frame (GstVideoEncoder * encoder,
+ GstVideoCodecFrame * frame)
+{
+ GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) encoder;
+ GstBuffer *outbuf;
+ gint ret_size = 0, c;
+ GstVideoInfo *info = &ffmpegenc->input_state->info;
+ GstVideoFrame vframe;
+
+ if (GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME (frame))
+ ffmpegenc->picture->pict_type = FF_I_TYPE;
+
+ if (!gst_video_frame_map (&vframe, info, frame->input_buffer, GST_MAP_READ)) {
+ GST_ERROR_OBJECT (encoder, "Failed to map input buffer");
+ return GST_FLOW_ERROR;
+ }
+
+ /* Fill avpicture */
+ for (c = 0; c < AV_NUM_DATA_POINTERS; c++) {
+ if (c < GST_VIDEO_INFO_N_COMPONENTS (info)) {
+ ffmpegenc->picture->data[c] = GST_VIDEO_FRAME_PLANE_DATA (&vframe, c);
+ ffmpegenc->picture->linesize[c] =
+ GST_VIDEO_FRAME_COMP_STRIDE (&vframe, c);
+ } else {
+ ffmpegenc->picture->data[c] = NULL;
+ ffmpegenc->picture->linesize[c] = 0;
+ }
+ }
+
+ ffmpegenc->picture->pts =
+ gst_ffmpeg_time_gst_to_ff (frame->pts /
+ ffmpegenc->context->ticks_per_frame, ffmpegenc->context->time_base);
+
+ ffmpegenc_setup_working_buf (ffmpegenc);
+
+ ret_size = avcodec_encode_video (ffmpegenc->context,
+ ffmpegenc->working_buf, ffmpegenc->working_buf_size, ffmpegenc->picture);
+
+ gst_video_frame_unmap (&vframe);
+
+ if (ret_size < 0)
+ goto encode_fail;
+
+ /* Encoder needs more data */
+ if (!ret_size)
+ return GST_FLOW_OK;
+
+ /* save stats info if there is some as well as a stats file */
+ if (ffmpegenc->file && ffmpegenc->context->stats_out)
+ if (fprintf (ffmpegenc->file, "%s", ffmpegenc->context->stats_out) < 0)
+ GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, WRITE,
+ (("Could not write to file \"%s\"."), ffmpegenc->filename),
+ GST_ERROR_SYSTEM);
+
+ gst_video_codec_frame_unref (frame);
+
+ /* Get oldest frame */
+ frame = gst_video_encoder_get_oldest_frame (encoder);
+
+ /* Allocate output buffer */
+ if (gst_video_encoder_allocate_output_frame (encoder, frame,
+ ret_size) != GST_FLOW_OK) {
+ gst_video_codec_frame_unref (frame);
+ goto alloc_fail;
+ }
+
+ outbuf = frame->output_buffer;
+ gst_buffer_fill (outbuf, 0, ffmpegenc->working_buf, ret_size);
+
+ /* buggy codec may not set coded_frame */
+ if (ffmpegenc->context->coded_frame) {
+ if (ffmpegenc->context->coded_frame->key_frame)
+ GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
+ } else
+ GST_WARNING_OBJECT (ffmpegenc, "codec did not provide keyframe info");
+
+ /* Reset frame type */
+ if (ffmpegenc->picture->pict_type)
+ ffmpegenc->picture->pict_type = 0;
+
+ return gst_video_encoder_finish_frame (encoder, frame);
+
+ /* ERRORS */
+encode_fail:
+ {
+#ifndef GST_DISABLE_GST_DEBUG
+ GstFFMpegVidEncClass *oclass =
+ (GstFFMpegVidEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
+ GST_ERROR_OBJECT (ffmpegenc,
+ "avenc_%s: failed to encode buffer", oclass->in_plugin->name);
+#endif /* GST_DISABLE_GST_DEBUG */
+ return GST_FLOW_OK;
+ }
+alloc_fail:
+ {
+#ifndef GST_DISABLE_GST_DEBUG
+ GstFFMpegVidEncClass *oclass =
+ (GstFFMpegVidEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
+ GST_ERROR_OBJECT (ffmpegenc,
+ "avenc_%s: failed to allocate buffer", oclass->in_plugin->name);
+#endif /* GST_DISABLE_GST_DEBUG */
+ return GST_FLOW_ERROR;
+ }
+}
+
+static void
+gst_ffmpegvidenc_flush_buffers (GstFFMpegVidEnc * ffmpegenc, gboolean send)
+{
+ GstVideoCodecFrame *frame;
+ GstBuffer *outbuf;
+ gint ret_size;
+
+ GST_DEBUG_OBJECT (ffmpegenc, "flushing buffers with sending %d", send);
+
+ /* no need to empty codec if there is none */
+ if (!ffmpegenc->opened)
+ return;
+
+ while ((frame =
+ gst_video_encoder_get_oldest_frame (GST_VIDEO_ENCODER (ffmpegenc)))) {
+
+ ffmpegenc_setup_working_buf (ffmpegenc);
+
+ ret_size = avcodec_encode_video (ffmpegenc->context,
+ ffmpegenc->working_buf, ffmpegenc->working_buf_size, NULL);
+
+ if (ret_size < 0) { /* there should be something, notify and give up */
+#ifndef GST_DISABLE_GST_DEBUG
+ GstFFMpegVidEncClass *oclass =
+ (GstFFMpegVidEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
+ GST_WARNING_OBJECT (ffmpegenc,
+ "avenc_%s: failed to flush buffer", oclass->in_plugin->name);
+#endif /* GST_DISABLE_GST_DEBUG */
+ gst_video_codec_frame_unref (frame);
+ break;
+ }
+
+ /* save stats info if there is some as well as a stats file */
+ if (ffmpegenc->file && ffmpegenc->context->stats_out)
+ if (fprintf (ffmpegenc->file, "%s", ffmpegenc->context->stats_out) < 0)
+ GST_ELEMENT_ERROR (ffmpegenc, RESOURCE, WRITE,
+ (("Could not write to file \"%s\"."), ffmpegenc->filename),
+ GST_ERROR_SYSTEM);
+
+ if (gst_video_encoder_allocate_output_frame (GST_VIDEO_ENCODER (ffmpegenc),
+ frame, ret_size) != GST_FLOW_OK) {
+#ifndef GST_DISABLE_GST_DEBUG
+ GstFFMpegVidEncClass *oclass =
+ (GstFFMpegVidEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
+ GST_WARNING_OBJECT (ffmpegenc,
+ "avenc_%s: failed to allocate buffer", oclass->in_plugin->name);
+#endif /* GST_DISABLE_GST_DEBUG */
+ gst_video_codec_frame_unref (frame);
+ break;
+ }
+ outbuf = frame->output_buffer;
+ gst_buffer_fill (outbuf, 0, ffmpegenc->working_buf, ret_size);
+
+ if (ffmpegenc->context->coded_frame->key_frame)
+ GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
+
+ gst_video_encoder_finish_frame (GST_VIDEO_ENCODER (ffmpegenc), frame);
+ }
+}
+
+
+static void
+gst_ffmpegvidenc_set_property (GObject * object,
+ guint prop_id, const GValue * value, GParamSpec * pspec)
+{
+ GstFFMpegVidEnc *ffmpegenc;
+
+ /* Get a pointer of the right type. */
+ ffmpegenc = (GstFFMpegVidEnc *) (object);
+
+ if (ffmpegenc->opened) {
+ GST_WARNING_OBJECT (ffmpegenc,
+ "Can't change properties once decoder is setup !");
+ return;
+ }
+
+ /* Check the argument id to see which argument we're setting. */
+ switch (prop_id) {
+ case ARG_BIT_RATE:
+ ffmpegenc->bitrate = g_value_get_int (value);
+ break;
+ case ARG_GOP_SIZE:
+ ffmpegenc->gop_size = g_value_get_int (value);
+ break;
+ case ARG_ME_METHOD:
+ ffmpegenc->me_method = g_value_get_enum (value);
+ break;
+ case ARG_BUFSIZE:
+ break;
+ case ARG_RTP_PAYLOAD_SIZE:
+ ffmpegenc->rtp_payload_size = g_value_get_int (value);
+ break;
+ default:
+ if (!gst_ffmpeg_cfg_set_property (object, value, pspec))
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+/* The set function is simply the inverse of the get fuction. */
+static void
+gst_ffmpegvidenc_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
+{
+ GstFFMpegVidEnc *ffmpegenc;
+
+ /* It's not null if we got it, but it might not be ours */
+ ffmpegenc = (GstFFMpegVidEnc *) (object);
+
+ switch (prop_id) {
+ case ARG_BIT_RATE:
+ g_value_set_int (value, ffmpegenc->bitrate);
+ break;
+ case ARG_GOP_SIZE:
+ g_value_set_int (value, ffmpegenc->gop_size);
+ break;
+ case ARG_ME_METHOD:
+ g_value_set_enum (value, ffmpegenc->me_method);
+ break;
+ case ARG_BUFSIZE:
+ g_value_set_int (value, ffmpegenc->buffer_size);
+ break;
+ case ARG_RTP_PAYLOAD_SIZE:
+ g_value_set_int (value, ffmpegenc->rtp_payload_size);
+ break;
+ default:
+ if (!gst_ffmpeg_cfg_get_property (object, value, pspec))
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+gst_ffmpegvidenc_stop (GstVideoEncoder * encoder)
+{
+ GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) encoder;
+
+ gst_ffmpegvidenc_flush_buffers (ffmpegenc, FALSE);
+ if (ffmpegenc->opened) {
+ gst_ffmpeg_avcodec_close (ffmpegenc->context);
+ ffmpegenc->opened = FALSE;
+ }
+ if (ffmpegenc->file) {
+ fclose (ffmpegenc->file);
+ ffmpegenc->file = NULL;
+ }
+ if (ffmpegenc->working_buf) {
+ g_free (ffmpegenc->working_buf);
+ ffmpegenc->working_buf = NULL;
+ }
+
+ return TRUE;
+}
+
+static GstFlowReturn
+gst_ffmpegvidenc_finish (GstVideoEncoder * encoder)
+{
+ GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) encoder;
+
+ gst_ffmpegvidenc_flush_buffers (ffmpegenc, TRUE);
+
+ return GST_FLOW_OK;
+}
+
+gboolean
+gst_ffmpegvidenc_register (GstPlugin * plugin)
+{
+ GTypeInfo typeinfo = {
+ sizeof (GstFFMpegVidEncClass),
+ (GBaseInitFunc) gst_ffmpegvidenc_base_init,
+ NULL,
+ (GClassInitFunc) gst_ffmpegvidenc_class_init,
+ NULL,
+ NULL,
+ sizeof (GstFFMpegVidEnc),
+ 0,
+ (GInstanceInitFunc) gst_ffmpegvidenc_init,
+ };
+ GType type;
+ AVCodec *in_plugin;
+
+
+ GST_LOG ("Registering encoders");
+
+ /* build global ffmpeg param/property info */
+ gst_ffmpeg_cfg_init ();
+
+ in_plugin = av_codec_next (NULL);
+ while (in_plugin) {
+ gchar *type_name;
+
+ /* Skip non-AV codecs */
+ if (in_plugin->type != AVMEDIA_TYPE_VIDEO)
+ goto next;
+
+ /* no quasi codecs, please */
+ if (in_plugin->id == CODEC_ID_RAWVIDEO ||
+ in_plugin->id == CODEC_ID_V210 ||
+ in_plugin->id == CODEC_ID_V210X ||
+ in_plugin->id == CODEC_ID_R210 || in_plugin->id == CODEC_ID_ZLIB) {
+ goto next;
+ }
+
+ /* No encoders depending on external libraries (we don't build them, but
+ * people who build against an external ffmpeg might have them.
+ * We have native gstreamer plugins for all of those libraries anyway. */
+ if (!strncmp (in_plugin->name, "lib", 3)) {
+ GST_DEBUG
+ ("Not using external library encoder %s. Use the gstreamer-native ones instead.",
+ in_plugin->name);
+ goto next;
+ }
+
+ /* only encoders */
+ if (!in_plugin->encode) {
+ goto next;
+ }
+
+ /* FIXME : We should have a method to know cheaply whether we have a mapping
+ * for the given plugin or not */
+
+ GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
+
+ /* no codecs for which we're GUARANTEED to have better alternatives */
+ if (!strcmp (in_plugin->name, "gif")) {
+ GST_LOG ("Ignoring encoder %s", in_plugin->name);
+ goto next;
+ }
+
+ /* construct the type */
+ type_name = g_strdup_printf ("avenc_%s", in_plugin->name);
+
+ type = g_type_from_name (type_name);
+
+ if (!type) {
+
+ /* create the glib type now */
+ type =
+ g_type_register_static (GST_TYPE_VIDEO_ENCODER, type_name, &typeinfo,
+ 0);
+ g_type_set_qdata (type, GST_FFENC_PARAMS_QDATA, (gpointer) in_plugin);
+
+ {
+ static const GInterfaceInfo preset_info = {
+ NULL,
+ NULL,
+ NULL
+ };
+ g_type_add_interface_static (type, GST_TYPE_PRESET, &preset_info);
+ }
+ }
+
+ if (!gst_element_register (plugin, type_name, GST_RANK_SECONDARY, type)) {
+ g_free (type_name);
+ return FALSE;
+ }
+
+ g_free (type_name);
+
+ next:
+ in_plugin = av_codec_next (in_plugin);
+ }
+
+ GST_LOG ("Finished registering encoders");
+
+ return TRUE;
+}
diff --git a/ext/ffmpeg/gstffmpegvidenc.h b/ext/ffmpeg/gstffmpegvidenc.h
new file mode 100644
index 0000000..eb201b3
--- /dev/null
+++ b/ext/ffmpeg/gstffmpegvidenc.h
@@ -0,0 +1,95 @@
+/* GStreamer
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* First, include the header file for the plugin, to bring in the
+ * object definition and other useful things.
+ */
+
+#ifndef __GST_FFMPEGVIDENC_H__
+#define __GST_FFMPEGVIDENC_H__
+
+G_BEGIN_DECLS
+
+#include <gst/video/gstvideoencoder.h>
+
+typedef struct _GstFFMpegVidEnc GstFFMpegVidEnc;
+
+struct _GstFFMpegVidEnc
+{
+ GstVideoEncoder parent;
+
+ GstVideoCodecState *input_state;
+
+ AVCodecContext *context;
+ AVFrame *picture;
+ gboolean opened;
+ gboolean discont;
+
+ /* cache */
+ gint bitrate;
+ gint me_method;
+ gint gop_size;
+ gint buffer_size;
+ gint rtp_payload_size;
+
+ guint8 *working_buf;
+ gsize working_buf_size;
+
+ /* settings with some special handling */
+ guint pass;
+ gfloat quantizer;
+ gchar *filename;
+ guint lmin;
+ guint lmax;
+ gint max_key_interval;
+ gboolean interlaced;
+
+ /* statistics file */
+ FILE *file;
+
+ /* other settings are copied over straight,
+ * include a context here, rather than copy-and-past it from avcodec.h */
+ AVCodecContext config;
+};
+
+typedef struct _GstFFMpegVidEncClass GstFFMpegVidEncClass;
+
+struct _GstFFMpegVidEncClass
+{
+ GstVideoEncoderClass parent_class;
+
+ AVCodec *in_plugin;
+ GstPadTemplate *srctempl, *sinktempl;
+ GstCaps *sinkcaps;
+};
+
+#define GST_TYPE_FFMPEGVIDENC \
+ (gst_ffmpegvidenc_get_type())
+#define GST_FFMPEGVIDENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGVIDENC,GstFFMpegVidEnc))
+#define GST_FFMPEGVIDENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGVIDENC,GstFFMpegVidEncClass))
+#define GST_IS_FFMPEGVIDENC(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGVIDENC))
+#define GST_IS_FFMPEGVIDENC_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGVIDENC))
+
+G_END_DECLS
+
+#endif /* __GST_FFMPEGVIDENC_H__ */
diff --git a/ext/libpostproc/Makefile.in b/ext/libpostproc/Makefile.in
index f422f19..3330889 100644
--- a/ext/libpostproc/Makefile.in
+++ b/ext/libpostproc/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/ext/libswscale/Makefile.in b/ext/libswscale/Makefile.in
index fbd76c1..8058e1b 100644
--- a/ext/libswscale/Makefile.in
+++ b/ext/libswscale/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/gst-libav.doap b/gst-libav.doap
index f8b6792..1368086 100644
--- a/gst-libav.doap
+++ b/gst-libav.doap
@@ -34,6 +34,16 @@ colorspace conversion elements.
<release>
<Version>
+ <revision>0.11.93</revision>
+ <branch>0.11</branch>
+ <name>Pink Noise Waltz</name>
+ <created>2012-08-08</created>
+ <file-release rdf:resource="http://gstreamer.freedesktop.org/src/gst-libav/gst-libav-0.11.93.tar.xz" />
+ </Version>
+ </release>
+
+ <release>
+ <Version>
<revision>0.11.92</revision>
<branch>0.11</branch>
<name>Wish You Were Here</name>
diff --git a/gst-libav.spec b/gst-libav.spec
index 0eee5ec..f4cb5d3 100644
--- a/gst-libav.spec
+++ b/gst-libav.spec
@@ -1,25 +1,22 @@
%define majorminor 1.0
-%define gstreamer gstreamer
-%define gst_minver 0.10.0
-%define gst_majorminor 0.10
+%define gstreamer gstreamer011
+%define gst_minver 0.11.0
+%define gst_majorminor 1.0
-
-Name: %{gstreamer}-ffmpeg
-Version: 0.11.92
+Name: %{gstreamer}-libav
+Version: 0.11.93
Release: 1
-Summary: GStreamer Streaming-media framework plug-in using FFmpeg.
-
+Summary: GStreamer Streaming-media framework plug-in using libav (FFmpeg).
Group: Libraries/Multimedia
License: LGPL
URL: http://gstreamer.net/
Vendor: GStreamer Backpackers Team <package@gstreamer.net>
-Source: http://gstreamer.freedesktop.org/src/gst-ffmpeg/gst-ffmpeg/gst-ffmpeg-%{version}.tar.gz
+Source: http://gstreamer.freedesktop.org/src/gst-ffmpeg/gst-ffmpeg/gst-libav-%{version}.tar.xz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: %{gstreamer} >= 0.9.7
BuildRequires: %{gstreamer}-devel >= 0.9.7
BuildRequires: %{gstreamer}-plugins-base-devel >= 0.9.7
-BuildRequires: liboil-devel >= 0.3.6
%description
GStreamer is a streaming-media framework, based on graphs of filters which
@@ -29,11 +26,11 @@ else media-related. Its plugin-based architecture means that new data
types or processing capabilities can be added simply by installing new
plug-ins.
-This plugin contains the FFmpeg codecs, containing codecs for most popular
+This plugin contains the libav (formerly FFmpeg) codecs, containing codecs for most popular
multimedia formats.
%prep
-%setup -q -n gst-ffmpeg-%{version}
+%setup -q -n gst-libav-%{version}
%build
%configure
@@ -52,12 +49,16 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root, -)
-%doc AUTHORS COPYING README gst-ffmpeg.doap
-%{_libdir}/gstreamer-%{gst_majorminor}/libgstffmpeg.so
+%doc AUTHORS COPYING README gst-libav.doap
+%{_libdir}/gstreamer-%{gst_majorminor}/libgstlibav.so
%{_libdir}/gstreamer-%{gst_majorminor}/libgstpostproc.so
-%{_libdir}/gstreamer-%{gst_majorminor}/libgstffmpegscale.so
+%{_libdir}/gstreamer-%{gst_majorminor}/libgstavscale.so
+
%changelog
+* Fri Aug 03 2012 Christian Schaller <uraeus@linuxrising.org>
+- update for 1.0 release and libav rename
+
* Fri Dec 15 2006 Thomas Vander Stichele <thomas at apestaart dot org>
- clean up
- add doap file
diff --git a/gst-libav.spec.in b/gst-libav.spec.in
index 9dca0f7..11437ed 100644
--- a/gst-libav.spec.in
+++ b/gst-libav.spec.in
@@ -1,25 +1,22 @@
%define majorminor @GST_API_VERSION@
-%define gstreamer gstreamer
-%define gst_minver 0.10.0
-%define gst_majorminor 0.10
+%define gstreamer gstreamer011
+%define gst_minver 0.11.0
+%define gst_majorminor 1.0
-
-Name: %{gstreamer}-ffmpeg
+Name: %{gstreamer}-libav
Version: @VERSION@
Release: @PACKAGE_VERSION_RELEASE@
-Summary: GStreamer Streaming-media framework plug-in using FFmpeg.
-
+Summary: GStreamer Streaming-media framework plug-in using libav (FFmpeg).
Group: Libraries/Multimedia
License: LGPL
URL: http://gstreamer.net/
Vendor: GStreamer Backpackers Team <package@gstreamer.net>
-Source: http://gstreamer.freedesktop.org/src/gst-ffmpeg/gst-ffmpeg/gst-ffmpeg-%{version}.tar.gz
+Source: http://gstreamer.freedesktop.org/src/gst-ffmpeg/gst-ffmpeg/gst-libav-%{version}.tar.xz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Requires: %{gstreamer} >= 0.9.7
BuildRequires: %{gstreamer}-devel >= 0.9.7
BuildRequires: %{gstreamer}-plugins-base-devel >= 0.9.7
-BuildRequires: liboil-devel >= 0.3.6
%description
GStreamer is a streaming-media framework, based on graphs of filters which
@@ -29,11 +26,11 @@ else media-related. Its plugin-based architecture means that new data
types or processing capabilities can be added simply by installing new
plug-ins.
-This plugin contains the FFmpeg codecs, containing codecs for most popular
+This plugin contains the libav (formerly FFmpeg) codecs, containing codecs for most popular
multimedia formats.
%prep
-%setup -q -n gst-ffmpeg-%{version}
+%setup -q -n gst-libav-%{version}
%build
%configure
@@ -52,12 +49,16 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root, -)
-%doc AUTHORS COPYING README gst-ffmpeg.doap
-%{_libdir}/gstreamer-%{gst_majorminor}/libgstffmpeg.so
+%doc AUTHORS COPYING README gst-libav.doap
+%{_libdir}/gstreamer-%{gst_majorminor}/libgstlibav.so
%{_libdir}/gstreamer-%{gst_majorminor}/libgstpostproc.so
-%{_libdir}/gstreamer-%{gst_majorminor}/libgstffmpegscale.so
+%{_libdir}/gstreamer-%{gst_majorminor}/libgstavscale.so
+
%changelog
+* Fri Aug 03 2012 Christian Schaller <uraeus@linuxrising.org>
+- update for 1.0 release and libav rename
+
* Fri Dec 15 2006 Thomas Vander Stichele <thomas at apestaart dot org>
- clean up
- add doap file
diff --git a/gst-libs/Makefile.in b/gst-libs/Makefile.in
index d1918d7..1654613 100644
--- a/gst-libs/Makefile.in
+++ b/gst-libs/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/gst-libs/ext/Makefile.am b/gst-libs/ext/Makefile.am
index b1054e1..cbd1274 100644
--- a/gst-libs/ext/Makefile.am
+++ b/gst-libs/ext/Makefile.am
@@ -36,7 +36,7 @@ maintainer-clean: distclean
maintainerclean: maintainer-clean
dist-local:
- GIT_DIR=libav/.git git checkout-index --prefix=../$(TMP_DIST_DIR)/libav/ -a
+ GIT_DIR=libav/.git git checkout-index --prefix=$(TMP_DIST_DIR)/libav/ -a
touch $(TMP_DIST_DIR)/libav/config.mak
echo "Patching libav ./configure"
sed -e '/Unknown option/ {N;N;s/exit 1//; }' $(TMP_DIST_DIR)/libav/configure > $(TMP_DIST_DIR)/libav/configure.tmp
diff --git a/gst-libs/ext/Makefile.in b/gst-libs/ext/Makefile.in
index e03b725..68fe4dc 100644
--- a/gst-libs/ext/Makefile.in
+++ b/gst-libs/ext/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -671,7 +671,7 @@ maintainer-clean: distclean
maintainerclean: maintainer-clean
dist-local:
- GIT_DIR=libav/.git git checkout-index --prefix=../$(TMP_DIST_DIR)/libav/ -a
+ GIT_DIR=libav/.git git checkout-index --prefix=$(TMP_DIST_DIR)/libav/ -a
touch $(TMP_DIST_DIR)/libav/config.mak
echo "Patching libav ./configure"
sed -e '/Unknown option/ {N;N;s/exit 1//; }' $(TMP_DIST_DIR)/libav/configure > $(TMP_DIST_DIR)/libav/configure.tmp
diff --git a/ltmain.sh b/ltmain.sh
index c7d06c3..33f642a 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -70,7 +70,7 @@
# compiler: $LTCC
# compiler flags: $LTCFLAGS
# linker: $LD (gnu? $with_gnu_ld)
-# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1
+# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.1
# automake: $automake_version
# autoconf: $autoconf_version
#
@@ -80,7 +80,7 @@
PROGRAM=libtool
PACKAGE=libtool
-VERSION="2.4.2 Debian-2.4.2-1"
+VERSION="2.4.2 Debian-2.4.2-1.1"
TIMESTAMP=""
package_revision=1.3337
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 828104c..534d1cc 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -2512,17 +2512,6 @@ freebsd* | dragonfly*)
esac
;;
-gnu*)
- version_type=linux # correct to gnu/linux during the next big refactor
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
haiku*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
@@ -2639,7 +2628,7 @@ linux*oldld* | linux*aout* | linux*coff*)
;;
# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
@@ -3255,10 +3244,6 @@ freebsd* | dragonfly*)
fi
;;
-gnu*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
haiku*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -3297,7 +3282,7 @@ irix5* | irix6* | nonstopux*)
;;
# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -4049,7 +4034,7 @@ m4_if([$1], [CXX], [
;;
esac
;;
- linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
KCC*)
# KAI C++ Compiler
@@ -4348,7 +4333,7 @@ m4_if([$1], [CXX], [
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
- linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
# old Intel for x86_64 which still supported -KPIC.
ecc*)
@@ -6241,9 +6226,6 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_TAGVAR(ld_shlibs, $1)=yes
;;
- gnu*)
- ;;
-
haiku*)
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
_LT_TAGVAR(link_all_deplibs, $1)=yes
@@ -6405,7 +6387,7 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_TAGVAR(inherit_rpath, $1)=yes
;;
- linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
KCC*)
# Kuck and Associates, Inc. (KAI) C++ Compiler
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 113a0cd..8977ac4 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/tests/check/Makefile.in b/tests/check/Makefile.in
index 8548c74..95f977c 100644
--- a/tests/check/Makefile.in
+++ b/tests/check/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff --git a/tests/check/elements/avdec_adpcm.c b/tests/check/elements/avdec_adpcm.c
index daad580..295e753 100644
--- a/tests/check/elements/avdec_adpcm.c
+++ b/tests/check/elements/avdec_adpcm.c
@@ -82,7 +82,7 @@ decode_file (const gchar * file, gboolean push_mode)
/* kids, don't use a sync handler for this at home, really; we do because
* we just want to abort and nothing else */
- gst_bus_set_sync_handler (bus, error_cb, (gpointer) file);
+ gst_bus_set_sync_handler (bus, error_cb, (gpointer) file, NULL);
gst_bin_add_many (GST_BIN (pipeline), src, queue, dec, sink, NULL);
gst_element_link_many (src, queue, dec, NULL);
diff --git a/tests/check/elements/avdemux_ape.c b/tests/check/elements/avdemux_ape.c
index 74151b7..3751fc5 100644
--- a/tests/check/elements/avdemux_ape.c
+++ b/tests/check/elements/avdemux_ape.c
@@ -97,7 +97,7 @@ read_tags_from_file (const gchar * file, gboolean push_mode)
/* kids, don't use a sync handler for this at home, really; we do because
* we just want to abort and nothing else */
- gst_bus_set_sync_handler (bus, error_cb, (gpointer) file);
+ gst_bus_set_sync_handler (bus, error_cb, (gpointer) file, NULL);
gst_bin_add_many (GST_BIN (pipeline), src, dec, sink, NULL);
gst_element_link_many (src, dec, NULL);
@@ -150,7 +150,7 @@ run_check_for_file (const gchar * filename, CheckTagsFunc * check_func)
tags = read_tags_from_file (filename, FALSE);
fail_unless (tags != NULL, "Failed to extract tags from '%s'", filename);
check_func (tags, filename);
- gst_tag_list_free (tags);
+ gst_tag_list_unref (tags);
}
#define tag_list_has_tag(taglist,tag) \
diff --git a/tests/files/Makefile.in b/tests/files/Makefile.in
index 33c0044..1cf84c3 100644
--- a/tests/files/Makefile.in
+++ b/tests/files/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.11.5 from Makefile.am.
+# Makefile.in generated by automake 1.11.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,