VLC 4.0.0-dev
vlc_opengl_filter.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vlc_opengl_filter.h
3 *****************************************************************************
4 * Copyright (C) 2020 VLC authors and VideoLAN
5 * Copyright (C) 2020-2023 Videolabs
6 *
7 * Authors: Alexandre Janniaux <ajanni@videolabs.io>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
23
24#ifndef VLC_OPENGL_FILTER_H
25#define VLC_OPENGL_FILTER_H
26
27#include <vlc_tick.h>
28#include <vlc_ancillary.h>
29
30struct vlc_gl_filter;
31struct vlc_gl_picture;
32struct vlc_gl_format;
33
34#ifdef __cplusplus
35extern "C"
36{
37#endif
38
39struct vlc_gl_tex_size {
40 unsigned width;
41 unsigned height;
42};
43
44struct vlc_gl_input_meta {
46 unsigned plane;
48};
49
50typedef int
53 const struct vlc_gl_format *glfmt,
54 struct vlc_gl_tex_size *size_out);
55
56#define set_callback_opengl_filter(open) \
57 { \
58 vlc_gl_filter_open_fn *fn = open; \
59 (void) fn; \
60 set_callback(fn); \
61 }
62
63struct vlc_gl_filter_ops {
64 /**
65 * Draw the result of the filter to the current framebuffer
66 */
67 int (*draw)(struct vlc_gl_filter *filter, const struct vlc_gl_picture *pic,
68 const struct vlc_gl_input_meta *meta);
69
70 /**
71 * Free filter resources
72 */
73 void (*close)(struct vlc_gl_filter *filter);
75 /**
76 * Request a (responsive) filter to adapt its output size (optional)
77 *
78 * A responsive filter is a filter for which the size of the produced
79 * pictures depends on the output (e.g. display) size rather than the
80 * input. This is for example the case for a renderer.
81 *
82 * A new output size is requested (size_out). The filter is authorized to
83 * change the size_out to enforce its own constraints.
84 *
85 * In addition, it may request to the previous filter (if any) an optimal
86 * size it wants to receive. If set to non-zero value, this previous filter
87 * will receive this size as its requested size (and so on).
88 *
89 * \retval true if the resize is accepted (possibly with a modified
90 * size_out)
91 * \retval false if the resize is rejected (included on error)
92 */
93 int (*request_output_size)(struct vlc_gl_filter *filter,
94 struct vlc_gl_tex_size *size_out,
95 struct vlc_gl_tex_size *optimal_in);
96
97 /**
98 * Callback to notify input size changes
99 *
100 * When a filter changes its output size as a result of
101 * request_output_size(), the next filter is notified by this callback.
102 */
103 void (*on_input_size_change)(struct vlc_gl_filter *filter,
104 const struct vlc_gl_tex_size *size);
105};
106
107/**
108 * OpenGL filter, in charge of a rendering pass.
109 */
110struct vlc_gl_filter {
114 struct vlc_gl_t *gl;
115 const struct vlc_gl_api *api;
116 const struct vlc_gl_format *glfmt_in;
118 struct {
119 /**
120 * An OpenGL filter may either operate on the input RGBA picture, or on
121 * individual input planes (without chroma conversion) separately.
122 *
123 * In practice, this is useful for deinterlace filters.
124 *
125 * This flag must be set by the filter module (default is false).
126 */
127 bool filter_planes;
129 /**
130 * A blend filter draws over the input picture (without reading it).
131 *
132 * Meaningless if filter_planes is true.
133 *
134 * This flag must be set by the filter module (default is false).
135 */
136 bool blend;
138 /**
139 * Request MSAA level.
140 *
141 * This value must be set by the filter module (default is 0, which
142 * means disabled).
143 *
144 * Meaningless if filter_planes is true.
145 *
146 * The actual MSAA level may be overwritten to 0 if multisampling is
147 * not supported, or to a higher value if another filter rendering on
148 * the same framebuffer requested a higher MSAA level.
149 */
150 unsigned msaa_level;
153 const struct vlc_gl_filter_ops *ops;
154 void *sys;
156
157#ifdef __cplusplus
158}
159#endif
160
161#endif
static struct @11 config
Definition: vlc_configuration.h:319
Internal module descriptor.
Definition: modules.h:76
Definition: vlc_opengl_filter.h:64
int(* draw)(struct vlc_gl_filter *filter, const struct vlc_gl_picture *pic, const struct vlc_gl_input_meta *meta)
Draw the result of the filter to the current framebuffer.
Definition: vlc_opengl_filter.h:68
int(* request_output_size)(struct vlc_gl_filter *filter, struct vlc_gl_tex_size *size_out, struct vlc_gl_tex_size *optimal_in)
Request a (responsive) filter to adapt its output size (optional)
Definition: vlc_opengl_filter.h:94
void(* on_input_size_change)(struct vlc_gl_filter *filter, const struct vlc_gl_tex_size *size)
Callback to notify input size changes.
Definition: vlc_opengl_filter.h:104
void(* close)(struct vlc_gl_filter *filter)
Free filter resources.
Definition: vlc_opengl_filter.h:74
OpenGL filter, in charge of a rendering pass.
Definition: vlc_opengl_filter.h:111
module_t * module
Definition: vlc_opengl_filter.h:113
vlc_object_t obj
Definition: vlc_opengl_filter.h:112
const struct vlc_gl_filter_ops * ops
Definition: vlc_opengl_filter.h:154
const struct vlc_gl_format * glfmt_in
Definition: vlc_opengl_filter.h:117
struct vlc_gl_filter::@274 config
struct vlc_gl_t * gl
Definition: vlc_opengl_filter.h:115
bool filter_planes
An OpenGL filter may either operate on the input RGBA picture, or on individual input planes (without...
Definition: vlc_opengl_filter.h:128
unsigned msaa_level
Request MSAA level.
Definition: vlc_opengl_filter.h:151
void * sys
Definition: vlc_opengl_filter.h:155
bool blend
A blend filter draws over the input picture (without reading it).
Definition: vlc_opengl_filter.h:137
const struct vlc_gl_api * api
Definition: vlc_opengl_filter.h:116
Definition: vlc_opengl_filter.h:45
vlc_tick_t pts
Definition: vlc_opengl_filter.h:46
unsigned plane
Definition: vlc_opengl_filter.h:47
const vlc_video_dovi_metadata_t * dovi_rpu
Definition: vlc_opengl_filter.h:48
Definition: vlc_opengl.h:98
Definition: vlc_opengl_filter.h:40
unsigned height
Definition: vlc_opengl_filter.h:42
unsigned width
Definition: vlc_opengl_filter.h:41
VLC object common members.
Definition: vlc_objects.h:45
Definition: vlc_ancillary.h:138
Ancillary definition and functions.
This file is a collection of common definitions and types.
int vlc_gl_filter_open_fn(struct vlc_gl_filter *filter, const config_chain_t *config, const struct vlc_gl_format *glfmt, struct vlc_gl_tex_size *size_out)
Definition: vlc_opengl_filter.h:52
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45