mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
yuv_importer.h
Go to the documentation of this file.
1 #ifndef MF_YUV_IMPORTER_H_
2 #define MF_YUV_IMPORTER_H_
3 
4 #include <fstream>
5 #include <memory>
6 #include "../color.h"
7 #include "../io/seekable_frame_importer.h"
8 #include "../ndarray/ndarray_view.h"
9 
10 namespace mf {
11 
13 class yuv_importer : public seekable_frame_importer<2, ycbcr_color> {
15 
16 private:
17  using char_type = std::ifstream::char_type;
18 
19  std::ifstream file_;
20  std::size_t file_size_;
21  std::size_t current_time_ = 0;
22 
23  std::unique_ptr<char_type[]> frame_buffer_;
24  std::streamsize frame_size_;
28 
29  std::size_t chroma_scale_y_;
30  std::size_t chroma_scale_x_;
31 
32 public:
33  yuv_importer(const std::string& filename, const ndsize<2>& frame_shape, int sampling);
34 
35  void read_frame(const ndarray_view<2, ycbcr_color>&) override;
36  bool reached_end() const override;
37 
38  time_unit current_time() const override;
39  time_unit total_duration() const override;
40 
41  void seek(time_unit) override;
42 };
43 
44 }
45 
46 #endif
time_unit total_duration() const override
Definition: yuv_importer.cc:72
time_unit current_time() const override
Definition: yuv_importer.cc:67
Seekable frame importer which reads YUV file.
Definition: yuv_importer.h:13
std::ptrdiff_t time_unit
Discrete time unit type.
Definition: common.h:52
Seekable frame importer, abstract base class.
Definition: seekable_frame_importer.h:16
void read_frame(const ndarray_view< 2, ycbcr_color > &) override
Definition: yuv_importer.cc:41
const ndsize< Dim > & frame_shape()
Definition: frame_importer.h:30
void seek(time_unit) override
Definition: yuv_importer.cc:77
Vector of n-dimensional coordinates.
Definition: ndcoord.h:18
yuv_importer(const std::string &filename, const ndsize< 2 > &frame_shape, int sampling)
Definition: yuv_importer.cc:6
bool reached_end() const override
Definition: yuv_importer.cc:62