mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ndarray_generic.h
Go to the documentation of this file.
1 #ifndef MF_NDARRAY_GENERIC_H_
2 #define MF_NDARRAY_GENERIC_H_
3 
4 #include "frame_format.h"
5 #include "ndarray_view_generic.h"
6 #include "../ndarray.h"
7 #include "../../elem.h"
8 #include "../../os/memory.h"
9 
10 namespace mf {
11 
13 
17  std::size_t frame_length_;
18  std::size_t array_length_;
19 
20  const frame_format& format() const noexcept { return format_; }
21  std::size_t frame_length() const noexcept { return frame_length_; }
22  std::size_t array_length() const noexcept { return array_length_; }
23  std::size_t frame_size() const noexcept { return frame_length_ * format_.stride(); }
24 
26  format_(format), frame_length_(frame_length), array_length_(array_length) { }
27 };
28 
29 
31 
32 template<typename Allocator = raw_allocator>
33 class ndarray_generic : public ndarray<2, byte, Allocator> {
35 
36 private:
37  frame_format format_;
38 
39 public:
41 
42  ndarray_generic(const ndarray_generic_properties&, std::size_t padding = 0, const Allocator& = Allocator());
43  explicit ndarray_generic(const ndarray_generic&) = default;
44 
45  const frame_format& format() const noexcept { return format_; }
46 
47  view_type view() { return view_type(base::view(), format_); }
48 };
49 
50 
51 }
52 
53 #include "ndarray_generic.tcc"
54 
55 #endif
std::size_t frame_length() const noexcept
Definition: ndarray_generic.h:21
Generic ndarray_view where lower dimension(s) are type-erased.
Definition: ndarray_view_generic.h:25
ndarray_generic(const ndarray_generic_properties &, std::size_t padding=0, const Allocator &=Allocator())
Definition: ndarray_generic.tcc:5
const frame_format & format() const noexcept
Definition: ndarray_generic.h:45
ndarray_generic_properties(const frame_format &format, std::size_t frame_length, std::size_t array_length)
Definition: ndarray_generic.h:25
std::size_t padding() const noexcept
Definition: ndarray.h:104
std::size_t frame_length_
Number of elements in one frame.
Definition: ndarray_generic.h:17
Multidimensional array container.
Definition: ndarray.h:26
view_type view()
Definition: ndarray_generic.h:47
std::size_t frame_size() const noexcept
Definition: ndarray_generic.h:23
view_type view()
Definition: ndarray.h:81
std::size_t array_length_
Number of frames.
Definition: ndarray_generic.h:18
std::size_t stride() const noexcept
Definition: frame_format.h:54
Array container with type erased multidimensional frames.
Definition: ndarray_generic.h:33
ndarray_view_generic< 2 > view_type
Definition: ndarray_generic.h:40
frame_format format_
Element type and alignment of frame.
Definition: ndarray_generic.h:16
Properties for construction of ndarray_generic and derived container objects.
Definition: ndarray_generic.h:15
const frame_format & format() const noexcept
Definition: ndarray_generic.h:20
std::size_t array_length() const noexcept
Definition: ndarray_generic.h:22
Format information of type-erased frame of ndarray_view_generic.
Definition: frame_format.h:14