JPC-RR r11.7
[jpcrr.git] / streamtools / hardsubs.hpp
blob078f675192c9b3267096f27e814aae3174f1bf36
1 #ifndef _hardsubs__hpp__included__
2 #define _hardsubs__hpp__included__
4 #include "png-out.hpp"
5 #include "newpacket.hpp"
6 #include "resize.hpp"
7 #include <list>
8 #include <string>
10 #define ALIGN_LEFT 0
11 #define ALIGN_TOP 0
12 #define ALIGN_CENTER 1
13 #define ALIGN_RIGHT 2
14 #define ALIGN_BOTTOM 2
15 #define ALIGN_CUSTOM 3
17 struct subtitle;
19 #define DEFAULT_FONT_SIZE 16
20 #define DEFAULT_HALO_THICKNESS 0
21 #define DEFAULT_FOREGROUND_R 255
22 #define DEFAULT_FOREGROUND_G 255
23 #define DEFAULT_FOREGROUND_B 255
24 #define DEFAULT_FOREGROUND_A 255
25 #define DEFAULT_HALO_R 0
26 #define DEFAULT_HALO_G 0
27 #define DEFAULT_HALO_B 0
28 #define DEFAULT_HALO_A 255
29 #define DEFAULT_BACKGROUND_R 0
30 #define DEFAULT_BACKGROUND_G 0
31 #define DEFAULT_BACKGROUND_B 0
32 #define DEFAULT_BACKGROUND_A 0
33 #define DEFAULT_ALIGN_TYPE ALIGN_CENTER
34 #define DEFAULT_SPACING 1
35 #define DEFAULT_DURATION 5000000000ULL
36 #define DEFAULT_XALIGN_TYPE ALIGN_CENTER
37 #define DEFAULT_YALIGN_TYPE ALIGN_BOTTOM
39 struct hardsub_render_settings
41 std::string font_name;
42 uint32_t font_size;
43 uint32_t halo_thickness;
44 uint8_t foreground_r;
45 uint8_t foreground_g;
46 uint8_t foreground_b;
47 uint8_t foreground_a;
48 uint8_t halo_r;
49 uint8_t halo_g;
50 uint8_t halo_b;
51 uint8_t halo_a;
52 uint8_t background_r;
53 uint8_t background_g;
54 uint8_t background_b;
55 uint8_t background_a;
56 uint32_t align_type;
57 uint32_t spacing;
58 std::string text;
59 image_frame_rgbx* operator()();
62 struct hardsub_settings
64 hardsub_settings();
65 void reset();
66 struct hardsub_render_settings rsettings;
67 uint64_t timecode;
68 uint64_t duration;
69 int xalign_type;
70 int32_t xalign;
71 int yalign_type;
72 int32_t yalign;
73 subtitle* operator()();
76 struct subtitle
78 uint64_t timecode;
79 uint64_t duration;
80 int xalign_type;
81 int32_t xalign;
82 int yalign_type;
83 int32_t yalign;
84 struct hardsub_render_settings used_settings;
85 image_frame_rgbx* subtitle_img;
86 ~subtitle();
90 void subtitle_set_resolution(uint32_t w, uint32_t h);
91 void render_subtitle(image_frame_rgbx& bottom, struct subtitle& sub);
92 std::list<subtitle*> parse_subtitle_option(struct hardsub_settings& settings, const std::string& option);
93 void print_hardsubs_help(const std::string& prefix);
94 std::list<subtitle*> process_hardsubs_options(struct hardsub_settings& settings, const std::string& prefix, int argc, char** argv);
95 void subtitle_update_parameter(std::list<subtitle*>& subs, unsigned char parameter, const std::string& value);
96 void subtitle_process_gameinfo(std::list<subtitle*>& subs, struct packet& p);
98 #endif