Loading...
Searching...
No Matches
overlay.h
Go to the documentation of this file.
/*
* This file is part of libbluray
* Copyright (C) 2010-2017 Petri Hintukainen <phintuka@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef BD_OVERLAY_H_
#define BD_OVERLAY_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#ifdef BLURAY_API_EXPORT
#include "util/attributes.h"
#elif !defined(BD_PUBLIC)
#define BD_PUBLIC
#endif
#define BD_OVERLAY_INTERFACE_VERSION 2
typedef enum {
BD_OVERLAY_PG = 0,
BD_OVERLAY_IG = 1,
} bd_overlay_plane_e;
/*
* Compressed YUV overlays
*/
typedef enum {
/* following events are executed immediately */
BD_OVERLAY_INIT = 0,
BD_OVERLAY_CLOSE = 1,
/* following events can be processed immediately, but changes
* should not be flushed to display before next FLUSH event
*/
BD_OVERLAY_CLEAR = 2,
BD_OVERLAY_DRAW = 3,
BD_OVERLAY_WIPE = 4,
BD_OVERLAY_HIDE = 5,
BD_OVERLAY_FLUSH = 6,
} bd_overlay_cmd_e;
typedef struct bd_pg_palette_entry_s {
uint8_t Y;
uint8_t Cr;
uint8_t Cb;
uint8_t T;
} BD_PG_PALETTE_ENTRY;
typedef struct bd_pg_rle_elem_s {
uint16_t len;
uint16_t color;
} BD_PG_RLE_ELEM;
typedef struct bd_overlay_s {
int64_t pts;
uint8_t plane;
uint8_t cmd;
uint8_t palette_update_flag;
uint16_t x;
uint16_t y;
uint16_t w;
uint16_t h;
const BD_PG_PALETTE_ENTRY * palette;
const BD_PG_RLE_ELEM * img;
} BD_OVERLAY;
/*
RLE images are reference-counted. If application caches rle data for later use,
it needs to use bd_refcnt_inc() and bd_refcnt_dec().
*/
BD_PUBLIC const void *bd_refcnt_inc(const void *);
BD_PUBLIC void bd_refcnt_dec(const void *);
#if 0
BD_OVERLAY *bd_overlay_copy(const BD_OVERLAY *src)
{
BD_OVERLAY *ov = malloc(sizeof(*ov));
memcpy(ov, src, sizeof(*ov));
if (ov->palette) {
ov->palette = malloc(256 * sizeof(BD_PG_PALETTE_ENTRY));
memcpy((void*)ov->palette, src->palette, 256 * sizeof(BD_PG_PALETTE_ENTRY));
}
if (ov->img) {
bd_refcnt_inc(ov->img);
}
return ov;
}
void bd_overlay_free(BD_OVERLAY **pov)
{
if (pov && *pov) {
BD_OVERLAY *ov = *pov;
void *p = (void*)ov->palette;
bd_refcnt_dec(ov->img);
X_FREE(p);
ov->palette = NULL;
X_FREE(*pov);
}
}
#endif
typedef enum {
/* following events are executed immediately */
BD_ARGB_OVERLAY_INIT = 0,
BD_ARGB_OVERLAY_CLOSE = 1,
/* following events can be processed immediately, but changes
* should not be flushed to display before next FLUSH event
*/
BD_ARGB_OVERLAY_DRAW = 3,
BD_ARGB_OVERLAY_FLUSH = 6,
} bd_argb_overlay_cmd_e;
typedef struct bd_argb_overlay_s {
int64_t pts;
uint8_t plane;
uint8_t cmd;
/* following fileds are used only when not using application-allocated
* frame buffer
*/
/* destination clip on the overlay plane */
uint16_t x;
uint16_t y;
uint16_t w;
uint16_t h;
uint16_t stride;
const uint32_t * argb;
} BD_ARGB_OVERLAY;
typedef struct bd_argb_buffer_s {
/* optional lock / unlock functions
* - Set by application
* - Called when buffer is accessed or modified
*/
void (*lock) (struct bd_argb_buffer_s *);
void (*unlock)(struct bd_argb_buffer_s *);
/* ARGB frame buffers
* - Allocated by application (BD_ARGB_OVERLAY_INIT).
* - Buffer can be freed after BD_ARGB_OVERLAY_CLOSE.
* - buffer can be replaced in overlay callback or lock().
*/
uint32_t *buf[4];
/* size of buffers
* - Set by application
* - If the buffer size is smaller than the size requested in BD_ARGB_OVERLAY_INIT,
* the buffer points only to the dirty area.
*/
int width;
int height;
struct {
uint16_t x0;
uint16_t y0;
uint16_t x1;
uint16_t y1;
} dirty[2];
} BD_ARGB_BUFFER;
#ifdef __cplusplus
}
#endif
#endif // BD_OVERLAY_H_
bd_refcnt_dec
BD_PUBLIC void bd_refcnt_dec(const void *)
Release reference-counted object.
bd_argb_overlay_cmd_e
bd_argb_overlay_cmd_e
ARGB overlay event type.
Definition overlay.h:157
BD_ARGB_OVERLAY_INIT
@ BD_ARGB_OVERLAY_INIT
Initialize overlay plane.
Definition overlay.h:159
BD_ARGB_OVERLAY_CLOSE
@ BD_ARGB_OVERLAY_CLOSE
Close overlay plane.
Definition overlay.h:160
BD_ARGB_OVERLAY_DRAW
@ BD_ARGB_OVERLAY_DRAW
Draw ARGB image on plane.
Definition overlay.h:165
BD_ARGB_OVERLAY_FLUSH
@ BD_ARGB_OVERLAY_FLUSH
All changes have been done, flush overlay to display at given pts.
Definition overlay.h:166
bd_overlay_cmd_e
bd_overlay_cmd_e
YUV overlay event type.
Definition overlay.h:58
BD_OVERLAY_INIT
@ BD_OVERLAY_INIT
Initialize overlay plane.
Definition overlay.h:60
BD_OVERLAY_WIPE
@ BD_OVERLAY_WIPE
Clear area.
Definition overlay.h:68
BD_OVERLAY_HIDE
@ BD_OVERLAY_HIDE
Overlay is empty and can be hidden.
Definition overlay.h:69
BD_OVERLAY_DRAW
@ BD_OVERLAY_DRAW
Draw bitmap.
Definition overlay.h:67
BD_OVERLAY_CLEAR
@ BD_OVERLAY_CLEAR
Clear overlay plane.
Definition overlay.h:66
BD_OVERLAY_CLOSE
@ BD_OVERLAY_CLOSE
Close overlay plane.
Definition overlay.h:61
BD_OVERLAY_FLUSH
@ BD_OVERLAY_FLUSH
All changes have been done, flush overlay to display at given pts.
Definition overlay.h:71
bd_overlay_plane_e
bd_overlay_plane_e
Overlay plane.
Definition overlay.h:46
BD_OVERLAY_IG
@ BD_OVERLAY_IG
Interactive Graphics plane (on top of PG plane).
Definition overlay.h:48
BD_OVERLAY_PG
@ BD_OVERLAY_PG
Presentation Graphics plane.
Definition overlay.h:47
bd_refcnt_inc
BD_PUBLIC const void * bd_refcnt_inc(const void *)
Hold reference-counted object.
BD_ARGB_BUFFER
Application-allocated frame buffer for ARGB overlays.
Definition overlay.h:201
BD_ARGB_BUFFER::unlock
void(* unlock)(struct bd_argb_buffer_s *)
Unlock buffer (write complete).
Definition overlay.h:207
BD_ARGB_BUFFER::height
int height
overlay buffer height (pixels)
Definition overlay.h:223
BD_ARGB_BUFFER::buf
uint32_t * buf[4]
[0] - PG plane, [1] - IG plane.
Definition overlay.h:215
BD_ARGB_BUFFER::width
int width
overlay buffer width (pixels)
Definition overlay.h:222
BD_ARGB_BUFFER::lock
void(* lock)(struct bd_argb_buffer_s *)
Lock (or prepare) buffer for writing.
Definition overlay.h:206
BD_ARGB_BUFFER::x0
uint16_t x0
top-left x coordinate
Definition overlay.h:230
BD_ARGB_BUFFER::y0
uint16_t y0
top-left y coordinate
Definition overlay.h:231
BD_ARGB_BUFFER::x1
uint16_t x1
bottom-down x coordinate
Definition overlay.h:232
BD_ARGB_BUFFER::y1
uint16_t y1
bottom-down y coordinate
Definition overlay.h:233
BD_ARGB_OVERLAY
ARGB overlay event.
Definition overlay.h:172
BD_ARGB_OVERLAY::y
uint16_t y
top-left y coordinate
Definition overlay.h:183
BD_ARGB_OVERLAY::pts
int64_t pts
Event timestamp, on video grid.
Definition overlay.h:173
BD_ARGB_OVERLAY::h
uint16_t h
region height
Definition overlay.h:185
BD_ARGB_OVERLAY::argb
const uint32_t * argb
ARGB image data, 'h' lines, line stride 'stride' pixels.
Definition overlay.h:188
BD_ARGB_OVERLAY::cmd
uint8_t cmd
Overlay event type (bd_argb_overlay_cmd_e).
Definition overlay.h:175
BD_ARGB_OVERLAY::plane
uint8_t plane
Overlay plane (bd_overlay_plane_e).
Definition overlay.h:174
BD_ARGB_OVERLAY::x
uint16_t x
top-left x coordinate
Definition overlay.h:182
BD_ARGB_OVERLAY::stride
uint16_t stride
ARGB buffer stride.
Definition overlay.h:187
BD_ARGB_OVERLAY::w
uint16_t w
region width
Definition overlay.h:184
BD_OVERLAY
YUV overlay event.
Definition overlay.h:101
BD_OVERLAY::cmd
uint8_t cmd
Overlay event type (bd_overlay_cmd_e).
Definition overlay.h:104
BD_OVERLAY::palette
const BD_PG_PALETTE_ENTRY * palette
overlay palette (256 entries)
Definition overlay.h:113
BD_OVERLAY::x
uint16_t x
top-left x coordinate
Definition overlay.h:108
BD_OVERLAY::palette_update_flag
uint8_t palette_update_flag
Set if only overlay palette is changed.
Definition overlay.h:106
BD_OVERLAY::pts
int64_t pts
Timestamp, on video grid.
Definition overlay.h:102
BD_OVERLAY::y
uint16_t y
top-left y coordinate
Definition overlay.h:109
BD_OVERLAY::w
uint16_t w
region width
Definition overlay.h:110
BD_OVERLAY::plane
uint8_t plane
Overlay plane (bd_overlay_plane_e).
Definition overlay.h:103
BD_OVERLAY::h
uint16_t h
region height
Definition overlay.h:111
BD_OVERLAY::img
const BD_PG_RLE_ELEM * img
RLE-compressed overlay image.
Definition overlay.h:114
BD_PG_PALETTE_ENTRY
Overlay palette entry.
Definition overlay.h:83
BD_PG_PALETTE_ENTRY::T
uint8_t T
Transparency ( 0...255).
Definition overlay.h:87
BD_PG_PALETTE_ENTRY::Cb
uint8_t Cb
Cb component (16...240).
Definition overlay.h:86
BD_PG_PALETTE_ENTRY::Y
uint8_t Y
Y component (16...235).
Definition overlay.h:84
BD_PG_PALETTE_ENTRY::Cr
uint8_t Cr
Cr component (16...240).
Definition overlay.h:85
BD_PG_RLE_ELEM
RLE element.
Definition overlay.h:93
BD_PG_RLE_ELEM::len
uint16_t len
RLE run length.
Definition overlay.h:94
BD_PG_RLE_ELEM::color
uint16_t color
palette index
Definition overlay.h:95