| 64 | using Micros = std::chrono::microseconds; |
| 65 | |
| 66 | struct ScopedFrame { |
| 67 | AVFrame* frame = nullptr; |
| 68 | |
| 69 | ScopedFrame() : frame(av_frame_alloc()) {} |
| 70 | explicit ScopedFrame(AVFrame* value) : frame(value) {} |
| 71 | |
| 72 | ~ScopedFrame() { |
| 73 | if (frame) |
| 74 | av_frame_free(&frame); |
| 75 | } |
| 76 | |
| 77 | ScopedFrame(const ScopedFrame&) = delete; |
| 78 | ScopedFrame& operator=(const ScopedFrame&) = delete; |
| 79 | |
| 80 | ScopedFrame(ScopedFrame&& other) noexcept : frame(other.frame) { |
| 81 | other.frame = nullptr; |
| 82 | } |
| 83 | |
| 84 | ScopedFrame& operator=(ScopedFrame&& other) noexcept { |
| 85 | if (this != &other) { |
| 86 | if (frame) |
| 87 | av_frame_free(&frame); |
| 88 | frame = other.frame; |
| 89 | other.frame = nullptr; |
| 90 | } |
| 91 | return *this; |
| 92 | } |
| 93 | |
| 94 | AVFrame* get() const { return frame; } |
| 95 | AVFrame* release() { |
| 96 | AVFrame* value = frame; |
| 97 | frame = nullptr; |
| 98 | return value; |
| 99 | } |
| 100 | operator bool() const { return frame != nullptr; } |
| 101 | }; |
| 102 | |
| 103 | struct ScopedPacket { |
| 104 | AVPacket* packet = nullptr; |
no outgoing calls
no test coverage detected