diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-14 15:33:37 +0300 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2016-04-14 15:33:37 +0300 |
commit | afccfaf26ac8fae3257302a74110b40615dfa05d (patch) | |
tree | 8d624efea672bfa209398c7157ab9fdcc123c49e /libavutil/hwcontext.c | |
parent | 7af788aa625735fa9b3ff2e647f497c62127e855 (diff) | |
parent | b1f01e85a92d401a9b29c79f23db36b7685e8c09 (diff) |
Merge commit 'b1f01e85a92d401a9b29c79f23db36b7685e8c09'
* commit 'b1f01e85a92d401a9b29c79f23db36b7685e8c09':
lavu: add a way to query hwcontext frame constraints
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavutil/hwcontext.c')
-rw-r--r-- | libavutil/hwcontext.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index 3eada29742..4dfec2c4dc 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -400,3 +400,48 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags) return 0; } + +void *av_hwdevice_hwconfig_alloc(AVBufferRef *ref) +{ + AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data; + const HWContextType *hw_type = ctx->internal->hw_type; + + if (hw_type->device_hwconfig_size == 0) + return NULL; + + return av_mallocz(hw_type->device_hwconfig_size); +} + +AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, + const void *hwconfig) +{ + AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data; + const HWContextType *hw_type = ctx->internal->hw_type; + AVHWFramesConstraints *constraints; + + if (!hw_type->frames_get_constraints) + return NULL; + + constraints = av_mallocz(sizeof(*constraints)); + if (!constraints) + return NULL; + + constraints->min_width = constraints->min_height = 0; + constraints->max_width = constraints->max_height = INT_MAX; + + if (hw_type->frames_get_constraints(ctx, hwconfig, constraints) >= 0) { + return constraints; + } else { + av_hwframe_constraints_free(&constraints); + return NULL; + } +} + +void av_hwframe_constraints_free(AVHWFramesConstraints **constraints) +{ + if (*constraints) { + av_freep(&(*constraints)->valid_hw_formats); + av_freep(&(*constraints)->valid_sw_formats); + } + av_freep(constraints); +} |