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-2017 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
25#ifndef BD_OVERLAY_H_
26#define BD_OVERLAY_H_
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <stdint.h>
33
35#define BD_OVERLAY_INTERFACE_VERSION 2
36
40typedef enum {
44
45/*
46 * Compressed YUV overlays
47 */
48
52typedef enum {
53 /* following events are executed immediately */
57 /* following events can be processed immediately, but changes
58 * should not be flushed to display before next FLUSH event
59 */
68
77typedef struct bd_pg_palette_entry_s {
78 uint8_t Y;
79 uint8_t Cr;
80 uint8_t Cb;
81 uint8_t T;
83
87typedef struct bd_pg_rle_elem_s {
88 uint16_t len;
89 uint16_t color;
91
95typedef struct bd_overlay_s {
96 int64_t pts;
97 uint8_t plane;
98 uint8_t cmd;
102 uint16_t x;
103 uint16_t y;
104 uint16_t w;
105 uint16_t h;
110} BD_OVERLAY;
111
112/*
113 RLE images are reference-counted. If application caches rle data for later use,
114 it needs to use bd_refcnt_inc() and bd_refcnt_dec().
115*/
116
117const void *bd_refcnt_inc(const void *);
118void bd_refcnt_dec(const void *);
120#if 0
121BD_OVERLAY *bd_overlay_copy(const BD_OVERLAY *src)
122{
123 BD_OVERLAY *ov = malloc(sizeof(*ov));
124 memcpy(ov, src, sizeof(*ov));
125 if (ov->palette) {
126 ov->palette = malloc(256 * sizeof(BD_PG_PALETTE_ENTRY));
127 memcpy((void*)ov->palette, src->palette, 256 * sizeof(BD_PG_PALETTE_ENTRY));
128 }
129 if (ov->img) {
130 bd_refcnt_inc(ov->img);
131 }
132 return ov;
133}
134
135void bd_overlay_free(BD_OVERLAY **pov)
136{
137 if (pov && *pov) {
138 BD_OVERLAY *ov = *pov;
139 void *p = (void*)ov->palette;
140 bd_refcnt_dec(ov->img);
141 X_FREE(p);
142 ov->palette = NULL;
143 X_FREE(*pov);
144 }
145}
146#endif
147
151typedef enum {
152 /* following events are executed immediately */
156 /* following events can be processed immediately, but changes
157 * should not be flushed to display before next FLUSH event
158 */
162
166typedef struct bd_argb_overlay_s {
167 int64_t pts;
168 uint8_t plane;
169 uint8_t cmd;
171 /* following fileds are used only when not using application-allocated
172 * frame buffer
173 */
174
175 /* destination clip on the overlay plane */
176 uint16_t x;
177 uint16_t y;
178 uint16_t w;
179 uint16_t h;
181 uint16_t stride;
182 const uint32_t * argb;
185
195typedef struct bd_argb_buffer_s {
196 /* optional lock / unlock functions
197 * - Set by application
198 * - Called when buffer is accessed or modified
199 */
200 void (*lock) (struct bd_argb_buffer_s *);
201 void (*unlock)(struct bd_argb_buffer_s *);
203 /* ARGB frame buffers
204 * - Allocated by application (BD_ARGB_OVERLAY_INIT).
205 * - Buffer can be freed after BD_ARGB_OVERLAY_CLOSE.
206 * - buffer can be replaced in overlay callback or lock().
207 */
208
209 uint32_t *buf[4];
211 /* size of buffers
212 * - Set by application
213 * - If the buffer size is smaller than the size requested in BD_ARGB_OVERLAY_INIT,
214 * the buffer points only to the dirty area.
215 */
216 int width;
217 int height;
223 struct {
224 uint16_t x0;
225 uint16_t y0;
226 uint16_t x1;
227 uint16_t y1;
228 } dirty[2];
231
232#ifdef __cplusplus
233}
234#endif
235
236#endif // BD_OVERLAY_H_
void bd_refcnt_dec(const void *)
Release reference-counted object.
const void * bd_refcnt_inc(const void *)
Hold reference-counted object.
bd_argb_overlay_cmd_e
ARGB overlay event type.
Definition overlay.h:151
@ BD_ARGB_OVERLAY_INIT
Initialize overlay plane.
Definition overlay.h:153
@ BD_ARGB_OVERLAY_CLOSE
Close overlay plane.
Definition overlay.h:154
@ BD_ARGB_OVERLAY_DRAW
Draw ARGB image on plane.
Definition overlay.h:159
@ BD_ARGB_OVERLAY_FLUSH
All changes have been done, flush overlay to display at given pts.
Definition overlay.h:160
bd_overlay_cmd_e
YUV overlay event type.
Definition overlay.h:52
@ BD_OVERLAY_INIT
Initialize overlay plane.
Definition overlay.h:54
@ BD_OVERLAY_WIPE
Clear area.
Definition overlay.h:62
@ BD_OVERLAY_HIDE
Overlay is empty and can be hidden.
Definition overlay.h:63
@ BD_OVERLAY_DRAW
Draw bitmap.
Definition overlay.h:61
@ BD_OVERLAY_CLEAR
Clear overlay plane.
Definition overlay.h:60
@ BD_OVERLAY_CLOSE
Close overlay plane.
Definition overlay.h:55
@ BD_OVERLAY_FLUSH
All changes have been done, flush overlay to display at given pts.
Definition overlay.h:65
bd_overlay_plane_e
Overlay plane.
Definition overlay.h:40
@ BD_OVERLAY_IG
Interactive Graphics plane (on top of PG plane)
Definition overlay.h:42
@ BD_OVERLAY_PG
Presentation Graphics plane.
Definition overlay.h:41
Application-allocated frame buffer for ARGB overlays.
Definition overlay.h:195
int height
overlay buffer height (pixels)
Definition overlay.h:217
int width
overlay buffer width (pixels)
Definition overlay.h:216
uint16_t x0
top-left x coordinate
Definition overlay.h:224
uint16_t y0
top-left y coordinate
Definition overlay.h:225
uint16_t x1
bottom-down x coordinate
Definition overlay.h:226
uint16_t y1
bottom-down y coordinate
Definition overlay.h:227
ARGB overlay event.
Definition overlay.h:166
uint16_t y
top-left y coordinate
Definition overlay.h:177
int64_t pts
Event timestamp, on video grid.
Definition overlay.h:167
uint16_t h
region height
Definition overlay.h:179
const uint32_t * argb
ARGB image data, 'h' lines, line stride 'stride' pixels.
Definition overlay.h:182
uint8_t cmd
Overlay event type (bd_argb_overlay_cmd_e)
Definition overlay.h:169
uint8_t plane
Overlay plane (bd_overlay_plane_e)
Definition overlay.h:168
uint16_t x
top-left x coordinate
Definition overlay.h:176
uint16_t stride
ARGB buffer stride.
Definition overlay.h:181
uint16_t w
region width
Definition overlay.h:178
YUV overlay event.
Definition overlay.h:95
uint8_t cmd
Overlay event type (bd_overlay_cmd_e)
Definition overlay.h:98
const BD_PG_PALETTE_ENTRY * palette
overlay palette (256 entries)
Definition overlay.h:107
uint16_t x
top-left x coordinate
Definition overlay.h:102
uint8_t palette_update_flag
Set if only overlay palette is changed.
Definition overlay.h:100
int64_t pts
Timestamp, on video grid.
Definition overlay.h:96
uint16_t y
top-left y coordinate
Definition overlay.h:103
uint16_t w
region width
Definition overlay.h:104
uint8_t plane
Overlay plane (bd_overlay_plane_e)
Definition overlay.h:97
uint16_t h
region height
Definition overlay.h:105
const BD_PG_RLE_ELEM * img
RLE-compressed overlay image.
Definition overlay.h:108
Overlay palette entry.
Definition overlay.h:77
uint8_t T
Transparency ( 0...255).
Definition overlay.h:81
uint8_t Cb
Cb component (16...240)
Definition overlay.h:80
uint8_t Y
Y component (16...235)
Definition overlay.h:78
uint8_t Cr
Cr component (16...240)
Definition overlay.h:79
RLE element.
Definition overlay.h:87
uint16_t len
RLE run length.
Definition overlay.h:88
uint16_t color
palette index
Definition overlay.h:89