Fix integer overflow in ft_rendered_size_line
[ilaris-y4m-tools.git] / rendertext.hpp
blobfc85c1e3fbe03ca4bb4cdb43d446335a80e67dad
1 #ifndef _rendertext_hpp_included_
2 #define _rendertext_hpp_included_
4 #include <map>
5 #include "png.hpp"
6 #include "yuv4mpeg.hpp"
7 #include "marker.hpp"
9 struct text_render_parameters
11 text_render_parameters();
12 std::string fontfile;
13 unsigned fontsize;
14 signed text_alignment;
15 unsigned text_spacing;
16 long fontface;
17 uint32_t fg_color;
18 uint32_t halo_color;
19 uint32_t bg_color;
20 signed halo_thickness;
21 bool argument(const std::string& arg);
22 parsed_png& render(const std::string& str);
23 std::pair<size_t, size_t> render_size(const std::string& str);
26 struct pre_subtitle
28 pre_subtitle();
29 ~pre_subtitle();
30 parsed_png* image;
31 ssize_t xpos;
32 ssize_t ypos;
33 bool xabsolute;
34 bool yabsolute;
35 timemarker start;
36 timemarker duration;
39 struct subtitle
41 subtitle(const pre_subtitle& presub, const yuv4mpeg_stream_header& strmh);
42 ~subtitle();
43 uint8_t* data;
44 uint32_t* alpha;
45 size_t width;
46 size_t height;
47 size_t planesep;
48 unsigned planes;
49 bool bits16;
50 ssize_t x;
51 ssize_t y;
52 uint64_t frame;
53 uint64_t duration;
54 static std::vector<subtitle*> from_presub(const std::vector<pre_subtitle*>& presubs,
55 const yuv4mpeg_stream_header& strmh);
56 void stamp(uint8_t* data, size_t iwidth, size_t iheight, uint64_t frameno) const;
59 struct subtitle_render_context
61 subtitle_render_context();
62 text_render_parameters tparams;
63 ssize_t xpos;
64 ssize_t ypos;
65 bool xabsolute;
66 bool yabsolute;
67 timemarker duration;
68 bool argument(const std::string& arg, pre_subtitle*& presub);
69 bool argument(const std::string& arg, std::vector<pre_subtitle*>& presubs)
71 pre_subtitle* presub = NULL;
72 bool ret = argument(arg, presub);
73 if(presub)
74 presubs.push_back(presub);
75 return ret;
79 #endif