Make sure that all readers call their packetizers' flush() function when they run out of data. Make sure that all packetizers' flush() functions call generic_packetizer_c::flush() as well so that this one can save the fact that flush() has been called already.

This commit is contained in:
Moritz Bunkus 2005-06-10 07:12:50 +00:00
parent 0ead02b226
commit 309b6e2cdf
20 changed files with 50 additions and 63 deletions

View File

@ -2157,15 +2157,6 @@ kax_reader_c::add_attachments(KaxAttachments *a) {
}
}
void
kax_reader_c::flush_packetizers() {
uint32_t i;
for (i = 0; i < tracks.size(); i++)
if (tracks[i]->ptzr != -1)
PTZR(tracks[i]->ptzr)->flush();
}
void
kax_reader_c::add_available_track_ids() {
int i;

View File

@ -182,7 +182,6 @@ protected:
virtual void handle_attachments(mm_io_c *io, EbmlElement *l0, int64_t pos);
virtual void handle_chapters(mm_io_c *io, EbmlElement *l0, int64_t pos);
virtual void handle_tags(mm_io_c *io, EbmlElement *l0, int64_t pos);
virtual void flush_packetizers();
};

View File

@ -899,14 +899,6 @@ mpeg_ps_reader_c::read(generic_packetizer_c *,
return FILE_STATUS_DONE;
}
void
mpeg_ps_reader_c::flush_packetizers() {
vector<generic_packetizer_c *>::iterator i;
foreach(i, reader_packetizers)
(*i)->flush();
}
int
mpeg_ps_reader_c::get_progress() {
return 100 * io->getFilePointer() / size;

View File

@ -111,8 +111,6 @@ public:
virtual bool find_next_packet(int &id);
virtual bool find_next_packet_for_id(int id);
virtual void flush_packetizers();
static int probe_file(mm_io_c *io, int64_t size);
};

View File

@ -1060,15 +1060,6 @@ ogm_reader_c::identify() {
}
}
void
ogm_reader_c::flush_packetizers() {
int i;
for (i = 0; i < sdemuxers.size(); i++)
if (sdemuxers[i]->ptzr != -1)
PTZR(sdemuxers[i]->ptzr)->flush();
}
void
ogm_reader_c::handle_stream_comments() {
int i, j, cch;

View File

@ -123,7 +123,6 @@ private:
virtual int read_headers();
virtual void process_header_page(ogg_page *pg);
virtual void process_header_packets(ogm_demuxer_t *dmx);
virtual void flush_packetizers();
virtual void handle_stream_comments();
};

View File

