libbluray
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
29 extern "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 2
42 
46 typedef enum {
50 
51 /*
52  * Compressed YUV overlays
53  */
54 
58 typedef enum {
59  /* following events are executed immediately */
63  /* following events can be processed immediately, but changes
64  * should not be flushed to display before next FLUSH event
65  */
74 
83 typedef struct bd_pg_palette_entry_s {
84  uint8_t Y;
85  uint8_t Cr;
86  uint8_t Cb;
87  uint8_t T;
89 
93 typedef struct bd_pg_rle_elem_s {
94  uint16_t len;
95  uint16_t color;
97 
101 typedef struct bd_overlay_s {
102  int64_t pts;
103  uint8_t plane;
104  uint8_t cmd;
108  uint16_t x;
109  uint16_t y;
110  uint16_t w;
111  uint16_t h;
114  const BD_PG_RLE_ELEM * img;
116 } BD_OVERLAY;
117 
118 /*
119  RLE images are reference-counted. If application caches rle data for later use,
120  it needs to use bd_refcnt_inc() and bd_refcnt_dec().
121 */
122 
123 BD_PUBLIC const void *bd_refcnt_inc(const void *);
124 BD_PUBLIC void bd_refcnt_dec(const void *);
126 #if 0
127 BD_OVERLAY *bd_overlay_copy(const BD_OVERLAY *src)
128 {
129  BD_OVERLAY *ov = malloc(sizeof(*ov));
130  memcpy(ov, src, sizeof(*ov));
131  if (ov->palette) {
132  ov->palette = malloc(256 * sizeof(BD_PG_PALETTE_ENTRY));
133  memcpy((void*)ov->palette, src->palette, 256 * sizeof(BD_PG_PALETTE_ENTRY));
134  }
135  if (ov->img) {
136  bd_refcnt_inc(ov->img);
137  }
138  return ov;
139 }
140 
141 void bd_overlay_free(BD_OVERLAY **pov)
142 {
143  if (pov && *pov) {
144  BD_OVERLAY *ov = *pov;
145  void *p = (void*)ov->palette;
146  bd_refcnt_dec(ov->img);
147  X_FREE(p);
148  ov->palette = NULL;
149  X_FREE(*pov);
150  }
151 }
152 #endif
153 
157 typedef enum {
158  /* following events are executed immediately */
162  /* following events can be processed immediately, but changes
163  * should not be flushed to display before next FLUSH event
164  */
168 
172 typedef struct bd_argb_overlay_s {
173  int64_t pts;
174  uint8_t plane;
175  uint8_t cmd;
177  /* following fileds are used only when not using application-allocated
178  * frame buffer
179  */
180 
181  /* destination clip on the overlay plane */
182  uint16_t x;
183  uint16_t y;
184  uint16_t w;
185  uint16_t h;
187  uint16_t stride;
188  const uint32_t * argb;
191 
201 typedef struct bd_argb_buffer_s {
202  /* optional lock / unlock functions
203  * - Set by application
204  * - Called when buffer is accessed or modified
205  */
206  void (*lock) (struct bd_argb_buffer_s *);
207  void (*unlock)(struct bd_argb_buffer_s *);
209  /* ARGB frame buffers
210  * - Allocated by application (BD_ARGB_OVERLAY_INIT).
211  * - Buffer can be freed after BD_ARGB_OVERLAY_CLOSE.
212  * - buffer can be replaced in overlay callback or lock().
213  */
214 
215  uint32_t *buf[4];
217  /* size of buffers
218  * - Set by application
219  * - If the buffer size is smaller than the size requested in BD_ARGB_OVERLAY_INIT,
220  * the buffer points only to the dirty area.
221  */
222  int width;
223  int height;
229  struct {
230  uint16_t x0;
231  uint16_t y0;
232  uint16_t x1;
233  uint16_t y1;
234  } dirty[2];
237 
238 #ifdef __cplusplus
239 }
240 #endif
241 
242 #endif // BD_OVERLAY_H_
Overlay palette entry.
Definition: overlay.h:83
YUV overlay event.
Definition: overlay.h:101
uint8_t Y
Y component (16...235)
Definition: overlay.h:84
Interactive Graphics plane (on top of PG plane)
Definition: overlay.h:48
uint8_t Cb
Cb component (16...240)
Definition: overlay.h:86
uint16_t y
top-left y coordinate
Definition: overlay.h:183
const uint32_t * argb
ARGB image data, 'h' lines, line stride 'stride' pixels.
Definition: overlay.h:188
Close overlay plane.
Definition: overlay.h:160
uint8_t palette_update_flag
Set if only overlay palette is changed.
Definition: overlay.h:106
Draw bitmap.
Definition: overlay.h:67
Initialize overlay plane.
Definition: overlay.h:60
Clear overlay plane.
Definition: overlay.h:66
Initialize overlay plane.
Definition: overlay.h:159
All changes have been done, flush overlay to display at given pts.
Definition: overlay.h:71
bd_overlay_cmd_e
YUV overlay event type.
Definition: overlay.h:58
uint16_t h
region height
Definition: overlay.h:111
uint16_t y
top-left y coordinate
Definition: overlay.h:109
int64_t pts
Event timestamp, on video grid.
Definition: overlay.h:173
const BD_PG_PALETTE_ENTRY * palette
overlay palette (256 entries)
Definition: overlay.h:113
uint8_t cmd
Overlay event type (bd_argb_overlay_cmd_e)
Definition: overlay.h:175
uint16_t h
region height
Definition: overlay.h:185
uint16_t x1
bottom-down x coordinate
Definition: overlay.h:232
int64_t pts
Timestamp, on video grid.
Definition: overlay.h:102
bd_overlay_plane_e
Overlay plane.
Definition: overlay.h:46
ARGB overlay event.
Definition: overlay.h:172
RLE element.
Definition: overlay.h:93
uint16_t y0
top-left y coordinate
Definition: overlay.h:231
uint8_t Cr
Cr component (16...240)
Definition: overlay.h:85
BD_PUBLIC void bd_refcnt_dec(const void *)
Release reference-counted object.
bd_argb_overlay_cmd_e
ARGB overlay event type.
Definition: overlay.h:157
Close overlay plane.
Definition: overlay.h:61
uint16_t w
region width
Definition: overlay.h:184
Overlay is empty and can be hidden.
Definition: overlay.h:69
All changes have been done, flush overlay to display at given pts.
Definition: overlay.h:166
Presentation Graphics plane.
Definition: overlay.h:47
uint16_t w
region width
Definition: overlay.h:110
uint8_t plane
Overlay plane (bd_overlay_plane_e)
Definition: overlay.h:103
uint16_t x0
top-left x coordinate
Definition: overlay.h:230
uint16_t stride
ARGB buffer stride.
Definition: overlay.h:187
int width
overlay buffer width (pixels)
Definition: overlay.h:222
uint16_t color
palette index
Definition: overlay.h:95
Draw ARGB image on plane.
Definition: overlay.h:165
Application-allocated frame buffer for ARGB overlays.
Definition: overlay.h:201
uint16_t y1
bottom-down y coordinate
Definition: overlay.h:233
Clear area.
Definition: overlay.h:68
int height
overlay buffer height (pixels)
Definition: overlay.h:223
uint8_t cmd
Overlay event type (bd_overlay_cmd_e)
Definition: overlay.h:104
BD_PUBLIC const void * bd_refcnt_inc(const void *)
Hold reference-counted object.
uint8_t T
Transparency ( 0...255).
Definition: overlay.h:87
uint8_t plane
Overlay plane (bd_overlay_plane_e)
Definition: overlay.h:174
uint16_t len
RLE run length.
Definition: overlay.h:94
const BD_PG_RLE_ELEM * img
RLE-compressed overlay image.
Definition: overlay.h:114
uint16_t x
top-left x coordinate
Definition: overlay.h:182
uint16_t x
top-left x coordinate
Definition: overlay.h:108