summaryrefslogtreecommitdiff
path: root/libavutil/hwcontext.c
diff options
context:
space:
mode:
authorMark Thompson <mrt@jkqxz.net>2016-02-18 23:25:52 +0000
committerAnton Khirnov <anton@khirnov.net>2016-03-19 15:38:00 +0100
commitb1f01e85a92d401a9b29c79f23db36b7685e8c09 (patch)
tree16b5ce3710f61e21f8dd6a368bc1cbede920a399 /libavutil/hwcontext.c
parent1098f5c0495c61a98d4ff6b8e24c17974d4bace5 (diff)
lavu: add a way to query hwcontext frame constraints
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavutil/hwcontext.c')
-rw-r--r--libavutil/hwcontext.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index b6d05181c4..53e11b8eae 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);
+}