Ignore empty or "erase only" subtitle packets read from OGM and Matroska files.

This commit is contained in:
Moritz Bunkus 2003-10-28 20:20:54 +00:00
parent 915dd64bdb
commit cfe3500959
4 changed files with 29 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2003-10-28 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge, mkvextract: The Matroska reader and the OGM reader
(mkvmerge) as well as mkvextract will discard empty or 'cleaning
only' subtitle packets as they are appear in OGMs in order to mark
the end of an entry.
2003-10-27 Moritz Bunkus <moritz@bunkus.org>
* mkvmerge: new feature: Added the ability to read timecodes from

View File

@ -514,6 +514,11 @@ static void handle_data(KaxBlock *block, int64_t block_duration,
track->warning_printed = true;
}
buffer[0] = *data.Buffer();
if ((data.Size() < 2) &&
((buffer[0] != ' ') || (buffer[0] != 0) || !iscr(buffer[0])))
break;
// Do the charset conversion.
s = (char *)safemalloc(data.Size() + 1);
memcpy(s, data.Buffer(), data.Size());

View File

@ -1548,17 +1548,21 @@ int kax_reader_c::read(generic_packetizer_c *) {
1);
if ((block_track->type == 's') &&
(block_track->sub_type == 't')) {
char *lines;
if ((re_size > 2) ||
((re_size > 0) && (*re_buffer != ' ') &&
(*re_buffer != 0) && !iscr(*re_buffer))) {
char *lines;
lines = (char *)safemalloc(re_size + 1);
lines[re_size] = 0;
memcpy(lines, re_buffer, re_size);
block_track->packetizer->process((unsigned char *)lines, 0,
(int64_t)last_timecode,
block_duration,
block_bref,
block_fref);
safefree(lines);
lines = (char *)safemalloc(re_size + 1);
lines[re_size] = 0;
memcpy(lines, re_buffer, re_size);
block_track->packetizer->process((unsigned char *)lines, 0,
(int64_t)last_timecode,
block_duration,
block_bref,
block_fref);
safefree(lines);
}
} else
block_track->packetizer->process(re_buffer, re_size,
(int64_t)last_timecode,

View File

@ -565,7 +565,9 @@ void ogm_reader_c::process_page(ogg_page *og) {
} else if (dmx->stype == OGM_STREAM_TYPE_TEXT) {
dmx->units_processed++;
if ((op.bytes - 1 - hdrlen) > 1)
if (((op.bytes - 1 - hdrlen) > 2) ||
((op.packet[hdrlen + 1] != ' ') &&
(op.packet[hdrlen + 1] != 0) && !iscr(op.packet[hdrlen + 1])))
dmx->packetizer->process(&op.packet[hdrlen + 1], op.bytes - 1 -
hdrlen, ogg_page_granulepos(og), lenbytes);