From 701608f39c59b530f6cede66ec24e9ddda8beae6 Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 12 Sep 2005 15:34:25 +0000 Subject: *** empty log message *** --- ChangeLog | 3 +- TODO | 6 +- acinclude.m4 | 1649 --------------------------------------------- src/Makefile.am | 5 + src/frame.h | 4 +- src/iso11172-1.h | 110 +++ src/iso11172-2.h | 73 ++ src/iso11172-3.h | 85 +++ src/libfame_wrapper.cc | 29 +- src/libfame_wrapper.h | 2 + src/liblame_wrapper.cc | 6 +- src/mov_encoder.cc | 69 +- src/mov_encoder.h | 14 +- src/mov_encoder_thread.cc | 51 +- src/mov_encoder_thread.h | 9 +- src/mov_encoder_writer.cc | 195 ++++-- src/mov_encoder_writer.h | 29 +- src/thread.cc | 5 + src/thread.h | 3 +- tools/MIaVAdd | 2 +- 20 files changed, 562 insertions(+), 1787 deletions(-) create mode 100644 src/iso11172-1.h create mode 100644 src/iso11172-2.h create mode 100644 src/iso11172-3.h diff --git a/ChangeLog b/ChangeLog index 91061d7..9ba686a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ Changelog for MIaV ======================================= -Juli XX 2005 - MIaV version 0.2.7 +XXXX XX 2005 - MIaV version 0.2.7 --------------------------------------- New Features: - Config file parser now reports line numbers when errors occure. @@ -16,6 +16,7 @@ New Features: - Added fullscreen view of the videofield (click it to activate/deactivate) - Added fullscreen view of the screenshots (click it to activate/deactivate) - Added about dialog. + - Added dvfile fallback, when firewire not available (For testing purposes). Bug Fixes: - Config variables can now contain numbers. diff --git a/TODO b/TODO index d91ff03..2bd2003 100644 --- a/TODO +++ b/TODO @@ -20,9 +20,6 @@ http://encyclopedia.laborlawtalk.com/YUV_4:2:0 http://www.cs.hmc.edu/qref/writing_man_pages.html http://www.schweikhardt.net/man_page_howto.html -open64 ? - - ========================================================================== TASKS (client) ========================================================================== @@ -84,6 +81,7 @@ Decoder: [x] - Make use of 2.6 kernel (through raw1394) [x] - Set flags on frame objects. [x] - Skip every second frame to save cpu (configurable) + [x] - Add dv file fallback, when firewire fails. Camera: [x] - Add initialize method (constructor should do nothing). @@ -99,7 +97,7 @@ Player: ImgEncoder: [x] - Make libjpeg calls work again. - [x] - Save jpeg files in special cpr hierake 'encrypted'! + [x] - Save jpeg files in special cpr hieracy 'encrypted'! [ ] - Clean up code! [ ] - Make save method configurable in options file. diff --git a/acinclude.m4 b/acinclude.m4 index 694ec25..d5ef61f 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,1652 +1,3 @@ -# as.m4 -# Figure out how to run the assembler. - -# AM_PROG_AS -AC_DEFUN([AM_PROG_AS], -[# By default we simply use the C compiler to build assembly code. -AC_REQUIRE([AC_PROG_CC]) -: ${AS='$(CC)'} -# Set ASFLAGS if not already set. -: ${ASFLAGS='$(CFLAGS)'} -AC_SUBST(AS) -AC_SUBST(ASFLAGS) -]) - -dnl AC_GCC_VERSION -dnl check for compiler version -dnl sets COMPILER_VERSION and GCC_VERSION - -AC_DEFUN([AC_CC_VERSION], -[ - AC_MSG_CHECKING([C compiler version]) - COMPILER_VERSION=`$CC -v 2>&1 | grep version` - if test -z "`echo $COMPILER_VERSION | grep gcc`" ; then - GCC_VERSION=unknown - AC_MSG_RESULT([unknown]) - else - dnl Ok, how to turn $3 into the real $3 - GCC_VERSION=`echo $COMPILER_VERSION | sed -e 's/.*\ .*\ \(.*\)\ .*/\1/'` - echo gcc $GCC_VERSION - fi -]) - -dnl AC_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS]) -dnl check if $CC supports a given set of cflags - -AC_DEFUN([AC_TRY_CFLAGS], -[ - AC_MSG_CHECKING([if $CC supports $1 flag(s)]) - ac_save_CFLAGS=$CFLAGS - CFLAGS=$1 - AC_TRY_COMPILE([], [], [ ac_cv_try_cflags_ok=yes ],[ ac_cv_try_cflags_ok=no ]) - CFLAGS=$ac_save_CFLAGS - AC_MSG_RESULT([$ac_cv_try_cflags_ok]) - if test x$ac_cv_try_cflags_ok = xyes; then - ifelse([$2], [], [:], [$2]) - else - ifelse([$3], [], [:], [$3]) - fi -]) - -dnl AC_TRY_CXXFLAGS (CXXFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS]) -dnl check if $CXX supports a given set of cxxflags - -AC_DEFUN([AC_TRY_CXXFLAGS], -[ - AC_MSG_CHECKING([if $CXX supports $1 flag(s)]) - AC_LANG_SAVE - AC_LANG_CPLUSPLUS - ac_save_CXXFLAGS=$CXXFLAGS - CXXFLAGS=$1 - AC_TRY_COMPILE([], [], [ ac_cv_try_cxxflags_ok=yes ],[ ac_cv_try_cxxflags_ok=no ]) - CXXFLAGS=$ac_save_CXXFLAGS - AC_MSG_RESULT([$ac_cv_try_cxxflags_ok]) - AC_LANG_RESTORE - if test x$ac_cv_try_cxxflags_ok = xyes; then - ifelse([$2], [], [:], [$2]) - else - ifelse([$3], [], [:], [$3]) - fi -]) - -dnl AC_CHECK_GNU_EXTENSIONS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) - -AC_DEFUN([AC_CHECK_GNU_EXTENSIONS], -[ - AC_CACHE_CHECK([if you need GNU extensions], ac_cv_gnu_extensions, - [ AC_TRY_COMPILE([#include ], [ -#ifndef __GNU_LIBRARY__ -gnuneeded -#endif - ], [ ac_cv_gnu_extensions=yes ], [ ac_cv_gnu_extensions=no ]) - ]) - if test x$ac_cv_gnu_extensions = xyes; then - ifelse([$1], [], [:], [$1]) - dnl AC_DEFINE_UNQUOTED(_GNU_SOURCE) - else - ifelse([$2], [], [:], [$2]) - fi -]) - -dnl -dnl AC_CHECK_GNU_VECTOR([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl -AC_DEFUN([AC_CHECK_GNU_VECTOR], -[ - AC_CACHE_CHECK([if gcc supports vector builtins], ac_cv_gnu_builtins, - [ AC_TRY_COMPILE([#include ], [ -int main(void) { -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2) -return 0; -#else -#error no vector builtins -#endif -} - ], [ ac_cv_gnu_builtins=yes ], [ ac_cv_gnu_builtins=no ]) - ]) - if test x$ac_cv_gnu_builtins = xyes; then - ifelse([$1], [], [:], [$1]) - else - ifelse([$2], [], [:], [$2]) - fi -]) -# Configure paths for DivX - -dnl Usage: -dnl AM_PATH_DIVX([ACTION-IF-FOUND-DECORE [, ACTION-IF-NOT-FOUND-DECORE -dnl [, ACTION-IF-FOUND-ENCORE, [ACTION-IF-NOT-FOUND-DECORE]]]] ) -dnl Test for libdivxdecore, libdivxencore, and define XVID_CFLAGS and XVID_LIBS -dnl -AC_DEFUN([AM_PATH_DIVX], -[ - AC_ARG_WITH(divx4_prefix, [ --with-divx4-prefix=PFX where divx4linux is installed. (optional)], - [], with_divx4_prefix=) - - have_divx_decore=no - have_divx_encore=no - DIVX_CFLAGS="" - DIVX_LIBS="" - save_CPPFLAGS=$CPPFLAGS - if test -n "$with_divx4_prefix" ; then - dnl user has specified extra path for DivX4 instalation - CPPFLAGS="-I$with_divx4_prefix $CPPFLAGS" - AC_CHECK_HEADER(include/decore.h, - DIVX_CFLAGS="-I$with_divx4_prefix/include" - DIVX_LIBS="-L$with_divx4_prefix/lib" - have_divx_decore=yes) - if test x$have_divx_decore = xno ; then - CPPFLAGS="-I$with_divx4_prefix $CPPFLAGS" - AC_CHECK_HEADER(decore.h, - DIVX_CFLAGS="-I$with_divx4_prefix" - DIVX_LIBS="-L$with_divx4_prefix" - have_divx_decore=yes) - fi - else - AC_CHECK_HEADER(decore.h, have_divx_decore=yes) - fi - - AC_CHECK_HEADER(encore2.h, have_divx_encore=yes) - CPPFLAGS=$save_CPPFLAGS - - if test x$have_divx_decore = xyes ; then - AC_CHECK_LIB(divxdecore, decore, - DIVX_LIBS="$DIVX_LIBS -ldivxdecore", - have_divx_decore=no, $DIVX_LIBS) - fi - - if test x$have_divx_encore = xyes ; then - AC_CHECK_LIB(divxencore, encore, - DIVX_LIBS="$DIVX_LIBS -ldivxencore", - have_divx_encore=no, $DIVX_LIBS) - fi - - if test x$have_divx_decore = xyes ; then - ifelse([$1], , :, [$1]) - else - ifelse([$2], , :, [$2]) - fi - - if test x$have_divx_encore = xyes ; then - ifelse([$3], , :, [$3]) - else - ifelse([$4], , :, [$4]) - fi - - AC_SUBST(DIVX_CFLAGS) - AC_SUBST(DIVX_LIBS) -]) - -dnl -dnl slightly modified dmalloc.m4 -dnl - -AC_DEFUN([AC_WITH_DMALLOCTH], -[ -AC_ARG_WITH(dmallocth, [ --with-dmallocth use dmallocth. (see: http://www.dmalloc.com)], - [], with_dmallocth=no) -if test x$with_dmallocth = xyes ; then - AC_MSG_RESULT([enabling dmalloc thread debugging]) - AC_CHECK_HEADER(dmalloc.h, , AC_MSG_ERROR([header file 'dmalloc.h' is missing!])) - AC_DEFINE(WITH_DMALLOCTH,1, [Define if using the dmallocth debugging malloc package]) - LIBS="$LIBS -ldmallocth" - LDFLAGS="$LDFLAGS -g" -fi -]) -# Configure paths for libfaad - -dnl AM_PATH_FAAD([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libfaad, and define FAAD_CFLAGS and FAAD_LIBS -dnl -AC_DEFUN([AM_PATH_FAAD], -[ - AC_ARG_WITH(faad_prefix, [ --with-faad-prefix=PFX where FAAD is installed. (optional)], - [], with_faad_prefix="") - - AC_ARG_ENABLE(faadtest, [ --disable-faadtest do not try to compile and run a test FAAD program], - [], enable_faadtest=yes) - - FAAD_CFLAGS="" - FAAD_LIBS="" - - have_faad=no - ac_save_CPPFLAGS=$CPPFLAGS - if test -n "$with_faad_prefix" ; then - dnl user has specified extra path for FAAD instalation - CPPFLAGS="-I$with_faad_prefix $CPPFLAGS" - AC_CHECK_HEADER(faad.h, - FAAD_CFLAGS="-I$with_faad_prefix" - FAAD_LIBS="-L$with_faad_prefix" - have_faad=yes) - else - AC_CHECK_HEADER(faad.h, have_faad=yes) - fi - CPPFLAGS=$ac_save_CPPFLAGS - -dnl -dnl Now check if the installed FAAD is sufficiently new. -dnl - if test x$have_faad = xyes ; then - FAAD_LIBS="$FAAD_LIBS -lfaad -lm" - if test x$enable_faadtest = xyes ; then - AC_CACHE_CHECK([for faacDecOpen in -lfaad], - ac_cv_val_HAVE_FAAD, - [ rm -f conf.faadtest - ac_save_CFLAGS=$CFLAGS - ac_save_LIBS=$LIBS - CFLAGS="$CFLAGS $FAAD_CFLAGS" - LIBS="$LIBS $FAAD_LIBS" - AC_TRY_RUN([ -#include -#include -#include -#include - -int main () -{ - faacDecHandle h = faacDecOpen(); - system("touch conf.faadtest"); - return 0; -} ], - [ ac_cv_val_HAVE_FAAD=yes ], - [ ac_cv_val_HAVE_FAAD=no ], - [ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) - CFLAGS=$ac_save_CFLAGS - LIBS=$ac_save_LIBS]) - test x$ac_cv_val_HAVE_FAAD = xno && have_faad = xno - fi - fi - - if test x$have_faad = xyes ; then - ifelse([$1], , :, [$1]) - else - if test -n "$FAAD_LIBS" -a x$enable_faadtest = xyes -a ! -f conf.faadtest ; then - AC_MSG_WARN([Could not run FAAD test program, checking why...]) - CFLAGS="$CFLAGS $FAAD_CFLAGS" - LIBS="$LIBS $FAAD_LIBS" - AC_TRY_LINK([ -#include -#include -], [ return 0 ], [ -AC_MSG_RESULT([*** The test program compiled, but did not run. This usually means -*** that the run-time linker is not finding FAAD or finding the wrong -*** version of FAAD. If it is not finding FAAD, you'll need to set your -*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point -*** to the installed location Also, make sure you have run ldconfig if that -*** is required on your system -*** -*** If you have an old version installed, it is best to remove it, although -*** you may also be able to get things to work by modifying LD_LIBRARY_PATH])], [ -AC_MSG_RESULT([*** The test program failed to compile or link. See the file config.log for the -*** exact error that occured. This usually means FAAD was incorrectly installed.])]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - FAAD_CFLAGS="" - FAAD_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(FAAD_CFLAGS) - AC_SUBST(FAAD_LIBS) - rm -f conf.faadtest -]) - -dnl Check for lrintf presence -dnl currently needed only by ffmpeg -AC_DEFUN([AC_FUNC_LRINTF], -[ - AC_CACHE_CHECK([whether system declares lrintf function in math.h], - ac_cv_val_HAVE_LRINTF, - [ac_save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -O2" - AC_TRY_RUN([ - #define _ISOC9X_SOURCE 1 - #include - int main( void ) { return (lrintf(3.999f) > 0)?0:1; } ], - [ ac_cv_val_HAVE_LRINTF=yes ], [ ac_cv_val_HAVE_LRINTF=no ], - [ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) - CFLAGS=$ac_save_CFLAGS - ]) - if test x$ac_cv_val_HAVE_LRINTF = xyes; then - AC_DEFINE(HAVE_LRINTF, 1, [Define if you have lrintf on your system.]) - fi -]) - - -dnl Usage: -dnl AM_PATH_FFMPEG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for ffmpeg, and define FFMPEG_CFLAGS and FFMPEG_LIBS - -AC_DEFUN([AM_PATH_FFMPEG], -[ - AC_REQUIRE([AC_FUNC_LRINTF]) - - dnl !!! - it really sucks - Makefile.am can't be optimized even by - dnl !!! preparing some extra variable forward - dnl !!! FFAVFORMAT_SRC= - - AC_REQUIRE([AC_CHECK_OSS]) - test x$enable_oss = xyes && AC_DEFINE(CONFIG_AUDIO_OSS, 1, [Define if you want to have ffmpeg OSS audio support compiled.]) - - AC_REQUIRE([AC_CHECK_V4L]) - test x$enable_v4l = xyes && AC_DEFINE(CONFIG_VIDEO4LINUX, 1, [Define if you have video4linux device. (ffmpeg)]) - - AC_REQUIRE([AC_FIND_ZLIB]) - test x$have_zlib = xyes && AC_DEFINE(CONFIG_ZLIB, 1, [Define if you have z library (-lz) (ffmpeg)]) - - AC_ARG_ENABLE(ffmpeg_faadbin, [ --enable-ffmpeg-faadbin build ffmpeg with FAAD binary support. (default=yes)], - [], enable_ffmpeg_faadbin=yes) - test x$enable_ffmpeg_faadbin = xyes && AC_DEFINE(CONFIG_FAADBIN, 1, [Define if you want to build support for runtime linked libfaad.]) - AC_REQUIRE([AM_PATH_FAAD]) - test x$have_faad = xyes && AC_DEFINE(CONFIG_FAAD, 1, [Define if you want to have AAC support compiled. (ffmpeg)]) - - AC_ARG_ENABLE(ffmpeg_risky, [ --enable-ffmpeg-risky build ffmpeg risky code. (default=yes)], - [], enable_ffmpeg_risky=yes) - - AC_ARG_ENABLE(ffmpeg_a52, [ --enable-ffmpeg-a52 build ffmpeg with A52 (AC3) support. (default=yes)], - [], enable_ffmpeg_a52=yes) - if test x$enable_ffmpeg_a52 = xyes ; then - AC_DEFINE(HAVE_FFMPEG_A52, 1, [Define if you want to use ffmpeg A52 audio decoder.]) - AC_ARG_ENABLE(ffmpeg_a52bin, [ --enable-ffmpeg-a52bin A52 plugin dlopens liba52.so.0 at runtime (default=no)], - [], enable_ffmpeg_a52bin=no) - - if test x$enable_ffmpeg_a52bin = xyes ; then - AC_DEFINE(CONFIG_A52BIN, 1, [Define if you want to build ffmpeg with A52 dlopened decoder.]) - fi - fi - - test x$enable_ffmpeg_risky = xyes && AC_DEFINE(CONFIG_RISKY, 1, [Define if you want to compile patent encumbered codecs. (ffmpeg)]) - - AC_DEFINE(CONFIG_ENCODERS, 1, [Define if you want to build ffmpeg encoders.]) - AC_DEFINE(CONFIG_DECODERS, 1, [Define if you want to build ffmpeg decoders.]) - AC_DEFINE(CONFIG_AC3, 1, [Define if you want to build ffmpeg with AC3 decoder.]) - AC_DEFINE(SIMPLE_IDCT, 1, [Define if you want to build ffmpeg with simples idct.]) - AC_DEFINE(CONFIG_NETWORK, 1, [Define if you want to build ffmpeg with network support.]) - AC_DEFINE(CONFIG_MPEGAUDIO_HP, 1, [Define if you want to have highquality ffmpeg mpeg audio support compiled.]) - AC_DEFINE(HAVE_PTHREADS, 1, [Define if you want to have ffmpeg pthread support compiled.]) - - if test -n "$ffmpeg_profiling" ; then - AC_DEFINE(HAVE_GPROF, 1, [Define if you want to build ffmpeg with gprof support.]) - fi - - test -z "$FFMPEG_CFLAGS" && FFMPEG_CFLAGS="-O4 $DEFAULT_FLAGS" - FFMPEG_CFLAGS="$FFMPEG_CFLAGS $DEFAULT_DEFINES" - - AC_CHECK_GNU_VECTOR(FFMPEG_SSE="-msse"; - AC_DEFINE(HAVE_BUILTIN_VECTOR, 1, [Define if your compiler supports vector builtins (MMX).]), []) - AC_SUBST(FFMPEG_CFLAGS) - AC_SUBST(FFMPEG_SSE) - - AM_CONDITIONAL(AMM_BUILD_STRPTIME, test x$ac_cv_func_strptime != xyes ) - -dnl ffmpeg_x86opt= -dnl test x$enable_x86opt = xno && ffmpeg_x86opt="--disable-mmx" -dnl AC_MSG_RESULT([=== configuring ffmpeg ===]) -dnl ( cd $srcdir/ffmpeg ; \ -dnl ./configure --prefix=$prefix --cc=$CC \ -dnl $ffmpeg_profiling $ffmpeg_cpu \ -dnl $ffmpeg_x86opt --disable-mp3lib \ -dnl --enable-simple_idct ) -]) -# Configure paths for FreeType2 -# Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor - -dnl AC_CHECK_FT2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl Test for FreeType2, and define FT2_CFLAGS and FT2_LIBS -dnl -AC_DEFUN([AC_CHECK_FT2], -[dnl -dnl Get the cflags and libraries from the freetype-config script -dnl -AC_ARG_WITH(ft-prefix, -[ --with-ft-prefix=PREFIX prefix where FreeType is installed (optional)], - ft_config_prefix="$withval", ft_config_prefix="") -AC_ARG_WITH(ft-exec-prefix, -[ --with-ft-exec-prefix=PFX exec prefix where FreeType is installed (optional)], - ft_config_exec_prefix="$withval", ft_config_exec_prefix="") -AC_ARG_ENABLE(freetypetest, -[ --disable-freetypetest Do not try to compile and run FT2 test program], - [], enable_fttest=yes) - -if test x$ft_config_exec_prefix != x ; then - ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix" - if test x${FT2_CONFIG+set} != xset ; then - FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config - fi -fi -if test x$ft_config_prefix != x ; then - ft_config_args="$ft_config_args --prefix=$ft_config_prefix" - if test x${FT2_CONFIG+set} != xset ; then - FT2_CONFIG=$ft_config_prefix/bin/freetype-config - fi -fi -AC_PATH_PROG(FT2_CONFIG, freetype-config, no) - -min_ft_version=ifelse([$1], ,6.1.0,$1) -AC_MSG_CHECKING(for FreeType - version >= $min_ft_version) -no_ft="" -if test "$FT2_CONFIG" = "no" ; then - no_ft=yes -else - FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags` - FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs` - ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - ft_min_major_version=`echo $min_ft_version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - ft_min_minor_version=`echo $min_ft_version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - ft_min_micro_version=`echo $min_ft_version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - if test x$enable_fttest = xyes ; then - ft_config_is_lt="" - if test $ft_config_major_version -lt $ft_min_major_version ; then - ft_config_is_lt=yes - else - if test $ft_config_major_version -eq $ft_min_major_version ; then - if test $ft_config_minor_version -lt $ft_min_minor_version ; then - ft_config_is_lt=yes - else - if test $ft_config_minor_version -eq $ft_min_minor_version ; then - if test $ft_config_micro_version -lt $ft_min_micro_version ; then - ft_config_is_lt=yes - fi - fi - fi - fi - fi - if test x$ft_config_is_lt = xyes ; then - no_ft=yes - else - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $FT2_CFLAGS" - LIBS="$FT2_LIBS $LIBS" -dnl -dnl Sanity checks for the results of freetype-config to some extent -dnl - AC_TRY_RUN([ -#include -#include FT_FREETYPE_H -#include -#include - -int -main() -{ - FT_Library library; - FT_Error error; - - error = FT_Init_FreeType(&library); - - if (error) - return 1; - else - { - FT_Done_FreeType(library); - return 0; - } -} -],, no_ft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi # test $ft_config_version -lt $ft_min_version - fi # test x$enable_fttest = xyes -fi # test "$FT2_CONFIG" = "no" -if test x$no_ft = x ; then - AC_MSG_RESULT(yes) - ifelse([$2], , :, [$2]) -else - AC_MSG_RESULT(no) - if test "$FT2_CONFIG" = "no" ; then - echo "*** The freetype-config script installed by FreeType 2 could not be found." - echo "*** If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path, or set the FT2_CONFIG environment variable to the" - echo "*** full path to freetype-config." - else - if test x$ft_config_is_lt = xyes ; then - echo "*** Your installed version of the FreeType 2 library is too old." - echo "*** If you have different versions of FreeType 2, make sure that" - echo "*** correct values for --with-ft-prefix or --with-ft-exec-prefix" - echo "*** are used, or set the FT2_CONFIG environment variable to the" - echo "*** full path to freetype-config." - else - echo "*** The FreeType test program failed to run. If your system uses" - echo "*** shared libraries and they are installed outside the normal" - echo "*** system library path, make sure the variable LD_LIBRARY_PATH" - echo "*** (or whatever is appropiate for your system) is correctly set." - fi - fi - FT2_CFLAGS="" - FT2_LIBS="" - ifelse([$3], , :, [$3]) -fi -AC_SUBST(FT2_CFLAGS) -AC_SUBST(FT2_LIBS) -]) -# Configure paths for iconv - -dnl Usage: -dnl AC_ICONV(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl Test for ares, and defines -dnl - ICONV_CFLAGS (compiler flags) -dnl - ICONV_LIBS (linker flags, stripping and path) -dnl prerequisites: - -AC_DEFUN([AC_ICONV], -[ - dnl check it it's part of the libc - AC_CHECK_LIB(c, iconv_open, ac_cv_have_iconv=yes, ac_cv_have_iconv=no) - - ICONV_CFLAGS= - ICONV_LIBS= - AC_ARG_WITH(iconv, [ --with-iconv=path path for extra iconv library], - [ - if test x$ac_cv_have_iconv = xno; then - ac_iconv_path= - case "$with_iconv" in - 'yes') ac_iconv_path="/usr" ;; - 'no') ;; - *) ac_iconv_path=$with_iconv ;; - esac - if test -n "$ac_iconv_path"; then - ac_save_ICONVLIBS=$LIBS - LIBS="-L$ac_iconv_path/lib $LIBS" - AC_CHECK_LIB(iconv, iconv_open, ac_cv_have_iconv=yes,) - if test x$ac_cv_have_iconv = xyes ; then - ICONV_LIBS="-liconv" - if test "$ac_iconv_path" != "/usr"; then - ICONV_CFLAGS="-I$ac_iconv_path/include" - ICONV_LIBS="$ac_iconv_path/lib $ICONV_LIBS" - fi - fi - LIBS=$ac_save_ICONVLIBS - fi - fi - ]) - - if test x$ac_cv_have_iconv = xyes ; then - AC_MSG_CHECKING([for iconv declaration]) - AC_CACHE_VAL(ac_cv_proto_iconv, [ - AC_TRY_COMPILE([ -#include -#include -extern -#ifdef __cplusplus -"C" -#endif -#if defined(__STDC__) || defined(__cplusplus) -size_t iconv (iconv_t cd, char**, size_t*, char**, size_t*); -#else -size_t iconv(); -#endif -], [], - [ ac_cv_proto_iconv="" ], [ ac_cv_proto_iconv="const" ]) ]) - AC_DEFINE_UNQUOTED(ICONV_CONST_CAST, $ac_cv_proto_iconv, [Use casting for iconv's inputbuffer - don't ask me.]) - if test x$ac_cv_proto_iconv = xconst ; then - AC_MSG_RESULT([using const]) - else - AC_MSG_RESULT([not using const]) - fi - ifelse([$2], , :, [$2]) - else - ICONV_CFLAGS="" - ICONV_LIBS="" - ifelse([$3], , :, [$3]) - fi - - AC_SUBST(ICONV_CFLAGS) - AC_SUBST(ICONV_LIBS) -]) -# Configure paths for libogg -# Jack Moffitt 10-21-2000 -# Shamelessly stolen from Owen Taylor and Manish Singh - -dnl AM_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS -dnl -AC_DEFUN([AM_PATH_OGG], -[dnl -dnl Get the cflags and libraries -dnl -AC_ARG_WITH(ogg-prefix,[ --with-ogg-prefix=PFX prefix where libogg is installed. (optional)], ogg_prefix="$withval", ogg_prefix="") -AC_ARG_ENABLE(oggtest, [ --disable-oggtest do not try to compile and run a test Ogg program.],, enable_oggtest=yes) - - if test "x$ogg_prefix" != "xNONE" ; then - ogg_args="$ogg_args --prefix=$ogg_prefix" - OGG_CFLAGS="-I$ogg_prefix/include" - OGG_LIBS="-L$ogg_prefix/lib" - elif test "$prefix" != ""; then - ogg_args="$ogg_args --prefix=$prefix" - OGG_CFLAGS="-I$prefix/include" - OGG_LIBS="-L$prefix/lib" - fi - - OGG_LIBS="$OGG_LIBS -logg" - - AC_MSG_CHECKING(for Ogg) - no_ogg="" - - - if test "x$enable_oggtest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $OGG_CFLAGS" - LIBS="$LIBS $OGG_LIBS" -dnl -dnl Now check if the installed Ogg is sufficiently new. -dnl - rm -f conf.oggtest - AC_TRY_RUN([ -#include -#include -#include -#include - -int main () -{ - system("touch conf.oggtest"); - return 0; -} - -],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - - if test "x$no_ogg" = "x" ; then - AC_MSG_RESULT(yes) - ifelse([$1], , :, [$1]) - else - AC_MSG_RESULT(no) - if test -f conf.oggtest ; then - : - else - echo "*** Could not run Ogg test program, checking why..." - CFLAGS="$CFLAGS $OGG_CFLAGS" - LIBS="$LIBS $OGG_LIBS" - AC_TRY_LINK([ -#include -#include -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding Ogg or finding the wrong" - echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means Ogg was incorrectly installed" - echo "*** or that you have moved Ogg since it was installed. In the latter case, you" - echo "*** may want to edit the ogg-config script: $OGG_CONFIG" ]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - OGG_CFLAGS="" - OGG_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(OGG_CFLAGS) - AC_SUBST(OGG_LIBS) - rm -f conf.oggtest -]) - -dnl Usage: -dnl AC_CHECK_OSS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for OSS audio interface, and defines -dnl prerequisites: - -AC_DEFUN([AC_CHECK_OSS], -[ - AC_ARG_ENABLE(oss, [ --enable-oss support the OSS audio API. (autodetect)], - [], enable_oss=yes) - if test x$enable_oss = xyes; then - AC_CACHE_CHECK([for OSS audio support], ac_cv_val_have_oss_audio, - [AC_TRY_COMPILE([ - #ifdef __NetBSD__ - #include - #include - #else - #include - #endif - ],[ int arg = SNDCTL_DSP_SETFRAGMENT; ], - [ ac_cv_val_have_oss_audio=yes ], [ ac_cv_val_have_oss_audio=no ]) - ]) - enable_oss=$ac_cv_val_have_oss_audio - fi - - if test x$enable_oss = xyes; then - AC_CHECK_LIB([ossaudio], [_oss_ioctl]) - ifelse([$1], , :, [$1]) - else - ifelse([$2], , :, [$2]) - fi -]) - - -dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) -dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page -dnl also defines GSTUFF_PKG_ERRORS on error -AC_DEFUN([PKG_CHECK_MODULES], [ - succeeded=no - - if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) - fi - - if test "$PKG_CONFIG" = "no" ; then - echo "*** The pkg-config script could not be found. Make sure it is" - echo "*** in your path, or set the PKG_CONFIG environment variable" - echo "*** to the full path to pkg-config." - echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config." - else - PKG_CONFIG_MIN_VERSION=0.9.0 - if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then - AC_MSG_CHECKING(for $2) - - if $PKG_CONFIG --exists "$2" ; then - AC_MSG_RESULT(yes) - succeeded=yes - - AC_MSG_CHECKING($1_CFLAGS) - $1_CFLAGS=`$PKG_CONFIG --cflags "$2"` - AC_MSG_RESULT($$1_CFLAGS) - - AC_MSG_CHECKING($1_LIBS) - $1_LIBS=`$PKG_CONFIG --libs "$2"` - AC_MSG_RESULT($$1_LIBS) - else - $1_CFLAGS="" - $1_LIBS="" - ## If we have a custom action on failure, don't print errors, but - ## do set a variable so people can do so. - $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` - ifelse([$4], ,echo $$1_PKG_ERRORS,) - fi - - AC_SUBST($1_CFLAGS) - AC_SUBST($1_LIBS) - else - echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." - echo "*** See http://www.freedesktop.org/software/pkgconfig" - fi - fi - - if test $succeeded = yes; then - ifelse([$3], , :, [$3]) - else - ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4]) - fi -]) - -# Configure paths for SDL -# Sam Lantinga 9/21/99 -# stolen from Manish Singh -# stolen back from Frank Belew -# stolen from Manish Singh -# Shamelessly stolen from Owen Taylor -# slightly modified for avifile - -dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS -dnl -AC_DEFUN([AM_PATH_SDL], -[dnl -dnl Get the cflags and libraries from the sdl-config script -dnl -AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX prefix where SDL is installed. (optional)], - sdl_prefix="$withval", sdl_prefix="") -AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX exec prefix where SDL is installed. (optional)], - sdl_exec_prefix="$withval", sdl_exec_prefix="") -AC_ARG_ENABLE(sdltest, [ --disable-sdltest do not try to compile and run a test SDL program.], - , enable_sdltest=yes) - - if test x$sdl_exec_prefix != x ; then - sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config - fi - fi - if test x$sdl_prefix != x ; then - sdl_args="$sdl_args --prefix=$sdl_prefix" - if test x${SDL_CONFIG+set} != xset ; then - SDL_CONFIG=$sdl_prefix/bin/sdl-config - fi - fi - if test -z "$SDL_CONFIG"; then - AC_CHECK_PROGS(SDL_MY_CONFIG, sdl-config sdl11-config, "") - if test -n "$SDL_MY_CONFIG"; then - SDL_CONFIG=`which $SDL_MY_CONFIG` - echo "setting SDL_CONFIG to $SDL_CONFIG" - fi - fi - - AC_REQUIRE([AC_CANONICAL_TARGET]) - PATH="$prefix/bin:$prefix/usr/bin:$PATH" - AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) - min_sdl_version=ifelse([$1], ,0.11.0,$1) - AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) - no_sdl="" - if test "$SDL_CONFIG" = "no" ; then - no_sdl=yes - else - SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` - SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs | sed -e 's!-L/usr/lib[[^/]]!!g'` - - sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` - sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` - sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ - sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` - if test "x$enable_sdltest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" -dnl -dnl Now check if the installed SDL is sufficiently new. (Also sanity -dnl checks the results of sdl-config to some extent -dnl - rm -f conf.sdltest - AC_TRY_RUN([ -#include -#include -#include -#include "SDL.h" - -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - -int main (int argc, char *argv[]) -{ - int major, minor, micro; - char *tmp_version; - - /* This hangs on some systems (?) - system ("touch conf.sdltest"); - */ - { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } - - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_sdl_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { - printf("%s, bad version string\n", "$min_sdl_version"); - exit(1); - } - - if (($sdl_major_version > major) || - (($sdl_major_version == major) && ($sdl_minor_version > minor)) || - (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) - { - return 0; - } - else - { - printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); - printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); - printf("*** best to upgrade to the required version.\n"); - printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); - printf("*** to point to the correct copy of sdl-config, and remove the file\n"); - printf("*** config.cache before re-running configure\n"); - return 1; - } -} - -],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - if test "x$no_sdl" = x ; then - AC_MSG_RESULT(yes) - ifelse([$2], , :, [$2]) - else - AC_MSG_RESULT(no) - if test "$SDL_CONFIG" = "no" ; then - echo "*** The sdl-config script installed by SDL could not be found" - echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" - echo "*** your path, or set the SDL_CONFIG environment variable to the" - echo "*** full path to sdl-config." - else - if test -f conf.sdltest ; then - : - else - echo "*** Could not run SDL test program, checking why..." - CFLAGS="$CFLAGS $SDL_CFLAGS" - LIBS="$LIBS $SDL_LIBS" - AC_TRY_LINK([ -#include -#include "SDL.h" - -int main(int argc, char *argv[]) -{ return 0; } -#undef main -#define main K_and_R_C_main -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding SDL or finding the wrong" - echo "*** version of SDL. If it is not finding SDL, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means SDL was incorrectly installed" - echo "*** or that you have moved SDL since it was installed. In the latter case, you" - echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - fi - SDL_CFLAGS="" - SDL_LIBS="" - ifelse([$3], , :, [$3]) - fi - AC_SUBST(SDL_CFLAGS) - AC_SUBST(SDL_LIBS) - rm -f conf.sdltest -]) - -AC_DEFUN([MY_TEST_SDL], -[ -AC_MSG_CHECKING([for SDL development libraries]) -cat > conftest.c <&5 2>&5; then - AC_MSG_RESULT([found]) - GOOD_SDL_INSTALLATION=yes - else - AC_MSG_RESULT([linking against SDL library failed. Check config.log for details.]) - GOOD_SDL_INSTALLATION=no - fi -else - AC_MSG_RESULT([not found]) - GOOD_SDL_INSTALLATION=no -fi -rm -f conftest.c conftest -]) - -dnl -*- shell-script -*- - -dnl This file is part of the Avifile packages -dnl and has been heavily modified for its purposes -dnl Copyright (C) 2002 Zdenek Kabelac (kabi@users.sourceforge.net) -dnl -dnl Originaly this file was part of the KDE libraries/packages -dnl Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu) -dnl (C) 1997 Stephan Kulow (coolo@kde.org) - -dnl This file is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Library General Public -dnl License as published by the Free Software Foundation; either -dnl version 2 of the License, or (at your option) any later version. - -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Library General Public License for more details. - -dnl You should have received a copy of the GNU Library General Public License -dnl along with this library; see the file COPYING.LIB. If not, write to -dnl the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -dnl Boston, MA 02111-1307, USA. - - -dnl ------------------------------------------------------------------------ -dnl Find a file (or one of more files in a list of dirs) -dnl ------------------------------------------------------------------------ -dnl -AC_DEFUN([AC_FIND_FILE], -[ -$3=NO -for i in $2; -do - for j in $1; - do - if test -r "$i/$j"; then - $3=$i - break 2 - fi - done -done -]) - -AC_DEFUN([AC_FIND_ZLIB], -[ - AC_CACHE_CHECK([for libz], ac_cv_lib_z, - [ac_save_LIBS=$LIBS - LIBS="$LIBS -lz" - AC_TRY_LINK([#include], - [return (zlibVersion() == ZLIB_VERSION); ], - [ ac_cv_lib_z=yes ], [ ac_cv_lib_z=no ]) - LIBS=$ac_save_LIBS]) - AC_SUBST(Z_LIBS) - if test x$ac_cv_lib_z = xyes ; then - Z_LIBS="-lz" - have_zlib=yes - ifelse([$1], , :, [$1]) - else - Z_LIBS= - have_zlib=no - ifelse([$2], , :, [$2]) - fi -]) - - -AC_DEFUN([AC_FIND_PNG], -[ -AC_REQUIRE([AC_FIND_ZLIB]) -AC_MSG_CHECKING([for libpng]) -AC_CACHE_VAL(ac_cv_lib_png, -[ac_save_LIBS="$LIBS" -LIBS="$all_libraries -lpng $LIBZ -lm -lX11 $LIBSOCKET" -AC_TRY_LINK([#include], - [ - png_structp png_ptr = png_create_read_struct( // image ptr - PNG_LIBPNG_VER_STRING, 0, 0, 0 ); - return( png_ptr != 0 ); - ], - eval "ac_cv_lib_png='-lpng $LIBZ -lm'", - eval "ac_cv_lib_png=no") - LIBS=$ac_save_LIBS -]) -if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then - AC_DEFINE_UNQUOTED(HAVE_LIBPNG) - LIBPNG="$ac_cv_lib_png" - AC_SUBST(LIBPNG) - AC_MSG_RESULT($ac_cv_lib_png) -else - AC_MSG_RESULT(no) - LIBPNG="" - AC_SUBST(LIBPNG) -fi -]) - - -dnl just a wrapper to clean up configure.in -AC_DEFUN([KDE_PROG_LIBTOOL], -[ -AC_REQUIRE([AM_ENABLE_SHARED]) -AC_REQUIRE([AM_ENABLE_STATIC]) -dnl libtool is only for C, so I must force him -dnl to find the correct flags for C++ -ac_save_cc=$CC -ac_save_cflags="$CFLAGS" -CC=$CXX -CFLAGS="$CXXFLAGS" -dnl AM_PROG_LIBTOOL dnl for libraries -CC=$ac_save_cc -CFLAGS="$ac_save_cflags" -]) - - -dnl Check for the type of the third argument of getsockname -AC_DEFUN([AC_CHECK_KSIZE_T], -[AC_MSG_CHECKING(for the third argument of getsockname) -AC_LANG_CPLUSPLUS -AC_CACHE_VAL(ac_cv_ksize_t, -[AC_TRY_COMPILE([ -#include -#include -],[ -socklen_t a=0; -getsockname(0,(struct sockaddr*)0, &a); -], -ac_cv_ksize_t=socklen_t, -ac_cv_ksize_t=) -if test -z "$ac_cv_ksize_t"; then -ac_save_cxxflags="$CXXFLAGS" -if test "$GCC" = "yes"; then - CXXFLAGS="-Werror $CXXFLAGS" -fi -AC_TRY_COMPILE([ -#include -#include -],[ -int a=0; -getsockname(0,(struct sockaddr*)0, &a); -], -ac_cv_ksize_t=int, -ac_cv_ksize_t=size_t) -CXXFLAGS=$ac_save_cxxflags -fi -]) - -if test -z "$ac_cv_ksize_t"; then - ac_cv_ksize_t=int -fi - -AC_MSG_RESULT($ac_cv_ksize_t) -AC_DEFINE_UNQUOTED(ksize_t, $ac_cv_ksize_t) - -]) - - - -# Search path for a program which passes the given test. -# Ulrich Drepper , 1996. - -# serial 1 -# Stephan Kulow: I appended a _KDE against name conflicts - -dnl AM_PATH_PROG_WITH_TEST_KDE(VARIABLE, PROG-TO-CHECK-FOR, -dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) -AC_DEFUN([AM_PATH_PROG_WITH_TEST_KDE], -[# Extract the first word of "$2", so it can be a program name with args. - set dummy $2; ac_word=[$]2 - AC_MSG_CHECKING([for $ac_word]) - AC_CACHE_VAL(ac_cv_path_$1, - [case "[$]$1" in - /*) ac_cv_path_$1="[$]$1" # Let the user override the test with a path. - ;; - *) - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" - for ac_dir in ifelse([$5], , $PATH, [$5]); do - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$ac_word; then - if [$3]; then - ac_cv_path_$1="$ac_dir/$ac_word" - break - fi - fi - done - IFS="$ac_save_ifs" - dnl If no 4th arg is given, leave the cache variable unset, - dnl so AC_PATH_PROGS will keep looking. - ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" - ]) - ;; - esac - ]) - $1="$ac_cv_path_$1" - if test -n "[$]$1"; then - AC_MSG_RESULT([$]$1) - else - AC_MSG_RESULT(no) - fi - AC_SUBST($1)dnl -]) - - - -AC_DEFUN([AM_DISABLE_LIBRARIES], -[ - AC_PROVIDE([AM_ENABLE_STATIC]) - AC_PROVIDE([AM_ENABLE_SHARED]) - enable_static=no - enable_shared=no -]) - - - - - - -# Check whether LC_MESSAGES is available in . -# Ulrich Drepper , 1995. -# -# This file can be copied and used freely without restrictions. It can -# be used in projects which are not available under the GNU General Public -# License or the GNU Library General Public License but which still want -# to provide support for the GNU gettext functionality. -# Please note that the actual code of the GNU gettext library is covered -# by the GNU Library General Public License, and the rest of the GNU -# gettext package package is covered by the GNU General Public License. -# They are *not* in the public domain. - -# serial 2 - -AC_DEFUN([AM_LC_MESSAGES], -[ - if test $ac_cv_header_locale_h = yes; then - AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, - [AC_TRY_LINK([#include ], [return LC_MESSAGES], - am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) - if test $am_cv_val_LC_MESSAGES = yes; then - AC_DEFINE(HAVE_LC_MESSAGES, 1, - [Define if your file defines LC_MESSAGES.]) - fi - fi -]) - - -dnl AM_PATH_LINUX([DEFAULT PATH, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) -dnl define LINUX_PATH and LINUX_CFLAGS -AC_DEFUN([AM_PATH_LINUX], -[ - AC_ARG_WITH(linux_prefix, [ --with-linux-prefix=PFX where are linux sources (=/usr/src/linux)], - [], with_linux_prefix=ifelse([$1], [], /usr/src/linux, $1)) - if test -f $with_linux_prefix/include/linux/modversions.h ; then - LINUX_CFLAGS="-D__KERNEL__ -DMODULE -I$with_linux_prefix/include -include $with_linux_prefix/include/linux/modversions.h" - LINUX_PREFIX=$with_linux_prefix - else - LINUX_CFLAGS="" - LINUX_PREFIX="" - fi - AC_SUBST(LINUX_CFLAGS) - AC_SUBST(LINUX_PREFIX) - - if test -n "$LINUX_PREFIX"; then - ifelse([$2], [], [:], [$2]) - else - ifelse([$3], [], [:], [$3]) - fi -]) - -# Configure paths for VIDIX - -dnl Check if vidix support should be build - -AC_DEFUN([AM_PATH_VIDIX], -[ - AC_ARG_ENABLE(vidix, [ --enable-vidix build vidix drivers. [default=yes]], - [], enable_vidix=yes) - AC_MSG_CHECKING([for vidix]) - if test x$enable_vidix = xyes -a x$ac_cv_prog_AWK != xno; then - case "$target" in - i?86-*-linux* | k?-*-linux* | athlon-*-linux*) - enable_vidix=yes - enable_linux=yes - ;; - i386-*-freebsd*) - enable_vidix=yes - enable_dha_kmod=no - ;; - *) - enable_dha_kmod=no - enable_vidix=no - ;; - esac - fi -dnl for now without linux kernel support - enable_linux=no - - AC_MSG_RESULT([$enable_vidix]) - - if test x$enable_vidix = xyes ; then - AC_DEFINE(HAVE_VIDIX, 1, [Define if you want to have vidix support.]) - fi -]) - -# Configure paths for libvorbis -# Jack Moffitt 10-21-2000 -# Shamelessly stolen from Owen Taylor and Manish Singh - -dnl AM_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS -dnl -AC_DEFUN([AM_PATH_VORBIS], -[dnl -dnl Get the cflags and libraries -dnl -AC_ARG_WITH(vorbis-prefix,[ --with-vorbis-prefix=PFX prefix where libvorbis is installed. (optional)], vorbis_prefix="$withval", vorbis_prefix="") -AC_ARG_ENABLE(vorbistest, [ --disable-vorbistest do not try to compile and run a test Vorbis program.],, enable_vorbistest=yes) - - if test "x$vorbis_prefix" != "xNONE" ; then - vorbis_args="$vorbis_args --prefix=$vorbis_prefix" - VORBIS_CFLAGS="-I$vorbis_prefix/include" - VORBIS_LIBDIR="-L$vorbis_prefix/lib" - elif test "$prefix" != ""; then - vorbis_args="$vorbis_args --prefix=$prefix" - VORBIS_CFLAGS="-I$prefix/include" - VORBIS_LIBDIR="-L$prefix/lib" - fi - - VORBIS_LIBS="$VORBIS_LIBDIR -lvorbis -lm" - VORBISFILE_LIBS="-lvorbisfile" - VORBISENC_LIBS="-lvorbisenc" - - AC_MSG_CHECKING(for Vorbis) - no_vorbis="" - - - if test "x$enable_vorbistest" = "xyes" ; then - ac_save_CFLAGS="$CFLAGS" - ac_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $VORBIS_CFLAGS" - LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS" -dnl -dnl Now check if the installed Vorbis is sufficiently new. -dnl - rm -f conf.vorbistest - AC_TRY_RUN([ -#include -#include -#include -#include - -int main () -{ - system("touch conf.vorbistest"); - return 0; -} - -],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - - if test "x$no_vorbis" = "x" ; then - AC_MSG_RESULT(yes) - ifelse([$1], , :, [$1]) - else - AC_MSG_RESULT(no) - if test -f conf.vorbistest ; then - : - else - echo "*** Could not run Vorbis test program, checking why..." - CFLAGS="$CFLAGS $VORBIS_CFLAGS" - LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS" - AC_TRY_LINK([ -#include -#include -], [ return 0; ], - [ echo "*** The test program compiled, but did not run. This usually means" - echo "*** that the run-time linker is not finding Vorbis or finding the wrong" - echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your" - echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" - echo "*** to the installed location Also, make sure you have run ldconfig if that" - echo "*** is required on your system" - echo "***" - echo "*** If you have an old version installed, it is best to remove it, although" - echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], - [ echo "*** The test program failed to compile or link. See the file config.log for the" - echo "*** exact error that occured. This usually means Vorbis was incorrectly installed" - echo "*** or that you have moved Vorbis since it was installed." ]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - VORBIS_CFLAGS="" - VORBIS_LIBS="" - VORBISFILE_LIBS="" - VORBISENC_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(VORBIS_CFLAGS) - AC_SUBST(VORBIS_LIBS) - AC_SUBST(VORBISFILE_LIBS) - AC_SUBST(VORBISENC_LIBS) - rm -f conf.vorbistest -]) - -# Configure paths for video4linux - -dnl Usage: -dnl AC_CHECK_V4L([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for video4linux interface, and defines -dnl prerequisites: - -AC_DEFUN([AC_CHECK_V4L], -[ - AC_ARG_ENABLE(v4l, [ --enable-v4l support v4l video interface. (autodetect)], - [], enable_v4l=yes) - if test x$enable_v4l = xyes; then - AC_CHECK_HEADER([linux/videodev.h], [], [ enable_v4l=no; ]) - fi - - if test x$enable_v4l = xyes; then - ifelse([$1], , :, [$1]) - else - ifelse([$2], , :, [$2]) - fi -]) - -# Configure paths for libxvidcore - -dnl AM_PATH_XVID([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libxvidcore, and define XVID_CFLAGS and XVID_LIBS -dnl -AC_DEFUN([AM_PATH_XVID], -[ - AC_ARG_WITH(xvid_prefix, [ --with-xvid-prefix=PFX where XviD is installed. (optional)], - [], with_xvid_prefix="") - - AC_ARG_ENABLE(xvidtest, [ --disable-xvidtest do not try to compile and run a test XviD program], - [], enable_xvidtest=yes) - - XVID_CFLAGS="" - XVID_LIBS="" - - have_xvid=no - ac_save_CPPFLAGS=$CPPFLAGS - if test -n "$with_xvid_prefix" ; then - dnl user has specified extra path for XviD instalation - CPPFLAGS="-I$with_xvid_prefix $CPPFLAGS" - AC_CHECK_HEADER(include/xvid.h, - XVID_CFLAGS="-I$with_xvid_prefix/include" - XVID_LIBS="-L$with_xvid_prefix/lib" - have_xvid=yes) - if test x$have_xvid = xno ; then - AC_CHECK_HEADER(xvid.h, - XVID_CFLAGS="-I$with_xvid_prefix" - XVID_LIBS="-L$with_xvid_prefix" - have_xvid=yes) - fi - else - AC_CHECK_HEADER(xvid.h, have_xvid=yes) - fi - CPPFLAGS=$ac_save_CPPFLAGS - XVID_LIBS="$XVID_LIBS -lxvidcore" - -dnl -dnl Now check if the installed XviD is sufficiently new. -dnl - if test x$have_xvid = xyes -a x$enable_xvidtest = xyes ; then - AC_CACHE_CHECK([for xvid_init in -lxvidcore], - ac_cv_val_HAVE_XVID, - [ rm -f conf.xvidtest - ac_save_CFLAGS=$CFLAGS - ac_save_LIBS=$LIBS - CFLAGS="$CFLAGS $XVID_CFLAGS" - LIBS="$LIBS $XVID_LIBS" - AC_TRY_RUN([ -#include -#include -#include -#include - -int main () -{ - XVID_INIT_PARAM xinit; - system("touch conf.xvidtest"); - - xinit.cpu_flags = 0; - xvid_init(NULL, 0, &xinit, NULL); - - if (xinit.api_version == API_VERSION) { - return 0; - } else { - printf("Header file and library are out of sync. Header file supports\n" - "version %d.%d API and shared library supports version %d.%d API.\n", - API_VERSION >> 16, API_VERSION & 0xFFFF, - xinit.api_version >> 16, xinit.api_version & 0xFFFF); - return 1; - } -} - ], - [ ac_cv_val_HAVE_XVID=yes ], - [ ac_cv_val_HAVE_XVID=no ], - [ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) - CFLAGS=$ac_save_CFLAGS - LIBS=$ac_save_LIBS]) - test x$ac_cv_val_HAVE_XVID = xno && have_xvid=no - fi - - if test x$have_xvid = xyes ; then - ifelse([$1], , :, [$1]) - else - if test ! -f conf.xvidtest ; then - AC_MSG_WARN([Could not run XviD test program, checking why...]) - CFLAGS="$CFLAGS $XVID_CFLAGS" - LIBS="$LIBS $XVID_LIBS" - AC_TRY_LINK([ -#include -#include -], [ return 0 ], [ -AC_MSG_RESULT([*** The test program compiled, but did not run. This usually means -*** that the run-time linker is not finding XviD or finding the wrong -*** version of XviD. If it is not finding XviD, you'll need to set your -*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point -*** to the installed location Also, make sure you have run ldconfig if that -*** is required on your system -*** -*** If you have an old version installed, it is best to remove it, although -*** you may also be able to get things to work by modifying LD_LIBRARY_PATH])], [ -AC_MSG_RESULT([*** The test program failed to compile or link. See the file config.log for the -*** exact error that occured. This usually means XviD was incorrectly installed.])]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - XVID_CFLAGS="" - XVID_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(XVID_CFLAGS) - AC_SUBST(XVID_LIBS) - rm -f conf.xvidtest -]) - -# Configure paths for libxvidcore version 1.0 - -dnl AM_PATH_XVID([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) -dnl Test for libxvidcore, and define XVID4_CFLAGS and XVID4_LIBS -dnl -AC_DEFUN([AM_PATH_XVID4], -[ - AC_ARG_WITH(xvid4_prefix, [ --with-xvid4-prefix=PFX where XviD4 is installed. (optional)], - [], with_xvid4_prefix="") - - AC_ARG_ENABLE(xvid4test, [ --disable-xvid4test do not try to compile and run a test XviD4 program], - [], enable_xvid4test=yes) - - XVID4_CFLAGS="" - XVID4_LIBS="" - - have_xvid4=no - ac_save_CPPFLAGS=$CPPFLAGS - if test -n "$with_xvid4_prefix" ; then - dnl user has specified extra path for XviD instalation - CPPFLAGS="-I$with_xvid4_prefix $CPPFLAGS" - AC_CHECK_HEADER(include/xvid.h, - XVID4_CFLAGS="-I$with_xvid4_prefix/include" - XVID4_LIBS="-L$with_xvid4_prefix/lib" - have_xvid4=yes) - if test x$have_xvid4 = xno ; then - AC_CHECK_HEADER(xvid.h, - XVID4_CFLAGS="-I$with_xvid4_prefix" - XVID4_LIBS="-L$with_xvid4_prefix" - have_xvid4=yes) - fi - else - AC_CHECK_HEADER(xvid.h, have_xvid4=yes) - fi - CPPFLAGS=$ac_save_CPPFLAGS - XVID4_LIBS="$XVID4_LIBS -lxvidcore" - -dnl -dnl Now check if the installed XviD is sufficiently new. -dnl - if test x$have_xvid4 = xyes -a x$enable_xvid4test = xyes ; then - AC_CACHE_CHECK([for xvid_global in -lxvidcore (4)], - ac_cv_val_HAVE_XVID4, - [ rm -f conf.xvidtest - ac_save_CFLAGS=$CFLAGS - ac_save_LIBS=$LIBS - CFLAGS="$CFLAGS $XVID4_CFLAGS" - LIBS="$LIBS $XVID4_LIBS" - AC_TRY_RUN([ -#include -#include -#include -#include - -int main () -{ - xvid_gbl_info_t xinfo; - system("touch conf.xvidtest"); - - memset(&xinfo, 0, sizeof(xinfo)); - xinfo.version = XVID_VERSION; - - if (xvid_global(NULL, XVID_GBL_INIT, &xinfo, NULL) == XVID_ERR_FAIL) { - printf("Header file and library are out of sync. Header file supports\n" - "version %d.%d API and shared library supports version %d.%d API.\n", - XVID_VERSION >> 16, XVID_VERSION & 0xFFFF, - xinfo.version >> 16, xinfo.version & 0xFFFF); - return 1; - } else - return 0; -} - ], - [ ac_cv_val_HAVE_XVID4=yes ], - [ ac_cv_val_HAVE_XVID4=no ], - [ echo $ac_n "cross compiling; assumed OK... $ac_c" ]) - CFLAGS=$ac_save_CFLAGS - LIBS=$ac_save_LIBS]) - test x$ac_cv_val_HAVE_XVID4 = xno && have_xvid4=no - fi - - if test x$have_xvid4 = xyes ; then - ifelse([$1], , :, [$1]) - else - if test ! -f conf.xvidtest ; then - AC_MSG_WARN([Could not run XviD4 test program, checking why...]) - CFLAGS="$CFLAGS $XVID4_CFLAGS" - LIBS="$LIBS $XVID4_LIBS" - AC_TRY_LINK([ -#include -#include -], [ return 0 ], [ -AC_MSG_RESULT([*** The test program compiled, but did not run. This usually means -*** that the run-time linker is not finding XviD or finding the wrong -*** version of XviD. If it is not finding XviD, you'll need to set your -*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point -*** to the installed location Also, make sure you have run ldconfig if that -*** is required on your system -*** -*** If you have an old version installed, it is best to remove it, although -*** you may also be able to get things to work by modifying LD_LIBRARY_PATH])], [ -AC_MSG_RESULT([*** The test program failed to compile or link. See the file config.log for the -*** exact error that occured. This usually means XviD was incorrectly installed.])]) - CFLAGS="$ac_save_CFLAGS" - LIBS="$ac_save_LIBS" - fi - XVID4_CFLAGS="" - XVID4_LIBS="" - ifelse([$2], , :, [$2]) - fi - AC_SUBST(XVID4_CFLAGS) - AC_SUBST(XVID4_LIBS) - rm -f conf.xvidtest -]) - ###############################################################################################################333 # Check for Qt compiler flags, linker flags, and binary packages AC_DEFUN([gw_CHECK_QT], diff --git a/src/Makefile.am b/src/Makefile.am index 2382214..8494cf1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,6 +32,7 @@ miav_SOURCES = $(shell if [ $QT_CXXFLAGS ] ; then ../tools/MocList cc; fi ) \ mov_encoder.cc \ mov_encoder_thread.cc \ mov_encoder_writer.cc \ + multiplexer.cc \ network.cc \ player.cc \ server.cc \ @@ -60,6 +61,9 @@ EXTRA_DIST = \ info.h \ info_console.h \ info_gui.h \ + iso11172-1.h \ + iso11172-2.h \ + iso11172-3.h \ jpeg_mem_dest.h \ libfame_wrapper.h \ liblame_wrapper.h \ @@ -71,6 +75,7 @@ EXTRA_DIST = \ mov_encoder.h \ mov_encoder_thread.h \ mov_encoder_writer.h \ + multiplexer.h \ network.h \ package.h \ player.h \ diff --git a/src/frame.h b/src/frame.h index e6faacd..18425ab 100644 --- a/src/frame.h +++ b/src/frame.h @@ -40,10 +40,12 @@ public: ~Frame(); unsigned char *data; - int size; + unsigned int size; unsigned int number; + unsigned int bitrate; + bool shoot; int freeze; // 1 is freeze, -1 is unfreeze bool record; diff --git a/src/iso11172-1.h b/src/iso11172-1.h new file mode 100644 index 0000000..f284410 --- /dev/null +++ b/src/iso11172-1.h @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * iso11172-1.h + * + * Wed Aug 31 13:48:30 CEST 2005 + * Copyright 2005 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MIaV 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +/* + * This file contains symbols used to create an ISO11172-1 compatible multiplexed + * MPEG stream. + */ + +#include "config.h" +#ifndef __MIAV_ISO11172_1_H__ +#define __MIAV_ISO11172_1_H__ + +#define CLOCK_90KHZ 90000 + +namespace ISO11172_1 { + //////////////////////////////////////////////////// + // Constants + //////////////////////////////////////////////////// + const char pack_start_code[] = "\x00\x00\x01\xBA"; + const char system_header_start_code[] = "\x00\x00\x01\xBB"; + const char packet_start_code_prefix[] = "\x00\x00\x01"; + const char stream_id_video1[] = "\xE3"; + const char stream_id_video2[] = "\xE4"; + const char stream_id_video3[] = "\xE5"; + const char stream_id_video4[] = "\xE6"; + const char stream_id_video5[] = "\xE7"; + const char stream_id_video6[] = "\xE8"; + const char stream_id_video7[] = "\xE9"; + const char stream_id_video8[] = "\xEA"; + const char stream_id_audio1[] = "\xC0"; + const char stream_id_audio2[] = "\xC1"; + const char stream_id_audio3[] = "\xC2"; + const char stream_id_audio4[] = "\xC3"; + const char stream_id_audio5[] = "\xC4"; + const char stream_id_audio6[] = "\xC5"; + const char stream_id_audio7[] = "\xC6"; + const char stream_id_audio8[] = "\xC7"; + const char stream_id_padding[] = "\xBE"; + const char end_code[] = "\x00\x00\x01\xB9"; + + //////////////////////////////////////////////////// + // Methods + //////////////////////////////////////////////////// + /** + * SCR stands for System Clock Reference + */ + inline unsigned int SCR(unsigned int previous_SCR, + unsigned int pack_header_size, + unsigned int packets_per_pack, + unsigned int packet_data_size, + unsigned int Rmux) + { + // To prevent a crash when doing division. + if(Rmux == 0) Rmux = 1; + return previous_SCR + (unsigned int)((double)(pack_header_size + + (packets_per_pack * packet_data_size)) * + (double)CLOCK_90KHZ / (double)Rmux); + } + + /** + * Calculates Rmux according to subclause A.5.4 + * mux stands for multiplexing and R for Rate, + * so Rmux is the rate of the multiplexing. + */ + inline unsigned int Rmux(unsigned int video_data_rate, + unsigned int audio_data_rate, + unsigned int packet_header_size, + unsigned int pack_header_size, + unsigned int packets_per_pack, + unsigned int packet_data_size) + { + // To prevent a crash when doing division. + if(packets_per_pack == 0) packets_per_pack = 1; + if(packet_data_size == 0) packet_data_size = 1; + + return (unsigned int)( + ((double)video_data_rate + (double)audio_data_rate) * + (1.0 + ((double)packet_header_size + (double)pack_header_size / (double)packets_per_pack) + / (double)packet_data_size) + ); + } + + +}; + +#endif/*__MIAV_ISO11172_1_H__*/ diff --git a/src/iso11172-2.h b/src/iso11172-2.h new file mode 100644 index 0000000..f2e2fa3 --- /dev/null +++ b/src/iso11172-2.h @@ -0,0 +1,73 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * iso11172-2.h + * + * Tue Sep 6 13:31:04 CEST 2005 + * Copyright 2005 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MIaV 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "config.h" +#ifndef __MIAV_ISO11172_2_H__ +#define __MIAV_ISO11172_2_H__ + +namespace ISO11172_2 { + //////////////////////////////////////////////////// + // Types + //////////////////////////////////////////////////// + typedef struct { + unsigned long int picture_rate:4; + unsigned long int pel_aspect_ratio:4; + unsigned long int vertical_size:12; + unsigned long int horizontal_size:12; + } sequence_header_1; + + typedef struct { + unsigned long int load_non_intra_quantizer_flag:1; + unsigned long int load_intra_quantizer_flag:1; + unsigned long int constrained_parameter_flag:1; + unsigned long int vbv_buffer_size:10; + unsigned long int marker_bit:1; + unsigned long int bitrate:18; + } sequence_header_2; + + //////////////////////////////////////////////////// + // Constants + //////////////////////////////////////////////////// + const char picture_start_code[] = "\x00\x00\x01\x00"; + const char slice_start_code_prefix[] ="\x00\x00\x01"; + // const char _code = "\x00\x00\x01\xB0"; //Reserved + // const char _code = "\x00\x00\x01\xB1"; //Reserved + const char user_data_start_code[] = "\x00\x00\x01\xB2"; + const char sequence_header_code[] = "\x00\x00\x01\xB3"; + const char sequence_error_code[] = "\x00\x00\x01\xB4"; + const char sequence_start_code[] = "\x00\x00\x01\xB5"; + // const char _code = "\x00\x00\x01\xB6"; //Reserved + const char sequence_end_code[] = "\x00\x00\x01\xB7"; + const char group_start_code[] = "\x00\x00\x01\xB8"; + const char system_start_code_prefix[] = "\x00\x00\x01"; + + //////////////////////////////////////////////////// + // Methods + //////////////////////////////////////////////////// + +}; + +#endif/*__MIAV_ISO11172_2_H__*/ diff --git a/src/iso11172-3.h b/src/iso11172-3.h new file mode 100644 index 0000000..d3eda79 --- /dev/null +++ b/src/iso11172-3.h @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + * iso11172-3.h + * + * Tue Sep 6 13:10:48 CEST 2005 + * Copyright 2005 Bent Bisballe Nyeng + * deva@aasimon.org + ****************************************************************************/ + +/* + * This file is part of MIaV. + * + * MIaV is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MIaV 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MIaV; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ +#include "config.h" +#ifndef __MIAV_ISO11172_3_H__ +#define __MIAV_ISO11172_3_H__ + +namespace ISO11172_3 { + //////////////////////////////////////////////////// + // Types + //////////////////////////////////////////////////// + typedef struct { + unsigned long int emphasis:2; + unsigned long int original_home:1; + unsigned long int copyright:1; + unsigned long int mode_extension:2; + unsigned long int mode:2; + unsigned long int private_bit:1; + unsigned long int padding_bit:1; + unsigned long int sampling_frequency:2; + unsigned long int bitrate_index:4; + unsigned long int protection_bit:1; + unsigned long int layer:2; + unsigned long int ID:1; + unsigned long int syncword:12; + } header; + + //////////////////////////////////////////////////// + // Constants + //////////////////////////////////////////////////// + + typedef enum { + ID_RESERVED = 0, + ID_MPEG = 1 + } IDs; + + typedef enum { + LAYER_RESERVED = 0x00, + LAYER_III = 0x01, + LAYER_II = 0x10, + LAYER_I = 0x11 + } layers; + + typedef enum { + CRC_ON = 0, + CRC_OFF = 1 + } crcs; + + typedef enum { + MODE_STEREO = 0x00, + MODE_JOINT_STEREO = 0x01, + MODE_DUAL_CHANNEL = 0x10, + MODE_SINGLE_CHANNEL = 0x11, + } modes; + + //////////////////////////////////////////////////// + // Methods + //////////////////////////////////////////////////// + +}; + +#endif/*__MIAV_ISO11172_3_H__*/ diff --git a/src/libfame_wrapper.cc b/src/libfame_wrapper.cc index e17ed68..94989f1 100644 --- a/src/libfame_wrapper.cc +++ b/src/libfame_wrapper.cc @@ -47,7 +47,9 @@ LibFAMEWrapper::LibFAMEWrapper(Info *i) yuv.y = new unsigned char [w*h * 2]; yuv.u = new unsigned char [w*h];// [w*h/4] yuv.v = new unsigned char [w*h];// [w*h/4] - + + calc_bitrate = 0; + ////////////LIBDV STUFF/////////////// dvdecoder = NULL; // Initialize in encode method @@ -224,6 +226,8 @@ Frame *LibFAMEWrapper::encode(Frame *dvframe) // Allocate a new frame for the output Frame *output = new Frame(NULL, FAME_BUFFER_SIZE); + fame_frame_statistics_t stats; + // Init frame params dv_get_timestamp(dvdecoder, output->timecode); // Set timecode output->size = 0; // Init size (incremented as we read) @@ -238,7 +242,28 @@ Frame *LibFAMEWrapper::encode(Frame *dvframe) pt += written; output->size += written; } - fame_end_frame(fame_context,0); + fame_end_frame(fame_context, &stats); + /* + info->info("frame_number: %d, coding: %c, target_bits: %d, actual_bits: %d, spatial_activity: %d, quant_scale: %f", + stats.frame_number, + stats.coding, + stats.target_bits, + stats.actual_bits, + stats.spatial_activity, + stats.quant_scale); + */ + /* + fame_frame_statistics_t_ { + unsigned int frame_number; + char coding; + signed int target_bits; + unsigned int actual_bits; + unsigned int spatial_activity; + float quant_scale; + } + */ + calc_bitrate += stats.actual_bits; + output->bitrate = (unsigned int)(((double)calc_bitrate / (double)(stats.frame_number+1)) * 25.0); return output; } diff --git a/src/libfame_wrapper.h b/src/libfame_wrapper.h index c4b5344..6a6b569 100644 --- a/src/libfame_wrapper.h +++ b/src/libfame_wrapper.h @@ -49,6 +49,8 @@ public: Frame *encode(Frame *dvframe); private: + unsigned long long calc_bitrate; + Info* info; // libFAME encoder diff --git a/src/liblame_wrapper.cc b/src/liblame_wrapper.cc index 5868c86..6d78380 100644 --- a/src/liblame_wrapper.cc +++ b/src/liblame_wrapper.cc @@ -48,7 +48,7 @@ LibLAMEWrapper::LibLAMEWrapper(Info *i) lame_set_mode(gfp, STEREO); lame_set_brate(gfp, config->readInt("mp3_bitrate")); - lame_set_strict_ISO(gfp, 0); + lame_set_strict_ISO(gfp, 1); // 1 = write a Xing VBR header frame. lame_set_bWriteVbrTag(gfp, 0); @@ -189,11 +189,15 @@ Frame *LibLAMEWrapper::encode(Frame *dvframe) * * return code = number of bytes output to mp3buf. Can be 0 */ + int flush_sz = lame_encode_flush_nogap(gfp, // global context handle mp3buf + val, // pointer to encoded MP3 stream mp3buf_size - val); // number of valid octets in this stream audio_frame->size = val + flush_sz; + // Bits pr. second + audio_frame->bitrate = config->readInt("mp3_bitrate") * 1000; + return audio_frame; } diff --git a/src/mov_encoder.cc b/src/mov_encoder.cc index 1073b35..a9a2ca2 100644 --- a/src/mov_encoder.cc +++ b/src/mov_encoder.cc @@ -44,8 +44,9 @@ #include "debug.h" MovEncoder::MovEncoder(sem_t *r_sem, - FrameVectorQueue *in, sem_t *in_sem, pthread_mutex_t *in_mutex, - FramePriorityQueue *out, sem_t *out_sem, pthread_mutex_t *out_mutex, + FrameVectorQueue *in, sem_t *in_sem, pthread_mutex_t *in_mutex, + FramePriorityQueue *v_out, pthread_mutex_t *v_out_mutex, sem_t *v_out_sem, + FramePriorityQueue *a_out, pthread_mutex_t *a_out_mutex, sem_t *a_out_sem, Info *i) { info = i; @@ -53,16 +54,21 @@ MovEncoder::MovEncoder(sem_t *r_sem, running = true; + // Queues inputqueue = in; - outputqueue = out; + video_outputqueue = v_out; + audio_outputqueue = a_out; + + // Queue mutexes + input_mutex = in_mutex; + video_output_mutex = v_out_mutex; + audio_output_mutex = a_out_mutex; input_sem = in_sem; - output_sem = out_sem; + video_output_sem = v_out_sem; + audio_output_sem = a_out_sem; read_sem = r_sem; - - input_mutex = in_mutex; - output_mutex = out_mutex; } MovEncoder::~MovEncoder() @@ -71,14 +77,13 @@ MovEncoder::~MovEncoder() } -//#define COPY_DV 1 - // this runs in a thread void MovEncoder::thread_main() { info->info("MovEncoder thread is running."); static volatile int test = 0; - int outsize = 0; + int v_outsize = 0; + int a_outsize = 0; int insize = 0; // Run with slightly lower priority than MovEncoderWriter @@ -113,49 +118,47 @@ void MovEncoder::thread_main() for(unsigned int cnt = 0; cnt < item->size(); cnt++) { in_frame = item->at(cnt); -#ifdef COPY_DV - // Encode video out_v_frame = new Frame(in_frame->data, in_frame->size); out_v_frame->number = in_frame->number; - - // Encode audio - out_a_frame = new Frame(in_frame->data, in_frame->size); - out_a_frame->number = in_frame->number + 1; - -#else /*COPY_DV*/ - - // Encode video out_v_frame = fame.encode(in_frame); out_v_frame->number = in_frame->number; // Encode audio + out_a_frame = new Frame(in_frame->data, in_frame->size); + out_a_frame->number = in_frame->number; out_a_frame = lame.encode(in_frame); - out_a_frame->number = in_frame->number + 1; + out_a_frame->number = in_frame->number; -#endif /*COPY_DV*/ delete in_frame; // Lock output mutex - pthread_mutex_lock(output_mutex); - - outputqueue->push(out_v_frame); - - outputqueue->push(out_a_frame); + pthread_mutex_lock(video_output_mutex); + video_outputqueue->push(out_v_frame); + v_outsize = video_outputqueue->size(); + pthread_mutex_unlock(video_output_mutex); + // Unlock output mutex - outsize = outputqueue->size(); + // Kick multiplexer (video) + sem_post(video_output_sem); - pthread_mutex_unlock(output_mutex); + // Lock output mutex + pthread_mutex_lock(audio_output_mutex); + audio_outputqueue->push(out_a_frame); + a_outsize = audio_outputqueue->size(); + pthread_mutex_unlock(audio_output_mutex); // Unlock output mutex + + // Kick multiplexer (audio) + sem_post(audio_output_sem); } delete item; test++; - if(test % (25 * 24) == 0) info->info("Input pool size: %d, output pool size: %d", insize, outsize); - - // Kick frame writer - sem_post(output_sem); + if(test % (25 * 24) == 0) + info->info("Input pool size: %d, video output pool size: %d, audio output pool size: %d", + insize, v_outsize, a_outsize); // Kick reader sem_post(read_sem); diff --git a/src/mov_encoder.h b/src/mov_encoder.h index cb233e5..6862c84 100644 --- a/src/mov_encoder.h +++ b/src/mov_encoder.h @@ -55,7 +55,8 @@ class MovEncoder : public Thread { public: MovEncoder(sem_t *r_sem, FrameVectorQueue *in, sem_t *in_sem, pthread_mutex_t *in_mutex, - FramePriorityQueue *out, sem_t *out_sem, pthread_mutex_t *out_mutex, + FramePriorityQueue *v_out, pthread_mutex_t *v_out_mutex, sem_t *v_out_sem, + FramePriorityQueue *a_out, pthread_mutex_t *a_out_mutex, sem_t *a_out_sem, Info *info); ~MovEncoder(); @@ -71,16 +72,19 @@ private: // Input/Output queues FrameVectorQueue *inputqueue; - FramePriorityQueue *outputqueue; + FramePriorityQueue *video_outputqueue; + FramePriorityQueue *audio_outputqueue; + pthread_mutex_t *input_mutex; + pthread_mutex_t *video_output_mutex; + pthread_mutex_t *audio_output_mutex; //thread stuff sem_t *input_sem; - sem_t *output_sem; + sem_t *video_output_sem; + sem_t *audio_output_sem; sem_t *read_sem; - pthread_mutex_t *input_mutex; - pthread_mutex_t *output_mutex; }; #endif diff --git a/src/mov_encoder_thread.cc b/src/mov_encoder_thread.cc index cfa6071..dc3581d 100644 --- a/src/mov_encoder_thread.cc +++ b/src/mov_encoder_thread.cc @@ -34,8 +34,16 @@ MovEncoderThread::MovEncoderThread(const char *cpr, Info *i) info = i; info->info("MovEncoderThread"); - outputqueue = new FramePriorityQueue(); + // Queues inputqueue = new FrameVectorQueue(); + video_outputqueue = new FramePriorityQueue(); + audio_outputqueue = new FramePriorityQueue(); + + // Queue mutexes + pthread_mutex_init (&input_mutex, NULL); + pthread_mutex_init (&video_output_mutex, NULL); + pthread_mutex_init (&audio_output_mutex, NULL); + block = new FrameVector(); num_frames_in_block = config->readString("frame_sequence")->length(); @@ -46,28 +54,26 @@ MovEncoderThread::MovEncoderThread(const char *cpr, Info *i) // Thread stuff sem_init(&in_sem, 0, 0); - sem_init(&out_sem, 0, 0); + sem_init(&video_out_sem, 0, 0); + sem_init(&audio_out_sem, 0, 0); sem_init(&read_sem, 0, 0); for(int cnt = 0; cnt < threads; cnt++) sem_post(&read_sem); - pthread_mutex_init (&input_mutex, NULL); - pthread_mutex_init (&output_mutex, NULL); - - writer = new MovEncoderWriter(cpr, outputqueue, &out_sem, &output_mutex, info); + writer = new MovEncoderWriter(cpr, + video_outputqueue, &video_output_mutex, &video_out_sem, + audio_outputqueue, &audio_output_mutex, &audio_out_sem, + info); writer->run(); - // writer_tid = new pthread_t; - //pthread_create (writer_tid, NULL, thread_run, writer); for(int cnt = 0; cnt < threads; cnt++) { MovEncoder *movenc = new MovEncoder(&read_sem, inputqueue, &in_sem, &input_mutex, - outputqueue, &out_sem, &output_mutex, + video_outputqueue, &video_output_mutex, &video_out_sem, + audio_outputqueue, &audio_output_mutex, &audio_out_sem, info); movenc->run(); encs.push_back(movenc); - // tids.push_back(new pthread_t); - // pthread_create (tids[cnt], NULL, thread_run, encs[cnt]); } frame_number = 0; @@ -80,9 +86,10 @@ MovEncoderThread::~MovEncoderThread() // These should not be deleted here... its done elsewhere. // inputqueue = NULL; - sem_post(&out_sem); + sem_post(&video_out_sem); + sem_post(&audio_out_sem); - // Stop the encoding threads. + // Tell the encoding threads to stop. for(int cnt = 0; cnt < threads; cnt++) { encs[cnt]->running = false; } @@ -94,27 +101,29 @@ MovEncoderThread::~MovEncoderThread() // They should be exited now, so we can delete them. for(int cnt = 0; cnt < threads; cnt++) { - // pthread_join(*tids[cnt], NULL); + // Wait for it to stop + encs[cnt]->wait_stop(); + // Delete it delete encs[cnt]; - // delete tids[cnt]; } // Tell the writer to stop writer->running = false; // Kick it to make it stop. - sem_post(&out_sem); + sem_post(&video_out_sem); + sem_post(&audio_out_sem); - // Destroy the thread - // pthread_join(*writer_tid, NULL); - // delete writer_tid; + // Wait for it to stop. + writer->wait_stop(); // delete the writer (end thereby close the file) delete writer; // Destroy the semaphores. sem_destroy(&in_sem); - sem_destroy(&out_sem); + sem_destroy(&video_out_sem); + sem_destroy(&audio_out_sem); sem_destroy(&read_sem); } @@ -157,5 +166,5 @@ void MovEncoderThread::encode(Frame* frame) block = new FrameVector; } - frame_number += 2; + frame_number ++; } diff --git a/src/mov_encoder_thread.h b/src/mov_encoder_thread.h index 5d38d3b..5684edf 100644 --- a/src/mov_encoder_thread.h +++ b/src/mov_encoder_thread.h @@ -52,17 +52,20 @@ private: Info *info; FrameVectorQueue *inputqueue; - FramePriorityQueue *outputqueue; + FramePriorityQueue *video_outputqueue; + FramePriorityQueue *audio_outputqueue; FrameVector *block; //thread stuff sem_t in_sem; - sem_t out_sem; + sem_t video_out_sem; + sem_t audio_out_sem; sem_t read_sem; pthread_mutex_t input_mutex; - pthread_mutex_t output_mutex; + pthread_mutex_t video_output_mutex; + pthread_mutex_t audio_output_mutex; // Used for encoder switching unsigned int frame_number; diff --git a/src/mov_encoder_writer.cc b/src/mov_encoder_writer.cc index f408417..bc9302a 100644 --- a/src/mov_encoder_writer.cc +++ b/src/mov_encoder_writer.cc @@ -44,10 +44,11 @@ using namespace std; #include +#include "multiplexer.h" + MovEncoderWriter::MovEncoderWriter(const char* cpr, - FramePriorityQueue *q, - sem_t *s, - pthread_mutex_t *m, + FramePriorityQueue *v_q, pthread_mutex_t *v_m, sem_t *v_s, + FramePriorityQueue *a_q, pthread_mutex_t *a_m, sem_t *a_s, Info *i) { info = i; @@ -80,12 +81,21 @@ MovEncoderWriter::MovEncoderWriter(const char* cpr, file = new File(fname, "mpg", info); - sem = s; - queue = q; - frame_number = 0; - mutex = m; + video_queue = v_q; + video_sem = v_s; + video_mutex = v_m; + + audio_queue = a_q; + audio_sem = a_s; + audio_mutex = a_m; + + video_frame_number = 0; + audio_frame_number = 0; running = true; + + // empty_timecode_struc(&SCR); + // timestamp = 0.0; } MovEncoderWriter::~MovEncoderWriter() @@ -94,74 +104,128 @@ MovEncoderWriter::~MovEncoderWriter() delete file; } -//#define WRITE_DV 1 void MovEncoderWriter::thread_main() { info->info("MovEncoderWriter::run"); - Frame *frame; + Multiplexer multiplexer(file, info, &running, + video_queue, video_mutex, video_sem, + audio_queue, audio_mutex, audio_sem); + multiplexer.multiplex(); -#ifndef WRITE_DV - - write_header(); - -#endif/*WRITE_DV*/ - - while(running) { - sem_wait(sem); +#if 0 + int wrote = 0; + while(running ) { + sem_wait(audio_sem); // Lock output mutex - pthread_mutex_lock(mutex); - frame = queue->top(); - if(frame && frame->number == frame_number) queue->pop(); - // poolsize = queue->size(); - pthread_mutex_unlock(mutex); + pthread_mutex_lock(audio_mutex); + audio_frame = audio_queue->top(); + if(audio_frame && audio_frame->number == audio_frame_number) audio_queue->pop(); + pthread_mutex_unlock(audio_mutex); // Unlock output mutex - int wrote = 0; - while(frame && (frame->number == frame_number)) { + while(audio_frame && (audio_frame->number == audio_frame_number)) { + if(file->Write(audio_frame->data, audio_frame->size) == -1) { + info->error("File write returned -1."); + return; + } - int ret = 0; + delete audio_frame; + audio_frame = NULL; + + wrote ++; + audio_frame_number++; + + // Lock output mutex + pthread_mutex_lock(audio_mutex); + audio_frame = audio_queue->top(); + if(audio_frame && audio_frame->number == audio_frame_number) audio_queue->pop(); + pthread_mutex_unlock(audio_mutex); + // Unlock output mutex + } + } +#endif/*0*/ + + // info->info("Wrote %d mpeg packets.", wrote); + info->info("MovEncoderWriter::stop"); +} + -#ifndef WRITE_DV - if(frame->number%2 == 1) write_audio_header((unsigned short int)frame->size); - else write_video_header((unsigned short int)frame->size); - ret = file->Write(frame->data, frame->size); -#else/*WRITE_DV*/ - if(frame->number%2 == 0) ret = file->Write(frame->data, frame->size); -#endif/*WRITE_DV*/ - frame_number++; - wrote ++; - delete frame; - if(ret == -1) { - info->error("File write returned -1."); - return; - } - // Lock output mutex - pthread_mutex_lock(mutex); - frame = queue->top(); - if(frame && frame->number == frame_number) queue->pop(); - // poolsize = queue->size(); - pthread_mutex_unlock(mutex); - // Unlock output mutex - } - } - info->info("MovEncoderWriter::stop"); -} -void MovEncoderWriter::write_header() + + + + + + + + + + + + + + + + + + + + + + +#if 0 +void MovEncoderWriter::write_system_header(unsigned int audio_size, unsigned int video_size) { + /* + Sys_header_struc sys_header; + + unsigned int mux_rate = (audio_size + video_size) * 25; + + create_sys_header(&sys_header, + mux_rate, //unsigned int rate_bound, + 1, //unsigned char audio_bound, + 1, //unsigned char fixed, + 1, //unsigned char CSPS, + 1, //unsigned char audio_lock, + 1, //unsigned char video_lock, + 1, //unsigned char video_bound, + + AUDIO_STR_0, //unsigned char stream1, + 0, //unsigned char buffer1_scale, + audio_size, //unsigned int buffer1_size, + // audio_size/128, //unsigned int buffer1_size, + + VIDEO_STR_0, //unsigned char stream2, + 1, //unsigned char buffer2_scale, + // video_size/1024, //unsigned int buffer2_size, + video_size, //unsigned int buffer2_size, + + // We both have audio *and* video + STREAMS_BOTH);//unsigned int which_streams + +// create_sys_header (sys_header, mux_rate, 1, 1, 1, 1, 1, 1, +// AUDIO_STR_0, 0, audio_size/128, +// VIDEO_STR_0, 1, video_size/1024, STREAMS_BOTH ); + + file->Write(sys_header.buf, sizeof(sys_header.buf)); +*/ + /** + * My shot at a valid system header + */ + /* // PACK char pack_start_code[] = { 0x00, 0x00, 0x01, 0xBA, @@ -177,6 +241,7 @@ void MovEncoderWriter::write_header() }; file->Write(pack_data, sizeof(pack_data)); + */ /* // SYSTEM char system_header_start_code[] = { @@ -216,6 +281,28 @@ void MovEncoderWriter::write_header() */ } +void MovEncoderWriter::write_packet_header(unsigned int audio_size, unsigned int video_size) +{ + /* + Pack_struc pack; + timestamp += 1.0; + make_timecode(timestamp, &SCR); + // Timecode_struc SCR; + unsigned int mux_rate = (audio_size + video_size) * 25; + // SCR. + + create_pack(&pack, mux_rate, &SCR); + + file->Write(pack.buf, sizeof(pack.buf)); + + unsigned char timestampbuf[32]; + unsigned char *i = timestampbuf; + buffer_timecode (&SCR, MARKER_JUST_PTS, &i); + + file->Write(timestampbuf, (int)i - (int)timestampbuf); + */ +} + void MovEncoderWriter::write_video_header(unsigned short int psize) { // PES Header startcode @@ -283,10 +370,7 @@ void MovEncoderWriter::write_audio_header(unsigned short int psize) file->Write(streamID, sizeof(streamID)); - psize += - sizeof(stuffing_bytes) + - sizeof(std_buffer) + - sizeof(PTS); + psize += sizeof(stuffing_bytes) + sizeof(std_buffer) + sizeof(PTS); packetsize[0] = ((char*)&psize)[1]; packetsize[1] = ((char*)&psize)[0]; file->Write(packetsize, sizeof(packetsize)); @@ -299,3 +383,4 @@ void MovEncoderWriter::write_audio_header(unsigned short int psize) } +#endif /*0*/ diff --git a/src/mov_encoder_writer.h b/src/mov_encoder_writer.h index f74dc51..e653223 100644 --- a/src/mov_encoder_writer.h +++ b/src/mov_encoder_writer.h @@ -36,12 +36,14 @@ #include using namespace std; +#define AUDIO_FRAME(x) x->number%2==1 +#define VIDEO_FRAME(x) x->number%2==0 + class MovEncoderWriter : public Thread { public: MovEncoderWriter(const char* cpr, - FramePriorityQueue *q, - sem_t *s, - pthread_mutex_t *m, + FramePriorityQueue *video_queue, pthread_mutex_t *video_mutex, sem_t *video_sem, + FramePriorityQueue *audio_queue, pthread_mutex_t *audio_mutex, sem_t *audio_sem, Info *info); ~MovEncoderWriter(); @@ -54,16 +56,23 @@ private: File *file; - FramePriorityQueue *queue; - pthread_mutex_t *mutex; + FramePriorityQueue *video_queue; + FramePriorityQueue *audio_queue; + pthread_mutex_t *video_mutex; + pthread_mutex_t *audio_mutex; + sem_t *video_sem; + sem_t *audio_sem; - sem_t *sem; + unsigned int video_frame_number; + unsigned int audio_frame_number; - unsigned int frame_number; + // Timecode_struc SCR; + // double timestamp; - void write_audio_header(unsigned short int packetsize); - void write_video_header(unsigned short int packetsize); - void write_header(); +// void write_audio_header(unsigned short int packetsize); +// void write_video_header(unsigned short int packetsize); +// void write_system_header(unsigned int audio_size, unsigned int video_size); +// void write_packet_header(unsigned int audio_size, unsigned int video_size); }; diff --git a/src/thread.cc b/src/thread.cc index 23b142a..2791c53 100644 --- a/src/thread.cc +++ b/src/thread.cc @@ -45,3 +45,8 @@ void Thread::run() { pthread_create (&tid, NULL, thread_run, this); } + +void Thread::wait_stop() +{ + pthread_join (tid, NULL); +} diff --git a/src/thread.h b/src/thread.h index 3ed3c93..6b7a52a 100644 --- a/src/thread.h +++ b/src/thread.h @@ -37,9 +37,10 @@ public: virtual ~Thread(); void run(); + void wait_stop(); virtual void thread_main() = 0; - + private: pthread_t tid; }; diff --git a/tools/MIaVAdd b/tools/MIaVAdd index 7463fb4..0fc0bd3 100755 --- a/tools/MIaVAdd +++ b/tools/MIaVAdd @@ -6,7 +6,7 @@ function allfile() { echo " * $1" >> $1; echo " *" >> $1 ; echo " * `date`" >> $1; - echo " * Copyright 2005 Bent Bisballe" >> $1; + echo " * Copyright 2005 Bent Bisballe Nyeng" >> $1; echo " * deva@aasimon.org" >> $1; echo " ****************************************************************************/" >> $1; echo "" >> $1; -- cgit v1.2.3