aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/sws_utils.h
blob: 41472b5ecf4d786c1b46adad96a1325207ff2af3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef MPLAYER_SWS_UTILS_H
#define MPLAYER_SWS_UTILS_H

#include <stdbool.h>

#include "mp_image.h"

struct mp_image;
struct mpv_global;

// libswscale currently requires 16 bytes alignment for row pointers and
// strides. Otherwise, it will print warnings and use slow codepaths.
// Guaranteed to be a power of 2 and > 1.
#define SWS_MIN_BYTE_ALIGN 16

extern const int mp_sws_hq_flags;
extern const int mp_sws_fast_flags;

bool mp_sws_supported_format(int imgfmt);

int mp_image_swscale(struct mp_image *dst, struct mp_image *src,
                     int my_sws_flags);

int mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src,
                           float gblur);

struct mp_sws_context {
    // Can be set for verbose error printing.
    struct mp_log *log;
    // 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;
    double params[2];

    // Cached context (if any)
    struct SwsContext *sws;
    bool supports_csp;

    // Contains parameters for which sws is valid
    struct mp_sws_context *cached;
};

struct mp_sws_context *mp_sws_alloc(void *talloc_ctx);
int mp_sws_reinit(struct mp_sws_context *ctx);
void mp_sws_set_from_cmdline(struct mp_sws_context *ctx, struct mpv_global *g);
int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst,
                 struct mp_image *src);

struct mp_image *mp_img_swap_to_native(struct mp_image *img);

#endif /* MP_SWS_UTILS_H */

// vim: ts=4 sw=4 et tw=80