lavc: allow subtitle text format to be ASS without timing
This commit is contained in:
@@ -409,6 +409,55 @@ ASSDialog *ff_ass_split_dialog(ASSSplitContext *ctx, const char *buf,
|
||||
return dialog;
|
||||
}
|
||||
|
||||
void ff_ass_free_dialog(ASSDialog **dialogp)
|
||||
{
|
||||
ASSDialog *dialog = *dialogp;
|
||||
if (!dialog)
|
||||
return;
|
||||
av_freep(&dialog->style);
|
||||
av_freep(&dialog->name);
|
||||
av_freep(&dialog->effect);
|
||||
av_freep(&dialog->text);
|
||||
av_freep(dialogp);
|
||||
}
|
||||
|
||||
ASSDialog *ff_ass_split_dialog2(ASSSplitContext *ctx, const char *buf)
|
||||
{
|
||||
int i;
|
||||
static const ASSFields fields[] = {
|
||||
{"ReadOrder", ASS_INT, offsetof(ASSDialog, readorder)},
|
||||
{"Layer", ASS_INT, offsetof(ASSDialog, layer) },
|
||||
{"Style", ASS_STR, offsetof(ASSDialog, style) },
|
||||
{"Name", ASS_STR, offsetof(ASSDialog, name) },
|
||||
{"MarginL", ASS_INT, offsetof(ASSDialog, margin_l) },
|
||||
{"MarginR", ASS_INT, offsetof(ASSDialog, margin_r) },
|
||||
{"MarginV", ASS_INT, offsetof(ASSDialog, margin_v) },
|
||||
{"Effect", ASS_STR, offsetof(ASSDialog, effect) },
|
||||
{"Text", ASS_STR, offsetof(ASSDialog, text) },
|
||||
};
|
||||
|
||||
ASSDialog *dialog = av_mallocz(sizeof(*dialog));
|
||||
if (!dialog)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(fields); i++) {
|
||||
size_t len;
|
||||
const int last = i == FF_ARRAY_ELEMS(fields) - 1;
|
||||
const ASSFieldType type = fields[i].type;
|
||||
uint8_t *ptr = (uint8_t *)dialog + fields[i].offset;
|
||||
buf = skip_space(buf);
|
||||
len = last ? strlen(buf) : strcspn(buf, ",");
|
||||
if (len >= INT_MAX) {
|
||||
ff_ass_free_dialog(&dialog);
|
||||
return NULL;
|
||||
}
|
||||
convert_func[type](ptr, buf, len);
|
||||
buf += len;
|
||||
if (*buf) buf++;
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
||||
void ff_ass_split_free(ASSSplitContext *ctx)
|
||||
{
|
||||
if (ctx) {
|
||||
|
||||
Reference in New Issue
Block a user