diff --git a/src/merge/pr_generic.cpp b/src/merge/pr_generic.cpp index 08c47c8d3..a6925151d 100644 --- a/src/merge/pr_generic.cpp +++ b/src/merge/pr_generic.cpp @@ -257,7 +257,6 @@ generic_packetizer_c::generic_packetizer_c(generic_reader_c *nreader, hvideo_display_height = -1; hcompression = COMPRESSION_UNSPECIFIED; - compressor = NULL; timecode_factory = timecode_factory_c::create(ti->ext_timecodes, ti->fname, ti->id); @@ -267,8 +266,6 @@ generic_packetizer_c::~generic_packetizer_c() { delete ti; safefree(hcodec_private); - if (compressor != NULL) - delete compressor; delete timecode_factory; } @@ -775,7 +772,8 @@ generic_packetizer_c::set_headers() { *static_cast(&GetChild(*c_comp)) = hcompression - 1; - compressor = compression_c::create(hcompression); + compressor = + counted_ptr(compression_c::create(hcompression)); } if (no_lacing) @@ -829,7 +827,7 @@ generic_packetizer_c::add_packet(memory_c &mem, pack = new packet_t; length = mem.size; - if (compressor != NULL) { + if (NULL != compressor.get()) { pack->data = compressor->compress(mem.data, length); mem.release(); } else @@ -875,7 +873,7 @@ generic_packetizer_c::add_packet(memories_c &mems, pack->data_adds_lengths.resize(mems.size() - 1); length = mems[0]->size; - if (compressor != NULL) { + if (NULL != compressor.get()) { pack->data = compressor->compress(mems[0]->data, length); mems[0]->release(); for (i = 1; i < mems.size(); i++) { @@ -1085,11 +1083,8 @@ generic_packetizer_c::connect(generic_packetizer_c *src, htrack_type = src->htrack_type; htrack_default_duration = src->htrack_default_duration; huid = src->huid; - if (compressor != NULL) - delete compressor; hcompression = src->hcompression; - compressor = src->compressor; - src->compressor = NULL; + compressor = counted_ptr(compression_c::create(hcompression)); last_cue_timecode = src->last_cue_timecode; correction_timecode_offset = 0; if (_append_timecode_offset == -1) diff --git a/src/merge/pr_generic.h b/src/merge/pr_generic.h index 0d0b7f339..10038d0d1 100644 --- a/src/merge/pr_generic.h +++ b/src/merge/pr_generic.h @@ -32,6 +32,7 @@ #include "compression.h" #include "error.h" #include "mm_io.h" +#include "smart_pointers.h" #include "timecode_factory.h" using namespace libmatroska; @@ -432,7 +433,7 @@ protected: int hvideo_display_width, hvideo_display_height; compression_method_e hcompression; - compression_c *compressor; + counted_ptr compressor; timecode_factory_c *timecode_factory;