RAII container for reading a single frame and managing the state associated with that
| 134 | /// RAII container for reading a single frame and managing the state associated |
| 135 | /// with that |
| 136 | class FrameReader { |
| 137 | public: |
| 138 | FrameReader(); |
| 139 | ~FrameReader(); |
| 140 | |
| 141 | std::shared_ptr<Array> read_frame( |
| 142 | std::string filename, |
| 143 | std::shared_ptr<Array> destination, |
| 144 | AVFormatContext* format_context, |
| 145 | AVCodecContext* decoder_context, |
| 146 | AVStream* stream); |
| 147 | |
| 148 | private: |
| 149 | /// the input packet (bytes from the input file) |
| 150 | AVPacket* packet_; |
| 151 | |
| 152 | /// the frame from the decoder (may be on the gpu/hw) |
| 153 | AVFrame* frame_; |
| 154 | |
| 155 | /// optional, the frame in main memory |
| 156 | AVFrame* cpuFrame_; |
| 157 | |
| 158 | /// context used to do format translation, e.g. YUV420 to RGB |
| 159 | SwsContext* scalerContext_; |
| 160 | |
| 161 | enum State { FRAME_READER_READING, FRAME_READER_FLUSHING, FRAME_READER_EOF }; |
| 162 | |
| 163 | State state_; |
| 164 | |
| 165 | std::shared_ptr<Array> decode_( |
| 166 | std::string filename, |
| 167 | std::shared_ptr<Array> destination, |
| 168 | AVCodecContext* decoder_context); |
| 169 | }; |
| 170 | |
| 171 | VideoReaderState::VideoReaderState(const std::string& filename) |
| 172 | : filename_(filename) { |
nothing calls this directly
no outgoing calls
no test coverage detected