From adeda19e26b1e5fd4a7e75e9deea3feccf28f042 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 4 Dec 2003 14:36:24 +0000 Subject: [PATCH] Converted track_info_t into a class and unified the duplication/freeing of its data. --- src/input/r_aac.cpp | 2 +- src/input/r_aac.h | 2 +- src/input/r_ac3.cpp | 2 +- src/input/r_ac3.h | 2 +- src/input/r_avi.h | 2 +- src/input/r_dts.cpp | 2 +- src/input/r_dts.h | 2 +- src/input/r_flac.cpp | 2 +- src/input/r_flac.h | 2 +- src/input/r_matroska.cpp | 56 ++++---- src/input/r_matroska.h | 2 +- src/input/r_mp3.cpp | 2 +- src/input/r_mp3.h | 2 +- src/input/r_ogm.cpp | 2 +- src/input/r_ogm.h | 2 +- src/input/r_qtmp4.cpp | 2 +- src/input/r_qtmp4.h | 2 +- src/input/r_real.cpp | 2 +- src/input/r_real.h | 2 +- src/input/r_srt.cpp | 2 +- src/input/r_srt.h | 2 +- src/input/r_ssa.cpp | 2 +- src/input/r_ssa.h | 2 +- src/input/r_vobsub.cpp | 2 +- src/input/r_vobsub.h | 2 +- src/input/r_wav.cpp | 2 +- src/input/r_wav.h | 2 +- src/mkvmerge.cpp | 161 ++++++---------------- src/output/p_aac.cpp | 2 +- src/output/p_aac.h | 2 +- src/output/p_ac3.cpp | 4 +- src/output/p_ac3.h | 4 +- src/output/p_dts.cpp | 2 +- src/output/p_dts.h | 2 +- src/output/p_flac.cpp | 2 +- src/output/p_flac.h | 2 +- src/output/p_mp3.cpp | 2 +- src/output/p_mp3.h | 2 +- src/output/p_passthrough.cpp | 2 +- src/output/p_passthrough.h | 2 +- src/output/p_pcm.cpp | 2 +- src/output/p_pcm.h | 2 +- src/output/p_textsubs.cpp | 2 +- src/output/p_textsubs.h | 2 +- src/output/p_video.cpp | 2 +- src/output/p_video.h | 2 +- src/output/p_vobsub.cpp | 2 +- src/output/p_vobsub.h | 2 +- src/output/p_vorbis.cpp | 2 +- src/output/p_vorbis.h | 2 +- src/pr_generic.cpp | 258 ++++++++++++++++++++++------------- src/pr_generic.h | 31 +++-- 52 files changed, 304 insertions(+), 302 deletions(-) diff --git a/src/input/r_aac.cpp b/src/input/r_aac.cpp index e203177c6..236c6672d 100644 --- a/src/input/r_aac.cpp +++ b/src/input/r_aac.cpp @@ -69,7 +69,7 @@ int aac_reader_c::probe_file(mm_io_c *mm_io, int64_t size) { #define INITCHUNKSIZE 16384 #define SINITCHUNKSIZE "16384" -aac_reader_c::aac_reader_c(track_info_t *nti) throw (error_c): +aac_reader_c::aac_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { int adif, i; aac_header_t aacheader; diff --git a/src/input/r_aac.h b/src/input/r_aac.h index a862303cc..62541d309 100644 --- a/src/input/r_aac.h +++ b/src/input/r_aac.h @@ -41,7 +41,7 @@ private: bool emphasis_present; public: - aac_reader_c(track_info_t *nti) throw (error_c); + aac_reader_c(track_info_c *nti) throw (error_c); virtual ~aac_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_ac3.cpp b/src/input/r_ac3.cpp index 63e90bfee..9a7bdefa9 100644 --- a/src/input/r_ac3.cpp +++ b/src/input/r_ac3.cpp @@ -62,7 +62,7 @@ int ac3_reader_c::probe_file(mm_io_c *mm_io, int64_t size) { return 1; } -ac3_reader_c::ac3_reader_c(track_info_t *nti) throw (error_c): +ac3_reader_c::ac3_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { int pos; ac3_header_t ac3header; diff --git a/src/input/r_ac3.h b/src/input/r_ac3.h index 6f4bd66e2..5ecd72ebb 100644 --- a/src/input/r_ac3.h +++ b/src/input/r_ac3.h @@ -40,7 +40,7 @@ private: int64_t bytes_processed, size; public: - ac3_reader_c(track_info_t *nti) throw (error_c); + ac3_reader_c(track_info_c *nti) throw (error_c); virtual ~ac3_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_avi.h b/src/input/r_avi.h index b816dfde0..dd4f6f5b7 100644 --- a/src/input/r_avi.h +++ b/src/input/r_avi.h @@ -72,7 +72,7 @@ private: int video_done, maxframes, is_divx, rederive_keyframes; public: - avi_reader_c(track_info_t *nti) throw (error_c); + avi_reader_c(track_info_c *nti) throw (error_c); virtual ~avi_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_dts.cpp b/src/input/r_dts.cpp index 2678273fd..aec8020c8 100644 --- a/src/input/r_dts.cpp +++ b/src/input/r_dts.cpp @@ -53,7 +53,7 @@ int dts_reader_c::probe_file(mm_io_c *mm_io, int64_t size) { return 1; } -dts_reader_c::dts_reader_c(track_info_t *nti) throw (error_c): +dts_reader_c::dts_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { int pos; dts_header_t dtsheader; diff --git a/src/input/r_dts.h b/src/input/r_dts.h index fa87f2658..3863e7787 100644 --- a/src/input/r_dts.h +++ b/src/input/r_dts.h @@ -40,7 +40,7 @@ private: int64_t bytes_processed, size; public: - dts_reader_c(track_info_t *nti) throw (error_c); + dts_reader_c(track_info_c *nti) throw (error_c); virtual ~dts_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_flac.cpp b/src/input/r_flac.cpp index 3bcc5cb0c..fc927b418 100644 --- a/src/input/r_flac.cpp +++ b/src/input/r_flac.cpp @@ -82,7 +82,7 @@ int flac_reader_c::probe_file(mm_io_c *mm_io, int64_t size) { return 1; } -flac_reader_c::flac_reader_c(track_info_t *nti) throw (error_c): +flac_reader_c::flac_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { unsigned char *buf; uint32_t size; diff --git a/src/input/r_flac.h b/src/input/r_flac.h index e25397d40..c7977e0d8 100644 --- a/src/input/r_flac.h +++ b/src/input/r_flac.h @@ -52,7 +52,7 @@ private: vector::iterator current_block; public: - flac_reader_c(track_info_t *nti) throw (error_c); + flac_reader_c(track_info_c *nti) throw (error_c); virtual ~flac_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_matroska.cpp b/src/input/r_matroska.cpp index 93cf34f5d..8e628b14f 100644 --- a/src/input/r_matroska.cpp +++ b/src/input/r_matroska.cpp @@ -115,7 +115,7 @@ int kax_reader_c::probe_file(mm_io_c *mm_io, int64_t size) { // {{{ C'TOR -kax_reader_c::kax_reader_c(track_info_t *nti) throw (error_c): +kax_reader_c::kax_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { title = ""; @@ -1231,23 +1231,24 @@ int kax_reader_c::read_headers() { void kax_reader_c::create_packetizers() { int i; kax_track_t *t; - track_info_t nti; + track_info_c *nti; for (i = 0; i < tracks.size(); i++) { t = tracks[i]; - memcpy(&nti, ti, sizeof(track_info_t)); - nti.private_data = (unsigned char *)t->private_data; - nti.private_size = t->private_size; - if (nti.default_track == 0) - nti.default_track = t->default_track; - if (nti.language == NULL) - nti.language = t->language; - if (nti.track_name == NULL) - nti.track_name = t->track_name; + nti = new track_info_c(*ti); + nti->private_data = + (unsigned char *)safememdup(t->private_data, t->private_size); + nti->private_size = t->private_size; + if (nti->default_track == 0) + nti->default_track = t->default_track; + if (nti->language == NULL) + nti->language = safestrdup(t->language); + if (nti->track_name == NULL) + nti->track_name = safestrdup(t->track_name); if (t->ok && demuxing_requested(t->type, t->tnum)) { - nti.id = t->tnum; // ID for this track. + nti->id = t->tnum; // ID for this track. switch (t->type) { case 'v': @@ -1257,8 +1258,8 @@ void kax_reader_c::create_packetizers() { t->packetizer = new video_packetizer_c(this, t->codec_id, t->v_frate, t->v_width, t->v_height, - t->v_bframes, &nti); - if (!nti.aspect_ratio_given) { // The user didn't set it. + t->v_bframes, nti); + if (!nti->aspect_ratio_given) { // The user didn't set it. if (t->v_dwidth != 0) t->packetizer->set_video_display_width(t->v_dwidth); if (t->v_dheight != 0) @@ -1271,14 +1272,14 @@ void kax_reader_c::create_packetizers() { t->packetizer = new pcm_packetizer_c(this, (unsigned long)t->a_sfreq, t->a_channels, t->a_bps, - &nti); + nti); if (verbose) mxinfo("+-> Using the PCM output module for track ID %u.\n", t->tnum); } else if (t->a_formattag == 0x0055) { t->packetizer = new mp3_packetizer_c(this, (unsigned long)t->a_sfreq, - t->a_channels, &nti); + t->a_channels, nti); if (verbose) mxinfo("+-> Using the MPEG audio output module for track ID %u." "\n", t->tnum); @@ -1293,7 +1294,7 @@ void kax_reader_c::create_packetizers() { bsid = 0; t->packetizer = new ac3_packetizer_c(this, (unsigned long)t->a_sfreq, - t->a_channels, bsid, &nti); + t->a_channels, bsid, nti); if (verbose) mxinfo("+-> Using the AC3 output module for track ID %u.\n", t->tnum); @@ -1304,7 +1305,7 @@ void kax_reader_c::create_packetizers() { /* t->packetizer = new dts_packetizer_c(this, (unsigned long)t->a_sfreq, - &nti); + nti); */ } else if (t->a_formattag == 0xFFFE) { t->packetizer = new vorbis_packetizer_c(this, @@ -1313,7 +1314,7 @@ void kax_reader_c::create_packetizers() { t->headers[1], t->header_sizes[1], t->headers[2], - t->header_sizes[2], &nti); + t->header_sizes[2], nti); if (verbose) mxinfo("+-> Using the Vorbis output module for track ID %u.\n", t->tnum); @@ -1355,7 +1356,7 @@ void kax_reader_c::create_packetizers() { t->packetizer = new aac_packetizer_c(this, id, profile, (unsigned long)t->a_sfreq, - t->a_channels, &nti, + t->a_channels, nti, false, true); if (verbose) mxinfo("+-> Using the AAC output module for track ID %u.\n", @@ -1382,14 +1383,15 @@ void kax_reader_c::create_packetizers() { #if defined(HAVE_FLAC_FORMAT_H) } else if ((t->a_formattag == FOURCC('f', 'L', 'a', 'C')) || (t->a_formattag == 0xf1ac)) { - nti.private_data = NULL; - nti.private_size = 0; + safefree(nti->private_data); + nti->private_data = NULL; + nti->private_size = 0; if (t->a_formattag == FOURCC('f', 'L', 'a', 'C')) t->packetizer = new flac_packetizer_c(this, (int)t->a_sfreq, t->a_channels, t->a_bps, (unsigned char *)t->private_data, - t->private_size, &nti); + t->private_size, nti); else t->packetizer = new flac_packetizer_c(this, (int)t->a_sfreq, t->a_channels, @@ -1397,7 +1399,7 @@ void kax_reader_c::create_packetizers() { ((unsigned char *)t->private_data) + sizeof(alWAVEFORMATEX), t->private_size - sizeof(alWAVEFORMATEX), - &nti); + nti); if (verbose) mxinfo("+-> Using the FLAC output module for track ID %u.\n", t->tnum); @@ -1416,7 +1418,7 @@ void kax_reader_c::create_packetizers() { if (!strcmp(t->codec_id, MKV_S_VOBSUB)) { t->packetizer = new vobsub_packetizer_c(this, t->private_data, t->private_size, - false, &nti); + false, nti); if (verbose) mxinfo("+-> Using the VobSub output module for track ID %u.\n", t->tnum); @@ -1427,7 +1429,7 @@ void kax_reader_c::create_packetizers() { t->packetizer = new textsubs_packetizer_c(this, t->codec_id, t->private_data, t->private_size, false, - true, &nti); + true, nti); if (verbose) mxinfo("+-> Using the text subtitle output module for track ID " "%u.\n", t->tnum); @@ -1446,6 +1448,8 @@ void kax_reader_c::create_packetizers() { "UID %u because it is already allocated for the new " "file.\n", t->tuid); } + + delete nti; } if (segment_title.length() == 0) diff --git a/src/input/r_matroska.h b/src/input/r_matroska.h index 84d52d247..f6f2ac0e6 100644 --- a/src/input/r_matroska.h +++ b/src/input/r_matroska.h @@ -123,7 +123,7 @@ private: vector attachments; public: - kax_reader_c(track_info_t *nti) throw (error_c); + kax_reader_c(track_info_c *nti) throw (error_c); virtual ~kax_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_mp3.cpp b/src/input/r_mp3.cpp index ce855d483..3955f320a 100644 --- a/src/input/r_mp3.cpp +++ b/src/input/r_mp3.cpp @@ -68,7 +68,7 @@ int mp3_reader_c::probe_file(mm_io_c *mm_io, int64_t size) { return 1; } -mp3_reader_c::mp3_reader_c(track_info_t *nti) throw (error_c): +mp3_reader_c::mp3_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { int pos, ptr, buf_size; unsigned char buf[16384]; diff --git a/src/input/r_mp3.h b/src/input/r_mp3.h index c55513cc3..c07ab90b2 100644 --- a/src/input/r_mp3.h +++ b/src/input/r_mp3.h @@ -40,7 +40,7 @@ private: mp3_header_t mp3header; public: - mp3_reader_c(track_info_t *nti) throw (error_c); + mp3_reader_c(track_info_c *nti) throw (error_c); virtual ~mp3_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_ogm.cpp b/src/input/r_ogm.cpp index b480bbea0..54ab48d4e 100644 --- a/src/input/r_ogm.cpp +++ b/src/input/r_ogm.cpp @@ -234,7 +234,7 @@ int ogm_reader_c::probe_file(mm_io_c *mm_io, int64_t size) { * Opens the file for processing, initializes an ogg_sync_state used for * reading from an OGG stream. */ -ogm_reader_c::ogm_reader_c(track_info_t *nti) throw (error_c): +ogm_reader_c::ogm_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { try { diff --git a/src/input/r_ogm.h b/src/input/r_ogm.h index 924784925..1fd5dd263 100644 --- a/src/input/r_ogm.h +++ b/src/input/r_ogm.h @@ -103,7 +103,7 @@ private: int64_t file_size; public: - ogm_reader_c(track_info_t *nti) throw (error_c); + ogm_reader_c(track_info_c *nti) throw (error_c); virtual ~ogm_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_qtmp4.cpp b/src/input/r_qtmp4.cpp index c4c31f4d2..6b002aa53 100644 --- a/src/input/r_qtmp4.cpp +++ b/src/input/r_qtmp4.cpp @@ -80,7 +80,7 @@ int qtmp4_reader_c::probe_file(mm_io_c *in, int64_t size) { return 0; } -qtmp4_reader_c::qtmp4_reader_c(track_info_t *nti) throw (error_c) : +qtmp4_reader_c::qtmp4_reader_c(track_info_c *nti) throw (error_c) : generic_reader_c(nti) { try { io = new mm_io_c(ti->fname, MODE_READ); diff --git a/src/input/r_qtmp4.h b/src/input/r_qtmp4.h index 04275a3d3..516a23a0b 100644 --- a/src/input/r_qtmp4.h +++ b/src/input/r_qtmp4.h @@ -120,7 +120,7 @@ private: int main_dmx; public: - qtmp4_reader_c(track_info_t *nti) throw (error_c); + qtmp4_reader_c(track_info_c *nti) throw (error_c); virtual ~qtmp4_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_real.cpp b/src/input/r_real.cpp index ec516df7d..534b72e42 100644 --- a/src/input/r_real.cpp +++ b/src/input/r_real.cpp @@ -140,7 +140,7 @@ int real_reader_c::probe_file(mm_io_c *io, int64_t size) { // {{{ C'TOR -real_reader_c::real_reader_c(track_info_t *nti) throw (error_c): +real_reader_c::real_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { try { diff --git a/src/input/r_real.h b/src/input/r_real.h index 390ceacd9..d61340aff 100644 --- a/src/input/r_real.h +++ b/src/input/r_real.h @@ -72,7 +72,7 @@ private: bool done; public: - real_reader_c(track_info_t *nti) throw (error_c); + real_reader_c(track_info_c *nti) throw (error_c); virtual ~real_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_srt.cpp b/src/input/r_srt.cpp index 8cde13304..12db5b372 100644 --- a/src/input/r_srt.cpp +++ b/src/input/r_srt.cpp @@ -65,7 +65,7 @@ int srt_reader_c::probe_file(mm_text_io_c *mm_io, int64_t) { return 1; } -srt_reader_c::srt_reader_c(track_info_t *nti) throw (error_c): +srt_reader_c::srt_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { bool is_utf8; diff --git a/src/input/r_srt.h b/src/input/r_srt.h index 73344683a..ee820d5f2 100644 --- a/src/input/r_srt.h +++ b/src/input/r_srt.h @@ -38,7 +38,7 @@ private: int act_wchar; public: - srt_reader_c(track_info_t *nti) throw (error_c); + srt_reader_c(track_info_c *nti) throw (error_c); virtual ~srt_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_ssa.cpp b/src/input/r_ssa.cpp index 182e1f71d..eafc89e8f 100644 --- a/src/input/r_ssa.cpp +++ b/src/input/r_ssa.cpp @@ -62,7 +62,7 @@ int ssa_reader_c::probe_file(mm_text_io_c *mm_io, int64_t size) { return 1; } -ssa_reader_c::ssa_reader_c(track_info_t *nti) throw (error_c): +ssa_reader_c::ssa_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { string line, global; int64_t old_pos; diff --git a/src/input/r_ssa.h b/src/input/r_ssa.h index 80177346a..5daa0eb21 100644 --- a/src/input/r_ssa.h +++ b/src/input/r_ssa.h @@ -45,7 +45,7 @@ private: int cc_utf8; public: - ssa_reader_c(track_info_t *nti) throw (error_c); + ssa_reader_c(track_info_c *nti) throw (error_c); virtual ~ssa_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_vobsub.cpp b/src/input/r_vobsub.cpp index f62906a58..29c3d822e 100644 --- a/src/input/r_vobsub.cpp +++ b/src/input/r_vobsub.cpp @@ -85,7 +85,7 @@ int vobsub_reader_c::probe_file(mm_io_c *mm_io, int64_t size) { return 1; } -vobsub_reader_c::vobsub_reader_c(track_info_t *nti) throw (error_c): +vobsub_reader_c::vobsub_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { string sub_name, line; int len; diff --git a/src/input/r_vobsub.h b/src/input/r_vobsub.h index 894a66493..d523e1bb8 100644 --- a/src/input/r_vobsub.h +++ b/src/input/r_vobsub.h @@ -61,7 +61,7 @@ private: vector tracks; public: - vobsub_reader_c(track_info_t *nti) throw (error_c); + vobsub_reader_c(track_info_c *nti) throw (error_c); virtual ~vobsub_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/input/r_wav.cpp b/src/input/r_wav.cpp index fd9f1fbac..c5d4905bb 100644 --- a/src/input/r_wav.cpp +++ b/src/input/r_wav.cpp @@ -111,7 +111,7 @@ int wav_reader_c::probe_file(mm_io_c *mm_io, int64_t size) { return 1; } -wav_reader_c::wav_reader_c(track_info_t *nti) throw (error_c): +wav_reader_c::wav_reader_c(track_info_c *nti) throw (error_c): generic_reader_c(nti) { int64_t size; diff --git a/src/input/r_wav.h b/src/input/r_wav.h index 0fdbb652e..d3180ceb1 100644 --- a/src/input/r_wav.h +++ b/src/input/r_wav.h @@ -50,7 +50,7 @@ private: bool is_dts; public: - wav_reader_c(track_info_t *nti) throw (error_c); + wav_reader_c(track_info_c *nti) throw (error_c); virtual ~wav_reader_c(); virtual int read(generic_packetizer_c *ptzr); diff --git a/src/mkvmerge.cpp b/src/mkvmerge.cpp index c8a218be4..cad7e1251 100644 --- a/src/mkvmerge.cpp +++ b/src/mkvmerge.cpp @@ -110,7 +110,7 @@ typedef struct filelist_tag { generic_reader_c *reader; - track_info_t *ti; + track_info_c *ti; } filelist_t; typedef struct { @@ -636,7 +636,7 @@ static void parse_sync(char *s, audio_sync_t &async, const char *opt) { async.displacement = atoi(s); } -static void parse_aspect_ratio(char *s, const char *opt, track_info_t &ti) { +static void parse_aspect_ratio(char *s, const char *opt, track_info_c &ti) { char *div, *c; float w, h; string orig = s; @@ -678,7 +678,7 @@ static void parse_aspect_ratio(char *s, const char *opt, track_info_t &ti) { ti.display_properties->push_back(dprop); } -static void parse_display_dimensions(char *s, track_info_t &ti) { +static void parse_display_dimensions(char *s, track_info_c &ti) { char *x, *c; string orig = s; int w, h; @@ -906,7 +906,7 @@ static void parse_tags(char *s, tags_t &tags, const char *opt) { tags.file_name = s; } -static void parse_fourcc(char *s, const char *opt, track_info_t &ti) { +static void parse_fourcc(char *s, const char *opt, track_info_c &ti) { char *c; string orig = s; fourcc_t fourcc; @@ -1181,27 +1181,9 @@ static void create_readers() { // {{{ FUNCTION identify(const char *filename) static void identify(const char *filename) { - track_info_t ti; + track_info_c ti; filelist_t *file; - memset(&ti, 0, sizeof(track_info_t)); - ti.audio_syncs = new vector; - ti.cue_creations = new vector; - ti.default_track_flags = new vector; - ti.languages = new vector; - ti.sub_charsets = new vector; - ti.all_tags = new vector; - ti.aspect_ratio = 0.0; - ti.atracks = new vector; - ti.vtracks = new vector; - ti.stracks = new vector; - ti.aac_is_sbr = new vector; - ti.compression_list = new vector; - ti.track_names = new vector; - ti.all_ext_timecodes = new vector; - ti.all_fourccs = new vector; - ti.display_properties = new vector; - file = (filelist_t *)safemalloc(sizeof(filelist_t)); file->name = safestrdup(filename); @@ -1217,7 +1199,7 @@ static void identify(const char *filename) { file->fp = NULL; file->status = EMOREDATA; file->pack = NULL; - file->ti = duplicate_track_info(&ti); + file->ti = new track_info_c(ti); files.push_back(file); @@ -1233,7 +1215,7 @@ static void identify(const char *filename) { // {{{ FUNCTION parse_args(int argc, char **argv) static void parse_args(int argc, char **argv) { - track_info_t ti; + track_info_c *ti; int i, j, cc_command_line; filelist_t *file; char *s, *this_arg, *next_arg; @@ -1245,23 +1227,7 @@ static void parse_args(int argc, char **argv) { tags_t tags; mm_io_c *io; - memset(&ti, 0, sizeof(track_info_t)); - ti.audio_syncs = new vector; - ti.cue_creations = new vector; - ti.default_track_flags = new vector; - ti.languages = new vector; - ti.sub_charsets = new vector; - ti.all_tags = new vector; - ti.aac_is_sbr = new vector; - ti.aspect_ratio = 0.0; - ti.atracks = new vector; - ti.vtracks = new vector; - ti.stracks = new vector; - ti.compression_list = new vector; - ti.track_names = new vector; - ti.all_ext_timecodes = new vector; - ti.all_fourccs = new vector; - ti.display_properties = new vector; + ti = new track_info_c; attachment = (attachment_t *)safemalloc(sizeof(attachment_t)); memset(attachment, 0, sizeof(attachment_t)); memset(&tags, 0, sizeof(tags_t)); @@ -1607,13 +1573,13 @@ static void parse_args(int argc, char **argv) { i++; } else if (!strcmp(this_arg, "--no-chapters")) { - ti.no_chapters = true; + ti->no_chapters = true; } else if (!strcmp(this_arg, "--no-attachments")) { - ti.no_attachments = true; + ti->no_attachments = true; } else if (!strcmp(this_arg, "--no-tags")) { - ti.no_tags = true; + ti->no_tags = true; } else if (!strcmp(this_arg, "--dump-packets")) { if (next_arg == NULL) @@ -1633,54 +1599,54 @@ static void parse_args(int argc, char **argv) { // Options that apply to the next input file only. else if (!strcmp(this_arg, "-A") || !strcmp(this_arg, "--noaudio")) - ti.no_audio = true; + ti->no_audio = true; else if (!strcmp(this_arg, "-D") || !strcmp(this_arg, "--novideo")) - ti.no_video = true; + ti->no_video = true; else if (!strcmp(this_arg, "-S") || !strcmp(this_arg, "--nosubs")) - ti.no_subs = true; + ti->no_subs = true; else if (!strcmp(this_arg, "-a") || !strcmp(this_arg, "--atracks")) { if (next_arg == NULL) mxerror("'%s' lacks the stream number(s).\n", this_arg); - parse_tracks(next_arg, ti.atracks, this_arg); + parse_tracks(next_arg, ti->atracks, this_arg); i++; } else if (!strcmp(this_arg, "-d") || !strcmp(this_arg, "--vtracks")) { if (next_arg == NULL) mxerror("'%s' lacks the stream number(s).\n", this_arg); - parse_tracks(next_arg, ti.vtracks, this_arg); + parse_tracks(next_arg, ti->vtracks, this_arg); i++; } else if (!strcmp(this_arg, "-s") || !strcmp(this_arg, "--stracks")) { if (next_arg == NULL) mxerror("'%s' lacks the stream number(s).\n", this_arg); - parse_tracks(next_arg, ti.stracks, this_arg); + parse_tracks(next_arg, ti->stracks, this_arg); i++; } else if (!strcmp(this_arg, "-f") || !strcmp(this_arg, "--fourcc")) { if (next_arg == NULL) mxerror("'%s' lacks the FourCC.\n", this_arg); - parse_fourcc(next_arg, this_arg, ti); + parse_fourcc(next_arg, this_arg, *ti); i++; } else if (!strcmp(this_arg, "--aspect-ratio")) { if (next_arg == NULL) mxerror("'--aspect-ratio' lacks the aspect ratio.\n"); - parse_aspect_ratio(next_arg, this_arg, ti); + parse_aspect_ratio(next_arg, this_arg, *ti); i++; } else if (!strcmp(this_arg, "--display-dimensions")) { if (next_arg == NULL) mxerror("'--display-dimensions' lacks the dimensions.\n"); - parse_display_dimensions(next_arg, ti); + parse_display_dimensions(next_arg, *ti); i++; } else if (!strcmp(this_arg, "-y") || !strcmp(this_arg, "--sync")) { @@ -1688,7 +1654,7 @@ static void parse_args(int argc, char **argv) { mxerror("'%s' lacks the audio delay.\n", this_arg); parse_sync(next_arg, async, this_arg); - ti.audio_syncs->push_back(async); + ti->audio_syncs->push_back(async); i++; } else if (!strcmp(this_arg, "--cues")) { @@ -1696,7 +1662,7 @@ static void parse_args(int argc, char **argv) { mxerror("'--cues' lacks its argument.\n"); parse_cues(next_arg, cues); - ti.cue_creations->push_back(cues); + ti->cue_creations->push_back(cues); i++; } else if (!strcmp(this_arg, "--default-track")) { @@ -1707,7 +1673,7 @@ static void parse_args(int argc, char **argv) { mxerror("Invalid track ID specified in '%s %s'.\n", this_arg, next_arg); - ti.default_track_flags->push_back(id); + ti->default_track_flags->push_back(id); i++; } else if (!strcmp(this_arg, "--language")) { @@ -1715,7 +1681,7 @@ static void parse_args(int argc, char **argv) { mxerror("'--language' lacks its argument.\n"); parse_language(next_arg, lang, "language", "language", true); - ti.languages->push_back(lang); + ti->languages->push_back(lang); i++; } else if (!strcmp(this_arg, "--sub-charset")) { @@ -1723,7 +1689,7 @@ static void parse_args(int argc, char **argv) { mxerror("'--sub-charset' lacks its argument.\n"); parse_sub_charset(next_arg, lang); - ti.sub_charsets->push_back(lang); + ti->sub_charsets->push_back(lang); i++; } else if (!strcmp(this_arg, "-t") || !strcmp(this_arg, "--tags")) { @@ -1731,7 +1697,7 @@ static void parse_args(int argc, char **argv) { mxerror("'%s' lacks its argument.\n", this_arg); parse_tags(next_arg, tags, this_arg); - ti.all_tags->push_back(tags); + ti->all_tags->push_back(tags); i++; } else if (!strcmp(this_arg, "--aac-is-sbr")) { @@ -1742,7 +1708,7 @@ static void parse_args(int argc, char **argv) { mxerror("Invalid track ID specified in '%s %s'.\n", this_arg, next_arg); - ti.aac_is_sbr->push_back(id); + ti->aac_is_sbr->push_back(id); i++; } else if (!strcmp(this_arg, "--compression")) { @@ -1750,7 +1716,7 @@ static void parse_args(int argc, char **argv) { mxerror("'--compression' lacks its argument.\n"); parse_compression(next_arg, cues); - ti.compression_list->push_back(cues); + ti->compression_list->push_back(cues); i++; } else if (!strcmp(this_arg, "--track-name")) { @@ -1759,7 +1725,7 @@ static void parse_args(int argc, char **argv) { parse_language(next_arg, lang, "track-name", "track name", false); lang.language = to_utf8(cc_command_line, lang.language); - ti.track_names->push_back(lang); + ti->track_names->push_back(lang); i++; } else if (!strcmp(this_arg, "--timecodes")) { @@ -1767,27 +1733,27 @@ static void parse_args(int argc, char **argv) { mxerror("'--timecodes' lacks its argument.\n"); parse_language(next_arg, lang, "timecodes", "timecodes", false); - ti.all_ext_timecodes->push_back(lang); + ti->all_ext_timecodes->push_back(lang); i++; } // The argument is an input file. else { - if ((ti.atracks->size() != 0) && ti.no_audio) + if ((ti->atracks->size() != 0) && ti->no_audio) mxerror("'-A' and '-a' used on the same source file.\n"); - if ((ti.vtracks->size() != 0) && ti.no_video) + if ((ti->vtracks->size() != 0) && ti->no_video) mxerror("'-D' and '-d' used on the same source file.\n"); - if ((ti.stracks->size() != 0) && ti.no_subs) + if ((ti->stracks->size() != 0) && ti->no_subs) mxerror("'-S' and '-s' used on the same source file.\n"); file = (filelist_t *)safemalloc(sizeof(filelist_t)); - file->name = this_arg; + file->name = safestrdup(this_arg); file->type = get_type(file->name); - ti.fname = this_arg; + ti->fname = safestrdup(this_arg); if (file->type == TYPEUNKNOWN) mxerror("File '%s' has unknown type. Please have a look " @@ -1799,46 +1765,13 @@ static void parse_args(int argc, char **argv) { if (file->type != TYPECHAPTERS) { file->status = EMOREDATA; file->pack = NULL; - file->ti = duplicate_track_info(&ti); + file->ti = ti; files.push_back(file); } else safefree(file); - delete ti.atracks; - delete ti.vtracks; - delete ti.stracks; - delete ti.audio_syncs; - delete ti.cue_creations; - delete ti.default_track_flags; - delete ti.languages; - delete ti.sub_charsets; - delete ti.all_tags; - delete ti.aac_is_sbr; - delete ti.compression_list; - for (j = 0; j < ti.track_names->size(); j++) - safefree((*ti.track_names)[j].language); - delete ti.track_names; - delete ti.all_ext_timecodes; - delete ti.all_fourccs; - delete ti.display_properties; - memset(&ti, 0, sizeof(track_info_t)); - ti.audio_syncs = new vector; - ti.cue_creations = new vector; - ti.default_track_flags = new vector; - ti.languages = new vector; - ti.sub_charsets = new vector; - ti.all_tags = new vector; - ti.aac_is_sbr = new vector; - ti.aspect_ratio = 0.0; - ti.atracks = new vector; - ti.vtracks = new vector; - ti.stracks = new vector; - ti.compression_list = new vector; - ti.track_names = new vector; - ti.all_ext_timecodes = new vector; - ti.all_fourccs = new vector; - ti.display_properties = new vector; + ti = new track_info_c; } } @@ -1862,23 +1795,7 @@ static void parse_args(int argc, char **argv) { attachment_sizes_others += attachments[i]->size; } - delete ti.audio_syncs; - delete ti.cue_creations; - delete ti.default_track_flags; - delete ti.languages; - delete ti.sub_charsets; - delete ti.all_tags; - delete ti.aac_is_sbr; - delete ti.atracks; - delete ti.vtracks; - delete ti.stracks; - delete ti.compression_list; - for (j = 0; j < ti.track_names->size(); j++) - safefree((*ti.track_names)[j].language); - delete ti.track_names; - delete ti.all_ext_timecodes; - delete ti.all_fourccs; - delete ti.display_properties; + delete ti; safefree(attachment); } @@ -2013,7 +1930,7 @@ static void cleanup() { while (files.size()) { file = files[files.size() - 1]; - free_track_info(file->ti); + delete file->ti; safefree(file); files.pop_back(); } diff --git a/src/output/p_aac.cpp b/src/output/p_aac.cpp index 26b7150c8..7563c1f34 100644 --- a/src/output/p_aac.cpp +++ b/src/output/p_aac.cpp @@ -34,7 +34,7 @@ using namespace libmatroska; aac_packetizer_c::aac_packetizer_c(generic_reader_c *nreader, int nid, int nprofile, unsigned long nsamples_per_sec, - int nchannels, track_info_t *nti, + int nchannels, track_info_c *nti, bool nemphasis_present, bool nheaderless) throw (error_c): generic_packetizer_c(nreader, nti) { diff --git a/src/output/p_aac.h b/src/output/p_aac.h index e495b975c..b7f650bac 100644 --- a/src/output/p_aac.h +++ b/src/output/p_aac.h @@ -48,7 +48,7 @@ private: public: aac_packetizer_c(generic_reader_c *nreader, int nid, int nprofile, unsigned long nsamples_per_sec, int nchannels, - track_info_t *nti, bool emphasis_present, + track_info_c *nti, bool emphasis_present, bool nheaderless = false) throw (error_c); virtual ~aac_packetizer_c(); diff --git a/src/output/p_ac3.cpp b/src/output/p_ac3.cpp index e91a48ff3..e728a1dec 100644 --- a/src/output/p_ac3.cpp +++ b/src/output/p_ac3.cpp @@ -33,7 +33,7 @@ using namespace libmatroska; ac3_packetizer_c::ac3_packetizer_c(generic_reader_c *nreader, unsigned long nsamples_per_sec, - int nchannels, int nbsid, track_info_t *nti) + int nchannels, int nbsid, track_info_c *nti) throw (error_c): generic_packetizer_c(nreader, nti) { packetno = 0; bytes_output = 0; @@ -159,7 +159,7 @@ void ac3_packetizer_c::dump_debug_info() { ac3_bs_packetizer_c::ac3_bs_packetizer_c(generic_reader_c *nreader, unsigned long nsamples_per_sec, int nchannels, int nbsid, - track_info_t *nti) + track_info_c *nti) throw (error_c): ac3_packetizer_c(nreader, nsamples_per_sec, nchannels, nbsid, nti) { bsb_present = false; diff --git a/src/output/p_ac3.h b/src/output/p_ac3.h index dfa460efa..03b320041 100644 --- a/src/output/p_ac3.h +++ b/src/output/p_ac3.h @@ -37,7 +37,7 @@ protected: public: ac3_packetizer_c(generic_reader_c *nreader, unsigned long nsamples_per_sec, - int nchannels, int nbsid, track_info_t *nti) + int nchannels, int nbsid, track_info_c *nti) throw (error_c); virtual ~ac3_packetizer_c(); @@ -62,7 +62,7 @@ protected: public: ac3_bs_packetizer_c(generic_reader_c *nreader, unsigned long nsamples_per_sec, - int nchannels, int nbsid, track_info_t *nti) + int nchannels, int nbsid, track_info_c *nti) throw (error_c); protected: diff --git a/src/output/p_dts.cpp b/src/output/p_dts.cpp index e3f760933..5f6d05198 100644 --- a/src/output/p_dts.cpp +++ b/src/output/p_dts.cpp @@ -86,7 +86,7 @@ bool operator!=(const dts_header_t &l, const dts_header_t &r) { dts_packetizer_c::dts_packetizer_c(generic_reader_c *nreader, const dts_header_t &dtsheader, - track_info_t *nti) + track_info_c *nti) throw (error_c): generic_packetizer_c(nreader, nti) { //packetno = 0; samples_written = 0; diff --git a/src/output/p_dts.h b/src/output/p_dts.h index 8dc72de9c..ae5fe44e9 100644 --- a/src/output/p_dts.h +++ b/src/output/p_dts.h @@ -42,7 +42,7 @@ public: bool skipping_is_normal; dts_packetizer_c(generic_reader_c *nreader, const dts_header_t &dts_header, - track_info_t *nti) throw (error_c); + track_info_c *nti) throw (error_c); virtual ~dts_packetizer_c(); virtual int process(unsigned char *buf, int size, int64_t timecode = -1, diff --git a/src/output/p_flac.cpp b/src/output/p_flac.cpp index 0337fb71b..8a3b42754 100644 --- a/src/output/p_flac.cpp +++ b/src/output/p_flac.cpp @@ -43,7 +43,7 @@ flac_packetizer_c::flac_packetizer_c(generic_reader_c *nreader, int nsample_rate, int nchannels, int nbits_per_sample, unsigned char *nheader, int nl_header, - track_info_t *nti) + track_info_c *nti) throw (error_c): generic_packetizer_c(nreader, nti) { last_timecode = 0; sample_rate = nsample_rate; diff --git a/src/output/p_flac.h b/src/output/p_flac.h index 9253b57cb..7c09e94f0 100644 --- a/src/output/p_flac.h +++ b/src/output/p_flac.h @@ -40,7 +40,7 @@ public: flac_packetizer_c(generic_reader_c *nreader, int nsample_rate, int nchannels, int nbits_per_sample, unsigned char *nheader, int nl_header, - track_info_t *nti) throw (error_c); + track_info_c *nti) throw (error_c); virtual ~flac_packetizer_c(); virtual int process(unsigned char *data, int size, int64_t timecode = -1, diff --git a/src/output/p_mp3.cpp b/src/output/p_mp3.cpp index 10eca21b1..21f51490c 100644 --- a/src/output/p_mp3.cpp +++ b/src/output/p_mp3.cpp @@ -33,7 +33,7 @@ using namespace libmatroska; mp3_packetizer_c::mp3_packetizer_c(generic_reader_c *nreader, unsigned long nsamples_per_sec, - int nchannels, track_info_t *nti) + int nchannels, track_info_c *nti) throw (error_c): generic_packetizer_c(nreader, nti), byte_buffer(128 * 1024) { samples_per_sec = nsamples_per_sec; diff --git a/src/output/p_mp3.h b/src/output/p_mp3.h index 2fad269fb..664d69258 100644 --- a/src/output/p_mp3.h +++ b/src/output/p_mp3.h @@ -37,7 +37,7 @@ private: public: mp3_packetizer_c(generic_reader_c *nreader, unsigned long nsamples_per_sec, - int nchannels, track_info_t *nti) + int nchannels, track_info_c *nti) throw (error_c); virtual ~mp3_packetizer_c(); diff --git a/src/output/p_passthrough.cpp b/src/output/p_passthrough.cpp index c0be5a43e..4533d532d 100644 --- a/src/output/p_passthrough.cpp +++ b/src/output/p_passthrough.cpp @@ -32,7 +32,7 @@ using namespace libmatroska; passthrough_packetizer_c::passthrough_packetizer_c(generic_reader_c *nreader, - track_info_t *nti) + track_info_c *nti) throw (error_c): generic_packetizer_c(nreader, nti) { packets_processed = 0; diff --git a/src/output/p_passthrough.h b/src/output/p_passthrough.h index 8e362fed8..68ba9e82f 100644 --- a/src/output/p_passthrough.h +++ b/src/output/p_passthrough.h @@ -32,7 +32,7 @@ private: bool sync_to_keyframe; public: - passthrough_packetizer_c(generic_reader_c *nreader, track_info_t *nti) + passthrough_packetizer_c(generic_reader_c *nreader, track_info_c *nti) throw (error_c); virtual int process(unsigned char *buf, int size, int64_t timecode = -1, diff --git a/src/output/p_pcm.cpp b/src/output/p_pcm.cpp index 24014910a..280438ac6 100644 --- a/src/output/p_pcm.cpp +++ b/src/output/p_pcm.cpp @@ -34,7 +34,7 @@ using namespace libmatroska; pcm_packetizer_c::pcm_packetizer_c(generic_reader_c *nreader, unsigned long nsamples_per_sec, int nchannels, int nbits_per_sample, - track_info_t *nti, bool nbig_endian) + track_info_c *nti, bool nbig_endian) throw (error_c): generic_packetizer_c(nreader, nti) { packetno = 0; diff --git a/src/output/p_pcm.h b/src/output/p_pcm.h index 23ff8e532..ba80999bf 100644 --- a/src/output/p_pcm.h +++ b/src/output/p_pcm.h @@ -36,7 +36,7 @@ private: public: pcm_packetizer_c(generic_reader_c *nreader, unsigned long nsamples_per_sec, - int nchannels, int nbits_per_sample, track_info_t *nti, + int nchannels, int nbits_per_sample, track_info_c *nti, bool nbig_endian = false) throw (error_c); virtual ~pcm_packetizer_c(); diff --git a/src/output/p_textsubs.cpp b/src/output/p_textsubs.cpp index 2cb74dd12..43b4f3452 100644 --- a/src/output/p_textsubs.cpp +++ b/src/output/p_textsubs.cpp @@ -34,7 +34,7 @@ textsubs_packetizer_c::textsubs_packetizer_c(generic_reader_c *nreader, const char *ncodec_id, const void *nglobal_data, int nglobal_size, bool nrecode, - bool is_utf8, track_info_t *nti) + bool is_utf8, track_info_c *nti) throw (error_c): generic_packetizer_c(nreader, nti) { packetno = 0; recode = nrecode; diff --git a/src/output/p_textsubs.h b/src/output/p_textsubs.h index e80f5c1cc..387acf886 100644 --- a/src/output/p_textsubs.h +++ b/src/output/p_textsubs.h @@ -38,7 +38,7 @@ private: public: textsubs_packetizer_c(generic_reader_c *nreader, const char *ncodec_id, const void *nglobal_data, int nglobal_size, - bool nrecode, bool is_utf8, track_info_t *nti) + bool nrecode, bool is_utf8, track_info_c *nti) throw (error_c); virtual ~textsubs_packetizer_c(); diff --git a/src/output/p_video.cpp b/src/output/p_video.cpp index ace71d5f3..bc702426c 100644 --- a/src/output/p_video.cpp +++ b/src/output/p_video.cpp @@ -40,7 +40,7 @@ video_packetizer_c::video_packetizer_c(generic_reader_c *nreader, const char *ncodec_id, double nfps, int nwidth, int nheight, bool nbframes, - track_info_t *nti) + track_info_c *nti) throw (error_c) : generic_packetizer_c(nreader, nti) { fps = nfps; width = nwidth; diff --git a/src/output/p_video.h b/src/output/p_video.h index 77465a721..98d063a48 100644 --- a/src/output/p_video.h +++ b/src/output/p_video.h @@ -41,7 +41,7 @@ private: public: video_packetizer_c(generic_reader_c *nreader, const char *ncodec_id, double nfps, int nwidth, int nheight, bool nbframes, - track_info_t *nti) + track_info_c *nti) throw (error_c); virtual ~video_packetizer_c(); diff --git a/src/output/p_vobsub.cpp b/src/output/p_vobsub.cpp index d3cce6974..22eae425c 100644 --- a/src/output/p_vobsub.cpp +++ b/src/output/p_vobsub.cpp @@ -40,7 +40,7 @@ vobsub_packetizer_c::vobsub_packetizer_c(generic_reader_c *nreader, const void *nidx_data, int nidx_data_size, bool nextract_from_mpeg, - track_info_t *nti) throw (error_c): + track_info_c *nti) throw (error_c): generic_packetizer_c(nreader, nti) { idx_data = (unsigned char *)safememdup(nidx_data, nidx_data_size); diff --git a/src/output/p_vobsub.h b/src/output/p_vobsub.h index 4e14f804c..8707b8cfe 100644 --- a/src/output/p_vobsub.h +++ b/src/output/p_vobsub.h @@ -37,7 +37,7 @@ private: public: vobsub_packetizer_c(generic_reader_c *nreader, const void *nidx_data, int nidx_data_size, - bool nextract_from_mpeg, track_info_t *nti) + bool nextract_from_mpeg, track_info_c *nti) throw (error_c); virtual ~vobsub_packetizer_c(); diff --git a/src/output/p_vorbis.cpp b/src/output/p_vorbis.cpp index d6a349f82..5924b29cc 100644 --- a/src/output/p_vorbis.cpp +++ b/src/output/p_vorbis.cpp @@ -43,7 +43,7 @@ vorbis_packetizer_c::vorbis_packetizer_c(generic_reader_c *nreader, unsigned char *d_comments, int l_comments, unsigned char *d_codecsetup, - int l_codecsetup, track_info_t *nti) + int l_codecsetup, track_info_c *nti) throw (error_c): generic_packetizer_c(nreader, nti) { int i; diff --git a/src/output/p_vorbis.h b/src/output/p_vorbis.h index bc90b09be..410901912 100644 --- a/src/output/p_vorbis.h +++ b/src/output/p_vorbis.h @@ -44,7 +44,7 @@ public: unsigned char *d_header, int l_header, unsigned char *d_comments, int l_comments, unsigned char *d_codecsetup, int l_codecsetup, - track_info_t *nti) throw (error_c); + track_info_c *nti) throw (error_c); virtual ~vorbis_packetizer_c(); virtual int process(unsigned char *data, int size, int64_t timecode = -1, diff --git a/src/pr_generic.cpp b/src/pr_generic.cpp index 080557474..7c504ed4a 100644 --- a/src/pr_generic.cpp +++ b/src/pr_generic.cpp @@ -37,7 +37,7 @@ using namespace std; generic_packetizer_c::generic_packetizer_c(generic_reader_c *nreader, - track_info_t *nti) throw(error_c) { + track_info_c *nti) throw(error_c) { int i; audio_sync_t *as; cue_creation_t *cc; @@ -56,7 +56,7 @@ generic_packetizer_c::generic_packetizer_c(generic_reader_c *nreader, duplicate_data = true; track_entry = NULL; - ti = duplicate_track_info(nti); + ti = new track_info_c(*nti); free_refs = -1; enqueued_bytes = 0; safety_last_timecode = 0; @@ -224,7 +224,7 @@ generic_packetizer_c::generic_packetizer_c(generic_reader_c *nreader, } generic_packetizer_c::~generic_packetizer_c() { - free_track_info(ti); + delete ti; safefree(hcodec_id); safefree(hcodec_private); @@ -926,12 +926,12 @@ void generic_packetizer_c::displace(float by_ms) { //-------------------------------------------------------------------- -generic_reader_c::generic_reader_c(track_info_t *nti) { - ti = duplicate_track_info(nti); +generic_reader_c::generic_reader_c(track_info_c *nti) { + ti = new track_info_c(*nti); } generic_reader_c::~generic_reader_c() { - free_track_info(ti); + delete ti; } bool generic_reader_c::demuxing_requested(char type, int64_t id) { @@ -967,98 +967,168 @@ bool generic_reader_c::demuxing_requested(char type, int64_t id) { //-------------------------------------------------------------------- -track_info_t *duplicate_track_info(track_info_t *src) { - track_info_t *dst; - int i; +track_info_c::track_info_c(): + initialized(true), + id(0), fname(NULL), + no_audio(false), no_video(false), no_subs(false), + private_data(NULL), private_size(0), + aspect_ratio(0.0), display_width(0), display_height(0), + aspect_ratio_given(false), display_dimensions_given(false), + cues(0), default_track(false), language(NULL), sub_charset(NULL), + tags_ptr(NULL), tags(NULL), + compression(COMPRESSION_NONE), + track_name(NULL), ext_timecodes(NULL), + no_chapters(false), no_attachments(false), no_tags(false) { + atracks = new vector; + vtracks = new vector; + stracks = new vector; - if (src == NULL) - return NULL; - - dst = (track_info_t *)safememdup(src, sizeof(track_info_t)); - dst->fname = safestrdup(src->fname); - dst->atracks = new vector(*src->atracks); - dst->vtracks = new vector(*src->vtracks); - dst->stracks = new vector(*src->stracks); - dst->audio_syncs = new vector(*src->audio_syncs); - dst->cue_creations = new vector(*src->cue_creations); - dst->default_track_flags = new vector(*src->default_track_flags); - dst->languages = new vector(*src->languages); - for (i = 0; i < src->languages->size(); i++) - (*dst->languages)[i].language = safestrdup((*src->languages)[i].language); - dst->language = safestrdup(src->language); - dst->sub_charsets = new vector(*src->sub_charsets); - for (i = 0; i < src->sub_charsets->size(); i++) - (*dst->sub_charsets)[i].language = - safestrdup((*src->sub_charsets)[i].language); - dst->sub_charset = safestrdup(src->sub_charset); - dst->all_tags = new vector(*src->all_tags); - for (i = 0; i < src->all_tags->size(); i++) - (*dst->all_tags)[i].file_name = safestrdup((*src->all_tags)[i].file_name); - dst->aac_is_sbr = new vector(*src->aac_is_sbr); - dst->private_data = (unsigned char *)safememdup(src->private_data, - src->private_size); - dst->compression_list = new vector(*src->compression_list); - dst->track_names = new vector(*src->track_names); - for (i = 0; i < src->track_names->size(); i++) - (*dst->track_names)[i].language = - safestrdup((*src->track_names)[i].language); - dst->track_name = safestrdup(src->track_name); - dst->all_ext_timecodes = new vector(*src->all_ext_timecodes); - for (i = 0; i < src->all_ext_timecodes->size(); i++) - (*dst->all_ext_timecodes)[i].language = - safestrdup((*src->all_ext_timecodes)[i].language); - dst->ext_timecodes = safestrdup(src->ext_timecodes); - dst->tags = NULL; - dst->all_fourccs = new vector(*src->all_fourccs); - dst->fourcc[0] = 0; - dst->display_properties = - new vector(*src->display_properties); - dst->aspect_ratio_given = false; - dst->display_dimensions_given = false; - - return dst; + all_fourccs = new vector; + memset(fourcc, 0, 5); + display_properties = new vector; + audio_syncs = new vector; + cue_creations = new vector; + default_track_flags = new vector; + languages = new vector; + sub_charsets = new vector; + all_tags = new vector; + aac_is_sbr = new vector; + compression_list = new vector; + track_names = new vector; + all_ext_timecodes = new vector; } -void free_track_info(track_info_t *ti) { - int i; +track_info_c::track_info_c(const track_info_c &src): + initialized(false) { + *this = src; +} - if (ti == NULL) +track_info_c::~track_info_c() { + free_contents(); +} + +void track_info_c::free_contents() { + uint32_t i; + + if (!initialized) return; - safefree(ti->fname); - delete ti->atracks; - delete ti->vtracks; - delete ti->stracks; - delete ti->audio_syncs; - delete ti->cue_creations; - delete ti->default_track_flags; - for (i = 0; i < ti->languages->size(); i++) - safefree((*ti->languages)[i].language); - delete ti->languages; - safefree(ti->language); - for (i = 0; i < ti->sub_charsets->size(); i++) - safefree((*ti->sub_charsets)[i].language); - delete ti->sub_charsets; - safefree(ti->sub_charset); - for (i = 0; i < ti->all_tags->size(); i++) - safefree((*ti->all_tags)[i].file_name); - delete ti->all_tags; - delete ti->aac_is_sbr; - delete ti->compression_list; - for (i = 0; i < ti->track_names->size(); i++) - safefree((*ti->track_names)[i].language); - delete ti->track_names; - safefree(ti->track_name); - for (i = 0; i < ti->all_ext_timecodes->size(); i++) - safefree((*ti->all_ext_timecodes)[i].language); - delete ti->all_ext_timecodes; - safefree(ti->ext_timecodes); - safefree(ti->private_data); - if (ti->tags != NULL) - delete ti->tags; - delete ti->all_fourccs; - delete ti->display_properties; - safefree(ti); + safefree(fname); + delete atracks; + delete vtracks; + delete stracks; + delete audio_syncs; + delete cue_creations; + delete default_track_flags; + for (i = 0; i < languages->size(); i++) + safefree((*languages)[i].language); + delete languages; + safefree(language); + for (i = 0; i < sub_charsets->size(); i++) + safefree((*sub_charsets)[i].language); + delete sub_charsets; + safefree(sub_charset); + for (i = 0; i < all_tags->size(); i++) + safefree((*all_tags)[i].file_name); + delete all_tags; + delete aac_is_sbr; + delete compression_list; + for (i = 0; i < track_names->size(); i++) + safefree((*track_names)[i].language); + delete track_names; + safefree(track_name); + for (i = 0; i < all_ext_timecodes->size(); i++) + safefree((*all_ext_timecodes)[i].language); + delete all_ext_timecodes; + safefree(ext_timecodes); + safefree(private_data); + if (tags != NULL) + delete tags; + delete all_fourccs; + delete display_properties; + + initialized = false; +} + +track_info_c &track_info_c::operator =(const track_info_c &src) { + uint32_t i; + + free_contents(); + + id = src.id; + fname = safestrdup(src.fname); + + no_audio = src.no_audio; + no_video = src.no_video; + no_subs = src.no_subs; + + atracks = new vector(*src.atracks); + vtracks = new vector(*src.vtracks); + stracks = new vector(*src.stracks); + + private_size = src.private_size; + private_data = (unsigned char *)safememdup(src.private_data, private_size); + + all_fourccs = new vector(*src.all_fourccs); + memcpy(fourcc, src.fourcc, 5); + + display_properties = + new vector(*src.display_properties); + aspect_ratio = src.aspect_ratio; + aspect_ratio_given = false; + display_dimensions_given = false; + + audio_syncs = new vector(*src.audio_syncs); + memcpy(&async, &src.async, sizeof(audio_sync_t)); + + cue_creations = new vector(*src.cue_creations); + cues = src.cues; + + default_track_flags = new vector(*src.default_track_flags); + default_track = src.default_track; + + languages = new vector(*src.languages); + for (i = 0; i < src.languages->size(); i++) + (*languages)[i].language = safestrdup((*src.languages)[i].language); + language = safestrdup(src.language); + + sub_charsets = new vector(*src.sub_charsets); + for (i = 0; i < src.sub_charsets->size(); i++) + (*sub_charsets)[i].language = + safestrdup((*src.sub_charsets)[i].language); + sub_charset = safestrdup(src.sub_charset); + + all_tags = new vector(*src.all_tags); + for (i = 0; i < src.all_tags->size(); i++) + (*all_tags)[i].file_name = safestrdup((*src.all_tags)[i].file_name); + tags_ptr = src.tags_ptr; + tags = NULL; +// tags = src.tags; + + aac_is_sbr = new vector(*src.aac_is_sbr); + + compression_list = new vector(*src.compression_list); + compression = src.compression; + + track_names = new vector(*src.track_names); + for (i = 0; i < src.track_names->size(); i++) + (*track_names)[i].language = + safestrdup((*src.track_names)[i].language); + track_name = safestrdup(src.track_name); + + all_ext_timecodes = new vector(*src.all_ext_timecodes); + for (i = 0; i < src.all_ext_timecodes->size(); i++) + (*all_ext_timecodes)[i].language = + safestrdup((*src.all_ext_timecodes)[i].language); + ext_timecodes = safestrdup(src.ext_timecodes); + + no_chapters = src.no_chapters; + no_attachments = src.no_attachments; + no_tags = src.no_tags; + + initialized = true; + + return *this; } struct ltstr { @@ -1068,7 +1138,7 @@ struct ltstr { }; static map pass_data; -void set_pass_data(track_info_t *ti, unsigned char *data, int size) { +void set_pass_data(track_info_c *ti, unsigned char *data, int size) { string key, value; key = string(ti->fname) + string("::") + to_string(ti->id); @@ -1078,7 +1148,7 @@ void set_pass_data(track_info_t *ti, unsigned char *data, int size) { pass_data[key.c_str()] = value; } -unsigned char *retrieve_pass_data(track_info_t *ti, int &size) { +unsigned char *retrieve_pass_data(track_info_c *ti, int &size) { map::iterator it; string key, value; unsigned char *data; diff --git a/src/pr_generic.h b/src/pr_generic.h index c64febf52..c32d8ab51 100644 --- a/src/pr_generic.h +++ b/src/pr_generic.h @@ -87,7 +87,10 @@ typedef struct { int64_t id; } fourcc_t; -typedef struct { +class track_info_c { +protected: + bool initialized; +public: // The track ID. int64_t id; @@ -138,7 +141,15 @@ typedef struct { char *ext_timecodes; // For this very track bool no_chapters, no_attachments, no_tags; -} track_info_t; + +public: + track_info_c(); + track_info_c(const track_info_c &src); + virtual ~track_info_c(); + + track_info_c &operator =(const track_info_c &src); + virtual void free_contents(); +}; class timecode_range_c { public: @@ -158,7 +169,7 @@ protected: generic_reader_c *reader; bool duplicate_data; - track_info_t *ti; + track_info_c *ti; int64_t initial_displacement; int64_t free_refs, enqueued_bytes, safety_last_timecode; @@ -191,7 +202,7 @@ protected: int ext_timecodes_version; public: - generic_packetizer_c(generic_reader_c *nreader, track_info_t *nti) + generic_packetizer_c(generic_reader_c *nreader, track_info_c *nti) throw (error_c); virtual ~generic_packetizer_c(); @@ -272,9 +283,9 @@ protected: class generic_reader_c { protected: - track_info_t *ti; + track_info_c *ti; public: - generic_reader_c(track_info_t *nti); + generic_reader_c(track_info_c *nti); virtual ~generic_reader_c(); virtual int read(generic_packetizer_c *ptzr) = 0; virtual int display_priority() = 0; @@ -290,9 +301,9 @@ protected: virtual bool demuxing_requested(char type, int64_t id); }; -track_info_t *duplicate_track_info(track_info_t *src); -void free_track_info(track_info_t *ti); -void set_pass_data(track_info_t *ti, unsigned char *data, int size); -unsigned char *retrieve_pass_data(track_info_t *ti, int &size); +track_info_c *duplicate_track_info(track_info_c *src); +void free_track_info(track_info_c *ti); +void set_pass_data(track_info_c *ti, unsigned char *data, int size); +unsigned char *retrieve_pass_data(track_info_c *ti, int &size); #endif // __PR_GENERIC_H