| 431 | } |
| 432 | |
| 433 | ASSDialog *ff_ass_split_dialog(ASSSplitContext *ctx, const char *buf) |
| 434 | { |
| 435 | int i; |
| 436 | static const ASSFields fields[] = { |
| 437 | {"ReadOrder", ASS_INT, offsetof(ASSDialog, readorder)}, |
| 438 | {"Layer", ASS_INT, offsetof(ASSDialog, layer) }, |
| 439 | {"Style", ASS_STR, offsetof(ASSDialog, style) }, |
| 440 | {"Name", ASS_STR, offsetof(ASSDialog, name) }, |
| 441 | {"MarginL", ASS_INT, offsetof(ASSDialog, margin_l) }, |
| 442 | {"MarginR", ASS_INT, offsetof(ASSDialog, margin_r) }, |
| 443 | {"MarginV", ASS_INT, offsetof(ASSDialog, margin_v) }, |
| 444 | {"Effect", ASS_STR, offsetof(ASSDialog, effect) }, |
| 445 | {"Text", ASS_STR, offsetof(ASSDialog, text) }, |
| 446 | }; |
| 447 | |
| 448 | ASSDialog *dialog = av_mallocz(sizeof(*dialog)); |
| 449 | if (!dialog) |
| 450 | return NULL; |
| 451 | |
| 452 | for (i = 0; i < FF_ARRAY_ELEMS(fields); i++) { |
| 453 | size_t len; |
| 454 | const int last = i == FF_ARRAY_ELEMS(fields) - 1; |
| 455 | const ASSFieldType type = fields[i].type; |
| 456 | uint8_t *ptr = (uint8_t *)dialog + fields[i].offset; |
| 457 | buf = skip_space(buf); |
| 458 | len = last ? strlen(buf) : strcspn(buf, ","); |
| 459 | if (len >= INT_MAX) { |
| 460 | ff_ass_free_dialog(&dialog); |
| 461 | return NULL; |
| 462 | } |
| 463 | convert_func[type](ptr, buf, len); |
| 464 | buf += len; |
| 465 | if (*buf) buf++; |
| 466 | } |
| 467 | return dialog; |
| 468 | } |
| 469 | |
| 470 | av_cold void ff_ass_split_free(ASSSplitContext *ctx) |
| 471 | { |
no test coverage detected