MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / hb_subtitle_style_init

Function hb_subtitle_style_init

libhb/ssautil.c:580–645  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

578}
579
580hb_subtitle_style_context_t * hb_subtitle_style_init(const uint8_t * ssa_buf, int size)
581{
582 hb_subtitle_style_context_t * ctx;
583 char * ssa_header = malloc(size + 1);
584
585 if (ssa_header == NULL)
586 {
587 return NULL;
588 }
589 memcpy(ssa_header, ssa_buf, size);
590 ssa_header[size] = 0;
591
592 ctx = calloc(1, sizeof(*ctx));
593 if (ctx == NULL)
594 {
595 return NULL;
596 }
597 if (ssa_header != NULL)
598 {
599 // Find beginning of styles
600 char * pos = strstr(ssa_header, "[V4");
601
602 if (pos != NULL)
603 {
604 pos = strstr(pos, "\nFormat:");
605 if (pos != NULL)
606 {
607 char ** fields;
608 char * line = sgetline(pos + 8);
609
610 fields = get_fields(line, 0);
611 free(line);
612
613 if (fields != NULL)
614 {
615 ssa_style_indices_t field_indices;
616
617 fill_field_indices(fields, &field_indices);
618
619 pos = strstr(pos, "\nStyle:");
620 while (pos != NULL)
621 {
622 char ** style;
623
624 line = sgetline(pos + 7);
625 style = get_fields(line, 0);
626 free(line);
627
628 if (add_style(ctx, style, &field_indices))
629 {
630 hb_str_vfree(style);
631 break;
632 }
633 hb_str_vfree(style);
634 pos = strstr(pos + 7, "\nStyle:");
635 }
636
637 hb_str_vfree(fields);

Callers 1

hb_tx3g_style_initFunction · 0.85

Calls 6

sgetlineFunction · 0.85
get_fieldsFunction · 0.85
fill_field_indicesFunction · 0.85
add_styleFunction · 0.85
hb_str_vfreeFunction · 0.85
ssa_style_resetFunction · 0.85

Tested by

no test coverage detected