├── .gitignore ├── .travis.yml ├── COPYING ├── Makefile.am ├── README.md ├── autogen.sh ├── configure.ac ├── debian ├── changelog ├── compat ├── control ├── copyright ├── postinst ├── postrm ├── rules └── source │ └── format ├── include ├── libde265_plugin_common.h └── vlc_codecs.h ├── m4 └── empty.dir ├── patches ├── vlc-2.1-37431af7ef-demux-mkv.diff ├── vlc-2.1-37431af7ef-demux-mp4.diff └── vlc-2.1-37431af7ef-demux-ts.diff ├── prepare-package.sh └── src ├── codec └── libde265dec.c ├── demux ├── COPYING.LIB ├── dvb-text.h ├── libde265demux.c ├── mkv │ ├── Ebml_parser.cpp │ ├── Ebml_parser.hpp │ ├── chapter_command.cpp │ ├── chapter_command.hpp │ ├── chapters.cpp │ ├── chapters.hpp │ ├── demux.cpp │ ├── demux.hpp │ ├── matroska_segment.cpp │ ├── matroska_segment.hpp │ ├── matroska_segment_parse.cpp │ ├── mkv.cpp │ ├── mkv.hpp │ ├── stream_io_callback.cpp │ ├── stream_io_callback.hpp │ ├── util.cpp │ ├── util.hpp │ ├── virtual_segment.cpp │ └── virtual_segment.hpp ├── mp4 │ ├── id3genres.h │ ├── libmp4.c │ ├── libmp4.h │ └── mp4.c ├── ts.c └── vobsub.h └── mux ├── COPYING.LIB └── mpeg ├── csa.c ├── csa.h └── dvbpsi_compat.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.lo 3 | .deps 4 | .dirstamp 5 | .libs 6 | Makefile 7 | *.la 8 | *.a 9 | *.so 10 | *.tar.gz 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # stats available at 2 | # https://travis-ci.org/strukturag/vlc-libde265/ 3 | language: c 4 | compiler: 5 | - clang 6 | - gcc 7 | 8 | before_install: 9 | - sudo add-apt-repository -y ppa:strukturag/libde265 10 | - sudo apt-get update -qq 11 | - sudo apt-get install -y libde265-dev libvlccore-dev libmatroska-dev libebml-dev libdvbpsi-dev 12 | 13 | script: 14 | - ./autogen.sh 15 | - ./configure 16 | - make 17 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | AUTOMAKE_OPTIONS = subdir-objects 4 | 5 | EXTRA_DIST = \ 6 | autogen.sh \ 7 | m4/empty.dir \ 8 | README.md \ 9 | prepare-package.sh \ 10 | src/demux/COPYING.LIB \ 11 | patches/* 12 | 13 | lib_LTLIBRARIES = libde265_plugin.la 14 | 15 | CFLAGS = -DVLC_MODULE_COPYRIGHT="\"Copyright \(c) struktur AG\"" 16 | CFLAGS += -DVLC_MODULE_LICENSE=\"LGPL\" 17 | 18 | 19 | 20 | libde265_plugin_la_CFLAGS = -DMODULE_STRING=\"de265\" $(libde265_CFLAGS) $(vlc_CFLAGS) 21 | libde265_plugin_la_CPPFLAGS = -DMODULE_STRING=\"de265\" $(libde265_CFLAGS) $(vlc_CFLAGS) 22 | libde265_plugin_la_LIBADD = $(libde265_LIBS) $(vlc_LIBS) 23 | libde265_plugin_la_LDFLAGS = -avoid-version -module -export-symbol-regex ^vlc_entry $(libde265_LDFLAGS) $(vlc_LDFLAGS) 24 | libde265_plugin_la_SOURCES = \ 25 | src/codec/libde265dec.c \ 26 | include/libde265_plugin_common.h 27 | 28 | lib_LTLIBRARIES += libde265demux_plugin.la 29 | 30 | libde265demux_plugin_la_CFLAGS = -DMODULE_STRING=\"de265demux\" $(vlc_CFLAGS) 31 | libde265demux_plugin_la_CPPFLAGS = -DMODULE_STRING=\"de265demux\" $(vlc_CFLAGS) 32 | libde265demux_plugin_la_LIBADD = $(vlc_LIBS) 33 | libde265demux_plugin_la_LDFLAGS = -avoid-version -module -export-symbol-regex ^vlc_entry $(vlc_LDFLAGS) 34 | libde265demux_plugin_la_SOURCES = \ 35 | src/demux/libde265demux.c \ 36 | include/libde265_plugin_common.h 37 | 38 | # older versions of vlc don't know about HEVC content in MKV 39 | if !HAVE_VLC_HEVC 40 | lib_LTLIBRARIES += libde265_mkv_plugin.la 41 | 42 | libde265_mkv_plugin_la_CFLAGS = -DHAVE_ATTRIBUTE_PACKED -DMODULE_STRING=\"mkv\" $(vlc_CFLAGS) 43 | libde265_mkv_plugin_la_CPPFLAGS = -DHAVE_ATTRIBUTE_PACKED -DMODULE_STRING=\"mkv\" $(vlc_CFLAGS) 44 | libde265_mkv_plugin_la_LIBADD = $(vlc_LIBS) -lebml -lmatroska 45 | libde265_mkv_plugin_la_LDFLAGS = -avoid-version -module -export-symbol-regex ^vlc_entry $(vlc_LDFLAGS) 46 | libde265_mkv_plugin_la_SOURCES = \ 47 | src/demux/vobsub.h \ 48 | src/demux/mp4/libmp4.c \ 49 | src/demux/mp4/libmp4.h \ 50 | src/demux/mkv/chapter_command.cpp \ 51 | src/demux/mkv/chapter_command.hpp \ 52 | src/demux/mkv/chapters.cpp \ 53 | src/demux/mkv/chapters.hpp \ 54 | src/demux/mkv/demux.cpp \ 55 | src/demux/mkv/demux.hpp \ 56 | src/demux/mkv/Ebml_parser.cpp \ 57 | src/demux/mkv/Ebml_parser.hpp \ 58 | src/demux/mkv/matroska_segment.cpp \ 59 | src/demux/mkv/matroska_segment.hpp \ 60 | src/demux/mkv/matroska_segment_parse.cpp \ 61 | src/demux/mkv/mkv.cpp \ 62 | src/demux/mkv/mkv.hpp \ 63 | src/demux/mkv/stream_io_callback.cpp \ 64 | src/demux/mkv/stream_io_callback.hpp \ 65 | src/demux/mkv/util.cpp \ 66 | src/demux/mkv/util.hpp \ 67 | src/demux/mkv/virtual_segment.cpp \ 68 | src/demux/mkv/virtual_segment.hpp \ 69 | include/libde265_plugin_common.h \ 70 | include/vlc_codecs.h 71 | endif 72 | 73 | # older versions of vlc don't know about HEVC content in MP4 74 | if !HAVE_VLC_HEVC_MP4 75 | lib_LTLIBRARIES += libde265_mp4_plugin.la 76 | 77 | libde265_mp4_plugin_la_CFLAGS = -DHAVE_ATTRIBUTE_PACKED -DMODULE_STRING=\"mp4\" $(vlc_CFLAGS) 78 | libde265_mp4_plugin_la_CPPFLAGS = -DHAVE_ATTRIBUTE_PACKED -DMODULE_STRING=\"mp4\" $(vlc_CFLAGS) 79 | libde265_mp4_plugin_la_LIBADD = $(vlc_LIBS) 80 | libde265_mp4_plugin_la_LDFLAGS = -avoid-version -module -export-symbol-regex ^vlc_entry $(vlc_LDFLAGS) 81 | libde265_mp4_plugin_la_SOURCES = \ 82 | src/demux/mp4/id3genres.h \ 83 | src/demux/mp4/libmp4.c \ 84 | src/demux/mp4/libmp4.h \ 85 | src/demux/mp4/mp4.c 86 | endif 87 | 88 | # older versions of vlc don't know about HEVC content in MPEG-TS 89 | if !HAVE_VLC_HEVC_TS 90 | lib_LTLIBRARIES += libde265_ts_plugin.la 91 | 92 | libde265_ts_plugin_la_CFLAGS = -DHAVE_ATTRIBUTE_PACKED -DMODULE_STRING=\"ts\" $(vlc_CFLAGS) $(libdvbpsi_CFLAGS) -Wno-deprecated-declarations 93 | libde265_ts_plugin_la_CPPFLAGS = -DHAVE_ATTRIBUTE_PACKED -DMODULE_STRING=\"ts\" $(vlc_CFLAGS) $(libdvbpsi_CFLAGS) 94 | libde265_ts_plugin_la_LIBADD = $(vlc_LIBS) $(libdvbpsi_LIBS) 95 | libde265_ts_plugin_la_LDFLAGS = -avoid-version -module -export-symbol-regex ^vlc_entry $(vlc_LDFLAGS) 96 | libde265_ts_plugin_la_SOURCES = \ 97 | src/demux/dvb-text.h \ 98 | src/demux/ts.c \ 99 | src/mux/mpeg/csa.c \ 100 | src/mux/mpeg/csa.h \ 101 | src/mux/mpeg/dvbpsi_compat.h \ 102 | include/libde265_plugin_common.h \ 103 | include/vlc_codecs.h 104 | endif 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vlc-libde265 2 | 3 | Plugins for VLC 2.x to support HEVC decoding using libde265. For VLC 4 | versions below 2.1, a modified MKV demuxer is included which has support 5 | for HEVC streams. For VLC versions below 2.2, modified MPEG-TS and MP4 6 | demuxers are included which have support for HEVC streams. 7 | 8 | 9 | ## Building 10 | 11 | [![Build Status](https://travis-ci.org/strukturag/vlc-libde265.png?branch=master)](https://travis-ci.org/strukturag/vlc-libde265) 12 | 13 | Execute the default `configure` / `make` steps: 14 | 15 | $ ./configure 16 | $ make 17 | 18 | If you fetched vlc-libde265 from GitHub, you will need to generate the 19 | `configure` script first: 20 | 21 | $ ./autogen.sh 22 | 23 | 24 | ## Dependencies 25 | 26 | In addition to a compiler, a couple of other packages must be installed 27 | in order to compile the plugin: 28 | - libvlccore-dev 29 | - libde265-dev (>= 0.7) 30 | - libebml-dev 31 | - libmatroska-dev 32 | - libdvbpsi-dev 33 | 34 | These should be available from the package management on any recent 35 | version of Debian / Ubuntu. 36 | 37 | 38 | ## Patches 39 | 40 | See the `patches` folder for changes applied to the VLC source code of 41 | the demuxers to make them compile against older versions of VLC. 42 | 43 | 44 | ## Settings 45 | 46 | In the advanced settings of VLC, a couple of properties can be configured 47 | for the libde265 plugins (below "Demuxers" and "Video codecs"): 48 | - Framerate for raw bitstream demuxer (25 fps is assumed by default) 49 | - Number of threads to use for decoding ("auto" by default) 50 | - Whether the deblocking filter should be disabled (enabled by default) 51 | - Whether the sample-adaptive-offset filter should be disabled (enabled by default) 52 | 53 | 54 | ## Packages 55 | 56 | Binary packages for Ubuntu are available on Launchpad: 57 | https://launchpad.net/~strukturag/+archive/libde265 58 | 59 | 60 | Copyright (c) 2014 struktur AG 61 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -x "`which autoreconf 2>/dev/null`" ] ; then 3 | exec autoreconf -ivf 4 | fi 5 | 6 | LIBTOOLIZE=libtoolize 7 | SYSNAME=`uname` 8 | if [ "x$SYSNAME" = "xDarwin" ] ; then 9 | LIBTOOLIZE=glibtoolize 10 | fi 11 | aclocal -I m4 && \ 12 | autoheader && \ 13 | $LIBTOOLIZE && \ 14 | autoconf && \ 15 | automake --add-missing --force-missing --copy 16 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # Process this file with autoconf to produce a configure script. 2 | AC_PREREQ([2.68]) 3 | AC_INIT([vlc-libde265], [0.1.7], [bauch@struktur.de]) 4 | AC_CONFIG_SRCDIR([src/codec/libde265dec.c]) 5 | AC_CONFIG_HEADERS([config.h]) 6 | AC_CONFIG_MACRO_DIR([m4]) 7 | AC_CANONICAL_SYSTEM 8 | AC_USE_SYSTEM_EXTENSIONS 9 | LT_INIT 10 | 11 | # Checks for programs. 12 | AC_PROG_CXX 13 | AC_PROG_CC 14 | AC_PROG_CC_C99 15 | AC_PROG_INSTALL 16 | AC_PROG_LN_S 17 | PKG_PROG_PKG_CONFIG 18 | 19 | # Initialize automake stuff 20 | AM_INIT_AUTOMAKE([foreign]) 21 | 22 | AC_HEADER_STDBOOL 23 | AC_TYPE_INT8_T 24 | AC_TYPE_INT16_T 25 | AC_TYPE_INT32_T 26 | AC_TYPE_INT64_T 27 | AC_TYPE_UINT8_T 28 | AC_TYPE_UINT16_T 29 | AC_TYPE_UINT32_T 30 | AC_TYPE_UINT64_T 31 | AC_TYPE_OFF_T 32 | AC_TYPE_SIZE_T 33 | 34 | AC_C_INLINE 35 | AC_FUNC_MALLOC 36 | AC_FUNC_REALLOC 37 | AC_FUNC_STRNLEN 38 | AC_SEARCH_LIBS([sqrt], [m]) 39 | AC_CHECK_FUNCS([memset sqrt strcasecmp strcspn strdup strndup strstr strtol]) 40 | 41 | PKG_CHECK_MODULES([libde265], [libde265 >= 0.7]) 42 | PKG_CHECK_MODULES([vlc], [vlc-plugin >= 2.0]) 43 | PKG_CHECK_MODULES([vlc212], [vlc-plugin >= 2.1], 44 | [AC_DEFINE([HAVE_VLC_HEVC], [1], [Whether VLC with HEVC support was found.]) 45 | have_vlc_hevc="yes"], 46 | [have_vlc_hevc="no"]) 47 | PKG_CHECK_MODULES([vlc220], [vlc-plugin >= 2.2], 48 | [AC_DEFINE([HAVE_VLC_HEVC_TS], [1], [Whether VLC with HEVC in MPEG-TS support was found.]) 49 | have_vlc_hevc_ts="yes" have_vlc_hevc_mp4="yes"], 50 | [have_vlc_hevc_ts="no" have_vlc_hevc_mp4="no"]) 51 | PKG_CHECK_MODULES([vlc300], [vlc-plugin >= 3.0], 52 | [AC_DEFINE([HAVE_VLC_REFCOUNT_PICTURE], [1], [Whether VLC refcounts pictures directly.]) 53 | have_vlc_refcount_picture="yes"], 54 | [have_vlc_refcount_picture="no"]) 55 | 56 | AM_CONDITIONAL([HAVE_VLC_HEVC], [test "x$have_vlc_hevc" != "xno"]) 57 | AM_CONDITIONAL([HAVE_VLC_HEVC_TS], [test "x$have_vlc_hevc_ts" != "xno"]) 58 | AM_CONDITIONAL([HAVE_VLC_HEVC_MP4], [test "x$have_vlc_hevc_mp4" != "xno"]) 59 | 60 | if eval "test $have_vlc_hevc != yes" ; then 61 | AC_LANG_PUSH([C++]) 62 | AC_CHECK_HEADERS([ebml/EbmlVersion.h]) 63 | AC_CHECK_HEADERS([matroska/KaxTag.h]) 64 | AC_LANG_POP([C++]) 65 | fi 66 | 67 | if eval "test $have_vlc_hevc_ts != yes" ; then 68 | PKG_CHECK_MODULES([libdvbpsi], [libdvbpsi]) 69 | fi 70 | 71 | AC_CONFIG_FILES([Makefile]) 72 | AC_OUTPUT 73 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | vlc-libde265 (0.1.7-1ppa1) unstable; urgency=low 2 | 3 | * Support different chroma formats and bit depths with libde265 1.0.0 4 | and later. 5 | * Depend on libde265-dev >= 1.0.2. 6 | 7 | -- Joachim Bauch Wed, 15 Jul 2015 16:19:56 +0200 8 | 9 | vlc-libde265 (0.1.6-1ppa1) unstable; urgency=low 10 | 11 | * Don't pin version of libde265 in "Depends", determined 12 | automatically. 13 | * Added early check to disable direct rendering if image alignment 14 | doesn't match what libde265 requires. 15 | 16 | -- Joachim Bauch Thu, 11 Sep 2014 16:46:49 +0200 17 | 18 | vlc-libde265 (0.1.5-2ppa2) unstable; urgency=low 19 | 20 | * Enabled armhf builds. 21 | 22 | -- Joachim Bauch Fri, 08 Aug 2014 14:35:58 +0200 23 | 24 | vlc-libde265 (0.1.5-2ppa1) unstable; urgency=low 25 | 26 | * Update plugin cache on installation/removal. 27 | 28 | -- Joachim Bauch Mon, 04 Aug 2014 14:56:47 +0200 29 | 30 | vlc-libde265 (0.1.5-1ppa1) unstable; urgency=low 31 | 32 | * Added raw HEVC/H.265 bitstream demuxer. 33 | * Added patched MP4 demuxer with support for HEVC/H.265 video. 34 | * Decode NAL blocks in extra data, fixes crashes/image errors with 35 | some packetized streams. 36 | * Added first entries to VLC settings (demuxer/codec). 37 | 38 | -- Joachim Bauch Mon, 23 Jun 2014 16:01:24 +0200 39 | 40 | vlc-libde265 (0.1.4-1ppa1) unstable; urgency=low 41 | 42 | * Include "libde265" in module description (GitHub issue #2). 43 | * Various cleanup, smaller code changes from feedback of VLC 44 | developers. 45 | * Now requires libde265 0.7. 46 | * Notify libde265 about frames to drop. 47 | * Disable deblocking/SAO when dropping frames to further speed up 48 | decoding. 49 | * Support direct rendering by decoding directly into VLC pictures. 50 | 51 | -- Joachim Bauch Wed, 04 Jun 2014 15:35:06 +0200 52 | 53 | vlc-libde265 (0.1.3-1ppa1) unstable; urgency=low 54 | 55 | * Increase priority of TS demuxer. 56 | * Fixed compilation of TS demuxer on Trusty. 57 | 58 | -- Joachim Bauch Tue, 06 May 2014 13:41:31 +0200 59 | 60 | vlc-libde265 (0.1.2-2ppa1) unstable; urgency=low 61 | 62 | * Install TS demuxer if available. 63 | 64 | -- Joachim Bauch Tue, 06 May 2014 11:24:00 +0200 65 | 66 | vlc-libde265 (0.1.2-1ppa1) unstable; urgency=low 67 | 68 | * Support decoding of MPEG-TS containing HEVC video. 69 | * Evaluate "extra" data to check if stream is packetized. 70 | 71 | -- Joachim Bauch Tue, 06 May 2014 11:08:17 +0200 72 | 73 | vlc-libde265 (0.1.1-1ppa1) unstable; urgency=low 74 | 75 | * Drop frames if computer is too slow for decoding. 76 | 77 | -- Joachim Bauch Thu, 10 Apr 2014 12:43:59 +0200 78 | 79 | vlc-libde265 (0.1.0-1ppa4) unstable; urgency=low 80 | 81 | * Fixed wrong package name in rules. 82 | 83 | -- Joachim Bauch Wed, 02 Apr 2014 23:43:48 +0200 84 | 85 | vlc-libde265 (0.1.0-1ppa3) unstable; urgency=low 86 | 87 | * Implement "build-arch" and "build-indep" to fix lintian errors. 88 | * Section should be "video". 89 | * Always get libebml-dev and libmatroska-dev as build dependencies, 90 | doesn't work otherwise on Launchpad. 91 | 92 | -- Joachim Bauch Wed, 02 Apr 2014 17:53:06 +0200 93 | 94 | vlc-libde265 (0.1.0-1ppa2) unstable; urgency=low 95 | 96 | * Rename binary package to have "plugin" in the name. 97 | 98 | -- Joachim Bauch Wed, 02 Apr 2014 14:16:27 +0200 99 | 100 | vlc-libde265 (0.1.0-1ppa1) unstable; urgency=low 101 | 102 | * Initial release. 103 | 104 | -- Joachim Bauch Wed, 02 Apr 2014 13:54:32 +0200 105 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 6 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: vlc-libde265 2 | Priority: optional 3 | Maintainer: Joachim Bauch 4 | Build-Depends: 5 | debhelper (>= 6.0), 6 | libtool, 7 | automake, 8 | autoconf, 9 | pkg-config, 10 | libde265-dev (>= 1.0.2), 11 | libvlccore-dev, 12 | libebml-dev, 13 | libmatroska-dev, 14 | libdvbpsi-dev 15 | Standards-Version: 3.8.3 16 | Section: video 17 | Homepage: https://github.com/strukturag/vlc-libde265 18 | 19 | Package: vlc-plugin-libde265 20 | Section: video 21 | Architecture: any 22 | Depends: 23 | ${shlibs:Depends}, 24 | ${misc:Depends} 25 | Recommends: vlc 26 | Description: HEVC/H.265 video decoder plugin for VLC 27 | HEVC/H.265 video decoder plugin for VLC using libde265 for decoding. 28 | 29 | Package: vlc-plugin-libde265-dbg 30 | Section: debug 31 | Architecture: any 32 | Depends: 33 | vlc-plugin-libde265 (= ${binary:Version}), 34 | ${shlibs:Depends}, 35 | ${misc:Depends} 36 | Description: HEVC/H.265 video decoder plugin for VLC - debug symbols 37 | HEVC/H.265 video decoder plugin for VLC using libde265 for decoding. 38 | . 39 | The debugging symbols for tracking down bugs in applications that use 40 | vlc-plugin-libde265 are provided by this package. 41 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /debian/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ -x /usr/lib/vlc/vlc-cache-gen ]; then 6 | echo "Updating VLC plugin cache..." 7 | /usr/lib/vlc/vlc-cache-gen /usr/lib/vlc/plugins/ || true 8 | fi 9 | 10 | #DEBHELPER# 11 | -------------------------------------------------------------------------------- /debian/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | if [ "$1" = "remove" ]; then 6 | if [ -x /usr/lib/vlc/vlc-cache-gen ]; then 7 | echo "Updating VLC plugin cache..." 8 | /usr/lib/vlc/vlc-cache-gen /usr/lib/vlc/plugins/ || true 9 | fi 10 | fi 11 | 12 | #DEBHELPER# 13 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | #export DH_VERBOSE=1 3 | 4 | DEBIAN := $(shell pwd)/debian 5 | $DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) 6 | 7 | configure: configure-stamp 8 | configure-stamp: 9 | dh_testdir 10 | # Add here commands to configure the package. 11 | ./autogen.sh 12 | ./configure --prefix=$(DEBIAN)/prefix 13 | touch configure-stamp 14 | 15 | build: build-arch build-indep 16 | build-arch: build-stamp 17 | build-indep: build-stamp 18 | build-stamp: configure-stamp 19 | dh_testdir 20 | 21 | # Add here commands to compile the package. 22 | $(MAKE) 23 | 24 | touch $@ 25 | 26 | clean: 27 | dh_testdir 28 | if [ -f build-stamp ]; then $(MAKE) clean ; fi 29 | rm -rf $(DEBIAN)/prefix 30 | rm -f configure-stamp 31 | rm -f build-stamp 32 | 33 | install: build 34 | dh_testdir 35 | dh_testroot 36 | dh_clean -k 37 | dh_installdirs 38 | 39 | # Add here commands to install the package 40 | make install 41 | mkdir -p $(DEBIAN)/vlc-plugin-libde265/usr/lib/vlc/plugins/codec/ 42 | cp $(DEBIAN)/prefix/lib/libde265_plugin.so $(DEBIAN)/vlc-plugin-libde265/usr/lib/vlc/plugins/codec/ 43 | mkdir -p $(DEBIAN)/vlc-plugin-libde265/usr/lib/vlc/plugins/demux/ 44 | cp $(DEBIAN)/prefix/lib/libde265demux_plugin.so $(DEBIAN)/vlc-plugin-libde265/usr/lib/vlc/plugins/demux/ 45 | if [ -e $(DEBIAN)/prefix/lib/libde265_mkv_plugin.so ]; then \ 46 | cp $(DEBIAN)/prefix/lib/libde265_mkv_plugin.so $(DEBIAN)/vlc-plugin-libde265/usr/lib/vlc/plugins/demux/; \ 47 | fi 48 | if [ -e $(DEBIAN)/prefix/lib/libde265_mp4_plugin.so ]; then \ 49 | cp $(DEBIAN)/prefix/lib/libde265_mp4_plugin.so $(DEBIAN)/vlc-plugin-libde265/usr/lib/vlc/plugins/demux/; \ 50 | fi 51 | if [ -e $(DEBIAN)/prefix/lib/libde265_ts_plugin.so ]; then \ 52 | cp $(DEBIAN)/prefix/lib/libde265_ts_plugin.so $(DEBIAN)/vlc-plugin-libde265/usr/lib/vlc/plugins/demux/; \ 53 | fi 54 | 55 | # Build architecture-independent files here. 56 | binary-indep: build install 57 | # We have nothing to do by default. 58 | 59 | # Build architecture-dependent files here. 60 | binary-arch: build install 61 | dh_testdir 62 | dh_testroot 63 | dh_install 64 | dh_installchangelogs 65 | dh_installdocs 66 | dh_installexamples 67 | dh_installinit 68 | dh_installlogrotate 69 | dh_installmenu 70 | dh_link 71 | dh_strip --dbg-package=vlc-plugin-libde265-dbg 72 | dh_strip 73 | dh_compress 74 | dh_fixperms 75 | dh_makeshlibs 76 | dh_installdeb 77 | dh_shlibdeps 78 | dh_gencontrol 79 | dh_md5sums 80 | dh_builddeb 81 | 82 | binary: binary-indep binary-arch 83 | .PHONY: build clean binary-indep binary-arch binary install configure 84 | 85 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /include/libde265_plugin_common.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBDE265_PLUGIN_COMMON_H_ 2 | #define _LIBDE265_PLUGIN_COMMON_H_ 3 | 4 | #ifdef HAVE_CONFIG_H 5 | # include "config.h" 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #ifndef N_ 13 | #define N_(x) (x) 14 | #endif 15 | 16 | #ifndef _ 17 | #define _(x) (x) 18 | #endif 19 | 20 | #ifndef VLC_CODEC_HEVC 21 | #ifdef HAVE_VLC_HEVC 22 | #error "should have VLC_CODEC_HEVC with this version of VLC" 23 | #endif 24 | #define VLC_CODEC_HEVC VLC_FOURCC('h','e','v','c') 25 | #endif 26 | 27 | #ifndef VLC_CODEC_HEV1 28 | #define VLC_CODEC_HEV1 VLC_FOURCC('h','e','v','1') 29 | #endif 30 | 31 | #ifndef VLC_CODEC_SCTE_27 32 | #ifdef HAVE_VLC_HEVC_TS 33 | #error "should have VLC_CODEC_SCTE_27 with this version of VLC" 34 | #endif 35 | #define VLC_CODEC_SCTE_27 VLC_FOURCC('S','C','2','7') 36 | #endif 37 | 38 | #endif // _LIBDE265_PLUGIN_COMMON_H_ 39 | -------------------------------------------------------------------------------- /include/vlc_codecs.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * codecs.h: codec related structures needed by the demuxers and decoders 3 | ***************************************************************************** 4 | * Copyright (C) 1999-2001 VLC authors and VideoLAN 5 | * $Id: ad1f0d9b61eeb2d99d928201272e0197712bde07 $ 6 | * 7 | * Author: Gildas Bazin 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU Lesser General Public License as published by 11 | * the Free Software Foundation; either version 2.1 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with this program; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 22 | *****************************************************************************/ 23 | 24 | #ifndef VLC_CODECS_H 25 | #define VLC_CODECS_H 1 26 | 27 | #include 28 | /** 29 | * \file 30 | * This file defines codec related structures needed by the demuxers and decoders 31 | */ 32 | 33 | /* Structures exported to the demuxers and decoders */ 34 | 35 | #if !(defined _GUID_DEFINED || defined GUID_DEFINED) 36 | #define GUID_DEFINED 37 | typedef struct _GUID 38 | { 39 | uint32_t Data1; 40 | uint16_t Data2; 41 | uint16_t Data3; 42 | uint8_t Data4[8]; 43 | } GUID, *REFGUID, *LPGUID; 44 | #endif /* GUID_DEFINED */ 45 | 46 | typedef GUID guid_t; 47 | 48 | #ifdef HAVE_ATTRIBUTE_PACKED 49 | # define ATTR_PACKED __attribute__((__packed__)) 50 | #elif defined(__SUNPRO_C) 51 | # pragma pack(1) 52 | # define ATTR_PACKED 53 | #else 54 | # error FIXME 55 | #endif 56 | 57 | #ifndef _WAVEFORMATEX_ 58 | #define _WAVEFORMATEX_ 59 | typedef struct 60 | ATTR_PACKED 61 | _WAVEFORMATEX { 62 | uint16_t wFormatTag; 63 | uint16_t nChannels; 64 | uint32_t nSamplesPerSec; 65 | uint32_t nAvgBytesPerSec; 66 | uint16_t nBlockAlign; 67 | uint16_t wBitsPerSample; 68 | uint16_t cbSize; 69 | } WAVEFORMATEX, *PWAVEFORMATEX, *NPWAVEFORMATEX, *LPWAVEFORMATEX; 70 | #endif /* _WAVEFORMATEX_ */ 71 | 72 | #ifndef _WAVEFORMATEXTENSIBLE_ 73 | #define _WAVEFORMATEXTENSIBLE_ 74 | typedef struct 75 | ATTR_PACKED 76 | _WAVEFORMATEXTENSIBLE { 77 | WAVEFORMATEX Format; 78 | union { 79 | uint16_t wValidBitsPerSample; 80 | uint16_t wSamplesPerBlock; 81 | uint16_t wReserved; 82 | } Samples; 83 | uint32_t dwChannelMask; 84 | GUID SubFormat; 85 | } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE; 86 | #endif /* _WAVEFORMATEXTENSIBLE_ */ 87 | 88 | #ifndef _WAVEHEADER_ 89 | #define _WAVEHEADER_ 90 | typedef struct 91 | ATTR_PACKED 92 | _WAVEHEADER { 93 | uint32_t MainChunkID; 94 | uint32_t Length; 95 | uint32_t ChunkTypeID; 96 | uint32_t SubChunkID; 97 | uint32_t SubChunkLength; 98 | uint16_t Format; 99 | uint16_t Modus; 100 | uint32_t SampleFreq; 101 | uint32_t BytesPerSec; 102 | uint16_t BytesPerSample; 103 | uint16_t BitsPerSample; 104 | uint32_t DataChunkID; 105 | uint32_t DataLength; 106 | } WAVEHEADER; 107 | #endif /* _WAVEHEADER_ */ 108 | 109 | #ifndef _VLC_BITMAPINFOHEADER_ 110 | #define _VLC_BITMAPINFOHEADER_ 111 | 112 | typedef struct 113 | ATTR_PACKED 114 | { 115 | uint32_t biSize; 116 | uint32_t biWidth; 117 | uint32_t biHeight; 118 | uint16_t biPlanes; 119 | uint16_t biBitCount; 120 | uint32_t biCompression; 121 | uint32_t biSizeImage; 122 | uint32_t biXPelsPerMeter; 123 | uint32_t biYPelsPerMeter; 124 | uint32_t biClrUsed; 125 | uint32_t biClrImportant; 126 | } VLC_BITMAPINFOHEADER, *VLC_PBITMAPINFOHEADER, *VLC_LPBITMAPINFOHEADER; 127 | 128 | typedef struct 129 | ATTR_PACKED 130 | { 131 | VLC_BITMAPINFOHEADER bmiHeader; 132 | int bmiColors[1]; 133 | } VLC_BITMAPINFO, *VLC_LPBITMAPINFO; 134 | #endif 135 | 136 | #ifndef _RECT32_ 137 | #define _RECT32_ 138 | typedef struct 139 | ATTR_PACKED 140 | { 141 | int left, top, right, bottom; 142 | } RECT32; 143 | #endif 144 | 145 | #ifndef _REFERENCE_TIME_ 146 | #define _REFERENCE_TIME_ 147 | typedef int64_t REFERENCE_TIME; 148 | #endif 149 | 150 | #ifndef _VIDEOINFOHEADER_ 151 | #define _VIDEOINFOHEADER_ 152 | typedef struct 153 | ATTR_PACKED 154 | { 155 | RECT32 rcSource; 156 | RECT32 rcTarget; 157 | uint32_t dwBitRate; 158 | uint32_t dwBitErrorRate; 159 | REFERENCE_TIME AvgTimePerFrame; 160 | VLC_BITMAPINFOHEADER bmiHeader; 161 | } VIDEOINFOHEADER; 162 | #endif 163 | 164 | #ifndef _RGBQUAD_ 165 | #define _RGBQUAD_ 166 | typedef struct 167 | ATTR_PACKED 168 | { 169 | uint8_t rgbBlue; 170 | uint8_t rgbGreen; 171 | uint8_t rgbRed; 172 | uint8_t rgbReserved; 173 | } RGBQUAD1; 174 | #endif 175 | 176 | #ifndef _TRUECOLORINFO_ 177 | #define _TRUECOLORINFO_ 178 | typedef struct 179 | ATTR_PACKED 180 | { 181 | uint32_t dwBitMasks[3]; 182 | RGBQUAD1 bmiColors[256]; 183 | } TRUECOLORINFO; 184 | #endif 185 | 186 | #ifndef _VIDEOINFO_ 187 | #define _VIDEOINFO_ 188 | typedef struct 189 | ATTR_PACKED 190 | { 191 | RECT32 rcSource; 192 | RECT32 rcTarget; 193 | uint32_t dwBitRate; 194 | uint32_t dwBitErrorRate; 195 | REFERENCE_TIME AvgTimePerFrame; 196 | VLC_BITMAPINFOHEADER bmiHeader; 197 | 198 | union 199 | { 200 | RGBQUAD1 bmiColors[256]; /* Colour palette */ 201 | uint32_t dwBitMasks[3]; /* True colour masks */ 202 | TRUECOLORINFO TrueColorInfo; /* Both of the above */ 203 | }; 204 | 205 | } VIDEOINFO; 206 | #endif 207 | 208 | #if defined(__SUNPRO_C) 209 | # pragma pack() 210 | #endif 211 | 212 | /* WAVE format wFormatTag IDs */ 213 | /* See http://msdn.microsoft.com/en-us/library/aa904731%28v=vs.80%29.aspx */ 214 | #define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */ 215 | #define WAVE_FORMAT_PCM 0x0001 /* Microsoft Corporation */ 216 | #define WAVE_FORMAT_ADPCM 0x0002 /* Microsoft Corporation */ 217 | #define WAVE_FORMAT_IEEE_FLOAT 0x0003 /* Microsoft Corporation */ 218 | #define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */ 219 | #define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */ 220 | #define WAVE_FORMAT_DTS_MS 0x0008 /* Microsoft Corporation */ 221 | #define WAVE_FORMAT_WMAS 0x000a /* WMA 9 Speech */ 222 | #define WAVE_FORMAT_IMA_ADPCM 0x0011 /* Intel Corporation */ 223 | #define WAVE_FORMAT_TRUESPEECH 0x0022 /* TrueSpeech */ 224 | #define WAVE_FORMAT_GSM610 0x0031 /* Microsoft Corporation */ 225 | #define WAVE_FORMAT_MSNAUDIO 0x0032 /* Microsoft Corporation */ 226 | #define WAVE_FORMAT_G726 0x0045 /* ITU-T standard */ 227 | #define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */ 228 | #define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */ 229 | #define WAVE_FORMAT_AMR_NB 0x0057 /* AMR NB */ 230 | #define WAVE_FORMAT_AMR_WB 0x0058 /* AMR Wideband */ 231 | #define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092 /* Sonic Foundry */ 232 | 233 | #define WAVE_FORMAT_AAC 0x00FF /* */ 234 | #define WAVE_FORMAT_SIPRO 0x0130 /* Sipro Lab Telecom Inc. */ 235 | 236 | #define WAVE_FORMAT_WMA1 0x0160 /* WMA version 1 */ 237 | #define WAVE_FORMAT_WMA2 0x0161 /* WMA (v2) 7, 8, 9 Series */ 238 | #define WAVE_FORMAT_WMAP 0x0162 /* WMA 9 Professional */ 239 | #define WAVE_FORMAT_WMAL 0x0163 /* WMA 9 Lossless */ 240 | 241 | #define WAVE_FORMAT_AAC_2 0x1601 /* Other AAC */ 242 | #define WAVE_FORMAT_AAC_LATM 0x1602 /* AAC/LATM */ 243 | 244 | #define WAVE_FORMAT_A52 0x2000 /* a52 */ 245 | #define WAVE_FORMAT_DTS 0x2001 /* DTS */ 246 | #define WAVE_FORMAT_FFMPEG_AAC 0x706D 247 | #define WAVE_FORMAT_DIVIO_AAC 0x4143 /* Divio's AAC */ 248 | 249 | /* Need to check these */ 250 | #define WAVE_FORMAT_DK3 0x0061 251 | #define WAVE_FORMAT_DK4 0x0062 252 | 253 | /* At least FFmpeg use that ID: from libavformat/riff.c ('Vo' == 0x566f) 254 | * { CODEC_ID_VORBIS, ('V'<<8)+'o' }, //HACK/FIXME, does vorbis in WAV/AVI have an (in)official id? 255 | */ 256 | #define WAVE_FORMAT_VORBIS 0x566f 257 | 258 | /* It seems that these IDs are used by braindead & obsolete VorbisACM encoder 259 | * (Windows only) 260 | * A few info is available except VorbisACM source (remember, Windows only) 261 | * (available on http://svn.xiph.org), but it seems that vo3+ at least is 262 | * made of Vorbis data encapsulated in Ogg container... 263 | */ 264 | #define WAVE_FORMAT_VORB_1 0x674f 265 | #define WAVE_FORMAT_VORB_2 0x6750 266 | #define WAVE_FORMAT_VORB_3 0x6751 267 | #define WAVE_FORMAT_VORB_1PLUS 0x676f 268 | #define WAVE_FORMAT_VORB_2PLUS 0x6770 269 | #define WAVE_FORMAT_VORB_3PLUS 0x6771 270 | 271 | #define WAVE_FORMAT_SPEEX 0xa109 /* Speex audio */ 272 | 273 | #if !defined(WAVE_FORMAT_EXTENSIBLE) 274 | #define WAVE_FORMAT_EXTENSIBLE 0xFFFE /* Microsoft */ 275 | #endif 276 | 277 | /* GUID SubFormat IDs */ 278 | /* We need both b/c const variables are not compile-time constants in C, giving 279 | * us an error if we use the const GUID in an enum */ 280 | 281 | #ifndef _KSDATAFORMAT_SUBTYPE_PCM_ 282 | #define _KSDATAFORMAT_SUBTYPE_PCM_ {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}} 283 | static const GUID VLC_KSDATAFORMAT_SUBTYPE_PCM = {0xE923AABF, 0xCB58, 0x4471, {0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62}}; 284 | #define KSDATAFORMAT_SUBTYPE_PCM VLC_KSDATAFORMAT_SUBTYPE_PCM 285 | #endif 286 | 287 | #ifndef _KSDATAFORMAT_SUBTYPE_UNKNOWN_ 288 | #define _KSDATAFORMAT_SUBTYPE_UNKNOWN_ {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} 289 | static const GUID VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; 290 | #define KSDATAFORMAT_SUBTYPE_UNKNOWN VLC_KSDATAFORMAT_SUBTYPE_UNKNOWN 291 | #endif 292 | 293 | /* Microsoft speaker definitions */ 294 | #define WAVE_SPEAKER_FRONT_LEFT 0x1 295 | #define WAVE_SPEAKER_FRONT_RIGHT 0x2 296 | #define WAVE_SPEAKER_FRONT_CENTER 0x4 297 | #define WAVE_SPEAKER_LOW_FREQUENCY 0x8 298 | #define WAVE_SPEAKER_BACK_LEFT 0x10 299 | #define WAVE_SPEAKER_BACK_RIGHT 0x20 300 | #define WAVE_SPEAKER_FRONT_LEFT_OF_CENTER 0x40 301 | #define WAVE_SPEAKER_FRONT_RIGHT_OF_CENTER 0x80 302 | #define WAVE_SPEAKER_BACK_CENTER 0x100 303 | #define WAVE_SPEAKER_SIDE_LEFT 0x200 304 | #define WAVE_SPEAKER_SIDE_RIGHT 0x400 305 | #define WAVE_SPEAKER_TOP_CENTER 0x800 306 | #define WAVE_SPEAKER_TOP_FRONT_LEFT 0x1000 307 | #define WAVE_SPEAKER_TOP_FRONT_CENTER 0x2000 308 | #define WAVE_SPEAKER_TOP_FRONT_RIGHT 0x4000 309 | #define WAVE_SPEAKER_TOP_BACK_LEFT 0x8000 310 | #define WAVE_SPEAKER_TOP_BACK_CENTER 0x10000 311 | #define WAVE_SPEAKER_TOP_BACK_RIGHT 0x20000 312 | #define WAVE_SPEAKER_RESERVED 0x80000000 313 | 314 | static const struct 315 | { 316 | uint16_t i_tag; 317 | vlc_fourcc_t i_fourcc; 318 | const char *psz_name; 319 | } 320 | wave_format_tag_to_fourcc[] = 321 | { 322 | { WAVE_FORMAT_PCM, VLC_FOURCC( 'a', 'r', 'a', 'w' ), "Raw audio" }, 323 | { WAVE_FORMAT_PCM, VLC_CODEC_S8, "PCM S8 audio" }, 324 | { WAVE_FORMAT_PCM, VLC_CODEC_S16L, "PCM S16L audio" }, 325 | { WAVE_FORMAT_PCM, VLC_CODEC_S24L, "PCM S24L audio" }, 326 | { WAVE_FORMAT_PCM, VLC_CODEC_S32L, "PCM S32L audio" }, 327 | { WAVE_FORMAT_ADPCM, VLC_CODEC_ADPCM_MS, "ADPCM" }, 328 | { WAVE_FORMAT_IEEE_FLOAT, VLC_FOURCC( 'a', 'f', 'l', 't' ), "IEEE Float audio" }, 329 | { WAVE_FORMAT_IEEE_FLOAT, VLC_CODEC_F32L, "PCM 32 (Float) audio" }, 330 | { WAVE_FORMAT_IEEE_FLOAT, VLC_CODEC_F64L, "PCM 64 (Float) audio" }, 331 | { WAVE_FORMAT_ALAW, VLC_CODEC_ALAW, "A-Law" }, 332 | { WAVE_FORMAT_MULAW, VLC_CODEC_MULAW, "Mu-Law" }, 333 | { WAVE_FORMAT_IMA_ADPCM, VLC_CODEC_ADPCM_IMA_WAV, "Ima-ADPCM" }, 334 | { WAVE_FORMAT_TRUESPEECH, VLC_FOURCC(0x22, 0x0, 0x0, 0x0 ), "Truespeech" }, 335 | { WAVE_FORMAT_GSM610, VLC_CODEC_GSM_MS, "Microsoft WAV GSM" }, 336 | { WAVE_FORMAT_G726, VLC_CODEC_ADPCM_G726, "G.726 ADPCM" }, 337 | { WAVE_FORMAT_MPEGLAYER3, VLC_CODEC_MPGA, "Mpeg Audio" }, 338 | { WAVE_FORMAT_MPEG, VLC_CODEC_MPGA, "Mpeg Audio" }, 339 | { WAVE_FORMAT_AMR_NB, VLC_CODEC_AMR_NB, "AMR NB" }, 340 | { WAVE_FORMAT_AMR_WB, VLC_CODEC_AMR_WB, "AMR Wideband" }, 341 | { WAVE_FORMAT_SIPRO, VLC_CODEC_SIPR, "Sipr Audio" }, 342 | { WAVE_FORMAT_A52, VLC_CODEC_A52, "A/52" }, 343 | { WAVE_FORMAT_WMA1, VLC_CODEC_WMA1, "Window Media Audio v1" }, 344 | { WAVE_FORMAT_WMA2, VLC_CODEC_WMA2, "Window Media Audio v2" }, 345 | { WAVE_FORMAT_WMAP, VLC_CODEC_WMAP, "Window Media Audio 9 Professional" }, 346 | { WAVE_FORMAT_WMAL, VLC_CODEC_WMAL, "Window Media Audio 9 Lossless" }, 347 | { WAVE_FORMAT_WMAS, VLC_CODEC_WMAS, "Window Media Audio 9 Speech" }, 348 | { WAVE_FORMAT_DK3, VLC_FOURCC( 'm', 's', 0x00,0x61), "Duck DK3" }, 349 | { WAVE_FORMAT_DK4, VLC_FOURCC( 'm', 's', 0x00,0x62), "Duck DK4" }, 350 | { WAVE_FORMAT_DTS, VLC_CODEC_DTS, "DTS Coherent Acoustics" }, 351 | { WAVE_FORMAT_DTS_MS, VLC_CODEC_DTS, "DTS Coherent Acoustics" }, 352 | { WAVE_FORMAT_DIVIO_AAC, VLC_CODEC_MP4A, "MPEG-4 Audio (Divio)" }, 353 | { WAVE_FORMAT_AAC, VLC_CODEC_MP4A, "MPEG-4 Audio" }, 354 | { WAVE_FORMAT_AAC_2, VLC_CODEC_MP4A, "MPEG-4 Audio" }, 355 | { WAVE_FORMAT_AAC_LATM, VLC_CODEC_MP4A, "MPEG-4 Audio" }, 356 | { WAVE_FORMAT_FFMPEG_AAC, VLC_CODEC_MP4A, "MPEG-4 Audio" }, 357 | { WAVE_FORMAT_VORBIS, VLC_CODEC_VORBIS, "Vorbis Audio" }, 358 | { WAVE_FORMAT_VORB_1, VLC_FOURCC( 'v', 'o', 'r', '1' ), "Vorbis 1 Audio" }, 359 | { WAVE_FORMAT_VORB_1PLUS, VLC_FOURCC( 'v', 'o', '1', '+' ), "Vorbis 1+ Audio" }, 360 | { WAVE_FORMAT_VORB_2, VLC_FOURCC( 'v', 'o', 'r', '2' ), "Vorbis 2 Audio" }, 361 | { WAVE_FORMAT_VORB_2PLUS, VLC_FOURCC( 'v', 'o', '2', '+' ), "Vorbis 2+ Audio" }, 362 | { WAVE_FORMAT_VORB_3, VLC_FOURCC( 'v', 'o', 'r', '3' ), "Vorbis 3 Audio" }, 363 | { WAVE_FORMAT_VORB_3PLUS, VLC_FOURCC( 'v', 'o', '3', '+' ), "Vorbis 3+ Audio" }, 364 | { WAVE_FORMAT_SPEEX, VLC_CODEC_SPEEX, "Speex Audio" }, 365 | { WAVE_FORMAT_UNKNOWN, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" } 366 | }; 367 | 368 | static inline void wf_tag_to_fourcc( uint16_t i_tag, vlc_fourcc_t *fcc, 369 | const char **ppsz_name ) 370 | { 371 | int i; 372 | for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ ) 373 | { 374 | if( wave_format_tag_to_fourcc[i].i_tag == i_tag ) break; 375 | } 376 | if( fcc ) *fcc = wave_format_tag_to_fourcc[i].i_fourcc; 377 | if( ppsz_name ) *ppsz_name = wave_format_tag_to_fourcc[i].psz_name; 378 | } 379 | 380 | static inline void fourcc_to_wf_tag( vlc_fourcc_t fcc, uint16_t *pi_tag ) 381 | { 382 | int i; 383 | for( i = 0; wave_format_tag_to_fourcc[i].i_tag != 0; i++ ) 384 | { 385 | if( wave_format_tag_to_fourcc[i].i_fourcc == fcc ) break; 386 | } 387 | if( pi_tag ) *pi_tag = wave_format_tag_to_fourcc[i].i_tag; 388 | } 389 | 390 | /* If wFormatTag is WAVEFORMATEXTENSIBLE, we must look at the SubFormat tag 391 | * to determine the actual format. Microsoft has stopped giving out wFormatTag 392 | * assignments in lieu of letting 3rd parties generate their own GUIDs 393 | */ 394 | static const struct 395 | { 396 | GUID guid_tag; 397 | vlc_fourcc_t i_fourcc; 398 | const char *psz_name; 399 | } 400 | sub_format_tag_to_fourcc[] = 401 | { 402 | { _KSDATAFORMAT_SUBTYPE_PCM_, VLC_FOURCC( 'p', 'c', 'm', ' ' ), "PCM" }, 403 | { _KSDATAFORMAT_SUBTYPE_UNKNOWN_, VLC_FOURCC( 'u', 'n', 'd', 'f' ), "Unknown" } 404 | }; 405 | 406 | /* compares two GUIDs, returns 1 if identical, 0 otherwise */ 407 | static inline int guidcmp( const GUID *s1, const GUID *s2 ) 408 | { 409 | return( s1->Data1 == s2->Data1 && s1->Data2 == s2->Data2 && 410 | s1->Data3 == s2->Data3 && !memcmp( s1->Data4, s2->Data4, 8 ) ); 411 | } 412 | 413 | static inline void sf_tag_to_fourcc( GUID *guid_tag, 414 | vlc_fourcc_t *fcc, const char **ppsz_name ) 415 | { 416 | int i; 417 | 418 | for( i = 0; !guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, 419 | &KSDATAFORMAT_SUBTYPE_UNKNOWN ); i++ ) 420 | { 421 | if( guidcmp( &sub_format_tag_to_fourcc[i].guid_tag, guid_tag ) ) break; 422 | } 423 | if( fcc ) *fcc = sub_format_tag_to_fourcc[i].i_fourcc; 424 | if( ppsz_name ) *ppsz_name = sub_format_tag_to_fourcc[i].psz_name; 425 | } 426 | 427 | #endif /* "codecs.h" */ 428 | -------------------------------------------------------------------------------- /m4/empty.dir: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /patches/vlc-2.1-37431af7ef-demux-mkv.diff: -------------------------------------------------------------------------------- 1 | Nur in src/demux/mkv/: .deps. 2 | Nur in src/demux/mkv/: .dirstamp. 3 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-chapter_command.lo. 4 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-chapter_command.o. 5 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-chapters.lo. 6 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-chapters.o. 7 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-demux.lo. 8 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-demux.o. 9 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-Ebml_parser.lo. 10 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-Ebml_parser.o. 11 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-matroska_segment.lo. 12 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-matroska_segment.o. 13 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-matroska_segment_parse.lo. 14 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-matroska_segment_parse.o. 15 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-mkv.lo. 16 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-mkv.o. 17 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-stream_io_callback.lo. 18 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-stream_io_callback.o. 19 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-util.lo. 20 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-util.o. 21 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-virtual_segment.lo. 22 | Nur in src/demux/mkv/: libde265_mkv_plugin_la-virtual_segment.o. 23 | Nur in src/demux/mkv/: .libs. 24 | diff -ur ../vlc-2.1/modules/demux/mkv/matroska_segment.cpp src/demux/mkv/matroska_segment.cpp 25 | --- ../vlc-2.1/modules/demux/mkv/matroska_segment.cpp 2014-04-10 12:27:29.000000000 +0200 26 | +++ src/demux/mkv/matroska_segment.cpp 2014-04-02 11:20:50.000000000 +0200 27 | @@ -259,7 +259,9 @@ 28 | {vlc_meta_URL, "URL", 0}, 29 | {vlc_meta_Publisher, "PUBLISHER", 0}, 30 | {vlc_meta_EncodedBy, "ENCODED_BY", 0}, 31 | +#if 0 32 | {vlc_meta_TrackTotal, "TOTAL_PARTS", 0}, 33 | +#endif 34 | {vlc_meta_Title, NULL, 0}, 35 | }; 36 | 37 | diff -ur ../vlc-2.1/modules/demux/mkv/matroska_segment_parse.cpp src/demux/mkv/matroska_segment_parse.cpp 38 | --- ../vlc-2.1/modules/demux/mkv/matroska_segment_parse.cpp 2014-04-10 12:27:29.000000000 +0200 39 | +++ src/demux/mkv/matroska_segment_parse.cpp 2014-05-07 14:35:00.000000000 +0200 40 | @@ -32,7 +32,7 @@ 41 | #include "../vobsub.h" 42 | } 43 | 44 | -#include 45 | +#include "../../../include/vlc_codecs.h" 46 | 47 | /* GetFourCC helper */ 48 | #define GetFOURCC( p ) __GetFOURCC( (uint8_t*)p ) 49 | @@ -1349,11 +1349,6 @@ 50 | p_tk->fmt.i_codec = VLC_CODEC_VP8; 51 | p_tk->b_pts_only = true; 52 | } 53 | - else if( !strncmp( p_tk->psz_codec, "V_VP9", 5 ) ) 54 | - { 55 | - p_tk->fmt.i_codec = VLC_CODEC_VP9; 56 | - fill_extra_data( p_tk, 0 ); 57 | - } 58 | else if( !strncmp( p_tk->psz_codec, "V_MPEG4", 7 ) ) 59 | { 60 | if( !strcmp( p_tk->psz_codec, "V_MPEG4/MS/V3" ) ) 61 | diff -ur ../vlc-2.1/modules/demux/mkv/mkv.cpp src/demux/mkv/mkv.cpp 62 | --- ../vlc-2.1/modules/demux/mkv/mkv.cpp 2014-04-10 12:27:29.000000000 +0200 63 | +++ src/demux/mkv/mkv.cpp 2014-06-23 15:11:44.000000000 +0200 64 | @@ -43,9 +43,9 @@ 65 | static void Close( vlc_object_t * ); 66 | 67 | vlc_module_begin () 68 | - set_shortname( "Matroska" ) 69 | - set_description( N_("Matroska stream demuxer" ) ) 70 | - set_capability( "demux", 50 ) 71 | + set_shortname( "Matroska (HEVC/H.265)" ) 72 | + set_description( N_("Matroska stream demuxer with support for HEVC/H.265 video" ) ) 73 | + set_capability( "demux", 100 ) 74 | set_callbacks( Open, Close ) 75 | set_category( CAT_INPUT ) 76 | set_subcategory( SUBCAT_INPUT_DEMUX ) 77 | @@ -190,7 +190,7 @@ 78 | const uint8_t *p_peek; 79 | bool file_ok = false; 80 | #warning Memory leak! 81 | - std::string s_url = vlc_path2uri( s_filename.c_str(), "file" ); 82 | + std::string s_url = make_URI( s_filename.c_str(), "file" ); 83 | stream_t *p_file_stream = stream_UrlNew( 84 | p_demux, 85 | s_url.c_str() ); 86 | diff -ur ../vlc-2.1/modules/demux/mkv/mkv.hpp src/demux/mkv/mkv.hpp 87 | --- ../vlc-2.1/modules/demux/mkv/mkv.hpp 2014-04-10 12:27:29.000000000 +0200 88 | +++ src/demux/mkv/mkv.hpp 2014-05-07 14:34:33.000000000 +0200 89 | @@ -103,6 +103,8 @@ 90 | # include 91 | #endif 92 | 93 | +#include "../../../include/libde265_plugin_common.h" 94 | + 95 | #define MKV_DEBUG 0 96 | 97 | #define MATROSKA_COMPRESSION_NONE -1 98 | -------------------------------------------------------------------------------- /patches/vlc-2.1-37431af7ef-demux-mp4.diff: -------------------------------------------------------------------------------- 1 | Nur in src/demux/mp4/: .deps. 2 | Nur in src/demux/mp4/: .dirstamp. 3 | Nur in src/demux/mp4/: libde265_mkv_plugin_la-libmp4.lo. 4 | Nur in src/demux/mp4/: libde265_mkv_plugin_la-libmp4.o. 5 | Nur in src/demux/mp4/: libde265_mp4_plugin_la-libmp4.lo. 6 | Nur in src/demux/mp4/: libde265_mp4_plugin_la-libmp4.o. 7 | Nur in src/demux/mp4/: libde265_mp4_plugin_la-mp4.lo. 8 | Nur in src/demux/mp4/: libde265_mp4_plugin_la-mp4.o. 9 | diff -ur ../vlc-2.1/modules/demux/mp4/libmp4.h src/demux/mp4/libmp4.h 10 | --- ../vlc-2.1/modules/demux/mp4/libmp4.h 2014-04-10 12:27:29.000000000 +0200 11 | +++ src/demux/mp4/libmp4.h 2014-05-07 14:34:05.000000000 +0200 12 | @@ -269,6 +269,8 @@ 13 | # define MP4_VERBOSE 1 14 | #endif 15 | 16 | +#include "../../../include/libde265_plugin_common.h" 17 | + 18 | struct MP4_Box_s; 19 | 20 | 21 | Nur in src/demux/mp4/: .libs. 22 | diff -ur ../vlc-2.1/modules/demux/mp4/mp4.c src/demux/mp4/mp4.c 23 | --- ../vlc-2.1/modules/demux/mp4/mp4.c 2014-04-10 12:27:29.000000000 +0200 24 | +++ src/demux/mp4/mp4.c 2014-06-23 15:12:46.000000000 +0200 25 | @@ -49,9 +49,9 @@ 26 | vlc_module_begin () 27 | set_category( CAT_INPUT ) 28 | set_subcategory( SUBCAT_INPUT_DEMUX ) 29 | - set_description( N_("MP4 stream demuxer") ) 30 | - set_shortname( N_("MP4") ) 31 | - set_capability( "demux", 240 ) 32 | + set_description( N_("MP4 stream demuxer with support for HEVC/H.265 video") ) 33 | + set_shortname( N_("MP4 (HEVC/H.265)") ) 34 | + set_capability( "demux", 241 ) 35 | set_callbacks( Open, Close ) 36 | vlc_module_end () 37 | 38 | @@ -1019,6 +1019,7 @@ 39 | case ATOM_0xa9trk: /* Track */ 40 | SET( vlc_meta_SetTrackNum ); 41 | break; 42 | +#if 0 43 | case ATOM_trkn: 44 | { 45 | char psz_trck[11]; 46 | @@ -1033,6 +1034,7 @@ 47 | } 48 | break; 49 | } 50 | +#endif 51 | case ATOM_0xa9cmt: /* Commment */ 52 | SET( vlc_meta_SetDescription ); 53 | break; 54 | @@ -1716,7 +1718,7 @@ 55 | p_track, i_sample_description_index, i_chunk ); 56 | p_demux->p_sys->f_fps = (float)p_track->fmt.video.i_frame_rate / 57 | (float)p_track->fmt.video.i_frame_rate_base; 58 | - 59 | +#if 0 60 | /* Rotation */ 61 | switch( (int)p_track->f_rotation ) { 62 | case 90: 63 | @@ -1729,7 +1731,7 @@ 64 | p_track->fmt.video.orientation = ORIENT_ROTATED_270; 65 | break; 66 | } 67 | - 68 | +#endif 69 | break; 70 | 71 | case AUDIO_ES: 72 | @@ -2218,6 +2220,7 @@ 73 | break; 74 | } 75 | case VLC_FOURCC( 'h', 'v', 'c', '1' ): 76 | + case VLC_FOURCC( 'h', 'e', 'v', '1' ): 77 | { 78 | MP4_Box_t *p_hvcC = MP4_BoxGet( p_sample, "hvcC" ); 79 | 80 | -------------------------------------------------------------------------------- /patches/vlc-2.1-37431af7ef-demux-ts.diff: -------------------------------------------------------------------------------- 1 | --- ../vlc-2.1/modules/demux/ts.c 2014-04-10 12:27:29.000000000 +0200 2 | +++ src/demux/ts.c 2014-06-23 15:12:32.000000000 +0200 3 | @@ -63,6 +63,8 @@ 4 | 5 | #include "../mux/mpeg/dvbpsi_compat.h" 6 | 7 | +#include "../../include/libde265_plugin_common.h" 8 | + 9 | #undef TS_DEBUG 10 | VLC_FORMAT(1, 2) static void ts_debug(const char *format, ...) 11 | { 12 | @@ -134,8 +136,8 @@ 13 | 14 | 15 | vlc_module_begin () 16 | - set_description( N_("MPEG Transport Stream demuxer") ) 17 | - set_shortname ( "MPEG-TS" ) 18 | + set_description( N_("MPEG Transport Stream demuxer with support for HEVC/H.265 video") ) 19 | + set_shortname ( "MPEG-TS (HEVC/H.265)" ) 20 | set_category( CAT_INPUT ) 21 | set_subcategory( SUBCAT_INPUT_DEMUX ) 22 | 23 | @@ -158,7 +160,7 @@ 24 | 25 | add_obsolete_bool( "ts-silent" ); 26 | 27 | - set_capability( "demux", 10 ) 28 | + set_capability( "demux", 50 ) 29 | set_callbacks( Open, Close ) 30 | add_shortcut( "ts" ) 31 | vlc_module_end () 32 | @@ -2403,6 +2405,9 @@ 33 | case 0x1B: /* H264 <- check transport syntax/needed descriptor */ 34 | es_format_Init( fmt, VIDEO_ES, VLC_CODEC_H264 ); 35 | break; 36 | + case 0x24: /* HEVC */ 37 | + es_format_Init( fmt, VIDEO_ES, VLC_CODEC_HEVC ); 38 | + break; 39 | case 0x42: /* CAVS (Chinese AVS) */ 40 | es_format_Init( fmt, VIDEO_ES, VLC_CODEC_CAVS ); 41 | break; 42 | @@ -3101,8 +3106,13 @@ 43 | 44 | /* */ 45 | if( i_start > 0 ) 46 | +#ifdef HAVE_VLC_HEVC 47 | vlc_epg_AddEvent( p_epg, i_start, i_duration, psz_name, psz_text, 48 | *psz_extra ? psz_extra : NULL, i_min_age ); 49 | +#else 50 | + vlc_epg_AddEvent( p_epg, i_start, i_duration, psz_name, psz_text, 51 | + *psz_extra ? psz_extra : NULL ); 52 | +#endif 53 | 54 | /* Update "now playing" field */ 55 | if( p_evt->i_running_status == 0x04 && i_start > 0 ) 56 | @@ -3638,6 +3648,11 @@ 57 | p_fmt->b_packetized = true; 58 | p_fmt->i_codec = VLC_CODEC_302M; 59 | } 60 | + else if( PMTEsHasRegistration( p_demux, p_es, "HEVC" ) ) 61 | + { 62 | + p_fmt->i_cat = VIDEO_ES; 63 | + p_fmt->i_codec = VLC_CODEC_HEVC; 64 | + } 65 | else 66 | { 67 | /* Subtitle/Teletext/VBI fallbacks */ 68 | -------------------------------------------------------------------------------- /prepare-package.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$1" ]; then 4 | echo "No series given." 5 | exit 6 | fi 7 | 8 | export SERIES=$1 9 | export VERSION=`dpkg-parsechangelog | sed -n 's/^Version: //p'` 10 | export TMPFILE=`mktemp` 11 | 12 | cp debian/changelog ${TMPFILE} 13 | sed -i s/${VERSION}/${VERSION}~${SERIES}1/ debian/changelog 14 | debuild -S -sa 15 | cp ${TMPFILE} debian/changelog 16 | rm -f ${TMPFILE} 17 | -------------------------------------------------------------------------------- /src/demux/dvb-text.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dvb-text.h: 3 | ***************************************************************************** 4 | * Copyright (C) 2007-2011 VLC authors and VideoLAN 5 | * 6 | * This program is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU Lesser General Public License as published by 8 | * the Free Software Foundation; either version 2.1 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with this program; if not, write to the Free Software Foundation, 18 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 19 | *****************************************************************************/ 20 | 21 | /** 22 | * Converts a DVB SI text item to UTF-8. 23 | * Refer to EN 800 486 annex A. 24 | * @return a heap-allocation nul-terminated UTF-8 string or NULL on error. 25 | */ 26 | static char *vlc_from_EIT (const void *buf, size_t length) 27 | { 28 | if (unlikely(length == 0)) 29 | return NULL; 30 | 31 | char encbuf[12]; 32 | const char *encoding = encbuf; 33 | 34 | const char *in = buf; 35 | size_t offset = 1; 36 | unsigned char c = *in; 37 | 38 | if (c >= 0x20) 39 | { 40 | offset = 0; 41 | encoding = "ISO_6937"; 42 | } 43 | else if ((1 << c) & 0x0EFE) /* 1-7, 9-11 -> ISO 8859-(c+4) */ 44 | { 45 | snprintf (encbuf, sizeof (encbuf), "ISO_8859-%hhu", 4 + c); 46 | } 47 | else switch (c) 48 | { 49 | case 0x10: /* two more bytes */ 50 | offset = 3; 51 | if (length < 3 || in[1] != 0x00) 52 | return NULL; 53 | 54 | c = in[2]; 55 | if ((1 << c) & 0xEFFE) /* 1-11, 13-15 -> ISO 8859-(c) */ 56 | snprintf (encbuf, sizeof (encbuf), "ISO_8859-%hhu", c); 57 | else 58 | return NULL; 59 | break; 60 | case 0x11: /* the BMP */ 61 | case 0x14: /* Big5 subset of the BMP */ 62 | encoding = "UCS-2BE"; 63 | break; 64 | case 0x12: 65 | /* DVB has no clue about Korean. KS X 1001 (a.k.a. KS C 5601) is a 66 | * character set, not a character encoding... So we assume EUC-KR. 67 | * It is an encoding of KS X 1001. In practice, I guess nobody uses 68 | * this in any real DVB system. */ 69 | encoding = "EUC-KR"; 70 | break; 71 | case 0x13: /* GB-2312-1980 */ 72 | encoding = "GB2312"; 73 | break; 74 | case 0x15: 75 | encoding = "UTF-8"; 76 | break; 77 | #if 0 78 | case 0x1F: /* operator-specific(?) */ 79 | offset = 2; 80 | #endif 81 | default: 82 | return NULL; 83 | } 84 | 85 | in += offset; 86 | length -= offset; 87 | 88 | char *out = FromCharset (encoding, in, length); 89 | if (out == NULL) 90 | { /* Fallback... */ 91 | out = strndup (in, length); 92 | if (unlikely(out == NULL)) 93 | return NULL; 94 | EnsureUTF8 (out); 95 | } 96 | 97 | /* Convert control codes */ 98 | for (char *p = strchr (out, '\xC2'); p; p = strchr (p + 1, '\xC2')) 99 | { 100 | /* We have valid UTF-8, to 0xC2 is followed by a continuation byte. */ 101 | /* 0x80-0x85,0x88-0x89 are reserved. 102 | * 0x86-0x87 are identical to Unicode and Latin-1. 103 | * 0x8A is CR/LF. 104 | * 0x8B-0x9F are unspecified. */ 105 | if (p[1] == '\x8A') 106 | memcpy (p, "\r\n", 2); 107 | } 108 | 109 | /* Private use area */ 110 | for (char *p = strchr (out, '\xEE'); p; p = strchr (p + 1, '\xEE')) 111 | { 112 | /* Within UTF-8, 0xEE is followed by a two continuation bytes. */ 113 | if (p[1] != '\x82') 114 | continue; 115 | if (p[2] == '\x8A') 116 | memcpy (p, "\r\r\n", 3); /* we need three bytes, so to CRs ;) */ 117 | } 118 | 119 | return out; 120 | } 121 | -------------------------------------------------------------------------------- /src/demux/libde265demux.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * libde265dec.c: libde265 decoder (HEVC/H.265) module 3 | ***************************************************************************** 4 | * Copyright (C) 2014 struktur AG 5 | * 6 | * Authors: Joachim Bauch 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 21 | *****************************************************************************/ 22 | 23 | /***************************************************************************** 24 | * Preamble 25 | *****************************************************************************/ 26 | 27 | #ifdef HAVE_CONFIG_H 28 | # include "config.h" 29 | #endif 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "../../include/libde265_plugin_common.h" 38 | 39 | /***************************************************************************** 40 | * Module descriptor 41 | *****************************************************************************/ 42 | static int Open(vlc_object_t *); 43 | static void Close(vlc_object_t *); 44 | 45 | #define DETECT_BUFFER_SIZE 1024 46 | 47 | #define INITIAL_PEEK_SIZE 4096 48 | 49 | #define NAL_UNIT_BLA_W_LP 16 // BLA = broken link access 50 | #define NAL_UNIT_BLA_W_RADL 17 51 | #define NAL_UNIT_BLA_N_LP 18 52 | #define NAL_UNIT_IDR_W_RADL 19 53 | #define NAL_UNIT_IDR_N_LP 20 54 | #define NAL_UNIT_CRA_NUT 21 // CRA = clean random access 55 | #define NAL_UNIT_VPS_NUT 32 56 | #define NAL_UNIT_SPS_NUT 33 57 | #define NAL_UNIT_PPS_NUT 34 58 | 59 | #define FPS_TEXT N_("Frames per Second") 60 | #define FPS_LONGTEXT N_("This is the desired frame rate when " \ 61 | "playing raw bitstreams. In the form 30000/1001 or 29.97") 62 | 63 | vlc_module_begin() 64 | set_shortname(N_("Raw HEVC/H.265")) 65 | set_description(N_("Raw HEVC/H.265 bitstream demuxer")) 66 | set_capability("demux", 200) 67 | set_category(CAT_INPUT) 68 | set_subcategory(SUBCAT_INPUT_DEMUX) 69 | set_callbacks(Open, Close) 70 | add_shortcut("libde265demux") 71 | add_string("libde265demux-fps", NULL, FPS_TEXT, FPS_LONGTEXT, false) 72 | vlc_module_end() 73 | 74 | /***************************************************************************** 75 | * Definitions of structures used by this plugin 76 | *****************************************************************************/ 77 | struct demux_sys_t 78 | { 79 | es_out_id_t *es_video; 80 | es_format_t fmt_video; 81 | date_t pcr; 82 | int frame_size_estimate; 83 | int data_peeked; 84 | const uint8_t *peek; 85 | }; 86 | 87 | /***************************************************************************** 88 | * Local prototypes 89 | *****************************************************************************/ 90 | static int Demux(demux_t *); 91 | static int Control(demux_t *, int i_query, va_list args); 92 | 93 | // supported file extensions 94 | static const char *extensions[] = 95 | { 96 | "hevc", 97 | "h265", 98 | "265", 99 | "bin", 100 | "bit", 101 | NULL 102 | }; 103 | 104 | /***************************************************************************** 105 | * Open: initializes raw DV demux structures 106 | *****************************************************************************/ 107 | static int Open(vlc_object_t * p_this) 108 | { 109 | demux_t *demux = (demux_t *) p_this; 110 | const uint8_t *buffer; 111 | int buffer_size; 112 | uint32_t code=-1; 113 | int vps = 0, sps=0, pps=0, irap=0; 114 | unsigned fps_num=25, fps_den=1; // assume 25/1 fps by default 115 | int i; 116 | char *psz_tmp; 117 | 118 | if (!demux->b_force) { 119 | /* guess preset based on file extension */ 120 | if (!demux->psz_file) { 121 | return VLC_EGENERIC; 122 | } 123 | 124 | const char *extension = strrchr(demux->psz_file, '.'); 125 | if (!extension) { 126 | return VLC_EGENERIC; 127 | } 128 | extension++; 129 | 130 | for (unsigned i=0; extensions[i]; i++) { 131 | if (!strcasecmp(extension, extensions[i])) { 132 | goto supported_extension; 133 | } 134 | } 135 | return VLC_EGENERIC; 136 | } 137 | 138 | supported_extension: 139 | buffer_size = stream_Peek(demux->s, &buffer, DETECT_BUFFER_SIZE); 140 | for(i=0; i> 1; 145 | 146 | if (code & 0x81) { // forbidden and reserved zero bits 147 | return VLC_EGENERIC; 148 | } 149 | 150 | if (nal2 & 0xf8) { // reserved zero 151 | return VLC_EGENERIC; 152 | } 153 | 154 | switch (type) { 155 | case NAL_UNIT_VPS_NUT: vps++; break; 156 | case NAL_UNIT_SPS_NUT: sps++; break; 157 | case NAL_UNIT_PPS_NUT: pps++; break; 158 | case NAL_UNIT_BLA_W_LP: 159 | case NAL_UNIT_BLA_W_RADL: 160 | case NAL_UNIT_BLA_N_LP: 161 | case NAL_UNIT_IDR_W_RADL: 162 | case NAL_UNIT_IDR_N_LP: 163 | case NAL_UNIT_CRA_NUT: irap++; break; 164 | default: break; 165 | } 166 | } 167 | } 168 | 169 | // check if it looks like a valid bitstream 170 | if (!vps || !sps || !pps || !irap) { 171 | return VLC_EGENERIC; 172 | } 173 | 174 | psz_tmp = var_CreateGetNonEmptyString(demux, "libde265demux-fps"); 175 | if (psz_tmp) { 176 | char *p_ptr; 177 | /* fps can either be n/d or q.f 178 | * for accuracy, avoid representation in float */ 179 | fps_num = strtol(psz_tmp, &p_ptr, 10); 180 | if (*p_ptr == '/') { 181 | p_ptr++; 182 | fps_den = strtol(p_ptr, NULL, 10); 183 | } else if(*p_ptr == '.') { 184 | char *p_end; 185 | p_ptr++; 186 | int i_frac = strtol(p_ptr, &p_end, 10); 187 | fps_den = (p_end - p_ptr) * 10; 188 | if (!fps_den) { 189 | fps_den = 1; 190 | } 191 | fps_num = fps_num * fps_den + i_frac; 192 | } 193 | else if (*p_ptr == '\0') { 194 | fps_den = 1; 195 | } 196 | free(psz_tmp); 197 | } 198 | 199 | if (!fps_num || !fps_den) { 200 | msg_Err(demux, "invalid or no framerate specified."); 201 | return VLC_EGENERIC; 202 | } 203 | 204 | demux_sys_t *sys = malloc(sizeof(*sys)); 205 | if (!sys) { 206 | return VLC_ENOMEM; 207 | } 208 | demux->p_sys = sys; 209 | 210 | es_format_Init(&sys->fmt_video, VIDEO_ES, VLC_CODEC_HEVC); 211 | sys->fmt_video.b_packetized = 0; 212 | 213 | vlc_ureduce(&sys->fmt_video.video.i_frame_rate, 214 | &sys->fmt_video.video.i_frame_rate_base, 215 | fps_num, fps_den, 0); 216 | date_Init(&sys->pcr, sys->fmt_video.video.i_frame_rate, 217 | sys->fmt_video.video.i_frame_rate_base); 218 | date_Set(&sys->pcr, 0); 219 | 220 | sys->frame_size_estimate = 0; 221 | sys->data_peeked = 0; 222 | sys->frame_size_estimate = INITIAL_PEEK_SIZE; 223 | 224 | demux->pf_demux = Demux; 225 | demux->pf_control = Control; 226 | 227 | sys->es_video = es_out_Add(demux->out, &sys->fmt_video); 228 | return VLC_SUCCESS; 229 | } 230 | 231 | /***************************************************************************** 232 | * Close: frees unused data 233 | *****************************************************************************/ 234 | static void Close(vlc_object_t *p_this) 235 | { 236 | demux_t *demux = (demux_t *) p_this; 237 | demux_sys_t *sys = demux->p_sys; 238 | 239 | free(sys); 240 | } 241 | 242 | /***************************************************************************** 243 | * Peek: Helper function to peek data with incremental size. 244 | * \return false if peek no more data, true otherwise. 245 | *****************************************************************************/ 246 | static bool Peek(demux_t *p_demux, bool first) 247 | { 248 | int data; 249 | demux_sys_t *sys = p_demux->p_sys; 250 | 251 | if (first) { 252 | sys->data_peeked = 0; 253 | } else if (sys->data_peeked == sys->frame_size_estimate) { 254 | sys->frame_size_estimate += 4096; 255 | } 256 | data = stream_Peek(p_demux->s, &sys->peek, sys->frame_size_estimate); 257 | if (data == sys->data_peeked) { 258 | msg_Warn(p_demux, "no more data"); 259 | return false; 260 | } 261 | //printf("Peeked: %d (requested %d)\n", data, sys->frame_size_estimate); 262 | sys->data_peeked = data; 263 | if (data <= 0) { 264 | msg_Warn(p_demux, "cannot peek data"); 265 | return false; 266 | } 267 | return true; 268 | } 269 | 270 | /***************************************************************************** 271 | * SearchStartcode: Helper function to search for next NAL start code 272 | * \return position of start code or -1 if none was found (or no more data 273 | * is available. 274 | *****************************************************************************/ 275 | static int32_t SearchStartcode(demux_t *p_demux, int32_t start, int32_t *length) 276 | { 277 | demux_sys_t *sys = p_demux->p_sys; 278 | if (start == 0) { 279 | if (!Peek(p_demux, true)) { 280 | return -1; 281 | } 282 | } 283 | 284 | int32_t pos = start; 285 | int32_t remaining = sys->data_peeked - pos; 286 | for (;;) { 287 | if (pos + 4 >= sys->data_peeked) { 288 | if (!Peek(p_demux, false)) { 289 | // probably EOF 290 | pos = -1; 291 | break; 292 | } 293 | } 294 | 295 | if (sys->peek[pos] == 0 && sys->peek[pos+1] == 0 && sys->peek[pos+2] == 1) { 296 | if (length) { 297 | *length = 3; 298 | } 299 | break; 300 | } else if (sys->peek[pos] == 0 && sys->peek[pos+1] == 0 && sys->peek[pos+2] == 0 && sys->peek[pos+3] == 1) { 301 | if (length) { 302 | *length = 4; 303 | } 304 | break; 305 | } 306 | pos++; 307 | } 308 | return pos; 309 | } 310 | 311 | /***************************************************************************** 312 | * Demux: reads and demuxes data packets 313 | ***************************************************************************** 314 | * Returns -1 in case of error, 0 in case of EOF, 1 otherwise 315 | *****************************************************************************/ 316 | static int Demux(demux_t *p_demux) 317 | { 318 | demux_sys_t *sys = p_demux->p_sys; 319 | mtime_t pcr = date_Get(&sys->pcr); 320 | block_t *p_block; 321 | int32_t code_length; 322 | 323 | int32_t start = SearchStartcode(p_demux, 0, &code_length); 324 | if (start == -1) { 325 | if (sys->data_peeked == 0) { 326 | return 0; 327 | } 328 | 329 | msg_Err(p_demux, "no startcode found"); 330 | return -1; 331 | } 332 | 333 | // need at least 3 or 4 bytes startcode + 2 bytes header 334 | if (sys->data_peeked < start + code_length + 2) { 335 | msg_Err(p_demux, "data shortage"); 336 | return -1; 337 | } 338 | 339 | // parse NALU header 340 | bs_t bitreader; 341 | bs_init(&bitreader, sys->peek + start + code_length, sys->data_peeked - start - code_length); 342 | bs_skip(&bitreader, 1); // reserved bit 343 | int32_t type = bs_read(&bitreader, 6); 344 | int32_t layer_id = bs_read(&bitreader, 6); 345 | int32_t temporal_id_plus1 = bs_read(&bitreader, 3); 346 | 347 | int32_t end = SearchStartcode(p_demux, start + code_length + 2, NULL); 348 | if (end == -1) { 349 | end = sys->data_peeked; 350 | } 351 | 352 | bool new_picture = false; 353 | if (type < 32) { 354 | int32_t flag = bs_read(&bitreader, 1); 355 | new_picture = (flag == 1); 356 | } 357 | 358 | if (new_picture) { 359 | /* Call the pace control */ 360 | es_out_Control(p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + pcr); 361 | } 362 | if ((p_block = stream_Block(p_demux->s, end - start)) == NULL) { 363 | /* EOF */ 364 | return 0; 365 | } 366 | 367 | p_block->i_pts = VLC_TS_INVALID; 368 | p_block->i_dts = VLC_TS_0 + pcr; 369 | es_out_Send(p_demux->out, sys->es_video, p_block); 370 | 371 | if (new_picture) { 372 | date_Increment(&sys->pcr, 1); 373 | } 374 | return 1; 375 | } 376 | 377 | /***************************************************************************** 378 | * Control: 379 | *****************************************************************************/ 380 | static int Control(demux_t *p_demux, int i_query, va_list args) 381 | { 382 | // TODO(fancycode): which queries should we handle directly? 383 | return demux_vaControlHelper(p_demux->s, 0, -1, -1, -1, i_query, args); 384 | } 385 | -------------------------------------------------------------------------------- /src/demux/mkv/Ebml_parser.cpp: -------------------------------------------------------------------------------- 1 | 2 | /***************************************************************************** 3 | * EbmlParser for the matroska demuxer 4 | ***************************************************************************** 5 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 6 | * $Id: 6890f418d7cad14aa151e393a2b8a33d4b9b06f2 $ 7 | * 8 | * Authors: Laurent Aimar 9 | * Steve Lhomme 10 | * 11 | * This program is free software; you can redistribute it and/or modify it 12 | * under the terms of the GNU Lesser General Public License as published by 13 | * the Free Software Foundation; either version 2.1 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public License 22 | * along with this program; if not, write to the Free Software Foundation, 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 24 | *****************************************************************************/ 25 | 26 | #include "Ebml_parser.hpp" 27 | #include "stream_io_callback.hpp" 28 | 29 | /***************************************************************************** 30 | * Ebml Stream parser 31 | *****************************************************************************/ 32 | EbmlParser::EbmlParser( EbmlStream *es, EbmlElement *el_start, demux_t *p_demux ) : 33 | p_demux( p_demux ), 34 | m_es( es ), 35 | mi_level( 1 ), 36 | m_got( NULL ), 37 | mi_user_level( 1 ), 38 | mb_keep( false ) 39 | { 40 | mi_remain_size[0] = el_start->GetSize(); 41 | memset( m_el, 0, 6 * sizeof( *m_el ) ); 42 | m_el[0] = el_start; 43 | mb_dummy = var_InheritBool( p_demux, "mkv-use-dummy" ); 44 | } 45 | 46 | EbmlParser::~EbmlParser( void ) 47 | { 48 | if( !mi_level ) 49 | { 50 | assert( !mb_keep ); 51 | delete m_el[1]; 52 | return; 53 | } 54 | 55 | for( int i = 1; i <= mi_level; i++ ) 56 | { 57 | if( !mb_keep ) 58 | { 59 | delete m_el[i]; 60 | } 61 | mb_keep = false; 62 | } 63 | } 64 | 65 | EbmlElement* EbmlParser::UnGet( uint64 i_block_pos, uint64 i_cluster_pos ) 66 | { 67 | if ( mi_user_level > mi_level ) 68 | { 69 | while ( mi_user_level != mi_level ) 70 | { 71 | delete m_el[mi_user_level]; 72 | m_el[mi_user_level] = NULL; 73 | mi_user_level--; 74 | } 75 | } 76 | 77 | /* Avoid data skip in BlockGet */ 78 | delete m_el[mi_level]; 79 | m_el[mi_level] = NULL; 80 | 81 | m_got = NULL; 82 | mb_keep = false; 83 | if ( m_el[1] && m_el[1]->GetElementPosition() == i_cluster_pos ) 84 | { 85 | m_es->I_O().setFilePointer( i_block_pos, seek_beginning ); 86 | return m_el[1]; 87 | } 88 | else 89 | { 90 | // seek to the previous Cluster 91 | m_es->I_O().setFilePointer( i_cluster_pos, seek_beginning ); 92 | while(mi_level > 1) 93 | { 94 | mi_level--; 95 | mi_user_level--; 96 | delete m_el[mi_level]; 97 | m_el[mi_level] = NULL; 98 | } 99 | return NULL; 100 | } 101 | } 102 | 103 | void EbmlParser::Up( void ) 104 | { 105 | if( mi_user_level == mi_level ) 106 | { 107 | msg_Warn( p_demux, "MKV/Ebml Parser: Up cannot escape itself" ); 108 | } 109 | 110 | mi_user_level--; 111 | } 112 | 113 | void EbmlParser::Down( void ) 114 | { 115 | mi_user_level++; 116 | mi_level++; 117 | } 118 | 119 | void EbmlParser::Keep( void ) 120 | { 121 | mb_keep = true; 122 | } 123 | 124 | void EbmlParser::Unkeep() 125 | { 126 | mb_keep = false; 127 | } 128 | 129 | int EbmlParser::GetLevel( void ) const 130 | { 131 | return mi_user_level; 132 | } 133 | 134 | void EbmlParser::Reset( demux_t *p_demux ) 135 | { 136 | while ( mi_level > 0) 137 | { 138 | delete m_el[mi_level]; 139 | m_el[mi_level] = NULL; 140 | mi_level--; 141 | } 142 | this->p_demux = p_demux; 143 | mi_user_level = mi_level = 1; 144 | // a little faster and cleaner 145 | m_es->I_O().setFilePointer( static_cast(m_el[0])->GetGlobalPosition(0) ); 146 | mb_dummy = var_InheritBool( p_demux, "mkv-use-dummy" ); 147 | } 148 | 149 | EbmlElement *EbmlParser::Get( int n_call ) 150 | { 151 | int i_ulev = 0; 152 | EbmlElement *p_prev = NULL; 153 | 154 | if( mi_user_level != mi_level ) 155 | { 156 | return NULL; 157 | } 158 | if( m_got ) 159 | { 160 | EbmlElement *ret = m_got; 161 | m_got = NULL; 162 | 163 | return ret; 164 | } 165 | 166 | p_prev = m_el[mi_level]; 167 | if( m_el[mi_level] ) 168 | { 169 | m_el[mi_level]->SkipData( *m_es, EBML_CONTEXT(m_el[mi_level]) ); 170 | 171 | } 172 | 173 | /* Ignore unknown level 0 or 1 elements */ 174 | m_el[mi_level] = m_es->FindNextElement( EBML_CONTEXT(m_el[mi_level - 1]), 175 | i_ulev, UINT64_MAX, 176 | ( mb_dummy | (mi_level > 1) ), 1 ); 177 | if( i_ulev > 0 ) 178 | { 179 | if( p_prev ) 180 | { 181 | if( !mb_keep ) 182 | { 183 | if( MKV_IS_ID( p_prev, KaxBlockVirtual ) ) 184 | static_cast(p_prev)->Fix(); 185 | delete p_prev; 186 | } 187 | mb_keep = false; 188 | } 189 | while( i_ulev > 0 ) 190 | { 191 | if( mi_level == 1 ) 192 | { 193 | mi_level = 0; 194 | return NULL; 195 | } 196 | 197 | delete m_el[mi_level - 1]; 198 | m_got = m_el[mi_level -1] = m_el[mi_level]; 199 | m_el[mi_level] = NULL; 200 | 201 | mi_level--; 202 | i_ulev--; 203 | } 204 | return NULL; 205 | } 206 | else if( m_el[mi_level] == NULL ) 207 | { 208 | msg_Warn( p_demux,"MKV/Ebml Parser: m_el[mi_level] == NULL\n" ); 209 | } 210 | else if( m_el[mi_level]->IsDummy() && !mb_dummy ) 211 | { 212 | bool b_bad_position = false; 213 | /* We got a dummy element but don't want those... 214 | * perform a sanity check */ 215 | if( !mi_level ) 216 | { 217 | msg_Err(p_demux, "Got invalid lvl 0 element... Aborting"); 218 | return NULL; 219 | } 220 | 221 | if( p_prev && p_prev->IsFiniteSize() && 222 | p_prev->GetEndPosition() != m_el[mi_level]->GetElementPosition() && 223 | mi_level > 1 ) 224 | { 225 | msg_Err( p_demux, "Dummy Element at unexpected position... corrupted file?" ); 226 | b_bad_position = true; 227 | } 228 | 229 | if( n_call < 10 && !b_bad_position && m_el[mi_level]->IsFiniteSize() && 230 | ( !m_el[mi_level-1]->IsFiniteSize() || 231 | m_el[mi_level]->GetEndPosition() <= m_el[mi_level-1]->GetEndPosition() ) ) 232 | { 233 | /* The element fits inside its upper element */ 234 | msg_Warn( p_demux, "Dummy element found %"PRIu64"... skipping it", 235 | m_el[mi_level]->GetElementPosition() ); 236 | return Get( ++n_call ); 237 | } 238 | else 239 | { 240 | /* Too large, misplaced or 10 successive dummy elements */ 241 | msg_Err( p_demux, 242 | "Dummy element too large or misplaced at %"PRIu64"... skipping to next upper element", 243 | m_el[mi_level]->GetElementPosition() ); 244 | 245 | if( mi_level >= 1 && 246 | m_el[mi_level]->GetElementPosition() >= m_el[mi_level-1]->GetEndPosition() ) 247 | { 248 | msg_Err(p_demux, "This element is outside its known parent... upping level"); 249 | delete m_el[mi_level - 1]; 250 | m_got = m_el[mi_level -1] = m_el[mi_level]; 251 | m_el[mi_level] = NULL; 252 | 253 | mi_level--; 254 | return NULL; 255 | } 256 | 257 | delete m_el[mi_level]; 258 | m_el[mi_level] = NULL; 259 | m_el[mi_level - 1]->SkipData( *m_es, EBML_CONTEXT(m_el[mi_level - 1]) ); 260 | return Get(); 261 | } 262 | } 263 | 264 | if( p_prev ) 265 | { 266 | if( !mb_keep ) 267 | { 268 | if( MKV_IS_ID( p_prev, KaxBlockVirtual ) ) 269 | static_cast(p_prev)->Fix(); 270 | delete p_prev; 271 | } 272 | mb_keep = false; 273 | } 274 | return m_el[mi_level]; 275 | } 276 | 277 | bool EbmlParser::IsTopPresent( EbmlElement *el ) const 278 | { 279 | for( int i = 0; i < mi_level; i++ ) 280 | { 281 | if( m_el[i] && m_el[i] == el ) 282 | return true; 283 | } 284 | return false; 285 | } 286 | 287 | -------------------------------------------------------------------------------- /src/demux/mkv/Ebml_parser.hpp: -------------------------------------------------------------------------------- 1 | 2 | /***************************************************************************** 3 | * mkv.cpp : matroska demuxer 4 | ***************************************************************************** 5 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 6 | * $Id: 57fdf232203c2a7db598b88d773555f3563ddecd $ 7 | * 8 | * Authors: Laurent Aimar 9 | * Steve Lhomme 10 | * 11 | * This program is free software; you can redistribute it and/or modify it 12 | * under the terms of the GNU Lesser General Public License as published by 13 | * the Free Software Foundation; either version 2.1 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public License 22 | * along with this program; if not, write to the Free Software Foundation, 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 24 | *****************************************************************************/ 25 | #ifndef _EBML_PARSER_HPP_ 26 | #define _EBML_PARSER_HPP_ 27 | 28 | #include "mkv.hpp" 29 | 30 | /***************************************************************************** 31 | * Ebml Stream parser 32 | *****************************************************************************/ 33 | class EbmlParser 34 | { 35 | public: 36 | EbmlParser( EbmlStream *es, EbmlElement *el_start, demux_t *p_demux ); 37 | ~EbmlParser( void ); 38 | 39 | void Up( void ); 40 | void Down( void ); 41 | void Reset( demux_t *p_demux ); 42 | EbmlElement *Get( int n_call = 0 ); 43 | void Keep( void ); 44 | void Unkeep( void ); 45 | EbmlElement *UnGet( uint64 i_block_pos, uint64 i_cluster_pos ); 46 | 47 | int GetLevel( void ) const; 48 | 49 | /* Is the provided element presents in our upper elements */ 50 | bool IsTopPresent( EbmlElement * ) const; 51 | 52 | private: 53 | demux_t *p_demux; 54 | EbmlStream *m_es; 55 | int mi_level; 56 | EbmlElement *m_el[10]; 57 | int64_t mi_remain_size[10]; 58 | 59 | EbmlElement *m_got; 60 | 61 | int mi_user_level; 62 | bool mb_keep; 63 | bool mb_dummy; 64 | }; 65 | 66 | /* This class works around a bug in KaxBlockVirtual implementation */ 67 | class KaxBlockVirtualWorkaround : public KaxBlockVirtual 68 | { 69 | public: 70 | void Fix() 71 | { 72 | if( GetBuffer() == DataBlock ) 73 | SetBuffer( NULL, 0 ); 74 | } 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/demux/mkv/chapter_command.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * chapter_command.hpp : matroska demuxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 5 | * $Id: 7c8a3c185aaaddc829831035a00d579da763be40 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * 10 | * This program is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | 25 | #ifndef _CHAPTER_COMMAND_H_ 26 | #define _CHAPTER_COMMAND_H_ 27 | 28 | #include "mkv.hpp" 29 | 30 | const binary MATROSKA_DVD_LEVEL_SS = 0x30; 31 | const binary MATROSKA_DVD_LEVEL_LU = 0x2A; 32 | const binary MATROSKA_DVD_LEVEL_TT = 0x28; 33 | const binary MATROSKA_DVD_LEVEL_PGC = 0x20; 34 | const binary MATROSKA_DVD_LEVEL_PG = 0x18; 35 | const binary MATROSKA_DVD_LEVEL_PTT = 0x10; 36 | const binary MATROSKA_DVD_LEVEL_CN = 0x08; 37 | 38 | class demux_sys_t; 39 | 40 | class chapter_codec_cmds_c 41 | { 42 | public: 43 | chapter_codec_cmds_c( demux_sys_t & demuxer, int codec_id = -1) 44 | :p_private_data(NULL) 45 | ,i_codec_id( codec_id ) 46 | ,sys( demuxer ) 47 | {} 48 | 49 | virtual ~chapter_codec_cmds_c() 50 | { 51 | delete p_private_data; 52 | vlc_delete_all( enter_cmds ); 53 | vlc_delete_all( leave_cmds ); 54 | vlc_delete_all( during_cmds ); 55 | } 56 | 57 | void SetPrivate( const KaxChapterProcessPrivate & private_data ) 58 | { 59 | p_private_data = new KaxChapterProcessPrivate( private_data ); 60 | } 61 | 62 | void AddCommand( const KaxChapterProcessCommand & command ); 63 | 64 | /// \return whether the codec has seeked in the files or not 65 | virtual bool Enter() { return false; } 66 | virtual bool Leave() { return false; } 67 | virtual std::string GetCodecName( bool ) const { return ""; } 68 | virtual int16 GetTitleNumber() { return -1; } 69 | 70 | KaxChapterProcessPrivate *p_private_data; 71 | 72 | protected: 73 | std::vector enter_cmds; 74 | std::vector during_cmds; 75 | std::vector leave_cmds; 76 | 77 | int i_codec_id; 78 | demux_sys_t & sys; 79 | }; 80 | 81 | 82 | class dvd_command_interpretor_c 83 | { 84 | public: 85 | dvd_command_interpretor_c( demux_sys_t & demuxer ) 86 | :sys( demuxer ) 87 | { 88 | memset( p_PRMs, 0, sizeof(p_PRMs) ); 89 | p_PRMs[ 0x80 + 1 ] = 15; 90 | p_PRMs[ 0x80 + 2 ] = 62; 91 | p_PRMs[ 0x80 + 3 ] = 1; 92 | p_PRMs[ 0x80 + 4 ] = 1; 93 | p_PRMs[ 0x80 + 7 ] = 1; 94 | p_PRMs[ 0x80 + 8 ] = 1; 95 | p_PRMs[ 0x80 + 16 ] = 0xFFFFu; 96 | p_PRMs[ 0x80 + 18 ] = 0xFFFFu; 97 | } 98 | 99 | bool Interpret( const binary * p_command, size_t i_size = 8 ); 100 | 101 | uint16 GetPRM( size_t index ) const 102 | { 103 | if ( index < 256 ) 104 | return p_PRMs[ index ]; 105 | else return 0; 106 | } 107 | 108 | uint16 GetGPRM( size_t index ) const 109 | { 110 | if ( index < 16 ) 111 | return p_PRMs[ index ]; 112 | else return 0; 113 | } 114 | 115 | uint16 GetSPRM( size_t index ) const 116 | { 117 | // 21,22,23 reserved for future use 118 | if ( index >= 0x80 && index < 0x95 ) 119 | return p_PRMs[ index ]; 120 | else return 0; 121 | } 122 | 123 | bool SetPRM( size_t index, uint16 value ) 124 | { 125 | if ( index < 16 ) 126 | { 127 | p_PRMs[ index ] = value; 128 | return true; 129 | } 130 | return false; 131 | } 132 | 133 | bool SetGPRM( size_t index, uint16 value ) 134 | { 135 | if ( index < 16 ) 136 | { 137 | p_PRMs[ index ] = value; 138 | return true; 139 | } 140 | return false; 141 | } 142 | 143 | bool SetSPRM( size_t index, uint16 value ) 144 | { 145 | if ( index > 0x80 && index <= 0x8D && index != 0x8C ) 146 | { 147 | p_PRMs[ index ] = value; 148 | return true; 149 | } 150 | return false; 151 | } 152 | 153 | protected: 154 | std::string GetRegTypeName( bool b_value, uint16 value ) const 155 | { 156 | std::string result; 157 | char s_value[6], s_reg_value[6]; 158 | sprintf( s_value, "%.5d", value ); 159 | 160 | if ( b_value ) 161 | { 162 | result = "value ("; 163 | result += s_value; 164 | result += ")"; 165 | } 166 | else if ( value < 0x80 ) 167 | { 168 | sprintf( s_reg_value, "%.5d", GetPRM( value ) ); 169 | result = "GPreg["; 170 | result += s_value; 171 | result += "] ("; 172 | result += s_reg_value; 173 | result += ")"; 174 | } 175 | else 176 | { 177 | sprintf( s_reg_value, "%.5d", GetPRM( value ) ); 178 | result = "SPreg["; 179 | result += s_value; 180 | result += "] ("; 181 | result += s_reg_value; 182 | result += ")"; 183 | } 184 | return result; 185 | } 186 | 187 | uint16 p_PRMs[256]; 188 | demux_sys_t & sys; 189 | 190 | // DVD command IDs 191 | 192 | // Tests 193 | // whether it's a comparison on the value or register 194 | static const uint16 CMD_DVD_TEST_VALUE = 0x80; 195 | static const uint16 CMD_DVD_IF_GPREG_AND = (1 << 4); 196 | static const uint16 CMD_DVD_IF_GPREG_EQUAL = (2 << 4); 197 | static const uint16 CMD_DVD_IF_GPREG_NOT_EQUAL = (3 << 4); 198 | static const uint16 CMD_DVD_IF_GPREG_SUP_EQUAL = (4 << 4); 199 | static const uint16 CMD_DVD_IF_GPREG_SUP = (5 << 4); 200 | static const uint16 CMD_DVD_IF_GPREG_INF_EQUAL = (6 << 4); 201 | static const uint16 CMD_DVD_IF_GPREG_INF = (7 << 4); 202 | 203 | static const uint16 CMD_DVD_NOP = 0x0000; 204 | static const uint16 CMD_DVD_GOTO_LINE = 0x0001; 205 | static const uint16 CMD_DVD_BREAK = 0x0002; 206 | // Links 207 | static const uint16 CMD_DVD_NOP2 = 0x2001; 208 | static const uint16 CMD_DVD_LINKPGCN = 0x2004; 209 | static const uint16 CMD_DVD_LINKPGN = 0x2006; 210 | static const uint16 CMD_DVD_LINKCN = 0x2007; 211 | static const uint16 CMD_DVD_JUMP_TT = 0x3002; 212 | static const uint16 CMD_DVD_JUMPVTS_TT = 0x3003; 213 | static const uint16 CMD_DVD_JUMPVTS_PTT = 0x3005; 214 | static const uint16 CMD_DVD_JUMP_SS = 0x3006; 215 | static const uint16 CMD_DVD_CALLSS_VTSM1 = 0x3008; 216 | // 217 | static const uint16 CMD_DVD_SET_HL_BTNN2 = 0x4600; 218 | static const uint16 CMD_DVD_SET_HL_BTNN_LINKPGCN1 = 0x4604; 219 | static const uint16 CMD_DVD_SET_STREAM = 0x5100; 220 | static const uint16 CMD_DVD_SET_GPRMMD = 0x5300; 221 | static const uint16 CMD_DVD_SET_HL_BTNN1 = 0x5600; 222 | static const uint16 CMD_DVD_SET_HL_BTNN_LINKPGCN2 = 0x5604; 223 | static const uint16 CMD_DVD_SET_HL_BTNN_LINKCN = 0x5607; 224 | // Operations 225 | static const uint16 CMD_DVD_MOV_SPREG_PREG = 0x6100; 226 | static const uint16 CMD_DVD_GPREG_MOV_VALUE = 0x7100; 227 | static const uint16 CMD_DVD_SUB_GPREG = 0x7400; 228 | static const uint16 CMD_DVD_MULT_GPREG = 0x7500; 229 | static const uint16 CMD_DVD_GPREG_DIV_VALUE = 0x7600; 230 | static const uint16 CMD_DVD_GPREG_AND_VALUE = 0x7900; 231 | 232 | // callbacks when browsing inside CodecPrivate 233 | static bool MatchIsDomain ( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ); 234 | static bool MatchIsVMG ( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ); 235 | static bool MatchVTSNumber ( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ); 236 | static bool MatchVTSMNumber ( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ); 237 | static bool MatchTitleNumber ( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ); 238 | static bool MatchPgcType ( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ); 239 | static bool MatchPgcNumber ( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ); 240 | static bool MatchChapterNumber( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ); 241 | static bool MatchCellNumber ( const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ); 242 | }; 243 | 244 | 245 | #include "demux.hpp" 246 | 247 | class dvd_chapter_codec_c : public chapter_codec_cmds_c 248 | { 249 | public: 250 | dvd_chapter_codec_c( demux_sys_t & sys ) 251 | :chapter_codec_cmds_c( sys, 1 ) 252 | {} 253 | 254 | bool Enter(); 255 | bool Leave(); 256 | std::string GetCodecName( bool f_for_title = false ) const; 257 | int16 GetTitleNumber(); 258 | }; 259 | 260 | class matroska_script_interpretor_c 261 | { 262 | public: 263 | matroska_script_interpretor_c( demux_sys_t & demuxer ) 264 | :sys( demuxer ) 265 | {} 266 | 267 | bool Interpret( const binary * p_command, size_t i_size ); 268 | 269 | // DVD command IDs 270 | static const std::string CMD_MS_GOTO_AND_PLAY; 271 | 272 | protected: 273 | demux_sys_t & sys; 274 | }; 275 | 276 | 277 | class matroska_script_codec_c : public chapter_codec_cmds_c 278 | { 279 | public: 280 | matroska_script_codec_c( demux_sys_t & sys ) 281 | :chapter_codec_cmds_c( sys, 0 ) 282 | ,interpretor( sys ) 283 | {} 284 | 285 | bool Enter(); 286 | bool Leave(); 287 | 288 | protected: 289 | matroska_script_interpretor_c interpretor; 290 | }; 291 | 292 | 293 | #endif 294 | -------------------------------------------------------------------------------- /src/demux/mkv/chapters.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * chapters.cpp : matroska demuxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 5 | * $Id: b8dab0c7d6021502cae873097c36f6381b86e254 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * 10 | * This program is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | 25 | #include "chapters.hpp" 26 | 27 | #include "chapter_command.hpp" 28 | 29 | chapter_item_c::~chapter_item_c() 30 | { 31 | if( p_segment_uid ) 32 | delete p_segment_uid; 33 | if( p_segment_edition_uid ) 34 | delete p_segment_edition_uid; 35 | vlc_delete_all( codecs ); 36 | vlc_delete_all( sub_chapters ); 37 | } 38 | 39 | chapter_item_c *chapter_item_c::BrowseCodecPrivate( unsigned int codec_id, 40 | bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ), 41 | const void *p_cookie, 42 | size_t i_cookie_size ) 43 | { 44 | VLC_UNUSED( codec_id ); 45 | // this chapter 46 | std::vector::const_iterator index = codecs.begin(); 47 | while ( index != codecs.end() ) 48 | { 49 | if ( match( **index ,p_cookie, i_cookie_size ) ) 50 | return this; 51 | ++index; 52 | } 53 | return NULL; 54 | } 55 | 56 | void chapter_item_c::Append( const chapter_item_c & chapter ) 57 | { 58 | // we are appending content for the same chapter UID 59 | size_t i; 60 | chapter_item_c *p_chapter; 61 | 62 | for ( i=0; ii_uid ); 65 | if ( p_chapter != NULL ) 66 | { 67 | p_chapter->Append( *chapter.sub_chapters[i] ); 68 | } 69 | else 70 | { 71 | sub_chapters.push_back( chapter.sub_chapters[i] ); 72 | } 73 | } 74 | } 75 | 76 | chapter_item_c * chapter_item_c::FindChapter( int64_t i_find_uid ) 77 | { 78 | size_t i; 79 | chapter_item_c *p_result = NULL; 80 | 81 | if ( i_uid == i_find_uid ) 82 | return this; 83 | 84 | for ( i=0; iFindChapter( i_find_uid ); 87 | if ( p_result != NULL ) 88 | break; 89 | } 90 | return p_result; 91 | } 92 | 93 | std::string chapter_item_c::GetCodecName( bool f_for_title ) const 94 | { 95 | std::string result; 96 | 97 | std::vector::const_iterator index = codecs.begin(); 98 | while ( index != codecs.end() ) 99 | { 100 | result = (*index)->GetCodecName( f_for_title ); 101 | if ( result != "" ) 102 | break; 103 | ++index; 104 | } 105 | 106 | return result; 107 | } 108 | 109 | int16 chapter_item_c::GetTitleNumber( ) const 110 | { 111 | int result = -1; 112 | 113 | std::vector::const_iterator index = codecs.begin(); 114 | while ( index != codecs.end() ) 115 | { 116 | result = (*index)->GetTitleNumber( ); 117 | if ( result >= 0 ) 118 | break; 119 | ++index; 120 | } 121 | 122 | return result; 123 | } 124 | 125 | bool chapter_item_c::ParentOf( const chapter_item_c & item ) const 126 | { 127 | if ( &item == this ) 128 | return true; 129 | 130 | std::vector::const_iterator index = sub_chapters.begin(); 131 | while ( index != sub_chapters.end() ) 132 | { 133 | if ( (*index)->ParentOf( item ) ) 134 | return true; 135 | ++index; 136 | } 137 | 138 | return false; 139 | } 140 | 141 | bool chapter_item_c::Enter( bool b_do_subs ) 142 | { 143 | bool f_result = false; 144 | std::vector::iterator index = codecs.begin(); 145 | while ( index != codecs.end() ) 146 | { 147 | f_result |= (*index)->Enter(); 148 | ++index; 149 | } 150 | 151 | if ( b_do_subs ) 152 | { 153 | // sub chapters 154 | std::vector::iterator index_ = sub_chapters.begin(); 155 | while ( index_ != sub_chapters.end() ) 156 | { 157 | f_result |= (*index_)->Enter( true ); 158 | ++index_; 159 | } 160 | } 161 | return f_result; 162 | } 163 | 164 | bool chapter_item_c::Leave( bool b_do_subs ) 165 | { 166 | bool f_result = false; 167 | b_is_leaving = true; 168 | std::vector::iterator index = codecs.begin(); 169 | while ( index != codecs.end() ) 170 | { 171 | f_result |= (*index)->Leave(); 172 | ++index; 173 | } 174 | 175 | if ( b_do_subs ) 176 | { 177 | // sub chapters 178 | std::vector::iterator index_ = sub_chapters.begin(); 179 | while ( index_ != sub_chapters.end() ) 180 | { 181 | f_result |= (*index_)->Leave( true ); 182 | ++index_; 183 | } 184 | } 185 | b_is_leaving = false; 186 | return f_result; 187 | } 188 | 189 | bool chapter_item_c::EnterAndLeave( chapter_item_c *p_item, bool b_final_enter ) 190 | { 191 | chapter_item_c *p_common_parent = p_item; 192 | 193 | // leave, up to a common parent 194 | while ( p_common_parent != NULL && !p_common_parent->ParentOf( *this ) ) 195 | { 196 | if ( !p_common_parent->b_is_leaving && p_common_parent->Leave( false ) ) 197 | return true; 198 | p_common_parent = p_common_parent->p_parent; 199 | } 200 | 201 | // enter from the parent to 202 | if ( p_common_parent != NULL ) 203 | { 204 | do 205 | { 206 | if ( p_common_parent == this ) 207 | return Enter( true ); 208 | 209 | for ( size_t i = 0; isub_chapters.size(); i++ ) 210 | { 211 | if ( p_common_parent->sub_chapters[i]->ParentOf( *this ) ) 212 | { 213 | p_common_parent = p_common_parent->sub_chapters[i]; 214 | if ( p_common_parent != this ) 215 | if ( p_common_parent->Enter( false ) ) 216 | return true; 217 | 218 | break; 219 | } 220 | } 221 | } while ( 1 ); 222 | } 223 | 224 | if ( b_final_enter ) 225 | return Enter( true ); 226 | else 227 | return false; 228 | } 229 | 230 | 231 | 232 | /* Chapter Edition Class */ 233 | std::string chapter_edition_c::GetMainName() const 234 | { 235 | if ( sub_chapters.size() ) 236 | { 237 | return sub_chapters[0]->GetCodecName( true ); 238 | } 239 | return ""; 240 | } 241 | 242 | -------------------------------------------------------------------------------- /src/demux/mkv/chapters.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * chapters.hpp : matroska demuxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 5 | * $Id: 8d0e592be1d119e440f9dda3a6a6d5833cb79472 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * 10 | * This program is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | 25 | /* chapter_item, chapter_edition, and chapter_translation classes */ 26 | 27 | #ifndef _CHAPTER_H_ 28 | #define _CHAPTER_H_ 29 | 30 | #include "mkv.hpp" 31 | 32 | class chapter_translation_c 33 | { 34 | public: 35 | chapter_translation_c() 36 | :p_translated(NULL) 37 | {} 38 | 39 | ~chapter_translation_c() 40 | { 41 | delete p_translated; 42 | } 43 | 44 | KaxChapterTranslateID *p_translated; 45 | unsigned int codec_id; 46 | std::vector editions; 47 | }; 48 | 49 | class chapter_codec_cmds_c; 50 | class chapter_item_c 51 | { 52 | public: 53 | chapter_item_c() 54 | :i_start_time(0) 55 | ,i_end_time(-1) 56 | ,p_segment_uid(NULL) 57 | ,p_segment_edition_uid(NULL) 58 | ,b_display_seekpoint(true) 59 | ,b_user_display(false) 60 | ,p_parent(NULL) 61 | ,b_is_leaving(false) 62 | {} 63 | 64 | virtual ~chapter_item_c(); 65 | void Append( const chapter_item_c & edition ); 66 | chapter_item_c * FindChapter( int64_t i_find_uid ); 67 | virtual chapter_item_c *BrowseCodecPrivate( unsigned int codec_id, 68 | bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ), 69 | const void *p_cookie, 70 | size_t i_cookie_size ); 71 | std::string GetCodecName( bool f_for_title = false ) const; 72 | bool ParentOf( const chapter_item_c & item ) const; 73 | int16 GetTitleNumber( ) const; 74 | 75 | int64_t i_start_time, i_end_time; 76 | std::vector sub_chapters; 77 | KaxChapterSegmentUID *p_segment_uid; 78 | KaxChapterSegmentEditionUID *p_segment_edition_uid; 79 | int64_t i_uid; 80 | bool b_display_seekpoint; 81 | bool b_user_display; 82 | std::string psz_name; 83 | chapter_item_c *p_parent; 84 | bool b_is_leaving; 85 | 86 | std::vector codecs; 87 | 88 | bool Enter( bool b_do_subchapters ); 89 | bool Leave( bool b_do_subchapters ); 90 | bool EnterAndLeave( chapter_item_c *p_item, bool b_enter = true ); 91 | }; 92 | 93 | class chapter_edition_c : public chapter_item_c 94 | { 95 | public: 96 | chapter_edition_c(): b_ordered(false), b_default(false), b_hidden(false) 97 | {} 98 | 99 | std::string GetMainName() const; 100 | bool b_ordered; 101 | bool b_default; 102 | /* TODO handle hidden chapters */ 103 | bool b_hidden; 104 | }; 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /src/demux/mkv/demux.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * demux.hpp : matroska demuxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 5 | * $Id: c295f13d13d07292a49724fe7257dacfc486f6d2 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * 10 | * This program is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | 25 | #ifndef _DEMUX_SYS_H 26 | #define _DEMUX_SYS_H 27 | 28 | #include "mkv.hpp" 29 | 30 | #include "chapter_command.hpp" 31 | #include "virtual_segment.hpp" 32 | 33 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 34 | #undef ATTRIBUTE_PACKED 35 | #undef PRAGMA_PACK_BEGIN 36 | #undef PRAGMA_PACK_END 37 | 38 | #if defined(__GNUC__) 39 | #define ATTRIBUTE_PACKED __attribute__ ((packed)) 40 | #define PRAGMA_PACK 0 41 | #endif 42 | 43 | #if !defined(ATTRIBUTE_PACKED) 44 | #define ATTRIBUTE_PACKED 45 | #define PRAGMA_PACK 1 46 | #endif 47 | 48 | #if PRAGMA_PACK 49 | #pragma pack(1) 50 | #endif 51 | 52 | /************************************* 53 | * taken from libdvdnav / libdvdread 54 | **************************************/ 55 | 56 | /** 57 | * DVD Time Information. 58 | */ 59 | typedef struct { 60 | uint8_t hour; 61 | uint8_t minute; 62 | uint8_t second; 63 | uint8_t frame_u; /* The two high bits are the frame rate. */ 64 | } ATTRIBUTE_PACKED dvd_time_t; 65 | 66 | /** 67 | * User Operations. 68 | */ 69 | typedef struct { 70 | #ifdef WORDS_BIGENDIAN 71 | unsigned char zero : 7; /* 25-31 */ 72 | unsigned char video_pres_mode_change : 1; /* 24 */ 73 | 74 | unsigned char karaoke_audio_pres_mode_change : 1; /* 23 */ 75 | unsigned char angle_change : 1; 76 | unsigned char subpic_stream_change : 1; 77 | unsigned char audio_stream_change : 1; 78 | unsigned char pause_on : 1; 79 | unsigned char still_off : 1; 80 | unsigned char button_select_or_activate : 1; 81 | unsigned char resume : 1; /* 16 */ 82 | 83 | unsigned char chapter_menu_call : 1; /* 15 */ 84 | unsigned char angle_menu_call : 1; 85 | unsigned char audio_menu_call : 1; 86 | unsigned char subpic_menu_call : 1; 87 | unsigned char root_menu_call : 1; 88 | unsigned char title_menu_call : 1; 89 | unsigned char backward_scan : 1; 90 | unsigned char forward_scan : 1; /* 8 */ 91 | 92 | unsigned char next_pg_search : 1; /* 7 */ 93 | unsigned char prev_or_top_pg_search : 1; 94 | unsigned char time_or_chapter_search : 1; 95 | unsigned char go_up : 1; 96 | unsigned char stop : 1; 97 | unsigned char title_play : 1; 98 | unsigned char chapter_search_or_play : 1; 99 | unsigned char title_or_time_play : 1; /* 0 */ 100 | #else 101 | unsigned char video_pres_mode_change : 1; /* 24 */ 102 | unsigned char zero : 7; /* 25-31 */ 103 | 104 | unsigned char resume : 1; /* 16 */ 105 | unsigned char button_select_or_activate : 1; 106 | unsigned char still_off : 1; 107 | unsigned char pause_on : 1; 108 | unsigned char audio_stream_change : 1; 109 | unsigned char subpic_stream_change : 1; 110 | unsigned char angle_change : 1; 111 | unsigned char karaoke_audio_pres_mode_change : 1; /* 23 */ 112 | 113 | unsigned char forward_scan : 1; /* 8 */ 114 | unsigned char backward_scan : 1; 115 | unsigned char title_menu_call : 1; 116 | unsigned char root_menu_call : 1; 117 | unsigned char subpic_menu_call : 1; 118 | unsigned char audio_menu_call : 1; 119 | unsigned char angle_menu_call : 1; 120 | unsigned char chapter_menu_call : 1; /* 15 */ 121 | 122 | unsigned char title_or_time_play : 1; /* 0 */ 123 | unsigned char chapter_search_or_play : 1; 124 | unsigned char title_play : 1; 125 | unsigned char stop : 1; 126 | unsigned char go_up : 1; 127 | unsigned char time_or_chapter_search : 1; 128 | unsigned char prev_or_top_pg_search : 1; 129 | unsigned char next_pg_search : 1; /* 7 */ 130 | #endif 131 | } ATTRIBUTE_PACKED user_ops_t; 132 | 133 | /** 134 | * Type to store per-command data. 135 | */ 136 | typedef struct { 137 | uint8_t bytes[8]; 138 | } ATTRIBUTE_PACKED vm_cmd_t; 139 | #define COMMAND_DATA_SIZE 8 140 | 141 | /** 142 | * PCI General Information 143 | */ 144 | typedef struct { 145 | uint32_t nv_pck_lbn; /**< sector address of this nav pack */ 146 | uint16_t vobu_cat; /**< 'category' of vobu */ 147 | uint16_t zero1; /**< reserved */ 148 | user_ops_t vobu_uop_ctl; /**< UOP of vobu */ 149 | uint32_t vobu_s_ptm; /**< start presentation time of vobu */ 150 | uint32_t vobu_e_ptm; /**< end presentation time of vobu */ 151 | uint32_t vobu_se_e_ptm; /**< end ptm of sequence end in vobu */ 152 | dvd_time_t e_eltm; /**< Cell elapsed time */ 153 | char vobu_isrc[32]; 154 | } ATTRIBUTE_PACKED pci_gi_t; 155 | 156 | /** 157 | * Non Seamless Angle Information 158 | */ 159 | typedef struct { 160 | uint32_t nsml_agl_dsta[9]; /**< address of destination vobu in AGL_C#n */ 161 | } ATTRIBUTE_PACKED nsml_agli_t; 162 | 163 | /** 164 | * Highlight General Information 165 | * 166 | * For btngrX_dsp_ty the bits have the following meaning: 167 | * 000b: normal 4/3 only buttons 168 | * XX1b: wide (16/9) buttons 169 | * X1Xb: letterbox buttons 170 | * 1XXb: pan&scan buttons 171 | */ 172 | typedef struct { 173 | uint16_t hli_ss; /**< status, only low 2 bits 0: no buttons, 1: different 2: equal 3: eual except for button cmds */ 174 | uint32_t hli_s_ptm; /**< start ptm of hli */ 175 | uint32_t hli_e_ptm; /**< end ptm of hli */ 176 | uint32_t btn_se_e_ptm; /**< end ptm of button select */ 177 | #ifdef WORDS_BIGENDIAN 178 | unsigned char zero1 : 2; /**< reserved */ 179 | unsigned char btngr_ns : 2; /**< number of button groups 1, 2 or 3 with 36/18/12 buttons */ 180 | unsigned char zero2 : 1; /**< reserved */ 181 | unsigned char btngr1_dsp_ty : 3; /**< display type of subpic stream for button group 1 */ 182 | unsigned char zero3 : 1; /**< reserved */ 183 | unsigned char btngr2_dsp_ty : 3; /**< display type of subpic stream for button group 2 */ 184 | unsigned char zero4 : 1; /**< reserved */ 185 | unsigned char btngr3_dsp_ty : 3; /**< display type of subpic stream for button group 3 */ 186 | #else 187 | unsigned char btngr1_dsp_ty : 3; 188 | unsigned char zero2 : 1; 189 | unsigned char btngr_ns : 2; 190 | unsigned char zero1 : 2; 191 | unsigned char btngr3_dsp_ty : 3; 192 | unsigned char zero4 : 1; 193 | unsigned char btngr2_dsp_ty : 3; 194 | unsigned char zero3 : 1; 195 | #endif 196 | uint8_t btn_ofn; /**< button offset number range 0-255 */ 197 | uint8_t btn_ns; /**< number of valid buttons <= 36/18/12 (low 6 bits) */ 198 | uint8_t nsl_btn_ns; /**< number of buttons selectable by U_BTNNi (low 6 bits) nsl_btn_ns <= btn_ns */ 199 | uint8_t zero5; /**< reserved */ 200 | uint8_t fosl_btnn; /**< forcedly selected button (low 6 bits) */ 201 | uint8_t foac_btnn; /**< forcedly activated button (low 6 bits) */ 202 | } ATTRIBUTE_PACKED hl_gi_t; 203 | 204 | 205 | /** 206 | * Button Color Information Table 207 | * Each entry beeing a 32bit word that contains the color indexs and alpha 208 | * values to use. They are all represented by 4 bit number and stored 209 | * like this [Ci3, Ci2, Ci1, Ci0, A3, A2, A1, A0]. The actual palette 210 | * that the indexes reference is in the PGC. 211 | * \todo split the uint32_t into a struct 212 | */ 213 | typedef struct { 214 | uint32_t btn_coli[3][2]; /**< [button color number-1][select:0/action:1] */ 215 | } ATTRIBUTE_PACKED btn_colit_t; 216 | 217 | /** 218 | * Button Information 219 | * 220 | * NOTE: I've had to change the structure from the disk layout to get 221 | * the packing to work with Sun's Forte C compiler. 222 | * The 4 and 7 bytes are 'rotated' was: ABC DEF GHIJ is: ABCG DEFH IJ 223 | */ 224 | typedef struct { 225 | #ifdef WORDS_BIGENDIAN 226 | uint32 btn_coln : 2; /**< button color number */ 227 | uint32 x_start : 10; /**< x start offset within the overlay */ 228 | uint32 zero1 : 2; /**< reserved */ 229 | uint32 x_end : 10; /**< x end offset within the overlay */ 230 | 231 | uint32 zero3 : 2; /**< reserved */ 232 | uint32 up : 6; /**< button index when pressing up */ 233 | 234 | uint32 auto_action_mode : 2; /**< 0: no, 1: activated if selected */ 235 | uint32 y_start : 10; /**< y start offset within the overlay */ 236 | uint32 zero2 : 2; /**< reserved */ 237 | uint32 y_end : 10; /**< y end offset within the overlay */ 238 | 239 | uint32 zero4 : 2; /**< reserved */ 240 | uint32 down : 6; /**< button index when pressing down */ 241 | unsigned char zero5 : 2; /**< reserved */ 242 | unsigned char left : 6; /**< button index when pressing left */ 243 | unsigned char zero6 : 2; /**< reserved */ 244 | unsigned char right : 6; /**< button index when pressing right */ 245 | #else 246 | uint32 x_end : 10; 247 | uint32 zero1 : 2; 248 | uint32 x_start : 10; 249 | uint32 btn_coln : 2; 250 | 251 | uint32 up : 6; 252 | uint32 zero3 : 2; 253 | 254 | uint32 y_end : 10; 255 | uint32 zero2 : 2; 256 | uint32 y_start : 10; 257 | uint32 auto_action_mode : 2; 258 | 259 | uint32 down : 6; 260 | uint32 zero4 : 2; 261 | unsigned char left : 6; 262 | unsigned char zero5 : 2; 263 | unsigned char right : 6; 264 | unsigned char zero6 : 2; 265 | #endif 266 | vm_cmd_t cmd; 267 | } ATTRIBUTE_PACKED btni_t; 268 | 269 | /** 270 | * Highlight Information 271 | */ 272 | typedef struct { 273 | hl_gi_t hl_gi; 274 | btn_colit_t btn_colit; 275 | btni_t btnit[36]; 276 | } ATTRIBUTE_PACKED hli_t; 277 | 278 | /** 279 | * PCI packet 280 | */ 281 | typedef struct { 282 | pci_gi_t pci_gi; 283 | nsml_agli_t nsml_agli; 284 | hli_t hli; 285 | uint8_t zero1[189]; 286 | } ATTRIBUTE_PACKED pci_t; 287 | 288 | #if PRAGMA_PACK 289 | #pragma pack() 290 | #endif 291 | //////////////////////////////////////// 292 | 293 | class virtual_segment_c; 294 | class chapter_item_c; 295 | 296 | class event_thread_t 297 | { 298 | public: 299 | event_thread_t(demux_t *); 300 | virtual ~event_thread_t(); 301 | 302 | void SetPci(const pci_t *data); 303 | void ResetPci(); 304 | 305 | private: 306 | void EventThread(); 307 | static void *EventThread(void *); 308 | 309 | static int EventMouse( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * ); 310 | static int EventKey( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * ); 311 | static int EventInput( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * ); 312 | 313 | demux_t *p_demux; 314 | 315 | bool is_running; 316 | vlc_thread_t thread; 317 | 318 | vlc_mutex_t lock; 319 | vlc_cond_t wait; 320 | bool b_abort; 321 | bool b_moved; 322 | bool b_clicked; 323 | int i_key_action; 324 | bool b_vout; 325 | pci_t pci_packet; 326 | }; 327 | 328 | 329 | class demux_sys_t 330 | { 331 | public: 332 | demux_sys_t( demux_t & demux ) 333 | :demuxer(demux) 334 | ,i_pts(0) 335 | ,i_pcr(0) 336 | ,i_start_pts(0) 337 | ,i_chapter_time(0) 338 | ,meta(NULL) 339 | ,i_current_title(0) 340 | ,p_current_segment(NULL) 341 | ,dvd_interpretor( *this ) 342 | ,f_duration(-1.0) 343 | ,p_input(NULL) 344 | ,p_ev(NULL) 345 | { 346 | vlc_mutex_init( &lock_demuxer ); 347 | } 348 | 349 | virtual ~demux_sys_t(); 350 | 351 | /* current data */ 352 | demux_t & demuxer; 353 | 354 | mtime_t i_pts; 355 | mtime_t i_pcr; 356 | mtime_t i_start_pts; 357 | mtime_t i_chapter_time; 358 | 359 | vlc_meta_t *meta; 360 | 361 | std::vector titles; // matroska editions 362 | size_t i_current_title; 363 | 364 | std::vector streams; 365 | std::vector stored_attachments; 366 | std::vector opened_segments; 367 | std::vector used_segments; 368 | virtual_segment_c *p_current_segment; 369 | 370 | dvd_command_interpretor_c dvd_interpretor; 371 | 372 | /* duration of the stream */ 373 | float f_duration; 374 | 375 | matroska_segment_c *FindSegment( const EbmlBinary & uid ) const; 376 | virtual_chapter_c *BrowseCodecPrivate( unsigned int codec_id, 377 | bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ), 378 | const void *p_cookie, 379 | size_t i_cookie_size, 380 | virtual_segment_c * & p_segment_found ); 381 | virtual_chapter_c *FindChapter( int64_t i_find_uid, virtual_segment_c * & p_segment_found ); 382 | 383 | void PreloadFamily( const matroska_segment_c & of_segment ); 384 | bool PreloadLinked(); 385 | void FreeUnused(); 386 | bool PreparePlayback( virtual_segment_c *p_new_segment ); 387 | matroska_stream_c *AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial = false ); 388 | void JumpTo( virtual_segment_c & p_segment, virtual_chapter_c * p_chapter ); 389 | 390 | void InitUi(); 391 | void CleanUi(); 392 | 393 | /* for spu variables */ 394 | input_thread_t *p_input; 395 | uint8_t palette[4][4]; 396 | vlc_mutex_t lock_demuxer; 397 | 398 | /* event */ 399 | event_thread_t *p_ev; 400 | 401 | protected: 402 | virtual_segment_c *VirtualFromSegments( std::vector *p_segments ) const; 403 | }; 404 | 405 | 406 | #endif 407 | -------------------------------------------------------------------------------- /src/demux/mkv/matroska_segment.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * matroska_segment.hpp : matroska demuxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 5 | * $Id: afb37dbc9f274e53e438de3c15441d8466c0e6b2 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * 10 | * This program is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | 25 | #ifndef _MATROSKA_SEGMENT_HPP_ 26 | #define _MATROSKA_SEGMENT_HPP_ 27 | 28 | #include "mkv.hpp" 29 | 30 | class EbmlParser; 31 | 32 | class chapter_edition_c; 33 | class chapter_translation_c; 34 | class chapter_item_c; 35 | 36 | struct mkv_track_t; 37 | struct mkv_index_t; 38 | 39 | typedef enum 40 | { 41 | WHOLE_SEGMENT, 42 | TRACK_UID, 43 | EDITION_UID, 44 | CHAPTER_UID, 45 | ATTACHMENT_UID 46 | } tag_target_type; 47 | 48 | class SimpleTag 49 | { 50 | public: 51 | SimpleTag(): 52 | psz_tag_name(NULL), psz_lang(NULL), b_default(true), p_value(NULL){} 53 | ~SimpleTag(); 54 | char *psz_tag_name; 55 | char *psz_lang; /* NULL value means "undf" */ 56 | bool b_default; 57 | char * p_value; 58 | std::vector sub_tags; 59 | }; 60 | 61 | class Tag 62 | { 63 | public: 64 | Tag():i_tag_type(WHOLE_SEGMENT),i_target_type(50),i_uid(0){} 65 | ~Tag(); 66 | tag_target_type i_tag_type; 67 | uint64_t i_target_type; 68 | uint64_t i_uid; 69 | std::vector simple_tags; 70 | }; 71 | 72 | class matroska_segment_c 73 | { 74 | public: 75 | matroska_segment_c( demux_sys_t & demuxer, EbmlStream & estream ); 76 | virtual ~matroska_segment_c(); 77 | 78 | KaxSegment *segment; 79 | EbmlStream & es; 80 | 81 | /* time scale */ 82 | uint64_t i_timescale; 83 | 84 | /* duration of the segment */ 85 | mtime_t i_duration; 86 | mtime_t i_start_time; 87 | 88 | /* all tracks */ 89 | std::vector tracks; 90 | 91 | /* from seekhead */ 92 | int i_seekhead_count; 93 | int64_t i_seekhead_position; 94 | int64_t i_cues_position; 95 | int64_t i_tracks_position; 96 | int64_t i_info_position; 97 | int64_t i_chapters_position; 98 | int64_t i_tags_position; 99 | int64_t i_attachments_position; 100 | 101 | KaxCluster *cluster; 102 | uint64 i_block_pos; 103 | uint64 i_cluster_pos; 104 | int64_t i_start_pos; 105 | KaxSegmentUID *p_segment_uid; 106 | KaxPrevUID *p_prev_segment_uid; 107 | KaxNextUID *p_next_segment_uid; 108 | 109 | bool b_cues; 110 | int i_index; 111 | int i_index_max; 112 | mkv_index_t *p_indexes; 113 | 114 | /* info */ 115 | char *psz_muxing_application; 116 | char *psz_writing_application; 117 | char *psz_segment_filename; 118 | char *psz_title; 119 | char *psz_date_utc; 120 | 121 | /* !!!!! GCC 3.3 bug on Darwin !!!!! */ 122 | /* when you remove this variable the compiler issues an atomicity error */ 123 | /* this variable only works when using std::vector */ 124 | std::vector stored_editions; 125 | int i_default_edition; 126 | 127 | std::vector translations; 128 | std::vector families; 129 | std::vector tags; 130 | 131 | demux_sys_t & sys; 132 | EbmlParser *ep; 133 | bool b_preloaded; 134 | bool b_ref_external_segments; 135 | 136 | bool Preload(); 137 | bool PreloadFamily( const matroska_segment_c & segment ); 138 | void InformationCreate(); 139 | void Seek( mtime_t i_date, mtime_t i_time_offset, int64_t i_global_position ); 140 | int BlockGet( KaxBlock * &, KaxSimpleBlock * &, bool *, bool *, int64_t *); 141 | 142 | int BlockFindTrackIndex( size_t *pi_track, 143 | const KaxBlock *, const KaxSimpleBlock * ); 144 | 145 | bool Select( mtime_t i_start_time ); 146 | void UnSelect(); 147 | 148 | static bool CompareSegmentUIDs( const matroska_segment_c * item_a, const matroska_segment_c * item_b ); 149 | 150 | private: 151 | void LoadCues( KaxCues *cues ); 152 | void LoadTags( KaxTags *tags ); 153 | bool LoadSeekHeadItem( const EbmlCallbacks & ClassInfos, int64_t i_element_position ); 154 | void ParseInfo( KaxInfo *info ); 155 | void ParseAttachments( KaxAttachments *attachments ); 156 | void ParseChapters( KaxChapters *chapters ); 157 | void ParseSeekHead( KaxSeekHead *seekhead ); 158 | void ParseTracks( KaxTracks *tracks ); 159 | void ParseChapterAtom( int i_level, KaxChapterAtom *ca, chapter_item_c & chapters ); 160 | void ParseTrackEntry( KaxTrackEntry *m ); 161 | void ParseCluster( bool b_update_start_time = true ); 162 | SimpleTag * ParseSimpleTags( KaxTagSimple *tag, int level = 50 ); 163 | void IndexAppendCluster( KaxCluster *cluster ); 164 | int32_t TrackInit( mkv_track_t * p_tk ); 165 | void ComputeTrackPriority(); 166 | }; 167 | 168 | 169 | #endif 170 | -------------------------------------------------------------------------------- /src/demux/mkv/mkv.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * mkv.hpp : matroska demuxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2005, 2008 VLC authors and VideoLAN 5 | * $Id: efc88b3c2fef23ac529fc190ef26fc0b404441e2 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * 10 | * This program is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | 25 | #ifndef _MKV_H_ 26 | #define _MKV_H_ 27 | 28 | /***************************************************************************** 29 | * Preamble 30 | *****************************************************************************/ 31 | 32 | 33 | /* config.h may include inttypes.h, so make sure we define that option 34 | * early enough. */ 35 | #define __STDC_FORMAT_MACROS 1 36 | #define __STDC_CONSTANT_MACROS 1 37 | #define __STDC_LIMIT_MACROS 1 38 | 39 | #ifdef HAVE_CONFIG_H 40 | # include "config.h" 41 | #endif 42 | 43 | #include 44 | 45 | #include 46 | #include 47 | 48 | #ifdef HAVE_TIME_H 49 | # include /* time() */ 50 | #endif 51 | 52 | #include 53 | #include 54 | #include 55 | #include 56 | 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | 64 | /* libebml and matroska */ 65 | #include "ebml/EbmlHead.h" 66 | #include "ebml/EbmlSubHead.h" 67 | #include "ebml/EbmlStream.h" 68 | #include "ebml/EbmlContexts.h" 69 | #include "ebml/EbmlVoid.h" 70 | #include "ebml/EbmlVersion.h" 71 | #include "ebml/StdIOCallback.h" 72 | 73 | #include "matroska/KaxAttachments.h" 74 | #include "matroska/KaxAttached.h" 75 | #include "matroska/KaxBlock.h" 76 | #include "matroska/KaxBlockData.h" 77 | #include "matroska/KaxChapters.h" 78 | #include "matroska/KaxCluster.h" 79 | #include "matroska/KaxClusterData.h" 80 | #include "matroska/KaxContexts.h" 81 | #include "matroska/KaxCues.h" 82 | #include "matroska/KaxCuesData.h" 83 | #include "matroska/KaxInfo.h" 84 | #include "matroska/KaxInfoData.h" 85 | #include "matroska/KaxSeekHead.h" 86 | #include "matroska/KaxSegment.h" 87 | #include "matroska/KaxTag.h" 88 | #include "matroska/KaxTags.h" 89 | //#include "matroska/KaxTagMulti.h" 90 | #include "matroska/KaxTracks.h" 91 | #include "matroska/KaxTrackAudio.h" 92 | #include "matroska/KaxTrackVideo.h" 93 | #include "matroska/KaxTrackEntryData.h" 94 | #include "matroska/KaxContentEncoding.h" 95 | #include "matroska/KaxVersion.h" 96 | 97 | #include "ebml/StdIOCallback.h" 98 | 99 | extern "C" { 100 | #include "../mp4/libmp4.h" 101 | } 102 | #ifdef HAVE_ZLIB_H 103 | # include 104 | #endif 105 | 106 | #include "../../../include/libde265_plugin_common.h" 107 | 108 | #define MKV_DEBUG 0 109 | 110 | #define MATROSKA_COMPRESSION_NONE -1 111 | #define MATROSKA_COMPRESSION_ZLIB 0 112 | #define MATROSKA_COMPRESSION_BLIB 1 113 | #define MATROSKA_COMPRESSION_LZOX 2 114 | #define MATROSKA_COMPRESSION_HEADER 3 115 | 116 | enum 117 | { 118 | MATROSKA_ENCODING_SCOPE_ALL_FRAMES = 1, 119 | MATROSKA_ENCODING_SCOPE_PRIVATE = 2, 120 | MATROSKA_ENCODING_SCOPE_NEXT = 4 /* unsupported */ 121 | }; 122 | 123 | #define MKVD_TIMECODESCALE 1000000 124 | 125 | #define MKV_IS_ID( el, C ) ( el != NULL && typeid( *el ) == typeid( C ) ) 126 | 127 | 128 | using namespace LIBMATROSKA_NAMESPACE; 129 | using namespace std; 130 | 131 | void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simpleblock, 132 | mtime_t i_pts, mtime_t i_duration, bool f_mandatory ); 133 | 134 | class attachment_c 135 | { 136 | public: 137 | attachment_c( const std::string& _psz_file_name, const std::string& _psz_mime_type, int _i_size ) 138 | :i_size(_i_size) 139 | ,psz_file_name( _psz_file_name) 140 | ,psz_mime_type( _psz_mime_type) 141 | { 142 | p_data = NULL; 143 | } 144 | ~attachment_c() { free( p_data ); } 145 | 146 | /* Allocs the data space. Returns true if allocation went ok */ 147 | bool init() 148 | { 149 | p_data = malloc( i_size ); 150 | return (p_data != NULL); 151 | } 152 | 153 | const char* fileName() const { return psz_file_name.c_str(); } 154 | const char* mimeType() const { return psz_mime_type.c_str(); } 155 | int size() const { return i_size; } 156 | 157 | void *p_data; 158 | private: 159 | int i_size; 160 | std::string psz_file_name; 161 | std::string psz_mime_type; 162 | }; 163 | 164 | class matroska_segment_c; 165 | struct matroska_stream_c 166 | { 167 | matroska_stream_c() :p_io_callback(NULL) ,p_estream(NULL) {} 168 | ~matroska_stream_c() 169 | { 170 | delete p_io_callback; 171 | delete p_estream; 172 | } 173 | 174 | IOCallback *p_io_callback; 175 | EbmlStream *p_estream; 176 | 177 | std::vector segments; 178 | }; 179 | 180 | 181 | /***************************************************************************** 182 | * definitions of structures and functions used by this plugins 183 | *****************************************************************************/ 184 | class PrivateTrackData 185 | { 186 | public: 187 | virtual ~PrivateTrackData() {} 188 | virtual int32_t Init() { return 0; } 189 | }; 190 | 191 | struct mkv_track_t 192 | { 193 | // ~mkv_track_t(); 194 | 195 | bool b_default; 196 | bool b_enabled; 197 | bool b_forced; 198 | unsigned int i_number; 199 | 200 | unsigned int i_extra_data; 201 | uint8_t *p_extra_data; 202 | 203 | char *psz_codec; 204 | bool b_dts_only; 205 | bool b_pts_only; 206 | 207 | uint64_t i_default_duration; 208 | float f_timecodescale; 209 | mtime_t i_last_dts; 210 | 211 | /* video */ 212 | es_format_t fmt; 213 | float f_fps; 214 | es_out_id_t *p_es; 215 | 216 | /* audio */ 217 | unsigned int i_original_rate; 218 | 219 | /* Private track paramters */ 220 | PrivateTrackData *p_sys; 221 | 222 | bool b_inited; 223 | /* data to be send first */ 224 | int i_data_init; 225 | uint8_t *p_data_init; 226 | 227 | /* hack : it's for seek */ 228 | bool b_search_keyframe; 229 | bool b_silent; 230 | 231 | /* informative */ 232 | const char *psz_codec_name; 233 | const char *psz_codec_settings; 234 | const char *psz_codec_info_url; 235 | const char *psz_codec_download_url; 236 | 237 | /* encryption/compression */ 238 | int i_compression_type; 239 | uint32_t i_encoding_scope; 240 | KaxContentCompSettings *p_compression_data; 241 | 242 | }; 243 | 244 | struct mkv_index_t 245 | { 246 | int i_track; 247 | int i_block_number; 248 | 249 | int64_t i_position; 250 | int64_t i_time; 251 | 252 | bool b_key; 253 | }; 254 | 255 | 256 | #endif /* _MKV_HPP_ */ 257 | -------------------------------------------------------------------------------- /src/demux/mkv/stream_io_callback.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * stream_io_callback.cpp : matroska demuxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2004, 2010 VLC authors and VideoLAN 5 | * $Id: 5b539deb708b568dc4ae7848307cc74c5c5226f3 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * 10 | * This program is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | 25 | #include "stream_io_callback.hpp" 26 | 27 | #include "matroska_segment.hpp" 28 | #include "demux.hpp" 29 | 30 | /***************************************************************************** 31 | * Stream managment 32 | *****************************************************************************/ 33 | vlc_stream_io_callback::vlc_stream_io_callback( stream_t *s_, bool b_owner_ ) 34 | : s( s_), b_owner( b_owner_ ) 35 | { 36 | mb_eof = false; 37 | } 38 | 39 | uint32 vlc_stream_io_callback::read( void *p_buffer, size_t i_size ) 40 | { 41 | if( i_size <= 0 || mb_eof ) 42 | return 0; 43 | 44 | return stream_Read( s, p_buffer, i_size ); 45 | } 46 | 47 | void vlc_stream_io_callback::setFilePointer(int64_t i_offset, seek_mode mode ) 48 | { 49 | int64_t i_pos, i_size; 50 | 51 | switch( mode ) 52 | { 53 | case seek_beginning: 54 | i_pos = i_offset; 55 | break; 56 | case seek_end: 57 | i_pos = stream_Size( s ) - i_offset; 58 | break; 59 | default: 60 | i_pos= stream_Tell( s ) + i_offset; 61 | break; 62 | } 63 | 64 | if( i_pos < 0 || ( ( i_size = stream_Size( s ) ) != 0 && i_pos >= i_size ) ) 65 | { 66 | mb_eof = true; 67 | return; 68 | } 69 | 70 | mb_eof = false; 71 | if( stream_Seek( s, i_pos ) ) 72 | { 73 | mb_eof = true; 74 | } 75 | return; 76 | } 77 | 78 | uint64 vlc_stream_io_callback::getFilePointer( void ) 79 | { 80 | if ( s == NULL ) 81 | return 0; 82 | return stream_Tell( s ); 83 | } 84 | 85 | size_t vlc_stream_io_callback::write(const void *, size_t ) 86 | { 87 | return 0; 88 | } 89 | 90 | uint64 vlc_stream_io_callback::toRead( void ) 91 | { 92 | uint64_t i_size; 93 | 94 | if( s == NULL) 95 | return 0; 96 | 97 | stream_Control( s, STREAM_GET_SIZE, &i_size ); 98 | 99 | if( i_size == 0 ) 100 | return UINT64_MAX; 101 | 102 | return (uint64) i_size - stream_Tell( s ); 103 | } 104 | 105 | -------------------------------------------------------------------------------- /src/demux/mkv/stream_io_callback.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * stream_io_callback.hpp : matroska demuxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 5 | * $Id: 8e9c28faadebf8adc0e9b33d9445116b5d028af0 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * 10 | * This program is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | #include "mkv.hpp" 25 | 26 | /***************************************************************************** 27 | * Stream managment 28 | *****************************************************************************/ 29 | class vlc_stream_io_callback: public IOCallback 30 | { 31 | private: 32 | stream_t *s; 33 | bool mb_eof; 34 | bool b_owner; 35 | 36 | public: 37 | vlc_stream_io_callback( stream_t *, bool ); 38 | 39 | virtual ~vlc_stream_io_callback() 40 | { 41 | if( b_owner ) 42 | stream_Delete( s ); 43 | } 44 | 45 | virtual uint32 read ( void *p_buffer, size_t i_size); 46 | virtual void setFilePointer ( int64_t i_offset, seek_mode mode = seek_beginning ); 47 | virtual size_t write ( const void *p_buffer, size_t i_size); 48 | virtual uint64 getFilePointer ( void ); 49 | virtual void close ( void ) { return; } 50 | uint64 toRead ( void ); 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /src/demux/mkv/util.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * util.cpp : matroska demuxer 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 5 | * $Id: 326f631fb87faaf5a49808d0c7dbb65ca1bd0277 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * 10 | * This program is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this program; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | #include "mkv.hpp" 25 | #include "util.hpp" 26 | #include "demux.hpp" 27 | 28 | #include 29 | /***************************************************************************** 30 | * Local prototypes 31 | *****************************************************************************/ 32 | 33 | #ifdef HAVE_ZLIB_H 34 | int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t * tk ) 35 | { 36 | int result; 37 | z_stream d_stream; 38 | size_t n = 0; 39 | uint8_t * p_new_extra = NULL; 40 | 41 | msg_Dbg(p_demux,"Inflating private data"); 42 | 43 | d_stream.zalloc = Z_NULL; 44 | d_stream.zfree = Z_NULL; 45 | d_stream.opaque = Z_NULL; 46 | if( inflateInit( &d_stream ) != Z_OK ) 47 | { 48 | msg_Err( p_demux, "Couldn't initiate inflation ignore track %d", 49 | tk->i_number ); 50 | free(tk->p_extra_data); 51 | delete tk; 52 | return 1; 53 | } 54 | 55 | d_stream.next_in = tk->p_extra_data; 56 | d_stream.avail_in = tk->i_extra_data; 57 | do 58 | { 59 | n++; 60 | p_new_extra = (uint8_t *) realloc(p_new_extra, n*1024); 61 | if( !p_new_extra ) 62 | { 63 | msg_Err( p_demux, "Couldn't allocate buffer to inflate data, ignore track %d", 64 | tk->i_number ); 65 | inflateEnd( &d_stream ); 66 | free(tk->p_extra_data); 67 | delete tk; 68 | return 1; 69 | } 70 | d_stream.next_out = &p_new_extra[(n - 1) * 1024]; 71 | d_stream.avail_out = 1024; 72 | result = inflate(&d_stream, Z_NO_FLUSH); 73 | if( result != Z_OK && result != Z_STREAM_END ) 74 | { 75 | msg_Err( p_demux, "Zlib decompression failed. Result: %d", result ); 76 | inflateEnd( &d_stream ); 77 | free(p_new_extra); 78 | free(tk->p_extra_data); 79 | delete tk; 80 | return 1; 81 | } 82 | } 83 | while ( d_stream.avail_out == 0 && d_stream.avail_in != 0 && 84 | result != Z_STREAM_END ); 85 | 86 | free( tk->p_extra_data ); 87 | tk->i_extra_data = d_stream.total_out; 88 | p_new_extra = (uint8_t *) realloc(p_new_extra, tk->i_extra_data); 89 | if( !p_new_extra ) 90 | { 91 | msg_Err( p_demux, "Couldn't allocate buffer to inflate data, ignore track %d", 92 | tk->i_number ); 93 | inflateEnd( &d_stream ); 94 | free(p_new_extra); 95 | delete tk; 96 | return 1; 97 | } 98 | 99 | tk->p_extra_data = p_new_extra; 100 | 101 | inflateEnd( &d_stream ); 102 | return 0; 103 | } 104 | 105 | block_t *block_zlib_decompress( vlc_object_t *p_this, block_t *p_in_block ) { 106 | int result, dstsize, n; 107 | unsigned char *dst; 108 | block_t *p_block; 109 | z_stream d_stream; 110 | 111 | d_stream.zalloc = (alloc_func)0; 112 | d_stream.zfree = (free_func)0; 113 | d_stream.opaque = (voidpf)0; 114 | result = inflateInit(&d_stream); 115 | if( result != Z_OK ) 116 | { 117 | msg_Dbg( p_this, "inflateInit() failed. Result: %d", result ); 118 | return NULL; 119 | } 120 | 121 | d_stream.next_in = (Bytef *)p_in_block->p_buffer; 122 | d_stream.avail_in = p_in_block->i_buffer; 123 | n = 0; 124 | p_block = block_Alloc( 0 ); 125 | dst = NULL; 126 | do 127 | { 128 | n++; 129 | p_block = block_Realloc( p_block, 0, n * 1000 ); 130 | dst = (unsigned char *)p_block->p_buffer; 131 | d_stream.next_out = (Bytef *)&dst[(n - 1) * 1000]; 132 | d_stream.avail_out = 1000; 133 | result = inflate(&d_stream, Z_NO_FLUSH); 134 | if( ( result != Z_OK ) && ( result != Z_STREAM_END ) ) 135 | { 136 | msg_Err( p_this, "Zlib decompression failed. Result: %d", result ); 137 | inflateEnd( &d_stream ); 138 | block_Release( p_block ); 139 | return p_in_block; 140 | } 141 | } 142 | while( ( d_stream.avail_out == 0 ) && ( d_stream.avail_in != 0 ) && 143 | ( result != Z_STREAM_END ) ); 144 | 145 | dstsize = d_stream.total_out; 146 | inflateEnd( &d_stream ); 147 | 148 | p_block = block_Realloc( p_block, 0, dstsize ); 149 | p_block->i_buffer = dstsize; 150 | block_Release( p_in_block ); 151 | 152 | return p_block; 153 | } 154 | #endif 155 | 156 | /* Utility function for BlockDecode */ 157 | block_t *MemToBlock( uint8_t *p_mem, size_t i_mem, size_t offset) 158 | { 159 | if( unlikely( i_mem > SIZE_MAX - offset ) ) 160 | return NULL; 161 | 162 | block_t *p_block = block_Alloc( i_mem + offset ); 163 | if( likely(p_block != NULL) ) 164 | { 165 | memcpy( p_block->p_buffer + offset, p_mem, i_mem ); 166 | } 167 | return p_block; 168 | } 169 | 170 | 171 | void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, mtime_t i_pts) 172 | { 173 | uint8_t * p_frame = p_blk->p_buffer; 174 | Cook_PrivateTrackData * p_sys = (Cook_PrivateTrackData *) p_tk->p_sys; 175 | size_t size = p_blk->i_buffer; 176 | 177 | if( p_tk->i_last_dts == VLC_TS_INVALID ) 178 | { 179 | for( size_t i = 0; i < p_sys->i_subpackets; i++) 180 | if( p_sys->p_subpackets[i] ) 181 | { 182 | block_Release(p_sys->p_subpackets[i]); 183 | p_sys->p_subpackets[i] = NULL; 184 | } 185 | p_sys->i_subpacket = 0; 186 | } 187 | 188 | if( p_tk->fmt.i_codec == VLC_CODEC_COOK || 189 | p_tk->fmt.i_codec == VLC_CODEC_ATRAC3 ) 190 | { 191 | const uint32_t i_num = p_sys->i_frame_size / p_sys->i_subpacket_size; 192 | const int y = p_sys->i_subpacket / ( p_sys->i_frame_size / p_sys->i_subpacket_size ); 193 | 194 | for( int i = 0; i < i_num; i++ ) 195 | { 196 | int i_index = p_sys->i_sub_packet_h * i + 197 | ((p_sys->i_sub_packet_h + 1) / 2) * (y&1) + (y>>1); 198 | if( i_index >= p_sys->i_subpackets ) 199 | return; 200 | 201 | block_t *p_block = block_Alloc( p_sys->i_subpacket_size ); 202 | if( !p_block ) 203 | return; 204 | 205 | if( size < p_sys->i_subpacket_size ) 206 | return; 207 | 208 | memcpy( p_block->p_buffer, p_frame, p_sys->i_subpacket_size ); 209 | p_block->i_dts = VLC_TS_INVALID; 210 | p_block->i_pts = VLC_TS_INVALID; 211 | if( !p_sys->i_subpacket ) 212 | { 213 | p_tk->i_last_dts = 214 | p_block->i_pts = i_pts + VLC_TS_0; 215 | } 216 | 217 | p_frame += p_sys->i_subpacket_size; 218 | size -= p_sys->i_subpacket_size; 219 | 220 | p_sys->i_subpacket++; 221 | p_sys->p_subpackets[i_index] = p_block; 222 | } 223 | } 224 | else 225 | { 226 | /*TODO*/ 227 | } 228 | if( p_sys->i_subpacket == p_sys->i_subpackets ) 229 | { 230 | for( size_t i = 0; i < p_sys->i_subpackets; i++) 231 | { 232 | es_out_Send( p_demux->out, p_tk->p_es, p_sys->p_subpackets[i]); 233 | p_sys->p_subpackets[i] = NULL; 234 | } 235 | p_sys->i_subpacket = 0; 236 | } 237 | } 238 | 239 | int32_t Cook_PrivateTrackData::Init() 240 | { 241 | i_subpackets = (size_t) i_sub_packet_h * (size_t) i_frame_size / (size_t) i_subpacket_size; 242 | p_subpackets = (block_t**) calloc(i_subpackets, sizeof(block_t*)); 243 | 244 | if( unlikely( !p_subpackets ) ) 245 | { 246 | i_subpackets = 0; 247 | return 1; 248 | } 249 | 250 | return 0; 251 | } 252 | 253 | Cook_PrivateTrackData::~Cook_PrivateTrackData() 254 | { 255 | for( size_t i = 0; i < i_subpackets; i++ ) 256 | if( p_subpackets[i] ) 257 | block_Release( p_subpackets[i] ); 258 | 259 | free( p_subpackets ); 260 | } 261 | 262 | static inline void fill_wvpk_block(uint16_t version, uint32_t block_samples, uint32_t flags, 263 | uint32_t crc, uint8_t * src, size_t srclen, uint8_t * dst) 264 | { 265 | const uint8_t wvpk_header[] = {'w','v','p','k', /* ckId */ 266 | 0x0, 0x0, 0x0, 0x0, /* ckSize */ 267 | 0x0, 0x0, /* version */ 268 | 0x0, /* track_no */ 269 | 0x0, /* index_no */ 270 | 0xFF, 0xFF, 0xFF, 0xFF, /* total_samples */ 271 | 0x0, 0x0, 0x0, 0x0 }; /* block_index */ 272 | memcpy( dst, wvpk_header, sizeof( wvpk_header ) ); 273 | SetDWLE( dst + 4, srclen + 24 ); 274 | SetWLE( dst + 8, version ); 275 | SetDWLE( dst + 20, block_samples ); 276 | SetDWLE( dst + 24, flags ); 277 | SetDWLE( dst + 28, crc ); 278 | memcpy( dst + 32, src, srclen ); 279 | } 280 | 281 | block_t * packetize_wavpack( mkv_track_t * p_tk, uint8_t * buffer, size_t size) 282 | { 283 | uint16_t version = 0x403; 284 | uint32_t block_samples; 285 | uint32_t flags; 286 | uint32_t crc; 287 | block_t * p_block = NULL; 288 | 289 | if( p_tk->i_extra_data >= 2 ) 290 | version = GetWLE( p_tk->p_extra_data ); 291 | 292 | if( size < 12 ) 293 | return NULL; 294 | 295 | block_samples = GetDWLE(buffer); 296 | buffer += 4; 297 | flags = GetDWLE(buffer); 298 | size -= 4; 299 | 300 | /* Check if WV_INITIAL_BLOCK and WV_FINAL_BLOCK are present */ 301 | if( ( flags & 0x1800 ) == 0x1800 ) 302 | { 303 | crc = GetDWLE(buffer+4); 304 | buffer += 8; 305 | size -= 8; 306 | 307 | p_block = block_Alloc( size + 32 ); 308 | if( !p_block ) 309 | return NULL; 310 | 311 | fill_wvpk_block(version, block_samples, flags, crc, buffer, size, p_block->p_buffer); 312 | } 313 | else 314 | { 315 | /* Multiblock */ 316 | size_t total_size = 0; 317 | 318 | p_block = block_Alloc( 0 ); 319 | if( !p_block ) 320 | return NULL; 321 | 322 | while(size >= 12) 323 | { 324 | flags = GetDWLE(buffer); 325 | buffer += 4; 326 | crc = GetDWLE(buffer); 327 | buffer += 4; 328 | uint32_t bsz = GetDWLE(buffer); 329 | buffer+= 4; 330 | size -= 12; 331 | 332 | bsz = (bsz < size)?bsz:size; 333 | 334 | total_size += bsz + 32; 335 | 336 | assert(total_size >= p_block->i_buffer); 337 | 338 | p_block = block_Realloc( p_block, 0, total_size ); 339 | 340 | if( !p_block ) 341 | return NULL; 342 | 343 | fill_wvpk_block(version, block_samples, flags, crc, buffer, bsz, 344 | p_block->p_buffer + total_size - bsz - 32 ); 345 | buffer += bsz; 346 | size -= bsz; 347 | } 348 | } 349 | 350 | return p_block; 351 | } 352 | -------------------------------------------------------------------------------- /src/demux/mkv/util.hpp: -------------------------------------------------------------------------------- 1 | 2 | /***************************************************************************** 3 | * mkv.cpp : matroska demuxer 4 | ***************************************************************************** 5 | * Copyright (C) 2003-2004 VLC authors and VideoLAN 6 | * $Id: c181ad23be316f15470605833baf722f9fe6b83f $ 7 | * 8 | * Authors: Laurent Aimar 9 | * Steve Lhomme 10 | * 11 | * This program is free software; you can redistribute it and/or modify it 12 | * under the terms of the GNU Lesser General Public License as published by 13 | * the Free Software Foundation; either version 2.1 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public License 22 | * along with this program; if not, write to the Free Software Foundation, 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 24 | *****************************************************************************/ 25 | 26 | #include "mkv.hpp" 27 | 28 | #ifdef HAVE_ZLIB_H 29 | int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t * tk ); 30 | block_t *block_zlib_decompress( vlc_object_t *p_this, block_t *p_in_block ); 31 | #endif 32 | 33 | block_t *MemToBlock( uint8_t *p_mem, size_t i_mem, size_t offset); 34 | void handle_real_audio(demux_t * p_demux, mkv_track_t * p_tk, block_t * p_blk, mtime_t i_pts); 35 | 36 | 37 | struct real_audio_private 38 | { 39 | uint32_t fourcc; 40 | uint16_t version; 41 | uint16_t unknown1; 42 | uint8_t unknown2[12]; 43 | uint16_t unknown3; 44 | uint16_t flavor; 45 | uint32_t coded_frame_size; 46 | uint32_t unknown4[3]; 47 | uint16_t sub_packet_h; 48 | uint16_t frame_size; 49 | uint16_t sub_packet_size; 50 | uint16_t unknown5; 51 | }; 52 | 53 | struct real_audio_private_v4 54 | { 55 | real_audio_private header; 56 | uint16_t sample_rate; 57 | uint16_t unknown; 58 | uint16_t sample_size; 59 | uint16_t channels; 60 | }; 61 | 62 | 63 | struct real_audio_private_v5 64 | { 65 | real_audio_private header; 66 | uint32_t unknown1; 67 | uint16_t unknown2; 68 | uint16_t sample_rate; 69 | uint16_t unknown3; 70 | uint16_t sample_size; 71 | uint16_t channels; 72 | }; 73 | 74 | class Cook_PrivateTrackData : public PrivateTrackData 75 | { 76 | public: 77 | Cook_PrivateTrackData(uint16_t sph, uint16_t fs, uint16_t sps): 78 | i_sub_packet_h(sph), i_frame_size(fs), i_subpacket_size(sps), 79 | p_subpackets(NULL), i_subpackets(0), i_subpacket(0){} 80 | ~Cook_PrivateTrackData(); 81 | int32_t Init(); 82 | 83 | uint16_t i_sub_packet_h; 84 | uint16_t i_frame_size; 85 | uint16_t i_subpacket_size; 86 | block_t **p_subpackets; 87 | size_t i_subpackets; 88 | size_t i_subpacket; 89 | }; 90 | 91 | block_t * packetize_wavpack( mkv_track_t *, uint8_t *, size_t); 92 | -------------------------------------------------------------------------------- /src/demux/mkv/virtual_segment.hpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * virtual_segment.hpp : virtual segment implementation in the MKV demuxer 3 | ***************************************************************************** 4 | * Copyright © 2003-2011 VideoLAN and VLC authors 5 | * $Id: c901e44e8996b3e825fc24ab7f929126a7ac5b08 $ 6 | * 7 | * Authors: Laurent Aimar 8 | * Steve Lhomme 9 | * Denis Charmet 10 | * 11 | * This program is free software; you can redistribute it and/or modify it 12 | * under the terms of the GNU Lesser General Public License as published by 13 | * the Free Software Foundation; either version 2.1 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public License 22 | * along with this program; if not, write to the Free Software Foundation, 23 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 24 | *****************************************************************************/ 25 | 26 | #ifndef _VIRTUAL_SEGMENT_HPP_ 27 | #define _VIRTUAL_SEGMENT_HPP_ 28 | 29 | #include "mkv.hpp" 30 | 31 | #include "matroska_segment.hpp" 32 | #include "chapters.hpp" 33 | 34 | /* virtual classes don't own anything but virtual elements so they shouldn't have to delete anything */ 35 | 36 | class virtual_chapter_c 37 | { 38 | public: 39 | virtual_chapter_c( matroska_segment_c *p_seg, chapter_item_c *p_chap, int64_t start, int64_t stop ): 40 | p_segment(p_seg), p_chapter(p_chap), 41 | i_virtual_start_time(start), i_virtual_stop_time(stop) 42 | {} 43 | ~virtual_chapter_c(); 44 | 45 | static virtual_chapter_c * CreateVirtualChapter( chapter_item_c * p_chap, 46 | matroska_segment_c * p_main_segment, 47 | std::vector * segments, 48 | int64_t * usertime_offset, bool b_ordered ); 49 | 50 | virtual_chapter_c* getSubChapterbyTimecode( int64_t time ); 51 | bool EnterAndLeave( virtual_chapter_c *p_item, bool b_enter = true ); 52 | virtual_chapter_c * FindChapter( int64_t i_find_uid ); 53 | int PublishChapters( input_title_t & title, int & i_user_chapters, int i_level ); 54 | 55 | virtual_chapter_c * BrowseCodecPrivate( unsigned int codec_id, 56 | bool (*match)( const chapter_codec_cmds_c &data, 57 | const void *p_cookie, 58 | size_t i_cookie_size ), 59 | const void *p_cookie, 60 | size_t i_cookie_size ); 61 | bool Enter( bool b_do_subs ); 62 | bool Leave( bool b_do_subs ); 63 | 64 | static bool CompareTimecode( const virtual_chapter_c * itemA, const virtual_chapter_c * itemB ) 65 | { 66 | return ( itemA->i_virtual_start_time < itemB->i_virtual_start_time ); 67 | } 68 | 69 | matroska_segment_c *p_segment; 70 | chapter_item_c *p_chapter; 71 | int64_t i_virtual_start_time; 72 | int64_t i_virtual_stop_time; 73 | int i_seekpoint_num; 74 | std::vector sub_chapters; 75 | #if MKV_DEBUG 76 | void print(); 77 | #endif 78 | }; 79 | 80 | class virtual_edition_c 81 | { 82 | public: 83 | virtual_edition_c( chapter_edition_c * p_edition, std::vector *opened_segments ); 84 | ~virtual_edition_c(); 85 | std::vector chapters; 86 | 87 | virtual_chapter_c* getChapterbyTimecode( int64_t time ); 88 | std::string GetMainName(); 89 | int PublishChapters( input_title_t & title, int & i_user_chapters, int i_level ); 90 | virtual_chapter_c * BrowseCodecPrivate( unsigned int codec_id, 91 | bool (*match)( const chapter_codec_cmds_c &data, 92 | const void *p_cookie, 93 | size_t i_cookie_size ), 94 | const void *p_cookie, size_t i_cookie_size ); 95 | 96 | bool b_ordered; 97 | int64_t i_duration; 98 | chapter_edition_c *p_edition; 99 | int i_seekpoint_num; 100 | 101 | private: 102 | void retimeChapters(); 103 | void retimeSubChapters( virtual_chapter_c * p_vchap ); 104 | #if MKV_DEBUG 105 | void print(){ for( size_t i = 0; iprint(); } 106 | #endif 107 | 108 | }; 109 | 110 | // class holding hard-linked segment together in the playback order 111 | class virtual_segment_c 112 | { 113 | public: 114 | virtual_segment_c( std::vector * opened_segments ); 115 | ~virtual_segment_c(); 116 | std::vector editions; 117 | int i_current_edition; 118 | virtual_chapter_c *p_current_chapter; 119 | int i_sys_title; 120 | 121 | 122 | inline virtual_edition_c * CurrentEdition() 123 | { 124 | if( i_current_edition >= 0 && (size_t) i_current_edition < editions.size() ) 125 | return editions[i_current_edition]; 126 | return NULL; 127 | } 128 | 129 | virtual_chapter_c * CurrentChapter() const 130 | { 131 | return p_current_chapter; 132 | } 133 | 134 | matroska_segment_c * CurrentSegment() const 135 | { 136 | if ( !p_current_chapter ) 137 | return NULL; 138 | return p_current_chapter->p_segment; 139 | } 140 | 141 | inline int64_t Duration() 142 | { 143 | return editions[i_current_edition]->i_duration / 1000; 144 | } 145 | 146 | inline std::vector* Editions() { return &editions; } 147 | 148 | virtual_chapter_c *BrowseCodecPrivate( unsigned int codec_id, 149 | bool (*match)( const chapter_codec_cmds_c &data, 150 | const void *p_cookie, 151 | size_t i_cookie_size ), 152 | const void *p_cookie, 153 | size_t i_cookie_size ); 154 | 155 | virtual_chapter_c * FindChapter( int64_t i_find_uid ); 156 | 157 | bool UpdateCurrentToChapter( demux_t & demux ); 158 | void Seek( demux_t & demuxer, mtime_t i_date, mtime_t i_time_offset, 159 | virtual_chapter_c *p_chapter, int64_t i_global_position ); 160 | private: 161 | void ChangeSegment( matroska_segment_c * p_old, matroska_segment_c * p_new, mtime_t i_start_time ); 162 | }; 163 | 164 | #endif 165 | -------------------------------------------------------------------------------- /src/demux/mp4/id3genres.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * id3genres.h: list of genres for id3 genre tags 3 | ***************************************************************************** 4 | * Copyright (C) 2002-2003 VLC authors and VideoLAN 5 | * $Id: 25cd8e9bc89c826ae363a9825dceb608a82423d9 $ 6 | * 7 | * Author: Sigmund Augdal Helberg 8 | * list found at http://www.id3.org/id3v2.4.0-frames.txt 9 | * Author: John Freed 10 | * updated with extensions to conform to real-world files 11 | * see http://www.id3.org/Compliance_Issues and 12 | * http://www.id3.org/id3v2.3.0 13 | * 14 | * This program is free software; you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published by 16 | * the Free Software Foundation; either version 2.1 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * This program is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | * GNU Lesser General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU Lesser General Public License 25 | * along with this program; if not, write to the Free Software Foundation, 26 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 27 | *****************************************************************************/ 28 | 29 | #define NUM_GENRES 148 30 | 31 | static const char *ppsz_genres[] = { 32 | N_("Blues"), 33 | N_("Classic Rock"), 34 | N_("Country"), 35 | N_("Dance"), 36 | N_("Disco"), 37 | N_("Funk"), 38 | N_("Grunge"), 39 | N_("Hip-Hop"), 40 | N_("Jazz"), 41 | N_("Metal"), 42 | N_("New Age"), 43 | N_("Oldies"), 44 | N_("Other"), 45 | N_("Pop"), 46 | N_("R&B"), 47 | N_("Rap"), 48 | N_("Reggae"), 49 | N_("Rock"), 50 | N_("Techno"), 51 | N_("Industrial"), 52 | N_("Alternative"), 53 | N_("Ska"), 54 | N_("Death Metal"), 55 | N_("Pranks"), 56 | N_("Soundtrack"), 57 | N_("Euro-Techno"), 58 | N_("Ambient"), 59 | N_("Trip-Hop"), 60 | N_("Vocal"), 61 | N_("Jazz+Funk"), 62 | N_("Fusion"), 63 | N_("Trance"), 64 | N_("Classical"), 65 | N_("Instrumental"), 66 | N_("Acid"), 67 | N_("House"), 68 | N_("Game"), 69 | N_("Sound Clip"), 70 | N_("Gospel"), 71 | N_("Noise"), 72 | N_("Alternative Rock"), 73 | N_("Bass"), 74 | N_("Soul"), 75 | N_("Punk"), 76 | N_("Space"), 77 | N_("Meditative"), 78 | N_("Instrumental Pop"), 79 | N_("Instrumental Rock"), 80 | N_("Ethnic"), 81 | N_("Gothic"), 82 | N_("Darkwave"), 83 | N_("Techno-Industrial"), 84 | N_("Electronic"), 85 | N_("Pop-Folk"), 86 | N_("Eurodance"), 87 | N_("Dream"), 88 | N_("Southern Rock"), 89 | N_("Comedy"), 90 | N_("Cult"), 91 | N_("Gangsta"), 92 | N_("Top 40"), 93 | N_("Christian Rap"), 94 | N_("Pop/Funk"), 95 | N_("Jungle"), 96 | N_("Native American"), 97 | N_("Cabaret"), 98 | N_("New Wave"), 99 | N_("Psychedelic"), 100 | N_("Rave"), 101 | N_("Showtunes"), 102 | N_("Trailer"), 103 | N_("Lo-Fi"), 104 | N_("Tribal"), 105 | N_("Acid Punk"), 106 | N_("Acid Jazz"), 107 | N_("Polka"), 108 | N_("Retro"), 109 | N_("Musical"), 110 | N_("Rock & Roll"), 111 | N_("Hard Rock"), 112 | N_("Folk"), 113 | N_("Folk-Rock"), 114 | N_("National Folk"), 115 | N_("Swing"), 116 | N_("Fast Fusion"), 117 | N_("Bebob"), 118 | N_("Latin"), 119 | N_("Revival"), 120 | N_("Celtic"), 121 | N_("Bluegrass"), 122 | N_("Avantgarde"), 123 | N_("Gothic Rock"), 124 | N_("Progressive Rock"), 125 | N_("Psychedelic Rock"), 126 | N_("Symphonic Rock"), 127 | N_("Slow Rock"), 128 | N_("Big Band"), 129 | N_("Chorus"), 130 | N_("Easy Listening"), 131 | N_("Acoustic"), 132 | N_("Humour"), 133 | N_("Speech"), 134 | N_("Chanson"), 135 | N_("Opera"), 136 | N_("Chamber Music"), 137 | N_("Sonata"), 138 | N_("Symphony"), 139 | N_("Booty Bass"), 140 | N_("Primus"), 141 | N_("Porn Groove"), 142 | N_("Satire"), 143 | N_("Slow Jam"), 144 | N_("Club"), 145 | N_("Tango"), 146 | N_("Samba"), 147 | N_("Folklore"), 148 | N_("Ballad"), 149 | N_("Power Ballad"), 150 | N_("Rhythmic Soul"), 151 | N_("Freestyle"), 152 | N_("Duet"), 153 | N_("Punk Rock"), 154 | N_("Drum Solo"), 155 | N_("Acapella"), 156 | N_("Euro-House"), 157 | N_("Dance Hall"), 158 | N_("Goa"), 159 | N_("Drum & Bass"), 160 | N_("Club - House"), 161 | N_("Hardcore"), 162 | N_("Terror"), 163 | N_("Indie"), 164 | N_("BritPop"), 165 | N_("Negerpunk"), 166 | N_("Polsk Punk"), 167 | N_("Beat"), 168 | N_("Christian Gangsta Rap"), 169 | N_("Heavy Metal"), 170 | N_("Black Metal"), 171 | N_("Crossover"), 172 | N_("Contemporary Christian"), 173 | N_("Christian Rock"), 174 | N_("Merengue"), 175 | N_("Salsa"), 176 | N_("Thrash Metal"), 177 | N_("Anime"), 178 | N_("JPop"), 179 | N_("Synthpop") 180 | }; 181 | -------------------------------------------------------------------------------- /src/demux/vobsub.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * vobsub.h: Vobsub support 3 | ***************************************************************************** 4 | * Copyright (C) 2009 VLC authors and VideoLAN 5 | * $Id: 67d850b9db7848f02336ac08f80d7715ac90f316 $ 6 | * 7 | * Authors: John Stebbins 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU Lesser General Public License as published by 11 | * the Free Software Foundation; either version 2.1 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with this program; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 22 | *****************************************************************************/ 23 | 24 | static inline void vobsub_palette_rgb2yuv( uint32_t *pu_palette ) 25 | { 26 | int i; 27 | for( i = 0; i < 16; i++ ) 28 | { 29 | uint8_t r, g, b, y, u, v; 30 | r = (pu_palette[i] >> 16) & 0xff; 31 | g = (pu_palette[i] >> 8) & 0xff; 32 | b = (pu_palette[i] >> 0) & 0xff; 33 | y = (uint8_t) __MIN(abs(r * 2104 + g * 4130 + b * 802 + 4096 + 131072) >> 13, 235); 34 | u = (uint8_t) __MIN(abs(r * -1214 + g * -2384 + b * 3598 + 4096 + 1048576) >> 13, 240); 35 | v = (uint8_t) __MIN(abs(r * 3598 + g * -3013 + b * -585 + 4096 + 1048576) >> 13, 240); 36 | pu_palette[i] = (y&0xff)<<16 | (v&0xff)<<8 | (u&0xff); 37 | } 38 | } 39 | 40 | static inline int vobsub_palette_parse( const char *psz_buf, uint32_t *pu_palette ) 41 | { 42 | if( sscanf( psz_buf, "palette: " 43 | "%"PRIx32", %"PRIx32", %"PRIx32", %"PRIx32", " 44 | "%"PRIx32", %"PRIx32", %"PRIx32", %"PRIx32", " 45 | "%"PRIx32", %"PRIx32", %"PRIx32", %"PRIx32", " 46 | "%"PRIx32", %"PRIx32", %"PRIx32", %"PRIx32"", 47 | &pu_palette[0], &pu_palette[1], &pu_palette[2], &pu_palette[3], 48 | &pu_palette[4], &pu_palette[5], &pu_palette[6], &pu_palette[7], 49 | &pu_palette[8], &pu_palette[9], &pu_palette[10], &pu_palette[11], 50 | &pu_palette[12], &pu_palette[13], &pu_palette[14], &pu_palette[15] ) == 16 ) 51 | { 52 | vobsub_palette_rgb2yuv( pu_palette ); 53 | return VLC_SUCCESS; 54 | } 55 | else 56 | { 57 | return VLC_EGENERIC; 58 | } 59 | } 60 | 61 | static inline int vobsub_size_parse( const char *psz_buf, 62 | int *pi_original_frame_width, 63 | int *pi_original_frame_height ) 64 | { 65 | if( sscanf( psz_buf, "size: %dx%d", 66 | pi_original_frame_width, pi_original_frame_height ) == 2 ) 67 | { 68 | return VLC_SUCCESS; 69 | } 70 | else 71 | { 72 | return VLC_EGENERIC; 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /src/mux/mpeg/csa.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * libcsa.c: CSA scrambler/descrambler 3 | ***************************************************************************** 4 | * Copyright (C) 2004-2005 Laurent Aimar 5 | * Copyright (C) the deCSA authors 6 | * 7 | * Authors: Laurent Aimar 8 | * Jean-Paul Saman 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 23 | *****************************************************************************/ 24 | 25 | #ifdef HAVE_CONFIG_H 26 | # include "config.h" 27 | #endif 28 | 29 | #include 30 | 31 | #include "csa.h" 32 | 33 | struct csa_t 34 | { 35 | /* odd and even keys */ 36 | uint8_t o_ck[8]; 37 | uint8_t e_ck[8]; 38 | 39 | uint8_t o_kk[57]; 40 | uint8_t e_kk[57]; 41 | 42 | /* cypher state */ 43 | int A[11]; 44 | int B[11]; 45 | int X, Y, Z; 46 | int D, E, F; 47 | int p, q, r; 48 | 49 | bool use_odd; 50 | }; 51 | 52 | static void csa_ComputeKey( uint8_t kk[57], uint8_t ck[8] ); 53 | 54 | static void csa_StreamCypher( csa_t *c, int b_init, uint8_t *ck, uint8_t *sb, uint8_t *cb ); 55 | 56 | static void csa_BlockDecypher( uint8_t kk[57], uint8_t ib[8], uint8_t bd[8] ); 57 | static void csa_BlockCypher( uint8_t kk[57], uint8_t bd[8], uint8_t ib[8] ); 58 | 59 | /***************************************************************************** 60 | * csa_New: 61 | *****************************************************************************/ 62 | csa_t *csa_New( void ) 63 | { 64 | return calloc( 1, sizeof( csa_t ) ); 65 | } 66 | 67 | /***************************************************************************** 68 | * csa_Delete: 69 | *****************************************************************************/ 70 | void csa_Delete( csa_t *c ) 71 | { 72 | free( c ); 73 | } 74 | 75 | /***************************************************************************** 76 | * csa_SetCW: 77 | *****************************************************************************/ 78 | int csa_SetCW( vlc_object_t *p_caller, csa_t *c, char *psz_ck, bool set_odd ) 79 | { 80 | if ( !c ) 81 | { 82 | msg_Dbg( p_caller, "no CSA found" ); 83 | return VLC_ENOOBJ; 84 | } 85 | /* skip 0x */ 86 | if( psz_ck[0] == '0' && ( psz_ck[1] == 'x' || psz_ck[1] == 'X' ) ) 87 | { 88 | psz_ck += 2; 89 | } 90 | if( strlen( psz_ck ) != 16 ) 91 | { 92 | msg_Warn( p_caller, "invalid csa ck (it must be 16 chars long)" ); 93 | return VLC_EBADVAR; 94 | } 95 | else 96 | { 97 | uint64_t i_ck = strtoull( psz_ck, NULL, 16 ); 98 | uint8_t ck[8]; 99 | int i; 100 | 101 | for( i = 0; i < 8; i++ ) 102 | { 103 | ck[i] = ( i_ck >> ( 56 - 8*i) )&0xff; 104 | } 105 | #ifndef TS_NO_CSA_CK_MSG 106 | msg_Dbg( p_caller, "using CSA (de)scrambling with %s " 107 | "key=%x:%x:%x:%x:%x:%x:%x:%x", set_odd ? "odd" : "even", 108 | ck[0], ck[1], ck[2], ck[3], ck[4], ck[5], ck[6], ck[7] ); 109 | #endif 110 | if( set_odd ) 111 | { 112 | memcpy( c->o_ck, ck, 8 ); 113 | csa_ComputeKey( c->o_kk, ck ); 114 | } 115 | else 116 | { 117 | memcpy( c->e_ck , ck, 8 ); 118 | csa_ComputeKey( c->e_kk , ck ); 119 | } 120 | return VLC_SUCCESS; 121 | } 122 | } 123 | 124 | /***************************************************************************** 125 | * csa_UseKey: 126 | *****************************************************************************/ 127 | int csa_UseKey( vlc_object_t *p_caller, csa_t *c, bool use_odd ) 128 | { 129 | if ( !c ) return VLC_ENOOBJ; 130 | c->use_odd = use_odd; 131 | #ifndef TS_NO_CSA_CK_MSG 132 | msg_Dbg( p_caller, "using the %s key for scrambling", 133 | use_odd ? "odd" : "even" ); 134 | #endif 135 | return VLC_SUCCESS; 136 | } 137 | 138 | /***************************************************************************** 139 | * csa_Decrypt: 140 | *****************************************************************************/ 141 | void csa_Decrypt( csa_t *c, uint8_t *pkt, int i_pkt_size ) 142 | { 143 | uint8_t *ck; 144 | uint8_t *kk; 145 | 146 | uint8_t ib[8], stream[8], block[8]; 147 | 148 | int i_hdr, i_residue; 149 | int i, j, n; 150 | 151 | /* transport scrambling control */ 152 | if( (pkt[3]&0x80) == 0 ) 153 | { 154 | /* not scrambled */ 155 | return; 156 | } 157 | if( pkt[3]&0x40 ) 158 | { 159 | ck = c->o_ck; 160 | kk = c->o_kk; 161 | } 162 | else 163 | { 164 | ck = c->e_ck; 165 | kk = c->e_kk; 166 | } 167 | 168 | /* clear transport scrambling control */ 169 | pkt[3] &= 0x3f; 170 | 171 | i_hdr = 4; 172 | if( pkt[3]&0x20 ) 173 | { 174 | /* skip adaption field */ 175 | i_hdr += pkt[4] + 1; 176 | } 177 | 178 | if( 188 - i_hdr < 8 ) 179 | return; 180 | 181 | /* init csa state */ 182 | csa_StreamCypher( c, 1, ck, &pkt[i_hdr], ib ); 183 | 184 | /* */ 185 | n = (i_pkt_size - i_hdr) / 8; 186 | if( n < 0 ) 187 | return; 188 | 189 | i_residue = (i_pkt_size - i_hdr) % 8; 190 | for( i = 1; i < n + 1; i++ ) 191 | { 192 | csa_BlockDecypher( kk, ib, block ); 193 | if( i != n ) 194 | { 195 | csa_StreamCypher( c, 0, ck, NULL, stream ); 196 | for( j = 0; j < 8; j++ ) 197 | { 198 | /* xor ib with stream */ 199 | ib[j] = pkt[i_hdr+8*i+j] ^ stream[j]; 200 | } 201 | } 202 | else 203 | { 204 | /* last block */ 205 | for( j = 0; j < 8; j++ ) 206 | { 207 | ib[j] = 0; 208 | } 209 | } 210 | /* xor ib with block */ 211 | for( j = 0; j < 8; j++ ) 212 | { 213 | pkt[i_hdr+8*(i-1)+j] = ib[j] ^ block[j]; 214 | } 215 | } 216 | 217 | if( i_residue > 0 ) 218 | { 219 | csa_StreamCypher( c, 0, ck, NULL, stream ); 220 | for( j = 0; j < i_residue; j++ ) 221 | { 222 | pkt[i_pkt_size - i_residue + j] ^= stream[j]; 223 | } 224 | } 225 | } 226 | 227 | /***************************************************************************** 228 | * csa_Encrypt: 229 | *****************************************************************************/ 230 | void csa_Encrypt( csa_t *c, uint8_t *pkt, int i_pkt_size ) 231 | { 232 | uint8_t *ck; 233 | uint8_t *kk; 234 | 235 | int i, j; 236 | int i_hdr = 4; /* hdr len */ 237 | uint8_t ib[184/8+2][8], stream[8], block[8]; 238 | int n, i_residue; 239 | 240 | /* set transport scrambling control */ 241 | pkt[3] |= 0x80; 242 | 243 | if( c->use_odd ) 244 | { 245 | pkt[3] |= 0x40; 246 | ck = c->o_ck; 247 | kk = c->o_kk; 248 | } 249 | else 250 | { 251 | ck = c->e_ck; 252 | kk = c->e_kk; 253 | } 254 | 255 | /* hdr len */ 256 | i_hdr = 4; 257 | if( pkt[3]&0x20 ) 258 | { 259 | /* skip adaption field */ 260 | i_hdr += pkt[4] + 1; 261 | } 262 | n = (i_pkt_size - i_hdr) / 8; 263 | i_residue = (i_pkt_size - i_hdr) % 8; 264 | 265 | if( n <= 0 ) 266 | { 267 | pkt[3] &= 0x3f; 268 | return; 269 | } 270 | 271 | /* */ 272 | for( i = 0; i < 8; i++ ) 273 | { 274 | ib[n+1][i] = 0; 275 | } 276 | for( i = n; i > 0; i-- ) 277 | { 278 | for( j = 0; j < 8; j++ ) 279 | { 280 | block[j] = pkt[i_hdr+8*(i-1)+j] ^ib[i+1][j]; 281 | } 282 | csa_BlockCypher( kk, block, ib[i] ); 283 | } 284 | 285 | /* init csa state */ 286 | csa_StreamCypher( c, 1, ck, ib[1], stream ); 287 | 288 | for( i = 0; i < 8; i++ ) 289 | { 290 | pkt[i_hdr+i] = ib[1][i]; 291 | } 292 | for( i = 2; i < n+1; i++ ) 293 | { 294 | csa_StreamCypher( c, 0, ck, NULL, stream ); 295 | for( j = 0; j < 8; j++ ) 296 | { 297 | pkt[i_hdr+8*(i-1)+j] = ib[i][j] ^ stream[j]; 298 | } 299 | } 300 | if( i_residue > 0 ) 301 | { 302 | csa_StreamCypher( c, 0, ck, NULL, stream ); 303 | for( j = 0; j < i_residue; j++ ) 304 | { 305 | pkt[i_pkt_size - i_residue + j] ^= stream[j]; 306 | } 307 | } 308 | } 309 | 310 | /***************************************************************************** 311 | * Divers 312 | *****************************************************************************/ 313 | static const uint8_t key_perm[0x40] = 314 | { 315 | 0x12,0x24,0x09,0x07,0x2A,0x31,0x1D,0x15,0x1C,0x36,0x3E,0x32,0x13,0x21,0x3B,0x40, 316 | 0x18,0x14,0x25,0x27,0x02,0x35,0x1B,0x01,0x22,0x04,0x0D,0x0E,0x39,0x28,0x1A,0x29, 317 | 0x33,0x23,0x34,0x0C,0x16,0x30,0x1E,0x3A,0x2D,0x1F,0x08,0x19,0x17,0x2F,0x3D,0x11, 318 | 0x3C,0x05,0x38,0x2B,0x0B,0x06,0x0A,0x2C,0x20,0x3F,0x2E,0x0F,0x03,0x26,0x10,0x37, 319 | }; 320 | 321 | static void csa_ComputeKey( uint8_t kk[57], uint8_t ck[8] ) 322 | { 323 | int i,j,k; 324 | int bit[64]; 325 | int newbit[64]; 326 | int kb[8][9]; 327 | 328 | /* from a cw create 56 key bytes, here kk[1..56] */ 329 | 330 | /* load ck into kb[7][1..8] */ 331 | for( i = 0; i < 8; i++ ) 332 | { 333 | kb[7][i+1] = ck[i]; 334 | } 335 | 336 | /* calculate all kb[6..1][*] */ 337 | for( i = 0; i < 7; i++ ) 338 | { 339 | /* do a 64 bit perm on kb */ 340 | for( j = 0; j < 8; j++ ) 341 | { 342 | for( k = 0; k < 8; k++ ) 343 | { 344 | bit[j*8+k] = (kb[7-i][1+j] >> (7-k)) & 1; 345 | newbit[key_perm[j*8+k]-1] = bit[j*8+k]; 346 | } 347 | } 348 | for( j = 0; j < 8; j++ ) 349 | { 350 | kb[6-i][1+j] = 0; 351 | for( k = 0; k < 8; k++ ) 352 | { 353 | kb[6-i][1+j] |= newbit[j*8+k] << (7-k); 354 | } 355 | } 356 | } 357 | 358 | /* xor to give kk */ 359 | for( i = 0; i < 7; i++ ) 360 | { 361 | for( j = 0; j < 8; j++ ) 362 | { 363 | kk[1+i*8+j] = kb[1+i][1+j] ^ i; 364 | } 365 | } 366 | } 367 | 368 | 369 | static const int sbox1[0x20] = {2,0,1,1,2,3,3,0, 3,2,2,0,1,1,0,3, 0,3,3,0,2,2,1,1, 2,2,0,3,1,1,3,0}; 370 | static const int sbox2[0x20] = {3,1,0,2,2,3,3,0, 1,3,2,1,0,0,1,2, 3,1,0,3,3,2,0,2, 0,0,1,2,2,1,3,1}; 371 | static const int sbox3[0x20] = {2,0,1,2,2,3,3,1, 1,1,0,3,3,0,2,0, 1,3,0,1,3,0,2,2, 2,0,1,2,0,3,3,1}; 372 | static const int sbox4[0x20] = {3,1,2,3,0,2,1,2, 1,2,0,1,3,0,0,3, 1,0,3,1,2,3,0,3, 0,3,2,0,1,2,2,1}; 373 | static const int sbox5[0x20] = {2,0,0,1,3,2,3,2, 0,1,3,3,1,0,2,1, 2,3,2,0,0,3,1,1, 1,0,3,2,3,1,0,2}; 374 | static const int sbox6[0x20] = {0,1,2,3,1,2,2,0, 0,1,3,0,2,3,1,3, 2,3,0,2,3,0,1,1, 2,1,1,2,0,3,3,0}; 375 | static const int sbox7[0x20] = {0,3,2,2,3,0,0,1, 3,0,1,3,1,2,2,1, 1,0,3,3,0,1,1,2, 2,3,1,0,2,3,0,2}; 376 | 377 | static void csa_StreamCypher( csa_t *c, int b_init, uint8_t *ck, uint8_t *sb, uint8_t *cb ) 378 | { 379 | int i,j, k; 380 | int extra_B; 381 | int s1,s2,s3,s4,s5,s6,s7; 382 | int next_A1; 383 | int next_B1; 384 | int next_E; 385 | 386 | if( b_init ) 387 | { 388 | // load first 32 bits of CK into A[1]..A[8] 389 | // load last 32 bits of CK into B[1]..B[8] 390 | // all other regs = 0 391 | for( i = 0; i < 4; i++ ) 392 | { 393 | c->A[1+2*i+0] = ( ck[i] >> 4 )&0x0f; 394 | c->A[1+2*i+1] = ( ck[i] >> 0 )&0x0f; 395 | 396 | c->B[1+2*i+0] = ( ck[4+i] >> 4 )&0x0f; 397 | c->B[1+2*i+1] = ( ck[4+i] >> 0 )&0x0f; 398 | } 399 | 400 | c->A[9] = c->A[10] = 0; 401 | c->B[9] = c->B[10] = 0; 402 | 403 | c->X = c->Y = c->Z = 0; 404 | c->D = c->E = c->F = 0; 405 | c->p = c->q = c->r = 0; 406 | } 407 | 408 | // 8 bytes per operation 409 | for( i = 0; i < 8; i++ ) 410 | { 411 | int op = 0; 412 | int in1 = 0; /* gcc warn */ 413 | int in2 = 0; 414 | 415 | if( b_init ) 416 | { 417 | in1 = ( sb[i] >> 4 )&0x0f; 418 | in2 = ( sb[i] >> 0 )&0x0f; 419 | } 420 | 421 | // 2 bits per iteration 422 | for( j = 0; j < 4; j++ ) 423 | { 424 | // from A[1]..A[10], 35 bits are selected as inputs to 7 s-boxes 425 | // 5 bits input per s-box, 2 bits output per s-box 426 | s1 = sbox1[ (((c->A[4]>>0)&1)<<4) | (((c->A[1]>>2)&1)<<3) | (((c->A[6]>>1)&1)<<2) | (((c->A[7]>>3)&1)<<1) | (((c->A[9]>>0)&1)<<0) ]; 427 | s2 = sbox2[ (((c->A[2]>>1)&1)<<4) | (((c->A[3]>>2)&1)<<3) | (((c->A[6]>>3)&1)<<2) | (((c->A[7]>>0)&1)<<1) | (((c->A[9]>>1)&1)<<0) ]; 428 | s3 = sbox3[ (((c->A[1]>>3)&1)<<4) | (((c->A[2]>>0)&1)<<3) | (((c->A[5]>>1)&1)<<2) | (((c->A[5]>>3)&1)<<1) | (((c->A[6]>>2)&1)<<0) ]; 429 | s4 = sbox4[ (((c->A[3]>>3)&1)<<4) | (((c->A[1]>>1)&1)<<3) | (((c->A[2]>>3)&1)<<2) | (((c->A[4]>>2)&1)<<1) | (((c->A[8]>>0)&1)<<0) ]; 430 | s5 = sbox5[ (((c->A[5]>>2)&1)<<4) | (((c->A[4]>>3)&1)<<3) | (((c->A[6]>>0)&1)<<2) | (((c->A[8]>>1)&1)<<1) | (((c->A[9]>>2)&1)<<0) ]; 431 | s6 = sbox6[ (((c->A[3]>>1)&1)<<4) | (((c->A[4]>>1)&1)<<3) | (((c->A[5]>>0)&1)<<2) | (((c->A[7]>>2)&1)<<1) | (((c->A[9]>>3)&1)<<0) ]; 432 | s7 = sbox7[ (((c->A[2]>>2)&1)<<4) | (((c->A[3]>>0)&1)<<3) | (((c->A[7]>>1)&1)<<2) | (((c->A[8]>>2)&1)<<1) | (((c->A[8]>>3)&1)<<0) ]; 433 | 434 | /* use 4x4 xor to produce extra nibble for T3 */ 435 | extra_B = ( ((c->B[3]&1)<<3) ^ ((c->B[6]&2)<<2) ^ ((c->B[7]&4)<<1) ^ ((c->B[9]&8)>>0) ) | 436 | ( ((c->B[6]&1)<<2) ^ ((c->B[8]&2)<<1) ^ ((c->B[3]&8)>>1) ^ ((c->B[4]&4)>>0) ) | 437 | ( ((c->B[5]&8)>>2) ^ ((c->B[8]&4)>>1) ^ ((c->B[4]&1)<<1) ^ ((c->B[5]&2)>>0) ) | 438 | ( ((c->B[9]&4)>>2) ^ ((c->B[6]&8)>>3) ^ ((c->B[3]&2)>>1) ^ ((c->B[8]&1)>>0) ) ; 439 | 440 | // T1 = xor all inputs 441 | // in1,in2, D are only used in T1 during initialisation, not generation 442 | next_A1 = c->A[10] ^ c->X; 443 | if( b_init ) next_A1 = next_A1 ^ c->D ^ ((j % 2) ? in2 : in1); 444 | 445 | // T2 = xor all inputs 446 | // in1,in2 are only used in T1 during initialisation, not generation 447 | // if p=0, use this, if p=1, rotate the result left 448 | next_B1 = c->B[7] ^ c->B[10] ^ c->Y; 449 | if( b_init) next_B1 = next_B1 ^ ((j % 2) ? in1 : in2); 450 | 451 | // if p=1, rotate left 452 | if( c->p ) next_B1 = ( (next_B1 << 1) | ((next_B1 >> 3) & 1) ) & 0xf; 453 | 454 | // T3 = xor all inputs 455 | c->D = c->E ^ c->Z ^ extra_B; 456 | 457 | // T4 = sum, carry of Z + E + r 458 | next_E = c->F; 459 | if( c->q ) 460 | { 461 | c->F = c->Z + c->E + c->r; 462 | // r is the carry 463 | c->r = (c->F >> 4) & 1; 464 | c->F = c->F & 0x0f; 465 | } 466 | else 467 | { 468 | c->F = c->E; 469 | } 470 | c->E = next_E; 471 | 472 | for( k = 10; k > 1; k-- ) 473 | { 474 | c->A[k] = c->A[k-1]; 475 | c->B[k] = c->B[k-1]; 476 | } 477 | c->A[1] = next_A1; 478 | c->B[1] = next_B1; 479 | 480 | c->X = ((s4&1)<<3) | ((s3&1)<<2) | (s2&2) | ((s1&2)>>1); 481 | c->Y = ((s6&1)<<3) | ((s5&1)<<2) | (s4&2) | ((s3&2)>>1); 482 | c->Z = ((s2&1)<<3) | ((s1&1)<<2) | (s6&2) | ((s5&2)>>1); 483 | c->p = (s7&2)>>1; 484 | c->q = (s7&1); 485 | 486 | // require 4 loops per output byte 487 | // 2 output bits are a function of the 4 bits of D 488 | // xor 2 by 2 489 | op = (op << 2)^ ( (((c->D^(c->D>>1))>>1)&2) | ((c->D^(c->D>>1))&1) ); 490 | } 491 | // return input data during init 492 | cb[i] = b_init ? sb[i] : op; 493 | } 494 | } 495 | 496 | 497 | // block - sbox 498 | static const uint8_t block_sbox[256] = 499 | { 500 | 0x3A,0xEA,0x68,0xFE,0x33,0xE9,0x88,0x1A,0x83,0xCF,0xE1,0x7F,0xBA,0xE2,0x38,0x12, 501 | 0xE8,0x27,0x61,0x95,0x0C,0x36,0xE5,0x70,0xA2,0x06,0x82,0x7C,0x17,0xA3,0x26,0x49, 502 | 0xBE,0x7A,0x6D,0x47,0xC1,0x51,0x8F,0xF3,0xCC,0x5B,0x67,0xBD,0xCD,0x18,0x08,0xC9, 503 | 0xFF,0x69,0xEF,0x03,0x4E,0x48,0x4A,0x84,0x3F,0xB4,0x10,0x04,0xDC,0xF5,0x5C,0xC6, 504 | 0x16,0xAB,0xAC,0x4C,0xF1,0x6A,0x2F,0x3C,0x3B,0xD4,0xD5,0x94,0xD0,0xC4,0x63,0x62, 505 | 0x71,0xA1,0xF9,0x4F,0x2E,0xAA,0xC5,0x56,0xE3,0x39,0x93,0xCE,0x65,0x64,0xE4,0x58, 506 | 0x6C,0x19,0x42,0x79,0xDD,0xEE,0x96,0xF6,0x8A,0xEC,0x1E,0x85,0x53,0x45,0xDE,0xBB, 507 | 0x7E,0x0A,0x9A,0x13,0x2A,0x9D,0xC2,0x5E,0x5A,0x1F,0x32,0x35,0x9C,0xA8,0x73,0x30, 508 | 509 | 0x29,0x3D,0xE7,0x92,0x87,0x1B,0x2B,0x4B,0xA5,0x57,0x97,0x40,0x15,0xE6,0xBC,0x0E, 510 | 0xEB,0xC3,0x34,0x2D,0xB8,0x44,0x25,0xA4,0x1C,0xC7,0x23,0xED,0x90,0x6E,0x50,0x00, 511 | 0x99,0x9E,0x4D,0xD9,0xDA,0x8D,0x6F,0x5F,0x3E,0xD7,0x21,0x74,0x86,0xDF,0x6B,0x05, 512 | 0x8E,0x5D,0x37,0x11,0xD2,0x28,0x75,0xD6,0xA7,0x77,0x24,0xBF,0xF0,0xB0,0x02,0xB7, 513 | 0xF8,0xFC,0x81,0x09,0xB1,0x01,0x76,0x91,0x7D,0x0F,0xC8,0xA0,0xF2,0xCB,0x78,0x60, 514 | 0xD1,0xF7,0xE0,0xB5,0x98,0x22,0xB3,0x20,0x1D,0xA6,0xDB,0x7B,0x59,0x9F,0xAE,0x31, 515 | 0xFB,0xD3,0xB6,0xCA,0x43,0x72,0x07,0xF4,0xD8,0x41,0x14,0x55,0x0D,0x54,0x8B,0xB9, 516 | 0xAD,0x46,0x0B,0xAF,0x80,0x52,0x2C,0xFA,0x8C,0x89,0x66,0xFD,0xB2,0xA9,0x9B,0xC0, 517 | }; 518 | 519 | // block - perm 520 | static const uint8_t block_perm[256] = 521 | { 522 | 0x00,0x02,0x80,0x82,0x20,0x22,0xA0,0xA2, 0x10,0x12,0x90,0x92,0x30,0x32,0xB0,0xB2, 523 | 0x04,0x06,0x84,0x86,0x24,0x26,0xA4,0xA6, 0x14,0x16,0x94,0x96,0x34,0x36,0xB4,0xB6, 524 | 0x40,0x42,0xC0,0xC2,0x60,0x62,0xE0,0xE2, 0x50,0x52,0xD0,0xD2,0x70,0x72,0xF0,0xF2, 525 | 0x44,0x46,0xC4,0xC6,0x64,0x66,0xE4,0xE6, 0x54,0x56,0xD4,0xD6,0x74,0x76,0xF4,0xF6, 526 | 0x01,0x03,0x81,0x83,0x21,0x23,0xA1,0xA3, 0x11,0x13,0x91,0x93,0x31,0x33,0xB1,0xB3, 527 | 0x05,0x07,0x85,0x87,0x25,0x27,0xA5,0xA7, 0x15,0x17,0x95,0x97,0x35,0x37,0xB5,0xB7, 528 | 0x41,0x43,0xC1,0xC3,0x61,0x63,0xE1,0xE3, 0x51,0x53,0xD1,0xD3,0x71,0x73,0xF1,0xF3, 529 | 0x45,0x47,0xC5,0xC7,0x65,0x67,0xE5,0xE7, 0x55,0x57,0xD5,0xD7,0x75,0x77,0xF5,0xF7, 530 | 531 | 0x08,0x0A,0x88,0x8A,0x28,0x2A,0xA8,0xAA, 0x18,0x1A,0x98,0x9A,0x38,0x3A,0xB8,0xBA, 532 | 0x0C,0x0E,0x8C,0x8E,0x2C,0x2E,0xAC,0xAE, 0x1C,0x1E,0x9C,0x9E,0x3C,0x3E,0xBC,0xBE, 533 | 0x48,0x4A,0xC8,0xCA,0x68,0x6A,0xE8,0xEA, 0x58,0x5A,0xD8,0xDA,0x78,0x7A,0xF8,0xFA, 534 | 0x4C,0x4E,0xCC,0xCE,0x6C,0x6E,0xEC,0xEE, 0x5C,0x5E,0xDC,0xDE,0x7C,0x7E,0xFC,0xFE, 535 | 0x09,0x0B,0x89,0x8B,0x29,0x2B,0xA9,0xAB, 0x19,0x1B,0x99,0x9B,0x39,0x3B,0xB9,0xBB, 536 | 0x0D,0x0F,0x8D,0x8F,0x2D,0x2F,0xAD,0xAF, 0x1D,0x1F,0x9D,0x9F,0x3D,0x3F,0xBD,0xBF, 537 | 0x49,0x4B,0xC9,0xCB,0x69,0x6B,0xE9,0xEB, 0x59,0x5B,0xD9,0xDB,0x79,0x7B,0xF9,0xFB, 538 | 0x4D,0x4F,0xCD,0xCF,0x6D,0x6F,0xED,0xEF, 0x5D,0x5F,0xDD,0xDF,0x7D,0x7F,0xFD,0xFF, 539 | }; 540 | 541 | static void csa_BlockDecypher( uint8_t kk[57], uint8_t ib[8], uint8_t bd[8] ) 542 | { 543 | int i; 544 | int perm_out; 545 | int R[9]; 546 | int next_R8; 547 | 548 | for( i = 0; i < 8; i++ ) 549 | { 550 | R[i+1] = ib[i]; 551 | } 552 | 553 | // loop over kk[56]..kk[1] 554 | for( i = 56; i > 0; i-- ) 555 | { 556 | const int sbox_out = block_sbox[ kk[i]^R[7] ]; 557 | perm_out = block_perm[sbox_out]; 558 | 559 | next_R8 = R[7]; 560 | R[7] = R[6] ^ perm_out; 561 | R[6] = R[5]; 562 | R[5] = R[4] ^ R[8] ^ sbox_out; 563 | R[4] = R[3] ^ R[8] ^ sbox_out; 564 | R[3] = R[2] ^ R[8] ^ sbox_out; 565 | R[2] = R[1]; 566 | R[1] = R[8] ^ sbox_out; 567 | 568 | R[8] = next_R8; 569 | } 570 | 571 | for( i = 0; i < 8; i++ ) 572 | { 573 | bd[i] = R[i+1]; 574 | } 575 | } 576 | 577 | static void csa_BlockCypher( uint8_t kk[57], uint8_t bd[8], uint8_t ib[8] ) 578 | { 579 | int i; 580 | int perm_out; 581 | int R[9]; 582 | int next_R1; 583 | 584 | for( i = 0; i < 8; i++ ) 585 | { 586 | R[i+1] = bd[i]; 587 | } 588 | 589 | // loop over kk[1]..kk[56] 590 | for( i = 1; i <= 56; i++ ) 591 | { 592 | const int sbox_out = block_sbox[ kk[i]^R[8] ]; 593 | perm_out = block_perm[sbox_out]; 594 | 595 | next_R1 = R[2]; 596 | R[2] = R[3] ^ R[1]; 597 | R[3] = R[4] ^ R[1]; 598 | R[4] = R[5] ^ R[1]; 599 | R[5] = R[6]; 600 | R[6] = R[7] ^ perm_out; 601 | R[7] = R[8]; 602 | R[8] = R[1] ^ sbox_out; 603 | 604 | R[1] = next_R1; 605 | } 606 | 607 | for( i = 0; i < 8; i++ ) 608 | { 609 | ib[i] = R[i+1]; 610 | } 611 | } 612 | 613 | -------------------------------------------------------------------------------- /src/mux/mpeg/csa.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * csa.h 3 | ***************************************************************************** 4 | * Copyright (C) 2004 Laurent Aimar 5 | * $Id: 2e380e73093a52c6d10c401f4a285670052ab2cc $ 6 | * 7 | * Authors: Laurent Aimar 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU Lesser General Public License as published by 11 | * the Free Software Foundation; either version 2.1 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU Lesser General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU Lesser General Public License 20 | * along with this program; if not, write to the Free Software Foundation, 21 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 22 | *****************************************************************************/ 23 | 24 | #ifndef _CSA_H 25 | #define _CSA_H 1 26 | 27 | typedef struct csa_t csa_t; 28 | #define csa_New __csa_New 29 | #define csa_Delete __csa_Delete 30 | #define csa_SetCW __csa_SetCW 31 | #define csa_UseKey __csa_UseKey 32 | #define csa_Decrypt __csa_decrypt 33 | #define csa_Encrypt __csa_encrypt 34 | 35 | csa_t *csa_New( void ); 36 | void csa_Delete( csa_t * ); 37 | 38 | int csa_SetCW( vlc_object_t *p_caller, csa_t *c, char *psz_ck, bool odd ); 39 | int csa_UseKey( vlc_object_t *p_caller, csa_t *, bool use_odd ); 40 | 41 | void csa_Decrypt( csa_t *, uint8_t *pkt, int i_pkt_size ); 42 | void csa_Encrypt( csa_t *, uint8_t *pkt, int i_pkt_size ); 43 | 44 | #endif /* _CSA_H */ 45 | -------------------------------------------------------------------------------- /src/mux/mpeg/dvbpsi_compat.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dvbpsi_compat.h: Compatibility headerfile 3 | ***************************************************************************** 4 | * Copyright (C) 2013 VideoLAN Association 5 | * 6 | * Authors: Jean-Paul Saman 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this program; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 21 | *****************************************************************************/ 22 | 23 | #ifndef DVBPSI_COMPAT_H 24 | #define DVBPSI_COMPAT_H 25 | 26 | /* 27 | * dvbpsi compatibility macros: 28 | * dvbpsi version 1.0.0 and above returns a struct 'dvbpsi_t' as handle 29 | */ 30 | #define DVBPSI_VERSION_WANTED(major,minor,bugfix) (((major)<<16)+((minor)<<8)+(bugfix)) 31 | 32 | #if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0)) 33 | # define dvbpsi_handle dvbpsi_t* 34 | # define dvbpsi_PushPacket(handle,data) dvbpsi_packet_push((handle),(data)) 35 | /* PAT */ 36 | # define dvbpsi_InitPAT(pat,id,version,next) dvbpsi_pat_init((pat),(id),(version),(bool)(next)) 37 | # define dvbpsi_PATAddProgram(pat,nr,pid) dvbpsi_pat_program_add((pat),(nr),(pid)) 38 | # define dvbpsi_EmptyPAT(pat) dvbpsi_pat_empty((pat)) 39 | # define dvbpsi_DeletePAT(table) dvbpsi_pat_delete((table)) 40 | # define dvbpsi_DetachPAT(pat) dvbpsi_pat_detach((pat)) 41 | /* PMT */ 42 | # define dvbpsi_InitPMT(pmt,program,version,next,pcr) \ 43 | dvbpsi_pmt_init((pmt),(program),(version),(bool)(next),(pcr)) 44 | # define dvbpsi_PMTAddDescriptor(pmt,tag,length,data) \ 45 | dvbpsi_pmt_descriptor_add((pmt),(tag),(length),(data)) 46 | # define dvbpsi_PMTAddES(pmt,type,pid) \ 47 | dvbpsi_pmt_es_add((pmt),(type),(pid)) 48 | # define dvbpsi_PMTESAddDescriptor(es,tag,length,data) \ 49 | dvbpsi_pmt_es_descriptor_add((es),(tag),(length),(data)) 50 | # define dvbpsi_EmptyPMT(pmt) dvbpsi_pmt_empty((pmt)) 51 | # define dvbpsi_DeletePMT(table) dvbpsi_pmt_delete((table)) 52 | # define dvbpsi_DetachPMT(pmt) dvbpsi_pmt_detach((pmt)) 53 | /* SDT */ 54 | # define dvbpsi_InitSDT(sdt,id,version,curnext,netid) \ 55 | dvbpsi_sdt_init((sdt),(id),(0),(version),(bool)(curnext),(netid)) 56 | # define dvbpsi_SDTAddService(sdt,id,schedule,present,status,ca) \ 57 | dvbpsi_sdt_service_add((sdt),(id),(bool)(schedule),(bool)(present),(status),(bool)(ca)) 58 | # define dvbpsi_EmptySDT(sdt) dvbpsi_sdt_empty((sdt)) 59 | # define dvbpsi_DeleteSDT(table) dvbpsi_sdt_delete((table)) 60 | /* TOT */ 61 | # define dvbpsi_DeleteTOT(table) dvbpsi_tot_delete((table)) 62 | /* EIT */ 63 | # define dvbpsi_DeleteEIT(table) dvbpsi_eit_delete((table)) 64 | /* NIT */ 65 | # define dvbpsi_DeleteNIT(table) dvbpsi_nit_delete((table)) 66 | 67 | static inline void dvbpsi_messages(dvbpsi_t *p_dvbpsi, const dvbpsi_msg_level_t level, const char* msg) 68 | { 69 | vlc_object_t *obj = (vlc_object_t *)p_dvbpsi->p_sys; 70 | 71 | /* See dvbpsi.h for the definition of these log levels.*/ 72 | switch(level) 73 | { 74 | case DVBPSI_MSG_ERROR: msg_Err( obj, "%s", msg ); break; 75 | case DVBPSI_MSG_WARN: msg_Warn( obj, "%s", msg ); break; 76 | case DVBPSI_MSG_NONE: 77 | case DVBPSI_MSG_DEBUG: 78 | #ifdef DVBPSI_DEBUG 79 | msg_Dbg( obj, "%s", msg ); 80 | #endif 81 | break; 82 | } 83 | } 84 | #endif 85 | 86 | #endif 87 | --------------------------------------------------------------------------------