diff options
Diffstat (limited to 'ext/dv')
-rw-r--r-- | ext/dv/Makefile.am | 20 | ||||
-rw-r--r-- | ext/dv/Makefile.in | 896 | ||||
-rw-r--r-- | ext/dv/NOTES | 13 | ||||
-rw-r--r-- | ext/dv/gstdv.c | 48 | ||||
-rw-r--r-- | ext/dv/gstdvdec.c | 619 | ||||
-rw-r--r-- | ext/dv/gstdvdec.h | 95 | ||||
-rw-r--r-- | ext/dv/gstdvdemux.c | 1909 | ||||
-rw-r--r-- | ext/dv/gstdvdemux.h | 98 | ||||
-rw-r--r-- | ext/dv/gstsmptetimecode.c | 240 | ||||
-rw-r--r-- | ext/dv/gstsmptetimecode.h | 70 | ||||
-rw-r--r-- | ext/dv/smpte_test.c | 81 |
11 files changed, 4089 insertions, 0 deletions
diff --git a/ext/dv/Makefile.am b/ext/dv/Makefile.am new file mode 100644 index 0000000..e63154d --- /dev/null +++ b/ext/dv/Makefile.am @@ -0,0 +1,20 @@ +plugin_LTLIBRARIES = libgstdv.la + +libgstdv_la_SOURCES = gstdv.c gstdvdec.c gstdvdemux.c gstsmptetimecode.c +libgstdv_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LIBDV_CFLAGS) +libgstdv_la_LIBADD = \ + $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) \ + $(GST_BASE_LIBS) $(GST_LIBS) $(LIBDV_LIBS) +libgstdv_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) +libgstdv_la_LIBTOOLFLAGS = --tag=disable-static + +noinst_HEADERS = gstdvdemux.h gstdvdec.h gstsmptetimecode.h + +EXTRA_DIST = NOTES + +noinst_PROGRAMS = smpte_test + +smpte_test_SOURCES = smpte_test.c gstsmptetimecode.c +smpte_test_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(LIBDV_CFLAGS) +smpte_test_LDADD = $(GST_BASE_LIBS) $(GST_LIBS) + diff --git a/ext/dv/Makefile.in b/ext/dv/Makefile.in new file mode 100644 index 0000000..279182d --- /dev/null +++ b/ext/dv/Makefile.in @@ -0,0 +1,896 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = smpte_test$(EXEEXT) +subdir = ext/dv +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/common/m4/as-ac-expand.m4 \ + $(top_srcdir)/common/m4/as-auto-alt.m4 \ + $(top_srcdir)/common/m4/as-compiler-flag.m4 \ + $(top_srcdir)/common/m4/as-gcc-inline-assembly.m4 \ + $(top_srcdir)/common/m4/as-objc.m4 \ + $(top_srcdir)/common/m4/as-python.m4 \ + $(top_srcdir)/common/m4/as-scrub-include.m4 \ + $(top_srcdir)/common/m4/as-version.m4 \ + $(top_srcdir)/common/m4/ax_create_stdint_h.m4 \ + $(top_srcdir)/common/m4/gst-arch.m4 \ + $(top_srcdir)/common/m4/gst-args.m4 \ + $(top_srcdir)/common/m4/gst-check.m4 \ + $(top_srcdir)/common/m4/gst-default.m4 \ + $(top_srcdir)/common/m4/gst-dowhile.m4 \ + $(top_srcdir)/common/m4/gst-error.m4 \ + $(top_srcdir)/common/m4/gst-feature.m4 \ + $(top_srcdir)/common/m4/gst-gettext.m4 \ + $(top_srcdir)/common/m4/gst-glib2.m4 \ + $(top_srcdir)/common/m4/gst-package-release-datetime.m4 \ + $(top_srcdir)/common/m4/gst-platform.m4 \ + $(top_srcdir)/common/m4/gst-plugin-docs.m4 \ + $(top_srcdir)/common/m4/gst-plugindir.m4 \ + $(top_srcdir)/common/m4/gst-x11.m4 \ + $(top_srcdir)/common/m4/gst.m4 \ + $(top_srcdir)/common/m4/gtk-doc.m4 \ + $(top_srcdir)/common/m4/orc.m4 $(top_srcdir)/common/m4/pkg.m4 \ + $(top_srcdir)/m4/aalib.m4 $(top_srcdir)/m4/esd.m4 \ + $(top_srcdir)/m4/gconf-2.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/gst-fionread.m4 \ + $(top_srcdir)/m4/gst-shout2.m4 $(top_srcdir)/m4/iconv.m4 \ + $(top_srcdir)/m4/intlmacosx.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(plugindir)" +LTLIBRARIES = $(plugin_LTLIBRARIES) +am__DEPENDENCIES_1 = +libgstdv_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am_libgstdv_la_OBJECTS = libgstdv_la-gstdv.lo libgstdv_la-gstdvdec.lo \ + libgstdv_la-gstdvdemux.lo libgstdv_la-gstsmptetimecode.lo +libgstdv_la_OBJECTS = $(am_libgstdv_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +libgstdv_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(libgstdv_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ + $(CCLD) $(libgstdv_la_CFLAGS) $(CFLAGS) $(libgstdv_la_LDFLAGS) \ + $(LDFLAGS) -o $@ +PROGRAMS = $(noinst_PROGRAMS) +am_smpte_test_OBJECTS = smpte_test-smpte_test.$(OBJEXT) \ + smpte_test-gstsmptetimecode.$(OBJEXT) +smpte_test_OBJECTS = $(am_smpte_test_OBJECTS) +smpte_test_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +smpte_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(smpte_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(libgstdv_la_SOURCES) $(smpte_test_SOURCES) +DIST_SOURCES = $(libgstdv_la_SOURCES) $(smpte_test_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +AALIB_CFLAGS = @AALIB_CFLAGS@ +AALIB_CONFIG = @AALIB_CONFIG@ +AALIB_LIBS = @AALIB_LIBS@ +ACLOCAL = @ACLOCAL@ +ACLOCAL_AMFLAGS = @ACLOCAL_AMFLAGS@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +ANNODEX_CFLAGS = @ANNODEX_CFLAGS@ +ANNODEX_LIBS = @ANNODEX_LIBS@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BZ2_LIBS = @BZ2_LIBS@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_GOBJECT_CFLAGS = @CAIRO_GOBJECT_CFLAGS@ +CAIRO_GOBJECT_LIBS = @CAIRO_GOBJECT_LIBS@ +CAIRO_LIBS = @CAIRO_LIBS@ +CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFAULT_AUDIOSINK = @DEFAULT_AUDIOSINK@ +DEFAULT_AUDIOSRC = @DEFAULT_AUDIOSRC@ +DEFAULT_VIDEOSINK = @DEFAULT_VIDEOSINK@ +DEFAULT_VIDEOSRC = @DEFAULT_VIDEOSRC@ +DEFAULT_VISUALIZER = @DEFAULT_VISUALIZER@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DEPRECATED_CFLAGS = @DEPRECATED_CFLAGS@ +DIRECTSOUND_CFLAGS = @DIRECTSOUND_CFLAGS@ +DIRECTSOUND_LDFLAGS = @DIRECTSOUND_LDFLAGS@ +DIRECTSOUND_LIBS = @DIRECTSOUND_LIBS@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DV1394_CFLAGS = @DV1394_CFLAGS@ +DV1394_LIBS = @DV1394_LIBS@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ERROR_CFLAGS = @ERROR_CFLAGS@ +ERROR_CXXFLAGS = @ERROR_CXXFLAGS@ +ESD_CFLAGS = @ESD_CFLAGS@ +ESD_CONFIG = @ESD_CONFIG@ +ESD_LIBS = @ESD_LIBS@ +EXEEXT = @EXEEXT@ +FFLAGS = @FFLAGS@ +FGREP = @FGREP@ +FLAC_CFLAGS = @FLAC_CFLAGS@ +FLAC_LIBS = @FLAC_LIBS@ +GCONFTOOL = @GCONFTOOL@ +GCONF_CFLAGS = @GCONF_CFLAGS@ +GCONF_LIBS = @GCONF_LIBS@ +GCONF_SCHEMA_CONFIG_SOURCE = @GCONF_SCHEMA_CONFIG_SOURCE@ +GCONF_SCHEMA_FILE_DIR = @GCONF_SCHEMA_FILE_DIR@ +GCOV = @GCOV@ +GCOV_CFLAGS = @GCOV_CFLAGS@ +GCOV_LIBS = @GCOV_LIBS@ +GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@ +GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GLIB_CFLAGS = @GLIB_CFLAGS@ +GLIB_LIBS = @GLIB_LIBS@ +GLIB_PREFIX = @GLIB_PREFIX@ +GLIB_REQ = @GLIB_REQ@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +GSTPB_PLUGINS_DIR = @GSTPB_PLUGINS_DIR@ +GSTPB_PREFIX = @GSTPB_PREFIX@ +GST_ALL_LDFLAGS = @GST_ALL_LDFLAGS@ +GST_BASE_CFLAGS = @GST_BASE_CFLAGS@ +GST_BASE_LIBS = @GST_BASE_LIBS@ +GST_CFLAGS = @GST_CFLAGS@ +GST_CHECK_CFLAGS = @GST_CHECK_CFLAGS@ +GST_CHECK_LIBS = @GST_CHECK_LIBS@ +GST_CONTROLLER_CFLAGS = @GST_CONTROLLER_CFLAGS@ +GST_CONTROLLER_LIBS = @GST_CONTROLLER_LIBS@ +GST_CXXFLAGS = @GST_CXXFLAGS@ +GST_GDP_CFLAGS = @GST_GDP_CFLAGS@ +GST_GDP_LIBS = @GST_GDP_LIBS@ +GST_LEVEL_DEFAULT = @GST_LEVEL_DEFAULT@ +GST_LIBS = @GST_LIBS@ +GST_LICENSE = @GST_LICENSE@ +GST_LT_LDFLAGS = @GST_LT_LDFLAGS@ +GST_MAJORMINOR = @GST_MAJORMINOR@ +GST_OPTION_CFLAGS = @GST_OPTION_CFLAGS@ +GST_OPTION_CXXFLAGS = @GST_OPTION_CXXFLAGS@ +GST_PACKAGE_NAME = @GST_PACKAGE_NAME@ +GST_PACKAGE_ORIGIN = @GST_PACKAGE_ORIGIN@ +GST_PLUGINS_ALL = @GST_PLUGINS_ALL@ +GST_PLUGINS_BASE_CFLAGS = @GST_PLUGINS_BASE_CFLAGS@ +GST_PLUGINS_BASE_DIR = @GST_PLUGINS_BASE_DIR@ +GST_PLUGINS_BASE_LIBS = @GST_PLUGINS_BASE_LIBS@ +GST_PLUGINS_DIR = @GST_PLUGINS_DIR@ +GST_PLUGINS_SELECTED = @GST_PLUGINS_SELECTED@ +GST_PLUGIN_LDFLAGS = @GST_PLUGIN_LDFLAGS@ +GST_PREFIX = @GST_PREFIX@ +GST_TOOLS_DIR = @GST_TOOLS_DIR@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTK_CFLAGS = @GTK_CFLAGS@ +GTK_LIBS = @GTK_LIBS@ +GTK_X11_CFLAGS = @GTK_X11_CFLAGS@ +GTK_X11_LIBS = @GTK_X11_LIBS@ +GUDEV_CFLAGS = @GUDEV_CFLAGS@ +GUDEV_LIBS = @GUDEV_LIBS@ +HAL_CFLAGS = @HAL_CFLAGS@ +HAL_LIBS = @HAL_LIBS@ +HAVE_AVC1394 = @HAVE_AVC1394@ +HAVE_BZ2 = @HAVE_BZ2@ +HAVE_CXX = @HAVE_CXX@ +HAVE_DIRECTSOUND = @HAVE_DIRECTSOUND@ +HAVE_GCONFTOOL = @HAVE_GCONFTOOL@ +HAVE_ROM1394 = @HAVE_ROM1394@ +HAVE_SPEEX = @HAVE_SPEEX@ +HAVE_X = @HAVE_X@ +HAVE_XSHM = @HAVE_XSHM@ +HAVE_ZLIB = @HAVE_ZLIB@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +JACK_0_120_1_CFLAGS = @JACK_0_120_1_CFLAGS@ +JACK_0_120_1_LIBS = @JACK_0_120_1_LIBS@ +JACK_1_9_7_CFLAGS = @JACK_1_9_7_CFLAGS@ +JACK_1_9_7_LIBS = @JACK_1_9_7_LIBS@ +JACK_CFLAGS = @JACK_CFLAGS@ +JACK_LIBS = @JACK_LIBS@ +JPEG_LIBS = @JPEG_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBCACA_CFLAGS = @LIBCACA_CFLAGS@ +LIBCACA_CONFIG = @LIBCACA_CONFIG@ +LIBCACA_LIBS = @LIBCACA_LIBS@ +LIBDV_CFLAGS = @LIBDV_CFLAGS@ +LIBDV_LIBS = @LIBDV_LIBS@ +LIBICONV = @LIBICONV@ +LIBIEC61883_CFLAGS = @LIBIEC61883_CFLAGS@ +LIBIEC61883_LIBS = @LIBIEC61883_LIBS@ +LIBINTL = @LIBINTL@ +LIBM = @LIBM@ +LIBOBJS = @LIBOBJS@ +LIBPNG_CFLAGS = @LIBPNG_CFLAGS@ +LIBPNG_LIBS = @LIBPNG_LIBS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBV4L2_CFLAGS = @LIBV4L2_CFLAGS@ +LIBV4L2_LIBS = @LIBV4L2_LIBS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOCALEDIR = @LOCALEDIR@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJC = @OBJC@ +OBJCDEPMODE = @OBJCDEPMODE@ +OBJC_LDFLAGS = @OBJC_LDFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORCC = @ORCC@ +ORCC_FLAGS = @ORCC_FLAGS@ +ORC_CFLAGS = @ORC_CFLAGS@ +ORC_LIBS = @ORC_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@ +PACKAGE_VERSION_MICRO = @PACKAGE_VERSION_MICRO@ +PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@ +PACKAGE_VERSION_NANO = @PACKAGE_VERSION_NANO@ +PACKAGE_VERSION_RELEASE = @PACKAGE_VERSION_RELEASE@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PLUGINDIR = @PLUGINDIR@ +POSUB = @POSUB@ +PROFILE_CFLAGS = @PROFILE_CFLAGS@ +PULSE_0_9_11_CFLAGS = @PULSE_0_9_11_CFLAGS@ +PULSE_0_9_11_LIBS = @PULSE_0_9_11_LIBS@ +PULSE_0_9_12_CFLAGS = @PULSE_0_9_12_CFLAGS@ +PULSE_0_9_12_LIBS = @PULSE_0_9_12_LIBS@ +PULSE_0_9_13_CFLAGS = @PULSE_0_9_13_CFLAGS@ +PULSE_0_9_13_LIBS = @PULSE_0_9_13_LIBS@ +PULSE_0_9_15_CFLAGS = @PULSE_0_9_15_CFLAGS@ +PULSE_0_9_15_LIBS = @PULSE_0_9_15_LIBS@ +PULSE_0_9_16_CFLAGS = @PULSE_0_9_16_CFLAGS@ +PULSE_0_9_16_LIBS = @PULSE_0_9_16_LIBS@ +PULSE_0_9_20_CFLAGS = @PULSE_0_9_20_CFLAGS@ +PULSE_0_9_20_LIBS = @PULSE_0_9_20_LIBS@ +PULSE_CFLAGS = @PULSE_CFLAGS@ +PULSE_LIBS = @PULSE_LIBS@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +RAW1394_CFLAGS = @RAW1394_CFLAGS@ +RAW1394_LIBS = @RAW1394_LIBS@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SHOUT2_CFLAGS = @SHOUT2_CFLAGS@ +SHOUT2_LIBS = @SHOUT2_LIBS@ +SOUP_CFLAGS = @SOUP_CFLAGS@ +SOUP_LIBS = @SOUP_LIBS@ +SPEEX_CFLAGS = @SPEEX_CFLAGS@ +SPEEX_LIBS = @SPEEX_LIBS@ +STRIP = @STRIP@ +TAGLIB_CFLAGS = @TAGLIB_CFLAGS@ +TAGLIB_CXXFLAGS = @TAGLIB_CXXFLAGS@ +TAGLIB_LIBS = @TAGLIB_LIBS@ +USE_NLS = @USE_NLS@ +VALGRIND_CFLAGS = @VALGRIND_CFLAGS@ +VALGRIND_LIBS = @VALGRIND_LIBS@ +VALGRIND_PATH = @VALGRIND_PATH@ +VERSION = @VERSION@ +WARNING_CFLAGS = @WARNING_CFLAGS@ +WARNING_CXXFLAGS = @WARNING_CXXFLAGS@ +WAVPACK_CFLAGS = @WAVPACK_CFLAGS@ +WAVPACK_LIBS = @WAVPACK_LIBS@ +WIN32_LIBS = @WIN32_LIBS@ +XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@ +XDAMAGE_LIBS = @XDAMAGE_LIBS@ +XFIXES_CFLAGS = @XFIXES_CFLAGS@ +XFIXES_LIBS = @XFIXES_LIBS@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +XMKMF = @XMKMF@ +XSHM_LIBS = @XSHM_LIBS@ +XVIDEO_LIBS = @XVIDEO_LIBS@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ZLIB_LIBS = @ZLIB_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +ac_ct_OBJC = @ac_ct_OBJC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +plugindir = @plugindir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +plugin_LTLIBRARIES = libgstdv.la +libgstdv_la_SOURCES = gstdv.c gstdvdec.c gstdvdemux.c gstsmptetimecode.c +libgstdv_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(LIBDV_CFLAGS) +libgstdv_la_LIBADD = \ + $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) \ + $(GST_BASE_LIBS) $(GST_LIBS) $(LIBDV_LIBS) + +libgstdv_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) +libgstdv_la_LIBTOOLFLAGS = --tag=disable-static +noinst_HEADERS = gstdvdemux.h gstdvdec.h gstsmptetimecode.h +EXTRA_DIST = NOTES +smpte_test_SOURCES = smpte_test.c gstsmptetimecode.c +smpte_test_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(LIBDV_CFLAGS) +smpte_test_LDADD = $(GST_BASE_LIBS) $(GST_LIBS) +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu ext/dv/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu ext/dv/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)" + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \ + } + +uninstall-pluginLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \ + done + +clean-pluginLTLIBRARIES: + -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES) + @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libgstdv.la: $(libgstdv_la_OBJECTS) $(libgstdv_la_DEPENDENCIES) + $(AM_V_CCLD)$(libgstdv_la_LINK) -rpath $(plugindir) $(libgstdv_la_OBJECTS) $(libgstdv_la_LIBADD) $(LIBS) + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +smpte_test$(EXEEXT): $(smpte_test_OBJECTS) $(smpte_test_DEPENDENCIES) + @rm -f smpte_test$(EXEEXT) + $(AM_V_CCLD)$(smpte_test_LINK) $(smpte_test_OBJECTS) $(smpte_test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstdv_la-gstdv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstdv_la-gstdvdec.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstdv_la-gstdvdemux.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgstdv_la-gstsmptetimecode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smpte_test-gstsmptetimecode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smpte_test-smpte_test.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libgstdv_la-gstdv.lo: gstdv.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdv_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdv_la_CFLAGS) $(CFLAGS) -MT libgstdv_la-gstdv.lo -MD -MP -MF $(DEPDIR)/libgstdv_la-gstdv.Tpo -c -o libgstdv_la-gstdv.lo `test -f 'gstdv.c' || echo '$(srcdir)/'`gstdv.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstdv_la-gstdv.Tpo $(DEPDIR)/libgstdv_la-gstdv.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstdv.c' object='libgstdv_la-gstdv.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdv_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdv_la_CFLAGS) $(CFLAGS) -c -o libgstdv_la-gstdv.lo `test -f 'gstdv.c' || echo '$(srcdir)/'`gstdv.c + +libgstdv_la-gstdvdec.lo: gstdvdec.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdv_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdv_la_CFLAGS) $(CFLAGS) -MT libgstdv_la-gstdvdec.lo -MD -MP -MF $(DEPDIR)/libgstdv_la-gstdvdec.Tpo -c -o libgstdv_la-gstdvdec.lo `test -f 'gstdvdec.c' || echo '$(srcdir)/'`gstdvdec.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstdv_la-gstdvdec.Tpo $(DEPDIR)/libgstdv_la-gstdvdec.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstdvdec.c' object='libgstdv_la-gstdvdec.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdv_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdv_la_CFLAGS) $(CFLAGS) -c -o libgstdv_la-gstdvdec.lo `test -f 'gstdvdec.c' || echo '$(srcdir)/'`gstdvdec.c + +libgstdv_la-gstdvdemux.lo: gstdvdemux.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdv_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdv_la_CFLAGS) $(CFLAGS) -MT libgstdv_la-gstdvdemux.lo -MD -MP -MF $(DEPDIR)/libgstdv_la-gstdvdemux.Tpo -c -o libgstdv_la-gstdvdemux.lo `test -f 'gstdvdemux.c' || echo '$(srcdir)/'`gstdvdemux.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstdv_la-gstdvdemux.Tpo $(DEPDIR)/libgstdv_la-gstdvdemux.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstdvdemux.c' object='libgstdv_la-gstdvdemux.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdv_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdv_la_CFLAGS) $(CFLAGS) -c -o libgstdv_la-gstdvdemux.lo `test -f 'gstdvdemux.c' || echo '$(srcdir)/'`gstdvdemux.c + +libgstdv_la-gstsmptetimecode.lo: gstsmptetimecode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdv_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdv_la_CFLAGS) $(CFLAGS) -MT libgstdv_la-gstsmptetimecode.lo -MD -MP -MF $(DEPDIR)/libgstdv_la-gstsmptetimecode.Tpo -c -o libgstdv_la-gstsmptetimecode.lo `test -f 'gstsmptetimecode.c' || echo '$(srcdir)/'`gstsmptetimecode.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libgstdv_la-gstsmptetimecode.Tpo $(DEPDIR)/libgstdv_la-gstsmptetimecode.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstsmptetimecode.c' object='libgstdv_la-gstsmptetimecode.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(libgstdv_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgstdv_la_CFLAGS) $(CFLAGS) -c -o libgstdv_la-gstsmptetimecode.lo `test -f 'gstsmptetimecode.c' || echo '$(srcdir)/'`gstsmptetimecode.c + +smpte_test-smpte_test.o: smpte_test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(smpte_test_CFLAGS) $(CFLAGS) -MT smpte_test-smpte_test.o -MD -MP -MF $(DEPDIR)/smpte_test-smpte_test.Tpo -c -o smpte_test-smpte_test.o `test -f 'smpte_test.c' || echo '$(srcdir)/'`smpte_test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/smpte_test-smpte_test.Tpo $(DEPDIR)/smpte_test-smpte_test.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='smpte_test.c' object='smpte_test-smpte_test.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(smpte_test_CFLAGS) $(CFLAGS) -c -o smpte_test-smpte_test.o `test -f 'smpte_test.c' || echo '$(srcdir)/'`smpte_test.c + +smpte_test-smpte_test.obj: smpte_test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(smpte_test_CFLAGS) $(CFLAGS) -MT smpte_test-smpte_test.obj -MD -MP -MF $(DEPDIR)/smpte_test-smpte_test.Tpo -c -o smpte_test-smpte_test.obj `if test -f 'smpte_test.c'; then $(CYGPATH_W) 'smpte_test.c'; else $(CYGPATH_W) '$(srcdir)/smpte_test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/smpte_test-smpte_test.Tpo $(DEPDIR)/smpte_test-smpte_test.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='smpte_test.c' object='smpte_test-smpte_test.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(smpte_test_CFLAGS) $(CFLAGS) -c -o smpte_test-smpte_test.obj `if test -f 'smpte_test.c'; then $(CYGPATH_W) 'smpte_test.c'; else $(CYGPATH_W) '$(srcdir)/smpte_test.c'; fi` + +smpte_test-gstsmptetimecode.o: gstsmptetimecode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(smpte_test_CFLAGS) $(CFLAGS) -MT smpte_test-gstsmptetimecode.o -MD -MP -MF $(DEPDIR)/smpte_test-gstsmptetimecode.Tpo -c -o smpte_test-gstsmptetimecode.o `test -f 'gstsmptetimecode.c' || echo '$(srcdir)/'`gstsmptetimecode.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/smpte_test-gstsmptetimecode.Tpo $(DEPDIR)/smpte_test-gstsmptetimecode.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstsmptetimecode.c' object='smpte_test-gstsmptetimecode.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(smpte_test_CFLAGS) $(CFLAGS) -c -o smpte_test-gstsmptetimecode.o `test -f 'gstsmptetimecode.c' || echo '$(srcdir)/'`gstsmptetimecode.c + +smpte_test-gstsmptetimecode.obj: gstsmptetimecode.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(smpte_test_CFLAGS) $(CFLAGS) -MT smpte_test-gstsmptetimecode.obj -MD -MP -MF $(DEPDIR)/smpte_test-gstsmptetimecode.Tpo -c -o smpte_test-gstsmptetimecode.obj `if test -f 'gstsmptetimecode.c'; then $(CYGPATH_W) 'gstsmptetimecode.c'; else $(CYGPATH_W) '$(srcdir)/gstsmptetimecode.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/smpte_test-gstsmptetimecode.Tpo $(DEPDIR)/smpte_test-gstsmptetimecode.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gstsmptetimecode.c' object='smpte_test-gstsmptetimecode.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(smpte_test_CFLAGS) $(CFLAGS) -c -o smpte_test-gstsmptetimecode.obj `if test -f 'gstsmptetimecode.c'; then $(CYGPATH_W) 'gstsmptetimecode.c'; else $(CYGPATH_W) '$(srcdir)/gstsmptetimecode.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(plugindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + clean-pluginLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-pluginLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pluginLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS clean-pluginLTLIBRARIES \ + ctags distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-pluginLTLIBRARIES install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-pluginLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/ext/dv/NOTES b/ext/dv/NOTES new file mode 100644 index 0000000..8421159 --- /dev/null +++ b/ext/dv/NOTES @@ -0,0 +1,13 @@ +Packets come from 1394 480 bytes at a time. This is not a video segment +length. This causes problems, since a packet boundary crossing a video +segment can split a video segment if we lose an iso packet. We can +recover from this, sorta, with significant changes to the parser. We have +to deal with the idea that a) some macroblocks just don't exist (we have +zero's for them) and b) when any of the 5 macroblocks doesn't exist, we +can't do pass 3. + +Since things are bitstream-based, we can deal with this, but we have to +add a layer of code that tries to save time (maybe) by not decoding things +that don't exist. Not sure how this is gonna work with the parse code +being based on video segments, and not easily splittable into +macroblock-level parsing (or is it?). diff --git a/ext/dv/gstdv.c b/ext/dv/gstdv.c new file mode 100644 index 0000000..970c5d1 --- /dev/null +++ b/ext/dv/gstdv.c @@ -0,0 +1,48 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> + * <2005> Wim Taymans <wim@fluendo.com> + * + * 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 "gstdvdec.h" +#include "gstdvdemux.h" + +static gboolean +plugin_init (GstPlugin * plugin) +{ + dv_init (0, 0); + + if (!gst_element_register (plugin, "dvdemux", GST_RANK_PRIMARY, + gst_dvdemux_get_type ())) + return FALSE; + + if (!gst_element_register (plugin, "dvdec", GST_RANK_MARGINAL, + gst_dvdec_get_type ())) + return FALSE; + + return TRUE; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "dv", + "DV demuxer and decoder based on libdv (libdv.sf.net)", + plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c new file mode 100644 index 0000000..e7fd946 --- /dev/null +++ b/ext/dv/gstdvdec.c @@ -0,0 +1,619 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> + * <2005> Wim Taymans <wim@fluendo.com> + * + * 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. + */ + +/** + * SECTION:element-dvdec + * + * dvdec decodes DV video into raw video. The element expects a full DV frame + * as input, which is 120000 bytes for NTSC and 144000 for PAL video. + * + * This element can perform simple frame dropping with the #GstDVDec:drop-factor + * property. Setting this property to a value N > 1 will only decode every + * Nth frame. + * + * <refsect2> + * <title>Example launch line</title> + * |[ + * gst-launch filesrc location=test.dv ! dvdemux name=demux ! dvdec ! xvimagesink + * ]| This pipeline decodes and renders the raw DV stream to a videosink. + * </refsect2> + * + * Last reviewed on 2006-02-28 (0.10.3) + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include <string.h> +#include <math.h> +#include <gst/video/video.h> + +#include "gstdvdec.h" + +/* sizes of one input buffer */ +#define NTSC_HEIGHT 480 +#define NTSC_BUFFER 120000 +#define NTSC_FRAMERATE_NUMERATOR 30000 +#define NTSC_FRAMERATE_DENOMINATOR 1001 + +#define PAL_HEIGHT 576 +#define PAL_BUFFER 144000 +#define PAL_FRAMERATE_NUMERATOR 25 +#define PAL_FRAMERATE_DENOMINATOR 1 + +#define PAL_NORMAL_PAR_X 59 +#define PAL_NORMAL_PAR_Y 54 +#define PAL_WIDE_PAR_X 118 +#define PAL_WIDE_PAR_Y 81 + +#define NTSC_NORMAL_PAR_X 10 +#define NTSC_NORMAL_PAR_Y 11 +#define NTSC_WIDE_PAR_X 40 +#define NTSC_WIDE_PAR_Y 33 + +#define DV_DEFAULT_QUALITY DV_QUALITY_BEST +#define DV_DEFAULT_DECODE_NTH 1 + +GST_DEBUG_CATEGORY_STATIC (dvdec_debug); +#define GST_CAT_DEFAULT dvdec_debug + +enum +{ + PROP_0, + PROP_CLAMP_LUMA, + PROP_CLAMP_CHROMA, + PROP_QUALITY, + PROP_DECODE_NTH +}; + +const gint qualities[] = { + DV_QUALITY_DC, + DV_QUALITY_AC_1, + DV_QUALITY_AC_2, + DV_QUALITY_DC | DV_QUALITY_COLOR, + DV_QUALITY_AC_1 | DV_QUALITY_COLOR, + DV_QUALITY_AC_2 | DV_QUALITY_COLOR +}; + +static GstStaticPadTemplate sink_temp = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/x-dv, systemstream = (boolean) false") + ); + +static GstStaticPadTemplate src_temp = GST_STATIC_PAD_TEMPLATE ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/x-raw-yuv, " + "format = (fourcc) YUY2, " + "width = (int) 720, " + "framerate = (fraction) [ 1/1, 60/1 ];" + "video/x-raw-rgb, " + "bpp = (int) 32, " + "depth = (int) 24, " + "endianness = (int) " G_STRINGIFY (G_BIG_ENDIAN) ", " + "red_mask = (int) 0x0000ff00, " + "green_mask = (int) 0x00ff0000, " + "blue_mask = (int) 0xff000000, " + "width = (int) 720, " + "framerate = (fraction) [ 1/1, 60/1 ];" + "video/x-raw-rgb, " + "bpp = (int) 24, " + "depth = (int) 24, " + "endianness = (int) " G_STRINGIFY (G_BIG_ENDIAN) ", " + "red_mask = (int) 0x00ff0000, " + "green_mask = (int) 0x0000ff00, " + "blue_mask = (int) 0x000000ff, " + "width = (int) 720, " "framerate = (fraction) [ 1/1, 60/1 ]") + ); + +#define GST_TYPE_DVDEC_QUALITY (gst_dvdec_quality_get_type()) +static GType +gst_dvdec_quality_get_type (void) +{ + static GType qtype = 0; + + if (qtype == 0) { + static const GEnumValue values[] = { + {0, "Monochrome, DC (Fastest)", "fastest"}, + {1, "Monochrome, first AC coefficient", "monochrome-ac"}, + {2, "Monochrome, highest quality", "monochrome-best"}, + {3, "Colour, DC, fastest", "colour-fastest"}, + {4, "Colour, using only the first AC coefficient", "colour-ac"}, + {5, "Highest quality colour decoding", "best"}, + {0, NULL, NULL}, + }; + + qtype = g_enum_register_static ("GstDVDecQualityEnum", values); + } + return qtype; +} + +GST_BOILERPLATE (GstDVDec, gst_dvdec, GstElement, GST_TYPE_ELEMENT); + +static void gst_dvdec_finalize (GObject * object); +static gboolean gst_dvdec_sink_setcaps (GstPad * pad, GstCaps * caps); +static GstFlowReturn gst_dvdec_chain (GstPad * pad, GstBuffer * buffer); +static gboolean gst_dvdec_sink_event (GstPad * pad, GstEvent * event); + +static GstStateChangeReturn gst_dvdec_change_state (GstElement * element, + GstStateChange transition); + +static void gst_dvdec_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_dvdec_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + +static void +gst_dvdec_base_init (gpointer g_class) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_temp)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&src_temp)); + + gst_element_class_set_details_simple (element_class, "DV video decoder", + "Codec/Decoder/Video", + "Uses libdv to decode DV video (smpte314) (libdv.sourceforge.net)", + "Erik Walthinsen <omega@cse.ogi.edu>," "Wim Taymans <wim@fluendo.com>"); + + GST_DEBUG_CATEGORY_INIT (dvdec_debug, "dvdec", 0, "DV decoding element"); +} + +static void +gst_dvdec_class_init (GstDVDecClass * klass) +{ + GObjectClass *gobject_class; + GstElementClass *gstelement_class; + + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; + + gobject_class->finalize = gst_dvdec_finalize; + gobject_class->set_property = gst_dvdec_set_property; + gobject_class->get_property = gst_dvdec_get_property; + + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CLAMP_LUMA, + g_param_spec_boolean ("clamp-luma", "Clamp luma", "Clamp luma", + FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CLAMP_CHROMA, + g_param_spec_boolean ("clamp-chroma", "Clamp chroma", "Clamp chroma", + FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_QUALITY, + g_param_spec_enum ("quality", "Quality", "Decoding quality", + GST_TYPE_DVDEC_QUALITY, DV_DEFAULT_QUALITY, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DECODE_NTH, + g_param_spec_int ("drop-factor", "Drop Factor", "Only decode Nth frame", + 1, G_MAXINT, DV_DEFAULT_DECODE_NTH, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + + gstelement_class->change_state = gst_dvdec_change_state; +} + +static void +gst_dvdec_init (GstDVDec * dvdec, GstDVDecClass * g_class) +{ + dvdec->sinkpad = gst_pad_new_from_static_template (&sink_temp, "sink"); + gst_pad_set_setcaps_function (dvdec->sinkpad, + GST_DEBUG_FUNCPTR (gst_dvdec_sink_setcaps)); + gst_pad_set_chain_function (dvdec->sinkpad, gst_dvdec_chain); + gst_pad_set_event_function (dvdec->sinkpad, gst_dvdec_sink_event); + gst_element_add_pad (GST_ELEMENT (dvdec), dvdec->sinkpad); + + dvdec->srcpad = gst_pad_new_from_static_template (&src_temp, "src"); + gst_pad_use_fixed_caps (dvdec->srcpad); + gst_element_add_pad (GST_ELEMENT (dvdec), dvdec->srcpad); + + dvdec->framerate_numerator = 0; + dvdec->framerate_denominator = 0; + dvdec->wide = FALSE; + dvdec->drop_factor = 1; + + dvdec->clamp_luma = FALSE; + dvdec->clamp_chroma = FALSE; + dvdec->quality = DV_DEFAULT_QUALITY; + dvdec->segment = gst_segment_new (); +} + +static void +gst_dvdec_finalize (GObject * object) +{ + GstDVDec *dvdec = GST_DVDEC (object); + + gst_segment_free (dvdec->segment); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static gboolean +gst_dvdec_sink_setcaps (GstPad * pad, GstCaps * caps) +{ + GstDVDec *dvdec; + GstStructure *s; + const GValue *par = NULL, *rate = NULL; + + dvdec = GST_DVDEC (gst_pad_get_parent (pad)); + + /* first parse the caps */ + s = gst_caps_get_structure (caps, 0); + + /* we allow framerate and PAR to be overwritten. framerate is mandatory. */ + if (!(rate = gst_structure_get_value (s, "framerate"))) + goto no_framerate; + par = gst_structure_get_value (s, "pixel-aspect-ratio"); + + if (par) { + dvdec->par_x = gst_value_get_fraction_numerator (par); + dvdec->par_y = gst_value_get_fraction_denominator (par); + dvdec->need_par = FALSE; + } else { + dvdec->par_x = 0; + dvdec->par_y = 0; + dvdec->need_par = TRUE; + } + dvdec->framerate_numerator = gst_value_get_fraction_numerator (rate); + dvdec->framerate_denominator = gst_value_get_fraction_denominator (rate); + dvdec->sink_negotiated = TRUE; + dvdec->src_negotiated = FALSE; + + gst_object_unref (dvdec); + + return TRUE; + + /* ERRORS */ +no_framerate: + { + GST_DEBUG_OBJECT (dvdec, "no framerate specified in caps"); + gst_object_unref (dvdec); + return FALSE; + } +} + +static gboolean +gst_dvdec_src_negotiate (GstDVDec * dvdec) +{ + GstCaps *othercaps; + + /* no PAR was specified in input, derive from encoded data */ + if (dvdec->need_par) { + if (dvdec->PAL) { + if (dvdec->wide) { + dvdec->par_x = PAL_WIDE_PAR_X; + dvdec->par_y = PAL_WIDE_PAR_Y; + } else { + dvdec->par_x = PAL_NORMAL_PAR_X; + dvdec->par_y = PAL_NORMAL_PAR_Y; + } + } else { + if (dvdec->wide) { + dvdec->par_x = NTSC_WIDE_PAR_X; + dvdec->par_y = NTSC_WIDE_PAR_Y; + } else { + dvdec->par_x = NTSC_NORMAL_PAR_X; + dvdec->par_y = NTSC_NORMAL_PAR_Y; + } + } + GST_DEBUG_OBJECT (dvdec, "Inferred PAR %d/%d from video format", + dvdec->par_x, dvdec->par_y); + } + + /* ignoring rgb, bgr0 for now */ + dvdec->bpp = 2; + + othercaps = gst_caps_new_simple ("video/x-raw-yuv", + "format", GST_TYPE_FOURCC, GST_STR_FOURCC ("YUY2"), + "width", G_TYPE_INT, 720, + "height", G_TYPE_INT, dvdec->height, + "framerate", GST_TYPE_FRACTION, dvdec->framerate_numerator, + dvdec->framerate_denominator, + "pixel-aspect-ratio", GST_TYPE_FRACTION, dvdec->par_x, + dvdec->par_y, "interlaced", G_TYPE_BOOLEAN, dvdec->interlaced, NULL); + + gst_pad_set_caps (dvdec->srcpad, othercaps); + gst_caps_unref (othercaps); + + dvdec->src_negotiated = TRUE; + + return TRUE; +} + +static gboolean +gst_dvdec_sink_event (GstPad * pad, GstEvent * event) +{ + GstDVDec *dvdec; + gboolean res = TRUE; + + dvdec = GST_DVDEC (gst_pad_get_parent (pad)); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_FLUSH_STOP: + gst_segment_init (dvdec->segment, GST_FORMAT_UNDEFINED); + break; + case GST_EVENT_NEWSEGMENT:{ + gboolean update; + gdouble rate, applied_rate; + GstFormat format; + gint64 start, stop, position; + + gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate, + &format, &start, &stop, &position); + + GST_DEBUG_OBJECT (dvdec, "Got NEWSEGMENT [%" GST_TIME_FORMAT + " - %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "]", + GST_TIME_ARGS (start), GST_TIME_ARGS (stop), + GST_TIME_ARGS (position)); + + gst_segment_set_newsegment_full (dvdec->segment, update, rate, + applied_rate, format, start, stop, position); + break; + } + default: + break; + } + + res = gst_pad_push_event (dvdec->srcpad, event); + + return res; +} + +static GstFlowReturn +gst_dvdec_chain (GstPad * pad, GstBuffer * buf) +{ + GstDVDec *dvdec; + guint8 *inframe; + guint8 *outframe; + guint8 *outframe_ptrs[3]; + gint outframe_pitches[3]; + GstBuffer *outbuf; + GstFlowReturn ret = GST_FLOW_OK; + guint length; + gint64 cstart, cstop; + gboolean PAL, wide; + + dvdec = GST_DVDEC (gst_pad_get_parent (pad)); + inframe = GST_BUFFER_DATA (buf); + + /* buffer should be at least the size of one NTSC frame, this should + * be enough to decode the header. */ + if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < NTSC_BUFFER)) + goto wrong_size; + + /* preliminary dropping. unref and return if outside of configured segment */ + if ((dvdec->segment->format == GST_FORMAT_TIME) && + (!(gst_segment_clip (dvdec->segment, GST_FORMAT_TIME, + GST_BUFFER_TIMESTAMP (buf), + GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf), + &cstart, &cstop)))) + goto dropping; + + if (G_UNLIKELY (dv_parse_header (dvdec->decoder, inframe) < 0)) + goto parse_header_error; + + /* get size */ + PAL = dv_system_50_fields (dvdec->decoder); + wide = dv_format_wide (dvdec->decoder); + + /* check the buffer is of right size after we know if we are + * dealing with PAL or NTSC */ + length = (PAL ? PAL_BUFFER : NTSC_BUFFER); + if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < length)) + goto wrong_size; + + dv_parse_packs (dvdec->decoder, inframe); + + if (dvdec->video_offset % dvdec->drop_factor != 0) + goto skip; + + /* renegotiate on change */ + if (PAL != dvdec->PAL || wide != dvdec->wide) { + dvdec->src_negotiated = FALSE; + dvdec->PAL = PAL; + dvdec->wide = wide; + } + + dvdec->height = (dvdec->PAL ? PAL_HEIGHT : NTSC_HEIGHT); + + dvdec->interlaced = !dv_is_progressive (dvdec->decoder); + + /* negotiate if not done yet */ + if (!dvdec->src_negotiated) { + if (!gst_dvdec_src_negotiate (dvdec)) + goto not_negotiated; + } + + ret = + gst_pad_alloc_buffer_and_set_caps (dvdec->srcpad, 0, + (720 * dvdec->height) * dvdec->bpp, + GST_PAD_CAPS (dvdec->srcpad), &outbuf); + if (G_UNLIKELY (ret != GST_FLOW_OK)) + goto no_buffer; + + outframe = GST_BUFFER_DATA (outbuf); + + outframe_ptrs[0] = outframe; + outframe_pitches[0] = 720 * dvdec->bpp; + + /* the rest only matters for YUY2 */ + if (dvdec->bpp < 3) { + outframe_ptrs[1] = outframe_ptrs[0] + 720 * dvdec->height; + outframe_ptrs[2] = outframe_ptrs[1] + 360 * dvdec->height; + + outframe_pitches[1] = dvdec->height / 2; + outframe_pitches[2] = outframe_pitches[1]; + } + + GST_DEBUG_OBJECT (dvdec, "decoding and pushing buffer"); + dv_decode_full_frame (dvdec->decoder, inframe, + e_dv_color_yuv, outframe_ptrs, outframe_pitches); + + GST_BUFFER_FLAG_UNSET (outbuf, GST_VIDEO_BUFFER_TFF); + + GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf); + GST_BUFFER_OFFSET_END (outbuf) = GST_BUFFER_OFFSET_END (buf); + GST_BUFFER_TIMESTAMP (outbuf) = cstart; + GST_BUFFER_DURATION (outbuf) = cstop - cstart; + + ret = gst_pad_push (dvdec->srcpad, outbuf); + +skip: + dvdec->video_offset++; + +done: + gst_buffer_unref (buf); + gst_object_unref (dvdec); + + return ret; + + /* ERRORS */ +wrong_size: + { + GST_ELEMENT_ERROR (dvdec, STREAM, DECODE, + (NULL), ("Input buffer too small")); + ret = GST_FLOW_ERROR; + goto done; + } +parse_header_error: + { + GST_ELEMENT_ERROR (dvdec, STREAM, DECODE, + (NULL), ("Error parsing DV header")); + ret = GST_FLOW_ERROR; + goto done; + } +not_negotiated: + { + GST_DEBUG_OBJECT (dvdec, "could not negotiate output"); + ret = GST_FLOW_NOT_NEGOTIATED; + goto done; + } +no_buffer: + { + GST_DEBUG_OBJECT (dvdec, "could not allocate buffer"); + goto done; + } + +dropping: + { + GST_DEBUG_OBJECT (dvdec, + "dropping buffer since it's out of the configured segment"); + goto done; + } +} + +static GstStateChangeReturn +gst_dvdec_change_state (GstElement * element, GstStateChange transition) +{ + GstDVDec *dvdec = GST_DVDEC (element); + GstStateChangeReturn ret; + + + switch (transition) { + case GST_STATE_CHANGE_NULL_TO_READY: + break; + case GST_STATE_CHANGE_READY_TO_PAUSED: + dvdec->decoder = + dv_decoder_new (0, dvdec->clamp_luma, dvdec->clamp_chroma); + dvdec->decoder->quality = qualities[dvdec->quality]; + dv_set_error_log (dvdec->decoder, NULL); + gst_segment_init (dvdec->segment, GST_FORMAT_UNDEFINED); + dvdec->src_negotiated = FALSE; + dvdec->sink_negotiated = FALSE; + /* + * Enable this function call when libdv2 0.100 or higher is more + * common + */ + /* dv_set_quality (dvdec->decoder, qualities [dvdec->quality]); */ + break; + case GST_STATE_CHANGE_PAUSED_TO_PLAYING: + break; + default: + break; + } + + ret = parent_class->change_state (element, transition); + + switch (transition) { + case GST_STATE_CHANGE_PLAYING_TO_PAUSED: + break; + case GST_STATE_CHANGE_PAUSED_TO_READY: + dv_decoder_free (dvdec->decoder); + dvdec->decoder = NULL; + break; + case GST_STATE_CHANGE_READY_TO_NULL: + break; + default: + break; + } + return ret; +} + +static void +gst_dvdec_set_property (GObject * object, guint prop_id, const GValue * value, + GParamSpec * pspec) +{ + GstDVDec *dvdec = GST_DVDEC (object); + + switch (prop_id) { + case PROP_CLAMP_LUMA: + dvdec->clamp_luma = g_value_get_boolean (value); + break; + case PROP_CLAMP_CHROMA: + dvdec->clamp_chroma = g_value_get_boolean (value); + break; + case PROP_QUALITY: + dvdec->quality = g_value_get_enum (value); + if ((dvdec->quality < 0) || (dvdec->quality > 5)) + dvdec->quality = 0; + break; + case PROP_DECODE_NTH: + dvdec->drop_factor = g_value_get_int (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gst_dvdec_get_property (GObject * object, guint prop_id, GValue * value, + GParamSpec * pspec) +{ + GstDVDec *dvdec = GST_DVDEC (object); + + switch (prop_id) { + case PROP_CLAMP_LUMA: + g_value_set_boolean (value, dvdec->clamp_luma); + break; + case PROP_CLAMP_CHROMA: + g_value_set_boolean (value, dvdec->clamp_chroma); + break; + case PROP_QUALITY: + g_value_set_enum (value, dvdec->quality); + break; + case PROP_DECODE_NTH: + g_value_set_int (value, dvdec->drop_factor); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} diff --git a/ext/dv/gstdvdec.h b/ext/dv/gstdvdec.h new file mode 100644 index 0000000..de8481d --- /dev/null +++ b/ext/dv/gstdvdec.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. + */ + + +#ifndef __GST_DVDEC_H__ +#define __GST_DVDEC_H__ + + +#include <gst/gst.h> +#include <libdv/dv.h> + + +G_BEGIN_DECLS + + +#define GST_TYPE_DVDEC \ + (gst_dvdec_get_type()) +#define GST_DVDEC(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVDEC,GstDVDec)) +#define GST_DVDEC_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVDEC,GstDVDecClass)) +#define GST_IS_DVDEC(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVDEC)) +#define GST_IS_DVDEC_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVDEC)) + + +typedef struct _GstDVDec GstDVDec; +typedef struct _GstDVDecClass GstDVDecClass; + + +struct _GstDVDec { + GstElement element; + + GstPad *sinkpad; + GstPad *srcpad; + + dv_decoder_t *decoder; + gboolean clamp_luma; + gboolean clamp_chroma; + gint quality; + + gboolean PAL; + gboolean interlaced; + gboolean wide; + gint frame_len; + + /* input caps */ + gboolean sink_negotiated; + gint framerate_numerator; + gint framerate_denominator; + gint height; + gint par_x; + gint par_y; + gboolean need_par; + + /* negotiated output */ + dv_color_space_t space; + gint bpp; + gboolean src_negotiated; + + gint video_offset; + gint drop_factor; + + GstSegment *segment; +}; + +struct _GstDVDecClass { + GstElementClass parent_class; +}; + + +GType gst_dvdec_get_type (void); + + +G_END_DECLS + + +#endif /* __GST_DVDEC_H__ */ diff --git a/ext/dv/gstdvdemux.c b/ext/dv/gstdvdemux.c new file mode 100644 index 0000000..90a2651 --- /dev/null +++ b/ext/dv/gstdvdemux.c @@ -0,0 +1,1909 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu> + * <2005> Wim Taymans <wim@fluendo.com> + * + * 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 <string.h> +#include <math.h> + +#include <gst/audio/audio.h> +#include "gstdvdemux.h" +#include "gstsmptetimecode.h" + +/** + * SECTION:element-dvdemux + * + * dvdemux splits raw DV into its audio and video components. The audio will be + * decoded raw samples and the video will be encoded DV video. + * + * This element can operate in both push and pull mode depending on the + * capabilities of the upstream peer. + * + * <refsect2> + * <title>Example launch line</title> + * |[ + * gst-launch filesrc location=test.dv ! dvdemux name=demux ! queue ! audioconvert ! alsasink demux. ! queue ! dvdec ! xvimagesink + * ]| This pipeline decodes and renders the raw DV stream to an audio and a videosink. + * </refsect2> + * + * Last reviewed on 2006-02-27 (0.10.3) + */ + +/* DV output has two modes, normal and wide. The resolution is the same in both + * cases: 720 pixels wide by 576 pixels tall in PAL format, and 720x480 for + * NTSC. + * + * Each of the modes has its own pixel aspect ratio, which is fixed in practice + * by ITU-R BT.601 (also known as "CCIR-601" or "Rec.601"). Or so claims a + * reference that I culled from the reliable "internet", + * http://www.mir.com/DMG/aspect.html. Normal PAL is 59/54 and normal NTSC is + * 10/11. Because the pixel resolution is the same for both cases, we can get + * the pixel aspect ratio for wide recordings by multiplying by the ratio of + * display aspect ratios, 16/9 (for wide) divided by 4/3 (for normal): + * + * Wide NTSC: 10/11 * (16/9)/(4/3) = 40/33 + * Wide PAL: 59/54 * (16/9)/(4/3) = 118/81 + * + * However, the pixel resolution coming out of a DV source does not combine with + * the standard pixel aspect ratios to give a proper display aspect ratio. An + * image 480 pixels tall, with a 4:3 display aspect ratio, will be 768 pixels + * wide. But, if we take the normal PAL aspect ratio of 59/54, and multiply it + * with the width of the DV image (720 pixels), we get 786.666..., which is + * nonintegral and too wide. The camera is not outputting a 4:3 image. + * + * If the video sink for this stream has fixed dimensions (such as for + * fullscreen playback, or for a java applet in a web page), you then have two + * choices. Either you show the whole image, but pad the image with black + * borders on the top and bottom (like watching a widescreen video on a 4:3 + * device), or you crop the video to the proper ratio. Apparently the latter is + * the standard practice. + * + * For its part, GStreamer is concerned with accuracy and preservation of + * information. This element outputs the 720x576 or 720x480 video that it + * recieves, noting the proper aspect ratio. This should not be a problem for + * windowed applications, which can change size to fit the video. Applications + * with fixed size requirements should decide whether to crop or pad which + * an element such as videobox can do. + */ + +#define NTSC_HEIGHT 480 +#define NTSC_BUFFER 120000 +#define NTSC_FRAMERATE_NUMERATOR 30000 +#define NTSC_FRAMERATE_DENOMINATOR 1001 + +#define PAL_HEIGHT 576 +#define PAL_BUFFER 144000 +#define PAL_FRAMERATE_NUMERATOR 25 +#define PAL_FRAMERATE_DENOMINATOR 1 + +#define PAL_NORMAL_PAR_X 59 +#define PAL_NORMAL_PAR_Y 54 +#define PAL_WIDE_PAR_X 118 +#define PAL_WIDE_PAR_Y 81 + +#define NTSC_NORMAL_PAR_X 10 +#define NTSC_NORMAL_PAR_Y 11 +#define NTSC_WIDE_PAR_X 40 +#define NTSC_WIDE_PAR_Y 33 + +GST_DEBUG_CATEGORY_STATIC (dvdemux_debug); +#define GST_CAT_DEFAULT dvdemux_debug + +static GstStaticPadTemplate sink_temp = GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/x-dv, systemstream = (boolean) true") + ); + +static GstStaticPadTemplate video_src_temp = GST_STATIC_PAD_TEMPLATE ("video", + GST_PAD_SRC, + GST_PAD_SOMETIMES, + GST_STATIC_CAPS ("video/x-dv, systemstream = (boolean) false") + ); + +static GstStaticPadTemplate audio_src_temp = GST_STATIC_PAD_TEMPLATE ("audio", + GST_PAD_SRC, + GST_PAD_SOMETIMES, + GST_STATIC_CAPS ("audio/x-raw-int, " + "depth = (int) 16, " + "width = (int) 16, " + "signed = (boolean) TRUE, " + "channels = (int) {2, 4}, " + "endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", " + "rate = (int) { 32000, 44100, 48000 }") + ); + + +GST_BOILERPLATE (GstDVDemux, gst_dvdemux, GstElement, GST_TYPE_ELEMENT); + +static void gst_dvdemux_finalize (GObject * object); + +/* query functions */ +static const GstQueryType *gst_dvdemux_get_src_query_types (GstPad * pad); +static gboolean gst_dvdemux_src_query (GstPad * pad, GstQuery * query); +static const GstQueryType *gst_dvdemux_get_sink_query_types (GstPad * pad); +static gboolean gst_dvdemux_sink_query (GstPad * pad, GstQuery * query); + +/* convert functions */ +static gboolean gst_dvdemux_sink_convert (GstDVDemux * demux, + GstFormat src_format, gint64 src_value, GstFormat * dest_format, + gint64 * dest_value); +static gboolean gst_dvdemux_src_convert (GstDVDemux * demux, GstPad * pad, + GstFormat src_format, gint64 src_value, GstFormat * dest_format, + gint64 * dest_value); + +/* event functions */ +static gboolean gst_dvdemux_send_event (GstElement * element, GstEvent * event); +static gboolean gst_dvdemux_handle_src_event (GstPad * pad, GstEvent * event); +static gboolean gst_dvdemux_handle_sink_event (GstPad * pad, GstEvent * event); + +/* scheduling functions */ +static void gst_dvdemux_loop (GstPad * pad); +static GstFlowReturn gst_dvdemux_flush (GstDVDemux * dvdemux); +static GstFlowReturn gst_dvdemux_chain (GstPad * pad, GstBuffer * buffer); + +/* state change functions */ +static gboolean gst_dvdemux_sink_activate (GstPad * sinkpad); +static gboolean gst_dvdemux_sink_activate_push (GstPad * sinkpad, + gboolean active); +static gboolean gst_dvdemux_sink_activate_pull (GstPad * sinkpad, + gboolean active); +static GstStateChangeReturn gst_dvdemux_change_state (GstElement * element, + GstStateChange transition); + +static void +gst_dvdemux_base_init (gpointer g_class) +{ + GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); + + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_temp)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&video_src_temp)); + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&audio_src_temp)); + + gst_element_class_set_details_simple (element_class, + "DV system stream demuxer", "Codec/Demuxer", + "Uses libdv to separate DV audio from DV video (libdv.sourceforge.net)", + "Erik Walthinsen <omega@cse.ogi.edu>, Wim Taymans <wim@fluendo.com>"); + + GST_DEBUG_CATEGORY_INIT (dvdemux_debug, "dvdemux", 0, "DV demuxer element"); +} + +static void +gst_dvdemux_class_init (GstDVDemuxClass * klass) +{ + GObjectClass *gobject_class; + GstElementClass *gstelement_class; + + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; + + gobject_class->finalize = gst_dvdemux_finalize; + + gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_dvdemux_change_state); + gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_dvdemux_send_event); +} + +static void +gst_dvdemux_init (GstDVDemux * dvdemux, GstDVDemuxClass * g_class) +{ + gint i; + + dvdemux->sinkpad = gst_pad_new_from_static_template (&sink_temp, "sink"); + /* we can operate in pull and push mode so we install + * a custom activate function */ + gst_pad_set_activate_function (dvdemux->sinkpad, + GST_DEBUG_FUNCPTR (gst_dvdemux_sink_activate)); + /* the function to activate in push mode */ + gst_pad_set_activatepush_function (dvdemux->sinkpad, + GST_DEBUG_FUNCPTR (gst_dvdemux_sink_activate_push)); + /* the function to activate in pull mode */ + gst_pad_set_activatepull_function (dvdemux->sinkpad, + GST_DEBUG_FUNCPTR (gst_dvdemux_sink_activate_pull)); + /* for push mode, this is the chain function */ + gst_pad_set_chain_function (dvdemux->sinkpad, + GST_DEBUG_FUNCPTR (gst_dvdemux_chain)); + /* handling events (in push mode only) */ + gst_pad_set_event_function (dvdemux->sinkpad, + GST_DEBUG_FUNCPTR (gst_dvdemux_handle_sink_event)); + /* query functions */ + gst_pad_set_query_function (dvdemux->sinkpad, + GST_DEBUG_FUNCPTR (gst_dvdemux_sink_query)); + gst_pad_set_query_type_function (dvdemux->sinkpad, + GST_DEBUG_FUNCPTR (gst_dvdemux_get_sink_query_types)); + + /* now add the pad */ + gst_element_add_pad (GST_ELEMENT (dvdemux), dvdemux->sinkpad); + + dvdemux->adapter = gst_adapter_new (); + + /* we need 4 temp buffers for audio decoding which are of a static + * size and which we can allocate here */ + for (i = 0; i < 4; i++) { + dvdemux->audio_buffers[i] = + (gint16 *) g_malloc (DV_AUDIO_MAX_SAMPLES * sizeof (gint16)); + } +} + +static void +gst_dvdemux_finalize (GObject * object) +{ + GstDVDemux *dvdemux; + gint i; + + dvdemux = GST_DVDEMUX (object); + + g_object_unref (dvdemux->adapter); + + /* clean up temp audio buffers */ + for (i = 0; i < 4; i++) { + g_free (dvdemux->audio_buffers[i]); + } + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +/* reset to default values before starting streaming */ +static void +gst_dvdemux_reset (GstDVDemux * dvdemux) +{ + dvdemux->frame_offset = 0; + dvdemux->audio_offset = 0; + dvdemux->video_offset = 0; + dvdemux->framecount = 0; + g_atomic_int_set (&dvdemux->found_header, 0); + dvdemux->frame_len = -1; + dvdemux->need_segment = FALSE; + dvdemux->new_media = FALSE; + dvdemux->framerate_numerator = 0; + dvdemux->framerate_denominator = 0; + dvdemux->height = 0; + dvdemux->frequency = 0; + dvdemux->channels = 0; + dvdemux->wide = FALSE; + gst_segment_init (&dvdemux->byte_segment, GST_FORMAT_BYTES); + gst_segment_init (&dvdemux->time_segment, GST_FORMAT_TIME); +} + +static GstPad * +gst_dvdemux_add_pad (GstDVDemux * dvdemux, GstStaticPadTemplate * template) +{ + gboolean no_more_pads; + GstPad *pad; + + pad = gst_pad_new_from_static_template (template, template->name_template); + + gst_pad_set_query_function (pad, GST_DEBUG_FUNCPTR (gst_dvdemux_src_query)); + + gst_pad_set_query_type_function (pad, + GST_DEBUG_FUNCPTR (gst_dvdemux_get_src_query_types)); + gst_pad_set_event_function (pad, + GST_DEBUG_FUNCPTR (gst_dvdemux_handle_src_event)); + gst_pad_use_fixed_caps (pad); + gst_pad_set_active (pad, TRUE); + gst_element_add_pad (GST_ELEMENT (dvdemux), pad); + + no_more_pads = + (dvdemux->videosrcpad != NULL && template == &audio_src_temp) || + (dvdemux->audiosrcpad != NULL && template == &video_src_temp); + + if (no_more_pads) + gst_element_no_more_pads (GST_ELEMENT (dvdemux)); + + gst_pad_push_event (pad, gst_event_new_new_segment (FALSE, + dvdemux->byte_segment.rate, GST_FORMAT_TIME, + dvdemux->time_segment.start, dvdemux->time_segment.stop, + dvdemux->time_segment.start)); + + if (no_more_pads) { + gst_element_found_tags (GST_ELEMENT (dvdemux), + gst_tag_list_new_full (GST_TAG_CONTAINER_FORMAT, "DV", NULL)); + } + + return pad; +} + +static void +gst_dvdemux_remove_pads (GstDVDemux * dvdemux) +{ + if (dvdemux->videosrcpad) { + gst_element_remove_pad (GST_ELEMENT (dvdemux), dvdemux->videosrcpad); + dvdemux->videosrcpad = NULL; + } + if (dvdemux->audiosrcpad) { + gst_element_remove_pad (GST_ELEMENT (dvdemux), dvdemux->audiosrcpad); + dvdemux->audiosrcpad = NULL; + } +} + +static gboolean +gst_dvdemux_src_convert (GstDVDemux * dvdemux, GstPad * pad, + GstFormat src_format, gint64 src_value, GstFormat * dest_format, + gint64 * dest_value) +{ + gboolean res = TRUE; + + if (*dest_format == src_format || src_value == -1) { + *dest_value = src_value; + goto done; + } + + if (dvdemux->frame_len <= 0) + goto error; + + if (dvdemux->decoder == NULL) + goto error; + + GST_INFO_OBJECT (pad, + "src_value:%" G_GINT64_FORMAT ", src_format:%d, dest_format:%d", + src_value, src_format, *dest_format); + + switch (src_format) { + case GST_FORMAT_BYTES: + switch (*dest_format) { + case GST_FORMAT_DEFAULT: + if (pad == dvdemux->videosrcpad) + *dest_value = src_value / dvdemux->frame_len; + else if (pad == dvdemux->audiosrcpad) + *dest_value = src_value / (2 * dvdemux->channels); + break; + case GST_FORMAT_TIME: + *dest_format = GST_FORMAT_TIME; + if (pad == dvdemux->videosrcpad) + *dest_value = gst_util_uint64_scale (src_value, + GST_SECOND * dvdemux->framerate_denominator, + dvdemux->frame_len * dvdemux->framerate_numerator); + else if (pad == dvdemux->audiosrcpad) + *dest_value = gst_util_uint64_scale_int (src_value, GST_SECOND, + 2 * dvdemux->frequency * dvdemux->channels); + break; + default: + res = FALSE; + } + break; + case GST_FORMAT_TIME: + switch (*dest_format) { + case GST_FORMAT_BYTES: + if (pad == dvdemux->videosrcpad) + *dest_value = gst_util_uint64_scale (src_value, + dvdemux->frame_len * dvdemux->framerate_numerator, + dvdemux->framerate_denominator * GST_SECOND); + else if (pad == dvdemux->audiosrcpad) + *dest_value = gst_util_uint64_scale_int (src_value, + 2 * dvdemux->frequency * dvdemux->channels, GST_SECOND); + break; + case GST_FORMAT_DEFAULT: + if (pad == dvdemux->videosrcpad) { + if (src_value) + *dest_value = gst_util_uint64_scale (src_value, + dvdemux->framerate_numerator, + dvdemux->framerate_denominator * GST_SECOND); + else + *dest_value = 0; + } else if (pad == dvdemux->audiosrcpad) { + *dest_value = gst_util_uint64_scale (src_value, + dvdemux->frequency, GST_SECOND); + } + break; + default: + res = FALSE; + } + break; + case GST_FORMAT_DEFAULT: + switch (*dest_format) { + case GST_FORMAT_TIME: + if (pad == dvdemux->videosrcpad) { + *dest_value = gst_util_uint64_scale (src_value, + GST_SECOND * dvdemux->framerate_denominator, + dvdemux->framerate_numerator); + } else if (pad == dvdemux->audiosrcpad) { + if (src_value) + *dest_value = gst_util_uint64_scale (src_value, + GST_SECOND, dvdemux->frequency); + else + *dest_value = 0; + } + break; + case GST_FORMAT_BYTES: + if (pad == dvdemux->videosrcpad) { + *dest_value = src_value * dvdemux->frame_len; + } else if (pad == dvdemux->audiosrcpad) { + *dest_value = src_value * 2 * dvdemux->channels; + } + break; + default: + res = FALSE; + } + break; + default: + res = FALSE; + } + +done: + GST_INFO_OBJECT (pad, + "Result : dest_format:%d, dest_value:%" G_GINT64_FORMAT ", res:%d", + *dest_format, *dest_value, res); + return res; + + /* ERRORS */ +error: + { + GST_INFO ("source conversion failed"); + return FALSE; + } +} + +static gboolean +gst_dvdemux_sink_convert (GstDVDemux * dvdemux, GstFormat src_format, + gint64 src_value, GstFormat * dest_format, gint64 * dest_value) +{ + gboolean res = TRUE; + + GST_DEBUG_OBJECT (dvdemux, "%d -> %d", src_format, *dest_format); + GST_INFO_OBJECT (dvdemux, + "src_value:%" G_GINT64_FORMAT ", src_format:%d, dest_format:%d", + src_value, src_format, *dest_format); + + if (*dest_format == GST_FORMAT_DEFAULT) + *dest_format = GST_FORMAT_TIME; + + if (*dest_format == src_format || src_value == -1) { + *dest_value = src_value; + goto done; + } + + if (dvdemux->frame_len <= 0) + goto error; + + switch (src_format) { + case GST_FORMAT_BYTES: + switch (*dest_format) { + case GST_FORMAT_TIME: + { + guint64 frame; + + /* get frame number, rounds down so don't combine this + * line and the next line. */ + frame = src_value / dvdemux->frame_len; + + *dest_value = gst_util_uint64_scale (frame, + GST_SECOND * dvdemux->framerate_denominator, + dvdemux->framerate_numerator); + break; + } + default: + res = FALSE; + } + break; + case GST_FORMAT_TIME: + switch (*dest_format) { + case GST_FORMAT_BYTES: + { + guint64 frame; + + /* calculate the frame */ + frame = + gst_util_uint64_scale (src_value, dvdemux->framerate_numerator, + dvdemux->framerate_denominator * GST_SECOND); + + /* calculate the offset from the rounded frame */ + *dest_value = frame * dvdemux->frame_len; + break; + } + default: + res = FALSE; + } + break; + default: + res = FALSE; + } + GST_INFO_OBJECT (dvdemux, + "Result : dest_format:%d, dest_value:%" G_GINT64_FORMAT ", res:%d", + *dest_format, *dest_value, res); + +done: + return res; + +error: + { + GST_INFO_OBJECT (dvdemux, "sink conversion failed"); + return FALSE; + } +} + +static const GstQueryType * +gst_dvdemux_get_src_query_types (GstPad * pad) +{ + static const GstQueryType src_query_types[] = { + GST_QUERY_POSITION, + GST_QUERY_DURATION, + GST_QUERY_CONVERT, + 0 + }; + + return src_query_types; +} + +static gboolean +gst_dvdemux_src_query (GstPad * pad, GstQuery * query) +{ + gboolean res = TRUE; + GstDVDemux *dvdemux; + + dvdemux = GST_DVDEMUX (gst_pad_get_parent (pad)); + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_POSITION: + { + GstFormat format; + gint64 cur; + + /* get target format */ + gst_query_parse_position (query, &format, NULL); + + /* bring the position to the requested format. */ + if (!(res = gst_dvdemux_src_convert (dvdemux, pad, + GST_FORMAT_TIME, dvdemux->time_segment.last_stop, + &format, &cur))) + goto error; + gst_query_set_position (query, format, cur); + break; + } + case GST_QUERY_DURATION: + { + GstFormat format; + GstFormat format2; + gint64 end; + GstPad *peer; + + /* get target format */ + gst_query_parse_duration (query, &format, NULL); + + /* change query to bytes to perform on peer */ + gst_query_set_duration (query, GST_FORMAT_BYTES, -1); + + if ((peer = gst_pad_get_peer (dvdemux->sinkpad))) { + /* ask peer for total length */ + if (!(res = gst_pad_query (peer, query))) { + gst_object_unref (peer); + goto error; + } + + /* get peer total length */ + gst_query_parse_duration (query, NULL, &end); + + gst_object_unref (peer); + + /* convert end to requested format */ + if (end != -1) { + format2 = format; + if (!(res = gst_dvdemux_sink_convert (dvdemux, + GST_FORMAT_BYTES, end, &format2, &end))) { + goto error; + } + } + } else { + end = -1; + } + gst_query_set_duration (query, format, end); + break; + } + case GST_QUERY_CONVERT: + { + GstFormat src_fmt, dest_fmt; + gint64 src_val, dest_val; + + gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val); + if (!(res = + gst_dvdemux_src_convert (dvdemux, pad, src_fmt, src_val, + &dest_fmt, &dest_val))) + goto error; + gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val); + break; + } + default: + res = gst_pad_query_default (pad, query); + break; + } + gst_object_unref (dvdemux); + + return res; + + /* ERRORS */ +error: + { + gst_object_unref (dvdemux); + GST_DEBUG ("error source query"); + return FALSE; + } +} + +static const GstQueryType * +gst_dvdemux_get_sink_query_types (GstPad * pad) +{ + static const GstQueryType sink_query_types[] = { + GST_QUERY_CONVERT, + 0 + }; + + return sink_query_types; +} + +static gboolean +gst_dvdemux_sink_query (GstPad * pad, GstQuery * query) +{ + gboolean res = TRUE; + GstDVDemux *dvdemux; + + dvdemux = GST_DVDEMUX (gst_pad_get_parent (pad)); + + switch (GST_QUERY_TYPE (query)) { + case GST_QUERY_CONVERT: + { + GstFormat src_fmt, dest_fmt; + gint64 src_val, dest_val; + + gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val); + if (!(res = + gst_dvdemux_sink_convert (dvdemux, src_fmt, src_val, &dest_fmt, + &dest_val))) + goto error; + gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val); + break; + } + default: + res = gst_pad_query_default (pad, query); + break; + } + gst_object_unref (dvdemux); + + return res; + + /* ERRORS */ +error: + { + gst_object_unref (dvdemux); + GST_DEBUG ("error handling sink query"); + return FALSE; + } +} + +/* takes ownership of the event */ +static gboolean +gst_dvdemux_push_event (GstDVDemux * dvdemux, GstEvent * event) +{ + gboolean res = FALSE; + + if (dvdemux->videosrcpad) { + gst_event_ref (event); + res |= gst_pad_push_event (dvdemux->videosrcpad, event); + } + + if (dvdemux->audiosrcpad) + res |= gst_pad_push_event (dvdemux->audiosrcpad, event); + else + gst_event_unref (event); + + return res; +} + +static gboolean +gst_dvdemux_handle_sink_event (GstPad * pad, GstEvent * event) +{ + GstDVDemux *dvdemux = GST_DVDEMUX (gst_pad_get_parent (pad)); + gboolean res = TRUE; + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_FLUSH_START: + /* we are not blocking on anything exect the push() calls + * to the peer which will be unblocked by forwarding the + * event.*/ + res = gst_dvdemux_push_event (dvdemux, event); + break; + case GST_EVENT_FLUSH_STOP: + gst_adapter_clear (dvdemux->adapter); + GST_DEBUG ("cleared adapter"); + gst_segment_init (&dvdemux->byte_segment, GST_FORMAT_BYTES); + gst_segment_init (&dvdemux->time_segment, GST_FORMAT_TIME); + res = gst_dvdemux_push_event (dvdemux, event); + break; + case GST_EVENT_NEWSEGMENT: + { + gboolean update; + gdouble rate; + GstFormat format; + gint64 start, stop, time; + + /* parse byte start and stop positions */ + gst_event_parse_new_segment (event, &update, &rate, &format, + &start, &stop, &time); + + switch (format) { + case GST_FORMAT_BYTES: + gst_segment_set_newsegment (&dvdemux->byte_segment, update, + rate, format, start, stop, time); + + /* the update can always be sent */ + if (update) { + GstEvent *update; + + update = gst_event_new_new_segment (TRUE, + dvdemux->time_segment.rate, dvdemux->time_segment.format, + dvdemux->time_segment.start, dvdemux->time_segment.last_stop, + dvdemux->time_segment.time); + + gst_dvdemux_push_event (dvdemux, update); + } else { + /* and queue a SEGMENT before sending the next set of buffers, we + * cannot convert to time yet as we might not know the size of the + * frames, etc.. */ + dvdemux->need_segment = TRUE; + } + gst_event_unref (event); + break; + case GST_FORMAT_TIME: + gst_segment_set_newsegment (&dvdemux->time_segment, update, + rate, format, start, stop, time); + + /* and we can just forward this time event */ + res = gst_dvdemux_push_event (dvdemux, event); + break; + default: + gst_event_unref (event); + /* cannot accept this format */ + res = FALSE; + break; + } + break; + } + case GST_EVENT_EOS: + /* flush any pending data, should be nothing left. */ + gst_dvdemux_flush (dvdemux); + /* forward event */ + res = gst_dvdemux_push_event (dvdemux, event); + /* and clear the adapter */ + gst_adapter_clear (dvdemux->adapter); + break; + default: + res = gst_dvdemux_push_event (dvdemux, event); + break; + } + + gst_object_unref (dvdemux); + + return res; +} + +/* convert a pair of values on the given srcpad */ +static gboolean +gst_dvdemux_convert_src_pair (GstDVDemux * dvdemux, GstPad * pad, + GstFormat src_format, gint64 src_start, gint64 src_stop, + GstFormat dst_format, gint64 * dst_start, gint64 * dst_stop) +{ + gboolean res; + + GST_INFO ("starting conversion of start"); + /* bring the format to time on srcpad. */ + if (!(res = gst_dvdemux_src_convert (dvdemux, pad, + src_format, src_start, &dst_format, dst_start))) { + goto done; + } + GST_INFO ("Finished conversion of start: %" G_GINT64_FORMAT, *dst_start); + + GST_INFO ("starting conversion of stop"); + /* bring the format to time on srcpad. */ + if (!(res = gst_dvdemux_src_convert (dvdemux, pad, + src_format, src_stop, &dst_format, dst_stop))) { + /* could not convert seek format to time offset */ + goto done; + } + GST_INFO ("Finished conversion of stop: %" G_GINT64_FORMAT, *dst_stop); +done: + return res; +} + +/* convert a pair of values on the sinkpad */ +static gboolean +gst_dvdemux_convert_sink_pair (GstDVDemux * dvdemux, + GstFormat src_format, gint64 src_start, gint64 src_stop, + GstFormat dst_format, gint64 * dst_start, gint64 * dst_stop) +{ + gboolean res; + + GST_INFO ("starting conversion of start"); + /* bring the format to time on srcpad. */ + if (!(res = gst_dvdemux_sink_convert (dvdemux, + src_format, src_start, &dst_format, dst_start))) { + goto done; + } + GST_INFO ("Finished conversion of start: %" G_GINT64_FORMAT, *dst_start); + + GST_INFO ("starting conversion of stop"); + /* bring the format to time on srcpad. */ + if (!(res = gst_dvdemux_sink_convert (dvdemux, + src_format, src_stop, &dst_format, dst_stop))) { + /* could not convert seek format to time offset */ + goto done; + } + GST_INFO ("Finished conversion of stop: %" G_GINT64_FORMAT, *dst_stop); +done: + return res; +} + +/* convert a pair of values on the srcpad to a pair of + * values on the sinkpad + */ +static gboolean +gst_dvdemux_convert_src_to_sink (GstDVDemux * dvdemux, GstPad * pad, + GstFormat src_format, gint64 src_start, gint64 src_stop, + GstFormat dst_format, gint64 * dst_start, gint64 * dst_stop) +{ + GstFormat conv; + gboolean res; + + conv = GST_FORMAT_TIME; + /* convert to TIME intermediate format */ + if (!(res = gst_dvdemux_convert_src_pair (dvdemux, pad, + src_format, src_start, src_stop, conv, dst_start, dst_stop))) { + /* could not convert format to time offset */ + goto done; + } + /* convert to dst format on sinkpad */ + if (!(res = gst_dvdemux_convert_sink_pair (dvdemux, + conv, *dst_start, *dst_stop, dst_format, dst_start, dst_stop))) { + /* could not convert format to time offset */ + goto done; + } +done: + return res; +} + +#if 0 +static gboolean +gst_dvdemux_convert_segment (GstDVDemux * dvdemux, GstSegment * src, + GstSegment * dest) +{ + dest->rate = src->rate; + dest->abs_rate = src->abs_rate; + dest->flags = src->flags; + + return TRUE; +} +#endif + +/* handle seek in push base mode. + * + * Convert the time seek to a bytes seek and send it + * upstream + * Does not take ownership of the event. + */ +static gboolean +gst_dvdemux_handle_push_seek (GstDVDemux * dvdemux, GstPad * pad, + GstEvent * event) +{ + gboolean res = FALSE; + gdouble rate; + GstSeekFlags flags; + GstFormat format; + GstSeekType cur_type, stop_type; + gint64 cur, stop; + gint64 start_position, end_position; + GstEvent *newevent; + + gst_event_parse_seek (event, &rate, &format, &flags, + &cur_type, &cur, &stop_type, &stop); + + /* First try if upstream can handle time based seeks */ + if (format == GST_FORMAT_TIME) + res = gst_pad_push_event (dvdemux->sinkpad, gst_event_ref (event)); + + if (!res) { + /* we convert the start/stop on the srcpad to the byte format + * on the sinkpad and forward the event */ + res = gst_dvdemux_convert_src_to_sink (dvdemux, pad, + format, cur, stop, GST_FORMAT_BYTES, &start_position, &end_position); + if (!res) + goto done; + + /* now this is the updated seek event on bytes */ + newevent = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags, + cur_type, start_position, stop_type, end_position); + + res = gst_pad_push_event (dvdemux->sinkpad, newevent); + } +done: + return res; +} + +/* position ourselves to the configured segment, used in pull mode. + * The input segment is in TIME format. We convert the time values + * to bytes values into our byte_segment which we use to pull data from + * the sinkpad peer. + */ +static gboolean +gst_dvdemux_do_seek (GstDVDemux * demux, GstSegment * segment) +{ + gboolean res; + GstFormat format; + + /* position to value configured is last_stop, this will round down + * to the byte position where the frame containing the given + * timestamp can be found. */ + format = GST_FORMAT_BYTES; + res = gst_dvdemux_sink_convert (demux, + segment->format, segment->last_stop, + &format, &demux->byte_segment.last_stop); + if (!res) + goto done; + + /* update byte segment start */ + gst_dvdemux_sink_convert (demux, + segment->format, segment->start, &format, &demux->byte_segment.start); + + /* update byte segment stop */ + gst_dvdemux_sink_convert (demux, + segment->format, segment->stop, &format, &demux->byte_segment.stop); + + /* update byte segment time */ + gst_dvdemux_sink_convert (demux, + segment->format, segment->time, &format, &demux->byte_segment.time); + + /* calculate current frame number */ + format = GST_FORMAT_DEFAULT; + gst_dvdemux_src_convert (demux, demux->videosrcpad, + segment->format, segment->start, &format, &demux->video_offset); + + /* calculate current audio number */ + format = GST_FORMAT_DEFAULT; + gst_dvdemux_src_convert (demux, demux->audiosrcpad, + segment->format, segment->start, &format, &demux->audio_offset); + + /* every DV frame corresponts with one video frame */ + demux->frame_offset = demux->video_offset; + +done: + return res; +} + +/* handle seek in pull base mode. + * + * Does not take ownership of the event. + */ +static gboolean +gst_dvdemux_handle_pull_seek (GstDVDemux * demux, GstPad * pad, + GstEvent * event) +{ + gboolean res; + gdouble rate; + GstFormat format; + GstSeekFlags flags; + GstSeekType cur_type, stop_type; + gint64 cur, stop; + gboolean flush; + gboolean update; + GstSegment seeksegment; + + GST_DEBUG_OBJECT (demux, "doing seek"); + + /* first bring the event format to TIME, our native format + * to perform the seek on */ + if (event) { + GstFormat conv; + + gst_event_parse_seek (event, &rate, &format, &flags, + &cur_type, &cur, &stop_type, &stop); + + /* can't seek backwards yet */ + if (rate <= 0.0) + goto wrong_rate; + + /* convert input format to TIME */ + conv = GST_FORMAT_TIME; + if (!(gst_dvdemux_convert_src_pair (demux, pad, + format, cur, stop, conv, &cur, &stop))) + goto no_format; + + format = GST_FORMAT_TIME; + } else { + flags = 0; + } + + flush = flags & GST_SEEK_FLAG_FLUSH; + + /* send flush start */ + if (flush) + gst_dvdemux_push_event (demux, gst_event_new_flush_start ()); + else + gst_pad_pause_task (demux->sinkpad); + + /* grab streaming lock, this should eventually be possible, either + * because the task is paused or our streaming thread stopped + * because our peer is flushing. */ + GST_PAD_STREAM_LOCK (demux->sinkpad); + + /* make copy into temp structure, we can only update the main one + * when the subclass actually could to the seek. */ + memcpy (&seeksegment, &demux->time_segment, sizeof (GstSegment)); + + /* now configure the seek segment */ + if (event) { + gst_segment_set_seek (&seeksegment, rate, format, flags, + cur_type, cur, stop_type, stop, &update); + } + + GST_DEBUG_OBJECT (demux, "segment configured from %" G_GINT64_FORMAT + " to %" G_GINT64_FORMAT ", position %" G_GINT64_FORMAT, + seeksegment.start, seeksegment.stop, seeksegment.last_stop); + + /* do the seek, segment.last_stop contains new position. */ + res = gst_dvdemux_do_seek (demux, &seeksegment); + + /* and prepare to continue streaming */ + if (flush) { + /* send flush stop, peer will accept data and events again. We + * are not yet providing data as we still have the STREAM_LOCK. */ + gst_dvdemux_push_event (demux, gst_event_new_flush_stop ()); + } else if (res && demux->running) { + /* we are running the current segment and doing a non-flushing seek, + * close the segment first based on the last_stop. */ + GST_DEBUG_OBJECT (demux, "closing running segment %" G_GINT64_FORMAT + " to %" G_GINT64_FORMAT, demux->time_segment.start, + demux->time_segment.last_stop); + + gst_dvdemux_push_event (demux, + gst_event_new_new_segment (TRUE, + demux->time_segment.rate, demux->time_segment.format, + demux->time_segment.start, demux->time_segment.last_stop, + demux->time_segment.time)); + } + + /* if successfull seek, we update our real segment and push + * out the new segment. */ + if (res) { + memcpy (&demux->time_segment, &seeksegment, sizeof (GstSegment)); + + if (demux->time_segment.flags & GST_SEEK_FLAG_SEGMENT) { + gst_element_post_message (GST_ELEMENT_CAST (demux), + gst_message_new_segment_start (GST_OBJECT_CAST (demux), + demux->time_segment.format, demux->time_segment.last_stop)); + } + if ((stop = demux->time_segment.stop) == -1) + stop = demux->time_segment.duration; + + GST_INFO_OBJECT (demux, + "Saving newsegment event to be sent in streaming thread"); + + if (demux->pending_segment) + gst_event_unref (demux->pending_segment); + + demux->pending_segment = gst_event_new_new_segment (FALSE, + demux->time_segment.rate, demux->time_segment.format, + demux->time_segment.last_stop, stop, demux->time_segment.time); + + demux->need_segment = FALSE; + } + + demux->running = TRUE; + /* 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_dvdemux_loop, + demux->sinkpad); + + /* and release the lock again so we can continue streaming */ + GST_PAD_STREAM_UNLOCK (demux->sinkpad); + + return TRUE; + + /* ERRORS */ +wrong_rate: + { + GST_DEBUG_OBJECT (demux, "negative playback rate %lf not supported.", rate); + return FALSE; + } +no_format: + { + GST_DEBUG_OBJECT (demux, "cannot convert to TIME format, seek aborted."); + return FALSE; + } +} + +static gboolean +gst_dvdemux_send_event (GstElement * element, GstEvent * event) +{ + GstDVDemux *dvdemux = GST_DVDEMUX (element); + gboolean res = FALSE; + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_SEEK: + { + /* checking header and configuring the seek must be atomic */ + GST_OBJECT_LOCK (dvdemux); + if (g_atomic_int_get (&dvdemux->found_header) == 0) { + GstEvent **event_p; + + event_p = &dvdemux->seek_event; + + /* We don't have pads yet. Keep the event. */ + GST_INFO_OBJECT (dvdemux, "Keeping the seek event for later"); + + gst_event_replace (event_p, event); + GST_OBJECT_UNLOCK (dvdemux); + + res = TRUE; + } else { + GST_OBJECT_UNLOCK (dvdemux); + + if (dvdemux->seek_handler) { + res = dvdemux->seek_handler (dvdemux, dvdemux->videosrcpad, event); + gst_event_unref (event); + } + } + break; + } + default: + res = GST_ELEMENT_CLASS (parent_class)->send_event (element, event); + break; + } + + return res; +} + +/* handle an event on the source pad, it's most likely a seek */ +static gboolean +gst_dvdemux_handle_src_event (GstPad * pad, GstEvent * event) +{ + gboolean res = TRUE; + GstDVDemux *dvdemux; + + dvdemux = GST_DVDEMUX (gst_pad_get_parent (pad)); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_SEEK: + /* seek handler is installed based on scheduling mode */ + if (dvdemux->seek_handler) + res = dvdemux->seek_handler (dvdemux, pad, event); + else + res = FALSE; + break; + case GST_EVENT_QOS: + /* we can't really (yet) do QoS */ + res = FALSE; + break; + case GST_EVENT_NAVIGATION: + /* no navigation either... */ + res = FALSE; + break; + default: + res = gst_pad_push_event (dvdemux->sinkpad, event); + event = NULL; + break; + } + if (event) + gst_event_unref (event); + + gst_object_unref (dvdemux); + + return res; +} + +/* does not take ownership of buffer */ +static GstFlowReturn +gst_dvdemux_demux_audio (GstDVDemux * dvdemux, GstBuffer * buffer, + guint64 duration) +{ + gint num_samples; + GstFlowReturn ret; + const guint8 *data; + + data = GST_BUFFER_DATA (buffer); + + dv_decode_full_audio (dvdemux->decoder, data, dvdemux->audio_buffers); + + if (G_LIKELY ((num_samples = dv_get_num_samples (dvdemux->decoder)) > 0)) { + gint16 *a_ptr; + gint i, j; + GstBuffer *outbuf; + gint frequency, channels; + + if (G_UNLIKELY (dvdemux->audiosrcpad == NULL)) + dvdemux->audiosrcpad = gst_dvdemux_add_pad (dvdemux, &audio_src_temp); + + /* get initial format or check if format changed */ + frequency = dv_get_frequency (dvdemux->decoder); + channels = dv_get_num_channels (dvdemux->decoder); + + if (G_UNLIKELY ((frequency != dvdemux->frequency) + || (channels != dvdemux->channels))) { + GstCaps *caps; + + dvdemux->frequency = frequency; + dvdemux->channels = channels; + + /* and set new caps */ + caps = gst_caps_new_simple ("audio/x-raw-int", + "rate", G_TYPE_INT, frequency, + "depth", G_TYPE_INT, 16, + "width", G_TYPE_INT, 16, + "signed", G_TYPE_BOOLEAN, TRUE, + "channels", G_TYPE_INT, channels, + "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL); + gst_pad_set_caps (dvdemux->audiosrcpad, caps); + gst_caps_unref (caps); + } + + outbuf = gst_buffer_new_and_alloc (num_samples * + sizeof (gint16) * dvdemux->channels); + + a_ptr = (gint16 *) GST_BUFFER_DATA (outbuf); + + for (i = 0; i < num_samples; i++) { + for (j = 0; j < dvdemux->channels; j++) { + *(a_ptr++) = dvdemux->audio_buffers[j][i]; + } + } + + GST_DEBUG ("pushing audio %" GST_TIME_FORMAT, + GST_TIME_ARGS (dvdemux->time_segment.last_stop)); + + GST_BUFFER_TIMESTAMP (outbuf) = dvdemux->time_segment.last_stop; + GST_BUFFER_DURATION (outbuf) = duration; + GST_BUFFER_OFFSET (outbuf) = dvdemux->audio_offset; + dvdemux->audio_offset += num_samples; + GST_BUFFER_OFFSET_END (outbuf) = dvdemux->audio_offset; + + if (dvdemux->new_media) + GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT); + gst_buffer_set_caps (outbuf, GST_PAD_CAPS (dvdemux->audiosrcpad)); + + ret = gst_pad_push (dvdemux->audiosrcpad, outbuf); + } else { + /* no samples */ + ret = GST_FLOW_OK; + } + + return ret; +} + +/* takes ownership of buffer */ +static GstFlowReturn +gst_dvdemux_demux_video (GstDVDemux * dvdemux, GstBuffer * buffer, + guint64 duration) +{ + GstBuffer *outbuf; + gint height; + gboolean wide; + GstFlowReturn ret = GST_FLOW_OK; + + if (G_UNLIKELY (dvdemux->videosrcpad == NULL)) + dvdemux->videosrcpad = gst_dvdemux_add_pad (dvdemux, &video_src_temp); + + /* get params */ + /* framerate is already up-to-date */ + height = dvdemux->decoder->height; + wide = dv_format_wide (dvdemux->decoder); + + /* see if anything changed */ + if (G_UNLIKELY ((dvdemux->height != height) || dvdemux->wide != wide)) { + GstCaps *caps; + gint par_x, par_y; + + dvdemux->height = height; + dvdemux->wide = wide; + + if (dvdemux->decoder->system == e_dv_system_625_50) { + if (wide) { + par_x = PAL_WIDE_PAR_X; + par_y = PAL_WIDE_PAR_Y; + } else { + par_x = PAL_NORMAL_PAR_X; + par_y = PAL_NORMAL_PAR_Y; + } + } else { + if (wide) { + par_x = NTSC_WIDE_PAR_X; + par_y = NTSC_WIDE_PAR_Y; + } else { + par_x = NTSC_NORMAL_PAR_X; + par_y = NTSC_NORMAL_PAR_Y; + } + } + + caps = gst_caps_new_simple ("video/x-dv", + "systemstream", G_TYPE_BOOLEAN, FALSE, + "width", G_TYPE_INT, 720, + "height", G_TYPE_INT, height, + "framerate", GST_TYPE_FRACTION, dvdemux->framerate_numerator, + dvdemux->framerate_denominator, + "pixel-aspect-ratio", GST_TYPE_FRACTION, par_x, par_y, NULL); + gst_pad_set_caps (dvdemux->videosrcpad, caps); + gst_caps_unref (caps); + } + + /* takes ownership of buffer here, we just need to modify + * the metadata. */ + outbuf = gst_buffer_make_metadata_writable (buffer); + + GST_BUFFER_TIMESTAMP (outbuf) = dvdemux->time_segment.last_stop; + GST_BUFFER_OFFSET (outbuf) = dvdemux->video_offset; + GST_BUFFER_OFFSET_END (outbuf) = dvdemux->video_offset + 1; + GST_BUFFER_DURATION (outbuf) = duration; + + if (dvdemux->new_media) + GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT); + gst_buffer_set_caps (outbuf, GST_PAD_CAPS (dvdemux->videosrcpad)); + + GST_DEBUG ("pushing video %" GST_TIME_FORMAT, + GST_TIME_ARGS (dvdemux->time_segment.last_stop)); + + ret = gst_pad_push (dvdemux->videosrcpad, outbuf); + + dvdemux->video_offset++; + + return ret; +} + +static int +get_ssyb_offset (int dif, int ssyb) +{ + int offset; + + offset = dif * 12000; /* to dif */ + offset += 80 * (1 + (ssyb / 6)); /* to subcode pack */ + offset += 3; /* past header */ + offset += 8 * (ssyb % 6); /* to ssyb */ + + return offset; +} + +static gboolean +gst_dvdemux_get_timecode (GstDVDemux * dvdemux, GstBuffer * buffer, + GstSMPTETimeCode * timecode) +{ + guint8 *data = GST_BUFFER_DATA (buffer); + int offset; + int dif; + int n_difs = dvdemux->decoder->num_dif_seqs; + + for (dif = 0; dif < n_difs; dif++) { + offset = get_ssyb_offset (dif, 3); + if (data[offset + 3] == 0x13) { + timecode->frames = ((data[offset + 4] >> 4) & 0x3) * 10 + + (data[offset + 4] & 0xf); + timecode->seconds = ((data[offset + 5] >> 4) & 0x3) * 10 + + (data[offset + 5] & 0xf); + timecode->minutes = ((data[offset + 6] >> 4) & 0x3) * 10 + + (data[offset + 6] & 0xf); + timecode->hours = ((data[offset + 7] >> 4) & 0x3) * 10 + + (data[offset + 7] & 0xf); + GST_DEBUG ("got timecode %" GST_SMPTE_TIME_CODE_FORMAT, + GST_SMPTE_TIME_CODE_ARGS (timecode)); + return TRUE; + } + } + + return FALSE; +} + +static gboolean +gst_dvdemux_is_new_media (GstDVDemux * dvdemux, GstBuffer * buffer) +{ + guint8 *data = GST_BUFFER_DATA (buffer); + int aaux_offset; + int dif; + int n_difs; + + n_difs = dvdemux->decoder->num_dif_seqs; + + for (dif = 0; dif < n_difs; dif++) { + if (dif & 1) { + aaux_offset = (dif * 12000) + (6 + 16 * 1) * 80 + 3; + } else { + aaux_offset = (dif * 12000) + (6 + 16 * 4) * 80 + 3; + } + if (data[aaux_offset + 0] == 0x51) { + if ((data[aaux_offset + 2] & 0x80) == 0) + return TRUE; + } + } + + return FALSE; +} + +/* takes ownership of buffer */ +static GstFlowReturn +gst_dvdemux_demux_frame (GstDVDemux * dvdemux, GstBuffer * buffer) +{ + GstClockTime next_ts; + GstFlowReturn aret, vret, ret; + guint8 *data; + guint64 duration; + GstSMPTETimeCode timecode; + int frame_number; + + if (G_UNLIKELY (dvdemux->need_segment)) { + GstEvent *event; + GstFormat format; + + /* convert to time and store as start/end_timestamp */ + format = GST_FORMAT_TIME; + if (!(gst_dvdemux_convert_sink_pair (dvdemux, + GST_FORMAT_BYTES, dvdemux->byte_segment.start, + dvdemux->byte_segment.stop, format, + &dvdemux->time_segment.start, &dvdemux->time_segment.stop))) + goto segment_error; + + dvdemux->time_segment.rate = dvdemux->byte_segment.rate; + dvdemux->time_segment.abs_rate = dvdemux->byte_segment.abs_rate; + dvdemux->time_segment.last_stop = dvdemux->time_segment.start; + + /* calculate current frame number */ + format = GST_FORMAT_DEFAULT; + if (!(gst_dvdemux_src_convert (dvdemux, dvdemux->videosrcpad, + GST_FORMAT_TIME, dvdemux->time_segment.start, + &format, &dvdemux->frame_offset))) + goto segment_error; + + GST_DEBUG_OBJECT (dvdemux, "sending segment start: %" GST_TIME_FORMAT + ", stop: %" GST_TIME_FORMAT ", time: %" GST_TIME_FORMAT, + GST_TIME_ARGS (dvdemux->time_segment.start), + GST_TIME_ARGS (dvdemux->time_segment.stop), + GST_TIME_ARGS (dvdemux->time_segment.start)); + + event = gst_event_new_new_segment (FALSE, dvdemux->byte_segment.rate, + GST_FORMAT_TIME, dvdemux->time_segment.start, + dvdemux->time_segment.stop, dvdemux->time_segment.start); + gst_dvdemux_push_event (dvdemux, event); + + dvdemux->need_segment = FALSE; + } + + gst_dvdemux_get_timecode (dvdemux, buffer, &timecode); + gst_smpte_time_code_get_frame_number ( + (dvdemux->decoder->system == e_dv_system_625_50) ? + GST_SMPTE_TIME_CODE_SYSTEM_25 : GST_SMPTE_TIME_CODE_SYSTEM_30, + &frame_number, &timecode); + + next_ts = gst_util_uint64_scale_int ( + (dvdemux->frame_offset + 1) * GST_SECOND, + dvdemux->framerate_denominator, dvdemux->framerate_numerator); + duration = next_ts - dvdemux->time_segment.last_stop; + + data = GST_BUFFER_DATA (buffer); + + dv_parse_packs (dvdemux->decoder, data); + dvdemux->new_media = FALSE; + if (gst_dvdemux_is_new_media (dvdemux, buffer) && + dvdemux->frames_since_new_media > 2) { + dvdemux->new_media = TRUE; + dvdemux->frames_since_new_media = 0; + } + dvdemux->frames_since_new_media++; + + /* does not take ownership of buffer */ + aret = ret = gst_dvdemux_demux_audio (dvdemux, buffer, duration); + if (G_UNLIKELY (ret != GST_FLOW_OK && ret != GST_FLOW_NOT_LINKED)) { + gst_buffer_unref (buffer); + goto done; + } + + /* takes ownership of buffer */ + vret = ret = gst_dvdemux_demux_video (dvdemux, buffer, duration); + if (G_UNLIKELY (ret != GST_FLOW_OK && ret != GST_FLOW_NOT_LINKED)) + goto done; + + /* if both are not linked, we stop */ + if (G_UNLIKELY (aret == GST_FLOW_NOT_LINKED && vret == GST_FLOW_NOT_LINKED)) { + ret = GST_FLOW_NOT_LINKED; + goto done; + } + + gst_segment_set_last_stop (&dvdemux->time_segment, GST_FORMAT_TIME, next_ts); + dvdemux->frame_offset++; + + /* check for the end of the segment */ + if (dvdemux->time_segment.stop != -1 && next_ts > dvdemux->time_segment.stop) + ret = GST_FLOW_UNEXPECTED; + else + ret = GST_FLOW_OK; + +done: + return ret; + + /* ERRORS */ +segment_error: + { + GST_DEBUG ("error generating new_segment event"); + gst_buffer_unref (buffer); + return GST_FLOW_ERROR; + } +} + +/* flush any remaining data in the adapter, used in chain based scheduling mode */ +static GstFlowReturn +gst_dvdemux_flush (GstDVDemux * dvdemux) +{ + GstFlowReturn ret = GST_FLOW_OK; + + while (gst_adapter_available (dvdemux->adapter) >= dvdemux->frame_len) { + const guint8 *data; + gint length; + + /* get the accumulated bytes */ + data = gst_adapter_peek (dvdemux->adapter, dvdemux->frame_len); + + /* parse header to know the length and other params */ + if (G_UNLIKELY (dv_parse_header (dvdemux->decoder, data) < 0)) + goto parse_header_error; + + /* after parsing the header we know the length of the data */ + length = dvdemux->frame_len = dvdemux->decoder->frame_size; + if (dvdemux->decoder->system == e_dv_system_625_50) { + dvdemux->framerate_numerator = PAL_FRAMERATE_NUMERATOR; + dvdemux->framerate_denominator = PAL_FRAMERATE_DENOMINATOR; + } else { + dvdemux->framerate_numerator = NTSC_FRAMERATE_NUMERATOR; + dvdemux->framerate_denominator = NTSC_FRAMERATE_DENOMINATOR; + } + g_atomic_int_set (&dvdemux->found_header, 1); + + /* let demux_video set the height, it needs to detect when things change so + * it can reset caps */ + + /* if we still have enough for a frame, start decoding */ + if (G_LIKELY (gst_adapter_available (dvdemux->adapter) >= length)) { + GstBuffer *buffer; + + data = gst_adapter_take (dvdemux->adapter, length); + + /* create buffer for the remainder of the code */ + buffer = gst_buffer_new (); + GST_BUFFER_DATA (buffer) = (guint8 *) data; + GST_BUFFER_SIZE (buffer) = length; + GST_BUFFER_MALLOCDATA (buffer) = (guint8 *) data; + + /* and decode the buffer, takes ownership */ + ret = gst_dvdemux_demux_frame (dvdemux, buffer); + if (G_UNLIKELY (ret != GST_FLOW_OK)) + goto done; + } + } +done: + return ret; + + /* ERRORS */ +parse_header_error: + { + GST_ELEMENT_ERROR (dvdemux, STREAM, DECODE, + (NULL), ("Error parsing DV header")); + return GST_FLOW_ERROR; + } +} + +/* streaming operation: + * + * accumulate data until we have a frame, then decode. + */ +static GstFlowReturn +gst_dvdemux_chain (GstPad * pad, GstBuffer * buffer) +{ + GstDVDemux *dvdemux; + GstFlowReturn ret; + GstClockTime timestamp; + + dvdemux = GST_DVDEMUX (gst_pad_get_parent (pad)); + + /* a discontinuity in the stream, we need to get rid of + * accumulated data in the adapter and assume a new frame + * starts after the discontinuity */ + if (G_UNLIKELY (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT))) + gst_adapter_clear (dvdemux->adapter); + + /* a timestamp always should be respected */ + timestamp = GST_BUFFER_TIMESTAMP (buffer); + if (GST_CLOCK_TIME_IS_VALID (timestamp)) { + gst_segment_set_last_stop (&dvdemux->time_segment, GST_FORMAT_TIME, + timestamp); + /* FIXME, adjust frame_offset and other counters */ + } + + gst_adapter_push (dvdemux->adapter, buffer); + + /* Apparently dv_parse_header can read from the body of the frame + * too, so it needs more than header_size bytes. Wacky! + */ + if (G_UNLIKELY (dvdemux->frame_len == -1)) { + /* if we don't know the length of a frame, we assume it is + * the NTSC_BUFFER length, as this is enough to figure out + * if this is PAL or NTSC */ + dvdemux->frame_len = NTSC_BUFFER; + } + + /* and try to flush pending frames */ + ret = gst_dvdemux_flush (dvdemux); + + gst_object_unref (dvdemux); + + return ret; +} + +/* pull based operation. + * + * Read header first to figure out the frame size. Then read + * and decode full frames. + */ +static void +gst_dvdemux_loop (GstPad * pad) +{ + GstFlowReturn ret; + GstDVDemux *dvdemux; + GstBuffer *buffer = NULL; + const guint8 *data; + + dvdemux = GST_DVDEMUX (gst_pad_get_parent (pad)); + + if (G_UNLIKELY (g_atomic_int_get (&dvdemux->found_header) == 0)) { + GST_DEBUG_OBJECT (dvdemux, "pulling first buffer"); + /* pull in NTSC sized buffer to figure out the frame + * length */ + ret = gst_pad_pull_range (dvdemux->sinkpad, + dvdemux->byte_segment.last_stop, NTSC_BUFFER, &buffer); + if (G_UNLIKELY (ret != GST_FLOW_OK)) + goto pause; + + /* check buffer size, don't want to read small buffers */ + if (G_UNLIKELY (GST_BUFFER_SIZE (buffer) < NTSC_BUFFER)) + goto small_buffer; + + data = GST_BUFFER_DATA (buffer); + + /* parse header to know the length and other params */ + if (G_UNLIKELY (dv_parse_header (dvdemux->decoder, data) < 0)) + goto parse_header_error; + + /* after parsing the header we know the length of the data */ + dvdemux->frame_len = dvdemux->decoder->frame_size; + if (dvdemux->decoder->system == e_dv_system_625_50) { + dvdemux->framerate_numerator = PAL_FRAMERATE_NUMERATOR; + dvdemux->framerate_denominator = PAL_FRAMERATE_DENOMINATOR; + } else { + dvdemux->framerate_numerator = NTSC_FRAMERATE_NUMERATOR; + dvdemux->framerate_denominator = NTSC_FRAMERATE_DENOMINATOR; + } + dvdemux->need_segment = TRUE; + + /* see if we need to read a larger part */ + if (dvdemux->frame_len != NTSC_BUFFER) { + gst_buffer_unref (buffer); + buffer = NULL; + } + + { + GstEvent *event; + + /* setting header and prrforming the seek must be atomic */ + GST_OBJECT_LOCK (dvdemux); + /* got header now */ + g_atomic_int_set (&dvdemux->found_header, 1); + + /* now perform pending seek if any. */ + event = dvdemux->seek_event; + if (event) + gst_event_ref (event); + GST_OBJECT_UNLOCK (dvdemux); + + if (event) { + if (!gst_dvdemux_handle_pull_seek (dvdemux, dvdemux->videosrcpad, + event)) { + GST_ELEMENT_WARNING (dvdemux, STREAM, DECODE, (NULL), + ("Error perfoming initial seek")); + } + gst_event_unref (event); + + /* and we need to pull a new buffer in all cases. */ + if (buffer) { + gst_buffer_unref (buffer); + buffer = NULL; + } + } + } + } + + + if (G_UNLIKELY (dvdemux->pending_segment)) { + + /* now send the newsegment */ + GST_DEBUG_OBJECT (dvdemux, "Sending newsegment from"); + + gst_dvdemux_push_event (dvdemux, dvdemux->pending_segment); + dvdemux->pending_segment = NULL; + } + + if (G_LIKELY (buffer == NULL)) { + GST_DEBUG_OBJECT (dvdemux, "pulling buffer at offset %" G_GINT64_FORMAT, + dvdemux->byte_segment.last_stop); + + ret = gst_pad_pull_range (dvdemux->sinkpad, + dvdemux->byte_segment.last_stop, dvdemux->frame_len, &buffer); + if (ret != GST_FLOW_OK) + goto pause; + + /* check buffer size, don't want to read small buffers */ + if (GST_BUFFER_SIZE (buffer) < dvdemux->frame_len) + goto small_buffer; + } + /* and decode the buffer */ + ret = gst_dvdemux_demux_frame (dvdemux, buffer); + if (G_UNLIKELY (ret != GST_FLOW_OK)) + goto pause; + + /* and position ourselves for the next buffer */ + dvdemux->byte_segment.last_stop += dvdemux->frame_len; + +done: + gst_object_unref (dvdemux); + + return; + + /* ERRORS */ +parse_header_error: + { + GST_ELEMENT_ERROR (dvdemux, STREAM, DECODE, + (NULL), ("Error parsing DV header")); + gst_buffer_unref (buffer); + dvdemux->running = FALSE; + gst_pad_pause_task (dvdemux->sinkpad); + gst_dvdemux_push_event (dvdemux, gst_event_new_eos ()); + goto done; + } +small_buffer: + { + GST_ELEMENT_ERROR (dvdemux, STREAM, DECODE, + (NULL), ("Error reading buffer")); + gst_buffer_unref (buffer); + dvdemux->running = FALSE; + gst_pad_pause_task (dvdemux->sinkpad); + gst_dvdemux_push_event (dvdemux, gst_event_new_eos ()); + goto done; + } +pause: + { + GST_INFO_OBJECT (dvdemux, "pausing task, %s", gst_flow_get_name (ret)); + dvdemux->running = FALSE; + gst_pad_pause_task (dvdemux->sinkpad); + if (ret == GST_FLOW_UNEXPECTED) { + GST_LOG_OBJECT (dvdemux, "got eos"); + /* perform EOS logic */ + if (dvdemux->time_segment.flags & GST_SEEK_FLAG_SEGMENT) { + gst_element_post_message (GST_ELEMENT (dvdemux), + gst_message_new_segment_done (GST_OBJECT_CAST (dvdemux), + dvdemux->time_segment.format, dvdemux->time_segment.last_stop)); + } else { + gst_dvdemux_push_event (dvdemux, gst_event_new_eos ()); + } + } else if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_UNEXPECTED) { + /* for fatal errors or not-linked we post an error message */ + GST_ELEMENT_ERROR (dvdemux, STREAM, FAILED, + (NULL), ("streaming stopped, reason %s", gst_flow_get_name (ret))); + gst_dvdemux_push_event (dvdemux, gst_event_new_eos ()); + } + goto done; + } +} + +static gboolean +gst_dvdemux_sink_activate_push (GstPad * sinkpad, gboolean active) +{ + GstDVDemux *demux = GST_DVDEMUX (gst_pad_get_parent (sinkpad)); + + if (active) { + demux->seek_handler = gst_dvdemux_handle_push_seek; + } else { + demux->seek_handler = NULL; + } + gst_object_unref (demux); + + return TRUE; +} + +static gboolean +gst_dvdemux_sink_activate_pull (GstPad * sinkpad, gboolean active) +{ + GstDVDemux *demux = GST_DVDEMUX (gst_pad_get_parent (sinkpad)); + + if (active) { + demux->running = TRUE; + demux->seek_handler = gst_dvdemux_handle_pull_seek; + gst_pad_start_task (sinkpad, (GstTaskFunction) gst_dvdemux_loop, sinkpad); + } else { + demux->seek_handler = NULL; + gst_pad_stop_task (sinkpad); + demux->running = FALSE; + } + + gst_object_unref (demux); + + return TRUE; +}; + +/* decide on push or pull based scheduling */ +static gboolean +gst_dvdemux_sink_activate (GstPad * sinkpad) +{ + gboolean ret; + + if (gst_pad_check_pull_range (sinkpad)) + ret = gst_pad_activate_pull (sinkpad, TRUE); + else + ret = gst_pad_activate_push (sinkpad, TRUE); + + return ret; +}; + +static GstStateChangeReturn +gst_dvdemux_change_state (GstElement * element, GstStateChange transition) +{ + GstDVDemux *dvdemux = GST_DVDEMUX (element); + GstStateChangeReturn ret; + + switch (transition) { + case GST_STATE_CHANGE_NULL_TO_READY: + break; + case GST_STATE_CHANGE_READY_TO_PAUSED: + dvdemux->decoder = dv_decoder_new (0, FALSE, FALSE); + dv_set_error_log (dvdemux->decoder, NULL); + gst_dvdemux_reset (dvdemux); + break; + case GST_STATE_CHANGE_PAUSED_TO_PLAYING: + break; + default: + break; + } + + ret = parent_class->change_state (element, transition); + + switch (transition) { + case GST_STATE_CHANGE_PLAYING_TO_PAUSED: + break; + case GST_STATE_CHANGE_PAUSED_TO_READY: + gst_adapter_clear (dvdemux->adapter); + dv_decoder_free (dvdemux->decoder); + dvdemux->decoder = NULL; + + gst_dvdemux_remove_pads (dvdemux); + break; + case GST_STATE_CHANGE_READY_TO_NULL: + { + GstEvent **event_p; + + event_p = &dvdemux->seek_event; + gst_event_replace (event_p, NULL); + if (dvdemux->pending_segment) + gst_event_unref (dvdemux->pending_segment); + dvdemux->pending_segment = NULL; + break; + } + default: + break; + } + return ret; +} diff --git a/ext/dv/gstdvdemux.h b/ext/dv/gstdvdemux.h new file mode 100644 index 0000000..9a4173d --- /dev/null +++ b/ext/dv/gstdvdemux.h @@ -0,0 +1,98 @@ +/* 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. + */ + + +#ifndef __GST_DVDEMUX_H__ +#define __GST_DVDEMUX_H__ + +#include <gst/gst.h> +#include <libdv/dv.h> +#include <gst/base/gstadapter.h> + +G_BEGIN_DECLS + +#define GST_TYPE_DVDEMUX \ + (gst_dvdemux_get_type()) +#define GST_DVDEMUX(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DVDEMUX,GstDVDemux)) +#define GST_DVDEMUX_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DVDEMUX,GstDVDemuxClass)) +#define GST_IS_DVDEMUX(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DVDEMUX)) +#define GST_IS_DVDEMUX_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DVDEMUX)) + + +typedef struct _GstDVDemux GstDVDemux; +typedef struct _GstDVDemuxClass GstDVDemuxClass; + +typedef gboolean (*GstDVDemuxSeekHandler) (GstDVDemux *demux, GstPad * pad, GstEvent * event); + + +struct _GstDVDemux { + GstElement element; + + GstPad *sinkpad; + GstPad *videosrcpad; + GstPad *audiosrcpad; + + dv_decoder_t *decoder; + + GstAdapter *adapter; + gint frame_len; + + /* video params */ + gint framerate_numerator; + gint framerate_denominator; + gint height; + gboolean wide; + /* audio params */ + gint frequency; + gint channels; + + gint framecount; + + gint64 frame_offset; + gint64 audio_offset; + gint64 video_offset; + + GstDVDemuxSeekHandler seek_handler; + GstSegment byte_segment; + GstSegment time_segment; + gboolean running; + gboolean need_segment; + gboolean new_media; + int frames_since_new_media; + + gint found_header; /* ATOMIC */ + GstEvent *seek_event; + GstEvent *pending_segment; + + gint16 *audio_buffers[4]; +}; + +struct _GstDVDemuxClass { + GstElementClass parent_class; +}; + +GType gst_dvdemux_get_type (void); + +G_END_DECLS + +#endif /* __GST_DVDEMUX_H__ */ diff --git a/ext/dv/gstsmptetimecode.c b/ext/dv/gstsmptetimecode.c new file mode 100644 index 0000000..40a36d3 --- /dev/null +++ b/ext/dv/gstsmptetimecode.c @@ -0,0 +1,240 @@ +/* GStreamer + * Copyright (C) 2009 David A. Schleef <ds@schleef.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Utility functions for handing SMPTE Time Codes, as described in + * SMPTE Standard 12M-1999. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gstsmptetimecode.h" + +#define NTSC_FRAMES_PER_10_MINS (10*60*30 - 10*2 + 2) +#define NTSC_FRAMES_PER_HOUR (6*NTSC_FRAMES_PER_10_MINS) + +/** + * gst_smpte_time_code_from_frame_number: + * @system: SMPTE Time Code system + * @time_code: pointer to time code structure + * @frame_number: integer frame number + * + * Converts a frame number to a time code. + * + * Returns: TRUE if the conversion was successful + */ +gboolean +gst_smpte_time_code_from_frame_number (GstSMPTETimeCodeSystem system, + GstSMPTETimeCode * time_code, int frame_number) +{ + int ten_mins; + int n; + + g_return_val_if_fail (time_code != NULL, FALSE); + g_return_val_if_fail (GST_SMPTE_TIME_CODE_SYSTEM_IS_VALID (system), FALSE); + + time_code->hours = 99; + time_code->minutes = 99; + time_code->seconds = 99; + time_code->frames = 99; + + if (frame_number < 0) + return FALSE; + + switch (system) { + case GST_SMPTE_TIME_CODE_SYSTEM_30: + if (frame_number >= 24 * NTSC_FRAMES_PER_HOUR) + return FALSE; + + ten_mins = frame_number / NTSC_FRAMES_PER_10_MINS; + frame_number -= ten_mins * NTSC_FRAMES_PER_10_MINS; + + time_code->hours = ten_mins / 6; + time_code->minutes = 10 * (ten_mins % 6); + + if (frame_number < 2) { + /* treat the first two frames of each ten minutes specially */ + time_code->seconds = 0; + time_code->frames = frame_number; + } else { + n = (frame_number - 2) / (60 * 30 - 2); + time_code->minutes += n; + frame_number -= n * (60 * 30 - 2); + + time_code->seconds = frame_number / 30; + time_code->frames = frame_number % 30; + } + break; + case GST_SMPTE_TIME_CODE_SYSTEM_25: + if (frame_number >= 24 * 60 * 60 * 25) + return FALSE; + + time_code->frames = frame_number % 25; + frame_number /= 25; + time_code->seconds = frame_number % 60; + frame_number /= 60; + time_code->minutes = frame_number % 60; + frame_number /= 60; + time_code->hours = frame_number; + break; + case GST_SMPTE_TIME_CODE_SYSTEM_24: + if (frame_number >= 24 * 60 * 60 * 24) + return FALSE; + + time_code->frames = frame_number % 24; + frame_number /= 24; + time_code->seconds = frame_number % 60; + frame_number /= 60; + time_code->minutes = frame_number % 60; + frame_number /= 60; + time_code->hours = frame_number; + break; + } + + return TRUE; +} + +/** + * gst_smpte_time_code_is_valid: + * @system: SMPTE Time Code system + * @time_code: pointer to time code structure + * + * Checks that the time code represents a valid time code. + * + * Returns: TRUE if the time code is valid + */ +gboolean +gst_smpte_time_code_is_valid (GstSMPTETimeCodeSystem system, + GstSMPTETimeCode * time_code) +{ + g_return_val_if_fail (time_code != NULL, FALSE); + g_return_val_if_fail (GST_SMPTE_TIME_CODE_SYSTEM_IS_VALID (system), FALSE); + + if (time_code->hours < 0 || time_code->hours >= 24) + return FALSE; + if (time_code->minutes < 0 || time_code->minutes >= 60) + return FALSE; + if (time_code->seconds < 0 || time_code->seconds >= 60) + return FALSE; + if (time_code->frames < 0) + return FALSE; + + switch (system) { + case GST_SMPTE_TIME_CODE_SYSTEM_30: + if (time_code->frames >= 30) + return FALSE; + if (time_code->frames >= 2 || time_code->seconds > 0) + return TRUE; + if (time_code->minutes % 10 != 0) + return FALSE; + break; + case GST_SMPTE_TIME_CODE_SYSTEM_25: + if (time_code->frames >= 25) + return FALSE; + break; + case GST_SMPTE_TIME_CODE_SYSTEM_24: + if (time_code->frames >= 24) + return FALSE; + break; + } + return TRUE; +} + +/** + * gst_smpte_time_get_frame_number: + * @system: SMPTE Time Code system + * @frame_number: pointer to frame number + * @time_code: pointer to time code structure + * + * Converts the time code structure to a linear frame number. + * + * Returns: TRUE if the time code could be converted + */ +gboolean +gst_smpte_time_code_get_frame_number (GstSMPTETimeCodeSystem system, + int *frame_number, GstSMPTETimeCode * time_code) +{ + int frame = 0; + + g_return_val_if_fail (GST_SMPTE_TIME_CODE_SYSTEM_IS_VALID (system), FALSE); + g_return_val_if_fail (time_code != NULL, FALSE); + + if (!gst_smpte_time_code_is_valid (system, time_code)) { + return FALSE; + } + + switch (system) { + case GST_SMPTE_TIME_CODE_SYSTEM_30: + frame = time_code->hours * NTSC_FRAMES_PER_HOUR; + frame += (time_code->minutes / 10) * NTSC_FRAMES_PER_10_MINS; + frame += (time_code->minutes % 10) * (30 * 60 - 2); + frame += time_code->seconds * 30; + break; + case GST_SMPTE_TIME_CODE_SYSTEM_25: + time_code->frames = + 25 * ((time_code->hours * 60 + time_code->minutes) * 60 + + time_code->seconds); + break; + case GST_SMPTE_TIME_CODE_SYSTEM_24: + time_code->frames = + 24 * ((time_code->hours * 60 + time_code->minutes) * 60 + + time_code->seconds); + break; + } + frame += time_code->frames; + + if (frame_number) { + *frame_number = frame; + } + + return TRUE; +} + +/** + * gst_smpte_time_get_timestamp: + * @system: SMPTE Time Code system + * @time_code: pointer to time code structure + * + * Converts the time code structure to a timestamp. + * + * Returns: Time stamp for time code, or GST_CLOCK_TIME_NONE if time + * code is invalid. + */ +GstClockTime +gst_smpte_time_code_get_timestamp (GstSMPTETimeCodeSystem system, + GstSMPTETimeCode * time_code) +{ + int frame_number; + + g_return_val_if_fail (GST_SMPTE_TIME_CODE_SYSTEM_IS_VALID (system), + GST_CLOCK_TIME_NONE); + g_return_val_if_fail (time_code != NULL, GST_CLOCK_TIME_NONE); + + if (gst_smpte_time_code_get_frame_number (system, &frame_number, time_code)) { + static int framerate_n[3] = { 3000, 25, 24 }; + static int framerate_d[3] = { 1001, 1, 1 }; + + return gst_util_uint64_scale (frame_number, + GST_SECOND * framerate_d[system], framerate_n[system]); + } + + return GST_CLOCK_TIME_NONE; +} diff --git a/ext/dv/gstsmptetimecode.h b/ext/dv/gstsmptetimecode.h new file mode 100644 index 0000000..cdda03e --- /dev/null +++ b/ext/dv/gstsmptetimecode.h @@ -0,0 +1,70 @@ +/* GStreamer + * Copyright (C) 2009 David A. Schleef <ds@schleef.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef _GST_SMPTE_TIME_CODE_H_ +#define _GST_SMPTE_TIME_CODE_H_ + +#include <gst/gst.h> + +G_BEGIN_DECLS + +typedef struct _GstSMPTETimeCode GstSMPTETimeCode; + +/** + * GstSMPTETimeCode: + * @GST_SMPTE_TIME_CODE_SYSTEM_30: 29.97 frame per second system (NTSC) + * @GST_SMPTE_TIME_CODE_SYSTEM_25: 25 frame per second system (PAL) + * @GST_SMPTE_TIME_CODE_SYSTEM_24: 24 frame per second system + * + * Enum value representing SMPTE Time Code system. + */ +typedef enum { + GST_SMPTE_TIME_CODE_SYSTEM_30 = 0, + GST_SMPTE_TIME_CODE_SYSTEM_25, + GST_SMPTE_TIME_CODE_SYSTEM_24 +} GstSMPTETimeCodeSystem; + +struct _GstSMPTETimeCode { + int hours; + int minutes; + int seconds; + int frames; +}; + +#define GST_SMPTE_TIME_CODE_SYSTEM_IS_VALID(x) \ + ((x) >= GST_SMPTE_TIME_CODE_SYSTEM_30 && (x) <= GST_SMPTE_TIME_CODE_SYSTEM_24) + +#define GST_SMPTE_TIME_CODE_FORMAT "02d:%02d:%02d:%02d" +#define GST_SMPTE_TIME_CODE_ARGS(timecode) \ + (timecode)->hours, (timecode)->minutes, \ + (timecode)->seconds, (timecode)->frames + +gboolean gst_smpte_time_code_is_valid (GstSMPTETimeCodeSystem system, + GstSMPTETimeCode *time_code); +gboolean gst_smpte_time_code_from_frame_number (GstSMPTETimeCodeSystem system, + GstSMPTETimeCode *time_code, int frame_number); +gboolean gst_smpte_time_code_get_frame_number (GstSMPTETimeCodeSystem system, + int *frame_number, GstSMPTETimeCode *time_code); +GstClockTime gst_smpte_time_code_get_timestamp (GstSMPTETimeCodeSystem system, + GstSMPTETimeCode *time_code); + +G_END_DECLS + +#endif + diff --git a/ext/dv/smpte_test.c b/ext/dv/smpte_test.c new file mode 100644 index 0000000..f18113c --- /dev/null +++ b/ext/dv/smpte_test.c @@ -0,0 +1,81 @@ + +#include "config.h" + +#include "gstsmptetimecode.h" + +#include <glib.h> + +#define NTSC_FRAMES_PER_10_MINS (10*60*30 - 10*2 + 2) +#define NTSC_FRAMES_PER_HOUR (6*NTSC_FRAMES_PER_10_MINS) + + +int +main (int argc, char *argv[]) +{ + GstSMPTETimeCode tc; + int i; + int min; + + for (min = 0; min < 3; min++) { + g_print ("--- minute %d ---\n", min); + for (i = min * 60 * 30 - 5; i <= min * 60 * 30 + 5; i++) { + gst_smpte_time_code_from_frame_number (GST_SMPTE_TIME_CODE_SYSTEM_30, &tc, + i); + g_print ("%d %02d:%02d:%02d:%02d\n", i, tc.hours, tc.minutes, tc.seconds, + tc.frames); + } + } + + for (min = 9; min < 12; min++) { + g_print ("--- minute %d ---\n", min); + for (i = min * 60 * 30 - 5 - 18; i <= min * 60 * 30 + 5 - 18; i++) { + gst_smpte_time_code_from_frame_number (GST_SMPTE_TIME_CODE_SYSTEM_30, &tc, + i); + g_print ("%d %02d:%02d:%02d:%02d\n", i, tc.hours, tc.minutes, tc.seconds, + tc.frames); + } + } + + for (min = -1; min < 2; min++) { + int offset = NTSC_FRAMES_PER_HOUR; + + g_print ("--- minute %d ---\n", min); + for (i = offset + min * 60 * 30 - 5; i <= offset + min * 60 * 30 + 5; i++) { + gst_smpte_time_code_from_frame_number (GST_SMPTE_TIME_CODE_SYSTEM_30, &tc, + i); + g_print ("%d %02d:%02d:%02d:%02d\n", i, tc.hours, tc.minutes, tc.seconds, + tc.frames); + } + } + + for (min = 0; min < 1; min++) { + int offset = NTSC_FRAMES_PER_HOUR; + + g_print ("--- minute %d ---\n", min); + for (i = 24 * offset - 5; i <= 24 * offset + 5; i++) { + gst_smpte_time_code_from_frame_number (GST_SMPTE_TIME_CODE_SYSTEM_30, &tc, + i); + g_print ("%d %02d:%02d:%02d:%02d\n", i, tc.hours, tc.minutes, tc.seconds, + tc.frames); + } + } + + for (i = 0; i < 24 * NTSC_FRAMES_PER_HOUR; i++) { + int fn; + int ret; + + gst_smpte_time_code_from_frame_number (GST_SMPTE_TIME_CODE_SYSTEM_30, &tc, + i); + + ret = gst_smpte_time_code_get_frame_number (GST_SMPTE_TIME_CODE_SYSTEM_30, + &fn, &tc); + if (!ret) { + g_print ("bad valid at %d\n", i); + } + if (fn != i) { + g_print ("index mismatch %d != %d\n", fn, i); + } + } + + return 0; +} |