Coverage Report

Created: 2026-01-26 07:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/mpv/video/out/gpu/utils.h
Line
Count
Source
1
#pragma once
2
3
#include <stdbool.h>
4
#include <math.h>
5
6
#include "ra.h"
7
#include "context.h"
8
9
// A 3x2 matrix, with the translation part separate.
10
struct gl_transform {
11
    // row-major, e.g. in mathematical notation:
12
    //  | m[0][0] m[0][1] |
13
    //  | m[1][0] m[1][1] |
14
    float m[2][2];
15
    float t[2];
16
};
17
18
static const struct gl_transform identity_trans = {
19
    .m = {{1.0, 0.0}, {0.0, 1.0}},
20
    .t = {0.0, 0.0},
21
};
22
23
void gl_transform_ortho(struct gl_transform *t, float x0, float x1,
24
                        float y0, float y1);
25
26
// This treats m as an affine transformation, in other words m[2][n] gets
27
// added to the output.
28
static inline void gl_transform_vec(struct gl_transform t, float *x, float *y)
29
0
{
30
0
    float vx = *x, vy = *y;
31
0
    *x = vx * t.m[0][0] + vy * t.m[0][1] + t.t[0];
32
0
    *y = vx * t.m[1][0] + vy * t.m[1][1] + t.t[1];
33
0
}
Unexecuted instantiation: vo_gpu.c:gl_transform_vec
Unexecuted instantiation: vo_gpu_next.c:gl_transform_vec
Unexecuted instantiation: context.c:gl_transform_vec
Unexecuted instantiation: ra_gl.c:gl_transform_vec
Unexecuted instantiation: utils.c:gl_transform_vec
Unexecuted instantiation: libmpv_gpu.c:gl_transform_vec
Unexecuted instantiation: video.c:gl_transform_vec
Unexecuted instantiation: video_shaders.c:gl_transform_vec
Unexecuted instantiation: libmpv_gl.c:gl_transform_vec
Unexecuted instantiation: osd.c:gl_transform_vec
Unexecuted instantiation: shader_cache.c:gl_transform_vec
Unexecuted instantiation: user_shaders.c:gl_transform_vec
Unexecuted instantiation: common.c:gl_transform_vec
34
35
struct mp_rect_f {
36
    float x0, y0, x1, y1;
37
};
38
39
// Semantic equality (fuzzy comparison)
40
static inline bool mp_rect_f_seq(struct mp_rect_f a, struct mp_rect_f b)
41
0
{
42
0
    return fabs(a.x0 - b.x0) < 1e-6 && fabs(a.x1 - b.x1) < 1e-6 &&
43
0
           fabs(a.y0 - b.y0) < 1e-6 && fabs(a.y1 - b.y1) < 1e-6;
44
0
}
Unexecuted instantiation: vo_gpu.c:mp_rect_f_seq
Unexecuted instantiation: vo_gpu_next.c:mp_rect_f_seq
Unexecuted instantiation: context.c:mp_rect_f_seq
Unexecuted instantiation: ra_gl.c:mp_rect_f_seq
Unexecuted instantiation: utils.c:mp_rect_f_seq
Unexecuted instantiation: libmpv_gpu.c:mp_rect_f_seq
Unexecuted instantiation: video.c:mp_rect_f_seq
Unexecuted instantiation: video_shaders.c:mp_rect_f_seq
Unexecuted instantiation: libmpv_gl.c:mp_rect_f_seq
Unexecuted instantiation: osd.c:mp_rect_f_seq
Unexecuted instantiation: shader_cache.c:mp_rect_f_seq
Unexecuted instantiation: user_shaders.c:mp_rect_f_seq
Unexecuted instantiation: common.c:mp_rect_f_seq
45
46
static inline void gl_transform_rect(struct gl_transform t, struct mp_rect_f *r)
47
0
{
48
0
    gl_transform_vec(t, &r->x0, &r->y0);
49
0
    gl_transform_vec(t, &r->x1, &r->y1);
50
0
}
Unexecuted instantiation: vo_gpu.c:gl_transform_rect
Unexecuted instantiation: vo_gpu_next.c:gl_transform_rect
Unexecuted instantiation: context.c:gl_transform_rect
Unexecuted instantiation: ra_gl.c:gl_transform_rect
Unexecuted instantiation: utils.c:gl_transform_rect
Unexecuted instantiation: libmpv_gpu.c:gl_transform_rect
Unexecuted instantiation: video.c:gl_transform_rect
Unexecuted instantiation: video_shaders.c:gl_transform_rect
Unexecuted instantiation: libmpv_gl.c:gl_transform_rect
Unexecuted instantiation: osd.c:gl_transform_rect
Unexecuted instantiation: shader_cache.c:gl_transform_rect
Unexecuted instantiation: user_shaders.c:gl_transform_rect
Unexecuted instantiation: common.c:gl_transform_rect
51
52
static inline bool gl_transform_eq(struct gl_transform a, struct gl_transform b)
53
0
{
54
0
    for (int x = 0; x < 2; x++) {
55
0
        for (int y = 0; y < 2; y++) {
56
0
            if (a.m[x][y] != b.m[x][y])
57
0
                return false;
58
0
        }
59
0
    }
60
61
0
    return a.t[0] == b.t[0] && a.t[1] == b.t[1];
62
0
}
Unexecuted instantiation: vo_gpu.c:gl_transform_eq
Unexecuted instantiation: vo_gpu_next.c:gl_transform_eq
Unexecuted instantiation: context.c:gl_transform_eq
Unexecuted instantiation: ra_gl.c:gl_transform_eq
Unexecuted instantiation: utils.c:gl_transform_eq
Unexecuted instantiation: libmpv_gpu.c:gl_transform_eq
Unexecuted instantiation: video.c:gl_transform_eq
Unexecuted instantiation: video_shaders.c:gl_transform_eq
Unexecuted instantiation: libmpv_gl.c:gl_transform_eq
Unexecuted instantiation: osd.c:gl_transform_eq
Unexecuted instantiation: shader_cache.c:gl_transform_eq
Unexecuted instantiation: user_shaders.c:gl_transform_eq
Unexecuted instantiation: common.c:gl_transform_eq
63
64
void gl_transform_trans(struct gl_transform t, struct gl_transform *x);
65
66
void gl_transform_ortho_fbo(struct gl_transform *t, const struct ra_fbo *fbo);
67
68
double gl_video_scale_ambient_lux(float lmin, float lmax,
69
                                  float rmin, float rmax, double lux);
