Skip to content

Commit e262b06

Browse files
committed
Memory Cleanup
Signed-off-by: Anshul Maheshwari <[email protected]>
1 parent 6942089 commit e262b06

File tree

6 files changed

+41
-10
lines changed

6 files changed

+41
-10
lines changed

src/lib_ccx/ccx_decoders_isdb.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,28 @@ typedef struct
279279
}ISDBSubContext;
280280

281281

282-
void delete_isdb_caption(void *isdb_ctx)
282+
/**
283+
* Find way to put remaining data
284+
*/
285+
void delete_isdb_decoder(void **isdb_ctx)
283286
{
284-
ISDBSubContext *ctx = isdb_ctx;
285-
free(ctx);
287+
ISDBSubContext *ctx = *isdb_ctx;
288+
struct ISDBText *text = NULL;
289+
struct ISDBText *text1 = NULL;
290+
list_for_each_entry_safe(text, text1, &ctx->text_list_head, list, struct ISDBText)
291+
{
292+
list_del(&text->list);
293+
free(text->buf);
294+
free(text);
295+
}
296+
297+
list_for_each_entry_safe(text, text1, &ctx->buffered_text, list, struct ISDBText)
298+
{
299+
list_del(&text->list);
300+
free(text->buf);
301+
free(text);
302+
}
303+
freep(isdb_ctx);
286304
}
287305

288306
static void init_layout(ISDBSubLayout *ls)
@@ -295,7 +313,8 @@ static void init_layout(ISDBSubLayout *ls)
295313
ls->font_scale.fscy = 100;
296314

297315
}
298-
void *init_isdb_caption(void)
316+
317+
void *init_isdb_decoder(void)
299318
{
300319
ISDBSubContext *ctx;
301320

src/lib_ccx/ccx_decoders_isdb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
int isdb_set_global_time(struct lib_cc_decode *dec_ctx, uint64_t timestamp);
88
int isdbsub_decode(struct lib_cc_decode *dec_ctx, const uint8_t *buf, size_t buf_size, struct cc_subtitle *sub);
9-
void delete_isdb_caption(void *isdb_ctx);
10-
void *init_isdb_caption(void);
9+
void delete_isdb_decoder(void **isdb_ctx);
10+
void *init_isdb_decoder(void);
1111

1212

1313
#endif

src/lib_ccx/ccx_demuxer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ void ccx_demuxer_delete(struct ccx_demuxer **ctx)
249249
lctx->PID_buffers[i]->buffer=NULL;
250250
lctx->PID_buffers[i]->buffer_length=0;
251251
}
252+
freep(&lctx->PID_buffers[i]);
252253
}
253254
for (i = 0; i < MAX_PID; i++)
254255
{

src/lib_ccx/lib_ccx.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "utility.h"
55
#include "dvb_subtitle_decoder.h"
66
#include "ccx_decoders_708.h"
7+
#include "ccx_decoders_isdb.h"
78

89
struct ccx_common_logging_t ccx_common_logging;
910
static struct ccx_decoders_common_settings_t *init_decoder_setting(
@@ -182,6 +183,12 @@ void dinit_libraries( struct lib_ccx_ctx **ctx)
182183
LLONG cfts;
183184
if (dec_ctx->codec == CCX_CODEC_DVB)
184185
dvbsub_close_decoder(&dec_ctx->private_data);
186+
//Test memory for teletext
187+
//else if (dec_ctx->codec == CCX_CODEC_TELETEXT)
188+
// telxcc_close(&dec_ctx->private_data, NULL);
189+
else if (dec_ctx->codec == CCX_CODEC_ISDB_CC)
190+
delete_isdb_decoder(&dec_ctx->private_data);
191+
185192
flush_cc_decode(dec_ctx, &dec_ctx->dec_sub);
186193
cfts = get_fts(dec_ctx->timing, dec_ctx->current_field);
187194
enc_ctx = get_encoder_by_pn(lctx, dec_ctx->program_number);
@@ -202,6 +209,7 @@ void dinit_libraries( struct lib_ccx_ctx **ctx)
202209
// free EPG memory
203210
EPG_free(lctx);
204211
freep(&lctx->freport.data_from_608);
212+
freep(&lctx->freport.data_from_708);
205213
ccx_demuxer_delete(&lctx->demux_ctx);
206214
dinit_decoder_setting(&lctx->dec_global_setting);
207215
freep(&ccx_options.enc_cfg.output_filename);
@@ -294,9 +302,6 @@ struct encoder_ctx *update_encoder_list_cinfo(struct lib_ccx_ctx *ctx, struct ca
294302
unsigned char in_format = 1;
295303
char *extension;
296304

297-
extension = get_file_extension(ccx_options.enc_cfg.write_format);
298-
if(!extension)
299-
return NULL;
300305

301306
if (ctx->write_format == CCX_OF_NULL)
302307
return NULL;
@@ -320,6 +325,9 @@ struct encoder_ctx *update_encoder_list_cinfo(struct lib_ccx_ctx *ctx, struct ca
320325
return enc_ctx;
321326
}
322327

328+
extension = get_file_extension(ccx_options.enc_cfg.write_format);
329+
if(!extension)
330+
return NULL;
323331

324332
if(ctx->multiprogram == CCX_FALSE)
325333
{

src/lib_ccx/ts_functions.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "ccx_demuxer.h"
55
#include "list.h"
66
#include "dvb_subtitle_decoder.h"
7+
#include "ccx_decoders_isdb.h"
78
#include "file_buffer.h"
89

910
unsigned char tspacket[188]; // Current packet
@@ -718,6 +719,8 @@ long ts_readstream(struct ccx_demuxer *ctx, struct demuxer_data **data)
718719
case CCX_CODEC_DVB:
719720
dvbsub_close_decoder(&cinfo->codec_private_data);
720721
break;
722+
case CCX_CODEC_ISDB_CC:
723+
delete_isdb_decoder(&cinfo->codec_private_data);
721724
default:
722725
break;
723726
}

src/lib_ccx/ts_tables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ int parse_PMT (struct ccx_demuxer *ctx, unsigned char *buf, int len, struct pro
311311
if (component_id != 0x08)
312312
break;
313313
mprint ("*****ISDB subtitles detected\n");
314-
ptr = init_isdb_caption();
314+
ptr = init_isdb_decoder();
315315
if (ptr == NULL)
316316
break;
317317
update_capinfo(ctx, elementary_PID, stream_type, CCX_CODEC_ISDB_CC, program_number, ptr);

0 commit comments

Comments
 (0)