Use the flags argument of av_hwframe_ctx_create_derived() to pass the mapping flags which will be used on allocation. Also, set the format and hardware context on the allocated frame automatically - the user should not be required to do this themselves.
Unified · Split
| @@ -13,6 +13,10 @@ libavutil: 2017-03-23 · 12 unmodified lines | ||
| 13 | 13 | |
| 14 | 14 | API changes, most recent first: |
| 15 | 15 | |
| 16 | +2017-04-30 - xxxxxxx - lavu 56.1.1 - hwcontext.h | |
| 17 | + av_hwframe_ctx_create_derived() now takes some AV_HWFRAME_MAP_* combination | |
| 18 | + as its flags argument (which was previously unused). | |
| 19 | + | |
| 16 | 20 | 2017-04-xx - xxxxxxx - lavu 56.1.0 - spherical.h |
| 17 | 21 | Add av_spherical_projection_name() and av_spherical_from_name(). |
| 18 | 22 | |
| @@ -455,6 +455,11 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags) · 454 unmodified lines | ||
| 455 | 455 | // and map the frame immediately. |
| 456 | 456 | AVFrame *src_frame; |
| 457 | 457 | |
| 458 | + frame->format = ctx->format; | |
| 459 | + frame->hw_frames_ctx = av_buffer_ref(hwframe_ref); | |
| 460 | + if (!frame->hw_frames_ctx) | |
| 461 | + return AVERROR(ENOMEM); | |
| 462 | + | |
| 458 | 463 | src_frame = av_frame_alloc(); |
| 459 | 464 | if (!src_frame) |
| 460 | 465 | return AVERROR(ENOMEM); |
| @@ -464,7 +469,8 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags) · 3 unmodified lines | ||
| 464 | 469 | if (ret < 0) |
| 465 | 470 | return ret; |
| 466 | 471 | |
| 467 | − ret = av_hwframe_map(frame, src_frame, 0); | |
| 472 | + ret = av_hwframe_map(frame, src_frame, | |
| 473 | + ctx->internal->source_allocation_map_flags); | |
| 468 | 474 | if (ret) { |
| 469 | 475 | av_log(ctx, AV_LOG_ERROR, "Failed to map frame into derived " |
| 470 | 476 | "frame context: %d.\n", ret); |
| @@ -816,6 +822,12 @@ int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx, · 345 unmodified lines | ||
| 816 | 822 | goto fail; |
| 817 | 823 | } |
| 818 | 824 | |
| 825 | + dst->internal->source_allocation_map_flags = | |
| 826 | + flags & (AV_HWFRAME_MAP_READ | | |
| 827 | + AV_HWFRAME_MAP_WRITE | | |
| 828 | + AV_HWFRAME_MAP_OVERWRITE | | |
| 829 | + AV_HWFRAME_MAP_DIRECT); | |
| 830 | + | |
| 819 | 831 | ret = AVERROR(ENOSYS); |
| 820 | 832 | if (src->internal->hw_type->frames_derive_from) |
| 821 | 833 | ret = src->internal->hw_type->frames_derive_from(dst, src, flags); |
| @@ -564,7 +564,9 @@ int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags); · 563 unmodified lines | ||
| 564 | 564 | * AVHWFramesContext on. |
| 565 | 565 | * @param source_frame_ctx A reference to an existing AVHWFramesContext |
| 566 | 566 | * which will be mapped to the derived context. |
| 567 | − * @param flags Currently unused; should be set to zero. | |
| 567 | + * @param flags Some combination of AV_HWFRAME_MAP_* flags, defining the | |
| 568 | + * mapping parameters to apply to frames which are allocated | |
| 569 | + * in the derived device. | |
| 568 | 570 | * @return Zero on success, negative AVERROR code on failure. |
| 569 | 571 | */ |
| 570 | 572 | int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx, |
| @@ -121,6 +121,11 @@ struct AVHWFramesInternal { · 120 unmodified lines | ||
| 121 | 121 | * context it was derived from. |
| 122 | 122 | */ |
| 123 | 123 | AVBufferRef *source_frames; |
| 124 | + /** | |
| 125 | + * Flags to apply to the mapping from the source to the derived | |
| 126 | + * frame context when trying to allocate in the derived context. | |
| 127 | + */ | |
| 128 | + int source_allocation_map_flags; | |
| 124 | 129 | }; |
| 125 | 130 | |
| 126 | 131 | typedef struct HWMapDescriptor { |
| @@ -55,7 +55,7 @@ · 54 unmodified lines | ||
| 55 | 55 | |
| 56 | 56 | #define LIBAVUTIL_VERSION_MAJOR 56 |
| 57 | 57 | #define LIBAVUTIL_VERSION_MINOR 1 |
| 58 | −#define LIBAVUTIL_VERSION_MICRO 0 | |
| 58 | +#define LIBAVUTIL_VERSION_MICRO 1 | |
| 59 | 59 | |
| 60 | 60 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| 61 | 61 | LIBAVUTIL_VERSION_MINOR, \ |