@ -1573,15 +1573,6 @@ qtmp4_reader_c::identify() {
}
}
void
qtmp4_reader_c::flush_packetizers() {
uint32_t i;
for (i = 0; i < demuxers.size(); i++)
if (demuxers[i]->ptzr != -1)
PTZR(demuxers[i]->ptzr)->flush();
}
void
qtmp4_reader_c::add_available_track_ids() {
int i;

View File

@ -210,7 +210,6 @@ protected:
virtual bool parse_esds_atom(mm_mem_io_c &memio, qtmp4_demuxer_ptr &dmx,
int level);
virtual uint32_t read_esds_descr_len(mm_mem_io_c &memio);
virtual void flush_packetizers();
virtual void handle_video_with_bframes(qtmp4_demuxer_ptr &dmx,
int64_t timecode, int64_t duration,

View File

@ -857,15 +857,6 @@ real_reader_c::get_information_from_data() {
file->num_packets_read = 0;
}
void
real_reader_c::flush_packetizers() {
uint32_t i;
for (i = 0; i < demuxers.size(); i++)
if (demuxers[i]->ptzr != -1)
PTZR(demuxers[i]->ptzr)->flush();
}
void
real_reader_c::add_available_track_ids() {
int i;

View File

@ -87,7 +87,6 @@ protected:
virtual void set_dimensions(real_demuxer_t *dmx, unsigned char *buffer,
int size);
virtual void get_information_from_data();
virtual void flush_packetizers();
virtual void deliver_aac_frames(real_demuxer_t *dmx, memory_c &mem);
virtual void queue_audio_frames(real_demuxer_t *dmx, memory_c &mem,
uint64_t timecode, uint32_t flags);

View File

@ -232,7 +232,11 @@ srt_reader_c::read(generic_packetizer_c *,
subs.process(PTZR0);
return subs.empty() ? FILE_STATUS_DONE : FILE_STATUS_MOREDATA;
if (subs.empty()) {
flush_packetizers();
return FILE_STATUS_DONE;
}
return FILE_STATUS_MOREDATA;
}
int

View File

@ -264,7 +264,11 @@ ssa_reader_c::read(generic_packetizer_c *,
subs.process((textsubs_packetizer_c *)PTZR0);
return subs.empty() ? FILE_STATUS_DONE : FILE_STATUS_MOREDATA;
if (subs.empty()) {
flush_packetizers();
return FILE_STATUS_DONE;
}
return FILE_STATUS_MOREDATA;
}
int

View File

@ -156,8 +156,10 @@ tta_reader_c::read(generic_packetizer_c *,
PTZR0->process(new packet_t(mem));
bytes_processed += nread;
if (pos >= seek_points.size())
if (pos >= seek_points.size()) {
PTZR0->flush();
return FILE_STATUS_DONE;
}
return FILE_STATUS_MOREDATA;
}

View File

@ -358,8 +358,11 @@ usf_reader_c::read(generic_packetizer_c *ptzr,
entry.m_start));
++(track->m_current_entry);
if (track->m_entries.end() == track->m_current_entry)
if (track->m_entries.end() == track->m_current_entry) {
PTZR(track->m_ptzr)->flush();
return FILE_STATUS_DONE;
}
return FILE_STATUS_MOREDATA;
}

View File

@ -195,12 +195,10 @@ wav_reader_c::read(generic_packetizer_c *,
bytes_processed += nread;
if (nread != bps) {
if ((nread != bps) || io->eof()) {
PTZR0->flush();
return FILE_STATUS_DONE;
} else if (io->eof())
return FILE_STATUS_DONE;
else
} else
return FILE_STATUS_MOREDATA;
}

View File

@ -130,14 +130,18 @@ wavpack_reader_c::read(generic_packetizer_c *ptzr,
while (dummy_meta.channel_count < meta.channel_count) {
extra_frames_number++;
block_size = wv_parse_frame(io, dummy_header, dummy_meta, false, false);
if (block_size == -1)
if (block_size == -1) {
PTZR0->flush();
return FILE_STATUS_DONE;
}
data_size += block_size;
io->skip(block_size);
}
if (data_size < 0)
if (data_size < 0) {
PTZR0->flush();
return FILE_STATUS_DONE;
}
data_size += 3 * sizeof(uint32_t);
if (extra_frames_number)
@ -162,8 +166,10 @@ wavpack_reader_c::read(generic_packetizer_c *ptzr,
put_uint32_le(databuffer, block_size);
databuffer += 4;
}
if (io->read(databuffer, block_size) < 0)
if (io->read(databuffer, block_size) < 0) {
PTZR0->flush();
return FILE_STATUS_DONE;
}
databuffer += block_size;
}
@ -181,8 +187,10 @@ wavpack_reader_c::read(generic_packetizer_c *ptzr,
extra_frames_number++;
block_size = wv_parse_frame(io_correc, dummy_header_correc,
dummy_meta, false, false);
if (block_size == -1)
if (block_size == -1) {
PTZR0->flush();
return FILE_STATUS_DONE;
}
data_size += block_size;
io_correc->skip(block_size);
}

View File

@ -72,6 +72,7 @@ generic_packetizer_c::generic_packetizer_c(generic_reader_c *nreader,
max_timecode_seen = 0;
default_track_warning_printed = false;
connected_to = 0;
has_been_flushed = false;
// Let's see if the user specified audio sync for this track.
found = false;
@ -1253,6 +1254,14 @@ generic_reader_c::get_queued_bytes() {
return bytes;
}
void
generic_reader_c::flush_packetizers() {
vector<generic_packetizer_c *>::const_iterator it;
foreach(it, reader_packetizers)
(*it)->flush();
}
//
//--------------------------------------------------------------------

View File

@ -381,6 +381,8 @@ public:
virtual int64_t get_queued_bytes();
virtual void flush_packetizers();
protected:
virtual bool demuxing_requested(char type, int64_t id);
};
@ -466,6 +468,8 @@ protected:
int64_t last_cue_timecode;
bool has_been_flushed;
public:
track_info_c ti;
generic_reader_c *reader;
@ -497,6 +501,7 @@ public:
return packet_queue.size();
}
virtual void flush() {
has_been_flushed = true;
}
virtual int64_t get_smallest_timecode() {
return (packet_queue.size() == 0) ? 0x0FFFFFFF :

View File

@ -132,6 +132,8 @@ pcm_packetizer_c::flush() {
bytes_output += size;
buffer.remove(size);
}
generic_packetizer_c::flush();
}
void

View File

@ -360,7 +360,8 @@ mpeg4_p2_video_packetizer_c::process_non_native(packet_cptr packet) {
"native mode.\n");
}
mpeg4_p2_find_frame_types(packet->memory->data, packet->memory->size, frames);
mpeg4_p2_find_frame_types(packet->memory->data, packet->memory->size,
frames);
// Add a timecode and a duration if they've been given.
if (-1 != packet->timecode)
@ -505,6 +506,7 @@ mpeg4_p2_video_packetizer_c::flush_frames() {
void
mpeg4_p2_video_packetizer_c::flush() {
flush_frames();
generic_packetizer_c::flush();
}
void