Fix integer overflow in ft_rendered_size_line
[ilaris-y4m-tools.git] / yuv4mpeg.hpp
blob04890b584eee4a2a0289fc143a61746056b34749
1 #ifndef _yuv4mpeg_hpp_included_
2 #define _yuv4mpeg_hpp_included_
4 #include <cstdint>
5 #include <string>
6 #include <vector>
7 #include "parseval.hpp"
9 regex_results yuv4mpeg_find_extension(const std::vector<std::string>& exts, const std::string& regex);
10 void yuv4mpeg_delete_extensions(std::vector<std::string>& exts, const std::string& regex);
12 struct yuv4mpeg_stream_header
14 yuv4mpeg_stream_header();
15 yuv4mpeg_stream_header(const std::string& str);
16 yuv4mpeg_stream_header(FILE* pipe);
17 operator std::string() const;
18 regex_results find_extension(const std::string& regex) const
20 return yuv4mpeg_find_extension(extension, regex);
22 void delete_extensions(const std::string& regex) { yuv4mpeg_delete_extensions(extension, regex); }
23 enum interlace_v
25 INT_UNKNOWN = '?',
26 INT_PROGRESSIVE = 'p',
27 INT_TOP_FIRST = 't',
28 INT_BOTTOM_FIRST = 'b',
29 INT_MIXED = 'm'
31 size_t width;
32 size_t height;
33 std::string chroma;
34 char interlace;
35 uint32_t fps_n;
36 uint32_t fps_d;
37 uint32_t sar_n;
38 uint32_t sar_d;
39 std::vector<std::string> extension;
42 struct yuv4mpeg_frame_header
44 yuv4mpeg_frame_header();
45 yuv4mpeg_frame_header(const std::string& str);
46 yuv4mpeg_frame_header(FILE* pipe);
47 operator std::string() const;
48 regex_results find_extension(const std::string& regex) const
50 return yuv4mpeg_find_extension(extension, regex);
52 void delete_extensions(const std::string& regex) { yuv4mpeg_delete_extensions(extension, regex); }
53 enum representation_v
55 REP_TOP_FIRST = 't',
56 REP_TOP_FIRST_REPEAT = 'T',
57 REP_BOTTOM_FIRST = 'b',
58 REP_BOTTOM_FIRST_REPEAT = 'B',
59 REP_PROGRESSIVE = '1',
60 REP_PROGRESSIVE_DBL = '2',
61 REP_PROGRESSIVE_TRIPL = '3'
63 enum temporal_v
65 TMP_PROGRESSIVE = 'p',
66 TMP_INTERLACED = 'i'
68 enum chroma_v
70 CHR_PROGRESIVE = 'p',
71 CHR_INTERLACED = 'i',
72 CHR_UNKNOWN = '?'
74 char representation;
75 char temporal;
76 char chroma;
77 uint32_t duration;
78 std::vector<std::string> extension;
81 void mark_pipe_as_binary(FILE* pipe);
82 void read_or_die(FILE* pipe, void* data, size_t datasize);
83 bool read_or_die2(FILE* pipe, void* data, size_t datasize);
84 bool read_line2(FILE* pipe, std::string& str);
85 void write_or_die(FILE* pipe, const void* data, size_t datasize);
86 void write_or_die(FILE* pipe, const std::string& data);
87 void get_512_scaling(size_t w, size_t h, uint32_t sar_n, uint32_t sar_d, size_t& w512, size_t& h512);
89 #endif