summaryrefslogtreecommitdiffstats
path: root/video/sws_utils.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-18 13:17:56 +0200
committerwm4 <wm4@nowhere>2013-07-18 13:31:01 +0200
commitd8659c9aa0ab74a3dabb321f34e93dd7f3890b03 (patch)
tree5116f8710d67cd9409dc54dee2e3cf5ef5e99bc6 /video/sws_utils.h
parent48789b354648b9892ec63dc91b91f7a3d5b588e4 (diff)
downloadmpv-d8659c9aa0ab74a3dabb321f34e93dd7f3890b03.tar.bz2
mpv-d8659c9aa0ab74a3dabb321f34e93dd7f3890b03.tar.xz
sws_utils: refactor swscale wrapper code
This splits the monolithic mp_image_swscale() function into a bunch of functions and a context struct. This means it's possible to set arbitrary parameters (e.g. even obscure ones without getting in the way), and you don't have to create the context on every call. This code is preparation for removing duplicated libswscale API usage from other parts of the code.
Diffstat (limited to 'video/sws_utils.h')
-rw-r--r--video/sws_utils.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/video/sws_utils.h b/video/sws_utils.h
index 22d16edefb..bef8e465ce 100644
--- a/video/sws_utils.h
+++ b/video/sws_utils.h
@@ -4,6 +4,8 @@
#include <stdbool.h>
#include <libswscale/swscale.h>
+#include "mp_image.h"
+
struct mp_image;
struct mp_csp_details;
@@ -26,6 +28,34 @@ void mp_image_swscale(struct mp_image *dst, struct mp_image *src,
void mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src,
float gblur);
+struct mp_sws_context {
+ // User configuration. These can be changed freely, at any time.
+ // mp_sws_scale() will handle the changes transparently.
+ int flags;
+ int brightness, contrast, saturation;
+ bool force_reload;
+ // These are also implicitly set by mp_sws_scale(), and thus optional.
+ // Setting them before that call makes sense when using mp_sws_reinit().
+ struct mp_image_params src, dst;
+
+ // Changing these requires setting force_reload=true.
+ // By default, they are NULL.
+ // Freeing the mp_sws_context will deallocate these if set.
+ struct SwsFilter *src_filter, *dst_filter;
+
+ // Cached context (if any)
+ struct SwsContext *sws;
+
+ // Contains parameters for which sws is valid
+ struct mp_sws_context *cached;
+};
+
+struct mp_sws_context *mp_sws_alloc(void *talloc_parent);
+int mp_sws_reinit(struct mp_sws_context *ctx);
+void mp_sws_set_from_cmdline(struct mp_sws_context *ctx);
+int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst,
+ struct mp_image *src);
+
#endif /* MP_SWS_UTILS_H */
// vim: ts=4 sw=4 et tw=80