mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2024-12-24 20:01:42 +00:00
Refactoring
This commit is contained in:
parent
b723378eb2
commit
7212d6848a
@ -622,11 +622,11 @@ void parse_segment_track_entry(struct matroska_ctx* mkv_ctx) {
|
||||
sub_track->lang_index = 0;
|
||||
sub_track->codec_id = codec_id;
|
||||
sub_track->sentence_count = 0;
|
||||
|
||||
for (int i = 0; i < mkv_ctx->sub_tracks_count; i++)
|
||||
if (strcmp((const char *)mkv_ctx->sub_tracks[i]->lang, (const char *)lang) == 0)
|
||||
sub_track->lang_index++;
|
||||
mkv_ctx->sub_tracks[mkv_ctx->sub_tracks_count] = sub_track;
|
||||
mkv_ctx->sub_tracks = realloc(mkv_ctx->sub_tracks, sizeof(struct matroska_sub_track*) * (mkv_ctx->sub_tracks_count + 1));
|
||||
mkv_ctx->sub_tracks[mkv_ctx->sub_tracks_count] = sub_track;
|
||||
mkv_ctx->sub_tracks_count++;
|
||||
}
|
||||
else
|
||||
@ -763,7 +763,6 @@ void save_sub_track(struct matroska_ctx* mkv_ctx, struct matroska_sub_track* tra
|
||||
{
|
||||
char* filename = generate_filename_from_track(mkv_ctx, track);
|
||||
mprint("\nOutput file: %s", filename);
|
||||
int size=0;
|
||||
int desc;
|
||||
#ifdef WIN32
|
||||
desc = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, S_IREAD | S_IWRITE);
|
||||
@ -798,11 +797,10 @@ void save_sub_track(struct matroska_ctx* mkv_ctx, struct matroska_sub_track* tra
|
||||
write(desc, " --> ", 5);
|
||||
write(desc, timestamp_end, strlen(timestamp_start));
|
||||
write(desc, "\n", 1);
|
||||
while (sentence->text[0] == '\n'){
|
||||
int size=0;
|
||||
while (sentence->text+size=='\n' || sentence->text+size=='\r' )
|
||||
size++;
|
||||
sentence->text++;
|
||||
}
|
||||
write(desc, sentence->text, sentence->text_size-size);
|
||||
write(desc, sentence->text+size, sentence->text_size-size);
|
||||
write(desc, "\n\n", 2);
|
||||
|
||||
free(timestamp_start);
|
||||
@ -939,7 +937,7 @@ int matroska_loop(struct lib_ccx_ctx *ctx)
|
||||
mkv_ctx->current_second = 0;
|
||||
mkv_ctx->filename = ctx->inputfile[ctx->current_file];
|
||||
mkv_ctx->file = create_file(ctx);
|
||||
mkv_ctx->sub_tracks = malloc(sizeof(struct matroska_sub_track*));
|
||||
mkv_ctx->sub_tracks = malloc(sizeof(struct matroska_sub_track**));
|
||||
|
||||
matroska_parse(mkv_ctx);
|
||||
|
||||
|
@ -248,7 +248,7 @@ char* generate_filename_from_track(struct matroska_ctx* mkv_ctx, struct matroska
|
||||
char* ass_ssa_sentence_erase_read_order(char* text);
|
||||
void save_sub_track(struct matroska_ctx* mkv_ctx, struct matroska_sub_track* track);
|
||||
void free_sub_track(struct matroska_sub_track* track);
|
||||
void matroska_save_all(struct matroska_ctx* mkv_ctx);
|
||||
void matroska_save_all(struct matroska_ctx* mkv_ctx,char* lang);
|
||||
void matroska_free_all(struct matroska_ctx* mkv_ctx);
|
||||
void matroska_parse(struct matroska_ctx* mkv_ctx);
|
||||
FILE* create_file(struct lib_ccx_ctx *ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user