Commit ec3dbeae authored by Mark Thompson's avatar Mark Thompson

hwcontext: Add frame context mapping for nontrivial contexts

Some frames contexts are not usable without additional format-specific
state in hwctx.  This change adds new functions frames_derive_from and
frames_derive_to to initialise this state appropriately when deriving
a frames context which will require it to be set.

(cherry picked from commit 27978155)
parent 045ff8d3
......@@ -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;
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment