]> git.sesse.net Git - casparcg/blob - core/frame/pixel_format.h
set svn:eol-style native on .h and .cpp files
[casparcg] / core / frame / pixel_format.h
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
6 * CasparCG 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 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CasparCG 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 CasparCG. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: Robert Nagy, ronag89@gmail.com
20 */
21
22 #pragma once
23
24 #include "../video_format.h"
25
26 #include <common/enum_class.h>
27
28 #include <cstddef>
29 #include <vector>
30
31 namespace caspar { namespace core {
32                 
33 struct pixel_format_def
34 {
35         enum type
36         {
37                 gray = 0,
38                 bgra,
39                 rgba,
40                 argb,
41                 abgr,
42                 ycbcr,
43                 ycbcra,
44                 luma,
45                 bgr,
46                 rgb,
47                 count,
48                 invalid,
49         };
50 };
51 typedef enum_class<pixel_format_def> pixel_format;
52
53 struct pixel_format_desc sealed
54 {
55         struct plane
56         {
57                 int linesize;
58                 int width;
59                 int height;
60                 int size;
61                 int stride;
62
63                 plane() 
64                         : linesize(0)
65                         , width(0)
66                         , height(0)
67                         , size(0)
68                         , stride(0)
69                 {
70                 }
71
72                 plane(int width, int height, int stride)
73                         : linesize(width*stride)
74                         , width(width)
75                         , height(height)
76                         , size(width*height*stride)
77                         , stride(stride)
78                 {
79                 }
80         };
81
82         pixel_format_desc(pixel_format format = core::pixel_format::invalid) 
83                 : format(format)
84         {
85         }
86         
87         pixel_format            format;
88         std::vector<plane>      planes;
89 };
90
91 }}