From b2976d98a1a83377671e70ef74e5baa78dfbda2d Mon Sep 17 00:00:00 2001 From: Andrea Gabriellini Date: Mon, 21 Jul 2008 10:09:54 +0100 Subject: [PATCH] Remove examples/decoder wrapper - Removed examples and decoder wrapper. Now it's just a dirac parser (as the name of project suggests...). - cleaned up the unit tests (removed tests for decoder wrapper). - further clean up of stale files. --- INSTALL | 5 +- configure.ac | 42 --- src/Makefile.am | 2 +- src/common/dirac.h | 31 -- src/common/util.cpp | 4 +- src/common/util.hpp | 28 +- src/decoder/.svn/entries | 304 ----------------- src/decoder/.svn/format | 1 - .../DefaultFrameMemoryManager.cpp.svn-base | 63 ---- .../DefaultFrameMemoryManager.hpp.svn-base | 59 ---- src/decoder/.svn/text-base/DiracState.cpp.svn-base | 182 ---------- src/decoder/.svn/text-base/DiracState.hpp.svn-base | 127 ------- src/decoder/.svn/text-base/Diracdec.cpp.svn-base | 247 -------------- src/decoder/.svn/text-base/Diracdec.hpp.svn-base | 107 ------ src/decoder/.svn/text-base/FileReader.cpp.svn-base | 109 ------ src/decoder/.svn/text-base/FileReader.hpp.svn-base | 97 ------ src/decoder/.svn/text-base/FileWriter.cpp.svn-base | 86 ----- src/decoder/.svn/text-base/FileWriter.hpp.svn-base | 80 ----- .../.svn/text-base/FrameManagerImpl.hpp.svn-base | 163 --------- .../.svn/text-base/FrameManagerMaker.hpp.svn-base | 64 ---- src/decoder/.svn/text-base/IDecoder.cpp.svn-base | 153 --------- src/decoder/.svn/text-base/IDecoder.hpp.svn-base | 138 -------- .../.svn/text-base/IFrameManager.cpp.svn-base | 68 ---- .../.svn/text-base/IFrameManager.hpp.svn-base | 82 ----- .../text-base/IFrameMemoryManager.hpp.svn-base | 160 --------- src/decoder/.svn/text-base/IWriter.hpp.svn-base | 117 ------- src/decoder/.svn/text-base/Makefile.am.svn-base | 47 --- src/decoder/.svn/text-base/SchroState.cpp.svn-base | 183 ---------- src/decoder/.svn/text-base/SchroState.hpp.svn-base | 136 -------- src/decoder/.svn/text-base/Schrodec.cpp.svn-base | 315 ----------------- src/decoder/.svn/text-base/Schrodec.hpp.svn-base | 123 ------- src/decoder/DefaultFrameMemoryManager.cpp | 63 ---- src/decoder/DefaultFrameMemoryManager.hpp | 59 ---- src/decoder/DiracState.cpp | 182 ---------- src/decoder/DiracState.hpp | 127 ------- src/decoder/Diracdec.cpp | 247 -------------- src/decoder/Diracdec.hpp | 107 ------ src/decoder/FileReader.cpp | 109 ------ src/decoder/FileReader.hpp | 97 ------ src/decoder/FileWriter.cpp | 86 ----- src/decoder/FileWriter.hpp | 80 ----- src/decoder/FrameManagerImpl.hpp | 163 --------- src/decoder/FrameManagerMaker.hpp | 64 ---- src/decoder/IDecoder.cpp | 153 --------- src/decoder/IDecoder.hpp | 138 -------- src/decoder/IFrameManager.cpp | 68 ---- src/decoder/IFrameManager.hpp | 82 ----- src/decoder/IFrameMemoryManager.hpp | 160 --------- src/decoder/IWriter.hpp | 117 ------- src/decoder/Makefile.am | 47 --- src/decoder/SchroState.cpp | 183 ---------- src/decoder/SchroState.hpp | 136 -------- src/decoder/Schrodec.cpp | 315 ----------------- src/decoder/Schrodec.hpp | 123 ------- src/examples/.svn/entries | 52 --- src/examples/.svn/format | 1 - src/examples/.svn/text-base/Makefile.am.svn-base | 15 - src/examples/.svn/text-base/decoder.cc.svn-base | 228 ------------- src/examples/Makefile.am | 15 - src/examples/decoder.cc | 228 ------------- src/parser/.svn/entries | 208 ------------ src/parser/.svn/format | 1 - src/parser/.svn/prop-base/AccessUnit.hpp.svn-base | 5 - src/parser/.svn/prop-base/IInput.hpp.svn-base | 5 - src/parser/.svn/prop-base/Parser.hpp.svn-base | 5 - .../.svn/prop-base/StreamReader.hpp.svn-base | 5 - src/parser/.svn/prop-base/buffer.cpp.svn-base | 5 - src/parser/.svn/prop-base/buffer.hpp.svn-base | 5 - src/parser/.svn/prop-base/parse_info.cpp.svn-base | 5 - src/parser/.svn/prop-base/parse_info.hpp.svn-base | 5 - src/parser/.svn/prop-base/parser.cpp.svn-base | 5 - src/parser/.svn/prop-base/parser.h.svn-base | 5 - src/parser/.svn/prop-base/scanner.cpp.svn-base | 5 - src/parser/.svn/prop-base/scanner.hpp.svn-base | 5 - src/parser/.svn/text-base/AccessUnit.hpp.svn-base | 171 ---------- src/parser/.svn/text-base/IInput.hpp.svn-base | 96 ------ src/parser/.svn/text-base/Makefile.am.svn-base | 33 -- src/parser/.svn/text-base/Parser.hpp.svn-base | 308 ----------------- .../.svn/text-base/StreamReader.hpp.svn-base | 235 ------------- src/parser/.svn/text-base/buffer.cpp.svn-base | 130 ------- src/parser/.svn/text-base/buffer.hpp.svn-base | 118 ------- src/parser/.svn/text-base/parse_info.cpp.svn-base | 342 ------------------- src/parser/.svn/text-base/parse_info.hpp.svn-base | 161 --------- src/parser/.svn/text-base/parser.cpp.svn-base | 376 --------------------- src/parser/.svn/text-base/parser.h.svn-base | 235 ------------- src/parser/.svn/text-base/scanner.cpp.svn-base | 227 ------------- src/parser/.svn/text-base/scanner.hpp.svn-base | 121 ------- src/parser/.svn/text-base/version.h.svn-base | 45 --- src/parser/Makefile.am | 4 +- src/unittest/DiracdecTest.cpp | 134 -------- src/unittest/DiracdecTest.hpp | 79 ----- src/unittest/FileReaderTest.cpp | 121 ------- src/unittest/FileReaderTest.hpp | 80 ----- src/unittest/FileWriterTest.cpp | 103 ------ src/unittest/FileWriterTest.hpp | 71 ---- src/unittest/Makefile.am | 26 +- src/unittest/SchrodecTest.cpp | 138 -------- src/unittest/SchrodecTest.hpp | 75 ---- 98 files changed, 27 insertions(+), 10439 deletions(-) delete mode 100644 src/decoder/.svn/entries delete mode 100644 src/decoder/.svn/format delete mode 100644 src/decoder/.svn/text-base/DefaultFrameMemoryManager.cpp.svn-base delete mode 100644 src/decoder/.svn/text-base/DefaultFrameMemoryManager.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/DiracState.cpp.svn-base delete mode 100644 src/decoder/.svn/text-base/DiracState.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/Diracdec.cpp.svn-base delete mode 100644 src/decoder/.svn/text-base/Diracdec.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/FileReader.cpp.svn-base delete mode 100644 src/decoder/.svn/text-base/FileReader.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/FileWriter.cpp.svn-base delete mode 100644 src/decoder/.svn/text-base/FileWriter.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/FrameManagerImpl.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/FrameManagerMaker.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/IDecoder.cpp.svn-base delete mode 100644 src/decoder/.svn/text-base/IDecoder.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/IFrameManager.cpp.svn-base delete mode 100644 src/decoder/.svn/text-base/IFrameManager.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/IFrameMemoryManager.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/IWriter.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/Makefile.am.svn-base delete mode 100644 src/decoder/.svn/text-base/SchroState.cpp.svn-base delete mode 100644 src/decoder/.svn/text-base/SchroState.hpp.svn-base delete mode 100644 src/decoder/.svn/text-base/Schrodec.cpp.svn-base delete mode 100644 src/decoder/.svn/text-base/Schrodec.hpp.svn-base delete mode 100644 src/decoder/DefaultFrameMemoryManager.cpp delete mode 100644 src/decoder/DefaultFrameMemoryManager.hpp delete mode 100644 src/decoder/DiracState.cpp delete mode 100644 src/decoder/DiracState.hpp delete mode 100644 src/decoder/Diracdec.cpp delete mode 100644 src/decoder/Diracdec.hpp delete mode 100644 src/decoder/FileReader.cpp delete mode 100644 src/decoder/FileReader.hpp delete mode 100644 src/decoder/FileWriter.cpp delete mode 100644 src/decoder/FileWriter.hpp delete mode 100644 src/decoder/FrameManagerImpl.hpp delete mode 100644 src/decoder/FrameManagerMaker.hpp delete mode 100644 src/decoder/IDecoder.cpp delete mode 100644 src/decoder/IDecoder.hpp delete mode 100644 src/decoder/IFrameManager.cpp delete mode 100644 src/decoder/IFrameManager.hpp delete mode 100644 src/decoder/IFrameMemoryManager.hpp delete mode 100644 src/decoder/IWriter.hpp delete mode 100644 src/decoder/Makefile.am delete mode 100644 src/decoder/SchroState.cpp delete mode 100644 src/decoder/SchroState.hpp delete mode 100644 src/decoder/Schrodec.cpp delete mode 100644 src/decoder/Schrodec.hpp delete mode 100644 src/examples/.svn/entries delete mode 100644 src/examples/.svn/format delete mode 100644 src/examples/.svn/text-base/Makefile.am.svn-base delete mode 100644 src/examples/.svn/text-base/decoder.cc.svn-base delete mode 100644 src/examples/Makefile.am delete mode 100644 src/examples/decoder.cc delete mode 100644 src/parser/.svn/entries delete mode 100644 src/parser/.svn/format delete mode 100644 src/parser/.svn/prop-base/AccessUnit.hpp.svn-base delete mode 100644 src/parser/.svn/prop-base/IInput.hpp.svn-base delete mode 100644 src/parser/.svn/prop-base/Parser.hpp.svn-base delete mode 100644 src/parser/.svn/prop-base/StreamReader.hpp.svn-base delete mode 100644 src/parser/.svn/prop-base/buffer.cpp.svn-base delete mode 100644 src/parser/.svn/prop-base/buffer.hpp.svn-base delete mode 100644 src/parser/.svn/prop-base/parse_info.cpp.svn-base delete mode 100644 src/parser/.svn/prop-base/parse_info.hpp.svn-base delete mode 100644 src/parser/.svn/prop-base/parser.cpp.svn-base delete mode 100644 src/parser/.svn/prop-base/parser.h.svn-base delete mode 100644 src/parser/.svn/prop-base/scanner.cpp.svn-base delete mode 100644 src/parser/.svn/prop-base/scanner.hpp.svn-base delete mode 100644 src/parser/.svn/text-base/AccessUnit.hpp.svn-base delete mode 100644 src/parser/.svn/text-base/IInput.hpp.svn-base delete mode 100644 src/parser/.svn/text-base/Makefile.am.svn-base delete mode 100644 src/parser/.svn/text-base/Parser.hpp.svn-base delete mode 100644 src/parser/.svn/text-base/StreamReader.hpp.svn-base delete mode 100644 src/parser/.svn/text-base/buffer.cpp.svn-base delete mode 100644 src/parser/.svn/text-base/buffer.hpp.svn-base delete mode 100644 src/parser/.svn/text-base/parse_info.cpp.svn-base delete mode 100644 src/parser/.svn/text-base/parse_info.hpp.svn-base delete mode 100644 src/parser/.svn/text-base/parser.cpp.svn-base delete mode 100644 src/parser/.svn/text-base/parser.h.svn-base delete mode 100644 src/parser/.svn/text-base/scanner.cpp.svn-base delete mode 100644 src/parser/.svn/text-base/scanner.hpp.svn-base delete mode 100644 src/parser/.svn/text-base/version.h.svn-base delete mode 100644 src/unittest/DiracdecTest.cpp delete mode 100644 src/unittest/DiracdecTest.hpp delete mode 100644 src/unittest/FileReaderTest.cpp delete mode 100644 src/unittest/FileReaderTest.hpp delete mode 100644 src/unittest/FileWriterTest.cpp delete mode 100644 src/unittest/FileWriterTest.hpp delete mode 100644 src/unittest/SchrodecTest.cpp delete mode 100644 src/unittest/SchrodecTest.hpp diff --git a/INSTALL b/INSTALL index 5458714..d3c5b40 100644 --- a/INSTALL +++ b/INSTALL @@ -2,7 +2,7 @@ Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, -2006 Free Software Foundation, Inc. +2006, 2007 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. @@ -67,6 +67,9 @@ The simplest way to compile this package is: all sorts of other programs in order to regenerate files that came with the distribution. + 6. Often, you can also type `make uninstall' to remove the installed + files again. + Compilers and Options ===================== diff --git a/configure.ac b/configure.ac index d691186..6eac008 100644 --- a/configure.ac +++ b/configure.ac @@ -16,46 +16,6 @@ AC_LIBTOOL_WIN32_DLL AM_PROG_LIBTOOL AC_SYS_LARGEFILE -############################ -# Schroedinger -############################ -AC_ARG_ENABLE(schroedinger, AS_HELP_STRING([--disable-schro],[disable schroedinger support (default=enabled)])) -if test "x$enable_schroedinger" != xno -then - SCHRO_VER="1.0" - PKG_CHECK_MODULES(SCHROEDINGER, schroedinger-1.0 >= $SCHRO_VER, HAVE_SCHRO=yes, HAVE_SCHRO=no) - if test "x${HAVE_SCHRO}" != xyes ; then - AC_MSG_ERROR([schroedinger-1.0 >= $SCHRO_VER is required]) - fi - AC_DEFINE(HAVE_SCHRO, 1, [Compile in support for Schroedinger libraries]) -else - HAVE_GST=no -fi - -AM_CONDITIONAL(HAVE_SCHRO, test "x$HAVE_SCHRO" = "xyes") -AC_SUBST(SCHROEDINGER_CFLAGS) -AC_SUBST(SCHROEDINGER_LIBS) - -############################ -# Dirac -############################ -AC_ARG_ENABLE(dirac, AS_HELP_STRING([--disable-dirac],[disable dirac support (default=enabled)])) -if test "x$enable_dirac" != xno -then - DIRAC_VER="0.9.1" - PKG_CHECK_MODULES(DIRAC, dirac >= $DIRAC_VER, HAVE_DIRAC=yes, HAVE_DIRAC=no) - if test "x${HAVE_DIRAC}" != xyes ; then - AC_MSG_ERROR([dirac-0.9.1 >= $DIRAC_VER is required]) - fi - AC_DEFINE(HAVE_DIRAC, 1, [Compile in support for Dirac libraries]) -else - HAVE_DIRAC=no -fi - -AM_CONDITIONAL(HAVE_DIRAC, test "x$HAVE_DIRAC" = "xyes") -AC_SUBST(DIRAC_CFLAGS) -AC_SUBST(DIRAC_LIBS) - dnl ----------------------------------------------- dnl Check if static libraries to be used on non-Windows platforms dnl ----------------------------------------------- @@ -89,8 +49,6 @@ AC_CONFIG_FILES([ Makefile \ src/Makefile \ src/common/Makefile \ src/parser/Makefile \ - src/examples/Makefile \ - src/decoder/Makefile \ src/unittest/Makefile \ ]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 497c1d9..b186967 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = common parser decoder examples unittest +SUBDIRS = common parser unittest diff --git a/src/common/dirac.h b/src/common/dirac.h index a0c3645..060118a 100644 --- a/src/common/dirac.h +++ b/src/common/dirac.h @@ -79,37 +79,6 @@ typedef unsigned int uint32; #endif -#if 0 - -#ifdef DIRAC_COMPILER_IS_GNUC -# include -#endif - -/* define base types for the entire Dirac code base. - the base types will be defined in a compiler/platform specific - header. I think we only need to do this for integer types - (ideally I'd like to use C99 types but they are not ISO C++ types - yet) -*/ -typedef DIRAC_SI08_BASE_TYPE int8; -typedef DIRAC_SI08_BASE_TYPE sint8; -typedef DIRAC_UI08_BASE_TYPE uint8; - -typedef DIRAC_SI16_BASE_TYPE int16; -typedef DIRAC_SI16_BASE_TYPE sint16; -typedef DIRAC_UI16_BASE_TYPE uint16; - -typedef DIRAC_SI32_BASE_TYPE int32; -typedef DIRAC_SI32_BASE_TYPE sint32; -typedef DIRAC_UI32_BASE_TYPE uint32; - -#ifdef DIRAC_64BIT_SUPPORT - typedef DIRAC_SI64_BASE_TYPE int64; - typedef DIRAC_SI64_BASE_TYPE sint64; - typedef DIRAC_UI64_BASE_TYPE uint64; -#endif /* DIRAC_64BIT_SUPPORT */ - -#endif - /* define assert and static asserts for the entire Dirac codebase */ #ifdef __cplusplus # include diff --git a/src/common/util.cpp b/src/common/util.cpp index e362f6f..677e54b 100644 --- a/src/common/util.cpp +++ b/src/common/util.cpp @@ -47,7 +47,7 @@ namespace dirac { readFourBytes ( uint8 const* cursor ) { DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - + uint32 value = static_cast ( *cursor ); for ( int i=1; i<4; ++i ) { value <<= 8; @@ -55,7 +55,7 @@ namespace dirac { } return value; } - + NonCopyable::NonCopyable() {} NonCopyable::~NonCopyable() {} } diff --git a/src/common/util.hpp b/src/common/util.hpp index 3fa9cc3..8c00688 100644 --- a/src/common/util.hpp +++ b/src/common/util.hpp @@ -42,17 +42,17 @@ namespace dirac { - + /* help check the state of the passed object. It requires T to have a - method called checkValidity with signature: void (*) () const + method called checkValidity with signature: void (*) () const By having checkValidity invoked in both constructor and destructor we can ensure that the state of an object is checked going into and before coming out of a public method */ template < typename T > struct ValidityChecker { - ValidityChecker ( T const& obj ) - : object_ (obj) + ValidityChecker ( T const& obj ) + : object_ (obj) { object_.checkValidity(); } @@ -63,40 +63,40 @@ namespace dirac private: T const& object_; }; - + /* reads 4 bytes from a buffer, big endian */ uint32 readFourBytes ( uint8 const* cursor ); - + template struct constant_value_type { typedef T value_type; static const T value = val; }; - + typedef constant_value_type true_type; typedef constant_value_type false_type; - + //! base class used to prevent user-defined objects from allwoing compiler //! generated methods (copy construction and assignment) //! inherit privately to use class NonCopyable { typedef NonCopyable class_type; - + protected: NonCopyable(); ~NonCopyable(); - + // compiler generated methods are not allowed NonCopyable ( class_type const& ); class_type& operator= ( class_type const& ); }; - - - - + + + + } /* dirac */ diff --git a/src/decoder/.svn/entries b/src/decoder/.svn/entries deleted file mode 100644 index 3563e7e..0000000 --- a/src/decoder/.svn/entries +++ /dev/null @@ -1,304 +0,0 @@ -8 - -dir -82 -file:///project/compression/andrea/svnrepos/dirac1.0/trunk/src/decoder -file:///project/compression/andrea/svnrepos - - - -2008-03-11T16:18:48.736334Z -76 -andrea - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -1eccbc7e-7240-0410-8f13-87e4ac67b0a8 - -Diracdec.cpp -file - - - - -2008-03-19T17:17:08.000000Z -28f70234e951f7b160efbb0d9160412a -2008-03-04T13:16:25.980552Z -67 -andrea - -IFrameManager.cpp -file - - - - -2008-03-19T17:17:08.000000Z -4b6dddd4314a3ef6b30431ca969c436a -2008-03-07T11:49:15.140736Z -74 -andrea - -Schrodec.hpp -file - - - - -2008-03-19T17:17:08.000000Z -bea6182354e282eea93c85c38cdb1181 -2008-02-23T21:10:16.138357Z -60 -andrea - -FileReader.cpp -file - - - - -2008-03-19T17:17:08.000000Z -b26c4a1a2336e36c642cefa1dfe94a10 -2008-03-04T13:16:25.980552Z -67 -andrea - -Diracdec.hpp -file - - - - -2008-03-19T17:17:08.000000Z -55a2fc8a529d87a733a23ad108d9b81e -2008-02-24T22:02:49.507637Z -61 -andrea - -IFrameManager.hpp -file - - - - -2008-03-19T17:17:08.000000Z -bcf8337c8d53968c2aa680790207cc95 -2008-03-07T11:49:15.140736Z -74 -andrea - -FileReader.hpp -file - - - - -2008-03-19T17:17:08.000000Z -9b700f0dede4a257088840497cce1a46 -2008-02-23T21:10:16.138357Z -60 -andrea - -FrameManagerMaker.hpp -file - - - - -2008-03-19T17:17:09.000000Z -c7cb9fef566dfda7e3010300015403b6 -2008-02-23T21:10:16.138357Z -60 -andrea - -FileWriter.cpp -file - - - - -2008-03-19T17:17:09.000000Z -6189059ef1d755c1c6ad84eca787c664 -2008-03-04T13:16:25.980552Z -67 -andrea - -FrameManagerImpl.hpp -file - - - - -2008-03-19T17:17:09.000000Z -0662a154b1292e0373f705ac93033122 -2008-03-07T15:04:16.331725Z -75 -andrea - -IDecoder.cpp -file - - - - -2008-03-19T17:17:09.000000Z -930355dcd2da2ca53a56cb1092ee33a7 -2008-03-04T13:16:25.980552Z -67 -andrea - -SchroState.cpp -file - - - - -2008-03-19T17:17:09.000000Z -accbde315a0b36eccafe2738873cd99a -2008-03-04T13:16:25.980552Z -67 -andrea - -FileWriter.hpp -file - - - - -2008-03-19T17:17:09.000000Z -1eace16dad7b5a01e36dc71ab79629ff -2008-02-23T21:10:16.138357Z -60 -andrea - -DiracState.cpp -file - - - - -2008-03-19T17:17:09.000000Z -c5f7c34f5a9268eaed59e2b450928be7 -2008-03-04T13:16:25.980552Z -67 -andrea - -IDecoder.hpp -file - - - - -2008-03-19T17:17:09.000000Z -ec988a729b7a5bedd4c1ac54a91786b7 -2008-02-23T21:10:16.138357Z -60 -andrea - -DefaultFrameMemoryManager.cpp -file - - - - -2008-03-19T17:17:09.000000Z -0beef7d1537a261b710291098dd7f5d0 -2008-03-07T15:04:16.331725Z -75 -andrea - -SchroState.hpp -file - - - - -2008-03-19T17:17:09.000000Z -65a7e32902e166b8f52836a53edd3fe3 -2008-02-23T21:10:16.138357Z -60 -andrea - -DiracState.hpp -file - - - - -2008-03-19T17:17:10.000000Z -8a55fb94fb49e944ac66dff35de83e81 -2008-02-24T22:02:49.507637Z -61 -andrea - -DefaultFrameMemoryManager.hpp -file - - - - -2008-03-19T17:17:10.000000Z -2c183a807ce9f5ec3bdad38485156240 -2008-03-07T11:49:15.140736Z -74 -andrea - -Makefile.am -file - - - - -2008-03-19T17:17:10.000000Z -759d5caa32de970cf12e3d1be397ccfe -2008-03-11T16:18:48.736334Z -76 -andrea - -IWriter.hpp -file - - - - -2008-03-19T17:17:10.000000Z -1da94919d079f6c38c0e0fc61319b42d -2008-03-07T11:49:15.140736Z -74 -andrea - -Schrodec.cpp -file - - - - -2008-03-19T17:17:10.000000Z -b3a91b935fcbb58c4650c0293e0e6d1e -2008-03-07T11:49:15.140736Z -74 -andrea - -IFrameMemoryManager.hpp -file - - - - -2008-03-19T17:17:10.000000Z -38533f45cf4ad8169c29a10d22d2ded8 -2008-03-07T15:04:16.331725Z -75 -andrea - diff --git a/src/decoder/.svn/format b/src/decoder/.svn/format deleted file mode 100644 index 45a4fb7..0000000 --- a/src/decoder/.svn/format +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/src/decoder/.svn/text-base/DefaultFrameMemoryManager.cpp.svn-base b/src/decoder/.svn/text-base/DefaultFrameMemoryManager.cpp.svn-base deleted file mode 100644 index 73bac69..0000000 --- a/src/decoder/.svn/text-base/DefaultFrameMemoryManager.cpp.svn-base +++ /dev/null @@ -1,63 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - - -using namespace ::dirac::decoder; - -typedef DefaultFrameMemoryManager::Buffer Buffer; -typedef DefaultFrameMemoryManager::size_type size_type; - -Buffer -DefaultFrameMemoryManager::allocateFrame ( size_type bufferSize ) -{ - DIRAC_MESSAGE_ASSERT ( "buffer size cannot be null", 0 != bufferSize ); - return new value_type [ bufferSize ]; -} - - -void -DefaultFrameMemoryManager::releaseFrame ( Buffer buffer ) -{ - delete [] buffer; -} - diff --git a/src/decoder/.svn/text-base/DefaultFrameMemoryManager.hpp.svn-base b/src/decoder/.svn/text-base/DefaultFrameMemoryManager.hpp.svn-base deleted file mode 100644 index 92a6a81..0000000 --- a/src/decoder/.svn/text-base/DefaultFrameMemoryManager.hpp.svn-base +++ /dev/null @@ -1,59 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _DEFAULTFRAMEMEMORYMANAGER_HPP_ -#define _DEFAULTFRAMEMEMORYMANAGER_HPP_ - -#include - -#include - -namespace dirac -{ -namespace decoder -{ - class DefaultFrameMemoryManager : public IFrameMemoryManager - { - virtual Buffer allocateFrame ( size_type bufferSize ); - virtual void releaseFrame ( Buffer buffer ); - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _DEFAULTFRAMEMEMORYMANAGER_HPP_ */ diff --git a/src/decoder/.svn/text-base/DiracState.cpp.svn-base b/src/decoder/.svn/text-base/DiracState.cpp.svn-base deleted file mode 100644 index a4614dd..0000000 --- a/src/decoder/.svn/text-base/DiracState.cpp.svn-base +++ /dev/null @@ -1,182 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -#include - -namespace dirac -{ -namespace decoder -{ - IDecoderState* - makeDiracState ( Diracdec& diracdec, int diracState ) - { - DIRAC_MESSAGE_ASSERT ( "state must be one of the possible dirac state values" - , diracState == STATE_BUFFER - || diracState == STATE_SEQUENCE - || diracState == STATE_SEQUENCE_END - || diracState == STATE_PICTURE_AVAIL - || diracState == STATE_INVALID ); - switch ( diracState ) { - case ( STATE_BUFFER ) : { - return new DiracNeedInput ( diracdec ); - // break; - } - case ( STATE_SEQUENCE ) : { - return new DiracDoNothing; - // break; - } - case ( STATE_SEQUENCE_END ) : { - return new DiracEndOfSequence; - // break; - } - case ( STATE_PICTURE_AVAIL ) : { - return new DiracFrameReady ( diracdec ); - // break; - } - case ( STATE_INVALID ) : { - return new DiracError; - // break; - } - default : { - return new DiracNull; - // break; - } - } - } -} /* decoder */ - -} /* dirac */ - -using namespace ::dirac::decoder; - -DiracNeedInput::DiracNeedInput ( Diracdec& diracdec ) -: diracdec_ ( diracdec ) {} - -void -DiracNeedInput::run() -{ - diracdec_.pushBits(); -} - -bool -DiracNeedInput::endOfSequence() const -{ - return diracdec_.eos_; -} - -DiracFrameReady::DiracFrameReady ( Diracdec& diracdec ) -: diracdec_ ( diracdec ) {} - -void -DiracFrameReady::run() -{ - diracdec_.pullFrameAndWrite(); -} - -bool -DiracFrameReady::endOfSequence() const -{ - return false; -} - - -DiracEndOfSequence::DiracEndOfSequence() {} - -void -DiracEndOfSequence::run() -{ - // do nothing -} - -bool -DiracEndOfSequence::endOfSequence() const -{ - return true; -} - -DiracError::DiracError() {} - -void -DiracError::run() -{ - throw DecoderException ( "Dirac decoder error - error while decoding stream" ); -} - -bool -DiracError::endOfSequence() const -{ - return false; -} - -DiracNull::DiracNull() {} - -void -DiracNull::run() -{ - throw DecoderException ( "programming error!" ); -} - -bool -DiracNull::endOfSequence() const -{ - return false; -} - -DiracDoNothing::DiracDoNothing() {} - -void -DiracDoNothing::run() -{ - // do nothing -} - -bool -DiracDoNothing::endOfSequence() const -{ - return false; -} - - - diff --git a/src/decoder/.svn/text-base/DiracState.hpp.svn-base b/src/decoder/.svn/text-base/DiracState.hpp.svn-base deleted file mode 100644 index 0466927..0000000 --- a/src/decoder/.svn/text-base/DiracState.hpp.svn-base +++ /dev/null @@ -1,127 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _DIRACSTATE_HPP_ -#define _DIRACSTATE_HPP_ - -#include - -#include - -namespace dirac -{ -namespace decoder -{ - class Diracdec; - - //! factory method used to generate state objects - //! - //! \a diracdec the dirac decoder associated with the dirac state - //! \a diracState the state value returned by dirac_parse - //! \r the dirac state object created by the factory method - IDecoderState* makeDiracState ( Diracdec& diracdec, int diracState ); - - class DiracNeedInput : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracNeedInput ( Diracdec& diracdec ); - - virtual void run(); - virtual bool endOfSequence() const; - - Diracdec& diracdec_; - }; - - class DiracFrameReady : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracFrameReady ( Diracdec& diracdec ); - - virtual void run(); - virtual bool endOfSequence() const; - - Diracdec& diracdec_; - }; - - class DiracEndOfSequence : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracEndOfSequence(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class DiracError : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracError(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class DiracNull : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracNull(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class DiracDoNothing : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracDoNothing(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - -} /* decoder */ - -} /* dirac */ - - -#endif /* _DIRACSTATE_HPP_ */ diff --git a/src/decoder/.svn/text-base/Diracdec.cpp.svn-base b/src/decoder/.svn/text-base/Diracdec.cpp.svn-base deleted file mode 100644 index eec7656..0000000 --- a/src/decoder/.svn/text-base/Diracdec.cpp.svn-base +++ /dev/null @@ -1,247 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - - -using namespace ::dirac::decoder; -using ::dirac::parser_project::AccessUnit; - -Diracdec::Diracdec ( IDecoder::ParserAutoPtr parser - , IDecoder::FrameManagerAutoPtr manager ) -: IDecoder ( parser, manager ), numberOfDecodedFrames_ ( 0 ) -, canPushBits_ ( true ), eos_ ( false ) -{ - yuv_[0] = yuv_[1] = yuv_[2] = static_cast ( 0 ); - initDirac(); - fetchSequenceHeader(); - setFrame(); -} - -Diracdec::~Diracdec() -{ - delete [] yuv_[0]; -} - -void -Diracdec::initDirac() -{ - const int VERBOSE_MODE = 0; // set to 1 if you wish to log messages to stdout - DecoderSharedPtr tmp ( dirac_decoder_init ( VERBOSE_MODE ) - , dirac_decoder_close ); - if ( !tmp.get() ) { - throw DecoderException ( "failed to create dirac decoder" ); - } - decoder_.swap ( tmp ); -} - -void -Diracdec::fetchSequenceHeader() -{ - AccessUnit au; - if ( !parser_->getNextSequenceHeader ( au ) || au.empty() ) { - throw DecoderException ( "Dirac decoder: failed to parser sequence header" ); - } - dirac_buffer ( decoder_.get(), const_cast ( au.begin() ) - , const_cast ( au.end() ) ); - if ( !parser_->moveCursorFwd() ) { - throw DecoderException ( "Dirac decoder: failed to parse access unit" ); - } - if ( !parser_->getNextAccessUnit ( au ) || au.empty() ) { - throw DecoderException ( "Dirac decoder: failed to parse access unit" ); - } - dirac_buffer ( decoder_.get(), const_cast ( au.begin() ) - , const_cast ( au.end() ) ); - // dirac_buffer ( decoder_.get(), aux, aux + 16 ); // FIXME - if ( STATE_SEQUENCE != dirac_parse ( decoder_.get() ) ) { - throw DecoderException ( "Dirac decoder: failed to decode sequence header" ); - } -} - -void -Diracdec::resetDecoder() -{ - delete [] yuv_[0]; - canPushBits_ = true; - eos_ = false; - numberOfDecodedFrames_ = 0; - decoder_.reset(); - initDirac(); - fetchSequenceHeader(); - setFrame(); -} - -//! push an access unit into dirac's input buffer -//! \r true if successful, false if end of stream -void -Diracdec::pushBits() -{ - DIRAC_MESSAGE_ASSERT ( "parser and decoder cannot be null", 0 != parser_.get() - && 0 != decoder_.get() ); - AccessUnit au; - if ( parser_->getNextAccessUnit ( au ) ) { - if ( canPushBits_ ) { - dirac_buffer ( decoder_.get(), const_cast ( au.begin() ) - , const_cast ( au.end() ) ); - } - if ( au.isLastEndOfSequence() || !parser_->moveCursorFwd() ) { - if ( !canPushBits_ ) eos_ = true; - canPushBits_ = false; - } - } - else { - if ( !canPushBits_ ) eos_ = true; - else canPushBits_ = false; - } -} - -void -Diracdec::setFrame() -{ - DIRAC_MESSAGE_ASSERT ( "parser and decoder cannot be null" - , 0 != parser_.get() && 0 != decoder_.get() ); - size_type bufferSize = getFrameBufferSize ( frameWidth(), frameHeight() - , chromaFormat() ); - if ( !bufferSize ) - throw DecoderException ( "failed to create frame buffer" ); - yuv_[0] = new value_type [ bufferSize ]; - yuv_[1] = yuv_[0] + frameWidth() * frameHeight(); - size_type chromaWidth = decoder_->src_params.chroma_width, - chromaHeight = decoder_->src_params.chroma_height; - yuv_[2] = yuv_[1] + chromaWidth * chromaHeight; - dirac_set_buf ( decoder_.get(), yuv_, NULL ); -} - -void -Diracdec::pullFrameAndWrite() -{ - DIRAC_MESSAGE_ASSERT ( "decoder and frame manager cannot be null" - , 0 != decoder_.get() && 0 != manager_.get() ); - if ( !decoder_->fbuf || !decoder_->fbuf->buf[0] ) { - throw - DecoderException ( "Dirac decoder: invalid frame buffer in dirac decoder" ); - } - ++numberOfDecodedFrames_; - writeFrame(); -} - -void -Diracdec::writeFrame() -{ - size_type count = getFrameBufferSize ( frameWidth(), frameHeight() - , chromaFormat() ); - // this is a safe cast - pointer buffer = const_cast ( manager_->allocate ( count ) ); - memcpy(static_cast ( buffer ), yuv_[0], count ); - manager_->write ( buffer, count ); - manager_->release ( buffer ); -} - -IDecoder::size_type -Diracdec::getFrameWidth() const -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - return decoder_->src_params.width; -} - -IDecoder::size_type -Diracdec::getFrameHeight() const -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - return decoder_->src_params.height; -} - -::dirac::decoder::ChromaFormat -Diracdec::getChromaFormat() const -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - switch ( decoder_->src_params.chroma ) { - case ( format444 ) : - return CHROMA_444; - // break; - case ( format422 ) : - return CHROMA_422; - // break; - case ( format420 ) : - return CHROMA_420; - // break; - default : - return UNDEFINED; - // break; - } -} - -void -Diracdec::runDecoder() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - std::auto_ptr decoderState; - do { - std::auto_ptr tmp ( getState() ); - decoderState = tmp; - decoderState->doNextAction(); - } while ( !decoderState->isEndOfSequence() ); -} - -IDecoder::size_type -Diracdec::numberOfFrames() const -{ - return numberOfDecodedFrames_; -} - -IDecoderState* -Diracdec::getDecoderState() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - return makeDiracState ( *this, dirac_parse ( decoder_.get() ) ); -} - -void -Diracdec::signOff() -{ - // do nothing -} - diff --git a/src/decoder/.svn/text-base/Diracdec.hpp.svn-base b/src/decoder/.svn/text-base/Diracdec.hpp.svn-base deleted file mode 100644 index ecd8ee9..0000000 --- a/src/decoder/.svn/text-base/Diracdec.hpp.svn-base +++ /dev/null @@ -1,107 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _DIRACDEC_HPP_ -#define _DIRACDEC_HPP_ - -#include - -#include - -#include - -namespace dirac -{ -namespace decoder -{ - class DiracNeedInput; - class DiracFrameReady; - class DiracError; - class DiracEndOfSequence; - class DiracNull; - class DiracDoNothing; - - class Diracdec : public IDecoder - { - friend class DiracNeedInput; - friend class DiracFrameReady; - friend class DiracError; - friend class DiracEndOfSequence; - friend class DiracNull; - friend class DoNothing; - - public: - typedef Diracdec class_type; - typedef std::tr1::shared_ptr DecoderSharedPtr; - - public: - Diracdec ( ParserAutoPtr parser, FrameManagerAutoPtr manager ); - virtual ~Diracdec(); - - private: - virtual void runDecoder(); - virtual IDecoderState* getDecoderState(); - virtual size_type numberOfFrames() const; - - virtual size_type getFrameWidth() const; - virtual size_type getFrameHeight() const; - virtual ChromaFormat getChromaFormat() const; - virtual void resetDecoder(); - - private: - void pushBits(); - void setFrame(); - void pullFrameAndWrite(); - void signOff(); - - void initDirac(); - void fetchSequenceHeader(); - void writeFrame(); - - private: - DecoderSharedPtr decoder_; - size_type numberOfDecodedFrames_; - pointer yuv_[3]; - bool canPushBits_; - bool eos_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _DIRACDEC_HPP_ */ diff --git a/src/decoder/.svn/text-base/FileReader.cpp.svn-base b/src/decoder/.svn/text-base/FileReader.cpp.svn-base deleted file mode 100644 index cbb5cbc..0000000 --- a/src/decoder/.svn/text-base/FileReader.cpp.svn-base +++ /dev/null @@ -1,109 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -using namespace ::dirac::decoder; - -FileReaderException::FileReaderException ( std::string const& message ) -: std::runtime_error ( message ) {} - -std::string FileReader::error_message_ = ""; - -FileReader::FileReader ( std::string const& filename ) -: IInput ( true ), str_ ( 0 ) -{ - if ( !filename.compare ( "-" ) ) { // pipe, can't rewind - bwdScan_ = false; - str_ = fopen ("/dev/stdin", "rb" ); - } - else { - str_ = fopen ( filename.c_str(), "rb" ); - } - if ( !str_ ) - { - error_message_ = "Error while opening " + filename; - throw FileReaderException ( error_message_ ); - } -} - -FileReader::~FileReader() -{ - if ( str_ ) fclose ( str_ ); -} - -bool -FileReader::available() const -{ - return str_ && !ferror ( str_ ) && !feof ( str_ ); -} - -FileReader::size_type -FileReader::readInput ( pointer begin, size_type count ) -{ - const size_type NO_DATA = 0; - if ( !available() ) return NO_DATA; - size_type bytesread = NO_DATA; - bytesread = fread ( static_cast ( begin ) - , sizeof ( value_type ), count, str_ ); - if ( ferror ( str_ ) ) return NO_DATA; - return bytesread; -} - - -bool -FileReader::rewindStream ( size_type count ) -{ - if ( !str_ || ferror ( str_ ) ) return false; - long pos = ftell ( str_ ); - if ( count > static_cast ( pos ) ) return false; - if ( fseek ( str_, -count, SEEK_CUR ) ) return false; - else return true; -} - -bool -FileReader::fullRewind() -{ - if ( !str_ || ferror ( str_ ) ) return false; - return ( !fseek ( str_, 0, SEEK_SET ) ); -} - - diff --git a/src/decoder/.svn/text-base/FileReader.hpp.svn-base b/src/decoder/.svn/text-base/FileReader.hpp.svn-base deleted file mode 100644 index 850af17..0000000 --- a/src/decoder/.svn/text-base/FileReader.hpp.svn-base +++ /dev/null @@ -1,97 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FILEREADER_HPP_ -#define _FILEREADER_HPP_ - -#include - -#include - -#include -#include -#include - - -namespace dirac -{ -namespace decoder -{ - class FileReaderException : public std::runtime_error - { - public: - FileReaderException ( std::string const& message ); - }; - - class FileReader : public parser_project::IInput - { - public: // type definitions - typedef FileReader class_type; // self - - typedef IInput::value_type value_type; - typedef IInput::size_type size_type; - typedef IInput::pointer pointer; - typedef IInput::const_pointer const_pointer; - - typedef FILE stream; - - public: // constructors - explicit FileReader ( std::string const& filename ); - virtual ~FileReader(); - private: // compiler generated methods are not allowed - FileReader ( class_type const& ); - class_type& operator= ( class_type const& ); - - private: // implementation of IInput virtual interface - virtual bool available() const; - - virtual size_type readInput ( pointer begin, size_type count ); - - virtual bool rewindStream ( size_type count ); - - virtual bool fullRewind(); - - private: // members - stream* str_; - static std::string error_message_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _FILEREADER_HPP_ */ diff --git a/src/decoder/.svn/text-base/FileWriter.cpp.svn-base b/src/decoder/.svn/text-base/FileWriter.cpp.svn-base deleted file mode 100644 index 3f05eea..0000000 --- a/src/decoder/.svn/text-base/FileWriter.cpp.svn-base +++ /dev/null @@ -1,86 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -using namespace ::dirac::decoder; - -FileWriterException::FileWriterException ( std::string const& message ) -: std::runtime_error ( message ) {} - -std::string FileWriter::error_message_ = ""; - - -FileWriter::FileWriter ( std::string const& filename ) -: str_ ( 0 ) -{ - if ( !filename.compare ( "-" ) ) { - str_ = fopen ( "/dev/stdin", "wb"); - } - else { - str_ = fopen ( filename.c_str(), "wb" ); - } - if ( !str_ ) { - error_message_ = "Error while opening " + filename; - throw FileWriterException ( error_message_ ); - } -} - -FileWriter::~FileWriter() -{ - if ( str_ ) fclose ( str_ ); -} - -bool -FileWriter::available() const -{ - return str_ && !ferror ( str_ ); -} - -bool -FileWriter::output ( IWriter<>::const_pointer begin - , IWriter<>::size_type count ) -{ - if ( !isAvailable() ) return false; - fwrite (begin, sizeof ( value_type ), count, str_ ); - return !ferror ( str_ ); -} - diff --git a/src/decoder/.svn/text-base/FileWriter.hpp.svn-base b/src/decoder/.svn/text-base/FileWriter.hpp.svn-base deleted file mode 100644 index 7bbdbbc..0000000 --- a/src/decoder/.svn/text-base/FileWriter.hpp.svn-base +++ /dev/null @@ -1,80 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FILEWRITER_HPP_ -#define _FILEWRITER_HPP_ - -#include - -#include - -#include -#include - -namespace dirac -{ -namespace decoder -{ - class FileWriterException : public std::runtime_error - { - public: - FileWriterException ( std::string const& message ); - }; - - class FileWriter : public IWriter<> - { - public: - typedef FILE stream; - - public: - explicit FileWriter ( std::string const& filename ); - virtual ~FileWriter(); - - private: - virtual bool available() const; - virtual bool output ( const_pointer begin, size_type count ); - - private: - stream* str_; - static std::string error_message_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _FILEWRITER_HPP_ */ diff --git a/src/decoder/.svn/text-base/FrameManagerImpl.hpp.svn-base b/src/decoder/.svn/text-base/FrameManagerImpl.hpp.svn-base deleted file mode 100644 index 1206a21..0000000 --- a/src/decoder/.svn/text-base/FrameManagerImpl.hpp.svn-base +++ /dev/null @@ -1,163 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FRAMEMANAGERIMPL_HPP_ -#define _FRAMEMANAGERIMPL_HPP_ - -#include -#include - -#include -#include - -namespace dirac -{ -namespace decoder -{ - template - IFrameManager* - makeFrameManager ( std::auto_ptr > - , std::auto_ptr > ); - - //! manager for cration, deletion and writing of frames generated by decoders - //! - //! The class is templated in a user's optional parameter. This parameter - //! is usually the object used by the user to manage the frames. This class - //! allows the user to feed the decoder the raw frame memory and the - //! associated object without the decoder having to worry about it. - //! It also allows the user to retrieve the memory buffer and associated - //! user's object once the decoder has pushed out a frame. - template - class FrameManagerImpl : public IFrameManager - { - friend IFrameManager* - makeFrameManager ( std::auto_ptr< IWriter > - , std::auto_ptr< IFrameMemoryManager >); - - public: - typedef typename std::auto_ptr< IWriter > WriterAutoPtr; - typedef typename std::auto_ptr< IFrameMemoryManager > - FrameMemMgrAutoPtr; - - private: - FrameManagerImpl ( WriterAutoPtr writer, FrameMemMgrAutoPtr manager ) - : writer_ ( writer ), manager_ ( manager ) {} - - public: - virtual ~FrameManagerImpl() {} - - private: - virtual bool writeFrame ( const_pointer buffer - , size_type bufferSize ) - { - DIRAC_MESSAGE_ASSERT ( "Buffer cannot be null", 0 != buffer ); - Priv* priv = - // this is a safe cast - manager_->retrievePrivateParameter ( const_cast ( buffer ) ); - return writer_->write ( buffer, bufferSize, priv ); - } - - virtual pointer allocateFrame ( size_type bufferSize ) - { - DIRAC_MESSAGE_ASSERT ( "buffer size cannot be null", 0 != bufferSize ); - return manager_->allocate ( bufferSize ); - } - - virtual void releaseFrame ( pointer buffer ) - { - manager_->release ( buffer ); - } - - private: - WriterAutoPtr writer_; - FrameMemMgrAutoPtr manager_; - }; - - template<> - class FrameManagerImpl : public IFrameManager - { - friend IFrameManager* - makeFrameManager ( std::auto_ptr< IWriter > - , std::auto_ptr< IFrameMemoryManager > ); - public: - typedef std::auto_ptr< IWriter > WriterAutoPtr; - typedef std::auto_ptr< IFrameMemoryManager > FrameMemMgrAutoPtr; - - private: - FrameManagerImpl ( WriterAutoPtr writer, FrameMemMgrAutoPtr manager ) - : writer_ ( writer ), manager_ ( manager ) {} - - public: - virtual ~FrameManagerImpl() {} - - private: - virtual bool writeFrame ( const_pointer buffer - , size_type bufferSize ) - { - DIRAC_MESSAGE_ASSERT ( "Buffer cannot be null", 0 != buffer ); - DIRAC_MESSAGE_ASSERT ( "Writer cannot be null", 0 != writer_.get() ); - - return writer_->write ( buffer, bufferSize ); - } - - virtual pointer allocateFrame ( size_type bufferSize ) - { - DIRAC_MESSAGE_ASSERT ( "Buffer size cannot be null", 0 != bufferSize ); - DIRAC_MESSAGE_ASSERT ( "frame manager cannot be null" - , 0 != manager_.get() ); - - return manager_->allocate ( bufferSize ); - } - - virtual void releaseFrame ( pointer buffer ) - { - DIRAC_MESSAGE_ASSERT ( "frame manager cannot be null" - , 0 != manager_.get() ); - - manager_->release ( buffer ); - } - - private: - WriterAutoPtr writer_; - FrameMemMgrAutoPtr manager_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _FRAMEMANAGERIMPL_HPP_ */ diff --git a/src/decoder/.svn/text-base/FrameManagerMaker.hpp.svn-base b/src/decoder/.svn/text-base/FrameManagerMaker.hpp.svn-base deleted file mode 100644 index 8b78460..0000000 --- a/src/decoder/.svn/text-base/FrameManagerMaker.hpp.svn-base +++ /dev/null @@ -1,64 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FRAMEMANAGERMAKER_HPP_ -#define _FRAMEMANAGERMAKER_HPP_ - -#include -#include -#include -#include - -namespace dirac -{ -namespace decoder -{ - //! factory method to create objects of type FrameManagerImpl - template - IFrameManager* - makeFrameManager ( std::auto_ptr > writer - , std::auto_ptr > manager ) - { - return new FrameManagerImpl ( writer, manager ); - } - -} /* decoder */ - -} /* dirac */ - - -#endif /* _FRAMEMANAGERMAKER_HPP_ */ diff --git a/src/decoder/.svn/text-base/IDecoder.cpp.svn-base b/src/decoder/.svn/text-base/IDecoder.cpp.svn-base deleted file mode 100644 index 246924f..0000000 --- a/src/decoder/.svn/text-base/IDecoder.cpp.svn-base +++ /dev/null @@ -1,153 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -using namespace ::dirac::decoder; - - -void -IDecoderState::doNextAction() -{ - run(); -} - -bool -IDecoderState::isEndOfSequence() const -{ - return endOfSequence(); -} - - -DecoderException::DecoderException ( std::string const& msg ) -: std::runtime_error ( msg ) {} - - -IDecoder::size_type -IDecoder::getFrameBufferSize ( int width, int height, ChromaFormat cf ) -{ - switch ( cf ) { - case ( CHROMA_444 ) : { - return width * height * 3; - // break; - } - case ( CHROMA_422 ) : { - return width * height * 2; - // break; - } - case ( CHROMA_420 ) : { - return ( width * height * 3 ) / 2; - // break; - } - default : { - throw DecoderException ( "Dirac decoder: invalid chroma format" ); - // break; - } - } -} - -IDecoder::IDecoder ( ParserAutoPtr parser, FrameManagerAutoPtr manager ) -: parser_ ( parser ), manager_ ( manager ) -{ - DIRAC_MESSAGE_ASSERT ( "parser and frame manager cannot be null" - , 0 != parser_.get() && 0 != manager_.get() ); -} - -IDecoder::~IDecoder() {} - - -IDecoder::ParserAutoPtr -IDecoder::releaseParser() -{ - return parser_; -} - -void -IDecoder::reacquireParser ( IDecoder::ParserAutoPtr parser ) -{ - if ( parser_.get() ) { - throw DecoderException ( "tried to set a parser over an existing one" ); - } - DIRAC_MESSAGE_ASSERT ( "parser cannot be null", 0 != parser.get() ); - parser_ = parser; - resetDecoder(); -} - - -void -IDecoder::decode() -{ - runDecoder(); -} - -IDecoderState* -IDecoder::getState() -{ - return getDecoderState(); -} - -IDecoder::size_type -IDecoder::numberOfDecodedFrames() const -{ - return numberOfFrames(); -} - -IDecoder::size_type -IDecoder::frameWidth() const -{ - return getFrameWidth(); -} - -IDecoder::size_type -IDecoder::frameHeight() const -{ - return getFrameHeight(); -} - -ChromaFormat -IDecoder::chromaFormat() const -{ - return getChromaFormat(); -} - - - diff --git a/src/decoder/.svn/text-base/IDecoder.hpp.svn-base b/src/decoder/.svn/text-base/IDecoder.hpp.svn-base deleted file mode 100644 index d766ff2..0000000 --- a/src/decoder/.svn/text-base/IDecoder.hpp.svn-base +++ /dev/null @@ -1,138 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _IDECODER_HPP_ -#define _IDECODER_HPP_ - -#include -#include - -#include -#include - -#include -#include -#include - -namespace dirac -{ -namespace decoder -{ - //! Abstract class containing the state of the decoder and its next action. - class IDecoderState : NonCopyable - { - public: - void doNextAction(); - bool isEndOfSequence() const; - - private: - virtual void run() =0; - virtual bool endOfSequence() const =0; - }; - - //! Exception for the Decoder hierarchy of classes - struct DecoderException : public std::runtime_error - { - DecoderException ( std::string const& msg ); - }; - - enum ChromaFormat { - //! Chroma format: 4-4-4 - CHROMA_444 - //! Chroma format: 4-2-2 - , CHROMA_422 - //! Chroma format: 4-2-0 - , CHROMA_420 - //! Invalid chroma format - , UNDEFINED - }; - - //! Generic interface for a Dirac decoder - class IDecoder : NonCopyable - { - public: - typedef IDecoder class_type; - typedef std::auto_ptr FrameManagerAutoPtr; - typedef std::auto_ptr ParserAutoPtr; - typedef parser::AccessUnit AU; - typedef AU::Buffer InputBuffer; - typedef size_t size_type; - typedef uint8 value_type; - typedef value_type* pointer; - typedef value_type const* const_pointer; - - public: - IDecoder ( ParserAutoPtr parser, FrameManagerAutoPtr manager ); - virtual ~IDecoder(); - - public: // main methods - ParserAutoPtr releaseParser(); - void reacquireParser ( ParserAutoPtr parser ); - - //! run the decoder autonomously, from beginning to end, if it can - //! it cannot be interrupted - void decode(); - IDecoderState* getState(); - - size_type numberOfDecodedFrames() const; - size_type frameWidth() const; - size_type frameHeight() const; - ChromaFormat chromaFormat() const; - static size_type getFrameBufferSize ( int widht - , int height - , ChromaFormat cf ); - - - private: - virtual void runDecoder() =0; - virtual IDecoderState* getDecoderState() =0; - virtual size_type numberOfFrames() const =0; - virtual void resetDecoder() =0; - virtual size_type getFrameWidth() const =0; - virtual size_type getFrameHeight() const =0; - virtual ChromaFormat getChromaFormat() const =0; - - protected: - ParserAutoPtr parser_; - FrameManagerAutoPtr manager_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _IDECODER_HPP_ */ diff --git a/src/decoder/.svn/text-base/IFrameManager.cpp.svn-base b/src/decoder/.svn/text-base/IFrameManager.cpp.svn-base deleted file mode 100644 index 7f6ad86..0000000 --- a/src/decoder/.svn/text-base/IFrameManager.cpp.svn-base +++ /dev/null @@ -1,68 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -using namespace ::dirac::decoder; - -IFrameManager::IFrameManager() {} - -IFrameManager::~IFrameManager() {} - -bool -IFrameManager::write ( IFrameManager::const_pointer buffer - , IFrameManager::size_type bufferSize ) -{ - return writeFrame ( buffer, bufferSize ); -} - -IFrameManager::pointer -IFrameManager::allocate ( IFrameManager::size_type bufferSize ) -{ - return allocateFrame ( bufferSize ); -} - -void -IFrameManager::release ( IFrameManager::pointer buffer ) -{ - releaseFrame ( buffer ); -} - diff --git a/src/decoder/.svn/text-base/IFrameManager.hpp.svn-base b/src/decoder/.svn/text-base/IFrameManager.hpp.svn-base deleted file mode 100644 index 46b2b28..0000000 --- a/src/decoder/.svn/text-base/IFrameManager.hpp.svn-base +++ /dev/null @@ -1,82 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _IFRAMEMANAGER_HPP_ -#define _IFRAMEMANAGER_HPP_ - -#include -#include -#include -#include - -#include - -namespace dirac -{ -namespace decoder -{ - class IFrameManager : NonCopyable - { - public: - typedef IFrameManager class_type; - typedef uint8 value_type; - typedef value_type* pointer; - typedef value_type const* const_pointer; - typedef size_t size_type; - - public: - IFrameManager(); - virtual ~IFrameManager(); - - public: - bool write ( const_pointer buffer - , size_type bufferSize ); - pointer allocate ( size_type bufferSize ); - void release ( pointer buffer ); - - private: - virtual bool writeFrame ( const_pointer buffer - , size_type bufferSize ) =0; - virtual pointer allocateFrame ( size_type bufferSize ) =0; - virtual void releaseFrame ( pointer buffer ) =0; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _IFRAMEMANAGER_HPP_ */ diff --git a/src/decoder/.svn/text-base/IFrameMemoryManager.hpp.svn-base b/src/decoder/.svn/text-base/IFrameMemoryManager.hpp.svn-base deleted file mode 100644 index 1ddf79e..0000000 --- a/src/decoder/.svn/text-base/IFrameMemoryManager.hpp.svn-base +++ /dev/null @@ -1,160 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _IFRAMEMEMORYMANAGER_HPP_ -#define _IFRAMEMEMORYMANAGER_HPP_ - -#include -#include - -#include -#include -#include -#include -#include - -namespace dirac -{ -namespace decoder -{ - struct FrameMemoryManagerException : public std::runtime_error - { - FrameMemoryManagerException ( std::string const& msg ) - : std::runtime_error ( msg ) {} - }; - - template - class IFrameMemoryManager : NonCopyable - { - public: - typedef uint8* Buffer; - typedef uint8 const* BufferConst; - typedef size_t size_type; - typedef Priv parameter_type; - - typedef std::map PrivateMap; - typedef typename PrivateMap::value_type value_type; - typedef typename PrivateMap::iterator iterator; - typedef typename PrivateMap::const_iterator const_iterator; - - public: - IFrameMemoryManager() {} - virtual ~IFrameMemoryManager() {} - - public: - Buffer allocate ( size_type bufferSize ) - { - Priv* priv = 0; - Buffer ret = allocateFrame ( bufferSize, priv ); - storePrivateParameter ( ret, priv ); - return ret; - } - - void release ( Buffer buffer ) - { - Priv* priv = retrievePrivateParameter ( buffer ); - releaseFrame ( buffer, priv ); - } - - //! retrieve private parameter and removes it from the internal map upon success - Priv* retrievePrivateParameter ( Buffer buffer ) - { - iterator ret = map_.find ( buffer ); - if ( map_.end() == ret ) { - return static_cast ( 0 ); - } - else { - map_.erase ( ret ); - return ret->second; - } - } - - private: - virtual Buffer allocateFrame ( size_type bufferSize, Priv*& priv ) =0; - virtual void releaseFrame ( Buffer buffer, Priv* priv ) =0; - - private: - void storePrivateParameter ( Buffer buffer, Priv* priv ) - { - DIRAC_MESSAGE_ASSERT ( "buffer and private data cannot be null" - , 0 != buffer && 0 != priv ); - std::pair ret = map_.insert ( value_type ( buffer, priv ) ); - if ( !ret.second ) { - throw FrameMemoryManagerException - ( "failed to store user data in IFrameMemoryManager - same buffer used twice ?"); - } - } - - private: - PrivateMap map_; - }; - - template<> - class IFrameMemoryManager - { - public: - typedef uint8* Buffer; - typedef uint8 const* BufferConst; - typedef uint8 value_type; - typedef void parameter_type; - typedef size_t size_type; - - public: - IFrameMemoryManager() {} - virtual ~IFrameMemoryManager() {} - // compiler generated methods are ok (no state associated with this class) - - public: - Buffer allocate ( size_type bufferSize ) - { - return allocateFrame ( bufferSize ); - } - void release ( Buffer buffer ) - { - releaseFrame ( buffer ); - } - - private: - virtual Buffer allocateFrame ( size_type bufferSize ) =0; - virtual void releaseFrame ( Buffer buffer ) =0; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _IFRAMEMEMORYMANAGER_HPP_ */ diff --git a/src/decoder/.svn/text-base/IWriter.hpp.svn-base b/src/decoder/.svn/text-base/IWriter.hpp.svn-base deleted file mode 100644 index 724b5c4..0000000 --- a/src/decoder/.svn/text-base/IWriter.hpp.svn-base +++ /dev/null @@ -1,117 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _IWRITER_HPP_ -#define _IWRITER_HPP_ - -#include -#include - -#include - -namespace dirac -{ -namespace decoder -{ - template - class IWriter : NonCopyable - { - public: - typedef uint8 value_type; - typedef value_type const* const_pointer; - typedef size_t size_type; - - typedef Priv parameter_type; - - public: - IWriter() {} - virtual ~IWriter() {} - - public: - bool write ( const_pointer begin, size_type count - , Priv* priv ) - { - return output ( begin, count, priv ); - } - - bool isAvailable() const - { - return available(); - } - - private: - virtual bool output ( const_pointer begin, size_type count - , Priv* priv ) =0; - virtual bool available() const =0; - }; - - template<> - class IWriter : NonCopyable - { - public: - typedef uint8 value_type; - typedef value_type const* const_pointer; - typedef size_t size_type; - - typedef void parameter_type; - - public: - IWriter() {} - virtual ~IWriter() {} - - public: - bool write ( const_pointer begin, size_type count ) - { - return output ( begin, count ); - } - - bool isAvailable() const - { - return available(); - } - - private: - virtual bool output ( const_pointer begin, size_type count ) =0; - virtual bool available() const =0; - }; - -} /* decoder */ - -} /* dirac */ - - -#endif /* _IWRITER_HPP_ */ diff --git a/src/decoder/.svn/text-base/Makefile.am.svn-base b/src/decoder/.svn/text-base/Makefile.am.svn-base deleted file mode 100644 index 0a7ee1d..0000000 --- a/src/decoder/.svn/text-base/Makefile.am.svn-base +++ /dev/null @@ -1,47 +0,0 @@ -INCLUDES = -I$(top_srcdir)/src -I$(srcdir) - -h_sources = FileReader.hpp \ - FileWriter.hpp \ - FrameManagerImpl.hpp \ - IDecoder.hpp \ - IFrameManager.hpp \ - IFrameMemoryManager.hpp \ - FrameManagerMaker.hpp \ - IWriter.hpp \ - DefaultFrameMemoryManager.hpp - -lib_h_sources = \ - IDecoder.hpp \ - IWriter.hpp \ - IFrameMemoryManager.hpp - -cpp_sources = FileReader.cpp \ - FileWriter.cpp \ - IDecoder.cpp \ - IFrameManager.cpp \ - DefaultFrameMemoryManager.cpp - -if HAVE_DIRAC - h_sources += Diracdec.hpp \ - DiracState.hpp - - cpp_sources += Diracdec.cpp \ - DiracState.cpp -endif - -if HAVE_SCHRO -h_sources += Schrodec.hpp \ - SchroState.hpp - -cpp_sources += Schrodec.cpp \ - SchroState.cpp -endif - -lib_LTLIBRARIES = libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_decoder.la - -libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_decoder_la_SOURCES = $(h_sources) $(cpp_sources) -libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_decoder_la_CXXFLAGS = $(SCHROEDINGER_CFLAGS) $(DIRAC_CFLAGS) $(AM_CXXFLAGS) -#libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_decoder_la_LIBADD = $(top_builddir)/src/parser/libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_parser.la - -library_includedir=$(includedir)/dirac_parser-@DIRAC_PARSER_MAJORMINOR@/decoder -library_include_HEADERS = $(lib_h_sources) diff --git a/src/decoder/.svn/text-base/SchroState.cpp.svn-base b/src/decoder/.svn/text-base/SchroState.cpp.svn-base deleted file mode 100644 index 5d857e2..0000000 --- a/src/decoder/.svn/text-base/SchroState.cpp.svn-base +++ /dev/null @@ -1,183 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -#include - - -namespace dirac -{ -namespace decoder -{ - IDecoderState* - makeSchroState ( Schrodec& schrodec, int schro_state ) - { - DIRAC_MESSAGE_ASSERT ( "state must be one of the possible schro status values" - , schro_state == SCHRO_DECODER_OK - || schro_state == SCHRO_DECODER_ERROR - || schro_state == SCHRO_DECODER_EOS - || schro_state == SCHRO_DECODER_NEED_BITS - || schro_state == SCHRO_DECODER_NEED_FRAME ); - - switch ( schro_state ) { - case ( SCHRO_DECODER_NEED_BITS ) : - return new SchroNeedInput ( schrodec ); - // break; - case ( SCHRO_DECODER_OK ) : - return new SchroFrameReady ( schrodec ); - // break; - case ( SCHRO_DECODER_NEED_FRAME ) : - return new SchroNeedFrame ( schrodec ); - // break; - case ( SCHRO_DECODER_EOS ) : - return new SchroEndOfSequence; - // break; - case ( SCHRO_DECODER_ERROR ) : - return new SchroError; - // break; - default : - return new SchroNull; - // break; - } - } - - -} /* decoder */ - -} /* dirac */ - - - -using namespace ::dirac::decoder; - - -SchroNeedInput::SchroNeedInput ( Schrodec& schrodec ) -: schrodec_ ( schrodec ) {} - -void -SchroNeedInput::run() -{ - schrodec_.pushBits(); -} - -bool -SchroNeedInput::endOfSequence() const -{ - return false; -} - -SchroNeedFrame::SchroNeedFrame ( Schrodec& schrodec ) -: schrodec_ ( schrodec ) {} - -void -SchroNeedFrame::run() -{ - schrodec_.setFrame(); -} - -bool -SchroNeedFrame::endOfSequence() const -{ - return false; -} - -SchroFrameReady::SchroFrameReady ( Schrodec& schrodec ) -: schrodec_ ( schrodec ) {} - -void -SchroFrameReady::run() -{ - schrodec_.pullFrameAndWrite(); -} - -bool -SchroFrameReady::endOfSequence() const -{ - return false; -} - -SchroError::SchroError() {} - -void -SchroError::run() -{ - throw DecoderException ( "Error while decoding stream"); -} - -bool -SchroError::endOfSequence() const -{ - return false; -} - -SchroEndOfSequence::SchroEndOfSequence() {} - -void -SchroEndOfSequence::run() -{ - // do nothing -} - -bool -SchroEndOfSequence::endOfSequence() const -{ - return true; -} - -SchroNull::SchroNull() {} - -void -SchroNull::run() -{ - throw DecoderException ( "programming error!" ); -} - -bool -SchroNull::endOfSequence() const -{ - return false; -} - - - diff --git a/src/decoder/.svn/text-base/SchroState.hpp.svn-base b/src/decoder/.svn/text-base/SchroState.hpp.svn-base deleted file mode 100644 index 7ffaaf7..0000000 --- a/src/decoder/.svn/text-base/SchroState.hpp.svn-base +++ /dev/null @@ -1,136 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _SCHROSTATE_HPP_ -#define _SCHROSTATE_HPP_ - -#include -#include - -#include - -namespace dirac -{ -namespace decoder -{ - // forward declaration - class Schrodec; - - //! factory method used to generate objects of type IDecoderState - //! - //! \a schrodec the schro decoder associated with the schro state - //! \a schro_state the state value returned by schro_decoder_wait - IDecoderState* makeSchroState ( Schrodec& schrodec - , int schro_state ); - - - class SchroNeedInput : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroNeedInput ( Schrodec& schrodec ); - - virtual void run (); - virtual bool endOfSequence() const; - - Schrodec& schrodec_; - }; - - class SchroNeedFrame : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroNeedFrame ( Schrodec& schrodec ); - - virtual void run (); - virtual bool endOfSequence() const; - - Schrodec& schrodec_; - }; - - class SchroFrameReady : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroFrameReady ( Schrodec& schrodec ); - - virtual void run (); - virtual bool endOfSequence() const; - - Schrodec& schrodec_; - }; - - class SchroError : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroError(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class SchroEndOfSequence : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroEndOfSequence(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class SchroNull : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroNull(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - - - - -} /* decoder */ - -} /* dirac */ - - -#endif /* _SCHROSTATE_HPP_ */ diff --git a/src/decoder/.svn/text-base/Schrodec.cpp.svn-base b/src/decoder/.svn/text-base/Schrodec.cpp.svn-base deleted file mode 100644 index 95c0f47..0000000 --- a/src/decoder/.svn/text-base/Schrodec.cpp.svn-base +++ /dev/null @@ -1,315 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include - -using namespace ::dirac::decoder; -using namespace ::dirac::parser_project; - -namespace -{ - IDecoder::size_type - getBufferSizeFroFrame ( SchroFrame* frame ) - { - DIRAC_MESSAGE_ASSERT ( "frame cannot be null", 0 != frame ); - - IDecoder::size_type ret = 0; - for (int i=0; i<3; ++i) ret += frame->components[i].length; - return ret; - } -} /* */ - -//! init schro, parse and decode sequence header and obtain video format params -Schrodec::Schrodec ( IDecoder::ParserAutoPtr parser - , IDecoder::FrameManagerAutoPtr manager ) -: IDecoder ( parser, manager ), numberOfDecodedFrames_ ( 0 ) -{ - initSchro(); - fetchSequenceHeader(); -} - -Schrodec::~Schrodec() {} - -Schrodec::VideoFormatSharedPtr -Schrodec::getVideoFormat() const -{ - return videoFormat_; -} - -void -Schrodec::createDecoder() -{ - DecoderSharedPtr tmp ( schro_decoder_new(), schro_decoder_free ); - decoder_.swap ( tmp ); - if ( !decoder_.get() ) { - throw DecoderException ( "failed to create schro decoder" ); - } - schro_decoder_set_skip_ratio ( decoder_.get(), 1.0 ); -} - -void -Schrodec::initSchro() -{ - schro_init(); - createDecoder(); -} - -void -Schrodec::resetDecoder() -{ - if ( decoder_.get() ) { - decoder_.reset(); - createDecoder(); - numberOfDecodedFrames_ = 0; - fetchSequenceHeader(); - } -} - -void -Schrodec::deleteBuffer ( SchroBuffer* schrobuffer, void* inputBuffer ) -{ - delete static_cast ( inputBuffer ); -} - -void -Schrodec::createSchroBuffer(IDecoder::AU& au, SchroBuffer*& schrobuffer ) -{ - InputBuffer* buf = au.releaseBuffer(); - schrobuffer = schro_buffer_new_with_data ( &(*buf)[0] , buf->size() ); - if ( !schrobuffer ) { - throw DecoderException ( "failed to create input buffer for schodec" ); - } - schrobuffer->priv = buf; - schrobuffer->free = deleteBuffer; -} - -void -Schrodec::fetchSequenceHeader() -{ - DIRAC_MESSAGE_ASSERT ( "parser cannot be null", 0 != parser_.get() ); - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - AccessUnit au; - if ( !parser_->getNextSequenceHeader ( au ) || au.empty() ) { - throw DecoderException ( "failed to parser sequence header" ); - } - - SchroBuffer* schrobuffer = 0; - createSchroBuffer ( au, schrobuffer ); - - if ( SCHRO_DECODER_FIRST_ACCESS_UNIT != - schro_decoder_push ( decoder_.get(), schrobuffer ) ) { - throw DecoderException ( "failed to decode sequence header" ); - } - - VideoFormatSharedPtr tmp ( schro_decoder_get_video_format ( decoder_.get() ) - , free ); - videoFormat_.swap ( tmp ); - if ( !videoFormat_.get() ) { - throw DecoderException ( "failed to extract video format" ); - } -} - -void -Schrodec::signOff() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - schro_decoder_push_end_of_stream ( decoder_.get() ); -} - -IDecoderState* -Schrodec::getDecoderState() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - return makeSchroState ( *this, schro_decoder_wait ( decoder_.get() ) ); -} - -//! parse a picture and push it in the decoder -void -Schrodec::pushBits() -{ - DIRAC_MESSAGE_ASSERT ( "parser and decoder cannot be null" - , 0 != parser_.get() && 0 != decoder_.get() ); - - // parse a picture, but check whether we reach the end of the sequence - AccessUnit au; - do { - if ( !parser_->getNextAccessUnit ( au ) || au.isLastEndOfSequence() - || !parser_->moveCursorFwd() ) { - signOff(); - return; - } - } while ( !au.isPicture() ); - - SchroBuffer* schrobuffer = 0; - createSchroBuffer ( au, schrobuffer ); - - int it = schro_decoder_push ( decoder_.get(), schrobuffer ); - if ( SCHRO_DECODER_ERROR == it ) { - throw DecoderException ( "failed to decode picture" ); - } -} - -//! static method used as a deleter for schro frame -void -Schrodec::deleteFrame ( SchroFrame* frame, void* decoder ) -{ - DIRAC_MESSAGE_ASSERT ( "frame cannot be null", 0 != frame ); - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder ); - - static_cast ( decoder )->manager_->release - ( static_cast ( frame->components[0].data ) ); -} - -//! allocate memory for a frame worth of data -void -Schrodec::setFrame() -{ - DIRAC_MESSAGE_ASSERT ( "parser, decoder and video format cannot be null" - , 0 != parser_.get() && 0 != decoder_.get() - && 0 != videoFormat_.get() ); - pointer buffer = manager_->allocate ( getFrameBufferSize( frameWidth() - , frameHeight() - , chromaFormat() ) ); - SchroFrame* frame = schro_frame_new_from_data_I420 ( buffer - , frameWidth() - , frameHeight() ); - schro_frame_set_free_callback ( frame, deleteFrame, this ); - schro_decoder_add_output_picture ( decoder_.get(), frame ); -} - -void -Schrodec::pullFrameAndWrite() -{ - DIRAC_MESSAGE_ASSERT ( "decoder and manager cannot be null" - , 0 != decoder_.get() && 0 != manager_.get() ); - - SchroFrame* frame = schro_decoder_pull ( decoder_.get() ); - if ( frame ) { - ++numberOfDecodedFrames_; - write ( frame ); - schro_frame_unref ( frame ); - } -} - -bool -Schrodec::write ( SchroFrame* frame ) -{ - DIRAC_MESSAGE_ASSERT ( "frame cannot be null", 0 != frame ); - DIRAC_MESSAGE_ASSERT ( "videoformat cannot be null", 0 != videoFormat_.get() ); - DIRAC_MESSAGE_ASSERT ( "frame manager cannot be null", 0 != manager_.get() ); - - // here we can format the data for output, if required - return manager_->write ( static_cast ( frame->components[0].data ) - , getBufferSizeFroFrame ( frame ) ); -} - -void -Schrodec::runDecoder() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - std::auto_ptr decoderState; - do { - std::auto_ptr tmp ( getState() ); - decoderState = tmp; // the previous DecoderState gets deleted here - decoderState->doNextAction(); - } while ( !decoderState->isEndOfSequence() ); -} - -IDecoder::size_type -Schrodec::numberOfFrames() const -{ - return numberOfDecodedFrames_; -} - -Schrodec::size_type -Schrodec::getFrameWidth() const -{ - if ( videoFormat_.get() ) { - return videoFormat_->width; - } - else { - return 0; - } -} - -IDecoder::size_type -Schrodec::getFrameHeight() const -{ - if ( videoFormat_.get() ) { - return videoFormat_->height; - } - else { - return 0; - } -} - -ChromaFormat -Schrodec::getChromaFormat() const -{ - if ( videoFormat_.get() ) { - switch ( videoFormat_->chroma_format ) { - case ( SCHRO_CHROMA_444 ) : - return CHROMA_444; - // break; - case ( SCHRO_CHROMA_422 ) : - return CHROMA_422; - // break; - case ( SCHRO_CHROMA_420 ) : - return CHROMA_420; - // break; - default : - return UNDEFINED; - // break; - } - } - else { - return UNDEFINED; - } -} - - diff --git a/src/decoder/.svn/text-base/Schrodec.hpp.svn-base b/src/decoder/.svn/text-base/Schrodec.hpp.svn-base deleted file mode 100644 index f000125..0000000 --- a/src/decoder/.svn/text-base/Schrodec.hpp.svn-base +++ /dev/null @@ -1,123 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _SCHRODEC_HPP_ -#define _SCHRODEC_HPP_ - - -#include -#include - -#include - - -namespace dirac -{ -namespace decoder -{ - - class SchroNeedInput; - class SchroNeedFrame; - class SchroFrameReady; - class SchroError; - class SchroEndOfSequence; - class SchroNull; - - //! A c++ wrapper for the schroedinger decoder - class Schrodec : public IDecoder - { - friend class SchroNeedInput; - friend class SchroNeedFrame; - friend class SchroFrameReady; - friend class SchroEndOfSequence; - friend class SchroError; - friend class SchroNull; - - public: - typedef Schrodec class_type; - typedef std::tr1::shared_ptr DecoderSharedPtr; - typedef std::tr1::shared_ptr VideoFormatSharedPtr; - - public: - Schrodec ( ParserAutoPtr parser, FrameManagerAutoPtr manager ); - ~Schrodec(); - - private: - //! run the decoder autonomously, from beginning to end, if it can - //! it cannot be interrupted - virtual void runDecoder(); - - virtual IDecoderState* getDecoderState(); - virtual size_type numberOfFrames() const; - - virtual size_type getFrameWidth() const; - virtual size_type getFrameHeight() const; - virtual ChromaFormat getChromaFormat() const; - virtual void resetDecoder(); - - private: - VideoFormatSharedPtr getVideoFormat() const; - void pushBits(); - void setFrame(); - void pullFrameAndWrite(); - - private: - void initSchro(); - void createDecoder(); - void fetchSequenceHeader(); - bool write ( SchroFrame* frame ); - void createSchroBuffer( AU& au - , SchroBuffer*& buffer ); - void signOff(); - - static void deleteFrame ( SchroFrame* frame - , void* decoder ); - static void deleteBuffer ( SchroBuffer* schrobuffer - , void* inputBuffer ); - - private: - VideoFormatSharedPtr videoFormat_; - DecoderSharedPtr decoder_; - size_type numberOfDecodedFrames_; - }; - -} /* decoder */ - -} /* dirac */ - - -#endif /* _SCHRODEC_HPP_ */ diff --git a/src/decoder/DefaultFrameMemoryManager.cpp b/src/decoder/DefaultFrameMemoryManager.cpp deleted file mode 100644 index 73bac69..0000000 --- a/src/decoder/DefaultFrameMemoryManager.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - - -using namespace ::dirac::decoder; - -typedef DefaultFrameMemoryManager::Buffer Buffer; -typedef DefaultFrameMemoryManager::size_type size_type; - -Buffer -DefaultFrameMemoryManager::allocateFrame ( size_type bufferSize ) -{ - DIRAC_MESSAGE_ASSERT ( "buffer size cannot be null", 0 != bufferSize ); - return new value_type [ bufferSize ]; -} - - -void -DefaultFrameMemoryManager::releaseFrame ( Buffer buffer ) -{ - delete [] buffer; -} - diff --git a/src/decoder/DefaultFrameMemoryManager.hpp b/src/decoder/DefaultFrameMemoryManager.hpp deleted file mode 100644 index 92a6a81..0000000 --- a/src/decoder/DefaultFrameMemoryManager.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _DEFAULTFRAMEMEMORYMANAGER_HPP_ -#define _DEFAULTFRAMEMEMORYMANAGER_HPP_ - -#include - -#include - -namespace dirac -{ -namespace decoder -{ - class DefaultFrameMemoryManager : public IFrameMemoryManager - { - virtual Buffer allocateFrame ( size_type bufferSize ); - virtual void releaseFrame ( Buffer buffer ); - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _DEFAULTFRAMEMEMORYMANAGER_HPP_ */ diff --git a/src/decoder/DiracState.cpp b/src/decoder/DiracState.cpp deleted file mode 100644 index a4614dd..0000000 --- a/src/decoder/DiracState.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -#include - -namespace dirac -{ -namespace decoder -{ - IDecoderState* - makeDiracState ( Diracdec& diracdec, int diracState ) - { - DIRAC_MESSAGE_ASSERT ( "state must be one of the possible dirac state values" - , diracState == STATE_BUFFER - || diracState == STATE_SEQUENCE - || diracState == STATE_SEQUENCE_END - || diracState == STATE_PICTURE_AVAIL - || diracState == STATE_INVALID ); - switch ( diracState ) { - case ( STATE_BUFFER ) : { - return new DiracNeedInput ( diracdec ); - // break; - } - case ( STATE_SEQUENCE ) : { - return new DiracDoNothing; - // break; - } - case ( STATE_SEQUENCE_END ) : { - return new DiracEndOfSequence; - // break; - } - case ( STATE_PICTURE_AVAIL ) : { - return new DiracFrameReady ( diracdec ); - // break; - } - case ( STATE_INVALID ) : { - return new DiracError; - // break; - } - default : { - return new DiracNull; - // break; - } - } - } -} /* decoder */ - -} /* dirac */ - -using namespace ::dirac::decoder; - -DiracNeedInput::DiracNeedInput ( Diracdec& diracdec ) -: diracdec_ ( diracdec ) {} - -void -DiracNeedInput::run() -{ - diracdec_.pushBits(); -} - -bool -DiracNeedInput::endOfSequence() const -{ - return diracdec_.eos_; -} - -DiracFrameReady::DiracFrameReady ( Diracdec& diracdec ) -: diracdec_ ( diracdec ) {} - -void -DiracFrameReady::run() -{ - diracdec_.pullFrameAndWrite(); -} - -bool -DiracFrameReady::endOfSequence() const -{ - return false; -} - - -DiracEndOfSequence::DiracEndOfSequence() {} - -void -DiracEndOfSequence::run() -{ - // do nothing -} - -bool -DiracEndOfSequence::endOfSequence() const -{ - return true; -} - -DiracError::DiracError() {} - -void -DiracError::run() -{ - throw DecoderException ( "Dirac decoder error - error while decoding stream" ); -} - -bool -DiracError::endOfSequence() const -{ - return false; -} - -DiracNull::DiracNull() {} - -void -DiracNull::run() -{ - throw DecoderException ( "programming error!" ); -} - -bool -DiracNull::endOfSequence() const -{ - return false; -} - -DiracDoNothing::DiracDoNothing() {} - -void -DiracDoNothing::run() -{ - // do nothing -} - -bool -DiracDoNothing::endOfSequence() const -{ - return false; -} - - - diff --git a/src/decoder/DiracState.hpp b/src/decoder/DiracState.hpp deleted file mode 100644 index 0466927..0000000 --- a/src/decoder/DiracState.hpp +++ /dev/null @@ -1,127 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _DIRACSTATE_HPP_ -#define _DIRACSTATE_HPP_ - -#include - -#include - -namespace dirac -{ -namespace decoder -{ - class Diracdec; - - //! factory method used to generate state objects - //! - //! \a diracdec the dirac decoder associated with the dirac state - //! \a diracState the state value returned by dirac_parse - //! \r the dirac state object created by the factory method - IDecoderState* makeDiracState ( Diracdec& diracdec, int diracState ); - - class DiracNeedInput : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracNeedInput ( Diracdec& diracdec ); - - virtual void run(); - virtual bool endOfSequence() const; - - Diracdec& diracdec_; - }; - - class DiracFrameReady : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracFrameReady ( Diracdec& diracdec ); - - virtual void run(); - virtual bool endOfSequence() const; - - Diracdec& diracdec_; - }; - - class DiracEndOfSequence : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracEndOfSequence(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class DiracError : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracError(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class DiracNull : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracNull(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class DiracDoNothing : public IDecoderState - { - friend IDecoderState* makeDiracState ( Diracdec&, int ); - - DiracDoNothing(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - -} /* decoder */ - -} /* dirac */ - - -#endif /* _DIRACSTATE_HPP_ */ diff --git a/src/decoder/Diracdec.cpp b/src/decoder/Diracdec.cpp deleted file mode 100644 index eec7656..0000000 --- a/src/decoder/Diracdec.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - - -using namespace ::dirac::decoder; -using ::dirac::parser_project::AccessUnit; - -Diracdec::Diracdec ( IDecoder::ParserAutoPtr parser - , IDecoder::FrameManagerAutoPtr manager ) -: IDecoder ( parser, manager ), numberOfDecodedFrames_ ( 0 ) -, canPushBits_ ( true ), eos_ ( false ) -{ - yuv_[0] = yuv_[1] = yuv_[2] = static_cast ( 0 ); - initDirac(); - fetchSequenceHeader(); - setFrame(); -} - -Diracdec::~Diracdec() -{ - delete [] yuv_[0]; -} - -void -Diracdec::initDirac() -{ - const int VERBOSE_MODE = 0; // set to 1 if you wish to log messages to stdout - DecoderSharedPtr tmp ( dirac_decoder_init ( VERBOSE_MODE ) - , dirac_decoder_close ); - if ( !tmp.get() ) { - throw DecoderException ( "failed to create dirac decoder" ); - } - decoder_.swap ( tmp ); -} - -void -Diracdec::fetchSequenceHeader() -{ - AccessUnit au; - if ( !parser_->getNextSequenceHeader ( au ) || au.empty() ) { - throw DecoderException ( "Dirac decoder: failed to parser sequence header" ); - } - dirac_buffer ( decoder_.get(), const_cast ( au.begin() ) - , const_cast ( au.end() ) ); - if ( !parser_->moveCursorFwd() ) { - throw DecoderException ( "Dirac decoder: failed to parse access unit" ); - } - if ( !parser_->getNextAccessUnit ( au ) || au.empty() ) { - throw DecoderException ( "Dirac decoder: failed to parse access unit" ); - } - dirac_buffer ( decoder_.get(), const_cast ( au.begin() ) - , const_cast ( au.end() ) ); - // dirac_buffer ( decoder_.get(), aux, aux + 16 ); // FIXME - if ( STATE_SEQUENCE != dirac_parse ( decoder_.get() ) ) { - throw DecoderException ( "Dirac decoder: failed to decode sequence header" ); - } -} - -void -Diracdec::resetDecoder() -{ - delete [] yuv_[0]; - canPushBits_ = true; - eos_ = false; - numberOfDecodedFrames_ = 0; - decoder_.reset(); - initDirac(); - fetchSequenceHeader(); - setFrame(); -} - -//! push an access unit into dirac's input buffer -//! \r true if successful, false if end of stream -void -Diracdec::pushBits() -{ - DIRAC_MESSAGE_ASSERT ( "parser and decoder cannot be null", 0 != parser_.get() - && 0 != decoder_.get() ); - AccessUnit au; - if ( parser_->getNextAccessUnit ( au ) ) { - if ( canPushBits_ ) { - dirac_buffer ( decoder_.get(), const_cast ( au.begin() ) - , const_cast ( au.end() ) ); - } - if ( au.isLastEndOfSequence() || !parser_->moveCursorFwd() ) { - if ( !canPushBits_ ) eos_ = true; - canPushBits_ = false; - } - } - else { - if ( !canPushBits_ ) eos_ = true; - else canPushBits_ = false; - } -} - -void -Diracdec::setFrame() -{ - DIRAC_MESSAGE_ASSERT ( "parser and decoder cannot be null" - , 0 != parser_.get() && 0 != decoder_.get() ); - size_type bufferSize = getFrameBufferSize ( frameWidth(), frameHeight() - , chromaFormat() ); - if ( !bufferSize ) - throw DecoderException ( "failed to create frame buffer" ); - yuv_[0] = new value_type [ bufferSize ]; - yuv_[1] = yuv_[0] + frameWidth() * frameHeight(); - size_type chromaWidth = decoder_->src_params.chroma_width, - chromaHeight = decoder_->src_params.chroma_height; - yuv_[2] = yuv_[1] + chromaWidth * chromaHeight; - dirac_set_buf ( decoder_.get(), yuv_, NULL ); -} - -void -Diracdec::pullFrameAndWrite() -{ - DIRAC_MESSAGE_ASSERT ( "decoder and frame manager cannot be null" - , 0 != decoder_.get() && 0 != manager_.get() ); - if ( !decoder_->fbuf || !decoder_->fbuf->buf[0] ) { - throw - DecoderException ( "Dirac decoder: invalid frame buffer in dirac decoder" ); - } - ++numberOfDecodedFrames_; - writeFrame(); -} - -void -Diracdec::writeFrame() -{ - size_type count = getFrameBufferSize ( frameWidth(), frameHeight() - , chromaFormat() ); - // this is a safe cast - pointer buffer = const_cast ( manager_->allocate ( count ) ); - memcpy(static_cast ( buffer ), yuv_[0], count ); - manager_->write ( buffer, count ); - manager_->release ( buffer ); -} - -IDecoder::size_type -Diracdec::getFrameWidth() const -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - return decoder_->src_params.width; -} - -IDecoder::size_type -Diracdec::getFrameHeight() const -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - return decoder_->src_params.height; -} - -::dirac::decoder::ChromaFormat -Diracdec::getChromaFormat() const -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - switch ( decoder_->src_params.chroma ) { - case ( format444 ) : - return CHROMA_444; - // break; - case ( format422 ) : - return CHROMA_422; - // break; - case ( format420 ) : - return CHROMA_420; - // break; - default : - return UNDEFINED; - // break; - } -} - -void -Diracdec::runDecoder() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - std::auto_ptr decoderState; - do { - std::auto_ptr tmp ( getState() ); - decoderState = tmp; - decoderState->doNextAction(); - } while ( !decoderState->isEndOfSequence() ); -} - -IDecoder::size_type -Diracdec::numberOfFrames() const -{ - return numberOfDecodedFrames_; -} - -IDecoderState* -Diracdec::getDecoderState() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - return makeDiracState ( *this, dirac_parse ( decoder_.get() ) ); -} - -void -Diracdec::signOff() -{ - // do nothing -} - diff --git a/src/decoder/Diracdec.hpp b/src/decoder/Diracdec.hpp deleted file mode 100644 index ecd8ee9..0000000 --- a/src/decoder/Diracdec.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _DIRACDEC_HPP_ -#define _DIRACDEC_HPP_ - -#include - -#include - -#include - -namespace dirac -{ -namespace decoder -{ - class DiracNeedInput; - class DiracFrameReady; - class DiracError; - class DiracEndOfSequence; - class DiracNull; - class DiracDoNothing; - - class Diracdec : public IDecoder - { - friend class DiracNeedInput; - friend class DiracFrameReady; - friend class DiracError; - friend class DiracEndOfSequence; - friend class DiracNull; - friend class DoNothing; - - public: - typedef Diracdec class_type; - typedef std::tr1::shared_ptr DecoderSharedPtr; - - public: - Diracdec ( ParserAutoPtr parser, FrameManagerAutoPtr manager ); - virtual ~Diracdec(); - - private: - virtual void runDecoder(); - virtual IDecoderState* getDecoderState(); - virtual size_type numberOfFrames() const; - - virtual size_type getFrameWidth() const; - virtual size_type getFrameHeight() const; - virtual ChromaFormat getChromaFormat() const; - virtual void resetDecoder(); - - private: - void pushBits(); - void setFrame(); - void pullFrameAndWrite(); - void signOff(); - - void initDirac(); - void fetchSequenceHeader(); - void writeFrame(); - - private: - DecoderSharedPtr decoder_; - size_type numberOfDecodedFrames_; - pointer yuv_[3]; - bool canPushBits_; - bool eos_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _DIRACDEC_HPP_ */ diff --git a/src/decoder/FileReader.cpp b/src/decoder/FileReader.cpp deleted file mode 100644 index cbb5cbc..0000000 --- a/src/decoder/FileReader.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -using namespace ::dirac::decoder; - -FileReaderException::FileReaderException ( std::string const& message ) -: std::runtime_error ( message ) {} - -std::string FileReader::error_message_ = ""; - -FileReader::FileReader ( std::string const& filename ) -: IInput ( true ), str_ ( 0 ) -{ - if ( !filename.compare ( "-" ) ) { // pipe, can't rewind - bwdScan_ = false; - str_ = fopen ("/dev/stdin", "rb" ); - } - else { - str_ = fopen ( filename.c_str(), "rb" ); - } - if ( !str_ ) - { - error_message_ = "Error while opening " + filename; - throw FileReaderException ( error_message_ ); - } -} - -FileReader::~FileReader() -{ - if ( str_ ) fclose ( str_ ); -} - -bool -FileReader::available() const -{ - return str_ && !ferror ( str_ ) && !feof ( str_ ); -} - -FileReader::size_type -FileReader::readInput ( pointer begin, size_type count ) -{ - const size_type NO_DATA = 0; - if ( !available() ) return NO_DATA; - size_type bytesread = NO_DATA; - bytesread = fread ( static_cast ( begin ) - , sizeof ( value_type ), count, str_ ); - if ( ferror ( str_ ) ) return NO_DATA; - return bytesread; -} - - -bool -FileReader::rewindStream ( size_type count ) -{ - if ( !str_ || ferror ( str_ ) ) return false; - long pos = ftell ( str_ ); - if ( count > static_cast ( pos ) ) return false; - if ( fseek ( str_, -count, SEEK_CUR ) ) return false; - else return true; -} - -bool -FileReader::fullRewind() -{ - if ( !str_ || ferror ( str_ ) ) return false; - return ( !fseek ( str_, 0, SEEK_SET ) ); -} - - diff --git a/src/decoder/FileReader.hpp b/src/decoder/FileReader.hpp deleted file mode 100644 index 850af17..0000000 --- a/src/decoder/FileReader.hpp +++ /dev/null @@ -1,97 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FILEREADER_HPP_ -#define _FILEREADER_HPP_ - -#include - -#include - -#include -#include -#include - - -namespace dirac -{ -namespace decoder -{ - class FileReaderException : public std::runtime_error - { - public: - FileReaderException ( std::string const& message ); - }; - - class FileReader : public parser_project::IInput - { - public: // type definitions - typedef FileReader class_type; // self - - typedef IInput::value_type value_type; - typedef IInput::size_type size_type; - typedef IInput::pointer pointer; - typedef IInput::const_pointer const_pointer; - - typedef FILE stream; - - public: // constructors - explicit FileReader ( std::string const& filename ); - virtual ~FileReader(); - private: // compiler generated methods are not allowed - FileReader ( class_type const& ); - class_type& operator= ( class_type const& ); - - private: // implementation of IInput virtual interface - virtual bool available() const; - - virtual size_type readInput ( pointer begin, size_type count ); - - virtual bool rewindStream ( size_type count ); - - virtual bool fullRewind(); - - private: // members - stream* str_; - static std::string error_message_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _FILEREADER_HPP_ */ diff --git a/src/decoder/FileWriter.cpp b/src/decoder/FileWriter.cpp deleted file mode 100644 index 3f05eea..0000000 --- a/src/decoder/FileWriter.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -using namespace ::dirac::decoder; - -FileWriterException::FileWriterException ( std::string const& message ) -: std::runtime_error ( message ) {} - -std::string FileWriter::error_message_ = ""; - - -FileWriter::FileWriter ( std::string const& filename ) -: str_ ( 0 ) -{ - if ( !filename.compare ( "-" ) ) { - str_ = fopen ( "/dev/stdin", "wb"); - } - else { - str_ = fopen ( filename.c_str(), "wb" ); - } - if ( !str_ ) { - error_message_ = "Error while opening " + filename; - throw FileWriterException ( error_message_ ); - } -} - -FileWriter::~FileWriter() -{ - if ( str_ ) fclose ( str_ ); -} - -bool -FileWriter::available() const -{ - return str_ && !ferror ( str_ ); -} - -bool -FileWriter::output ( IWriter<>::const_pointer begin - , IWriter<>::size_type count ) -{ - if ( !isAvailable() ) return false; - fwrite (begin, sizeof ( value_type ), count, str_ ); - return !ferror ( str_ ); -} - diff --git a/src/decoder/FileWriter.hpp b/src/decoder/FileWriter.hpp deleted file mode 100644 index 7bbdbbc..0000000 --- a/src/decoder/FileWriter.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FILEWRITER_HPP_ -#define _FILEWRITER_HPP_ - -#include - -#include - -#include -#include - -namespace dirac -{ -namespace decoder -{ - class FileWriterException : public std::runtime_error - { - public: - FileWriterException ( std::string const& message ); - }; - - class FileWriter : public IWriter<> - { - public: - typedef FILE stream; - - public: - explicit FileWriter ( std::string const& filename ); - virtual ~FileWriter(); - - private: - virtual bool available() const; - virtual bool output ( const_pointer begin, size_type count ); - - private: - stream* str_; - static std::string error_message_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _FILEWRITER_HPP_ */ diff --git a/src/decoder/FrameManagerImpl.hpp b/src/decoder/FrameManagerImpl.hpp deleted file mode 100644 index 1206a21..0000000 --- a/src/decoder/FrameManagerImpl.hpp +++ /dev/null @@ -1,163 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FRAMEMANAGERIMPL_HPP_ -#define _FRAMEMANAGERIMPL_HPP_ - -#include -#include - -#include -#include - -namespace dirac -{ -namespace decoder -{ - template - IFrameManager* - makeFrameManager ( std::auto_ptr > - , std::auto_ptr > ); - - //! manager for cration, deletion and writing of frames generated by decoders - //! - //! The class is templated in a user's optional parameter. This parameter - //! is usually the object used by the user to manage the frames. This class - //! allows the user to feed the decoder the raw frame memory and the - //! associated object without the decoder having to worry about it. - //! It also allows the user to retrieve the memory buffer and associated - //! user's object once the decoder has pushed out a frame. - template - class FrameManagerImpl : public IFrameManager - { - friend IFrameManager* - makeFrameManager ( std::auto_ptr< IWriter > - , std::auto_ptr< IFrameMemoryManager >); - - public: - typedef typename std::auto_ptr< IWriter > WriterAutoPtr; - typedef typename std::auto_ptr< IFrameMemoryManager > - FrameMemMgrAutoPtr; - - private: - FrameManagerImpl ( WriterAutoPtr writer, FrameMemMgrAutoPtr manager ) - : writer_ ( writer ), manager_ ( manager ) {} - - public: - virtual ~FrameManagerImpl() {} - - private: - virtual bool writeFrame ( const_pointer buffer - , size_type bufferSize ) - { - DIRAC_MESSAGE_ASSERT ( "Buffer cannot be null", 0 != buffer ); - Priv* priv = - // this is a safe cast - manager_->retrievePrivateParameter ( const_cast ( buffer ) ); - return writer_->write ( buffer, bufferSize, priv ); - } - - virtual pointer allocateFrame ( size_type bufferSize ) - { - DIRAC_MESSAGE_ASSERT ( "buffer size cannot be null", 0 != bufferSize ); - return manager_->allocate ( bufferSize ); - } - - virtual void releaseFrame ( pointer buffer ) - { - manager_->release ( buffer ); - } - - private: - WriterAutoPtr writer_; - FrameMemMgrAutoPtr manager_; - }; - - template<> - class FrameManagerImpl : public IFrameManager - { - friend IFrameManager* - makeFrameManager ( std::auto_ptr< IWriter > - , std::auto_ptr< IFrameMemoryManager > ); - public: - typedef std::auto_ptr< IWriter > WriterAutoPtr; - typedef std::auto_ptr< IFrameMemoryManager > FrameMemMgrAutoPtr; - - private: - FrameManagerImpl ( WriterAutoPtr writer, FrameMemMgrAutoPtr manager ) - : writer_ ( writer ), manager_ ( manager ) {} - - public: - virtual ~FrameManagerImpl() {} - - private: - virtual bool writeFrame ( const_pointer buffer - , size_type bufferSize ) - { - DIRAC_MESSAGE_ASSERT ( "Buffer cannot be null", 0 != buffer ); - DIRAC_MESSAGE_ASSERT ( "Writer cannot be null", 0 != writer_.get() ); - - return writer_->write ( buffer, bufferSize ); - } - - virtual pointer allocateFrame ( size_type bufferSize ) - { - DIRAC_MESSAGE_ASSERT ( "Buffer size cannot be null", 0 != bufferSize ); - DIRAC_MESSAGE_ASSERT ( "frame manager cannot be null" - , 0 != manager_.get() ); - - return manager_->allocate ( bufferSize ); - } - - virtual void releaseFrame ( pointer buffer ) - { - DIRAC_MESSAGE_ASSERT ( "frame manager cannot be null" - , 0 != manager_.get() ); - - manager_->release ( buffer ); - } - - private: - WriterAutoPtr writer_; - FrameMemMgrAutoPtr manager_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _FRAMEMANAGERIMPL_HPP_ */ diff --git a/src/decoder/FrameManagerMaker.hpp b/src/decoder/FrameManagerMaker.hpp deleted file mode 100644 index 8b78460..0000000 --- a/src/decoder/FrameManagerMaker.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FRAMEMANAGERMAKER_HPP_ -#define _FRAMEMANAGERMAKER_HPP_ - -#include -#include -#include -#include - -namespace dirac -{ -namespace decoder -{ - //! factory method to create objects of type FrameManagerImpl - template - IFrameManager* - makeFrameManager ( std::auto_ptr > writer - , std::auto_ptr > manager ) - { - return new FrameManagerImpl ( writer, manager ); - } - -} /* decoder */ - -} /* dirac */ - - -#endif /* _FRAMEMANAGERMAKER_HPP_ */ diff --git a/src/decoder/IDecoder.cpp b/src/decoder/IDecoder.cpp deleted file mode 100644 index 246924f..0000000 --- a/src/decoder/IDecoder.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -using namespace ::dirac::decoder; - - -void -IDecoderState::doNextAction() -{ - run(); -} - -bool -IDecoderState::isEndOfSequence() const -{ - return endOfSequence(); -} - - -DecoderException::DecoderException ( std::string const& msg ) -: std::runtime_error ( msg ) {} - - -IDecoder::size_type -IDecoder::getFrameBufferSize ( int width, int height, ChromaFormat cf ) -{ - switch ( cf ) { - case ( CHROMA_444 ) : { - return width * height * 3; - // break; - } - case ( CHROMA_422 ) : { - return width * height * 2; - // break; - } - case ( CHROMA_420 ) : { - return ( width * height * 3 ) / 2; - // break; - } - default : { - throw DecoderException ( "Dirac decoder: invalid chroma format" ); - // break; - } - } -} - -IDecoder::IDecoder ( ParserAutoPtr parser, FrameManagerAutoPtr manager ) -: parser_ ( parser ), manager_ ( manager ) -{ - DIRAC_MESSAGE_ASSERT ( "parser and frame manager cannot be null" - , 0 != parser_.get() && 0 != manager_.get() ); -} - -IDecoder::~IDecoder() {} - - -IDecoder::ParserAutoPtr -IDecoder::releaseParser() -{ - return parser_; -} - -void -IDecoder::reacquireParser ( IDecoder::ParserAutoPtr parser ) -{ - if ( parser_.get() ) { - throw DecoderException ( "tried to set a parser over an existing one" ); - } - DIRAC_MESSAGE_ASSERT ( "parser cannot be null", 0 != parser.get() ); - parser_ = parser; - resetDecoder(); -} - - -void -IDecoder::decode() -{ - runDecoder(); -} - -IDecoderState* -IDecoder::getState() -{ - return getDecoderState(); -} - -IDecoder::size_type -IDecoder::numberOfDecodedFrames() const -{ - return numberOfFrames(); -} - -IDecoder::size_type -IDecoder::frameWidth() const -{ - return getFrameWidth(); -} - -IDecoder::size_type -IDecoder::frameHeight() const -{ - return getFrameHeight(); -} - -ChromaFormat -IDecoder::chromaFormat() const -{ - return getChromaFormat(); -} - - - diff --git a/src/decoder/IDecoder.hpp b/src/decoder/IDecoder.hpp deleted file mode 100644 index d766ff2..0000000 --- a/src/decoder/IDecoder.hpp +++ /dev/null @@ -1,138 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _IDECODER_HPP_ -#define _IDECODER_HPP_ - -#include -#include - -#include -#include - -#include -#include -#include - -namespace dirac -{ -namespace decoder -{ - //! Abstract class containing the state of the decoder and its next action. - class IDecoderState : NonCopyable - { - public: - void doNextAction(); - bool isEndOfSequence() const; - - private: - virtual void run() =0; - virtual bool endOfSequence() const =0; - }; - - //! Exception for the Decoder hierarchy of classes - struct DecoderException : public std::runtime_error - { - DecoderException ( std::string const& msg ); - }; - - enum ChromaFormat { - //! Chroma format: 4-4-4 - CHROMA_444 - //! Chroma format: 4-2-2 - , CHROMA_422 - //! Chroma format: 4-2-0 - , CHROMA_420 - //! Invalid chroma format - , UNDEFINED - }; - - //! Generic interface for a Dirac decoder - class IDecoder : NonCopyable - { - public: - typedef IDecoder class_type; - typedef std::auto_ptr FrameManagerAutoPtr; - typedef std::auto_ptr ParserAutoPtr; - typedef parser::AccessUnit AU; - typedef AU::Buffer InputBuffer; - typedef size_t size_type; - typedef uint8 value_type; - typedef value_type* pointer; - typedef value_type const* const_pointer; - - public: - IDecoder ( ParserAutoPtr parser, FrameManagerAutoPtr manager ); - virtual ~IDecoder(); - - public: // main methods - ParserAutoPtr releaseParser(); - void reacquireParser ( ParserAutoPtr parser ); - - //! run the decoder autonomously, from beginning to end, if it can - //! it cannot be interrupted - void decode(); - IDecoderState* getState(); - - size_type numberOfDecodedFrames() const; - size_type frameWidth() const; - size_type frameHeight() const; - ChromaFormat chromaFormat() const; - static size_type getFrameBufferSize ( int widht - , int height - , ChromaFormat cf ); - - - private: - virtual void runDecoder() =0; - virtual IDecoderState* getDecoderState() =0; - virtual size_type numberOfFrames() const =0; - virtual void resetDecoder() =0; - virtual size_type getFrameWidth() const =0; - virtual size_type getFrameHeight() const =0; - virtual ChromaFormat getChromaFormat() const =0; - - protected: - ParserAutoPtr parser_; - FrameManagerAutoPtr manager_; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _IDECODER_HPP_ */ diff --git a/src/decoder/IFrameManager.cpp b/src/decoder/IFrameManager.cpp deleted file mode 100644 index 7f6ad86..0000000 --- a/src/decoder/IFrameManager.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -using namespace ::dirac::decoder; - -IFrameManager::IFrameManager() {} - -IFrameManager::~IFrameManager() {} - -bool -IFrameManager::write ( IFrameManager::const_pointer buffer - , IFrameManager::size_type bufferSize ) -{ - return writeFrame ( buffer, bufferSize ); -} - -IFrameManager::pointer -IFrameManager::allocate ( IFrameManager::size_type bufferSize ) -{ - return allocateFrame ( bufferSize ); -} - -void -IFrameManager::release ( IFrameManager::pointer buffer ) -{ - releaseFrame ( buffer ); -} - diff --git a/src/decoder/IFrameManager.hpp b/src/decoder/IFrameManager.hpp deleted file mode 100644 index 46b2b28..0000000 --- a/src/decoder/IFrameManager.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _IFRAMEMANAGER_HPP_ -#define _IFRAMEMANAGER_HPP_ - -#include -#include -#include -#include - -#include - -namespace dirac -{ -namespace decoder -{ - class IFrameManager : NonCopyable - { - public: - typedef IFrameManager class_type; - typedef uint8 value_type; - typedef value_type* pointer; - typedef value_type const* const_pointer; - typedef size_t size_type; - - public: - IFrameManager(); - virtual ~IFrameManager(); - - public: - bool write ( const_pointer buffer - , size_type bufferSize ); - pointer allocate ( size_type bufferSize ); - void release ( pointer buffer ); - - private: - virtual bool writeFrame ( const_pointer buffer - , size_type bufferSize ) =0; - virtual pointer allocateFrame ( size_type bufferSize ) =0; - virtual void releaseFrame ( pointer buffer ) =0; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _IFRAMEMANAGER_HPP_ */ diff --git a/src/decoder/IFrameMemoryManager.hpp b/src/decoder/IFrameMemoryManager.hpp deleted file mode 100644 index 1ddf79e..0000000 --- a/src/decoder/IFrameMemoryManager.hpp +++ /dev/null @@ -1,160 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _IFRAMEMEMORYMANAGER_HPP_ -#define _IFRAMEMEMORYMANAGER_HPP_ - -#include -#include - -#include -#include -#include -#include -#include - -namespace dirac -{ -namespace decoder -{ - struct FrameMemoryManagerException : public std::runtime_error - { - FrameMemoryManagerException ( std::string const& msg ) - : std::runtime_error ( msg ) {} - }; - - template - class IFrameMemoryManager : NonCopyable - { - public: - typedef uint8* Buffer; - typedef uint8 const* BufferConst; - typedef size_t size_type; - typedef Priv parameter_type; - - typedef std::map PrivateMap; - typedef typename PrivateMap::value_type value_type; - typedef typename PrivateMap::iterator iterator; - typedef typename PrivateMap::const_iterator const_iterator; - - public: - IFrameMemoryManager() {} - virtual ~IFrameMemoryManager() {} - - public: - Buffer allocate ( size_type bufferSize ) - { - Priv* priv = 0; - Buffer ret = allocateFrame ( bufferSize, priv ); - storePrivateParameter ( ret, priv ); - return ret; - } - - void release ( Buffer buffer ) - { - Priv* priv = retrievePrivateParameter ( buffer ); - releaseFrame ( buffer, priv ); - } - - //! retrieve private parameter and removes it from the internal map upon success - Priv* retrievePrivateParameter ( Buffer buffer ) - { - iterator ret = map_.find ( buffer ); - if ( map_.end() == ret ) { - return static_cast ( 0 ); - } - else { - map_.erase ( ret ); - return ret->second; - } - } - - private: - virtual Buffer allocateFrame ( size_type bufferSize, Priv*& priv ) =0; - virtual void releaseFrame ( Buffer buffer, Priv* priv ) =0; - - private: - void storePrivateParameter ( Buffer buffer, Priv* priv ) - { - DIRAC_MESSAGE_ASSERT ( "buffer and private data cannot be null" - , 0 != buffer && 0 != priv ); - std::pair ret = map_.insert ( value_type ( buffer, priv ) ); - if ( !ret.second ) { - throw FrameMemoryManagerException - ( "failed to store user data in IFrameMemoryManager - same buffer used twice ?"); - } - } - - private: - PrivateMap map_; - }; - - template<> - class IFrameMemoryManager - { - public: - typedef uint8* Buffer; - typedef uint8 const* BufferConst; - typedef uint8 value_type; - typedef void parameter_type; - typedef size_t size_type; - - public: - IFrameMemoryManager() {} - virtual ~IFrameMemoryManager() {} - // compiler generated methods are ok (no state associated with this class) - - public: - Buffer allocate ( size_type bufferSize ) - { - return allocateFrame ( bufferSize ); - } - void release ( Buffer buffer ) - { - releaseFrame ( buffer ); - } - - private: - virtual Buffer allocateFrame ( size_type bufferSize ) =0; - virtual void releaseFrame ( Buffer buffer ) =0; - }; -} /* decoder */ - -} /* dirac */ - - -#endif /* _IFRAMEMEMORYMANAGER_HPP_ */ diff --git a/src/decoder/IWriter.hpp b/src/decoder/IWriter.hpp deleted file mode 100644 index 724b5c4..0000000 --- a/src/decoder/IWriter.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _IWRITER_HPP_ -#define _IWRITER_HPP_ - -#include -#include - -#include - -namespace dirac -{ -namespace decoder -{ - template - class IWriter : NonCopyable - { - public: - typedef uint8 value_type; - typedef value_type const* const_pointer; - typedef size_t size_type; - - typedef Priv parameter_type; - - public: - IWriter() {} - virtual ~IWriter() {} - - public: - bool write ( const_pointer begin, size_type count - , Priv* priv ) - { - return output ( begin, count, priv ); - } - - bool isAvailable() const - { - return available(); - } - - private: - virtual bool output ( const_pointer begin, size_type count - , Priv* priv ) =0; - virtual bool available() const =0; - }; - - template<> - class IWriter : NonCopyable - { - public: - typedef uint8 value_type; - typedef value_type const* const_pointer; - typedef size_t size_type; - - typedef void parameter_type; - - public: - IWriter() {} - virtual ~IWriter() {} - - public: - bool write ( const_pointer begin, size_type count ) - { - return output ( begin, count ); - } - - bool isAvailable() const - { - return available(); - } - - private: - virtual bool output ( const_pointer begin, size_type count ) =0; - virtual bool available() const =0; - }; - -} /* decoder */ - -} /* dirac */ - - -#endif /* _IWRITER_HPP_ */ diff --git a/src/decoder/Makefile.am b/src/decoder/Makefile.am deleted file mode 100644 index 0a7ee1d..0000000 --- a/src/decoder/Makefile.am +++ /dev/null @@ -1,47 +0,0 @@ -INCLUDES = -I$(top_srcdir)/src -I$(srcdir) - -h_sources = FileReader.hpp \ - FileWriter.hpp \ - FrameManagerImpl.hpp \ - IDecoder.hpp \ - IFrameManager.hpp \ - IFrameMemoryManager.hpp \ - FrameManagerMaker.hpp \ - IWriter.hpp \ - DefaultFrameMemoryManager.hpp - -lib_h_sources = \ - IDecoder.hpp \ - IWriter.hpp \ - IFrameMemoryManager.hpp - -cpp_sources = FileReader.cpp \ - FileWriter.cpp \ - IDecoder.cpp \ - IFrameManager.cpp \ - DefaultFrameMemoryManager.cpp - -if HAVE_DIRAC - h_sources += Diracdec.hpp \ - DiracState.hpp - - cpp_sources += Diracdec.cpp \ - DiracState.cpp -endif - -if HAVE_SCHRO -h_sources += Schrodec.hpp \ - SchroState.hpp - -cpp_sources += Schrodec.cpp \ - SchroState.cpp -endif - -lib_LTLIBRARIES = libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_decoder.la - -libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_decoder_la_SOURCES = $(h_sources) $(cpp_sources) -libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_decoder_la_CXXFLAGS = $(SCHROEDINGER_CFLAGS) $(DIRAC_CFLAGS) $(AM_CXXFLAGS) -#libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_decoder_la_LIBADD = $(top_builddir)/src/parser/libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_parser.la - -library_includedir=$(includedir)/dirac_parser-@DIRAC_PARSER_MAJORMINOR@/decoder -library_include_HEADERS = $(lib_h_sources) diff --git a/src/decoder/SchroState.cpp b/src/decoder/SchroState.cpp deleted file mode 100644 index 5d857e2..0000000 --- a/src/decoder/SchroState.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -#include - - -namespace dirac -{ -namespace decoder -{ - IDecoderState* - makeSchroState ( Schrodec& schrodec, int schro_state ) - { - DIRAC_MESSAGE_ASSERT ( "state must be one of the possible schro status values" - , schro_state == SCHRO_DECODER_OK - || schro_state == SCHRO_DECODER_ERROR - || schro_state == SCHRO_DECODER_EOS - || schro_state == SCHRO_DECODER_NEED_BITS - || schro_state == SCHRO_DECODER_NEED_FRAME ); - - switch ( schro_state ) { - case ( SCHRO_DECODER_NEED_BITS ) : - return new SchroNeedInput ( schrodec ); - // break; - case ( SCHRO_DECODER_OK ) : - return new SchroFrameReady ( schrodec ); - // break; - case ( SCHRO_DECODER_NEED_FRAME ) : - return new SchroNeedFrame ( schrodec ); - // break; - case ( SCHRO_DECODER_EOS ) : - return new SchroEndOfSequence; - // break; - case ( SCHRO_DECODER_ERROR ) : - return new SchroError; - // break; - default : - return new SchroNull; - // break; - } - } - - -} /* decoder */ - -} /* dirac */ - - - -using namespace ::dirac::decoder; - - -SchroNeedInput::SchroNeedInput ( Schrodec& schrodec ) -: schrodec_ ( schrodec ) {} - -void -SchroNeedInput::run() -{ - schrodec_.pushBits(); -} - -bool -SchroNeedInput::endOfSequence() const -{ - return false; -} - -SchroNeedFrame::SchroNeedFrame ( Schrodec& schrodec ) -: schrodec_ ( schrodec ) {} - -void -SchroNeedFrame::run() -{ - schrodec_.setFrame(); -} - -bool -SchroNeedFrame::endOfSequence() const -{ - return false; -} - -SchroFrameReady::SchroFrameReady ( Schrodec& schrodec ) -: schrodec_ ( schrodec ) {} - -void -SchroFrameReady::run() -{ - schrodec_.pullFrameAndWrite(); -} - -bool -SchroFrameReady::endOfSequence() const -{ - return false; -} - -SchroError::SchroError() {} - -void -SchroError::run() -{ - throw DecoderException ( "Error while decoding stream"); -} - -bool -SchroError::endOfSequence() const -{ - return false; -} - -SchroEndOfSequence::SchroEndOfSequence() {} - -void -SchroEndOfSequence::run() -{ - // do nothing -} - -bool -SchroEndOfSequence::endOfSequence() const -{ - return true; -} - -SchroNull::SchroNull() {} - -void -SchroNull::run() -{ - throw DecoderException ( "programming error!" ); -} - -bool -SchroNull::endOfSequence() const -{ - return false; -} - - - diff --git a/src/decoder/SchroState.hpp b/src/decoder/SchroState.hpp deleted file mode 100644 index 7ffaaf7..0000000 --- a/src/decoder/SchroState.hpp +++ /dev/null @@ -1,136 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _SCHROSTATE_HPP_ -#define _SCHROSTATE_HPP_ - -#include -#include - -#include - -namespace dirac -{ -namespace decoder -{ - // forward declaration - class Schrodec; - - //! factory method used to generate objects of type IDecoderState - //! - //! \a schrodec the schro decoder associated with the schro state - //! \a schro_state the state value returned by schro_decoder_wait - IDecoderState* makeSchroState ( Schrodec& schrodec - , int schro_state ); - - - class SchroNeedInput : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroNeedInput ( Schrodec& schrodec ); - - virtual void run (); - virtual bool endOfSequence() const; - - Schrodec& schrodec_; - }; - - class SchroNeedFrame : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroNeedFrame ( Schrodec& schrodec ); - - virtual void run (); - virtual bool endOfSequence() const; - - Schrodec& schrodec_; - }; - - class SchroFrameReady : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroFrameReady ( Schrodec& schrodec ); - - virtual void run (); - virtual bool endOfSequence() const; - - Schrodec& schrodec_; - }; - - class SchroError : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroError(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class SchroEndOfSequence : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroEndOfSequence(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - class SchroNull : public IDecoderState - { - friend IDecoderState* makeSchroState(Schrodec&, int); - //! private constructor - SchroNull(); - - virtual void run(); - virtual bool endOfSequence() const; - }; - - - - - -} /* decoder */ - -} /* dirac */ - - -#endif /* _SCHROSTATE_HPP_ */ diff --git a/src/decoder/Schrodec.cpp b/src/decoder/Schrodec.cpp deleted file mode 100644 index 95c0f47..0000000 --- a/src/decoder/Schrodec.cpp +++ /dev/null @@ -1,315 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include - -using namespace ::dirac::decoder; -using namespace ::dirac::parser_project; - -namespace -{ - IDecoder::size_type - getBufferSizeFroFrame ( SchroFrame* frame ) - { - DIRAC_MESSAGE_ASSERT ( "frame cannot be null", 0 != frame ); - - IDecoder::size_type ret = 0; - for (int i=0; i<3; ++i) ret += frame->components[i].length; - return ret; - } -} /* */ - -//! init schro, parse and decode sequence header and obtain video format params -Schrodec::Schrodec ( IDecoder::ParserAutoPtr parser - , IDecoder::FrameManagerAutoPtr manager ) -: IDecoder ( parser, manager ), numberOfDecodedFrames_ ( 0 ) -{ - initSchro(); - fetchSequenceHeader(); -} - -Schrodec::~Schrodec() {} - -Schrodec::VideoFormatSharedPtr -Schrodec::getVideoFormat() const -{ - return videoFormat_; -} - -void -Schrodec::createDecoder() -{ - DecoderSharedPtr tmp ( schro_decoder_new(), schro_decoder_free ); - decoder_.swap ( tmp ); - if ( !decoder_.get() ) { - throw DecoderException ( "failed to create schro decoder" ); - } - schro_decoder_set_skip_ratio ( decoder_.get(), 1.0 ); -} - -void -Schrodec::initSchro() -{ - schro_init(); - createDecoder(); -} - -void -Schrodec::resetDecoder() -{ - if ( decoder_.get() ) { - decoder_.reset(); - createDecoder(); - numberOfDecodedFrames_ = 0; - fetchSequenceHeader(); - } -} - -void -Schrodec::deleteBuffer ( SchroBuffer* schrobuffer, void* inputBuffer ) -{ - delete static_cast ( inputBuffer ); -} - -void -Schrodec::createSchroBuffer(IDecoder::AU& au, SchroBuffer*& schrobuffer ) -{ - InputBuffer* buf = au.releaseBuffer(); - schrobuffer = schro_buffer_new_with_data ( &(*buf)[0] , buf->size() ); - if ( !schrobuffer ) { - throw DecoderException ( "failed to create input buffer for schodec" ); - } - schrobuffer->priv = buf; - schrobuffer->free = deleteBuffer; -} - -void -Schrodec::fetchSequenceHeader() -{ - DIRAC_MESSAGE_ASSERT ( "parser cannot be null", 0 != parser_.get() ); - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - AccessUnit au; - if ( !parser_->getNextSequenceHeader ( au ) || au.empty() ) { - throw DecoderException ( "failed to parser sequence header" ); - } - - SchroBuffer* schrobuffer = 0; - createSchroBuffer ( au, schrobuffer ); - - if ( SCHRO_DECODER_FIRST_ACCESS_UNIT != - schro_decoder_push ( decoder_.get(), schrobuffer ) ) { - throw DecoderException ( "failed to decode sequence header" ); - } - - VideoFormatSharedPtr tmp ( schro_decoder_get_video_format ( decoder_.get() ) - , free ); - videoFormat_.swap ( tmp ); - if ( !videoFormat_.get() ) { - throw DecoderException ( "failed to extract video format" ); - } -} - -void -Schrodec::signOff() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - schro_decoder_push_end_of_stream ( decoder_.get() ); -} - -IDecoderState* -Schrodec::getDecoderState() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - return makeSchroState ( *this, schro_decoder_wait ( decoder_.get() ) ); -} - -//! parse a picture and push it in the decoder -void -Schrodec::pushBits() -{ - DIRAC_MESSAGE_ASSERT ( "parser and decoder cannot be null" - , 0 != parser_.get() && 0 != decoder_.get() ); - - // parse a picture, but check whether we reach the end of the sequence - AccessUnit au; - do { - if ( !parser_->getNextAccessUnit ( au ) || au.isLastEndOfSequence() - || !parser_->moveCursorFwd() ) { - signOff(); - return; - } - } while ( !au.isPicture() ); - - SchroBuffer* schrobuffer = 0; - createSchroBuffer ( au, schrobuffer ); - - int it = schro_decoder_push ( decoder_.get(), schrobuffer ); - if ( SCHRO_DECODER_ERROR == it ) { - throw DecoderException ( "failed to decode picture" ); - } -} - -//! static method used as a deleter for schro frame -void -Schrodec::deleteFrame ( SchroFrame* frame, void* decoder ) -{ - DIRAC_MESSAGE_ASSERT ( "frame cannot be null", 0 != frame ); - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder ); - - static_cast ( decoder )->manager_->release - ( static_cast ( frame->components[0].data ) ); -} - -//! allocate memory for a frame worth of data -void -Schrodec::setFrame() -{ - DIRAC_MESSAGE_ASSERT ( "parser, decoder and video format cannot be null" - , 0 != parser_.get() && 0 != decoder_.get() - && 0 != videoFormat_.get() ); - pointer buffer = manager_->allocate ( getFrameBufferSize( frameWidth() - , frameHeight() - , chromaFormat() ) ); - SchroFrame* frame = schro_frame_new_from_data_I420 ( buffer - , frameWidth() - , frameHeight() ); - schro_frame_set_free_callback ( frame, deleteFrame, this ); - schro_decoder_add_output_picture ( decoder_.get(), frame ); -} - -void -Schrodec::pullFrameAndWrite() -{ - DIRAC_MESSAGE_ASSERT ( "decoder and manager cannot be null" - , 0 != decoder_.get() && 0 != manager_.get() ); - - SchroFrame* frame = schro_decoder_pull ( decoder_.get() ); - if ( frame ) { - ++numberOfDecodedFrames_; - write ( frame ); - schro_frame_unref ( frame ); - } -} - -bool -Schrodec::write ( SchroFrame* frame ) -{ - DIRAC_MESSAGE_ASSERT ( "frame cannot be null", 0 != frame ); - DIRAC_MESSAGE_ASSERT ( "videoformat cannot be null", 0 != videoFormat_.get() ); - DIRAC_MESSAGE_ASSERT ( "frame manager cannot be null", 0 != manager_.get() ); - - // here we can format the data for output, if required - return manager_->write ( static_cast ( frame->components[0].data ) - , getBufferSizeFroFrame ( frame ) ); -} - -void -Schrodec::runDecoder() -{ - DIRAC_MESSAGE_ASSERT ( "decoder cannot be null", 0 != decoder_.get() ); - - std::auto_ptr decoderState; - do { - std::auto_ptr tmp ( getState() ); - decoderState = tmp; // the previous DecoderState gets deleted here - decoderState->doNextAction(); - } while ( !decoderState->isEndOfSequence() ); -} - -IDecoder::size_type -Schrodec::numberOfFrames() const -{ - return numberOfDecodedFrames_; -} - -Schrodec::size_type -Schrodec::getFrameWidth() const -{ - if ( videoFormat_.get() ) { - return videoFormat_->width; - } - else { - return 0; - } -} - -IDecoder::size_type -Schrodec::getFrameHeight() const -{ - if ( videoFormat_.get() ) { - return videoFormat_->height; - } - else { - return 0; - } -} - -ChromaFormat -Schrodec::getChromaFormat() const -{ - if ( videoFormat_.get() ) { - switch ( videoFormat_->chroma_format ) { - case ( SCHRO_CHROMA_444 ) : - return CHROMA_444; - // break; - case ( SCHRO_CHROMA_422 ) : - return CHROMA_422; - // break; - case ( SCHRO_CHROMA_420 ) : - return CHROMA_420; - // break; - default : - return UNDEFINED; - // break; - } - } - else { - return UNDEFINED; - } -} - - diff --git a/src/decoder/Schrodec.hpp b/src/decoder/Schrodec.hpp deleted file mode 100644 index f000125..0000000 --- a/src/decoder/Schrodec.hpp +++ /dev/null @@ -1,123 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _SCHRODEC_HPP_ -#define _SCHRODEC_HPP_ - - -#include -#include - -#include - - -namespace dirac -{ -namespace decoder -{ - - class SchroNeedInput; - class SchroNeedFrame; - class SchroFrameReady; - class SchroError; - class SchroEndOfSequence; - class SchroNull; - - //! A c++ wrapper for the schroedinger decoder - class Schrodec : public IDecoder - { - friend class SchroNeedInput; - friend class SchroNeedFrame; - friend class SchroFrameReady; - friend class SchroEndOfSequence; - friend class SchroError; - friend class SchroNull; - - public: - typedef Schrodec class_type; - typedef std::tr1::shared_ptr DecoderSharedPtr; - typedef std::tr1::shared_ptr VideoFormatSharedPtr; - - public: - Schrodec ( ParserAutoPtr parser, FrameManagerAutoPtr manager ); - ~Schrodec(); - - private: - //! run the decoder autonomously, from beginning to end, if it can - //! it cannot be interrupted - virtual void runDecoder(); - - virtual IDecoderState* getDecoderState(); - virtual size_type numberOfFrames() const; - - virtual size_type getFrameWidth() const; - virtual size_type getFrameHeight() const; - virtual ChromaFormat getChromaFormat() const; - virtual void resetDecoder(); - - private: - VideoFormatSharedPtr getVideoFormat() const; - void pushBits(); - void setFrame(); - void pullFrameAndWrite(); - - private: - void initSchro(); - void createDecoder(); - void fetchSequenceHeader(); - bool write ( SchroFrame* frame ); - void createSchroBuffer( AU& au - , SchroBuffer*& buffer ); - void signOff(); - - static void deleteFrame ( SchroFrame* frame - , void* decoder ); - static void deleteBuffer ( SchroBuffer* schrobuffer - , void* inputBuffer ); - - private: - VideoFormatSharedPtr videoFormat_; - DecoderSharedPtr decoder_; - size_type numberOfDecodedFrames_; - }; - -} /* decoder */ - -} /* dirac */ - - -#endif /* _SCHRODEC_HPP_ */ diff --git a/src/examples/.svn/entries b/src/examples/.svn/entries deleted file mode 100644 index 09053b7..0000000 --- a/src/examples/.svn/entries +++ /dev/null @@ -1,52 +0,0 @@ -8 - -dir -82 -file:///project/compression/andrea/svnrepos/dirac1.0/trunk/src/examples -file:///project/compression/andrea/svnrepos - - - -2008-03-11T16:18:48.736334Z -76 -andrea - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -1eccbc7e-7240-0410-8f13-87e4ac67b0a8 - -Makefile.am -file - - - - -2008-03-19T17:17:18.000000Z -05bd4ad332092a74d89a763f838b78dd -2008-03-11T16:18:48.736334Z -76 -andrea - -decoder.cc -file - - - - -2008-03-19T17:17:18.000000Z -65c08985b2c0392224bc3f30a34e460e -2008-03-04T15:52:17.257620Z -73 -andrea - diff --git a/src/examples/.svn/format b/src/examples/.svn/format deleted file mode 100644 index 45a4fb7..0000000 --- a/src/examples/.svn/format +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/src/examples/.svn/text-base/Makefile.am.svn-base b/src/examples/.svn/text-base/Makefile.am.svn-base deleted file mode 100644 index c09a0dc..0000000 --- a/src/examples/.svn/text-base/Makefile.am.svn-base +++ /dev/null @@ -1,15 +0,0 @@ -INCLUDES = -I$(top_srcdir)/src -I$(srcdir) - -bin_PROGRAMS = decoder - -decoder_SOURCES = decoder.cc - -decoder_CXXFLAGS = $(SCHROEDINGER_CFLAGS) $(DIRAC_CFLAGS) - -decoder_LDADD = ../decoder/libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_decoder.la \ - ../parser/libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_parser.la \ - $(SCHROEDINGER_LIBS) $(DIRAC_LIBS) -if USE_STATIC -decoder_LDFLAGS = $(LDFLAGS) -static -else -endif diff --git a/src/examples/.svn/text-base/decoder.cc.svn-base b/src/examples/.svn/text-base/decoder.cc.svn-base deleted file mode 100644 index abfe64f..0000000 --- a/src/examples/.svn/text-base/decoder.cc.svn-base +++ /dev/null @@ -1,228 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: schro_decoder.cpp 37 2008-02-07 09:18:30Z andrea $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include -#include -#include - -#ifdef HAVE_SCHRO -#include -#endif - -#ifdef HAVE_DIRAC -#include -#endif - -#include -#include - -#include -#include -#include - - - -#include -#include -#include -#include -#include - -using namespace ::dirac::parser_project; -using namespace ::dirac::decoder; - - -namespace -{ - - - class Arguments - { - public: - Arguments ( int argc, char const* argv[] ) - : inputFileName_ ( ""), outputFileName_ ( "" ), isValid_ ( false ) - , isSchro_ ( true ) - { - DIRAC_MESSAGE_ASSERT ( "argv caanot be null", 0 != argv ); - if ( 1 == argc ) { - printUsage(argv[0]); - return; - } - int offset = 1; - while ( '-' == *argv[offset] ) { - if ( !strcmp ( argv[offset], "-h" ) - || !strcmp ( argv[offset], "-help" ) ) { - ++offset; - } - else if ( !strcmp ( argv[offset], "-schro" ) ) { - isSchro_ = true; - ++offset; - } - else if ( !strcmp ( argv[offset], "-dirac" ) ) { - isSchro_ = false; - ++offset; - } - else { - printUsage(argv[0]); - return; - } - } - if ( argc - offset != 2) { - printUsage (argv[0]); - return; - } - inputFileName_ = argv[offset]; - outputFileName_ = argv[++offset]; - isValid_ = true; - } - // compiler defined methods are allowed - - public: - std::string inputFileName() const { return inputFileName_; } - std::string outputFileName() const { return outputFileName_; } - bool isValid() const { return isValid_; } - bool isSchro() const { return isSchro_;} - bool isDirac() const { return !isSchro_; } - private: - void printUsage ( std::string processName ) - { - std::cout << "Wavelet video decoder: Schroedinger and Dirac under one roof." << std::endl; - std::cout << "Usage: " << processName << " [-h] [-schro|-dirac] input-file output-file"; - std::cout << std::endl; - std::cout << "\t-h Display help message" << std::endl; - - #ifdef HAVE_SCHRO - std::cout << "\t-schro Select the Schroedinger decoder (default)" << std::endl; - #endif - - #ifdef HAVE_DIRAC - std::cout << "\t-dirac Select the Dirac decoder" << std::endl; - #endif - - std::cout << "\tinput-file dirac file name excluding extension" << std::endl; - std::cout << "\toutput-file decoded output file, excluding extension" << std::endl; - } - - bool help_; - std::string inputFileName_, outputFileName_; - bool isValid_; - bool isSchro_; - }; - - IDecoder* - makeDecoder ( Arguments const& args ) - { - std::auto_ptr input ( new FileReader ( args.inputFileName() ) ); - std::auto_ptr reader ( new StreamReader ( input, 50 ) ); - std::auto_ptr parser ( new Parser ( reader ) ); - std::auto_ptr > writer ( new FileWriter ( args.outputFileName() ) ); - std::auto_ptr > frameMemMgr - ( new DefaultFrameMemoryManager ); - std::auto_ptr manager - ( makeFrameManager ( writer, frameMemMgr ) ); - if ( args.isSchro() ) { - #ifdef HAVE_SCHRO - std::cout << "About to decode " << args.inputFileName(); - std::cout << " with the schroedinger decoder.\n\n"; - return new Schrodec ( parser, manager ); - #else - std::cerr << "Schroedinger library not supported\n"; - return 0; - #endif - } - else { - #ifdef HAVE_DIRAC - std::cout << "\nAbout to decode " << args.inputFileName(); - std::cout << " with the dirac decoder.\n"; - return new Diracdec ( parser, manager ); - #else - std::cerr << "Dirac library not supported\n"; - return 0; - #endif - } - } -} /* */ - - -int main (int argc, char const* argv[]) -{ - // parse command line arguments - Arguments args ( argc, argv ); - if ( !args.isValid() ) return 0; - - size_t frameCount = 0; - // create input - try { - std::auto_ptr decoder ( makeDecoder ( args ) ); - if ( !decoder.get() ) { - std::cout << "Programming error: failed to create decoder object" << std::endl; - return 0; - } - - // If we don't need to interrupt the decoding process we can just invoke - // decoder->decode(); - std::auto_ptr decoderState; - do { - std::auto_ptr tmp ( decoder->getState() ); - decoderState = tmp; // the previous DecoderState gets deleted here - decoderState->doNextAction(); - // check loop condition here, if needed - } while ( !decoderState->isEndOfSequence() ); - frameCount = decoder->numberOfDecodedFrames(); - } - catch ( std::runtime_error& exc ) { - std::cout << "Error while decoding " << args.inputFileName(); - std::cout << std::endl; - std::cout << exc.what() << std::endl; - return 0; - } - catch (...) { - std::cout << "Unexpected exception" << std::endl; - return 0; - } - - std::cout << "Decoded : " << frameCount << " frames." << std::endl; - - return 0; -} diff --git a/src/examples/Makefile.am b/src/examples/Makefile.am deleted file mode 100644 index c09a0dc..0000000 --- a/src/examples/Makefile.am +++ /dev/null @@ -1,15 +0,0 @@ -INCLUDES = -I$(top_srcdir)/src -I$(srcdir) - -bin_PROGRAMS = decoder - -decoder_SOURCES = decoder.cc - -decoder_CXXFLAGS = $(SCHROEDINGER_CFLAGS) $(DIRAC_CFLAGS) - -decoder_LDADD = ../decoder/libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_decoder.la \ - ../parser/libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_parser.la \ - $(SCHROEDINGER_LIBS) $(DIRAC_LIBS) -if USE_STATIC -decoder_LDFLAGS = $(LDFLAGS) -static -else -endif diff --git a/src/examples/decoder.cc b/src/examples/decoder.cc deleted file mode 100644 index abfe64f..0000000 --- a/src/examples/decoder.cc +++ /dev/null @@ -1,228 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: schro_decoder.cpp 37 2008-02-07 09:18:30Z andrea $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include -#include -#include - -#ifdef HAVE_SCHRO -#include -#endif - -#ifdef HAVE_DIRAC -#include -#endif - -#include -#include - -#include -#include -#include - - - -#include -#include -#include -#include -#include - -using namespace ::dirac::parser_project; -using namespace ::dirac::decoder; - - -namespace -{ - - - class Arguments - { - public: - Arguments ( int argc, char const* argv[] ) - : inputFileName_ ( ""), outputFileName_ ( "" ), isValid_ ( false ) - , isSchro_ ( true ) - { - DIRAC_MESSAGE_ASSERT ( "argv caanot be null", 0 != argv ); - if ( 1 == argc ) { - printUsage(argv[0]); - return; - } - int offset = 1; - while ( '-' == *argv[offset] ) { - if ( !strcmp ( argv[offset], "-h" ) - || !strcmp ( argv[offset], "-help" ) ) { - ++offset; - } - else if ( !strcmp ( argv[offset], "-schro" ) ) { - isSchro_ = true; - ++offset; - } - else if ( !strcmp ( argv[offset], "-dirac" ) ) { - isSchro_ = false; - ++offset; - } - else { - printUsage(argv[0]); - return; - } - } - if ( argc - offset != 2) { - printUsage (argv[0]); - return; - } - inputFileName_ = argv[offset]; - outputFileName_ = argv[++offset]; - isValid_ = true; - } - // compiler defined methods are allowed - - public: - std::string inputFileName() const { return inputFileName_; } - std::string outputFileName() const { return outputFileName_; } - bool isValid() const { return isValid_; } - bool isSchro() const { return isSchro_;} - bool isDirac() const { return !isSchro_; } - private: - void printUsage ( std::string processName ) - { - std::cout << "Wavelet video decoder: Schroedinger and Dirac under one roof." << std::endl; - std::cout << "Usage: " << processName << " [-h] [-schro|-dirac] input-file output-file"; - std::cout << std::endl; - std::cout << "\t-h Display help message" << std::endl; - - #ifdef HAVE_SCHRO - std::cout << "\t-schro Select the Schroedinger decoder (default)" << std::endl; - #endif - - #ifdef HAVE_DIRAC - std::cout << "\t-dirac Select the Dirac decoder" << std::endl; - #endif - - std::cout << "\tinput-file dirac file name excluding extension" << std::endl; - std::cout << "\toutput-file decoded output file, excluding extension" << std::endl; - } - - bool help_; - std::string inputFileName_, outputFileName_; - bool isValid_; - bool isSchro_; - }; - - IDecoder* - makeDecoder ( Arguments const& args ) - { - std::auto_ptr input ( new FileReader ( args.inputFileName() ) ); - std::auto_ptr reader ( new StreamReader ( input, 50 ) ); - std::auto_ptr parser ( new Parser ( reader ) ); - std::auto_ptr > writer ( new FileWriter ( args.outputFileName() ) ); - std::auto_ptr > frameMemMgr - ( new DefaultFrameMemoryManager ); - std::auto_ptr manager - ( makeFrameManager ( writer, frameMemMgr ) ); - if ( args.isSchro() ) { - #ifdef HAVE_SCHRO - std::cout << "About to decode " << args.inputFileName(); - std::cout << " with the schroedinger decoder.\n\n"; - return new Schrodec ( parser, manager ); - #else - std::cerr << "Schroedinger library not supported\n"; - return 0; - #endif - } - else { - #ifdef HAVE_DIRAC - std::cout << "\nAbout to decode " << args.inputFileName(); - std::cout << " with the dirac decoder.\n"; - return new Diracdec ( parser, manager ); - #else - std::cerr << "Dirac library not supported\n"; - return 0; - #endif - } - } -} /* */ - - -int main (int argc, char const* argv[]) -{ - // parse command line arguments - Arguments args ( argc, argv ); - if ( !args.isValid() ) return 0; - - size_t frameCount = 0; - // create input - try { - std::auto_ptr decoder ( makeDecoder ( args ) ); - if ( !decoder.get() ) { - std::cout << "Programming error: failed to create decoder object" << std::endl; - return 0; - } - - // If we don't need to interrupt the decoding process we can just invoke - // decoder->decode(); - std::auto_ptr decoderState; - do { - std::auto_ptr tmp ( decoder->getState() ); - decoderState = tmp; // the previous DecoderState gets deleted here - decoderState->doNextAction(); - // check loop condition here, if needed - } while ( !decoderState->isEndOfSequence() ); - frameCount = decoder->numberOfDecodedFrames(); - } - catch ( std::runtime_error& exc ) { - std::cout << "Error while decoding " << args.inputFileName(); - std::cout << std::endl; - std::cout << exc.what() << std::endl; - return 0; - } - catch (...) { - std::cout << "Unexpected exception" << std::endl; - return 0; - } - - std::cout << "Decoded : " << frameCount << " frames." << std::endl; - - return 0; -} diff --git a/src/parser/.svn/entries b/src/parser/.svn/entries deleted file mode 100644 index 17a6898..0000000 --- a/src/parser/.svn/entries +++ /dev/null @@ -1,208 +0,0 @@ -8 - -dir -82 -file:///project/compression/andrea/svnrepos/dirac1.0/trunk/src/parser -file:///project/compression/andrea/svnrepos - - - -2008-03-11T16:18:48.736334Z -76 -andrea - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -1eccbc7e-7240-0410-8f13-87e4ac67b0a8 - -buffer.hpp -file - - - - -2008-03-19T17:17:15.000000Z -44cf250ca49d6622c3b73dc5588dc05f -2008-02-07T09:18:30.604498Z -37 -andrea -has-props - -scanner.hpp -file - - - - -2008-03-19T17:17:15.000000Z -edc8e48ce8fa46f88ef91140147253f4 -2008-02-07T09:18:30.604498Z -37 -andrea -has-props - -Parser.hpp -file - - - - -2008-03-19T17:17:15.000000Z -1b0418709163d38d449bef3ece8d719a -2008-03-04T13:16:25.980552Z -67 -andrea -has-props - -parser.h -file - - - - -2008-03-19T17:17:15.000000Z -a1f54175a4e0821cc1f3c8d6122201c7 -2008-02-10T18:02:04.094151Z -40 -andrea -has-props - -StreamReader.hpp -file - - - - -2008-03-19T17:17:15.000000Z -409c0dcd9cce650fb4c1400c0ac41da1 -2008-03-04T13:16:25.980552Z -67 -andrea -has-props - -parse_info.cpp -file - - - - -2008-03-19T17:17:16.000000Z -6a9df5e3a77a972a95035eab55b58175 -2008-03-04T13:16:25.980552Z -67 -andrea -has-props - -AccessUnit.hpp -file - - - - -2008-03-19T17:17:16.000000Z -51c79eceb78c939cafb86ae8565d3b87 -2008-03-04T13:16:25.980552Z -67 -andrea -has-props - -Makefile.am -file - - - - -2008-03-19T17:17:17.000000Z -451ce7cc8c993647fa4f35d435479e5b -2008-03-11T16:18:48.736334Z -76 -andrea - -buffer.cpp -file - - - - -2008-03-19T17:17:17.000000Z -dc8a7becfd3ae9a5d5074dc97a7a780c -2008-03-04T13:16:25.980552Z -67 -andrea -has-props - -scanner.cpp -file - - - - -2008-03-19T17:17:17.000000Z -c3d4c36f11b221054c2552097fb1bd4c -2008-03-04T13:16:25.980552Z -67 -andrea -has-props - -parse_info.hpp -file - - - - -2008-03-19T17:17:17.000000Z -7ba8e793417eb1f3cf6deeb5aa674920 -2008-02-12T22:48:00.374579Z -48 -andrea -has-props - -version.h -file - - - - -2008-03-19T17:17:17.000000Z -ca76027e7902832922a2a729a889904f -2008-03-04T13:16:25.980552Z -67 -andrea - -parser.cpp -file - - - - -2008-03-19T17:17:17.000000Z -9dd54c43b8249f5b3810c74f86008c81 -2008-03-04T13:16:25.980552Z -67 -andrea -has-props - -IInput.hpp -file - - - - -2008-03-19T17:17:17.000000Z -d5dac4f8d14e19b206f4a7860093ba57 -2008-02-17T17:16:20.305835Z -58 -andrea -has-props - diff --git a/src/parser/.svn/format b/src/parser/.svn/format deleted file mode 100644 index 45a4fb7..0000000 --- a/src/parser/.svn/format +++ /dev/null @@ -1 +0,0 @@ -8 diff --git a/src/parser/.svn/prop-base/AccessUnit.hpp.svn-base b/src/parser/.svn/prop-base/AccessUnit.hpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/AccessUnit.hpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/IInput.hpp.svn-base b/src/parser/.svn/prop-base/IInput.hpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/IInput.hpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/Parser.hpp.svn-base b/src/parser/.svn/prop-base/Parser.hpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/Parser.hpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/StreamReader.hpp.svn-base b/src/parser/.svn/prop-base/StreamReader.hpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/StreamReader.hpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/buffer.cpp.svn-base b/src/parser/.svn/prop-base/buffer.cpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/buffer.cpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/buffer.hpp.svn-base b/src/parser/.svn/prop-base/buffer.hpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/buffer.hpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/parse_info.cpp.svn-base b/src/parser/.svn/prop-base/parse_info.cpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/parse_info.cpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/parse_info.hpp.svn-base b/src/parser/.svn/prop-base/parse_info.hpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/parse_info.hpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/parser.cpp.svn-base b/src/parser/.svn/prop-base/parser.cpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/parser.cpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/parser.h.svn-base b/src/parser/.svn/prop-base/parser.h.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/parser.h.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/scanner.cpp.svn-base b/src/parser/.svn/prop-base/scanner.cpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/scanner.cpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/prop-base/scanner.hpp.svn-base b/src/parser/.svn/prop-base/scanner.hpp.svn-base deleted file mode 100644 index 92c8ad7..0000000 --- a/src/parser/.svn/prop-base/scanner.hpp.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff --git a/src/parser/.svn/text-base/AccessUnit.hpp.svn-base b/src/parser/.svn/text-base/AccessUnit.hpp.svn-base deleted file mode 100644 index 6656a3b..0000000 --- a/src/parser/.svn/text-base/AccessUnit.hpp.svn-base +++ /dev/null @@ -1,171 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _ACCESSUNIT_HPP_ -#define _ACCESSUNIT_HPP_ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include - -#include -#include -#include - -namespace dirac -{ -namespace parser_project -{ - struct AccessUnitException : public std::runtime_error - { - AccessUnitException ( std::string const& msg ) - : std::runtime_error ( msg ) {} - }; - - class AccessUnit - { - friend class ValidityChecker; - - public: // type definitions - typedef AccessUnit class_type; - typedef std::vector Buffer; - typedef Buffer::value_type value_type; - typedef Buffer::pointer pointer; - typedef Buffer::const_pointer const_pointer; - typedef Buffer::size_type size_type; - - public: // constructors - AccessUnit() : buffer_() {} - AccessUnit ( const_pointer begin, size_type size ) - : buffer_() - { - setp ( begin, size ); - } - ~AccessUnit() { checkValidity(); } - private: // compiler generated methods are not allowed - AccessUnit ( AccessUnit const& ); - AccessUnit& operator= ( AccessUnit const& ); - - public: // main interface - void setp ( const_pointer begin, size_type size ) - { - ValidityChecker checker ( *this ); - - if ( !dirac_parser_is_access_unit ( begin, size ) ) - throw AccessUnitException ( "this is not an access unit" ); - Buffer tmp ( begin, begin + size ); - buffer_.swap ( tmp ); - } - - //! release internal buffer - it doesn't check whether the buffer is empty - Buffer* releaseBuffer() - { - ValidityChecker checker ( *this ); - - Buffer* buf = new Buffer; - std::swap ( buffer_, *buf ); - return buf; - } - - const_pointer begin() const - { checkValidity(); return empty() ? 0 : &( *buffer_.begin() ); } - pointer begin() - { checkValidity(); return empty() ? 0 : &( *buffer_.begin() ); } - const_pointer end() const - { checkValidity(); return empty() ? 0 : &(*buffer_.begin() ) + size(); } - size_type size() const - { checkValidity(); return buffer_.size(); } - bool empty() const - { checkValidity(); return buffer_.empty(); } - - bool isSequenceHeader() const - { - checkValidity(); - return dirac_parser_is_sequence_header ( begin(), size() ); - } - bool isPicture() const - { - checkValidity(); - return dirac_parser_is_picture ( begin(), size() ); - } - bool isIPicture() const - { - checkValidity(); - return dirac_parser_is_i_picture ( begin(), size() ); - } - bool isAuxiliaryData() const - { - checkValidity(); - return dirac_parser_is_auxiliary_data ( begin(), size() ); - } - bool isPaddingData() const - { - checkValidity(); - return dirac_parser_is_padding_data ( begin(), size() ); - } - bool isEndOfSequence() const - { - checkValidity(); - return dirac_parser_is_end_of_sequence ( begin(), size() ); - } - bool isLastEndOfSequence() const - { - checkValidity(); - return dirac_parser_is_last_end_of_sequence ( begin(), size() ); - } - - private: // helper methods - void checkValidity() const - { - DIRAC_MESSAGE_ASSERT ( "buffer empty or must hold access unit" - , buffer_.empty() - || dirac_parser_is_access_unit ( &buffer_[0], buffer_.size() ) ); - } - private: // members - Buffer buffer_; - }; -} /* parser_project */ - -} /* dirac */ - - -#endif /* _ACCESSUNIT_HPP_ */ diff --git a/src/parser/.svn/text-base/IInput.hpp.svn-base b/src/parser/.svn/text-base/IInput.hpp.svn-base deleted file mode 100644 index 0a26164..0000000 --- a/src/parser/.svn/text-base/IInput.hpp.svn-base +++ /dev/null @@ -1,96 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _IINPUT_HPP_ -#define _IINPUT_HPP_ - -#include - -#include - -namespace dirac -{ -namespace parser_project -{ - class IInput - { - public: // type definitions - typedef IInput class_type; // self - typedef uint8 value_type; - typedef value_type* pointer; - typedef value_type const* const_pointer; - typedef size_t size_type; - - public: // constructors - IInput ( bool bwdScan ) : bwdScan_ ( bwdScan ) {} - virtual ~IInput() {} - private: // compiler generated methods are not allowed - IInput ( IInput const& ); - IInput& operator= ( IInput const& ); - - public: // main methods - //! true if the input stream has no errors and has not reached the end - bool isAvailable() const - { return available(); } - size_type read ( pointer begin, size_type count) - { - DIRAC_MESSAGE_ASSERT ( "pointer cannot be null", 0 != begin ); - return readInput ( begin, count ); - } - bool backwardScanSupported() const - { return bwdScan_; } - bool rewind ( size_type count ) - { return rewindStream ( count ); } - bool rewind() - { return fullRewind(); } - - private: // virtual interface - virtual bool available() const =0; - virtual size_type readInput ( pointer begin - , size_type count ) =0; - virtual bool rewindStream ( size_type count ) =0; - virtual bool fullRewind() =0; - - protected: - bool bwdScan_; - }; -} /* parser_project */ - -} /* dirac */ - - -#endif /* _IINPUT_HPP_ */ diff --git a/src/parser/.svn/text-base/Makefile.am.svn-base b/src/parser/.svn/text-base/Makefile.am.svn-base deleted file mode 100644 index 6ca4802..0000000 --- a/src/parser/.svn/text-base/Makefile.am.svn-base +++ /dev/null @@ -1,33 +0,0 @@ -INCLUDES = -I$(top_srcdir)/src -I$(srcdir) - -h_sources = AccessUnit.hpp \ - buffer.hpp \ - IInput.hpp \ - parse_info.hpp \ - parser.h \ - Parser.hpp \ - scanner.hpp \ - StreamReader.hpp \ - version.h - -lib_h_sources = \ - parser.h \ - IInput.hpp \ - AccessUnit.hpp \ - StreamReader.hpp \ - Parser.hpp - -cpp_sources = buffer.cpp \ - parse_info.cpp \ - parser.cpp \ - scanner.cpp - -lib_LTLIBRARIES = libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_parser.la - -libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_parser_la_SOURCES = $(h_sources) $(cpp_sources) -libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_parser_la_CXXFLAGS = $(AM_CXXFLAGS) -libdirac_parser_@DIRAC_PARSER_MAJORMINOR@_parser_la_LIBADD = \ - $(top_builddir)/src/common/libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_common.la - -library_includedir=$(includedir)/dirac_parser-@DIRAC_PARSER_MAJORMINOR@/parser -library_include_HEADERS = $(lib_h_sources) diff --git a/src/parser/.svn/text-base/Parser.hpp.svn-base b/src/parser/.svn/text-base/Parser.hpp.svn-base deleted file mode 100644 index 21e0aff..0000000 --- a/src/parser/.svn/text-base/Parser.hpp.svn-base +++ /dev/null @@ -1,308 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _PARSER_HPP_ -#define _PARSER_HPP_ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include - -#include -#include - - -namespace dirac -{ -namespace parser_project -{ - - //! C++ wrapper for the parser API - aims to offer the same functionality - class Parser { - typedef int (*parser_getter) ( uint8 const**, size_t, size_t*); - - public: - explicit Parser ( std::auto_ptr str ) : str_ ( str ) - { - checkValidity(); - } - ~Parser() - { - checkValidity(); - } - private: // compiler generated methods are not allowed - Parser ( Parser const& ); - Parser& operator= ( Parser const& ); - - public: - //! retrieves the next sequence header in the associated stream - //! au will contain a copy of the sequence header, if found - //! the cursor will not be moved past the beginning of the seqhdr, if found - bool getNextSequenceHeader ( AccessUnit& au) - { - checkValidity(); - return getAccessUnitFwd ( dirac_parser_get_sequence_header, au ); - } - - //! retrieves the next picture in the stream and copies content in au - //! the cursor will point to the start of the pic, if found - bool getNextPicture ( AccessUnit& au ) - { - checkValidity(); - return getAccessUnitFwd ( dirac_parser_get_next_picture, au ); - } - - //! retrieves the next i picture in the stream and copies content in au - //! the cursor will point to the start of the i pic, if found - bool getNextIPicture ( AccessUnit& au ) - { - checkValidity(); - return getAccessUnitFwd ( dirac_parser_get_next_i_picture, au ); - } - - //! retrieves the next access unit and copies content in au - //! the cursor will point to the start of the access unit, if found - bool getNextAccessUnit ( AccessUnit& au ) - { - checkValidity(); - return getAccessUnitFwd ( dirac_parser_get_next_access_unit, au ); - } - - //! Retrieves I pics forward or backward in the bitstream and copies - //! content in au, if found - //! the cursor will point to the start of the requested i pic, if found - bool getNextIPictureSkipN ( AccessUnit& au, int n ) - { - checkValidity(); - size_t au_size = 0; - int number = n; - while ( true ) { - if ( !dirac_parser_get_i_picture_skip_n ( &str_->gptr() - , str_->sizeFwd() - , str_->sizeBwd() - , &number - , &au_size ) ) { - if ( 0 > n ) { - if ( !str_->addDataBwd() ) return false; - else continue; - } - else { - if ( !str_->addDataFwd() ) return false; - else continue; - } - } - else { - au.setp ( str_->gptr(), au_size ); - return true; - } - } - } - - //! Retrieves I pics bwd in the bitstream and copies content in au - //! the cursor will point to the start of the requested i pic, if found - bool getPreviousIPicture ( AccessUnit& au ) - { - checkValidity(); - size_t au_size = 0; - while ( true ) { - if ( !dirac_parser_get_previous_i_picture ( &str_->gptr() - , str_->sizeFwd() - , str_->sizeBwd() - , &au_size ) ) { - if ( !str_->addDataBwd() ) return false; - else continue; - } - else { - au.setp ( str_->gptr(), au_size ); - return true; - } - } - } - - //! Determines whether the cursor is pointing to the start of a dirac AU - bool isAccessUnit() const - { - checkValidity(); - return dirac_parser_is_access_unit ( str_->gptr(), str_->sizeFwd() ); - } - - //! Determines whether the cursor is pointing to the start of a dirac SeqHdr - bool isSequenceHeader() const - { - checkValidity(); - return dirac_parser_is_sequence_header ( str_->gptr(), str_->sizeFwd() ); - } - - //! Determines whether the cursor is pointing to the start of a picture - bool isPicture() const - { - checkValidity(); - return dirac_parser_is_picture ( str_->gptr(), str_->sizeFwd() ); - } - - //! Determines whether the cursor is pointing to the start of an intra pic - bool isIPicture() const - { - checkValidity(); - return dirac_parser_is_i_picture ( str_->gptr(), str_->sizeFwd() ); - } - - //! Determines whether the cursor is pointing to the start of aux data - bool isAuxiliaryData() const - { - checkValidity(); - return dirac_parser_is_auxiliary_data ( str_->gptr(), str_->sizeFwd() ); - } - - //! Determines whether the cursor is pointing to the start of padding data - bool isPaddingData() const - { - checkValidity(); - return dirac_parser_is_padding_data ( str_->gptr(), str_->sizeFwd() ); - } - - //! Determines whether the cursor is pointing to the start of the end of seq - bool isEndOfSequence() const - { - checkValidity(); - return dirac_parser_is_end_of_sequence ( str_->gptr(), str_->sizeFwd() ); - } - - //! Determines whether the cursor if pointing to the start of the last - //! end of sequence of the stream - bool isLastEndOfSequence() const - { - checkValidity(); - return dirac_parser_is_last_end_of_sequence ( str_->gptr(), str_->sizeFwd() ); - } - - //! Retrieves pic number, if cursor points to start of pic - bool getPictureNumber ( uint32& n ) const - { - checkValidity(); - return dirac_parser_get_picture_number ( str_->gptr() - , str_->sizeFwd() - , &n ); - } - - //! Move cursor forward by one access unit - Note that the user must - //! ensure that the cursor points to start of AU or else undefined behaviour - bool moveCursorFwd() - { - checkValidity(); - while ( true ) { - if ( !dirac_parser_move_cursor_fwd ( &str_->gptr(), str_->sizeFwd() ) ) { - if ( !str_->addDataFwd() ) return false; - else continue; - } - else return true; - } - } - - //! Rewind the cursor to the beginning of the stream, if possible - //! otherwise it has no effect - bool rewind() - { - checkValidity(); - return str_->rewind(); - } - - //! Allows to swap two Parser objects, guaranteed not to throw - void swap ( Parser& rhs ) - { - checkValidity(); - std::auto_ptr tmp ( str_.release() ); - str_ = rhs.str_; - rhs.str_ = tmp; - } - - //! Returns the major version number of this API - int getVersionMajor() const - { - return dirac_parser_get_version_major(); - } - - //! Returns the minor version number of this API - int getVersionMinor() const - { - return dirac_parser_get_version_minor(); - } - - //! Returns the revision number of this API - int getRevision() const - { - return dirac_parser_get_revision(); - } - - private: // helper methods - //! helper class used to implement getter methods - bool getAccessUnitFwd ( parser_getter getter, AccessUnit& au) - { - size_t au_size = 0; - while ( true ) { - if ( !getter ( &str_->gptr(), str_->sizeFwd(), &au_size ) ) { - if ( !str_->addDataFwd() ) return false; - else continue; - } - else { - au.setp ( str_->gptr(), au_size ); - return true; - } - } - } - - void checkValidity() const - { - DIRAC_MESSAGE_ASSERT ( "stream reader cannot be null", 0 != str_.get() ); - } - - private: // members - //! stream buffer used to hold the dirac bitstream - std::auto_ptr str_; - }; -} /* parser_project */ - -} /* dirac */ - - -#endif /* _PARSER_HPP_ */ diff --git a/src/parser/.svn/text-base/StreamReader.hpp.svn-base b/src/parser/.svn/text-base/StreamReader.hpp.svn-base deleted file mode 100644 index 8129d76..0000000 --- a/src/parser/.svn/text-base/StreamReader.hpp.svn-base +++ /dev/null @@ -1,235 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _STREAMREADER_HPP_ -#define _STREAMREADER_HPP_ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include - -#include -#include -#include -#include - - -namespace dirac -{ -namespace parser_project -{ - //! An exception class for StreamReader - class StreamReaderException : public std::runtime_error - { - public: - StreamReaderException ( std::string const& message ) - : std::runtime_error ( message ) {} - }; - - //! A stream buffer class loosely based on streambuf to manage buffered reads - //! from any medium - class StreamReader - { - friend class ValidityChecker; - - public: - typedef StreamReader class_type; - typedef std::vector Buffer; - typedef Buffer::value_type value_type; - typedef Buffer::pointer pointer; - typedef Buffer::const_pointer const_pointer; - typedef Buffer::size_type size_type; - - public: - explicit StreamReader ( std::auto_ptr input - , size_type putback_page_number = PUT_BACK_PAGE_N ) - : input_ ( input ), buffer_ ( PAGE_SIZE * putback_page_number * BUFFER_SIZE ) - , eback_ ( 0 ), gptr_ ( 0 ), egptr_ ( 0 ), global_offset_ ( 0 ) - { - DIRAC_MESSAGE_ASSERT ( "buffer cannot be empty", !buffer_.empty() ); - DIRAC_MESSAGE_ASSERT ( "input cannot be null", 0 != input_.get() ); - - eback_ = &buffer_[0] + PAGE_SIZE * putback_page_number; - gptr_ = egptr_ = eback_; - if ( !addDataFwd() ) - throw StreamReaderException ( "no data from input" ); - checkValidity(); - } - ~StreamReader() { checkValidity(); } - private: // compiler generated methods are not allowed - StreamReader ( class_type const& ); - class_type& operator= ( class_type const& ); - - public: - bool addDataFwd() - { - ValidityChecker checker ( *this ); - size_type original_size = buffer_.size() - putback_size(); - size_type target = original_size - sizeFwd(); - if ( sizeFwd() < sizeBwd() ) { - // this is a safe cast - memcpy ( const_cast ( eback_ ), gptr_, sizeFwd() ); - } - else { - // this is a safe cast - memmove (const_cast ( eback_ ), gptr_, sizeFwd() ); - } - size_type bytesread = 0; - while ( input_->isAvailable() && bytesread < target ) { - bytesread += - input_->read ( const_cast ( eback_ ) + sizeFwd() + bytesread - , target - bytesread ); - } - setg ( eback_, eback_, eback_ + sizeFwd() + bytesread ); - global_offset_ += bytesread; - return bytesread; - } - - bool addDataBwd() - { - if ( !input_->backwardScanSupported() ) return false; - if ( sizeBwd() >static_cast ( eback_ - &buffer_[0] ) ) - throw StreamReaderException ( "Putback is too small, increase buffer size" ); - memcpy ( &buffer_[0], eback_, sizeBwd() ); - size_type target = buffer_.size() - sizeBwd() - putback_size(); - if ( !input_->rewind ( target ) ) return false; - size_type bytesread = 0; - while ( input_->isAvailable() && bytesread < target ) { - // this cast is safe - bytesread += input_->read ( const_cast ( eback_ ) + bytesread, target - bytesread ); - } - // this cast is safe - memcpy ( const_cast ( eback_ ) + bytesread, &buffer_[0], sizeBwd() ); - setg ( eback_ - , eback_ + bytesread + sizeBwd() - , eback_ + bytesread + sizeBwd() ); - global_offset_ -= bytesread; - return bytesread; - } - - const_pointer eback() const { checkValidity(); return eback_; } - const_pointer& gptr() { checkValidity(); return gptr_; } - const_pointer egptr() const { checkValidity(); return egptr_; } - size_type size() const { checkValidity(); return egptr_ - eback_; } - size_type sizeFwd() const { checkValidity(); return egptr_ - gptr_; } - size_type sizeBwd() const { checkValidity(); return gptr_ - eback_; } - - //! rewind the associated physical medium to the beginning of the stream - //! if possible - bool rewind() - { - ValidityChecker checker ( *this ); - bool ret = input_->rewind(); - if ( ret ) { - setg ( eback(), eback(), eback() ); - global_offset_ = 0; - return addDataFwd(); - } - else return false; - } - - void swap ( class_type& rhs ) - { - ValidityChecker checker ( *this ); - std::auto_ptr tmp ( input_.release() ); - input_ = rhs.input_; - rhs.input_ = tmp; - buffer_.swap ( rhs.buffer_ ); - std::swap ( eback_, rhs.eback_ ); - std::swap ( gptr_, rhs.gptr_ ); - std::swap ( egptr_, rhs.egptr_ ); - std::swap ( global_offset_, rhs.global_offset_ ); - } - - int64 goffset() const - { checkValidity(); return global_offset_ - sizeFwd(); } - - bool isAvailable() const - { checkValidity(); return input_->isAvailable(); } - - private: - void checkValidity() const - { - DIRAC_MESSAGE_ASSERT ( "internal pointer cannot be null" - , 0 != eback_ && 0 != gptr_ && 0 != egptr_ ); - DIRAC_MESSAGE_ASSERT ( "eback must lie within buffer" - , !( eback_ < &buffer_[0] ) - && !( eback_ > &buffer_[0] + buffer_.size() ) ); - DIRAC_MESSAGE_ASSERT ( "egptr must lie within buffer" - , !( egptr_ < &buffer_[0] ) - && !( egptr_ > &buffer_[0] + buffer_.size() ) ); - DIRAC_MESSAGE_ASSERT ( "gptr must lie within eback and egptr" - , !( gptr_ < eback_) && !( gptr_ > egptr_ ) ); - } - - void setg ( const_pointer eback, const_pointer gptr - , const_pointer egptr ) - { - eback_ = eback; - gptr_ = gptr; - egptr_ = egptr; - } - - size_type putback_size() const - { - return static_cast ( eback_ - &buffer_[0] ); - } - - private: - enum { - PAGE_SIZE = 4096 - , PUT_BACK_PAGE_N = 500 - , BUFFER_SIZE = 10 - }; - - std::auto_ptr input_; - Buffer buffer_; - const_pointer eback_, gptr_, egptr_; - int64 global_offset_; - }; - -} /* parse_project */ - -} /* dirac */ - - -#endif /* _STREAMREADER_HPP_ */ diff --git a/src/parser/.svn/text-base/buffer.cpp.svn-base b/src/parser/.svn/text-base/buffer.cpp.svn-base deleted file mode 100644 index de8e096..0000000 --- a/src/parser/.svn/text-base/buffer.cpp.svn-base +++ /dev/null @@ -1,130 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -namespace parser = ::dirac::parser_project; -using namespace parser; - -Buffer::Buffer ( const_iterator& cursor, size_type size ) - : begin_ ( cursor ), end_ ( cursor + size ), cursor_ ( cursor ) -{ - checkValidity(); -} - -Buffer::Buffer ( const_iterator& cursor, size_type sizeFwd, size_type sizeBwd ) - : begin_ ( cursor - sizeBwd ), end_ ( cursor + sizeFwd ), cursor_ ( cursor ) -{ - checkValidity(); -} - -Buffer::~Buffer() -{ - checkValidity(); -} - -void -Buffer::checkValidity() const -{ - DIRAC_MESSAGE_ASSERT ( "begin cannot be null", 0 != begin_ ); - DIRAC_MESSAGE_ASSERT ( "end cannot be null", 0 != end_ ); - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor_ ); - DIRAC_MESSAGE_ASSERT ( "end cannot precede begin", !( end_ < begin_ ) ); - DIRAC_MESSAGE_ASSERT ( "cursor must be included in buffer" - , !( begin_ > cursor_ ) && !( cursor_ > end_ ) ); -} - -Buffer::const_iterator -Buffer::begin() const -{ - checkValidity(); - return begin_; -} - -Buffer::const_iterator -Buffer::end() const -{ - checkValidity(); - return end_; -} - -Buffer::size_type -Buffer::size() const -{ - checkValidity(); - return ( end_ - begin_ ); -} - -bool -Buffer::empty() const -{ - checkValidity(); - return begin_ == end_; -} - -Buffer::const_reverse_iterator -Buffer::rbegin() const -{ - checkValidity(); - return const_reverse_iterator ( end_ ); -} - -Buffer::const_reverse_iterator -Buffer::rend() const -{ - checkValidity(); - return const_reverse_iterator ( begin_ ); -} - -Buffer::CursorProxy const -Buffer::cursor() const -{ - checkValidity(); - return CursorProxy ( const_cast ( cursor_ ) ); -} - -Buffer::CursorProxy -Buffer::cursor() -{ - checkValidity(); - return CursorProxy ( cursor_ ); -} - diff --git a/src/parser/.svn/text-base/buffer.hpp.svn-base b/src/parser/.svn/text-base/buffer.hpp.svn-base deleted file mode 100644 index 75b5ddf..0000000 --- a/src/parser/.svn/text-base/buffer.hpp.svn-base +++ /dev/null @@ -1,118 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _BUFFER_HPP_ -#define _BUFFER_HPP_ - -#include - -#include - -namespace dirac -{ -namespace parser_project -{ - - class Buffer - { - public: // some type definitions - typedef uint8 const* const_pointer; - typedef uint8 const* const_iterator; - typedef uint32 size_type; - typedef std::reverse_iterator const_reverse_iterator; - - public: // contructions - Buffer ( const_iterator& cursor, size_type size ); - Buffer ( const_iterator& cursor, size_type sizeFwd, size_type sizeBwd ); - ~Buffer(); - - // compiler generated methods are OK - - public: // helper class - //! Proxy class used to discriminate between lvalue and rvalue use of cursor - //! I decided to use a proxy because I can control its use - class CursorProxy - { - public: // type definitions - typedef Buffer::size_type size_type; - typedef Buffer::const_iterator const_iterator; - - public: // construction - CursorProxy ( const_iterator& cursor ) - : cursor_ ( cursor ) {} - ~CursorProxy() {} - // compiler generated methods are OK - - public: - // lvalue uses - CursorProxy& operator= ( const_iterator c ) { cursor_ = c; return *this; } - CursorProxy& operator++() { ++cursor_; return *this; } - - // rvalue uses - operator const_iterator() const { return cursor_; } - - private: // members - const_iterator& cursor_; - }; - - public: // main methods - const_iterator begin() const; - const_iterator end() const; - size_type size() const; - bool empty() const; - - const_reverse_iterator rbegin() const; - const_reverse_iterator rend() const; - - CursorProxy const cursor() const; // rvalue - CursorProxy cursor(); // lvalue - - private: // helper methods - void checkValidity() const; - - private: // members - const_iterator begin_; - const_iterator end_; - const_iterator& cursor_; - }; - -} /* parser_project */ - -} /* dirac */ - - -#endif /* _BUFFER_HPP_ */ diff --git a/src/parser/.svn/text-base/parse_info.cpp.svn-base b/src/parser/.svn/text-base/parse_info.cpp.svn-base deleted file mode 100644 index b66b814..0000000 --- a/src/parser/.svn/text-base/parse_info.cpp.svn-base +++ /dev/null @@ -1,342 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -namespace dirac -{ -namespace parser_project -{ - ParseInfo::ParseInfoPrefix::value_type const - ParseInfo::ParseInfoPrefix::prefix_[] = { 0x42, 0x42, 0x43, 0x44 }; - ParseInfo::ParseInfoPrefix ParseInfo::prefix_; - - enum { - PI_HEADER_LENGTH = 13 - , PI_PREFIX_LENGTH = 4 - - // parse code - , CHECK_SEQUENCE_HEADER = 0xFF - , SEQUENCE_HEADER_VALUE = 0x00 - - , CHECK_END_OF_SEQUENCE = 0xFF - , END_OF_SEQUENCE_VALUE = 0x10 - - , CHECK_AUXILIARY_DATA = 0xF8 - , AUXILIARY_DATA_VALUE = 0x20 - - , CHECK_PADDING_DATA = 0xFF // I think, rather than F8, is appr. here - , PADDING_DATA_VALUE = 0x30 - - , CHECK_PICTURE = 0x08 - , PICTURE_VALUE = 0x08 - - , CHECK_CORE_SYNTAX = 0x88 - , CORE_SYNTAX_VALUE = 0x08 - - , CHECK_LOW_DELAY_SYNTAX = 0x88 - , LOW_DELAY_SYNTAX_VALUE = 0x88 - - , CHECK_USING_AC = 0x48 - , USING_AC_VALUE = 0x08 - - , CHECK_IS_REFERENCE = 0x0C - , IS_REFERENCE_VALUE = 0x0C - - , CHECK_IS_NON_REFERENCE = 0x0C - , IS_NON_REFERENCE_VALUE = 0x08 - - , NUMBER_OF_REFERENCES = 0x03 - - // offsets - , PC_OFFSET = 4 // parse code offset - , NPO_OFFSET = 5 // next parse offset's offset - , PPO_OFFSET = 9 // previous parse offset's offset - , RPPO_OFFSET = 5 // previous parse offset's offset - // from the reverse cursor's base - // other constants - , DATA_OK = 1 - , NO_DATA = 0 - - }; - -} /* parser_project */ - -} /* dirac */ - - -namespace parser = ::dirac::parser_project; -using namespace parser; - -/* ParseInfo::ParseInfoPrefix */ - -ParseInfo::ParseInfoPrefix::const_iterator -ParseInfo::ParseInfoPrefix::begin() -{ - return prefix_; -} - -ParseInfo::ParseInfoPrefix::const_iterator -ParseInfo::ParseInfoPrefix::end() -{ - return prefix_ + DIRAC_ARRAY_SIZE ( prefix_ ); -} - -ParseInfo::ParseInfoPrefix::size_type -ParseInfo::ParseInfoPrefix::size() -{ - return PI_PREFIX_LENGTH; -} - -ParseInfo::ParseInfoPrefix::const_reverse_iterator -ParseInfo::ParseInfoPrefix::rbegin() -{ - return std::reverse_iterator ( end() ); -} - -ParseInfo::ParseInfoPrefix::const_reverse_iterator -ParseInfo::ParseInfoPrefix::rend() -{ - return std::reverse_iterator ( begin() ); -} - -bool -ParseInfo::ParseInfoPrefix::isParseInfo ( const_iterator cursor, size_type size ) -{ - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - return ( !( PI_HEADER_LENGTH > size ) - && prefix_[0] == cursor[0] && prefix_[1] == cursor[1] - && prefix_[2] == cursor[2] && prefix_[3] == cursor[3] ); -} - -ParseInfo::const_iterator -ParseInfo::prefixBegin() -{ - return prefix_.begin(); -} - -ParseInfo::const_iterator -ParseInfo::prefixEnd() -{ - return prefix_.end(); -} - -ParseInfo::const_reverse_iterator -ParseInfo::prefixRbegin() -{ - return prefix_.rbegin(); -} - -ParseInfo::const_reverse_iterator -ParseInfo::prefixRend() -{ - return prefix_.rend(); -} - -ParseInfo::size_type -ParseInfo::prefixSize() -{ - return prefix_.size(); -} - - -/* ParseInfo */ - -ParseInfo::ParseInfo ( const_iterator cursor ) - : cursor_ ( cursor ) -{ - checkValidity(); -} - -ParseInfo::~ParseInfo() -{ - checkValidity(); -} - -void -ParseInfo::checkValidity() const -{ - DIRAC_MESSAGE_ASSERT ( "parse info header cannot be null", 0 != cursor_ ); -} - -ParseInfo::value_type -ParseInfo::getParseCode() const -{ - return cursor_[PC_OFFSET]; -} - -bool -ParseInfo::isParseInfo ( const_iterator buffer, size_type size ) -{ - DIRAC_MESSAGE_ASSERT ( "buffer cannot be null", 0 != buffer ); - return prefix_.isParseInfo ( buffer, size ); -} - -bool -ParseInfo::isSequenceHeader() const -{ - checkValidity(); - return SEQUENCE_HEADER_VALUE == ( CHECK_SEQUENCE_HEADER & getParseCode() ); -} - -bool -ParseInfo::isEndOfSequence() const -{ - checkValidity(); - return END_OF_SEQUENCE_VALUE == ( CHECK_END_OF_SEQUENCE & getParseCode() ); -} - -bool -ParseInfo::isAuxiliaryData() const -{ - checkValidity(); - return AUXILIARY_DATA_VALUE == ( CHECK_AUXILIARY_DATA & getParseCode() ); -} - -bool -ParseInfo::isPaddingData() const -{ - checkValidity(); - return PADDING_DATA_VALUE == ( CHECK_PADDING_DATA & getParseCode() ); -} - -bool -ParseInfo::isPicture() const -{ - checkValidity(); - return PICTURE_VALUE == ( CHECK_PICTURE & getParseCode() ); -} - -bool -ParseInfo::isCoreSyntax() const -{ - checkValidity(); - return CORE_SYNTAX_VALUE == ( CHECK_CORE_SYNTAX & getParseCode() ); -} - -bool -ParseInfo::isLowDelaySyntax() const -{ - checkValidity(); - return LOW_DELAY_SYNTAX_VALUE == ( CHECK_LOW_DELAY_SYNTAX & getParseCode() ); -} - -bool -ParseInfo::isUsingArithmeticCoding() const -{ - checkValidity(); - return USING_AC_VALUE == ( CHECK_USING_AC & getParseCode() ); -} - -bool -ParseInfo::isReference() const -{ - checkValidity(); - return IS_REFERENCE_VALUE == ( CHECK_IS_REFERENCE & getParseCode() ); -} - -bool -ParseInfo::isNotReference() const -{ - checkValidity(); - return IS_NON_REFERENCE_VALUE == ( CHECK_IS_NON_REFERENCE & getParseCode() ); -} - -ParseInfo::value_type -ParseInfo::getNumberOfReferences() const -{ - checkValidity(); - return NUMBER_OF_REFERENCES & getParseCode(); -} - -bool -ParseInfo::isIntra() const -{ - checkValidity(); - return isPicture() && 0 == getNumberOfReferences(); -} - -bool -ParseInfo::isInter() const -{ - checkValidity(); - return isPicture() && getNumberOfReferences(); -} - -bool -ParseInfo::hasPayload() const -{ - checkValidity(); - return END_OF_SEQUENCE_VALUE != getParseCode(); -} - -ParseInfo::const_iterator -ParseInfo::payload() const -{ - checkValidity(); - return cursor_ + PI_HEADER_LENGTH; -} - -ParseInfo::const_iterator -ParseInfo::next() const -{ - checkValidity(); - - return cursor_ + readFourBytes ( cursor_ + NPO_OFFSET ); -} - -ParseInfo::const_iterator -ParseInfo::previous() const -{ - checkValidity(); - - return cursor_ - readFourBytes ( cursor_ + PPO_OFFSET ); -} - -ParseInfo::size_type -ParseInfo::size() const -{ - checkValidity(); - size_type next = readFourBytes ( cursor_ + NPO_OFFSET ); - return 0 == next ? PI_HEADER_LENGTH : next; -} diff --git a/src/parser/.svn/text-base/parse_info.hpp.svn-base b/src/parser/.svn/text-base/parse_info.hpp.svn-base deleted file mode 100644 index 80fedca..0000000 --- a/src/parser/.svn/text-base/parse_info.hpp.svn-base +++ /dev/null @@ -1,161 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _PARSE_INFO_HPP_ -#define _PARSE_INFO_HPP_ - -#include -#include - -#include - -namespace dirac -{ -namespace parser_project -{ - /* This class is used to identify and manage dirac access units. It can - recognise whether a buffer contains a parse info header and it can decode - the individual components carried in the PIH. - Note that an object of type ParseInfo can only be created if we know - the start of PIH and that the passed buffer contains the entire PIH. - The class provides a complement of static methods to determine whether - a PIH is fully contained in a passed buffer. If an object of this - class is instantiated on a buffer not caontaining at least 13 bytes or - not starting with the PIH the resulting behaviour is undefined. */ - class ParseInfo - { - public: - typedef uint8 value_type; - typedef uint32 size_type; - typedef value_type const* const_iterator; - typedef value_type const* const_pointer; - typedef value_type const_reference; - typedef std::reverse_iterator const_reverse_iterator; - - public: // construction - explicit ParseInfo ( const_iterator cursor ); - ~ParseInfo(); - // compiler generated methods are OK - - private: // helper class - class ParseInfoPrefix - { - public: // types - typedef uint8 value_type; - typedef value_type const* const_iterator; - typedef std::reverse_iterator const_reverse_iterator; - typedef uint32 size_type; - - public: // construction - // compiler generated methods are OK - - public: // main methods - static const_iterator begin(); - static const_iterator end(); - static const_reverse_iterator rbegin(); - static const_reverse_iterator rend(); - static size_type size(); - - static bool isParseInfo ( const_iterator cursor, size_type size ); - - private: // members - static const value_type prefix_[]; - }; - - public: // main methods - bool isSequenceHeader() const; - bool isEndOfSequence() const; - bool isAuxiliaryData() const; - bool isPaddingData() const; - bool isPicture() const; - bool isCoreSyntax() const; - bool isLowDelaySyntax() const; - bool isUsingArithmeticCoding() const; - - bool isReference() const; - bool isNotReference() const; - bool isIntra() const; - bool isInter() const; - value_type getNumberOfReferences() const; - - // data unit - // false if end of sequence, true otherwise - bool hasPayload() const; - // returns start of payload - it assumes access unit has a payload, - // undefined behaviour if it doesn't - const_iterator payload() const; - //! returns the pointer obtained by adding the next field to cursor - const_iterator next() const; - //! returns the pointer obtained by subtracting the previous field to cursor - const_iterator previous() const; - // the size of the access unit is deducted from the next field in the PIH - // it is assumed that only a END OF SEQUENCE access unit can have a next - // field set to 0 (in which case the size is 13). - size_type size() const; - - /* checks that the cursor points to the start of a parse info header - and that there is enough room in the buffer to contain the entire - PIH */ - static bool isParseInfo ( const_iterator cursor, size_type size ); - - static const_iterator prefixBegin(); - static const_iterator prefixEnd(); - static const_reverse_iterator prefixRbegin(); - static const_reverse_iterator prefixRend(); - static size_type prefixSize(); - - - public: // helper member - - private: // utils - void checkValidity() const; - value_type getParseCode() const; - - private: // members - /* reference to start of parse info header */ - const_iterator cursor_; - static ParseInfoPrefix prefix_; - }; - - - -} /* parser_project */ - -} /* dirac */ - - -#endif /* _PARSE_INFO_HPP_ */ diff --git a/src/parser/.svn/text-base/parser.cpp.svn-base b/src/parser/.svn/text-base/parser.cpp.svn-base deleted file mode 100644 index 836c4bf..0000000 --- a/src/parser/.svn/text-base/parser.cpp.svn-base +++ /dev/null @@ -1,376 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -#include -#include - -#include - -namespace -{ - enum { - NO_DATA = 0 - , DATA_OK - }; - - using parser::ParseInfo; - - /* returns true if it is possible to move the cursor to the start of the - next access unit. The cursor must point to the start of an access unit - or else undefined behaviour will follow. - Returns false upon failure */ - bool - moveCursorForward ( uint8 const*& cursor, size_t length ) - { - DIRAC_MESSAGE_ASSERT ( "cursor must point to start of access unit" - , ParseInfo::isParseInfo ( cursor, length ) ); - - uint8 const* next = ParseInfo ( cursor ).next(); - if ( next > cursor && next < (cursor + length) ) { - cursor = next; - return true; - } - else - return false; - } - -} /* */ - -namespace dirac -{ -namespace parser_project -{ - - int - dirac_parser_get_sequence_header ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t* seq_hdr_size_reference ) - { - DIRAC_MESSAGE_ASSERT ( "cursor_reference cannot be null" - , 0 != cursor_reference ); - DIRAC_MESSAGE_ASSERT ( "seq_hdr_size_reference cannot be null" - , 0 != seq_hdr_size_reference ); - - Scanner scanner ( *cursor_reference, buffer_size_fwd ); - while ( scanner.scanForward() ) { - ParseInfo pi ( scanner.cursor() ); - if ( pi.isSequenceHeader() ) { - *seq_hdr_size_reference = pi.size(); - return DATA_OK; - } - else if ( !moveCursorForward ( *cursor_reference, scanner.sizeFwd() ) ) { - return NO_DATA; - } - } - return NO_DATA; - } - - int - dirac_parser_get_next_picture ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t* pic_size_reference) - { - DIRAC_MESSAGE_ASSERT ( "cursor_reference cannot be null" - , 0 != cursor_reference ); - DIRAC_MESSAGE_ASSERT ( "pic_size_reference cannot be null" - , 0 != pic_size_reference ); - - Scanner scanner ( *cursor_reference, buffer_size_fwd ); - while ( scanner.scanForward() ) { - ParseInfo pi ( scanner.cursor() ); - if ( pi.isPicture() ) { - *pic_size_reference = pi.size(); - return DATA_OK; - } - else if ( !moveCursorForward ( *cursor_reference, scanner.sizeFwd() ) ) { - return NO_DATA; - } - } - return NO_DATA; - } - - int - dirac_parser_get_next_access_unit ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t* acc_unit_size_reference ) - { - DIRAC_MESSAGE_ASSERT ( "cursor_reference cannot be null" - , 0 != cursor_reference ); - DIRAC_MESSAGE_ASSERT ( "acc_unit_size_reference cannot be null" - , 0 != acc_unit_size_reference ); - - Scanner scanner ( *cursor_reference, buffer_size_fwd ); - if ( scanner.scanForward() ) { - *acc_unit_size_reference = ParseInfo ( scanner.cursor() ).size(); - return DATA_OK; - } - else { - return NO_DATA; - } - } - - int - dirac_parser_get_next_i_picture ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t* pic_size_reference ) - { - DIRAC_MESSAGE_ASSERT ( "cursor_reference cannot be null" - , 0 != cursor_reference ); - DIRAC_MESSAGE_ASSERT ( "pic_size_reference cannot be null" - , 0 != pic_size_reference ); - - Scanner scanner ( *cursor_reference, buffer_size_fwd ); - while ( scanner.scanForward() ) { - ParseInfo pi ( scanner.cursor() ); - if ( pi.isIntra() ) { - *pic_size_reference = pi.size(); - return DATA_OK; - } - else if ( !moveCursorForward ( *cursor_reference, scanner.sizeFwd() ) ) { - return NO_DATA; - } - } - return NO_DATA; - } - - int - dirac_parser_get_i_picture_skip_n ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t buffer_size_bwd - , int* n - , size_t* pic_size_reference ) - { - DIRAC_MESSAGE_ASSERT ( "cursor_reference cannot be null" - , 0 != cursor_reference ); - DIRAC_MESSAGE_ASSERT ( "pic_size_reference cannot be null" - , 0 != pic_size_reference ); - DIRAC_MESSAGE_ASSERT ( "n cannot be null", 0 != n ); - - Scanner scanner ( *cursor_reference, buffer_size_fwd, buffer_size_bwd ); - if ( 0 > *n ) { // scan backward - while ( scanner.scanBackward() ) { - ParseInfo pi ( scanner.cursor() ); - if ( pi.isIntra() && 0 == ++(*n) ) { - *pic_size_reference = pi.size(); - return DATA_OK; - } - // note: we don't need to move the cursor for backward scanning - } - return NO_DATA; - } - else { // scan forward - while ( scanner.scanForward() ) { - ParseInfo pi ( scanner.cursor() ); - if ( pi.isIntra() && 0 == (*n)-- ) { - *pic_size_reference = pi.size(); - ++(*n); // we need this because we want to use 0 to request the next - // i pic forward - lack of symmetry with backward search - FIXME - return DATA_OK; - } - else if ( !moveCursorForward ( *cursor_reference, scanner.sizeFwd() ) ) { - return NO_DATA; - } - } - return NO_DATA; - } - } - - int - dirac_parser_get_previous_i_picture ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t buffer_size_bwd - , size_t* pic_size_reference ) - { - DIRAC_MESSAGE_ASSERT ( "cursor_reference cannot be null" - , 0 != cursor_reference ); - DIRAC_MESSAGE_ASSERT ( "pic_size_reference cannot be null" - , 0 != pic_size_reference ); - - Scanner scanner ( *cursor_reference, buffer_size_fwd, buffer_size_bwd ); - while ( scanner.scanBackward() ) { - ParseInfo pi ( scanner.cursor() ); - if ( pi.isIntra() ) { - *pic_size_reference = pi.size(); - return DATA_OK; - } - // note: we don't need to move the cursor backwards - } - return NO_DATA; - } - - - - int - dirac_parser_move_cursor_fwd ( uint8 const** cursor_reference - , size_t buffer_size_fwd ) - { - DIRAC_MESSAGE_ASSERT ( "cursor_reference cannot be null" - , 0 != cursor_reference ); - - return moveCursorForward ( *cursor_reference, buffer_size_fwd ); - } - - - - int - dirac_parser_is_access_unit ( uint8 const* cursor - , size_t buffer_size_fwd ) - { - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - // check that cursor points to the start of an access unit and - // that the entire access unit is contained in the passed buffer - return ParseInfo::isParseInfo ( cursor, buffer_size_fwd ) - && ( !( buffer_size_fwd < ParseInfo ( cursor ).size() ) ); - } - - int - dirac_parser_is_sequence_header ( uint8 const* cursor - , size_t buffer_size_fwd ) - { - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - - return dirac_parser_is_access_unit ( cursor, buffer_size_fwd ) - && ParseInfo ( cursor ).isSequenceHeader(); - } - - int - dirac_parser_is_picture ( uint8 const* cursor - , size_t buffer_size_fwd ) - { - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - - return dirac_parser_is_access_unit ( cursor, buffer_size_fwd ) - && ParseInfo ( cursor ).isPicture(); - } - - int - dirac_parser_is_i_picture ( uint8 const* cursor - , size_t buffer_size_fwd ) - { - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - - return dirac_parser_is_access_unit ( cursor, buffer_size_fwd ) - && ParseInfo ( cursor ).isIntra(); - } - - int - dirac_parser_is_auxiliary_data ( uint8 const* cursor - , size_t buffer_size_fwd ) - { - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - - return dirac_parser_is_access_unit ( cursor, buffer_size_fwd ) - && ParseInfo ( cursor ).isAuxiliaryData(); - } - - int - dirac_parser_is_padding_data ( uint8 const* cursor - , size_t buffer_size_fwd ) - { - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - - return dirac_parser_is_access_unit ( cursor, buffer_size_fwd ) - && ParseInfo ( cursor ).isPaddingData(); - } - - int - dirac_parser_is_end_of_sequence ( uint8 const* cursor - , size_t buffer_size_fwd ) - { - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - - return dirac_parser_is_access_unit ( cursor, buffer_size_fwd ) - && ParseInfo ( cursor ).isEndOfSequence(); - } - - int - dirac_parser_is_last_end_of_sequence ( uint8 const* cursor - , size_t buffer_size_fwd ) - { - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - - return dirac_parser_is_access_unit ( cursor, buffer_size_fwd ) - && ParseInfo ( cursor ).isEndOfSequence() - && ParseInfo ( cursor ).next() == cursor; - } - - int - dirac_parser_get_picture_number ( uint8 const* cursor - , size_t size - , uint32* pic_number_reference ) - { - DIRAC_MESSAGE_ASSERT ( "cursor cannot be null", 0 != cursor ); - DIRAC_MESSAGE_ASSERT ( "cursor must point to start of picture access unit" - , ParseInfo::isParseInfo ( cursor, size ) - && ParseInfo ( cursor ).isPicture() ); - DIRAC_MESSAGE_ASSERT ( "pic_number_reference cannot be null" - , 0 != pic_number_reference ); - - *pic_number_reference = readFourBytes ( ParseInfo ( cursor ).payload() ); - return DATA_OK; // it never returns 0, it's assumed the client has checked - // that we have a picture before invoking this function - } - - int - dirac_parser_get_version_major() - { - return DIRAC_PARSER_VERSION_MAJOR; - } - - int - dirac_parser_get_version_minor() - { - return DIRAC_PARSER_VERSION_MINOR; - } - - int - dirac_parser_get_revision() - { - return DIRAC_PARSER_REVISION; - } - -} /* parser_project */ - -} /* dirac */ diff --git a/src/parser/.svn/text-base/parser.h.svn-base b/src/parser/.svn/text-base/parser.h.svn-base deleted file mode 100644 index 1aba7de..0000000 --- a/src/parser/.svn/text-base/parser.h.svn-base +++ /dev/null @@ -1,235 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _PARSER_H_ -#define _PARSER_H_ - - -#include - -#include - -#ifdef __cplusplus - -namespace dirac -{ -namespace parser_project -{ -extern "C" { - -#endif - - /*! The parser interface expects the user to manage the buffer containing - the bitstream to parse. The API accepts a reference to a cursor into - the buffer, pointing to the current parsing position in the stream. - The parser API will move the cursor along the buffer, looking for - the required type of access unit. If the cursor is already pointing - to the start of the desired access unit the API will not move - the cursor forward. - The API also offers a function to move the cursor forward by exactly - one access unit; this function is to be used once the stream is in sync. - In this case the client can invoke a "get" followed by a "move". - All functions return 0 in case of failure and non-zero upon success. - In case of failure the cursor will be moved as far forward as possible. - Non-zero is only returned if the entire access unit is contained in - the passed buffer. - - While parsing the stream backwards the cursor will be moved to the start - of the first access unit which occurs entirely before the current position - of the cursor. - The API expects all pointers to be not NULL. Undefined behaviour - will ensue if this is not the case. */ - - /*! scans the passed buffer from the cursor position forward for up to - buffer_size_fwd bytes looking for a sequence header entirely contained - in the buffer. If found, the cursor position is moved to the start - of the sequence header while the length of the access unit is saved - in seq_hdr_size_reference. - Returns non-zero upon success, when the cursor and seq_hdr_size_reference - are changed, zero upon failure, when the cursor is moved as much forward - as possible in the buffer. seq_hdr_size_reference is not changed in this - case. - cursor_reference and seq_hdr_size_reference cannot be null */ - int - dirac_parser_get_sequence_header ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t* seq_hdr_size_reference ); - - /*! same as above but for the pictures */ - int - dirac_parser_get_next_picture ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t* pic_size_reference ); - - /*! same as above but for any type of access unit */ - int - dirac_parser_get_next_access_unit ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t* acc_unit_size_reference ); - - /*! same as above but only for i pictures */ - int - dirac_parser_get_next_i_picture ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t* pic_size_reference ); - - /*! scans the passed buffer forward or backward looking for an i picture. - The size of the available buffer is given by the sum of buffer_size_fwd - and buffer_size_bwd. If scanning forward, n==0 means get the next i pic, - n==1 means the next + 1, etc. Negative values equates to scanning the - buffer backward, so n==-1 means fetching the first i picture entirely - contained in the buffer and ending before the current position of the - cursor. - The function will move the cursor while trying to find the required i pic. - It returns non-zero upon success, when the cursor will be moved - to the start of the required i pic and pic_size_reference carries the - length of the i pic. Returns zero upon failure, when the cursor is moved - as far forward (or backward, for negative values of n) as possible - while pic_size_reference is not modified. - n is decreased according to the i pics found by the function scanning - cursor_reference, n and pic_size_reference cannot be null */ - int - dirac_parser_get_i_picture_skip_n ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t buffer_size_bwd - , int* n - , size_t* pic_size_reference ); - - /*! cursor_reference is a reference to the current position of the cursor - in the client-provided buffer. buffer_size_fwd is the available data - in the buffer past the cursor, buffer_size_bwd is the available data - before the cursor (to be used for scanning the buffer backwards). - picture_size is a reference to the size of the i picture parsed by this - function. It will be set to 0 if it cannot find an I picture */ - int - dirac_parser_get_previous_i_picture ( uint8 const** cursor_reference - , size_t buffer_size_fwd - , size_t buffer_size_bwd - , size_t* pic_size_reference ); - - /*! move the cursor by one access unit - this function should be used once - the stream is in sync, ie we have already parsed at least one - access unit. - The function expects the cursor to point to the start of an access unit - and that the entire access unit is contained in the passed buffer. - It returns 0 if it cannot move the cursor to the start of the next access - unit (this includes if it is on the last access unit in the buffer), - non zero upon success. - Note that you don't need to move the cursor if you're scanning the stream - backwards, since it is assumed that the user is looking for the previous - access unit, which should end one byte before the position pointed by the - passed cursor. - The cursor cannot be null (same applies to its reference) - buffer_size_fwd carries the number of available bytes in the buffer - from the cursor's position (scanning forward). */ - int - dirac_parser_move_cursor_fwd ( uint8 const** cursor_reference - , size_t buffer_size_fwd ); - - /*! the following group of functions are self-explanatory: the functions - return 0 if the passed buffer doesn't contain the expected type - of dirac access unit, and non zero otherwise. - Note that cursor must point to the start of the access unit; - the entire access unit must be contained in the passed buffer for - this function to return non-zero. - The cursor cannot be null. */ - int - dirac_parser_is_access_unit ( uint8 const* cursor - , size_t buffer_size_fwd ); - int - dirac_parser_is_sequence_header ( uint8 const* cursor - , size_t buffer_size_fwd ); - int - dirac_parser_is_picture ( uint8 const* cursor - , size_t buffer_size_fwd ); - int - dirac_parser_is_i_picture ( uint8 const* cursor - , size_t buffer_size_fwd ); - int - dirac_parser_is_auxiliary_data ( uint8 const* cursor - , size_t buffer_size_fwd ); - int - dirac_parser_is_padding_data ( uint8 const* cursor - , size_t buffer_size_fwd ); - int - dirac_parser_is_end_of_sequence ( uint8 const* cursor - , size_t buffer_size_fwd ); - int - dirac_parser_is_last_end_of_sequence - ( uint8 const* cursor - , size_t buffer_size_fwd ); - - /*! to be used on access units containing pictures - this function expects - the cursor to point to the start of an access unit and contain a picture. - Failure to ensure that will result in undefined behaviour. - It will check that there is enough data to decode the entire picture. - It will return 0 if it cannot decode the picture number (eg, because - the buffer doesn't contain an access unit or because the buffer is not - long enough or doesn't start with an access unit) and pic_number will - not be changed. - It will return non zero if successful and will set *pic_number to - the picture number. - cursor cannot be null, cursor must point to start of picture access unit - or else undefined behaviour */ - int - dirac_parser_get_picture_number ( uint8 const* cursor - , size_t size - , uint32* pic_number_reference ); - - /*! current version of this API */ - int - dirac_parser_get_version_major(); - int - dirac_parser_get_version_minor(); - int - dirac_parser_get_revision(); - -#ifdef __cplusplus - -} /* extern "C" */ - -} /* parser_project */ - -} /* dirac */ - - -/* we'll use this alias for the Parser module */ -namespace parser = ::dirac::parser_project; - -#endif - -#endif /* _PARSER_H_ */ diff --git a/src/parser/.svn/text-base/scanner.cpp.svn-base b/src/parser/.svn/text-base/scanner.cpp.svn-base deleted file mode 100644 index d07d259..0000000 --- a/src/parser/.svn/text-base/scanner.cpp.svn-base +++ /dev/null @@ -1,227 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include - -namespace parser = ::dirac::parser_project; -using namespace parser; - - -Scanner::Scanner ( const_iterator& cursor, size_type sizeFwd ) - : buffer_ ( cursor, sizeFwd ) {} - -Scanner::Scanner ( const_iterator& cursor - , size_type sizeFwd - , size_type sizeBwd ) - : buffer_ ( cursor, sizeFwd, sizeBwd ) {} - -Scanner::~Scanner() {} - - - -/* scan the associated buffer forward for the next access unit - it starts by looking for a parse info header and then it ensures - that the entire access unit associated with that PIH is contained in - the buffer by looking for the next PIH. - There is one exception, the final end of sequence PIH. In that case the - PIH doesn't have any payload and may be the last element in the stream; - if a EoS is detected and there is no further access unit then the function - returns true. - Returns true if it finds an access unit; the cursor of the associated - buffer will point to the start of the access unit. - Returns false if it cannot find a PIH or the access unit is not - completely contained in the buffer associated with buffer_. In this case - the cursor of the associated buffer is moved as far forward as - required (ie, the end of the buffer - 3, if we couldn't find anything, - or the beginning of the PIH if the associated access unit didn't fit - in the buffer) */ -bool -Scanner::scanForward() -{ - static int fwdScanCount = 0; // used to avoid forever loops in corrupted streams - if ( isBufferInSyncFwd() ) { // bitstream in sync - fwdScanCount = 0; - return true; - } - - // ok, the bitstream is not in sync, start scanning the buffer forward - do { - const_iterator cursor = std::search - ( buffer_.cursor(), buffer_.end() - , ParseInfo::prefixBegin(), ParseInfo::prefixEnd() ); - if ( buffer_.end() == cursor ) { - // I need more data, I couldn't find a parse info prefix - buffer_.cursor() = cursor - ParseInfo::prefixSize() + 1; - fwdScanCount = 0; - return false; - } - else { - // found first PI header, now check for second PI to confirm first one - if ( !ParseInfo::isParseInfo ( cursor, buffer_.end() - cursor ) ) { - ++fwdScanCount; - buffer_.cursor() = cursor; - return false; // we need more data - } - ParseInfo firstPi ( cursor ); - const_iterator nextAccessUnit = firstPi.next(); - if ( nextAccessUnit > buffer_.end() ) { - // I need more data - if ( fwdScanCount ) { - // I have already checked this access unit once, push the cursor fwd - // probably a corrupted (or non-compliant) bitstream - ++buffer_.cursor(); - fwdScanCount = 0; - continue; - } - else { - // we need more data - ++fwdScanCount; // we only want to ask for more data once - buffer_.cursor() = cursor; // update cursor position to start of PI - return false; - } - } - else { - // found next PI, we can return successfully - fwdScanCount = 0; - buffer_.cursor() = cursor; - return true; - } - } - } while ( true ); -} - -bool -Scanner::isBufferInSyncFwd() -{ - int bufferLength = buffer_.end() - buffer_.cursor(); - if ( ParseInfo::isParseInfo ( buffer_.cursor(), bufferLength ) ) { - const_iterator next = ParseInfo ( buffer_.cursor() ).next(); - if ( next > buffer_.end() ) - return false; - if ( buffer_.cursor() == next) { - return ParseInfo ( buffer_.cursor() ).isEndOfSequence(); - } - return ParseInfo::isParseInfo ( next, buffer_.end() - next ); - } - return false; -} - -bool -Scanner::scanBackward() -{ - static int bwdScanCount = 0; // used to avoid forever loops in corrupted streams - if ( isBufferInSyncBwd() ) { // bitstream in sync - bwdScanCount = 0; - return true; - } - - do { - const_reverse_iterator rcursor - ( std::search ( const_reverse_iterator ( buffer_.cursor() ) - , buffer_.rend() - , ParseInfo::prefixRbegin() - , ParseInfo::prefixRend() ) ); - if ( buffer_.rend() == rcursor ) { - // I need more data, I couldn't find a PI prefix - buffer_.cursor() = rcursor.base() + ParseInfo::prefixSize() - 1; - bwdScanCount = 0; - return false; - } - else { - // found first PI, now look for previous one - // note that rcursor doesn't point to start of PI - if ( !ParseInfo::isParseInfo ( rcursor.base() - ParseInfo::prefixSize() - , buffer_.end() - rcursor.base() + ParseInfo::prefixSize() ) ) { - buffer_.cursor() = rcursor.base() - 1; - bwdScanCount = 0; - continue; - } - ParseInfo firstPi ( rcursor.base() - ParseInfo::prefixSize() ); - const_iterator prevPi = firstPi.previous(); - if ( prevPi < buffer_.begin() ) { - // I may need more data - if ( bwdScanCount ) { - // I have already checked this access unit once, push the cursor - // backward and start again (probably corrupted or non-compliant stream) - buffer_.cursor() = rcursor.base() - 1; - bwdScanCount = 0; - continue; - } - else { - ++bwdScanCount; - buffer_.cursor() = rcursor.base(); - return false; - } - } - else { - bwdScanCount = 0; - if ( prevPi == buffer_.cursor() - && !ParseInfo ( prevPi ).isSequenceHeader() ) { - bwdScanCount = 0; - buffer_.cursor() = prevPi - 1; - continue; - } - buffer_.cursor() = prevPi; - return true; - } - } - } while ( true ); -} - -bool -Scanner::isBufferInSyncBwd() -{ - int bufferLength = buffer_.end() - buffer_.cursor(); - if ( ParseInfo::isParseInfo ( buffer_.cursor(), bufferLength ) ) { - const_iterator previous = - ParseInfo ( buffer_.cursor() ).previous(); - if ( previous < buffer_.begin() ) return false; - if ( buffer_.cursor() == previous ) { - return false; // we found the first access unit in the stream - } - buffer_.cursor() = previous; - return true; - } - return false; -} diff --git a/src/parser/.svn/text-base/scanner.hpp.svn-base b/src/parser/.svn/text-base/scanner.hpp.svn-base deleted file mode 100644 index 31593d5..0000000 --- a/src/parser/.svn/text-base/scanner.hpp.svn-base +++ /dev/null @@ -1,121 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id$ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _SCANNER_HPP_ -#define _SCANNER_HPP_ - -#include -#include - -#include - -namespace dirac -{ -namespace parser_project -{ - /* responsible for scanning the bitstream contained in the buffer - forward and backward looking for a ParseInfo Header. */ - class Scanner - { - public: // type definitions - typedef uint8 value_type; - typedef value_type const* const_iterator; - typedef value_type const_reference; - typedef ptrdiff_t difference_type; - typedef uint32 size_type; - typedef std::reverse_iterator const_reverse_iterator; - - public: - Scanner ( const_iterator& cursor, size_type sizeFwd ); - Scanner ( const_iterator& cursor, size_type sizeFwd, size_type sizeBwd); - ~Scanner(); - // compiler generated methods are ok - - public: // main methods - /* scan the associated buffer forward for the next access unit - it starts by looking for a parse info header and then it ensures - that the entire access unit associated with that PIH is contained in - the buffer. - Returns true if it finds an access unit; the cursor of the associated - buffer will point to the start of the access unit. - Returns false if it cannot find a PIH or the access unit is not - completely contaned in the buffer associated with buffer_. In this case - the cursor of the associated buffer is moved as far forward as - required (ie, the end of the buffer - 3, if we couldn't find anything, - or the beginning of the PIH if the associated access unit didn't fit - in the buffer) */ - bool scanForward(); - /* scan the associated buffer backwards for the previous access unit, - if there is one. - If the cursor of the associated buffer points to the start of an access - unit this function will search for the previous PIH. Otherwise - it will look for a PIH while scanning back and that will be considered - the end of the desired access unit. So it will then look for a PIH - further up the buffer (still scanning backward) which will mark - the start of the desired access unit. - Only a sequence header can be the first access unit in dirac stream; - if it finds a PIH without predecessors it must be of type SEQHDR or - else it will not be parsed successfully. - Returns true if it finds the desired access unit and leave the cursor - on the start of the access unit. - Returns false if unsuccessful and moves the cursor backward as far - as required. */ - bool scanBackward(); - - /* returns the position of the cursor of the underlying buffer */ - const_iterator cursor() const { return buffer_.cursor(); } - /* returns the size of the available buffer scanning forward */ - size_type sizeFwd() const { return buffer_.end() - buffer_.cursor(); } - /* returns the size of the available buffer scanning backward */ - size_type sizeBwd() const { return buffer_.cursor() - buffer_.begin(); } - - private: // utils - bool isBufferInSyncFwd(); - bool isBufferInSyncBwd(); - - private: // members - Buffer buffer_; - }; - - - -} /* parser_project */ - -} /* dirac */ - - -#endif /* _SCANNER_HPP_ */ diff --git a/src/parser/.svn/text-base/version.h.svn-base b/src/parser/.svn/text-base/version.h.svn-base deleted file mode 100644 index 3f9d0b4..0000000 --- a/src/parser/.svn/text-base/version.h.svn-base +++ /dev/null @@ -1,45 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _VERSION_H_ -#define _VERSION_H_ - -#define DIRAC_PARSER_VERSION_MAJOR 1 -#define DIRAC_PARSER_VERSION_MINOR 0 -#define DIRAC_PARSER_REVISION 66 - -#endif /* _VERSION_H_ */ diff --git a/src/parser/Makefile.am b/src/parser/Makefile.am index 6ca4802..90e1386 100644 --- a/src/parser/Makefile.am +++ b/src/parser/Makefile.am @@ -9,7 +9,7 @@ h_sources = AccessUnit.hpp \ scanner.hpp \ StreamReader.hpp \ version.h - + lib_h_sources = \ parser.h \ IInput.hpp \ @@ -20,7 +20,7 @@ lib_h_sources = \ cpp_sources = buffer.cpp \ parse_info.cpp \ parser.cpp \ - scanner.cpp + scanner.cpp lib_LTLIBRARIES = libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_parser.la diff --git a/src/unittest/DiracdecTest.cpp b/src/unittest/DiracdecTest.cpp deleted file mode 100644 index 80427b4..0000000 --- a/src/unittest/DiracdecTest.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include - -#include -#include -#include -#include - -#include - -//NOTE: ensure that the suite is added to the default registry in -//cppunit_testsuite.cpp -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (DiracdecTest, coreSuiteName()); - -using namespace ::dirac::decoder; -using namespace ::dirac::parser_project; - -#ifdef BITS -std::string DiracdecTest::filename_ = BITS; -#else -std::string DiracdecTest::filename_ = "../bitstreams/AN_schro_1Mbps.drc"; -#endif - - -DiracdecTest::DiracdecTest() {} - -DiracdecTest::~DiracdecTest() {} - -void -DiracdecTest::setUp() -{ - std::auto_ptr input ( new FileReader ( filename_ ) ); - std::auto_ptr reader ( new StreamReader ( input, 50 ) ); - std::auto_ptr tmp ( new Parser ( reader ) ); - parser_ = tmp; - - std::auto_ptr > writer ( new FileWriter ( filename_ + ".i420" ) ); - std::auto_ptr > frameMemMgr - ( new DefaultFrameMemoryManager ); - std::auto_ptr manager - ( makeFrameManager ( writer, frameMemMgr ) ); - manager_ = manager; -} - -void -DiracdecTest::tearDown() -{ - std::string tmp = filename_ + ".i420"; - remove ( tmp.c_str() ); -} - -void -DiracdecTest::testDiracdec() -{ - Diracdec diracdec ( parser_, manager_ ); - std::auto_ptr decoderState; - do { - std::auto_ptr tmp ( diracdec.getState() ); - decoderState = tmp; // the previous DecoderState gets deleted here - decoderState->doNextAction(); - } while ( !decoderState->isEndOfSequence() ); - - uint32 nframes1 = diracdec.numberOfDecodedFrames(); - std::cout << "Dirac decoder decoded " << nframes1 << " frames.\n"; - - std::auto_ptr parser = diracdec.releaseParser(); - parser->rewind(); - diracdec.reacquireParser ( parser ); - do { - std::auto_ptr tmp ( diracdec.getState() ); - decoderState = tmp; // the previous DecoderState gets deleted here - decoderState->doNextAction(); - } while ( !decoderState->isEndOfSequence() ); - - uint32 nframes2 = diracdec.numberOfDecodedFrames(); - std::cout << "After rewind Dirac decoder decoded " << nframes2; - std::cout << " frames." << std::endl; - - CPPUNIT_ASSERT_EQUAL ( nframes1, nframes2 ); - -} - -void -DiracdecTest::testDiracdecRun() -{ - Diracdec diracdec ( parser_, manager_ ); - diracdec.decode(); - std::cout << "Dirac decoder decoded " << diracdec.numberOfDecodedFrames(); - std::cout << " frames." << std::endl; -} - - diff --git a/src/unittest/DiracdecTest.hpp b/src/unittest/DiracdecTest.hpp deleted file mode 100644 index 5da6ccc..0000000 --- a/src/unittest/DiracdecTest.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _DIRACDECTEST_HPP_ -#define _DIRACDECTEST_HPP_ - - -#include - -#include - -#include -#include - -#include -#include - - -class DiracdecTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE ( DiracdecTest ); - CPPUNIT_TEST ( testDiracdec ); - CPPUNIT_TEST ( testDiracdecRun ); - CPPUNIT_TEST_SUITE_END(); - -public: - DiracdecTest(); - virtual ~DiracdecTest(); - - virtual void setUp(); - virtual void tearDown(); - - void testDiracdec(); - void testDiracdecRun(); - - private: - std::auto_ptr parser_; - std::auto_ptr manager_; - static std::string filename_; -}; - - -#endif /* _DIRACDECTEST_HPP_ */ - - diff --git a/src/unittest/FileReaderTest.cpp b/src/unittest/FileReaderTest.cpp deleted file mode 100644 index 378aed8..0000000 --- a/src/unittest/FileReaderTest.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include - -#include - -//NOTE: ensure that the suite is added to the default registry in -//cppunit_testsuite.cpp -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (FileReaderTest, coreSuiteName()); - - -using ::dirac::decoder::FileReader; - -#ifdef BITS -std::string FileReaderTest::filename_ = BITS; -#else -std::string FileReaderTest::filename_ = "../bitstreams/AN_schro_1Mbps.drc"; -#endif - -FileReaderTest::FileReaderTest() {} - -FileReaderTest::~FileReaderTest() {} - -void -FileReaderTest::setUp() -{ - data_ = new uint8[ARRAY_SIZE]; -} - -void -FileReaderTest::tearDown() -{ - delete [] data_; -} - -void -FileReaderTest::testFileReader() -{ - FileReader input ( filename_ ); - CPPUNIT_ASSERT ( input.isAvailable() ); - CPPUNIT_ASSERT ( input.backwardScanSupported() ); - CPPUNIT_ASSERT_EQUAL ( static_cast ( ARRAY_SIZE ) - , input.read ( data_, ARRAY_SIZE ) ); - CPPUNIT_ASSERT ( input.isAvailable() ); - const size_t BUFFER_SIZE = ARRAY_SIZE / 2; - CPPUNIT_ASSERT ( input.rewind ( BUFFER_SIZE ) ); - uint8* buffer = new uint8[BUFFER_SIZE]; - CPPUNIT_ASSERT_EQUAL ( BUFFER_SIZE, input.read ( buffer, BUFFER_SIZE ) ); - CPPUNIT_ASSERT ( !memcmp(buffer, data_ + BUFFER_SIZE, BUFFER_SIZE) ); - delete [] buffer; -} - -void -FileReaderTest::testFullFleScan() -{ - size_t fileLength = filesize(); - FileReader input ( filename_ ); - CPPUNIT_ASSERT ( input.isAvailable() ); - CPPUNIT_ASSERT ( input.backwardScanSupported() ); - size_t count = 0; - while ( input.isAvailable() ) { - count += input.read ( data_, ARRAY_SIZE ); - } - CPPUNIT_ASSERT_EQUAL ( count, fileLength ); -} - -size_t -FileReaderTest::filesize() -{ - FILE* str = fopen ( filename_.c_str(), "rb" ); - if ( !str ) return 0; - if ( fseek ( str, 0, SEEK_END ) ) return 0; - size_t pos = ftell ( str ); - fclose ( str ); - return pos; -} - - - diff --git a/src/unittest/FileReaderTest.hpp b/src/unittest/FileReaderTest.hpp deleted file mode 100644 index 6ea8aeb..0000000 --- a/src/unittest/FileReaderTest.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: FileReaderTestSuite.hpp 60 2008-02-23 21:10:16Z andrea $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FILEREADERTEST_HPP_ -#define _FILEREADERTEST_HPP_ - -#include -#include - -#include -#include - -class FileReaderTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE ( FileReaderTest ); - CPPUNIT_TEST ( testFileReader ); - CPPUNIT_TEST ( testFullFleScan ); - CPPUNIT_TEST_SUITE_END(); - -public: - FileReaderTest(); - virtual ~FileReaderTest(); - - virtual void setUp(); - virtual void tearDown(); - - void testFileReader(); - void testFullFleScan(); - - -private: // members - size_t filesize(); - -private: - enum { - ARRAY_SIZE = 10000 - }; - - uint8* data_; - static std::string filename_; -}; - - - - -#endif /* _FILEREADERTEST_HPP_ */ diff --git a/src/unittest/FileWriterTest.cpp b/src/unittest/FileWriterTest.cpp deleted file mode 100644 index 05019db..0000000 --- a/src/unittest/FileWriterTest.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#include - -#include -#include -#include - -using ::dirac::decoder::FileWriter; -using ::dirac::decoder::FileReader; - -//NOTE: ensure that the suite is added to the default registry in -//cppunit_testsuite.cpp -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (FileWriterTest, coreSuiteName()); - -std::string FileWriterTest::filename_ = "FileWriterTest"; - - - -FileWriterTest::FileWriterTest(){} - -FileWriterTest::~FileWriterTest() {} - - -void -FileWriterTest::setUp() -{ - buffer_ = new uint8 [BUFFERSIZE]; - memset(static_cast ( buffer_ ), 3, BUFFERSIZE); -} - -void -FileWriterTest::tearDown() -{ - delete [] buffer_; - remove ( filename_.c_str() ); -} - -void -FileWriterTest::testFileWriterImpl() -{ - FileWriter* writer = new FileWriter ( filename_ ); - CPPUNIT_ASSERT ( writer->isAvailable() ); - CPPUNIT_ASSERT ( writer->write ( buffer_, BUFFERSIZE ) ); - CPPUNIT_ASSERT ( writer->isAvailable() ); - CPPUNIT_ASSERT ( writer->write ( buffer_, BUFFERSIZE ) ); - CPPUNIT_ASSERT ( writer->isAvailable() ); - delete writer; - std::auto_ptr readBuffer ( new uint8[BUFFERSIZE] ); - FileReader* reader = new FileReader ( filename_ ); - CPPUNIT_ASSERT ( reader->isAvailable() ); - CPPUNIT_ASSERT_EQUAL ( static_cast ( BUFFERSIZE ) - , reader->read ( readBuffer.get(), BUFFERSIZE ) ); - CPPUNIT_ASSERT ( !memcmp(static_cast ( buffer_ ) - , static_cast ( readBuffer.get() ), BUFFERSIZE) ); - CPPUNIT_ASSERT ( reader->isAvailable() ); - delete reader; -} - - diff --git a/src/unittest/FileWriterTest.hpp b/src/unittest/FileWriterTest.hpp deleted file mode 100644 index f7ab327..0000000 --- a/src/unittest/FileWriterTest.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _FILEWRITERTEST_HPP_ -#define _FILEWRITERTEST_HPP_ - -#include -#include - -#include - -class FileWriterTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE ( FileWriterTest ); - CPPUNIT_TEST ( testFileWriterImpl ); - CPPUNIT_TEST_SUITE_END(); - -public: - FileWriterTest(); - virtual ~FileWriterTest(); - - virtual void setUp(); - virtual void tearDown(); - - void testFileWriterImpl(); - -private: // members - uint8* buffer_; - static std::string filename_; - enum { - BUFFERSIZE = 10000 - }; -}; - - - -#endif /* _FILEWRITERTEST_HPP_ */ diff --git a/src/unittest/Makefile.am b/src/unittest/Makefile.am index 5334829..a6d0899 100644 --- a/src/unittest/Makefile.am +++ b/src/unittest/Makefile.am @@ -4,34 +4,26 @@ h_sources = AccessUnitTest.hpp \ Bitstream.hpp \ BufferTest.hpp \ core_suite.hpp \ - DiracdecTest.hpp \ - FileReaderTest.hpp \ - FileWriterTest.hpp \ ParseInfoTest.hpp \ ParserCppTest.hpp \ ParserTest.hpp \ ScannerTest.hpp \ - SchrodecTest.hpp \ StreamReaderTest.hpp - + cpp_sources = AccessUnitTest.cpp \ BufferTest.cpp \ cppunit_testsuite.cpp \ - DiracdecTest.cpp \ - FileReaderTest.cpp \ - FileWriterTest.cpp \ ParseInfoTest.cpp \ ParserCppTest.cpp \ ParserTest.cpp \ ScannerTest.cpp \ - SchrodecTest.cpp \ StreamReaderTest.cpp \ utmain.cpp - + #EXTRA_DIST = $(cpp_sources) $(h_sources) -noinst_PROGRAMS = +noinst_PROGRAMS = if HAVE_CPPUNIT noinst_PROGRAMS +=runner endif @@ -40,19 +32,9 @@ runner_SOURCES = $(cpp_sources) runner_CXXFLAGS = $(SCHROEDINGER_CFLAGS) $(DIRAC_CFLAGS) $(CPPUNIT_CFLAGS) \ -DBITS=\"$(builddir)/bitstreams/AN_352x288_800Kbps.drc\" -runner_LDADD = ../parser/libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_parser.la \ - ../decoder/libdirac_parser-@DIRAC_PARSER_MAJORMINOR@_decoder.la \ +runner_LDADD = ../parser/libdirac_parser-@DIRAC_PARSER_MAJORMINOR@.la \ $(CPPUNIT_LIBS) -if HAVE_DIRAC - runner_LDADD += $(DIRAC_LIBS) -endif - -if HAVE_SCHRO - runner_LDADD += $(SCHROEDINGER_LIBS) -endif - - if USE_STATIC runner_LDFLAGS = $(LDFLAGS) -static else diff --git a/src/unittest/SchrodecTest.cpp b/src/unittest/SchrodecTest.cpp deleted file mode 100644 index 6a2d559..0000000 --- a/src/unittest/SchrodecTest.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -using namespace ::dirac::decoder; -using namespace ::dirac::parser_project; - -//NOTE: ensure that the suite is added to the default registry in -//cppunit_testsuite.cpp -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (SchrodecTest, coreSuiteName()); - -#ifdef BITS -std::string SchrodecTest::filename_ = BITS; -#else -std::string SchrodecTest::filename_ = "../bitstreams/AN_schro_1Mbps.drc"; -#endif - -SchrodecTest::SchrodecTest() {} - -SchrodecTest::~SchrodecTest() {} - -void -SchrodecTest::setUp() -{ - std::auto_ptr input ( new FileReader ( filename_ ) ); - std::auto_ptr reader ( new StreamReader ( input, 50 ) ); - std::auto_ptr tmp ( new Parser ( reader ) ); - parser_ = tmp; - - std::auto_ptr > writer ( new FileWriter ( filename_ + ".i420" ) ); - std::auto_ptr > frameMemMgr - ( new DefaultFrameMemoryManager ); - std::auto_ptr manager - ( makeFrameManager ( writer, frameMemMgr ) ); - - manager_ = manager; -} - -void -SchrodecTest::tearDown() -{ - std::string tmp = filename_ + ".i420"; - remove ( tmp.c_str() ); -} - -void -SchrodecTest::testSchrodec() -{ - Schrodec schro ( parser_, manager_ ); - std::auto_ptr decoderState; - do { - std::auto_ptr tmp ( schro.getState() ); - decoderState = tmp; // the previous DecoderState gets deleted here - decoderState->doNextAction(); - } while ( !decoderState->isEndOfSequence() ); - uint32 nframes1 = schro.numberOfDecodedFrames(); - std::cout << "Schro decoder decoded " << nframes1; - std::cout << " frames." << std::endl; - - std::auto_ptr parser = schro.releaseParser(); - parser->rewind(); - schro.reacquireParser ( parser ); - do { - std::auto_ptr tmp ( schro.getState() ); - decoderState = tmp; // the previous DecoderState gets deleted here - decoderState->doNextAction(); - } while ( !decoderState->isEndOfSequence() ); - - uint32 nframes2 = schro.numberOfDecodedFrames(); - std::cout << "After rewinding, Schro decoder decoded " << nframes2; - std::cout << " frames." << std::endl; - - CPPUNIT_ASSERT_EQUAL ( nframes1, nframes2 ); -} - -void -SchrodecTest::testSchrodecRun() -{ - Schrodec schro ( parser_, manager_ ); - schro.decode(); - std::cout << "Schroedinger decoder decoded " << schro.numberOfDecodedFrames(); - std::cout << " frames." << std::endl; -} - - - - diff --git a/src/unittest/SchrodecTest.hpp b/src/unittest/SchrodecTest.hpp deleted file mode 100644 index bb7082d..0000000 --- a/src/unittest/SchrodecTest.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** -* -* $Id: $ -* -* Version: MPL 1.1/GPL 2.0/LGPL 2.1 -* -* The contents of this file are subject to the Mozilla Public License -* Version 1.1 (the "License"); you may not use this file except in compliance -* with the License. You may obtain a copy of the License at -* http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS IS" basis, -* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for -* the specific language governing rights and limitations under the License. -* -* The Original Code is BBC Research code. -* -* The Initial Developer of the Original Code is the British Broadcasting -* Corporation. -* Portions created by the Initial Developer are Copyright (C) 2007. -* All Rights Reserved. -* -* Contributor(s): Andrea Gabriellini (Original Author) -* -* Alternatively, the contents of this file may be used under the terms of -* the GNU General Public License Version 2 (the "GPL"), or the GNU Lesser -* Public License Version 2.1 (the "LGPL"), in which case the provisions of -* the GPL or the LGPL are applicable instead of those above. If you wish to -* allow use of your version of this file only under the terms of the either -* the GPL or LGPL and not to allow others to use your version of this file -* under the MPL, indicate your decision by deleting the provisions above -* and replace them with the notice and other provisions required by the GPL -* or LGPL. If you do not delete the provisions above, a recipient may use -* your version of this file under the terms of any one of the MPL, the GPL -* or the LGPL. -* ***** END LICENSE BLOCK ***** */ - -#ifndef _SCHRODECTEST_HPP_ -#define _SCHRODECTEST_HPP_ - -#include - -#include -#include -#include - -#include - -class SchrodecTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE ( SchrodecTest ); - CPPUNIT_TEST ( testSchrodec ); - CPPUNIT_TEST ( testSchrodecRun ); - CPPUNIT_TEST_SUITE_END(); - -public: - SchrodecTest(); - virtual ~SchrodecTest(); - - virtual void setUp(); - virtual void tearDown(); - - void testSchrodec(); - void testSchrodecRun(); - -private: - std::auto_ptr parser_; - std::auto_ptr manager_; - static std::string filename_; -}; - - - - -#endif /* _SCHRODECTEST_HPP_ */ -- 2.11.4.GIT