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 
35 #define BD_OVERLAY_INTERFACE_VERSION 2
36 
40 typedef enum {
44 
45 /*
46  * Compressed YUV overlays
47  */
48 
52 typedef 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 
77 typedef struct bd_pg_palette_entry_s {
78  uint8_t Y;
79  uint8_t Cr;
80  uint8_t Cb;
81  uint8_t T;
82 } BD_PG_PALETTE_ENTRY;
83 
87 typedef struct bd_pg_rle_elem_s {
88  uint16_t len;
89  uint16_t color;
90 } BD_PG_RLE_ELEM;
91 
95 typedef 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;
107  const BD_PG_PALETTE_ENTRY * palette;
108  const BD_PG_RLE_ELEM * img;
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 
117 const void *bd_refcnt_inc(const void *);
118 void bd_refcnt_dec(const void *);
120 #if 0
121 BD_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 
135 void 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 
151 typedef 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 
166 typedef 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;
184 } BD_ARGB_OVERLAY;
185 
195 typedef 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];
230 } BD_ARGB_BUFFER;
231 
232 #ifdef __cplusplus
233 }
234 #endif
235 
236 #endif // BD_OVERLAY_H_
bd_argb_buffer_s::dirty
struct bd_argb_buffer_s::@0 dirty[2]
Dirty area of frame buffers.
BD_OVERLAY_FLUSH
@ BD_OVERLAY_FLUSH
All changes have been done, flush overlay to display at given pts.
Definition: overlay.h:65
bd_pg_palette_entry_s::T
uint8_t T
Transparency ( 0...255).
Definition: overlay.h:81
bd_argb_buffer_s::buf
uint32_t * buf[4]
[0] - PG plane, [1] - IG plane.
Definition: overlay.h:209
BD_ARGB_OVERLAY_FLUSH
@ BD_ARGB_OVERLAY_FLUSH
All changes have been done, flush overlay to display at given pts.
Definition: overlay.h:160
bd_overlay_cmd_e
bd_overlay_cmd_e
YUV overlay event type.
Definition: overlay.h:52
bd_overlay_s::cmd
uint8_t cmd
Overlay event type (bd_overlay_cmd_e)
Definition: overlay.h:98
bd_argb_buffer_s::unlock
void(* unlock)(struct bd_argb_buffer_s *)
Unlock buffer (write complete)
Definition: overlay.h:201
bd_overlay_s::w
uint16_t w
region width
Definition: overlay.h:104
bd_pg_rle_elem_s::color
uint16_t color
palette index
Definition: overlay.h:89
bd_pg_rle_elem_s::len
uint16_t len
RLE run length.
Definition: overlay.h:88
bd_pg_palette_entry_s::Y
uint8_t Y
Y component (16...235)
Definition: overlay.h:78
bd_argb_overlay_s::w
uint16_t w
region width
Definition: overlay.h:178
bd_overlay_s::img
const BD_PG_RLE_ELEM * img
RLE-compressed overlay image.
Definition: overlay.h:108
bd_argb_buffer_s::y1
uint16_t y1
bottom-down y coordinate
Definition: overlay.h:227
bd_overlay_s::plane
uint8_t plane
Overlay plane (bd_overlay_plane_e)
Definition: overlay.h:97
bd_overlay_plane_e
bd_overlay_plane_e
Overlay plane.
Definition: overlay.h:40
bd_pg_palette_entry_s
Overlay palette entry.
Definition: overlay.h:77
bd_overlay_s::x
uint16_t x
top-left x coordinate
Definition: overlay.h:102
bd_argb_buffer_s
Application-allocated frame buffer for ARGB overlays.
Definition: overlay.h:195
bd_argb_buffer_s::x0
uint16_t x0
top-left x coordinate
Definition: overlay.h:224
bd_argb_overlay_s::h
uint16_t h
region height
Definition: overlay.h:179
BD_OVERLAY_IG
@ BD_OVERLAY_IG
Interactive Graphics plane (on top of PG plane)
Definition: overlay.h:42
bd_argb_overlay_s::plane
uint8_t plane
Overlay plane (bd_overlay_plane_e)
Definition: overlay.h:168
bd_argb_overlay_cmd_e
bd_argb_overlay_cmd_e
ARGB overlay event type.
Definition: overlay.h:151
BD_ARGB_OVERLAY_DRAW
@ BD_ARGB_OVERLAY_DRAW
Draw ARGB image on plane.
Definition: overlay.h:159
bd_refcnt_inc
const void * bd_refcnt_inc(const void *)
Hold reference-counted object.
bd_pg_palette_entry_s::Cr
uint8_t Cr
Cr component (16...240)
Definition: overlay.h:79
bd_pg_palette_entry_s::Cb
uint8_t Cb
Cb component (16...240)
Definition: overlay.h:80
BD_OVERLAY_DRAW
@ BD_OVERLAY_DRAW
Draw bitmap.
Definition: overlay.h:61
bd_overlay_s::palette
const BD_PG_PALETTE_ENTRY * palette
overlay palette (256 entries)
Definition: overlay.h:107
BD_OVERLAY_CLEAR
@ BD_OVERLAY_CLEAR
Clear overlay plane.
Definition: overlay.h:60
bd_argb_buffer_s::lock
void(* lock)(struct bd_argb_buffer_s *)
Lock (or prepare) buffer for writing.
Definition: overlay.h:200
bd_argb_overlay_s
ARGB overlay event.
Definition: overlay.h:166
bd_argb_overlay_s::argb
const uint32_t * argb
ARGB image data, 'h' lines, line stride 'stride' pixels.
Definition: overlay.h:182
bd_argb_overlay_s::x
uint16_t x
top-left x coordinate
Definition: overlay.h:176
bd_refcnt_dec
void bd_refcnt_dec(const void *)
Release reference-counted object.
BD_OVERLAY_WIPE
@ BD_OVERLAY_WIPE
Clear area.
Definition: overlay.h:62
bd_overlay_s::h
uint16_t h
region height
Definition: overlay.h:105
BD_OVERLAY_INIT
@ BD_OVERLAY_INIT
Initialize overlay plane.
Definition: overlay.h:54
bd_overlay_s::palette_update_flag
uint8_t palette_update_flag
Set if only overlay palette is changed.
Definition: overlay.h:100
bd_overlay_s::pts
int64_t pts
Timestamp, on video grid.
Definition: overlay.h:96
BD_ARGB_OVERLAY_INIT
@ BD_ARGB_OVERLAY_INIT
Initialize overlay plane.
Definition: overlay.h:153
bd_argb_buffer_s::width
int width
overlay buffer width (pixels)
Definition: overlay.h:216
bd_argb_overlay_s::y
uint16_t y
top-left y coordinate
Definition: overlay.h:177
BD_OVERLAY_HIDE
@ BD_OVERLAY_HIDE
Overlay is empty and can be hidden.
Definition: overlay.h:63
bd_argb_overlay_s::cmd
uint8_t cmd
Overlay event type (bd_argb_overlay_cmd_e)
Definition: overlay.h:169
BD_ARGB_OVERLAY_CLOSE
@ BD_ARGB_OVERLAY_CLOSE
Close overlay plane.
Definition: overlay.h:154
bd_argb_overlay_s::stride
uint16_t stride
ARGB buffer stride.
Definition: overlay.h:181
BD_OVERLAY_PG
@ BD_OVERLAY_PG
Presentation Graphics plane.
Definition: overlay.h:41
BD_OVERLAY_CLOSE
@ BD_OVERLAY_CLOSE
Close overlay plane.
Definition: overlay.h:55
bd_argb_buffer_s::height
int height
overlay buffer height (pixels)
Definition: overlay.h:217
bd_argb_overlay_s::pts
int64_t pts
Event timestamp, on video grid.
Definition: overlay.h:167
bd_argb_buffer_s::x1
uint16_t x1
bottom-down x coordinate
Definition: overlay.h:226
bd_overlay_s::y
uint16_t y
top-left y coordinate
Definition: overlay.h:103
bd_argb_buffer_s::y0
uint16_t y0
top-left y coordinate
Definition: overlay.h:225
bd_overlay_s
YUV overlay event.
Definition: overlay.h:95
bd_pg_rle_elem_s
RLE element.
Definition: overlay.h:87