13#include <libavformat/avformat.h>
20 std::atomic<int> m_refCount;
29 : m_frame(frame), m_refCount(1), m_pts(pts), m_isValid(
isValid) {
36 av_frame_free(&m_frame);
41 if (--m_refCount == 0) {
58 rhs.m_videoFrame =
nullptr;
62 ++rhs.m_videoFrame->m_refCount;
66 if (this->m_videoFrame) { this->m_videoFrame->
unref(); }
67 this->m_videoFrame = rhs.m_videoFrame;
68 rhs.m_videoFrame =
nullptr;
74 if (this->m_videoFrame) { this->m_videoFrame->
unref(); }
75 this->m_videoFrame = rhs.m_videoFrame;
76 ++m_videoFrame->m_refCount;
83 if (m_videoFrame) { m_videoFrame->
unref(); }
87 return this->m_videoFrame == frame.m_videoFrame;
98 return m_videoFrame && m_videoFrame->m_isValid;
103 return m_videoFrame->m_pts;
106 [[nodiscard]] std::byte *
getY()
const {
107 return !m_videoFrame->m_frame ? nullptr :
reinterpret_cast<std::byte *
>(m_videoFrame->m_frame->data[0]);
110 [[nodiscard]] std::byte *
getU()
const {
111 return !m_videoFrame->m_frame ? nullptr :
reinterpret_cast<std::byte *
>(m_videoFrame->m_frame->data[1]);
114 [[nodiscard]] std::byte *
getV()
const {
115 return !m_videoFrame->m_frame ? nullptr :
reinterpret_cast<std::byte *
>(m_videoFrame->m_frame->data[2]);
119 return !m_videoFrame->m_frame ? 0 : m_videoFrame->m_frame->linesize[0];
123 return !m_videoFrame->m_frame ? 0 : m_videoFrame->m_frame->width;
127 return !m_videoFrame->m_frame ? 0 : m_videoFrame->m_frame->height;
133 && this->getWidth() == frame.
getWidth()
134 && this->getHeight() == frame.
getHeight()
151 AudioFrame() : m_data(nullptr), m_len(0), m_pts(std::numeric_limits<double>::quiet_NaN()) {}
153 AudioFrame(std::byte *data,
int len,
double pts) : m_data(data), m_len(len), m_pts(pts) {}
Definition: frame.hpp:145
int getDataLen() const
Definition: frame.hpp:163
AudioFrame()
Definition: frame.hpp:151
AudioFrame(std::byte *data, int len, double pts)
Definition: frame.hpp:153
std::byte * getSampleData() const
Definition: frame.hpp:159
bool isValid()
Definition: frame.hpp:155
double getPTS() const
Definition: frame.hpp:167
void unref()
Definition: frame.hpp:40
VideoFrame(AVFrame *frame, double pts, const bool isValid)
Definition: frame.hpp:28
static std::atomic< int > totalCount
Definition: frame.hpp:26
~VideoFrame()
Definition: frame.hpp:33
std::byte * getV() const
Definition: frame.hpp:114
VideoFrameRef & operator=(const VideoFrameRef &rhs) noexcept
Definition: frame.hpp:72
VideoFrameRef & operator=(VideoFrameRef &&rhs) noexcept
Definition: frame.hpp:65
bool operator==(const VideoFrameRef &frame) const
Definition: frame.hpp:86
VideoFrameRef()
Definition: frame.hpp:55
bool isValid() const
Definition: frame.hpp:97
~VideoFrameRef()
Definition: frame.hpp:82
bool isSameSize(int width, int height) const
Definition: frame.hpp:139
VideoFrameRef(VideoFrameRef &&rhs) noexcept
Definition: frame.hpp:57
bool isSameSize(const VideoFrameRef &frame) const
Definition: frame.hpp:130
double getPTS() const
Definition: frame.hpp:102
int getWidth() const
Definition: frame.hpp:122
int getLineSize() const
Definition: frame.hpp:118
VideoFrameRef(AVFrame *frame, bool isValid, double pts)
Definition: frame.hpp:51
std::byte * getU() const
Definition: frame.hpp:110
bool operator!=(const VideoFrameRef &frame) const
Definition: frame.hpp:90
std::byte * getY() const
Definition: frame.hpp:106
VideoFrameRef(const VideoFrameRef &rhs)
Definition: frame.hpp:61
int getHeight() const
Definition: frame.hpp:126
INCLUDE_FFMPEG_BEGIN INCLUDE_FFMPEG_END typedef std::function< void(AVFrame *)> FrameFreeFunc
Definition: frame.hpp:16
#define INCLUDE_FFMPEG_END
Definition: ponyplayer.h:26