summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libavutil/hwcontext.c9
-rw-r--r--libavutil/hwcontext_internal.h5
2 files changed, 13 insertions, 1 deletions
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index b845658b40..ed09c49f2d 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -819,7 +819,14 @@ int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx,
goto fail;
}
- ret = av_hwframe_ctx_init(dst_ref);
+ ret = AVERROR(ENOSYS);
+ if (src->internal->hw_type->frames_derive_from)
+ ret = src->internal->hw_type->frames_derive_from(dst, src, flags);
+ if (ret == AVERROR(ENOSYS) &&
+ dst->internal->hw_type->frames_derive_to)
+ ret = dst->internal->hw_type->frames_derive_to(dst, src, flags);
+ if (ret == AVERROR(ENOSYS))
+ ret = 0;
if (ret)
goto fail;
diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h
index 6451c0e2c5..0a0c4e86ce 100644
--- a/libavutil/hwcontext_internal.h
+++ b/libavutil/hwcontext_internal.h
@@ -92,6 +92,11 @@ typedef struct HWContextType {
const AVFrame *src, int flags);
int (*map_from)(AVHWFramesContext *ctx, AVFrame *dst,
const AVFrame *src, int flags);
+
+ int (*frames_derive_to)(AVHWFramesContext *dst_ctx,
+ AVHWFramesContext *src_ctx, int flags);
+ int (*frames_derive_from)(AVHWFramesContext *dst_ctx,
+ AVHWFramesContext *src_ctx, int flags);
} HWContextType;
struct AVHWDeviceInternal {