1 /*
2  * This file is part of libbluray
3  * Copyright (C) 2013  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 
20 #if !defined(_BD_TEXTST_H_)
21 #define _BD_TEXTST_H_
22 
23 #include "pg.h"
24 
25 #include <stdint.h>
26 
27 
28 #define BD_TEXTST_FLOW_LEFT_RIGHT  1  /* Left-to-Right character progression, Top-to-Bottom line progression */
29 #define BD_TEXTST_FLOW_RIGHT_LEFT  2  /* Right-to-Left character progression, Top-to-Bottom line progression */
30 #define BD_TEXTST_FLOW_TOP_BOTTOM  3  /* Top-to-Bottom character progression, Right-to-Left line progression */
31 
32 #define BD_TEXTST_HALIGN_LEFT   1
33 #define BD_TEXTST_HALIGN_CENTER 2
34 #define BD_TEXTST_HALIGN_RIGHT  3
35 
36 #define BD_TEXTST_VALIGN_TOP    1
37 #define BD_TEXTST_VALIGN_MIDDLE 2
38 #define BD_TEXTST_VALIGN_BOTTOM 3
39 
40 #define BD_TEXTST_FONT_OUTLINE_THIN   1
41 #define BD_TEXTST_FONT_OUTLINE_MEDIUM 2
42 #define BD_TEXTST_FONT_OUTLINE_THICK  3
43 
44 #define BD_TEXTST_DATA_STRING      1
45 #define BD_TEXTST_DATA_FONT_ID     2
46 #define BD_TEXTST_DATA_FONT_STYLE  3
47 #define BD_TEXTST_DATA_FONT_SIZE   4
48 #define BD_TEXTST_DATA_FONT_COLOR  5
49 #define BD_TEXTST_DATA_NEWLINE     0x0a
50 #define BD_TEXTST_DATA_RESET_STYLE 0x0b
51 
52 
53 typedef struct {
54     uint16_t xpos;
55     uint16_t ypos;
56     uint16_t width;
57     uint16_t height;
58 } BD_TEXTST_RECT;
59 
60 typedef struct {
61     BD_TEXTST_RECT region;
62     uint8_t        background_color; /* palette entry id ref */
63 } BD_TEXTST_REGION_INFO;
64 
65 typedef struct {
66     uint8_t bold : 1;
67     uint8_t italic : 1;
68     uint8_t outline_border : 1;
69 } BD_TEXTST_FONT_STYLE;
70 
71 typedef struct {
72     uint8_t               region_style_id;
73     BD_TEXTST_REGION_INFO region_info;
74     BD_TEXTST_RECT        text_box;          /* relative to region */
75     uint8_t               text_flow;         /* BD_TEXTST_FLOW_* */
76     uint8_t               text_halign;       /* BD_TEXTST_HALIGN_* */
77     uint8_t               text_valign;       /* BD_TEXTST_VALIGN_* */
78     uint8_t               line_space;
79     uint8_t               font_id_ref;
80     BD_TEXTST_FONT_STYLE  font_style;
81     uint8_t               font_size;
82     uint8_t               font_color;        /* palette entry id ref */
83     uint8_t               outline_color;     /* palette entry id ref */
84     uint8_t               outline_thickness; /* BD_TEXTST_FONT_OUTLINE_* */
85 } BD_TEXTST_REGION_STYLE;
86 
87 typedef struct {
88     uint8_t user_style_id;
89     int16_t region_hpos_delta;
90     int16_t region_vpos_delta;
91     int16_t text_box_hpos_delta;
92     int16_t text_box_vpos_delta;
93     int16_t text_box_width_delta;
94     int16_t text_box_height_delta;
95     int8_t  font_size_delta;
96     int8_t  line_space_delta;
97 } BD_TEXTST_USER_STYLE;
98 
99 typedef struct {
100     uint8_t type;  /* BD_TEXTST_DATA_* */
101 
102     union {
103         uint8_t font_id_ref;
104         uint8_t font_size;
105         uint8_t font_color;
106         struct {
107             BD_TEXTST_FONT_STYLE style;
108             uint8_t              outline_color;
109             uint8_t              outline_thickness;
110         } style;
111         struct {
112             uint8_t length;
113             uint8_t string[1];
114         } text;
115     } data;
116 } BD_TEXTST_DATA;
117 
118 typedef struct {
119     uint8_t         continous_present_flag;
120     uint8_t         forced_on_flag;
121     uint8_t         region_style_id_ref;
122 
123     unsigned        elem_count;
124     BD_TEXTST_DATA *elem; /* note: variable-sized elements */
125 
126     unsigned        line_count;
127 } BD_TEXTST_DIALOG_REGION;
128 
129 /*
130  * segments
131  */
132 
133 typedef struct {
134     uint8_t                 player_style_flag;
135     uint8_t                 region_style_count;
136     uint8_t                 user_style_count;
137     BD_TEXTST_REGION_STYLE *region_style;
138     BD_TEXTST_USER_STYLE   *user_style;
139     BD_PG_PALETTE_ENTRY     palette[256];
140 } BD_TEXTST_DIALOG_STYLE;
141 
142 typedef struct {
143     int64_t                  start_pts;
144     int64_t                  end_pts;
145 
146     BD_PG_PALETTE_ENTRY     *palette_update;
147 
148     uint8_t                  region_count;
149     BD_TEXTST_DIALOG_REGION  region[2];
150 
151 } BD_TEXTST_DIALOG_PRESENTATION;
152 
153 #endif // _BD_TEXTST_H_
154