70
71
// A pool of buffers, which can grow as needed
72
struct ra_buf_pool {
73
    struct ra_buf_params current_params;
74
    struct ra_buf **buffers;
75
    int num_buffers;
76
    int index;
77
};
78
79
void ra_buf_pool_uninit(struct ra *ra, struct ra_buf_pool *pool);
80
81
// Note: params->initial_data is *not* supported
82
struct ra_buf *ra_buf_pool_get(struct ra *ra, struct ra_buf_pool *pool,
83
                               const struct ra_buf_params *params);
84
85
// Helper that wraps ra_tex_upload using texture upload buffers to ensure that
86
// params->buf is always set. This is intended for RA-internal usage.
87
bool ra_tex_upload_pbo(struct ra *ra, struct ra_buf_pool *pbo,
88
                       const struct ra_tex_upload_params *params);
89
90
// Layout rules for GLSL's packing modes
91
struct ra_layout std140_layout(struct ra_renderpass_input *inp);
92
struct ra_layout std430_layout(struct ra_renderpass_input *inp);
93
94
bool ra_tex_resize(struct ra *ra, struct mp_log *log, struct ra_tex **tex,
95
                   int w, int h, const struct ra_format *fmt);
96
97
// A wrapper around ra_timer that does result pooling, averaging etc.
98
struct timer_pool;
99
100
struct timer_pool *timer_pool_create(struct ra *ra);
101
void timer_pool_destroy(struct timer_pool *pool);
102
void timer_pool_start(struct timer_pool *pool);
103
void timer_pool_stop(struct timer_pool *pool);
104
struct mp_pass_perf timer_pool_measure(struct timer_pool *pool);
105
106
// print a multi line string with line numbers (e.g. for shader sources)
107
// log, lev: module and log level, as in mp_msg()
108
void mp_log_source(struct mp_log *log, int lev, const char *src);