1 /*
2  * Copyright (C) 2000-2018 the xine project
3  *
4  * This file is part of xine, a free video player.
5  *
6  * xine is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * xine is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19  */
20 
21 #ifndef HAVE_VIDEO_OVERLAY_H
22 #define HAVE_VIDEO_OVERLAY_H
23 
24 #include <xine/xine_internal.h>
25 
26 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
27 #define CLUT_Y_CR_CB_INIT(_y,_cr,_cb)   {.y = (_y), .cr = (_cr), .cb = (_cb) }
28 #elif defined(__GNUC__)
29 #define CLUT_Y_CR_CB_INIT(_y,_cr,_cb)	{y: (_y), cr: (_cr), cb: (_cb)}
30 #else
31 #define CLUT_Y_CR_CB_INIT(_y,_cr,_cb)	{ (_cb), (_cr), (_y) }
32 #endif
33 
34 #define MAX_OBJECTS   50
35 #define MAX_EVENTS    50
36 #define MAX_SHOWING   (5 + 16)
37 
38 #define OVERLAY_EVENT_NULL             0
39 #define OVERLAY_EVENT_SHOW             1
40 #define OVERLAY_EVENT_HIDE             2
41 #define OVERLAY_EVENT_MENU_BUTTON      3
42 #define OVERLAY_EVENT_FREE_HANDLE      8 /* Frees a handle, previous allocated via get_handle */
43 
44 typedef struct video_overlay_object_s {
45   int32_t	 handle;       /* Used to match Show and Hide events. */
46   uint32_t	 object_type;  /* 0=Subtitle, 1=Menu */
47   int64_t        pts;          /* Needed for Menu button compares */
48   vo_overlay_t  *overlay;      /* The image data. */
49   uint32_t	*palette;      /* If NULL, no palette contained in this event. */
50   uint32_t       palette_type; /* 1 Y'CrCB, 2 R'G'B' */
51 } video_overlay_object_t;
52 
53 /* This will hold all details of an event item, needed for event queue to function */
54 typedef struct video_overlay_event_s {
55   int64_t	 vpts;        /* Time when event will action. 0 means action now */
56 /* Once video_out blend_yuv etc. can take rle_elem_t with Colour, blend and length information.
57  * we can remove clut and blend from this structure.
58  * This will allow for many more colours for OSD.
59  */
60   uint32_t	 event_type;  /* Show SPU, Show OSD, Hide etc. */
61   video_overlay_object_t   object; /* The image data. */
62 } video_overlay_event_t;
63 
64 video_overlay_manager_t *_x_video_overlay_new_manager(xine_t *) XINE_MALLOC XINE_PROTECTED;
65 
66 /* Transport color matrix setting inside those unused "foo" fields.
67    Guard against uninitialized values. */
68 #define _X_SET_CLUT_CM(clut,color_matrix) { \
69   uint8_t *q = (uint8_t *)clut; \
70   q[3]  = 'X'; \
71   q[7]  = 'C'; \
72   q[11] = 'M'; \
73   q[15] = color_matrix; \
74 }
75 
76 void _x_overlay_clut_yuv2rgb(vo_overlay_t *overlay, int video_color_matrix) XINE_PROTECTED;
77 void _x_overlay_to_argb32(const vo_overlay_t *overlay, uint32_t *rgba, int stride, const char *format) XINE_PROTECTED;
78 
79 #endif
80