5a6 > * SSA reading fixes by Manta 20a22 > #include "subreaderctx.h" 98c100,101 < subtitle *sub_read_line_sami(stream_t* st, subtitle *current) { --- > subtitle *sub_read_line_sami(stream_t* st, subreaderctx *context) { > subtitle *current = context->globalctx.current; 261c264,265 < subtitle *sub_read_line_microdvd(stream_t *st,subtitle *current) { --- > subtitle *sub_read_line_microdvd(stream_t *st,subreaderctx *context) { > subtitle *current = context->globalctx.current; 289c293,294 < subtitle *sub_read_line_mpl2(stream_t *st,subtitle *current) { --- > subtitle *sub_read_line_mpl2(stream_t *st,subreaderctx *context) { > subtitle *current = context->globalctx.current; 315c320,321 < subtitle *sub_read_line_subrip(stream_t* st, subtitle *current) { --- > subtitle *sub_read_line_subrip(stream_t* st, subreaderctx *context) { > subtitle *current = context->globalctx.current; 345c351,352 < subtitle *sub_read_line_subviewer(stream_t *st,subtitle *current) { --- > subtitle *sub_read_line_subviewer(stream_t *st,subreaderctx *context) { > subtitle *current = context->globalctx.current; 394c401,402 < subtitle *sub_read_line_subviewer2(stream_t *st,subtitle *current) { --- > subtitle *sub_read_line_subviewer2(stream_t *st,subreaderctx *context) { > subtitle *current = context->globalctx.current; 427c435,436 < subtitle *sub_read_line_vplayer(stream_t *st,subtitle *current) { --- > subtitle *sub_read_line_vplayer(stream_t *st,subreaderctx *context) { > subtitle *current = context->globalctx.current; 473c482 < subtitle *sub_read_line_rt(stream_t *st,subtitle *current) { --- > subtitle *sub_read_line_rt(stream_t *st,subreaderctx *context) { 476a486 > subtitle *current = context->globalctx.current; 523c533,538 < subtitle *sub_read_line_ssa(stream_t *st,subtitle *current) { --- > void sub_initctx_ssa(subreaderctx *context) > { > context->ssactx.itemsOnLine = 32; > } > > subtitle *sub_read_line_ssa(stream_t *st,subreaderctx *context) { 528a544 > * Manta: Fortunately, we can rely on "Format:" line, which defines used items. 532a549 > subtitle *current = context->ssactx.current; 534,535c551 < static int max_comma = 32; /* let's use 32 for the case that the */ < /* amount of commas increase with newer SSA versions */ --- > int max_comma = context->ssactx.itemsOnLine; 547a564,574 > if (strncmp(line, "Format: ", 8) == 0) { > /* lets count commas */ > tmp = line; > max_comma = 0; > while (*tmp != 0) { > if (*tmp == ',') max_comma++; > tmp++; > } > context->ssactx.itemsOnLine = max_comma; > // mp_msg(MSGT_SUBREADER,MSGL_INFO,"SSA: Items on line counted: %d.\n", max_comma); > } 566c593,594 < if(*(++tmp) == ' ') break; --- > /* can't do ++tmp 'cause it will skip possibly following comma */ > if(tmp[1] == ' ') break; 571c599,603 < if(comma < max_comma)max_comma = comma; --- > if(comma < max_comma) { > context->ssactx.itemsOnLine = comma; > max_comma = comma; > // mp_msg(MSGT_SUBREADER,MSGL_INFO,"SSA: Items on line adjusted: %d.\n", max_comma); > } 606,607c638,640 < } < if(*so) { --- > } /* two consecutive commands can occure, need to check first */ > else > if(*so) { 624c657,658 < subtitle *sub_read_line_pjs(stream_t *st,subtitle *current) { --- > subtitle *sub_read_line_pjs(stream_t *st,subreaderctx *context) { > subtitle *current = context->globalctx.current; 662c696,697 < subtitle *sub_read_line_mpsub(stream_t *st, subtitle *current) { --- > subtitle *sub_read_line_mpsub(stream_t *st, subreaderctx *context) { > subtitle *current = context->globalctx.current; 702,705c737,740 < #ifndef USE_SORTSUB < //we don't need this if we use previous_sub_end < subtitle *previous_aqt_sub = NULL; < #endif --- > void sub_initctx_aqt(subreaderctx *context) > { > context->lookbackctx.previous = NULL; > } 707c742,743 < subtitle *sub_read_line_aqt(stream_t *st,subtitle *current) { --- > subtitle *sub_read_line_aqt(stream_t *st,subreaderctx *context) { > subtitle *current = context->lookbackctx.current; 723,726c759,762 < if (previous_aqt_sub != NULL) < previous_aqt_sub->end = current->start-1; < < previous_aqt_sub = current; --- > if (context->lookbackctx.previous != NULL) > context->lookbackctx.previous->end = current->start-1; > > context->lookbackctx.previous = current; 752c788 < previous_aqt_sub = NULL; --- > context->lookbackctx.previous = NULL; 760,762c796,799 < #ifndef USE_SORTSUB < subtitle *previous_subrip09_sub = NULL; < #endif --- > void sub_initctx_subrip09(subreaderctx *context) > { > context->lookbackctx.previous = NULL; > } 764c801,802 < subtitle *sub_read_line_subrip09(stream_t *st,subtitle *current) { --- > subtitle *sub_read_line_subrip09(stream_t *st,subreaderctx *context) { > subtitle *current = context->lookbackctx.current; 783,784c821,822 < if (previous_subrip09_sub != NULL) < previous_subrip09_sub->end = current->start-1; --- > if (context->lookbackctx.previous != NULL) > context->lookbackctx.previous->end = current->start-1; 786c824 < previous_subrip09_sub = current; --- > context->lookbackctx.previous = current; 808c846 < previous_subrip09_sub = NULL; --- > context->lookbackctx.previous = NULL; 816c854 < subtitle *sub_read_line_jacosub(stream_t* st, subtitle * current) --- > subtitle *sub_read_line_jacosub(stream_t* st, subreaderctx *context) 817a856 > subtitle *current = context->globalctx.current; 1300c1339,1340 < subtitle * (*read)(stream_t *st,subtitle *dest); --- > void (*init)(subreaderctx *context); > subtitle * (*read)(stream_t *st,subreaderctx *context); 1363,1376c1403,1416 < { sub_read_line_microdvd, NULL, "microdvd" }, < { sub_read_line_subrip, NULL, "subrip" }, < { sub_read_line_subviewer, NULL, "subviewer" }, < { sub_read_line_sami, NULL, "sami" }, < { sub_read_line_vplayer, NULL, "vplayer" }, < { sub_read_line_rt, NULL, "rt" }, < { sub_read_line_ssa, sub_pp_ssa, "ssa" }, < { sub_read_line_pjs, NULL, "pjs" }, < { sub_read_line_mpsub, NULL, "mpsub" }, < { sub_read_line_aqt, NULL, "aqt" }, < { sub_read_line_subviewer2, NULL, "subviewer 2.0" }, < { sub_read_line_subrip09, NULL, "subrip 0.9" }, < { sub_read_line_jacosub, NULL, "jacosub" }, < { sub_read_line_mpl2, NULL, "mpl2" } --- > { NULL, sub_read_line_microdvd, NULL, "microdvd" }, > { NULL, sub_read_line_subrip, NULL, "subrip" }, > { NULL, sub_read_line_subviewer, NULL, "subviewer" }, > { NULL, sub_read_line_sami, NULL, "sami" }, > { NULL, sub_read_line_vplayer, NULL, "vplayer" }, > { NULL, sub_read_line_rt, NULL, "rt" }, > { sub_initctx_ssa, sub_read_line_ssa, sub_pp_ssa, "ssa" }, > { NULL, sub_read_line_pjs, NULL, "pjs" }, > { NULL, sub_read_line_mpsub, NULL, "mpsub" }, > { sub_initctx_aqt, sub_read_line_aqt, NULL, "aqt" }, > { NULL, sub_read_line_subviewer2, NULL, "subviewer 2.0" }, > { sub_initctx_subrip09, sub_read_line_subrip09, NULL, "subrip 0.9" }, > { NULL, sub_read_line_jacosub, NULL, "jacosub" }, > { NULL, sub_read_line_mpl2, NULL, "mpl2" } 1378a1419 > subreaderctx context; 1387a1429,1434 > > context.globalctx.current = NULL; > if (srp->init != NULL) { > srp->init(&context); > mp_msg(MSGT_SUBREADER,MSGL_INFO,"SUB: Reader specific context initialized\n"); > } 1418c1465 < --- > 1424c1471 < #endif --- > #endif 1434c1481,1482 < sub=srp->read(fd,sub); --- > context.globalctx.current = sub; > sub=srp->read(fd, &context); 2286c2334 < subd = sub_read_file(argv[1]); --- > subd = sub_read_file(argv[1], 24);