| 739 | } |
| 740 | |
| 741 | int ff_hwframe_map_create(AVBufferRef *hwframe_ref, |
| 742 | AVFrame *dst, const AVFrame *src, |
| 743 | void (*unmap)(AVHWFramesContext *ctx, |
| 744 | HWMapDescriptor *hwmap), |
| 745 | void *priv) |
| 746 | { |
| 747 | AVHWFramesContext *ctx = (AVHWFramesContext*)hwframe_ref->data; |
| 748 | HWMapDescriptor *hwmap; |
| 749 | int ret; |
| 750 | |
| 751 | hwmap = av_mallocz(sizeof(*hwmap)); |
| 752 | if (!hwmap) { |
| 753 | ret = AVERROR(ENOMEM); |
| 754 | goto fail; |
| 755 | } |
| 756 | |
| 757 | hwmap->source = av_frame_alloc(); |
| 758 | if (!hwmap->source) { |
| 759 | ret = AVERROR(ENOMEM); |
| 760 | goto fail; |
| 761 | } |
| 762 | ret = av_frame_ref(hwmap->source, src); |
| 763 | if (ret < 0) |
| 764 | goto fail; |
| 765 | |
| 766 | hwmap->hw_frames_ctx = av_buffer_ref(hwframe_ref); |
| 767 | if (!hwmap->hw_frames_ctx) { |
| 768 | ret = AVERROR(ENOMEM); |
| 769 | goto fail; |
| 770 | } |
| 771 | |
| 772 | hwmap->unmap = unmap; |
| 773 | hwmap->priv = priv; |
| 774 | |
| 775 | dst->buf[0] = av_buffer_create((uint8_t*)hwmap, sizeof(*hwmap), |
| 776 | &ff_hwframe_unmap, ctx, 0); |
| 777 | if (!dst->buf[0]) { |
| 778 | ret = AVERROR(ENOMEM); |
| 779 | goto fail; |
| 780 | } |
| 781 | |
| 782 | return 0; |
| 783 | |
| 784 | fail: |
| 785 | if (hwmap) { |
| 786 | av_buffer_unref(&hwmap->hw_frames_ctx); |
| 787 | av_frame_free(&hwmap->source); |
| 788 | } |
| 789 | av_free(hwmap); |
| 790 | return ret; |
| 791 | } |
| 792 | |
| 793 | int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags) |
| 794 | { |
no test coverage detected