libbluray
Loading...
Searching...
No Matches
overlay.h
Go to the documentation of this file.
1/*
2 * This file is part of libbluray
3 * Copyright (C) 2010-2026 Petri Hintukainen <phintuka@users.sourceforge.net>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library. If not, see
17 * <http://www.gnu.org/licenses/>.
18 */
19
24
25#ifndef BD_OVERLAY_H_
26#define BD_OVERLAY_H_
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <stdint.h>
33
34#ifdef BLURAY_API_EXPORT
35#include "util/attributes.h"
36#elif !defined(BD_PUBLIC)
37#define BD_PUBLIC
38#endif
39
41#define BD_OVERLAY_INTERFACE_VERSION 3
42
51
52/*
53 * Compressed YUV overlays
54 */
55
59typedef enum {
60 /* following events are executed immediately */
63
64 /* following events can be processed immediately, but changes
65 * should not be flushed to display before next FLUSH event
66 */
71
73
75
84typedef struct bd_pg_palette_entry_s {
85 uint8_t Y;
86 uint8_t Cr;
87 uint8_t Cb;
88 uint8_t T;
90
94typedef struct bd_pg_rle_elem_s {
95 uint16_t len;
96 uint16_t color;
98
102typedef struct bd_overlay_s {
103 int64_t pts;
104 uint8_t plane;
105 uint8_t cmd;
106
108
109 uint16_t x;
110 uint16_t y;
111 uint16_t w;
112 uint16_t h;
113
116
117} BD_OVERLAY;
118
119/*
120 RLE images are reference-counted. If application caches rle data for later use,
121 it needs to use bd_refcnt_inc() and bd_refcnt_dec().
122*/
123
124BD_PUBLIC const void *bd_refcnt_inc(const void *);
125BD_PUBLIC void bd_refcnt_dec(const void *);
126
127#if 0
128BD_OVERLAY *bd_overlay_copy(const BD_OVERLAY *src)
129{
130 BD_OVERLAY *ov = malloc(sizeof(*ov));
131 memcpy(ov, src, sizeof(*ov));
132 if (ov->palette) {
133 ov->palette = malloc(256 * sizeof(BD_PG_PALETTE_ENTRY));
134 memcpy((void*)ov->palette, src->palette, 256 * sizeof(BD_PG_PALETTE_ENTRY));
135 }
136 if (ov->img) {
137 bd_refcnt_inc(ov->img);
138 }
139 return ov;
140}
141
142void bd_overlay_free(BD_OVERLAY **pov)
143{
144 if (pov && *pov) {
145 BD_OVERLAY *ov = *pov;
146 void *p = (void*)ov->palette;
147 bd_refcnt_dec(ov->img);
148 X_FREE(p);
149 ov->palette = NULL;
150 X_FREE(*pov);
151 }
152}
153#endif
154
158typedef enum {
159 /* following events are executed immediately */
162
163 /* following events can be processed immediately, but changes
164 * should not be flushed to display before next FLUSH event
165 */
169
173typedef struct bd_argb_overlay_s {
174 int64_t pts;
175 uint8_t plane;
176 uint8_t cmd;
177
178 /* following fileds are used only when not using application-allocated
179 * frame buffer
180 */
181
182 /* destination clip on the overlay plane */
183 uint16_t x;
184 uint16_t y;
185 uint16_t w;
186 uint16_t h;
187
188 uint16_t stride;
189 const uint32_t * argb;
190
192
202typedef struct bd_argb_buffer_s {
203 /* optional lock / unlock functions
204 * - Set by application
205 * - Called when buffer is accessed or modified
206 */
207 void (*lock) (struct bd_argb_buffer_s *);
208 void (*unlock)(struct bd_argb_buffer_s *);
209
210 /* ARGB frame buffers
211 * - Allocated by application (BD_ARGB_OVERLAY_INIT).
212 * - Buffer can be freed after BD_ARGB_OVERLAY_CLOSE.
213 * - buffer can be replaced in overlay callback or lock().
214 */
215
216 uint32_t *buf[6];
217
218 /* size of buffers
219 * - Set by application
220 * - If the buffer size is smaller than the size requested in BD_ARGB_OVERLAY_INIT,
221 * the buffer points only to the dirty area.
222 */
223 int width;
224 int height;
225
230 struct {
231 uint16_t x0;
232 uint16_t y0;
233 uint16_t x1;
234 uint16_t y1;
235 } dirty[3];
236
238
239#ifdef __cplusplus
240}
241#endif
242
243#endif // BD_OVERLAY_H_
BD_PUBLIC void bd_refcnt_dec(const void *)
Release reference-counted object.
bd_argb_overlay_cmd_e
ARGB overlay event type.
Definition overlay.h:158
@ BD_ARGB_OVERLAY_INIT
Initialize overlay plane.
Definition overlay.h:160
@ BD_ARGB_OVERLAY_CLOSE
Close overlay plane.
Definition overlay.h:161
@ BD_ARGB_OVERLAY_DRAW
Draw ARGB image on plane.
Definition overlay.h:166
@ BD_ARGB_OVERLAY_FLUSH
All changes have been done, flush overlay to display at given pts.
Definition overlay.h:167
bd_overlay_cmd_e
YUV overlay event type.
Definition overlay.h:59
@ BD_OVERLAY_INIT
Initialize overlay plane.
Definition overlay.h:61
@ BD_OVERLAY_WIPE
Clear area.
Definition overlay.h:69
@ BD_OVERLAY_HIDE
Overlay is empty and can be hidden.
Definition overlay.h:70
@ BD_OVERLAY_DRAW
Draw bitmap.
Definition overlay.h:68
@ BD_OVERLAY_CLEAR
Clear overlay plane.
Definition overlay.h:67
@ BD_OVERLAY_CLOSE
Close overlay plane.
Definition overlay.h:62
@ BD_OVERLAY_FLUSH
All changes have been done, flush overlay to display at given pts.
Definition overlay.h:72
bd_overlay_plane_e
Overlay plane.
Definition overlay.h:46
@ BD_OVERLAY_IG
Interactive Graphics plane (on top of PG plane).
Definition overlay.h:48
@ BD_OVERLAY_BG
Background Graphics plane (behind video).
Definition overlay.h:49
@ BD_OVERLAY_PG
Presentation Graphics plane.
Definition overlay.h:47
BD_PUBLIC const void * bd_refcnt_inc(const void *)
Hold reference-counted object.
Application-allocated frame buffer for ARGB overlays.
Definition overlay.h:202
void(* unlock)(struct bd_argb_buffer_s *)
Unlock buffer (write complete).
Definition overlay.h:208
int height
overlay buffer height (pixels)
Definition overlay.h:224
int width
overlay buffer width (pixels)
Definition overlay.h:223
void(* lock)(struct bd_argb_buffer_s *)
Lock (or prepare) buffer for writing.
Definition overlay.h:207
uint16_t x0
top-left x coordinate
Definition overlay.h:231
uint16_t y0
top-left y coordinate
Definition overlay.h:232
uint32_t * buf[6]
[0] - PG plane, [1] - IG plane, [2] - Background plane.
Definition overlay.h:216
uint16_t x1
bottom-down x coordinate
Definition overlay.h:233
uint16_t y1
bottom-down y coordinate
Definition overlay.h:234
ARGB overlay event.
Definition overlay.h:173
uint16_t y
top-left y coordinate
Definition overlay.h:184
int64_t pts
Event timestamp, on video grid.
Definition overlay.h:174
uint16_t h
region height
Definition overlay.h:186
const uint32_t * argb
ARGB image data, 'h' lines, line stride 'stride' pixels.
Definition overlay.h:189
uint8_t cmd
Overlay event type (bd_argb_overlay_cmd_e).
Definition overlay.h:176
uint8_t plane
Overlay plane (bd_overlay_plane_e).
Definition overlay.h:175
uint16_t x
top-left x coordinate
Definition overlay.h:183
uint16_t stride
ARGB buffer stride.
Definition overlay.h:188
uint16_t w
region width
Definition overlay.h:185
YUV overlay event.
Definition overlay.h:102
uint8_t cmd
Overlay event type (bd_overlay_cmd_e).
Definition overlay.h:105
const BD_PG_PALETTE_ENTRY * palette
overlay palette (256 entries)
Definition overlay.h:114
uint16_t x
top-left x coordinate
Definition overlay.h:109
uint8_t palette_update_flag
Set if only overlay palette is changed.
Definition overlay.h:107
int64_t pts
Timestamp, on video grid.
Definition overlay.h:103
uint16_t y
top-left y coordinate
Definition overlay.h:110
uint16_t w
region width
Definition overlay.h:111
uint8_t plane
Overlay plane (bd_overlay_plane_e).
Definition overlay.h:104
uint16_t h
region height
Definition overlay.h:112
const BD_PG_RLE_ELEM * img
RLE-compressed overlay image.
Definition overlay.h:115
Overlay palette entry.
Definition overlay.h:84
uint8_t T
Transparency ( 0...255).
Definition overlay.h:88
uint8_t Cb
Cb component (16...240).
Definition overlay.h:87
uint8_t Y
Y component (16...235).
Definition overlay.h:85
uint8_t Cr
Cr component (16...240).
Definition overlay.h:86
RLE element.
Definition overlay.h:94
uint16_t len
RLE run length.
Definition overlay.h:95
uint16_t color
palette index
Definition overlay.h:96