Recognize HD-DVD subtitles as unsupported file types.

This commit is contained in:
Moritz Bunkus 2011-02-17 13:44:09 +01:00
parent 43d0c085d4
commit 79bbaa9185
6 changed files with 109 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2011-02-17 Moritz Bunkus <moritz@bunkus.org>
* 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 <moritz@bunkus.org>
* build: Boost 1.36.0 or newer is required (up from 1.34.0). Also

View File

@ -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,

22
src/common/hdsub.h Normal file
View File

@ -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 <moritz@bunkus.org>.
*/
#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

45
src/input/r_hdsub.cpp Normal file
View File

@ -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 <moritz@bunkus.org>.
*/
#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;
}
}

32
src/input/r_hdsub.h Normal file
View File

@ -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 <moritz@bunkus.org>.
*/
#ifndef __R_HDSUB_H
#define __R_HDSUB_H
#include "common/common_pch.h"
#include <stdio.h>
#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

View File

@ -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;