History

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 27978155bc661eec9f22bcf82c9cfc099cff4365)

Mark Thompson committed 9 years ago

Commit ec3dbea1 parent 045ff8d2 files · +13 −1Browse files

Unified · Split

2 files
  1. libavutil/hwcontext.c +8 −1
  2. libavutil/hwcontext_internal.h +5 −0
libavutil/hwcontext.c+8−1
@@ -819,7 +819,14 @@ int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx, · 818 unmodified lines
819 goto fail;819 goto fail;
820 }820 }
821 821
822 ret = av_hwframe_ctx_init(dst_ref);822 ret = AVERROR(ENOSYS);
823 if (src->internal->hw_type->frames_derive_from)
824 ret = src->internal->hw_type->frames_derive_from(dst, src, flags);
825 if (ret == AVERROR(ENOSYS) &&
826 dst->internal->hw_type->frames_derive_to)
827 ret = dst->internal->hw_type->frames_derive_to(dst, src, flags);
828 if (ret == AVERROR(ENOSYS))
829 ret = 0;
823 if (ret)830 if (ret)
824 goto fail;831 goto fail;
825 832
libavutil/hwcontext_internal.h+5−0
@@ -92,6 +92,11 @@ typedef struct HWContextType { · 91 unmodified lines
92 const AVFrame *src, int flags);92 const AVFrame *src, int flags);
93 int (*map_from)(AVHWFramesContext *ctx, AVFrame *dst,93 int (*map_from)(AVHWFramesContext *ctx, AVFrame *dst,
94 const AVFrame *src, int flags);94 const AVFrame *src, int flags);
95
96 int (*frames_derive_to)(AVHWFramesContext *dst_ctx,
97 AVHWFramesContext *src_ctx, int flags);
98 int (*frames_derive_from)(AVHWFramesContext *dst_ctx,
99 AVHWFramesContext *src_ctx, int flags);
95} HWContextType;100} HWContextType;
96 101
97struct AVHWDeviceInternal {102struct AVHWDeviceInternal {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t