mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-04 05:44:53 +00:00
[FIX] Fix some minor memory leaks (#989)
* Destroy pix after use and release memory * Free the frame and any dynamically allocated objects in it * Fix typographical error * Free the packet that was allocated by av_read_frame * Add missing declarations
This commit is contained in:
committed by
Carlos Fernandez Sanz
parent
ef63d61f3d
commit
45ed8456ee
@@ -111,8 +111,8 @@ int hardsubx_process_data(struct lib_hardsubx_ctx *ctx)
|
||||
|
||||
// Free the allocated memory for frame processing
|
||||
av_free(ctx->rgb_buffer);
|
||||
av_free(ctx->rgb_frame);
|
||||
av_free(ctx->frame);
|
||||
av_frame_free(ctx->rgb_frame);
|
||||
av_frame_free(ctx->frame);
|
||||
avcodec_close(ctx->codec_ctx);
|
||||
avformat_close_input(&ctx->format_ctx);
|
||||
}
|
||||
@@ -203,7 +203,7 @@ void _hardsubx_params_dump(struct ccx_s_options *options, struct lib_hardsubx_ct
|
||||
}
|
||||
else
|
||||
{
|
||||
mprint("Minimum subtitle duration : %0.2f seconds (Default)\n",ctx->min_sub_duration);
|
||||
mprint("Minimum subtitle duration : %0.2f seconds\n",ctx->min_sub_duration);
|
||||
}
|
||||
|
||||
mprint("FFMpeg Media Information:-\n");
|
||||
|
||||
@@ -82,11 +82,17 @@ struct lib_hardsubx_ctx
|
||||
struct lib_hardsubx_ctx* _init_hardsubx(struct ccx_s_options *options);
|
||||
void _hardsubx_params_dump(struct ccx_s_options *options, struct lib_hardsubx_ctx *ctx);
|
||||
void hardsubx(struct ccx_s_options *options);
|
||||
void _dinit_hardsubx(struct lib_hardsubx_ctx **ctx);
|
||||
int hardsubx_process_data(struct lib_hardsubx_ctx *ctx);
|
||||
|
||||
//hardsubx_decoder.c
|
||||
int hardsubx_process_frames_linear(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx);
|
||||
int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct encoder_ctx *enc_ctx);
|
||||
int hardsubx_process_frames_binary(struct lib_hardsubx_ctx *ctx);
|
||||
char* _process_frame_white_basic(struct lib_hardsubx_ctx *ctx, AVFrame *frame, int width, int height, int index);
|
||||
char *_process_frame_color_basic(struct lib_hardsubx_ctx *ctx, AVFrame *frame, int width, int height, int index);
|
||||
void _display_frame(struct lib_hardsubx_ctx *ctx, AVFrame *frame, int width, int height, int timestamp);
|
||||
char* _process_frame_tickertext(struct lib_hardsubx_ctx *ctx, AVFrame *frame, int width, int height, int index);
|
||||
|
||||
//hardsubx_imgops.c
|
||||
void rgb_to_hsv(float R, float G, float B,float *H, float *S, float *V);
|
||||
@@ -105,6 +111,8 @@ int edit_distance(char * word1, char * word2, int len1, int len2);
|
||||
int64_t convert_pts_to_ms(int64_t pts, AVRational time_base);
|
||||
int64_t convert_pts_to_ns(int64_t pts, AVRational time_base);
|
||||
int64_t convert_pts_to_s(int64_t pts, AVRational time_base);
|
||||
int is_valid_trailing_char(char c);
|
||||
char *prune_string(char *s);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -190,6 +190,8 @@ char *_process_frame_color_basic(struct lib_hardsubx_ctx *ctx, AVFrame *frame, i
|
||||
pixDestroy(&im);
|
||||
pixDestroy(&edge_im);
|
||||
pixDestroy(&hue_im);
|
||||
pixDestroy(&edge_im_2);
|
||||
pixDestroy(&pixd);
|
||||
|
||||
return subtitle_text;
|
||||
}
|
||||
@@ -258,6 +260,7 @@ void _display_frame(struct lib_hardsubx_ctx *ctx, AVFrame *frame, int width, int
|
||||
pixDestroy(&feat_im);
|
||||
pixDestroy(&edge_im_2);
|
||||
pixDestroy(&pixd);
|
||||
pixDestroy(&hue_im);
|
||||
}
|
||||
|
||||
char* _process_frame_tickertext(struct lib_hardsubx_ctx *ctx, AVFrame *frame, int width, int height, int index)
|
||||
@@ -366,6 +369,7 @@ int hardsubx_process_frames_tickertext(struct lib_hardsubx_ctx *ctx, struct enco
|
||||
activity_progress(progress,cur_sec/60,cur_sec%60);
|
||||
}
|
||||
}
|
||||
av_packet_unref(&ctx->packet);
|
||||
}
|
||||
activity_progress(100,cur_sec/60,cur_sec%60);
|
||||
return 0;
|
||||
@@ -545,6 +549,7 @@ int hardsubx_process_frames_binary(struct lib_hardsubx_ctx *ctx)
|
||||
break;
|
||||
}
|
||||
}
|
||||
av_packet_unref(&ctx->packet);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user