1 #ifndef MPLAYER_SWS_UTILS_H 2 #define MPLAYER_SWS_UTILS_H 3 4 #include <stdbool.h> 5 6 #include "mp_image.h" 7 8 struct mp_image; 9 struct mpv_global; 10 11 // libswscale currently requires 16 bytes alignment for row pointers and 12 // strides. Otherwise, it will print warnings and use slow codepaths. 13 // Guaranteed to be a power of 2 and > 1. 14 #define SWS_MIN_BYTE_ALIGN MP_IMAGE_BYTE_ALIGN 15 16 extern const int mp_sws_fast_flags; 17 18 bool mp_sws_supported_format(int imgfmt); 19 20 int mp_image_swscale(struct mp_image *dst, struct mp_image *src, 21 int my_sws_flags); 22 23 int mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src, 24 float gblur); 25 26 enum mp_sws_scaler { 27 MP_SWS_AUTO = 0, // use command line 28 MP_SWS_SWS, 29 MP_SWS_ZIMG, 30 }; 31 32 struct mp_sws_context { 33 // Can be set for verbose error printing. 34 struct mp_log *log; 35 // User configuration. These can be changed freely, at any time. 36 // mp_sws_scale() will handle the changes transparently. 37 int flags; 38 bool allow_zimg; // use zimg if available (ignores filters and all) 39 bool force_reload; 40 // These are also implicitly set by mp_sws_scale(), and thus optional. 41 // Setting them before that call makes sense when using mp_sws_reinit(). 42 struct mp_image_params src, dst; 43 44 // This is unfortunately a hack: bypass command line choice 45 enum mp_sws_scaler force_scaler; 46 47 // If zimg is used. Need to manually invalidate cache (set force_reload). 48 // Conflicts with enabling command line opts. 49 struct zimg_opts *zimg_opts; 50 51 // Changing these requires setting force_reload=true. 52 // By default, they are NULL. 53 // Freeing the mp_sws_context will deallocate these if set. 54 struct SwsFilter *src_filter, *dst_filter; 55 double params[2]; 56 57 // Cached context (if any) 58 struct SwsContext *sws; 59 bool supports_csp; 60 61 // Private. 62 struct m_config_cache *opts_cache; 63 struct mp_sws_context *cached; // contains parameters for which sws is valid 64 struct mp_zimg_context *zimg; 65 bool zimg_ok; 66 struct mp_image *aligned_src, *aligned_dst; 67 }; 68 69 struct mp_sws_context *mp_sws_alloc(void *talloc_ctx); 70 void mp_sws_enable_cmdline_opts(struct mp_sws_context *ctx, struct mpv_global *g); 71 int mp_sws_reinit(struct mp_sws_context *ctx); 72 int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst, 73 struct mp_image *src); 74 75 bool mp_sws_supports_formats(struct mp_sws_context *ctx, 76 int imgfmt_out, int imgfmt_in); 77 78 struct mp_image *mp_img_swap_to_native(struct mp_image *img); 79 80 #endif /* MP_SWS_UTILS_H */ 81 82 // vim: ts=4 sw=4 et tw=80 83