| 541 | } |
| 542 | |
| 543 | static int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy) |
| 544 | { |
| 545 | AVBufferRef *buf; |
| 546 | AVSubtitle *sub; |
| 547 | int ret; |
| 548 | |
| 549 | if (copy) { |
| 550 | sub = av_mallocz(sizeof(*sub)); |
| 551 | ret = sub ? copy_av_subtitle(sub, subtitle) : AVERROR(ENOMEM); |
| 552 | if (ret < 0) { |
| 553 | av_freep(&sub); |
| 554 | return ret; |
| 555 | } |
| 556 | } else { |
| 557 | sub = av_memdup(subtitle, sizeof(*subtitle)); |
| 558 | if (!sub) |
| 559 | return AVERROR(ENOMEM); |
| 560 | memset(subtitle, 0, sizeof(*subtitle)); |
| 561 | } |
| 562 | |
| 563 | buf = av_buffer_create((uint8_t*)sub, sizeof(*sub), |
| 564 | subtitle_free, NULL, 0); |
| 565 | if (!buf) { |
| 566 | avsubtitle_free(sub); |
| 567 | av_freep(&sub); |
| 568 | return AVERROR(ENOMEM); |
| 569 | } |
| 570 | |
| 571 | frame->buf[0] = buf; |
| 572 | |
| 573 | return 0; |
| 574 | } |
| 575 | |
| 576 | static int process_subtitle(DecoderPriv *dp, AVFrame *frame) |
| 577 | { |
no test coverage detected