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)
Unified · Split
| @@ -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 | ||
| @@ -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 | ||
| 97 | struct AVHWDeviceInternal { | 102 | struct AVHWDeviceInternal { |