diff --git a/ChangeLog b/ChangeLog index 287f5bef7..dd2381f12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-02-17 Moritz Bunkus + + * mkvmerge: enhancement: HD-DVD subtitles are recognized as being + an unsupported file format. This makes the error message presented + to the user a bit clearer. Fix for bug 600. + 2011-02-15 Moritz Bunkus * build: Boost 1.36.0 or newer is required (up from 1.34.0). Also diff --git a/src/common/file_types.h b/src/common/file_types.h index bed751c6e..c7bd5f656 100644 --- a/src/common/file_types.h +++ b/src/common/file_types.h @@ -32,6 +32,7 @@ enum file_type_e { FILE_TYPE_DTS, FILE_TYPE_FLAC, FILE_TYPE_FLV, + FILE_TYPE_HDSUB, FILE_TYPE_IVF, FILE_TYPE_MATROSKA, FILE_TYPE_MICRODVD, diff --git a/src/common/hdsub.h b/src/common/hdsub.h new file mode 100644 index 000000000..f3298d20e --- /dev/null +++ b/src/common/hdsub.h @@ -0,0 +1,22 @@ +/* + mkvmerge -- utility for splicing together matroska files + from component media subtypes + + Distributed under the GPL + see the file COPYING for details + or visit http://www.gnu.org/copyleft/gpl.html + + definitions and helper functions for PGS/SUP subtitles + + Written by Moritz Bunkus . +*/ + +#ifndef __MTX_COMMON_PGSSUP_H +#define __MTX_COMMON_PGSSUP_H + +#include "common/os.h" + +#define HDSUB_FILE_MAGIC 0x5350 // "SP" big endian + +#endif // __MTX_COMMON_HDSUB_H + diff --git a/src/input/r_hdsub.cpp b/src/input/r_hdsub.cpp new file mode 100644 index 000000000..85ad8c140 --- /dev/null +++ b/src/input/r_hdsub.cpp @@ -0,0 +1,45 @@ +/* + mkvmerge -- utility for splicing together matroska files + from component media subtypes + + Distributed under the GPL + see the file COPYING for details + or visit http://www.gnu.org/copyleft/gpl.html + + HDSUB demultiplexer module + + Written by Moritz Bunkus . +*/ + +#include "common/common_pch.h" + +#include "common/endian.h" +#include "common/hdsub.h" +#include "input/r_hdsub.h" + +int +hdsub_reader_c::probe_file(mm_io_c *io, + uint64_t size) { + try { + if (2 > size) + return 0; + + unsigned char buf[2]; + + io->setFilePointer(0, seek_beginning); + if (io->read(buf, 2) != 2) + return 0; + io->setFilePointer(0, seek_beginning); + + if (HDSUB_FILE_MAGIC == get_uint16_be(buf)) { + id_result_container_unsupported(io->get_file_name(), "HD-DVD sub"); + // Never reached: + return 1; + } + + return 0; + + } catch (...) { + return 0; + } +} diff --git a/src/input/r_hdsub.h b/src/input/r_hdsub.h new file mode 100644 index 000000000..64996d8c8 --- /dev/null +++ b/src/input/r_hdsub.h @@ -0,0 +1,32 @@ +/* + mkvmerge -- utility for splicing together matroska files + from component media subtypes + + Distributed under the GPL + see the file COPYING for details + or visit http://www.gnu.org/copyleft/gpl.html + + class definitions for the HDSUB demultiplexer module + + Written by Moritz Bunkus . +*/ + +#ifndef __R_HDSUB_H +#define __R_HDSUB_H + +#include "common/common_pch.h" + +#include + +#include "common/error.h" +#include "common/mm_io.h" +#include "merge/pr_generic.h" + +class hdsub_reader_c: public generic_reader_c { +public: + hdsub_reader_c(track_info_c &n_ti): generic_reader_c(n_ti) { }; + + static int probe_file(mm_io_c *in, uint64_t size); +}; + +#endif // __R_HDSUB_H diff --git a/src/merge/output_control.cpp b/src/merge/output_control.cpp index 6201e47ef..358af9191 100644 --- a/src/merge/output_control.cpp +++ b/src/merge/output_control.cpp @@ -84,6 +84,7 @@ #include "input/r_dts.h" #include "input/r_flac.h" #include "input/r_flv.h" +#include "input/r_hdsub.h" #include "input/r_ivf.h" #include "input/r_matroska.h" #include "input/r_mp3.h" @@ -315,6 +316,8 @@ get_file_type(filelist_t &file) { type = FILE_TYPE_CDXA; else if (flv_reader_c::probe_file(io, size)) type = FILE_TYPE_FLV; + else if (hdsub_reader_c::probe_file(io, size)) + type = FILE_TYPE_HDSUB; // File types that can be detected unambiguously else if (avi_reader_c::probe_file(io, size)) type = FILE_TYPE_AVI;